From f2608355c891ff4aabe49c2c3665bb13083c3f8a Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Mon, 12 Nov 2018 14:16:16 +0100 Subject: [PATCH 001/125] CAMEL-12925 - Camel-Slack: Consumer must be able to use a different server than the default one --- .../camel-slack/src/main/docs/slack-component.adoc | 3 ++- .../slack/SlackComponentVerifierExtension.java | 2 +- .../apache/camel/component/slack/SlackConsumer.java | 4 ++-- .../apache/camel/component/slack/SlackEndpoint.java | 13 +++++++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/components/camel-slack/src/main/docs/slack-component.adoc b/components/camel-slack/src/main/docs/slack-component.adoc index a7c5699686628..329fd2d2b1425 100644 --- a/components/camel-slack/src/main/docs/slack-component.adoc +++ b/components/camel-slack/src/main/docs/slack-component.adoc @@ -77,7 +77,7 @@ with the following path and query parameters: |=== -==== Query Parameters (25 parameters): +==== Query Parameters (26 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -86,6 +86,7 @@ with the following path and query parameters: | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | *maxResults* (consumer) | The Max Result for the poll | 10 | String | *sendEmptyMessageWhenIdle* (consumer) | If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. | false | boolean +| *serverUrl* (consumer) | The Server URL of the Slack instance | https://slack.com | String | *token* (consumer) | The token to use | | String | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponentVerifierExtension.java b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponentVerifierExtension.java index 7eb6650dee287..143c532fb2e50 100644 --- a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponentVerifierExtension.java +++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponentVerifierExtension.java @@ -111,7 +111,7 @@ private void verifyCredentials(ResultBuilder builder, Map parame try { HttpClient client = HttpClientBuilder.create().useSystemProperties().build(); - HttpPost httpPost = new HttpPost("https://slack.com/api/channels.list"); + HttpPost httpPost = new HttpPost(parameters.get("serverUrl") + "/api/channels.list"); List params = new ArrayList(); params.add(new BasicNameValuePair("token", token)); diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java index 5c665d5f7bfc5..c9835be4b17f2 100644 --- a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java +++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java @@ -62,7 +62,7 @@ protected int poll() throws Exception { Queue exchanges; HttpClient client = HttpClientBuilder.create().useSystemProperties().build(); - HttpPost httpPost = new HttpPost("https://slack.com/api/channels.history"); + HttpPost httpPost = new HttpPost(slackEndpoint.getServerUrl() + "/api/channels.history"); List params = new ArrayList(); params.add(new BasicNameValuePair("channel", channelId)); if (ObjectHelper.isNotEmpty(timestamp)) { @@ -130,7 +130,7 @@ public void done(boolean doneSync) { private String getChannelId(String channel) throws IOException, ParseException { HttpClient client = HttpClientBuilder.create().useSystemProperties().build(); - HttpPost httpPost = new HttpPost("https://slack.com/api/channels.list"); + HttpPost httpPost = new HttpPost(slackEndpoint.getServerUrl() + "/api/channels.list"); List params = new ArrayList(); params.add(new BasicNameValuePair("token", slackEndpoint.getToken())); diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackEndpoint.java b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackEndpoint.java index 57b7e4ce0a081..1e75df0ccb7d0 100644 --- a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackEndpoint.java +++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackEndpoint.java @@ -54,6 +54,8 @@ public class SlackEndpoint extends ScheduledPollEndpoint { private String token; @UriParam(label = "consumer", defaultValue = "10") private String maxResults = "10"; + @UriParam(label = "consumer", defaultValue = "https://slack.com") + private String serverUrl = "https://slack.com"; /** * Constructor for SlackEndpoint @@ -169,6 +171,17 @@ public void setMaxResults(String maxResult) { this.maxResults = maxResult; } + public String getServerUrl() { + return serverUrl; + } + + /** + * The Server URL of the Slack instance + */ + public void setServerUrl(String serverUrl) { + this.serverUrl = serverUrl; + } + public Exchange createExchange(JSONObject object) { return createExchange(getExchangePattern(), object); } From a8d7d2d64ba37627a932b18c653cddee864b877c Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Mon, 12 Nov 2018 14:17:04 +0100 Subject: [PATCH 002/125] Camel-slack: Removed unused import --- .../java/org/apache/camel/component/slack/SlackEndpoint.java | 1 - 1 file changed, 1 deletion(-) diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackEndpoint.java b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackEndpoint.java index 1e75df0ccb7d0..25cb8c20f658f 100644 --- a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackEndpoint.java +++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackEndpoint.java @@ -24,7 +24,6 @@ import org.apache.camel.Producer; import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.slack.helper.SlackMessage; -import org.apache.camel.impl.DefaultEndpoint; import org.apache.camel.impl.ScheduledPollEndpoint; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; From 9e268156698743e3692e0023e77544f29e221864 Mon Sep 17 00:00:00 2001 From: Andrea Tarocchi Date: Mon, 12 Nov 2018 15:58:11 +0100 Subject: [PATCH 003/125] renamed apiProperties to apiProperty in camel-core/src/main/docs/rest-dsl.adoc fix CAMEL-12929 (#2608) --- camel-core/src/main/docs/rest-dsl.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camel-core/src/main/docs/rest-dsl.adoc b/camel-core/src/main/docs/rest-dsl.adoc index 570cdc003e33c..b5e4fce3604ca 100644 --- a/camel-core/src/main/docs/rest-dsl.adoc +++ b/camel-core/src/main/docs/rest-dsl.adoc @@ -585,7 +585,7 @@ whether the Content-Type and Accept headers from A key without a prefix is a common key for all situations. From Camel 2.17: the options value can use the # notation to refer to a bean to lookup in the Registry -|apiProperties | -|Sets additional options on api level. +|apiProperty | -|Sets additional options on api level. |corsHeaders | -|Allows to configure custom CORS headers. |=== From e21ef60d01abed84b290e760c17c25f89d53172c Mon Sep 17 00:00:00 2001 From: aldettinger Date: Mon, 12 Nov 2018 20:19:56 +0100 Subject: [PATCH 004/125] Explicited the servlet-api dependency version brought by spring-boot-starter-undertow so that its no more overridden by camel-parent --- examples/camel-example-rest-producer/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/camel-example-rest-producer/pom.xml b/examples/camel-example-rest-producer/pom.xml index d3a88e71d1d28..d7c2d99f0378f 100644 --- a/examples/camel-example-rest-producer/pom.xml +++ b/examples/camel-example-rest-producer/pom.xml @@ -58,6 +58,11 @@ pom import + + javax.servlet + javax.servlet-api + 4.0.1 + From de7785ede195fb9453d2125aa0cdcf5e11e20e3c Mon Sep 17 00:00:00 2001 From: Pascal Schumacher Date: Mon, 12 Nov 2018 20:39:44 +0100 Subject: [PATCH 005/125] Update Groovy to version 2.5.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5ce708ee40f51..fe6cf76e750f2 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ 2.5 3.0 1.6.2 - 2.5.3 + 2.5.4 From 5c5259caf4a222301afe0cf525cb322a527a6d8d Mon Sep 17 00:00:00 2001 From: Pascal Schumacher Date: Mon, 12 Nov 2018 21:46:28 +0100 Subject: [PATCH 006/125] Parent POM: Remove unused backport-util-concurrent-version property --- parent/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index 80d1b1f8a1638..f6f9d5ae6a623 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -88,7 +88,6 @@ 8.0.0 8.0.0_1 20.0 - 3.1 5.2_4 2.1.0 1.4.6 From d0e08a8d4c7dc1440f52130e86ba52a2ace943cc Mon Sep 17 00:00:00 2001 From: Pascal Schumacher Date: Mon, 12 Nov 2018 21:50:55 +0100 Subject: [PATCH 007/125] Parent POM: Remove unused commons-digester-1x-version property --- parent/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index f6f9d5ae6a623..79fd41be4787a 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -145,7 +145,6 @@ 1.0.15 1.4 2.5.0 - 1.8.1 2.1 1.3 3.1_7 From 5e34af225e7cebf4ffa92d938e41d0eb46833475 Mon Sep 17 00:00:00 2001 From: Pascal Schumacher Date: Mon, 12 Nov 2018 22:13:06 +0100 Subject: [PATCH 008/125] Parent POM: Remove pdfbox18-version property and dependency management of jempbox, because jempbox is not used by pdfbox 2 --- parent/pom.xml | 6 ------ .../spring-boot-dm/camel-spring-boot-dependencies/pom.xml | 5 ----- 2 files changed, 11 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index 79fd41be4787a..6d7a82bfe884b 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -560,7 +560,6 @@ 4.12.0 1.3.2 1.8.6 - 1.8.16 2.0.12 0.7.1 3.5.1 @@ -4910,11 +4909,6 @@ - - org.apache.pdfbox - jempbox - ${pdfbox18-version} - org.apache.pdfbox fontbox diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml index 0b3b6ce322655..2d1d0f0b92744 100644 --- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml +++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml @@ -3349,11 +3349,6 @@ fontbox 2.0.12 - - org.apache.pdfbox - jempbox - 1.8.16 - org.apache.pdfbox pdfbox From 1ece67412d19215d7fb8fe9675ccd75c65b1d45d Mon Sep 17 00:00:00 2001 From: Maciej Swiderski Date: Wed, 7 Nov 2018 14:33:49 +0100 Subject: [PATCH 009/125] CAMEL-12931 - Upgrade jBPM component to use 7 series with consumer capability to react to produced events by jBPM --- components/camel-jbpm/pom.xml | 71 ++-- .../src/main/docs/jbpm-component.adoc | 175 ++++++++-- .../jbpm/JBPMCamelConsumerAware.java | 29 ++ .../camel/component/jbpm/JBPMComponent.java | 6 +- .../component/jbpm/JBPMConfiguration.java | 73 +++- .../camel/component/jbpm/JBPMConstants.java | 11 +- .../camel/component/jbpm/JBPMConsumer.java | 208 ++++++++++++ .../camel/component/jbpm/JBPMEndpoint.java | 44 +-- .../camel/component/jbpm/JBPMProducer.java | 291 +++++++++------- .../jbpm/emitters/CamelEventEmitter.java | 75 ++++ .../ServiceRegistryBoundEventEmitter.java | 62 ++++ .../listeners/CamelCaseEventListener.java | 286 ++++++++++++++++ .../listeners/CamelProcessEventListener.java | 138 ++++++++ .../listeners/CamelTaskEventListener.java | 321 ++++++++++++++++++ .../jbpm/server/CamelKieServerExtension.java | 225 ++++++++++++ ...kie.server.services.api.KieServerExtension | 1 + .../jbpm/JBPMComponentIntegrationTest.java | 65 +++- parent/pom.xml | 2 +- .../features/src/main/resources/features.xml | 50 ++- 19 files changed, 1883 insertions(+), 250 deletions(-) create mode 100644 components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMCamelConsumerAware.java create mode 100644 components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConsumer.java create mode 100644 components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/CamelEventEmitter.java create mode 100644 components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/ServiceRegistryBoundEventEmitter.java create mode 100644 components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelCaseEventListener.java create mode 100644 components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelProcessEventListener.java create mode 100644 components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelTaskEventListener.java create mode 100644 components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/server/CamelKieServerExtension.java create mode 100644 components/camel-jbpm/src/main/resources/META-INF/services/org.kie.server.services.api.KieServerExtension diff --git a/components/camel-jbpm/pom.xml b/components/camel-jbpm/pom.xml index 6c197d48b9570..2a5a161e5dbdd 100644 --- a/components/camel-jbpm/pom.xml +++ b/components/camel-jbpm/pom.xml @@ -43,32 +43,55 @@ camel-core - org.kie.remote - kie-remote-client + org.kie.server + kie-server-client ${jbpm-version} - - - org.hornetq - hornetq-core-client - - - org.hornetq - hornetq-jms-client - - - org.jboss.spec.javax.jms - jboss-jms-api_1.1_spec - - - org.jboss.spec.javax.xml.ws - jboss-jaxws-api_2.2_spec - - - org.jboss.logging - jboss-logging - - + + + + org.kie + kie-api + ${jbpm-version} + provided + true + + + org.kie + kie-internal + ${jbpm-version} + provided + true + + + org.jbpm + jbpm-services-api + ${jbpm-version} + provided + true + + + org.jbpm + jbpm-case-mgmt-api + ${jbpm-version} + provided + true + + + org.kie.server + kie-server-services-common + ${jbpm-version} + provided + true + + + org.jbpm + jbpm-persistence-api + ${jbpm-version} + provided + true + + org.jboss.logging jboss-logging diff --git a/components/camel-jbpm/src/main/docs/jbpm-component.adoc b/components/camel-jbpm/src/main/docs/jbpm-component.adoc index 70e7796cdde89..46928d21565f4 100644 --- a/components/camel-jbpm/src/main/docs/jbpm-component.adoc +++ b/components/camel-jbpm/src/main/docs/jbpm-component.adoc @@ -4,9 +4,9 @@ *Available as of Camel version 2.6* The *jbpm* component provides integration with Business Process -Management (BPM) Suit http://www.jbpm.org/[jBPM]. It uses -kie-remote-client API to interact with jBPM instance over REST. The -component supports only producer. +Management http://www.jbpm.org/[jBPM]. It uses +kie-server-client API to interact with jBPM instance over REST. The +component supports both producer and consumer. Maven users will need to add the following dependency to their `pom.xml` for this component: @@ -20,6 +20,111 @@ for this component: ------------------------------------------------------------------------------------ +## Consumer + +jBPM Consumer allows to attach routes to + +* ProcessEventListeners +* TaskEventListners +* CaseEventListeners + +### URI format + +[source,java] +--------------------------------------------- +jbpm::events:type:[classifier][?options] +--------------------------------------------- + +==== Path Parameters (3 parameters): + + +[width="100%",cols="2,5,^1,2",options="header"] +|=== +| Name | Description | Default | Type +| *events* | Classifier for the consumer to know which type of data it should attach to | | URL +| *type* | Type of event listener - supports: process, task, case | | String +| *classifier* | Used to distinguish routes for same event type| | String +|=== + +Each route would then receive events when they are being produced by jBPM engine. + +Routes can be defined either in global way - on application level or deployed +together with business assets projects also knows as KJARs. + +Consumers are configured via KieServerExtension that is a pluggable interface to enhance +jBPM with additional capabilities. It reacts to different life cycle phases of the KIE Server +and by that is able to configure individual endpoints properly. + +### KJAR routes + +Create file named `camel-routes.xml` in the root folder of your KJAR (src/main/resources) so it will be automatically +discovered and Camel Context for given KJAR will be created. + +### Global routes + +Create file name `global-camel-routes` in the root of the class path of KIE Server. It will be automatically found and registered +on every KJAR deployed to KIE Server. + + +Example camel-routes.xml file that can be placed in the KJAR + +[source, xml] +---- + + + + + + ${in.header.EventType} == 'beforeProcessStarted' + + + + + + + + ${in.header.EventType} starts with 'before' + + + + +---- + + +### Use of jBPM Component in KIE Server + +To make use of camel-jbpm component in a KIE Server it is as simple as just adding two jars into KIE Server application + +* camel-core +* camel-jbpm + +then start KIE Server and you will see once booted following information in logs + +[source, plain] +---- +Camel KIE Server extension has been successfully registered as server extension +.... + +Route: tasks started and consuming from: jbpm://events:task:test?deploymentId=form-rendering_1.0.0 +Total 2 routes, of which 2 are started +Apache Camel 2.23.0-SNAPSHOT (CamelContext: KIE Server Camel context for container evaluation_1.0.0) started in 0.378 seconds +o.k.server.services.impl.KieServerImpl : Container evaluation_1.0.0 (for release id evaluation:evaluation:1.0.0) successfully started +---- + +To make use of jBPM Consumer jBPM deployment descriptor must also define camel specific event listeners of following types + +* `new org.apache.camel.component.jbpm.listeners.CamelProcessEventListener()` +* `new org.apache.camel.component.jbpm.listeners.CamelTaskEventListener()` +* `new org.apache.camel.component.jbpm.listeners.CamelCaseEventListener()` + +These must be set in either server level of kjar deployment descriptor (use MVEL as resolver type) - see jbpm docs for more details about +deployment descriptors. + +## Producer + +Producer is dedicated to interact with jBPM via kie-server-client that uses exposed REST api of +jBPM (KIE Server). + ### URI format [source,java] @@ -47,40 +152,46 @@ jbpm:connectionURL with the following path and query parameters: -==== Path Parameters (1 parameters): +==== Path Parameters (2 parameters): [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type | *connectionURL* | *Required* The URL to the jBPM server. | | URL +| *eventListenerType* | Sets the event listener type to attach to | | String |=== -==== Query Parameters (25 parameters): +==== Query Parameters (30 parameters): [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type -| *attachmentId* (producer) | attachId to use when retrieving attachments | | Long -| *contentId* (producer) | contentId to use when retrieving attachments | | Long -| *deploymentId* (producer) | *Required* The id of the deployment | | String -| *event* (producer) | the data associated with this event when signalEvent operation is performed | | Object -| *eventType* (producer) | the type of event to use when signalEvent operation is performed | | String -| *identifier* (producer) | identifier the global identifier | | String -| *language* (producer) | The language to use when filtering user tasks | | String -| *maxNumber* (producer) | the maximum number of rules that should be fired | | Integer +| *attachmentId* (common) | attachId to use when retrieving attachments | | Long +| *contentId* (common) | contentId to use when retrieving attachments | | Long +| *deploymentId* (common) | *Required* The id of the deployment | | String +| *emitterSendItems* (common) | Sets if event produced by emitter should be sent as single items or complete collection | | Boolean +| *event* (common) | the data associated with this event when signalEvent operation is performed | | Object +| *eventType* (common) | the type of event to use when signalEvent operation is performed | | String +| *identifier* (common) | identifier the global identifier | | String +| *maxNumber* (common) | the maximum number of rules that should be fired | | Integer +| *page* (common) | The page to use when retrieving user tasks | | Integer +| *pageSize* (common) | The page size to use when retrieving user tasks | | Integer +| *processId* (common) | the id of the process that should be acted upon | | String +| *processInstanceId* (common) | the id of the process instance | | Long +| *targetUserId* (common) | The targetUserId used when delegating a task | | String +| *task* (common) | The task instance to use with task operations | | Task +| *taskId* (common) | the id of the task | | Long +| *timeout* (common) | A timeout value | | Integer +| *userId* (common) | userId to use with task operations | | String +| *value* (common) | the value to assign to the global identifier | | Object +| *workItemId* (common) | the id of the work item | | Long +| *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean +| *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler +| *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern | *operation* (producer) | The operation to perform | startProcess | String -| *processId* (producer) | the id of the process that should be acted upon | | String -| *processInstanceId* (producer) | the id of the process instance | | Long -| *targetUserId* (producer) | The targetUserId used when delegating a task | | String -| *task* (producer) | The task instance to use with task operations | | Task -| *taskId* (producer) | the id of the task | | Long -| *timeout* (producer) | A timeout value | | Integer -| *userId* (producer) | userId to use with task operations | | String -| *value* (producer) | the value to assign to the global identifier | | Object -| *workItemId* (producer) | the id of the work item | | Long | *entities* (advanced) | The potentialOwners when nominateTask operation is performed | | List | *extraJaxbClasses* (advanced) | To load additional classes when working with XML | | Class[] | *parameters* (advanced) | the variables that should be set for various operations | | Map @@ -153,23 +264,29 @@ org.infinispan.notifications.cachelistener.event.Event.Type |CamelJBPMContentId |0 |Long |contentId to use when retrieving attachments -|CamelJBPMEntityList |null |List |The potentialOwners when nominateTask operation is performed +|CamelJBPMEntityList |null |List |The potentialOwners when nominateTask operation is performed -|CamelJBPMStatusList |null |List |The list of status to use when filtering tasks +|CamelJBPMStatusList |null |List |The list of status to use when filtering tasks |======================================================================= ### Example Below is an example route that starts a business process with id -project1.integration-test and deploymentId -org.kie.example:project1:1.0.0-SNAPSHOT +evaluation. To run this example you need jBPM to run locally, easiest is to use single zip +distribution - downloaded from jbpm.org. Next, start it and import Evaluation sample project, build and deploy. +Once done this test can be ran out of the box. [source,java] ---------------------------------------------------------------------------------------------- +Map params = new HashMap<>(); +params.put("employee", "wbadmin"); +params.put("reason", "Camel asks for it"); + from("direct:start") - .setHeader(JBPMConstants.PROCESS_ID, constant("project1.integration-test")) - .to("jbpm:http://localhost:8080/business-central?userName=bpmsAdmin&password=pa$word1" - + "&deploymentId=org.kie.example:project1:1.0.0-SNAPSHOT"); + .setHeader(JBPMConstants.PROCESS_ID, constant("evaluation")) + .setHeader((JBPMConstants.PARAMETERS, params)) + .to("jbpm:http://localhost:8080/kie-server/services/rest/server?userName=wbadmin&password=wbadmin + &deploymentId=evaluation"); ---------------------------------------------------------------------------------------------- ### See Also diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMCamelConsumerAware.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMCamelConsumerAware.java new file mode 100644 index 0000000000000..85b4df2a626ec --- /dev/null +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMCamelConsumerAware.java @@ -0,0 +1,29 @@ +/** + * 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.camel.component.jbpm; + +/** + * Indicates that class implementing this interface should receive (at some point) + * JBPMConsumer instance that is required to operate. + */ +public interface JBPMCamelConsumerAware { + + void addConsumer(JBPMConsumer consumer); + + void removeConsumer(JBPMConsumer consumer); +} diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMComponent.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMComponent.java index f562234ed4740..ed03b515f170b 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMComponent.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMComponent.java @@ -26,7 +26,11 @@ public class JBPMComponent extends DefaultComponent { protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { JBPMConfiguration configuration = new JBPMConfiguration(); - configuration.setConnectionURL(new URL(remaining)); + if (remaining.startsWith("events")) { + configuration.setEventListenerType(remaining.split(":")[1]); + } else { + configuration.setConnectionURL(new URL(remaining)); + } setProperties(configuration, parameters); return new JBPMEndpoint(uri, this, configuration); } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConfiguration.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConfiguration.java index c4a30c7069039..9633aaa765ee6 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConfiguration.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.jbpm; import java.net.URL; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -24,8 +25,6 @@ import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; import org.apache.camel.spi.UriPath; -import org.kie.api.task.model.OrganizationalEntity; -import org.kie.api.task.model.Status; import org.kie.api.task.model.Task; @UriParams @@ -58,7 +57,9 @@ public class JBPMConfiguration { @UriParam private String userId; @UriParam - private String language; + private Integer page = 0; + @UriParam + private Integer pageSize = 10; @UriParam private String targetUserId; @UriParam @@ -68,9 +69,9 @@ public class JBPMConfiguration { @UriParam private Task task; @UriParam(label = "advanced") - private List entities; + private List entities; @UriParam(label = "filter") - private List statuses; + private List statuses; @UriParam(label = "security", secret = true) private String userName; @UriParam(label = "security", secret = true) @@ -81,6 +82,11 @@ public class JBPMConfiguration { private Map parameters; @UriParam(label = "advanced") private Class[] extraJaxbClasses; + @UriParam + private Boolean emitterSendItems; + + @UriPath + private String eventListenerType; public String getOperation() { return operation; @@ -225,15 +231,26 @@ public void setTask(Task task) { this.task = task; } - public String getLanguage() { - return language; + public Integer getPage() { + return page; + } + + /** + * The page to use when retrieving user tasks + */ + public void setPage(Integer page) { + this.page = page; + } + + public Integer getPageSize() { + return pageSize; } /** - * The language to use when filtering user tasks + * The page size to use when retrieving user tasks */ - public void setLanguage(String language) { - this.language = language; + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; } public String getTargetUserId() { @@ -269,25 +286,25 @@ public void setContentId(Long contentId) { this.contentId = contentId; } - public List getEntities() { + public List getEntities() { return entities; } /** * The potentialOwners when nominateTask operation is performed */ - public void setEntities(List entities) { + public void setEntities(List entities) { this.entities = entities; } - public List getStatuses() { + public List getStatuses() { return statuses; } /** * The list of status to use when filtering tasks */ - public void setStatuses(List statuses) { + public void setStatuses(List statuses) { this.statuses = statuses; } @@ -356,4 +373,32 @@ public Class[] getExtraJaxbClasses() { public void setExtraJaxbClasses(Class[] extraJaxbClasses) { this.extraJaxbClasses = extraJaxbClasses; } + + + public String getEventListenerType() { + return eventListenerType; + } + + /** + * Sets the event listener type to attach to + */ + public void setEventListenerType(String eventListenerType) { + this.eventListenerType = eventListenerType; + } + + public Boolean getEmitterSendItems() { + return emitterSendItems; + } + + /** + * Sets if event produced by emitter should be sent as single items or complete collection + */ + public void setEmitterSendItems(Boolean emiterSendItems) { + this.emitterSendItems = emiterSendItems; + } + + @Override + public String toString() { + return "JBPMConfiguration [connectionURL=" + connectionURL + ", operation=" + operation + ", deploymentId=" + deploymentId + ", processInstanceId=" + processInstanceId + ", value=" + value + ", processId=" + processId + ", eventType=" + eventType + ", event=" + event + ", maxNumber=" + maxNumber + ", identifier=" + identifier + ", workItemId=" + workItemId + ", taskId=" + taskId + ", userId=" + userId + ", page=" + page + ", pageSize=" + pageSize + ", targetUserId=" + targetUserId + ", attachmentId=" + attachmentId + ", contentId=" + contentId + ", task=" + task + ", entities=" + entities + ", statuses=" + statuses + ", userName=" + userName + ", password=" + password + ", timeout=" + timeout + ", parameters=" + parameters + ", extraJaxbClasses=" + Arrays.toString(extraJaxbClasses) + ", eventListenerType=" + eventListenerType + "]"; + } } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConstants.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConstants.java index 6b00d02598a99..8341cfd619c81 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConstants.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConstants.java @@ -30,10 +30,17 @@ public interface JBPMConstants { String TASK_ID = "CamelJBPMTaskId"; String TASK = "CamelJBPMTask"; String USER_ID = "CamelJBPMUserId"; - String TARGET_USER_ID = "CamelJBPMTargetUserId"; - String LANGUAGE = "CamelJBPMLanguage"; + String TARGET_USER_ID = "CamelJBPMTargetUserId"; String ATTACHMENT_ID = "CamelJBPMAttachmentId"; String CONTENT_ID = "CamelJBPMContentId"; String ENTITY_LIST = "CamelJBPMEntityList"; String STATUS_LIST = "CamelJBPMStatusList"; + String RESULT_PAGE = "CamelJBPMResultPage"; + String RESULT_PAGE_SIZE = "CamelJBPMResultPageSize"; + + + String JBPM_PROCESS_EVENT_LISTENER = "process"; + String JBPM_TASK_EVENT_LISTENER = "task"; + String JBPM_CASE_EVENT_LISTENER = "case"; + String JBPM_EVENT_EMITTER = "emitter"; } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConsumer.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConsumer.java new file mode 100644 index 0000000000000..6c5c6f9064755 --- /dev/null +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConsumer.java @@ -0,0 +1,208 @@ +/** + * 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.camel.component.jbpm; + +import org.apache.camel.AsyncCallback; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.ExchangePattern; +import org.apache.camel.Processor; +import org.apache.camel.component.jbpm.emitters.CamelEventEmitter; +import org.apache.camel.component.jbpm.listeners.CamelCaseEventListener; +import org.apache.camel.component.jbpm.listeners.CamelProcessEventListener; +import org.apache.camel.component.jbpm.listeners.CamelTaskEventListener; +import org.apache.camel.impl.DefaultConsumer; +import org.jbpm.services.api.DeploymentEvent; +import org.jbpm.services.api.DeploymentEventListener; +import org.jbpm.services.api.DeploymentService; +import org.jbpm.services.api.ListenerSupport; +import org.jbpm.services.api.model.DeployedUnit; +import org.jbpm.services.api.service.ServiceRegistry; +import org.kie.internal.runtime.manager.CacheManager; +import org.kie.internal.runtime.manager.InternalRuntimeManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class JBPMConsumer extends DefaultConsumer implements DeploymentEventListener { + + private static final transient Logger LOGGER = LoggerFactory.getLogger(JBPMConsumer.class); + + private JBPMEndpoint endpoint; + private JBPMConfiguration configuration; + + public JBPMConsumer(Endpoint endpoint, Processor processor) { + super(endpoint, processor); + + this.endpoint = (JBPMEndpoint) endpoint; + this.configuration = ((JBPMEndpoint) getEndpoint()).getConfiguration(); + } + + @Override + protected void doStart() throws Exception { + super.doStart(); + + DeploymentService deploymentService = (DeploymentService) ServiceRegistry.get().service(ServiceRegistry.DEPLOYMENT_SERVICE); + + if (configuration.getDeploymentId() != null) { + InternalRuntimeManager manager = (InternalRuntimeManager) deploymentService.getRuntimeManager(configuration.getDeploymentId()); + configure(manager, this); + + LOGGER.debug("JBPM Camel Consumer configured and started for deployment id {}", configuration.getDeploymentId()); + } else { + + ((ListenerSupport) deploymentService).addListener(this); + + for (DeployedUnit deployed : deploymentService.getDeployedUnits()) { + InternalRuntimeManager manager = (InternalRuntimeManager) deployed.getRuntimeManager(); + configure(manager, this); + } + + LOGGER.debug("JBPM Camel Consumer configured and started on all available deployments"); + } + + + } + + @Override + protected void doStop() throws Exception { + super.doStop(); + DeploymentService deploymentService = (DeploymentService) ServiceRegistry.get().service(ServiceRegistry.DEPLOYMENT_SERVICE); + if (configuration.getDeploymentId() != null) { + LOGGER.debug("JBPM Camel Consumer unconfigured and stopped for deployment id {}", configuration.getDeploymentId()); + } else { + ((ListenerSupport) deploymentService).removeListener(this); + + LOGGER.debug("JBPM Camel Consumer unconfigured and stopped on all available deployments"); + } + + if (JBPMConstants.JBPM_EVENT_EMITTER.equals(configuration.getEventListenerType())) { + ServiceRegistry.get().remove("CamelEventEmitter"); + } + + } + + public void sendMessage(String eventType, Object body) { + Exchange exchange = getEndpoint().createExchange(ExchangePattern.InOnly); + exchange.getIn().setHeader("EventType", eventType); + + exchange.getIn().setBody(body); + + if (!endpoint.isSynchronous()) { + getAsyncProcessor().process(exchange, new AsyncCallback() { + @Override + public void done(boolean doneSync) { + // handle any thrown exception + if (exchange.getException() != null) { + getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException()); + } + } + }); + } else { + try { + getProcessor().process(exchange); + } catch (Exception e) { + exchange.setException(e); + } + + // handle any thrown exception + if (exchange.getException() != null) { + getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException()); + } + } + } + + @Override + public void onDeploy(DeploymentEvent event) { + InternalRuntimeManager manager = (InternalRuntimeManager) event.getDeployedUnit().getRuntimeManager(); + configure(manager, this); + + } + + @Override + public void onUnDeploy(DeploymentEvent event) { + // no-op + } + + @Override + public void onActivate(DeploymentEvent event) { + // no-op + + } + + @Override + public void onDeactivate(DeploymentEvent event) { + // no-op + + } + + + protected void configure(InternalRuntimeManager manager, JBPMConsumer consumer) { + String eventListenerType = configuration.getEventListenerType(); + if (eventListenerType == null) { + return; + } + + + configureConsumer(eventListenerType, manager, consumer); + + } + + protected void configureConsumer(String eventListenerType, InternalRuntimeManager manager, JBPMConsumer consumer) { + LOGGER.debug("Configuring Camel JBPM Consumer for {} on runtime manager {}", eventListenerType, manager); + + CacheManager cacheManager = manager.getCacheManager(); + JBPMCamelConsumerAware consumerAware = null; + if (JBPMConstants.JBPM_PROCESS_EVENT_LISTENER.equals(eventListenerType)) { + consumerAware = (JBPMCamelConsumerAware) cacheManager.get("new org.apache.camel.component.jbpm.listeners.CamelProcessEventListener()"); + if (consumerAware == null) { + consumerAware = new CamelProcessEventListener(); + cacheManager.add("new org.apache.camel.component.jbpm.listeners.CamelProcessEventListener()", consumerAware); + } + LOGGER.debug("Configuring JBPMConsumer on process event listener {}", consumerAware); + } else if (JBPMConstants.JBPM_TASK_EVENT_LISTENER.equals(eventListenerType)) { + consumerAware = (JBPMCamelConsumerAware) cacheManager.get("new org.apache.camel.component.jbpm.listeners.CamelTaskEventListener()"); + if (consumerAware == null) { + consumerAware = new CamelTaskEventListener(); + cacheManager.add("new org.apache.camel.component.jbpm.listeners.CamelTaskEventListener()", consumerAware); + } + LOGGER.debug("Configuring JBPMConsumer on task event listener {}", consumerAware); + } else if (JBPMConstants.JBPM_CASE_EVENT_LISTENER.equals(eventListenerType)) { + consumerAware = (JBPMCamelConsumerAware) cacheManager.get("new org.apache.camel.component.jbpm.listeners.CamelCaseEventListener()"); + if (consumerAware == null) { + consumerAware = new CamelCaseEventListener(); + cacheManager.add("new org.apache.camel.component.jbpm.listeners.CamelCaseEventListener()", consumerAware); + } + LOGGER.debug("Configuring JBPMConsumer on case event listener {}", consumerAware); + } else if (JBPMConstants.JBPM_EVENT_EMITTER.equals(eventListenerType)) { + LOGGER.debug("Configuring JBPMConsumer for event emitter"); + ServiceRegistry.get().register("CamelEventEmitter", new CamelEventEmitter(this, configuration.getEmitterSendItems())); + + return; + } + + LOGGER.debug("Adding consumer {} on {}", consumer, consumerAware); + consumerAware.addConsumer(consumer); + + } + + @Override + public String toString() { + return "JBPMConsumer [endpoint=" + endpoint + ", configuration=" + configuration + "]"; + } +} diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMEndpoint.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMEndpoint.java index 1a5d5e5e0d615..eb0472f94c6c2 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMEndpoint.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMEndpoint.java @@ -18,6 +18,9 @@ import java.net.MalformedURLException; import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; import org.apache.camel.Consumer; import org.apache.camel.Processor; @@ -25,16 +28,16 @@ import org.apache.camel.impl.DefaultEndpoint; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; -import org.kie.api.runtime.manager.RuntimeEngine; -import org.kie.remote.client.api.RemoteRestRuntimeEngineBuilder; -import org.kie.services.client.api.RemoteRuntimeEngineFactory; +import org.kie.server.client.KieServicesClient; +import org.kie.server.client.KieServicesConfiguration; +import org.kie.server.client.KieServicesFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * The jbpm component provides integration with jBPM (Business Process Management). */ -@UriEndpoint(firstVersion = "2.6.0", scheme = "jbpm", title = "JBPM", syntax = "jbpm:connectionURL", producerOnly = true, label = "process") +@UriEndpoint(firstVersion = "2.6.0", scheme = "jbpm", title = "JBPM", syntax = "jbpm:connectionURL", label = "process") public class JBPMEndpoint extends DefaultEndpoint { private static final transient Logger LOGGER = LoggerFactory.getLogger(JBPMEndpoint.class); @@ -47,35 +50,24 @@ public JBPMEndpoint(String uri, JBPMComponent component, JBPMConfiguration confi } public Producer createProducer() throws Exception { - RemoteRestRuntimeEngineBuilder engineBuilder = RemoteRuntimeEngineFactory.newRestBuilder(); - if (configuration.getUserName() != null) { - engineBuilder.addUserName(configuration.getUserName()); - } - if (configuration.getPassword() != null) { - engineBuilder.addPassword(configuration.getPassword()); - } - if (configuration.getDeploymentId() != null) { - engineBuilder.addDeploymentId(configuration.getDeploymentId()); - } - if (configuration.getConnectionURL() != null) { - engineBuilder.addUrl(configuration.getConnectionURL()); - } - if (configuration.getProcessInstanceId() != null) { - engineBuilder.addProcessInstanceId(configuration.getProcessInstanceId()); - } + KieServicesConfiguration kieConfiguration = KieServicesFactory.newRestConfiguration(configuration.getConnectionURL().toExternalForm(), configuration.getUserName(), configuration.getPassword()); + if (configuration.getTimeout() != null) { - engineBuilder.addTimeout(configuration.getTimeout()); + kieConfiguration.setTimeout(configuration.getTimeout()); } if (configuration.getExtraJaxbClasses() != null) { - engineBuilder.addExtraJaxbClasses(configuration.getExtraJaxbClasses()); + List> classes = Arrays.asList(configuration.getExtraJaxbClasses()); + kieConfiguration.addExtraClasses(new LinkedHashSet<>(classes)); } - RuntimeEngine runtimeEngine = engineBuilder.build(); - - return new JBPMProducer(this, runtimeEngine); + + KieServicesClient kieServerClient = KieServicesFactory.newKieServicesClient(kieConfiguration); + LOGGER.debug("JBPM Producer created with KieServerClient configured for {}", configuration.getConnectionURL()); + return new JBPMProducer(this, kieServerClient); } public Consumer createConsumer(Processor processor) throws Exception { - throw new UnsupportedOperationException("Consumer not supported for " + getClass().getSimpleName() + " endpoint"); + LOGGER.debug("JBPM Consumer created and configured for deployment {}", configuration.getDeploymentId()); + return new JBPMConsumer(this, processor); } public boolean isSingleton() { diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMProducer.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMProducer.java index 8fc9fc4fdb4f8..c9f218b3e940b 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMProducer.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMProducer.java @@ -16,7 +16,9 @@ */ package org.apache.camel.component.jbpm; +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -24,55 +26,54 @@ import org.apache.camel.Message; import org.apache.camel.impl.DefaultProducer; import org.apache.camel.util.ExchangeHelper; -import org.kie.api.runtime.KieSession; -import org.kie.api.runtime.manager.RuntimeEngine; -import org.kie.api.runtime.process.ProcessInstance; -import org.kie.api.task.TaskService; -import org.kie.api.task.model.Attachment; -import org.kie.api.task.model.Content; -import org.kie.api.task.model.OrganizationalEntity; -import org.kie.api.task.model.Status; +import org.kie.api.KieServices; +import org.kie.api.command.BatchExecutionCommand; +import org.kie.api.command.Command; +import org.kie.api.command.KieCommands; +import org.kie.api.runtime.ExecutionResults; import org.kie.api.task.model.Task; -import org.kie.api.task.model.TaskSummary; +import org.kie.server.api.model.ServiceResponse; +import org.kie.server.api.model.instance.ProcessInstance; +import org.kie.server.api.model.instance.TaskAttachment; +import org.kie.server.api.model.instance.TaskInstance; +import org.kie.server.api.model.instance.TaskSummary; +import org.kie.server.client.KieServicesClient; +import org.kie.server.client.ProcessServicesClient; +import org.kie.server.client.QueryServicesClient; +import org.kie.server.client.RuleServicesClient; +import org.kie.server.client.UserTaskServicesClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class JBPMProducer extends DefaultProducer { private static final transient Logger LOGGER = LoggerFactory.getLogger(JBPMProducer.class); - private KieSession kieSession; - private TaskService taskService; + + private static KieCommands commandsFactory = KieServices.get().getCommands(); + private JBPMConfiguration configuration; - private RuntimeEngine runtimeEngine; + private KieServicesClient kieServicesClient; + - public JBPMProducer(JBPMEndpoint endpoint, RuntimeEngine runtimeEngine) { + public JBPMProducer(JBPMEndpoint endpoint, KieServicesClient kieServicesClient) { super(endpoint); this.configuration = endpoint.getConfiguration(); - this.runtimeEngine = runtimeEngine; + this.kieServicesClient = kieServicesClient; } @Override protected void doStart() throws Exception { LOGGER.trace("starting producer"); - kieSession = runtimeEngine.getKieSession(); - taskService = runtimeEngine.getTaskService(); super.doStart(); LOGGER.trace("started producer"); } @Override protected void doStop() throws Exception { - super.doStop(); - if (kieSession != null) { - kieSession = null; - } - - if (taskService != null) { - taskService = null; - } + super.doStop(); } public void process(Exchange exchange) throws Exception { - getOperation(exchange).execute(kieSession, taskService, configuration, exchange); + getOperation(exchange).execute(kieServicesClient, configuration, exchange); } Operation getOperation(Exchange exchange) { @@ -92,35 +93,40 @@ enum Operation { //PROCESS OPERATIONS startProcess { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - ProcessInstance processInstance = kieSession.startProcess(getProcessId(configuration, exchange), getParameters(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); + Long processInstance = processClient.startProcess(configuration.getDeploymentId(), getProcessId(configuration, exchange), getParameters(configuration, exchange)); setResult(exchange, processInstance); } }, abortProcessInstance { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - kieSession.abortProcessInstance(safe(getProcessInstanceId(configuration, exchange))); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); + processClient.abortProcessInstance(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange))); } }, signalEvent { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); Long processInstanceId = getProcessInstanceId(configuration, exchange); if (processInstanceId != null) { - kieSession.signalEvent(getEventType(configuration, exchange), getEvent(configuration, exchange), processInstanceId); + processClient.signalProcessInstance(configuration.getDeploymentId(), processInstanceId, getEventType(configuration, exchange), getEvent(configuration, exchange)); } else { - kieSession.signalEvent(getEventType(configuration, exchange), getEvent(configuration, exchange)); + processClient.signal(configuration.getDeploymentId(), getEventType(configuration, exchange), getEvent(configuration, exchange)); } } }, getProcessInstance { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - ProcessInstance processInstance = kieSession.getProcessInstance(safe(getProcessInstanceId(configuration, exchange))); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); + ProcessInstance processInstance = processClient.getProcessInstance(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange))); setResult(exchange, processInstance); } }, getProcessInstances { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - Collection processInstances = kieSession.getProcessInstances(); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + QueryServicesClient queryClient = kieServicesClient.getServicesClient(QueryServicesClient.class); + Collection processInstances = queryClient.findProcessInstances(getPage(configuration, exchange), getPageSize(configuration, exchange)); setResult(exchange, processInstances); } }, @@ -128,198 +134,217 @@ void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration c //RULE OPERATIONS fireAllRules { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + RuleServicesClient ruleClient = kieServicesClient.getServicesClient(RuleServicesClient.class); + List> commands = new ArrayList>(); + BatchExecutionCommand executionCommand = commandsFactory.newBatchExecution(commands); + Integer max = getMaxNumber(configuration, exchange); - int rulesFired; if (max != null) { - rulesFired = kieSession.fireAllRules(max); + commands.add(commandsFactory.newFireAllRules(max)); } else { - rulesFired = kieSession.fireAllRules(); + commands.add(commandsFactory.newFireAllRules()); } - setResult(exchange, rulesFired); - } - }, getFactCount { - @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - long factCount = kieSession.getFactCount(); - setResult(exchange, factCount); + ServiceResponse reply = ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); + setResult(exchange, reply.getResult()); } }, getGlobal { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - Object global = kieSession.getGlobal(getIdentifier(configuration, exchange)); - setResult(exchange, global); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + RuleServicesClient ruleClient = kieServicesClient.getServicesClient(RuleServicesClient.class); + List> commands = new ArrayList>(); + BatchExecutionCommand executionCommand = commandsFactory.newBatchExecution(commands); + String identifier = getIdentifier(configuration, exchange); + commands.add(commandsFactory.newGetGlobal(identifier, identifier)); + + ServiceResponse reply = ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); + setResult(exchange, reply.getResult().getValue(identifier)); } }, setGlobal { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - kieSession.setGlobal(getIdentifier(configuration, exchange), getValue(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + RuleServicesClient ruleClient = kieServicesClient.getServicesClient(RuleServicesClient.class); + List> commands = new ArrayList>(); + BatchExecutionCommand executionCommand = commandsFactory.newBatchExecution(commands); + + commands.add(commandsFactory.newSetGlobal(getIdentifier(configuration, exchange), getValue(configuration, exchange))); + + ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); } }, //WORK ITEM OPERATIONS abortWorkItem { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - kieSession.getWorkItemManager().abortWorkItem(safe(getWorkItemId(configuration, exchange))); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); + processClient.abortWorkItem(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange)), safe(getWorkItemId(configuration, exchange))); } }, completeWorkItem { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - kieSession.getWorkItemManager().completeWorkItem(safe(getWorkItemId(configuration, exchange)), getParameters(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); + processClient.completeWorkItem(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange)), safe(getWorkItemId(configuration, exchange)), getParameters(configuration, exchange)); } }, //TASK OPERATIONS activateTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.activate(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); - } - }, addTask { - @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - long taskId = taskService.addTask(getTask(configuration, exchange), getParameters(configuration, exchange)); - setResult(exchange, taskId); - } - }, claimNextAvailableTask { - @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.claimNextAvailable(getUserId(configuration, exchange), getLanguage(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.activateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } }, claimTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.claim(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.claimTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } }, completeTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.complete(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), getParameters(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.completeAutoProgress(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), getParameters(configuration, exchange)); } }, delegateTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.delegate(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), getTargetUserId(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.delegateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), getTargetUserId(configuration, exchange)); } }, exitTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.exit(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.exitTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } }, failTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.fail(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), getParameters(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.failTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), getParameters(configuration, exchange)); } }, getAttachment { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - Attachment attachment = taskService.getAttachmentById(safe(getAttachmentId(configuration, exchange))); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + TaskAttachment attachment = taskClient.getTaskAttachmentById(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), safe(getAttachmentId(configuration, exchange))); setResult(exchange, attachment); } - }, getContent { - @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - Content content = taskService.getContentById(safe(getContentId(configuration, exchange))); - setResult(exchange, content); - } }, getTasksAssignedAsBusinessAdministrator { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - List taskSummaries = taskService.getTasksAssignedAsBusinessAdministrator(getUserId(configuration, exchange), getLanguage(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + List taskSummaries = taskClient.findTasksAssignedAsBusinessAdministrator(getUserId(configuration, exchange), getPage(configuration, exchange), getPageSize(configuration, exchange)); setResult(exchange, taskSummaries); } }, getTasksAssignedAsPotentialOwnerByStatus { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.getTasksAssignedAsPotentialOwnerByStatus(getUserId(configuration, exchange), getStatuses(configuration, exchange), getLanguage(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + List taskSummaries = taskClient.findTasksAssignedAsPotentialOwner(getUserId(configuration, exchange), getStatuses(configuration, exchange), getPage(configuration, exchange), getPageSize(configuration, exchange)); + setResult(exchange, taskSummaries); } }, getTaskByWorkItem { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - Task task = taskService.getTaskByWorkItemId(safe(getWorkItemId(configuration, exchange))); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + TaskInstance task = taskClient.findTaskByWorkItemId(safe(getWorkItemId(configuration, exchange))); setResult(exchange, task); } }, getTaskBy { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - Task task = taskService.getTaskById(safe(getTaskId(configuration, exchange))); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + TaskInstance task = taskClient.findTaskById(safe(getTaskId(configuration, exchange))); setResult(exchange, task); } }, getTaskContent { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - Map taskContent = taskService.getTaskContent(safe(getTaskId(configuration, exchange))); - setResult(exchange, taskContent); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + Map content = taskClient.getTaskOutputContentByTaskId(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange))); + setResult(exchange, content); } }, getTasksByProcessInstance { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - List processInstanceIds = taskService.getTasksByProcessInstanceId(safe(getProcessInstanceId(configuration, exchange))); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + List processInstanceIds = taskClient.findTasksByStatusByProcessInstanceId(safe(getProcessInstanceId(configuration, exchange)), Collections.emptyList(), + getPage(configuration, exchange), getPageSize(configuration, exchange)); setResult(exchange, processInstanceIds); } }, getTasksByStatusByProcessInstance { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - List taskSummaryList = taskService.getTasksByStatusByProcessInstanceId( + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + List taskSummaryList = taskClient.findTasksByStatusByProcessInstanceId( safe(getProcessInstanceId(configuration, exchange)), getStatuses(configuration, exchange), - getLanguage(configuration, exchange)); + getPage(configuration, exchange), getPageSize(configuration, exchange)); setResult(exchange, taskSummaryList); } }, getTasksOwned { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - List summaryList = taskService.getTasksOwned(getUserId(configuration, exchange), getLanguage(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + List summaryList = taskClient.findTasksOwned(getUserId(configuration, exchange), getPage(configuration, exchange), getPageSize(configuration, exchange)); setResult(exchange, summaryList); } }, nominateTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.nominate(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), getEntities(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.nominateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), getEntities(configuration, exchange)); } }, releaseTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.release(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.releaseTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } }, resumeTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.resume(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.resumeTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } }, skipTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.skip(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.skipTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } }, startTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.start(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.startTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } }, stopTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.stop(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.stopTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } }, suspendTask { @Override - void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) { - taskService.suspend(safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); + void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { + UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); + taskClient.suspendTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } }; - List getStatuses(JBPMConfiguration configuration, Exchange exchange) { - List statusList = exchange.getIn().getHeader(JBPMConstants.STATUS_LIST, List.class); + List getStatuses(JBPMConfiguration configuration, Exchange exchange) { + List statusList = exchange.getIn().getHeader(JBPMConstants.STATUS_LIST, List.class); if (statusList == null) { statusList = configuration.getStatuses(); } return statusList; } - List getEntities(JBPMConfiguration configuration, Exchange exchange) { - List entityList = exchange.getIn().getHeader(JBPMConstants.ENTITY_LIST, List.class); + List getEntities(JBPMConfiguration configuration, Exchange exchange) { + List entityList = exchange.getIn().getHeader(JBPMConstants.ENTITY_LIST, List.class); if (entityList == null) { entityList = configuration.getEntities(); } @@ -350,12 +375,20 @@ String getTargetUserId(JBPMConfiguration configuration, Exchange exchange) { return userId; } - String getLanguage(JBPMConfiguration configuration, Exchange exchange) { - String language = exchange.getIn().getHeader(JBPMConstants.LANGUAGE, String.class); - if (language == null) { - language = configuration.getLanguage(); + Integer getPage(JBPMConfiguration configuration, Exchange exchange) { + Integer page = exchange.getIn().getHeader(JBPMConstants.RESULT_PAGE, Integer.class); + if (page == null) { + page = configuration.getPage(); + } + return page; + } + + Integer getPageSize(JBPMConfiguration configuration, Exchange exchange) { + Integer pageSize = exchange.getIn().getHeader(JBPMConstants.RESULT_PAGE_SIZE, Integer.class); + if (pageSize == null) { + pageSize = configuration.getPageSize(); } - return language; + return pageSize; } Task getTask(JBPMConfiguration configuration, Exchange exchange) { @@ -466,7 +499,7 @@ void setResult(Exchange exchange, Object result) { getResultMessage(exchange).setBody(result); } - abstract void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange); + abstract void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange); } } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/CamelEventEmitter.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/CamelEventEmitter.java new file mode 100644 index 0000000000000..0886466f0f81d --- /dev/null +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/CamelEventEmitter.java @@ -0,0 +1,75 @@ +/** + * 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.camel.component.jbpm.emitters; + +import java.util.Collection; + +import org.apache.camel.component.jbpm.JBPMConsumer; +import org.jbpm.persistence.api.integration.EventCollection; +import org.jbpm.persistence.api.integration.EventEmitter; +import org.jbpm.persistence.api.integration.InstanceView; +import org.jbpm.persistence.api.integration.base.BaseEventCollection; + +public class CamelEventEmitter implements EventEmitter { + + private JBPMConsumer consumer; + private boolean sendItems; + + public CamelEventEmitter(JBPMConsumer consumer, boolean sendItems) { + this.consumer = consumer; + this.sendItems = sendItems; + } + + @Override + public void deliver(Collection> data) { + // no-op + + } + + @Override + public void apply(Collection> data) { + if (consumer == null || data.isEmpty()) { + return; + } + + if (sendItems) { + + data.forEach(item -> consumer.sendMessage("Emitter", item)); + } else { + + consumer.sendMessage("Emitter", data); + } + } + + @Override + public void drop(Collection> data) { + // no-op + + } + + @Override + public EventCollection newCollection() { + return new BaseEventCollection(); + } + + @Override + public void close() { + + } + +} diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/ServiceRegistryBoundEventEmitter.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/ServiceRegistryBoundEventEmitter.java new file mode 100644 index 0000000000000..c531aa783d711 --- /dev/null +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/emitters/ServiceRegistryBoundEventEmitter.java @@ -0,0 +1,62 @@ +/** + * 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.camel.component.jbpm.emitters; + +import java.util.Collection; + +import org.jbpm.persistence.api.integration.EventCollection; +import org.jbpm.persistence.api.integration.EventEmitter; +import org.jbpm.persistence.api.integration.InstanceView; +import org.jbpm.services.api.service.ServiceRegistry; + +public class ServiceRegistryBoundEventEmitter implements EventEmitter { + + private EventEmitter delegate; + + public ServiceRegistryBoundEventEmitter() { + this.delegate = (EventEmitter) ServiceRegistry.get().service("CamelEventEmitter"); + } + + @Override + public void deliver(Collection> data) { + delegate.deliver(data); + + } + + @Override + public void apply(Collection> data) { + delegate.apply(data); + } + + @Override + public void drop(Collection> data) { + delegate.drop(data); + + } + + @Override + public EventCollection newCollection() { + return delegate.newCollection(); + } + + @Override + public void close() { + + } + +} diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelCaseEventListener.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelCaseEventListener.java new file mode 100644 index 0000000000000..4906b5b9b87f6 --- /dev/null +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelCaseEventListener.java @@ -0,0 +1,286 @@ +/** + * 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.camel.component.jbpm.listeners; + +import java.util.LinkedHashSet; +import java.util.Set; + +import org.apache.camel.component.jbpm.JBPMCamelConsumerAware; +import org.apache.camel.component.jbpm.JBPMConsumer; +import org.jbpm.casemgmt.api.event.CaseCancelEvent; +import org.jbpm.casemgmt.api.event.CaseCloseEvent; +import org.jbpm.casemgmt.api.event.CaseCommentEvent; +import org.jbpm.casemgmt.api.event.CaseDataEvent; +import org.jbpm.casemgmt.api.event.CaseDestroyEvent; +import org.jbpm.casemgmt.api.event.CaseDynamicSubprocessEvent; +import org.jbpm.casemgmt.api.event.CaseDynamicTaskEvent; +import org.jbpm.casemgmt.api.event.CaseEventListener; +import org.jbpm.casemgmt.api.event.CaseReopenEvent; +import org.jbpm.casemgmt.api.event.CaseRoleAssignmentEvent; +import org.jbpm.casemgmt.api.event.CaseStartEvent; +import org.kie.internal.runtime.Cacheable; + + +public class CamelCaseEventListener implements CaseEventListener, Cacheable, JBPMCamelConsumerAware { + + private Set consumers = new LinkedHashSet<>(); + + @Override + public void beforeCaseStarted(CaseStartEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeCaseStarted", event); + } + + @Override + public void afterCaseStarted(CaseStartEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterCaseStarted", event); + } + + @Override + public void beforeCaseClosed(CaseCloseEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeCaseClosed", event); + } + + @Override + public void afterCaseClosed(CaseCloseEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterCaseClosed", event); + } + + @Override + public void beforeCaseCancelled(CaseCancelEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeCaseCancelled", event); + } + + @Override + public void afterCaseCancelled(CaseCancelEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterCaseCancelled", event); + } + + @Override + public void beforeCaseDestroyed(CaseDestroyEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeCaseDestroyed", event); + } + + @Override + public void afterCaseDestroyed(CaseDestroyEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterCaseDestroyed", event); + } + + @Override + public void beforeCaseReopen(CaseReopenEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeCaseReopen", event); + } + + @Override + public void afterCaseReopen(CaseReopenEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterCaseReopen", event); + } + + @Override + public void beforeCaseCommentAdded(CaseCommentEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeCaseCommentAdded", event); + } + + @Override + public void afterCaseCommentAdded(CaseCommentEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterCaseCommentAdded", event); + } + + @Override + public void beforeCaseCommentUpdated(CaseCommentEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeCaseCommentUpdated", event); + } + + @Override + public void afterCaseCommentUpdated(CaseCommentEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterCaseCommentUpdated", event); + } + + @Override + public void beforeCaseCommentRemoved(CaseCommentEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeCaseCommentRemoved", event); + } + + @Override + public void afterCaseCommentRemoved(CaseCommentEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterCaseCommentRemoved", event); + } + + @Override + public void beforeCaseRoleAssignmentAdded(CaseRoleAssignmentEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeCaseRoleAssignmentAdded", event); + } + + @Override + public void afterCaseRoleAssignmentAdded(CaseRoleAssignmentEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterCaseRoleAssignmentAdded", event); + } + + @Override + public void beforeCaseRoleAssignmentRemoved(CaseRoleAssignmentEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeCaseRoleAssignmentRemoved", event); + } + + @Override + public void afterCaseRoleAssignmentRemoved(CaseRoleAssignmentEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterCaseRoleAssignmentRemoved", event); + } + + @Override + public void beforeCaseDataAdded(CaseDataEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeCaseDataAdded", event); + } + + @Override + public void afterCaseDataAdded(CaseDataEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterCaseDataAdded", event); + } + + @Override + public void beforeCaseDataRemoved(CaseDataEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeCaseDataRemoved", event); + } + + @Override + public void afterCaseDataRemoved(CaseDataEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterCaseDataRemoved", event); + } + + @Override + public void beforeDynamicTaskAdded(CaseDynamicTaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeDynamicTaskAdded", event); + } + + @Override + public void afterDynamicTaskAdded(CaseDynamicTaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterDynamicTaskAdded", event); + } + + @Override + public void beforeDynamicProcessAdded(CaseDynamicSubprocessEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeDynamicProcessAdded", event); + } + + @Override + public void afterDynamicProcessAdded(CaseDynamicSubprocessEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterDynamicProcessAdded", event); + } + + @Override + public void close() { + + } + + @Override + public void addConsumer(JBPMConsumer consumer) { + this.consumers.add(consumer); + } + + @Override + public void removeConsumer(JBPMConsumer consumer) { + this.consumers.remove(consumer); + } + + protected void sendMessage(String eventType, Object event) { + this.consumers.stream().filter(c -> c.getStatus().isStarted()).forEach(c -> c.sendMessage(eventType, event)); + } + +} diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelProcessEventListener.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelProcessEventListener.java new file mode 100644 index 0000000000000..2e6ff08af69ae --- /dev/null +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelProcessEventListener.java @@ -0,0 +1,138 @@ +/** + * 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.camel.component.jbpm.listeners; + +import java.util.LinkedHashSet; +import java.util.Set; + +import org.apache.camel.component.jbpm.JBPMCamelConsumerAware; +import org.apache.camel.component.jbpm.JBPMConsumer; +import org.kie.api.event.process.ProcessCompletedEvent; +import org.kie.api.event.process.ProcessEventListener; +import org.kie.api.event.process.ProcessNodeLeftEvent; +import org.kie.api.event.process.ProcessNodeTriggeredEvent; +import org.kie.api.event.process.ProcessStartedEvent; +import org.kie.api.event.process.ProcessVariableChangedEvent; +import org.kie.internal.runtime.Cacheable; + + +public class CamelProcessEventListener implements ProcessEventListener, Cacheable, JBPMCamelConsumerAware { + + private Set consumers = new LinkedHashSet<>(); + + @Override + public void beforeProcessStarted(ProcessStartedEvent event) { + if (consumers.isEmpty()) { + return; + } + + sendMessage("beforeProcessStarted", event); + } + + @Override + public void afterProcessStarted(ProcessStartedEvent event) { + if (consumers.isEmpty()) { + return; + } + + sendMessage("afterProcessStarted", event); + } + + @Override + public void beforeProcessCompleted(ProcessCompletedEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeProcessCompleted", event); + } + + @Override + public void afterProcessCompleted(ProcessCompletedEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterProcessCompleted", event); + } + + @Override + public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeNodeTriggered", event); + } + + @Override + public void afterNodeTriggered(ProcessNodeTriggeredEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterNodeTriggered", event); + } + + @Override + public void beforeNodeLeft(ProcessNodeLeftEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeNodeLeft", event); + } + + @Override + public void afterNodeLeft(ProcessNodeLeftEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterNodeLeft", event); + } + + @Override + public void beforeVariableChanged(ProcessVariableChangedEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeVariableChanged", event); + } + + @Override + public void afterVariableChanged(ProcessVariableChangedEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterVariableChanged", event); + } + + @Override + public void close() { + + } + + @Override + public void addConsumer(JBPMConsumer consumer) { + this.consumers.add(consumer); + } + + @Override + public void removeConsumer(JBPMConsumer consumer) { + this.consumers.remove(consumer); + } + + protected void sendMessage(String eventType, Object event) { + this.consumers.stream().filter(c -> c.getStatus().isStarted()).forEach(c -> c.sendMessage(eventType, event)); + } +} diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelTaskEventListener.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelTaskEventListener.java new file mode 100644 index 0000000000000..67a93b7d2e5d1 --- /dev/null +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/listeners/CamelTaskEventListener.java @@ -0,0 +1,321 @@ +/** + * 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.camel.component.jbpm.listeners; + +import java.util.LinkedHashSet; +import java.util.Set; + +import org.apache.camel.component.jbpm.JBPMCamelConsumerAware; +import org.apache.camel.component.jbpm.JBPMConsumer; +import org.kie.api.task.TaskEvent; +import org.kie.api.task.TaskLifeCycleEventListener; +import org.kie.internal.runtime.Cacheable; + + +public class CamelTaskEventListener implements Cacheable, TaskLifeCycleEventListener, JBPMCamelConsumerAware { + + private Set consumers = new LinkedHashSet<>(); + + @Override + public void beforeTaskActivatedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskActivatedEvent", event); + } + + @Override + public void beforeTaskClaimedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskClaimedEvent", event); + } + + @Override + public void beforeTaskSkippedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskSkippedEvent", event); + } + + @Override + public void beforeTaskStartedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskStartedEvent", event); + + } + + @Override + public void beforeTaskStoppedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskStoppedEvent", event); + + } + + @Override + public void beforeTaskCompletedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskCompletedEvent", event); + + } + + @Override + public void beforeTaskFailedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskFailedEvent", event); + + } + + @Override + public void beforeTaskAddedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskAddedEvent", event); + + } + + @Override + public void beforeTaskExitedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskExitedEvent", event); + + } + + @Override + public void beforeTaskReleasedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskReleasedEvent", event); + + } + + @Override + public void beforeTaskResumedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskResumedEvent", event); + + } + + @Override + public void beforeTaskSuspendedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskSuspendedEvent", event); + + } + + @Override + public void beforeTaskForwardedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskForwardedEvent", event); + + } + + @Override + public void beforeTaskDelegatedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskDelegatedEvent", event); + + } + + @Override + public void beforeTaskNominatedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("beforeTaskNominatedEvent", event); + + } + + @Override + public void afterTaskActivatedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskActivatedEvent", event); + + } + + @Override + public void afterTaskClaimedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskClaimedEvent", event); + + } + + @Override + public void afterTaskSkippedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskSkippedEvent", event); + + } + + @Override + public void afterTaskStartedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskStartedEvent", event); + + } + + @Override + public void afterTaskStoppedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskStoppedEvent", event); + + } + + @Override + public void afterTaskCompletedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskCompletedEvent", event); + + } + + @Override + public void afterTaskFailedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskFailedEvent", event); + + } + + @Override + public void afterTaskAddedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskAddedEvent", event); + + } + + @Override + public void afterTaskExitedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskExitedEvent", event); + + } + + @Override + public void afterTaskReleasedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskReleasedEvent", event); + + } + + @Override + public void afterTaskResumedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskResumedEvent", event); + + } + + @Override + public void afterTaskSuspendedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskSuspendedEvent", event); + + } + + @Override + public void afterTaskForwardedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskForwardedEvent", event); + + } + + @Override + public void afterTaskDelegatedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskDelegatedEvent", event); + + } + + @Override + public void afterTaskNominatedEvent(TaskEvent event) { + if (consumers.isEmpty()) { + return; + } + sendMessage("afterTaskNominatedEvent", event); + + } + + @Override + public void close() { + + } + + @Override + public void addConsumer(JBPMConsumer consumer) { + this.consumers.add(consumer); + } + + @Override + public void removeConsumer(JBPMConsumer consumer) { + this.consumers.remove(consumer); + } + + protected void sendMessage(String eventType, Object event) { + this.consumers.stream().filter(c -> c.getStatus().isStarted()).forEach(c -> c.sendMessage(eventType, event)); + } + + +} diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/server/CamelKieServerExtension.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/server/CamelKieServerExtension.java new file mode 100644 index 0000000000000..3a8a0ea9bb0d6 --- /dev/null +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/server/CamelKieServerExtension.java @@ -0,0 +1,225 @@ +/** + * 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.camel.component.jbpm.server; + +import java.io.InputStream; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.camel.impl.DefaultCamelContext; +import org.apache.camel.model.FromDefinition; +import org.apache.camel.model.RouteDefinition; +import org.apache.camel.model.RoutesDefinition; +import org.jbpm.services.api.service.ServiceRegistry; +import org.kie.server.services.api.KieContainerInstance; +import org.kie.server.services.api.KieServerExtension; +import org.kie.server.services.api.KieServerRegistry; +import org.kie.server.services.api.SupportedTransports; +import org.kie.server.services.impl.KieServerImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class CamelKieServerExtension implements KieServerExtension { + public static final String EXTENSION_NAME = "Camel"; + + private static final Logger logger = LoggerFactory.getLogger(CamelKieServerExtension.class); + + private static final Boolean disabled = Boolean.parseBoolean(System.getProperty("org.camel.server.ext.disabled", "false")); + + protected DefaultCamelContext camel; + + protected boolean managedCamel; + + protected Map camelContexts = new HashMap<>(); + + public CamelKieServerExtension() { + this.managedCamel = true; + } + + public CamelKieServerExtension(DefaultCamelContext camel) { + this.camel = camel; + this.managedCamel = false; + } + + @Override + public boolean isInitialized() { + return camel != null; + } + + @Override + public boolean isActive() { + return disabled == false; + } + + @Override + public void init(KieServerImpl kieServer, KieServerRegistry registry) { + if (this.managedCamel && this.camel == null) { + this.camel = new DefaultCamelContext(); + this.camel.setName("KIE Server Camel context"); + + try (InputStream is = this.getClass().getResourceAsStream("/global-camel-routes.xml")) { + if (is != null) { + + RoutesDefinition routes = camel.loadRoutesDefinition(is); + camel.addRouteDefinitions(routes.getRoutes()); + } + } catch (Exception e) { + logger.error("Error while adding Camel context for KIE Server", e); + } + } + + ServiceRegistry.get().register("GlobalCamelService", this.camel); + } + + @Override + public void destroy(KieServerImpl kieServer, KieServerRegistry registry) { + ServiceRegistry.get().remove("GlobalCamelService"); + + if (this.managedCamel && this.camel != null) { + try { + this.camel.stop(); + } catch (Exception e) { + logger.error("Failed at stopping KIE Server extension {}", EXTENSION_NAME); + } + } + } + + @Override + public void createContainer(String id, KieContainerInstance kieContainerInstance, Map parameters) { + + ClassLoader classloader = kieContainerInstance.getKieContainer().getClassLoader(); + try (InputStream is = classloader.getResourceAsStream("camel-routes.xml")) { + if (is != null) { + + DefaultCamelContext context = new DefaultCamelContext(); + context.setName("KIE Server Camel context for container " + kieContainerInstance.getContainerId()); + + RoutesDefinition routes = context.loadRoutesDefinition(is); + annotateKJarRoutes(routes, id); + context.addRouteDefinitions(routes.getRoutes()); + context.start(); + camelContexts.put(id, context); + + ServiceRegistry.get().register(id + "_CamelService", this.camel); + + } + } catch (Exception e) { + logger.error("Error while adding Camel context for {}", kieContainerInstance.getContainerId(), e); + } + } + + @Override + public void updateContainer(String id, KieContainerInstance kieContainerInstance, Map parameters) { + disposeContainer(id, kieContainerInstance, parameters); + createContainer(id, kieContainerInstance, parameters); + } + + @Override + public boolean isUpdateContainerAllowed(String id, KieContainerInstance kieContainerInstance, Map parameters) { + return true; + } + + @Override + public void disposeContainer(String id, KieContainerInstance kieContainerInstance, Map parameters) { + DefaultCamelContext context = camelContexts.get(id); + + if (context != null) { + + ServiceRegistry.get().remove(id + "_CamelService"); + try { + context.stop(); + } catch (Exception e) { + logger.error("Error while removing Camel context for container {}", id, e); + } + } + } + + @Override + public List getAppComponents(SupportedTransports type) { + return Collections.emptyList(); + } + + @Override + public T getAppComponents(Class serviceType) { + return null; + } + + @Override + public String getImplementedCapability() { + return "Integration"; + } + + @Override + public List getServices() { + return Collections.emptyList(); + } + + @Override + public String getExtensionName() { + return EXTENSION_NAME; + } + + @Override + public Integer getStartOrder() { + return 50; + } + + @Override + public void serverStarted() { + if (this.managedCamel && this.camel != null && !this.camel.isStarted()) { + try { + this.camel.start(); + } catch (Exception e) { + logger.error("Failed at start Camel context", e); + } + } + } + + @Override + public String toString() { + return EXTENSION_NAME + " KIE Server extension"; + } + + protected void annotateKJarRoutes(RoutesDefinition routes, String deploymentId) { + for (RouteDefinition route : routes.getRoutes()) { + + for (FromDefinition from : route.getInputs()) { + + if (from.getUri().startsWith("jbpm:events") && !from.getUri().contains("deploymentId")) { + StringBuilder uri = new StringBuilder(from.getUri()); + + String[] split = from.getUri().split("\\?"); + if (split.length == 1) { + // no query given + uri.append("?"); + } else { + // already query params exist + uri.append("&"); + } + uri.append("deploymentId=").append(deploymentId); + from.setUri(uri.toString()); + } + + System.out.println(from.getUri()); + } + } + } +} diff --git a/components/camel-jbpm/src/main/resources/META-INF/services/org.kie.server.services.api.KieServerExtension b/components/camel-jbpm/src/main/resources/META-INF/services/org.kie.server.services.api.KieServerExtension new file mode 100644 index 0000000000000..a3aed9f0f76d2 --- /dev/null +++ b/components/camel-jbpm/src/main/resources/META-INF/services/org.kie.server.services.api.KieServerExtension @@ -0,0 +1 @@ +org.apache.camel.component.jbpm.server.CamelKieServerExtension \ No newline at end of file diff --git a/components/camel-jbpm/src/test/java/org/apache/camel/component/jbpm/JBPMComponentIntegrationTest.java b/components/camel-jbpm/src/test/java/org/apache/camel/component/jbpm/JBPMComponentIntegrationTest.java index 987b0a6b91206..18e1055a94d13 100644 --- a/components/camel-jbpm/src/test/java/org/apache/camel/component/jbpm/JBPMComponentIntegrationTest.java +++ b/components/camel-jbpm/src/test/java/org/apache/camel/component/jbpm/JBPMComponentIntegrationTest.java @@ -17,21 +17,74 @@ package org.apache.camel.component.jbpm; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.jbpm.JBPMProducer.Operation; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Ignore; import org.junit.Test; +import org.kie.server.api.model.instance.TaskSummary; -@Ignore("This is an integration test that needs BPMS running on the local machine") +/** + * To run this example you need jBPM to run locally, easiest is to use single zip + * distribution - download from jbpm.org + * + * Next, start it and import Evaluation sample project, build and deploy. + * Once done this test can be ran out of the box. + */ +@Ignore("This is an integration test that needs jBPM running on the local machine") public class JBPMComponentIntegrationTest extends CamelTestSupport { + @SuppressWarnings("unchecked") @Test public void interactsOverRest() throws Exception { getMockEndpoint("mock:result").expectedMessageCount(1); - template.sendBodyAndHeader("direct:start", null, JBPMConstants.PROCESS_ID, "project1.integration-test"); + + // let's start process instance for evaluation process + Map params = new HashMap<>(); + params.put("employee", "wbadmin"); + params.put("reason", "Camel asks for it"); + + Map headers = new HashMap<>(); + headers.put(JBPMConstants.PROCESS_ID, "evaluation"); + headers.put(JBPMConstants.PARAMETERS, params); + + template.sendBodyAndHeaders("direct:start", null, headers); + assertMockEndpointsSatisfied(); + Long processInstanceId = (Long) getMockEndpoint("mock:result").getExchanges().get(0).getIn().getBody(); + assertNotNull(processInstanceId); + + // now let's collect user tasks + headers = new HashMap<>(); + headers.put(JBPMConstants.OPERATION, JBPMConstants.OPERATION + Operation.getTasksOwned); + + template.sendBodyAndHeaders("direct:start", null, headers); + getMockEndpoint("mock:result").expectedMessageCount(2); + assertMockEndpointsSatisfied(); + + List tasks = (List) getMockEndpoint("mock:result").getExchanges().get(1).getIn().getBody(); + assertEquals(1, tasks.size()); + + // let's complete first user task + headers = new HashMap<>(); + headers.put(JBPMConstants.TASK_ID, tasks.get(0).getId()); + headers.put(JBPMConstants.OPERATION, JBPMConstants.OPERATION + Operation.completeTask); + + template.sendBodyAndHeaders("direct:start", null, headers); + getMockEndpoint("mock:result").expectedMessageCount(3); + assertMockEndpointsSatisfied(); + + // lastly let's abort process instance we just created + headers = new HashMap<>(); + headers.put(JBPMConstants.PROCESS_INSTANCE_ID, processInstanceId); + headers.put(JBPMConstants.OPERATION, JBPMConstants.OPERATION + Operation.abortProcessInstance); + + template.sendBodyAndHeaders("direct:start", null, headers); + getMockEndpoint("mock:result").expectedMessageCount(4); assertMockEndpointsSatisfied(); - - assertNotNull(getMockEndpoint("mock:result").getExchanges().get(0).getIn().getBody()); } @Override @@ -40,8 +93,8 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() { from("direct:start") - .to("jbpm:http://localhost:8080/business-central?userName=bpmsAdmin&password=pa$word1" - + "&deploymentId=org.kie.example:project1:1.0.0-SNAPSHOT") + .to("jbpm:http://localhost:8080/kie-server/services/rest/server?userName=wbadmin&password=wbadmin" + + "&deploymentId=evaluation") .to("mock:result"); } }; diff --git a/parent/pom.xml b/parent/pom.xml index 6d7a82bfe884b..69253d4b1f660 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -360,7 +360,7 @@ 2.0.1 2.2.11_1 1.1.6 - 6.5.0.Final + 7.14.0.Final 1.0.0.Final 3.3.2.Final 1.4.10.Final diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml index 51a998811d1c6..0b6cb7d746a42 100644 --- a/platforms/karaf/features/src/main/resources/features.xml +++ b/platforms/karaf/features/src/main/resources/features.xml @@ -1149,27 +1149,41 @@
The camel-jbpm feature can only run on a SUN JVM. You need to add the package com.sun.tools.xjc to the java platform packages in the etc/jre.properties file.
camel-core transaction - mvn:org.openengsb.wrapped/com.google.protobuf/2.4.1.w1 - mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax-inject/${javax-inject-bundle-version} - mvn:org.codehaus.jackson/jackson-jaxrs/${jackson-version} - mvn:org.codehaus.jackson/jackson-core-asl/${jackson-version} - mvn:org.codehaus.jackson/jackson-mapper-asl/${jackson-version} - mvn:org.codehaus.jackson/jackson-xc/${jackson-version} - mvn:org.apache.geronimo.specs/geronimo-jms_1.1_spec/${geronimo-jms-spec-version} - mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxws-api-2.2/${servicemix-specs-version} + cxf-jaxrs + mvn:org.kie.server/kie-server-api/${jbpm-version} + mvn:org.kie.server/kie-server-common/${jbpm-version} + mvn:org.kie.server/kie-server-client/${jbpm-version} + mvn:org.kie.soup/kie-soup-maven-support/${jbpm-version} + mvn:org.kie.soup/kie-soup-project-datamodel-api/${jbpm-version} + mvn:org.kie.soup/kie-soup-project-datamodel-commons/${jbpm-version} + mvn:org.kie.soup/kie-soup-commons/${jbpm-version} + mvn:org.kie/kie-api/${jbpm-version} + mvn:org.kie/kie-internal/${jbpm-version} mvn:org.drools/drools-core/${jbpm-version} mvn:org.drools/drools-compiler/${jbpm-version} - wrap:mvn:org.kie/kie-internal/${jbpm-version} - mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream-java8/${xstream-bundle-version} + mvn:org.mvel/mvel2/${mvel-version} + mvn:org.kie/kie-dmn-model/${jbpm-version} + mvn:org.kie/kie-dmn-api/${jbpm-version} + mvn:org.optaplanner/optaplanner-core/${jbpm-version} + mvn:org.optaplanner/optaplanner-persistence-common/${jbpm-version} + mvn:org.optaplanner/optaplanner-persistence-jaxb/${jbpm-version} + mvn:org.optaplanner/optaplanner-persistence-jackson/${jbpm-version} + mvn:org.optaplanner/optaplanner-persistence-xstream/${jbpm-version} + mvn:com.google.protobuf/protobuf-java/${protobuf-version} + mvn:com.google.guava/guava/${google-guava-version} + mvn:org.apache.commons/commons-math3/${commons-math3-version} + mvn:org.apache.commons/commons-lang3/${commons-lang3-version} mvn:commons-codec/commons-codec/${commons-codec-version} - mvn:org.mvel/mvel2/${mvel-version} - wrap:mvn:org.kie/kie-api/${jbpm-version} - wrap:mvn:org.kie.remote/kie-remote-common/${jbpm-version} - wrap:mvn:org.kie.remote.ws/kie-remote-ws-common/${jbpm-version} - wrap:mvn:org.kie.remote/kie-remote-jaxb/${jbpm-version} - wrap:mvn:org.kie.remote/kie-services-client/6.1.0.Final - wrap:mvn:org.kie.remote/kie-remote-client/${jbpm-version} - mvn:org.apache.camel/camel-jbpm/${project.version} + mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson2-version} + mvn:com.fasterxml.jackson.core/jackson-core/${jackson2-version} + mvn:com.fasterxml.jackson.core/jackson-databind/${jackson2-version} + mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson2-version} + mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxws-api-2.2/${servicemix-specs-version} + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream-java8/${xstream-bundle-version} + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xpp3/${xpp3-bundle-version} + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.reflections/${reflections-bundle-version} + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-xjc/${jaxb-bundle-version} + mvn:org.apache.camel/camel-jbpm/${project.version} camel-core From 85954bfb0ec7e2c26f5cc467d9b7c60195e8f4c6 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Tue, 13 Nov 2018 08:30:52 +0100 Subject: [PATCH 010/125] Upgrade Atmosphere Websocket to version 2.5.2 --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index 69253d4b1f660..57088ff60699f 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -69,7 +69,7 @@ 1.0.0-final 1.0.0-final_1 2.2.2 - 2.5.1 + 2.5.2 [2.5,3.0) 1.0.8 1.2.1 From 3fc0486ba9b4b9000434c9b73ed29a8728b3b7b5 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Tue, 13 Nov 2018 12:22:26 +0100 Subject: [PATCH 011/125] Upgrade Joda Time to version 2.10.1 --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index 57088ff60699f..4ac47da29e262 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -396,7 +396,7 @@ 2.0.0-m30 1.21 1.6.2 - 2.10 + 2.10.1 1.6.0 0.1.1 0.1.1_1 From ef48e4b46950249e760d7f139a7b6b4d0b141bcc Mon Sep 17 00:00:00 2001 From: Maciej Swiderski Date: Tue, 13 Nov 2018 10:28:34 +0100 Subject: [PATCH 012/125] upgrade versions of optaplanner and kie as they are from same release cycle --- parent/pom.xml | 6 +++--- .../karaf/features/src/main/resources/features.xml | 11 +++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index 4ac47da29e262..983ecc6d2ec13 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -184,7 +184,7 @@ 3.0.14_1 1.6.1_5 6.4.1 - 7.3.0.Final + 7.14.0.Final 3.0.10 3.3.0-v20070426 2.1.5 @@ -441,7 +441,7 @@ 2.0.0_1 2.4.4 4.2.1 - 7.3.0.Final + 7.14.0.Final 0.4.9 4.1.0 4.1.0 @@ -549,7 +549,7 @@ 0.31.0 0.1.4 1.5.0 - 7.3.0.Final + 7.14.0.Final 2.0.8_6 1.6.0 2.4_5 diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml index 0b6cb7d746a42..2e07d63199fc8 100644 --- a/platforms/karaf/features/src/main/resources/features.xml +++ b/platforms/karaf/features/src/main/resources/features.xml @@ -1731,7 +1731,14 @@ mvn:commons-io/commons-io/${commons-io-version} mvn:commons-collections/commons-collections/${commons-collections-version} mvn:org.optaplanner/optaplanner-core/${optaplanner-version} - mvn:org.uberfire/uberfire-maven-support/${uberfire-maven-support-version} + mvn:org.optaplanner/optaplanner-persistence-common/${optaplanner-version} + mvn:org.optaplanner/optaplanner-persistence-jaxb/${optaplanner-version} + mvn:org.optaplanner/optaplanner-persistence-jackson/${optaplanner-version} + mvn:org.optaplanner/optaplanner-persistence-xstream/${optaplanner-version} + mvn:org.kie.soup/kie-soup-maven-support/${kie-version} + mvn:org.kie.soup/kie-soup-project-datamodel-api/${kie-version} + mvn:org.kie.soup/kie-soup-project-datamodel-commons/${kie-version} + mvn:org.kie.soup/kie-soup-commons/${kie-version} mvn:org.kie/kie-api/${kie-version} mvn:org.kie/kie-internal/${kie-version} mvn:org.drools/drools-core/${drools-version} @@ -1743,7 +1750,7 @@ mvn:com.google.protobuf/protobuf-java/${protobuf-version} mvn:com.google.guava/guava/${google-guava-version} mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax-inject/${javax-inject-bundle-version} - mvn:org.apache.camel/camel-optaplanner/${project.version} + mvn:org.apache.camel/camel-optaplanner/${project.version} camel-core From c9923bc5f1719164f75de51103ad3352c5cfd250 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Tue, 13 Nov 2018 15:00:45 +0100 Subject: [PATCH 013/125] Added link in Summary about REST DSL --- docs/user-manual/en/SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md index 9abdaca7dca51..bb7c40748a3a0 100644 --- a/docs/user-manual/en/SUMMARY.md +++ b/docs/user-manual/en/SUMMARY.md @@ -128,7 +128,7 @@ * [Java DSL](java-dsl.adoc) * [Spring DSL](spring.adoc) * [Blueprint DSL](using-osgi-blueprint-with-camel.adoc) -* Rest DSL +* [Rest DSL](../../../camel-core/src/main/docs/rest-dsl.adoc) * [Groovy DSL](groovy-dsl.adoc) * [Scala DSL](scala-dsl.adoc) * [Annotation DSL](bean-integration.adoc) From 355e6553896c9cdf3d67102aabe4cae121297a50 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Tue, 13 Nov 2018 15:27:45 +0100 Subject: [PATCH 014/125] Added languages.adoc to Summary --- docs/user-manual/en/SUMMARY.md | 2 +- docs/user-manual/en/languages.adoc | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md index bb7c40748a3a0..628f5592b5da8 100644 --- a/docs/user-manual/en/SUMMARY.md +++ b/docs/user-manual/en/SUMMARY.md @@ -102,7 +102,7 @@ * [Injector](injector.adoc) * [Intercept](intercept.adoc) * [Inversion of Control with Smart Defaults](inversion-of-control-with-smart-defaults.adoc) -* Languages +* [Languages](languages.adoc) * [Lifecycle](lifecycle.adoc) * [OnCompletion](oncompletion.adoc) * Pluggable Class Resolvers diff --git a/docs/user-manual/en/languages.adoc b/docs/user-manual/en/languages.adoc index 453e4aedfa959..34a718844a5ac 100644 --- a/docs/user-manual/en/languages.adoc +++ b/docs/user-manual/en/languages.adoc @@ -8,9 +8,8 @@ link:expression.adoc[Expression] or link:predicate.adoc[Predicate] within either the link:dsl.adoc[Routing Domain Specific Language] or the link:xml-configuration.adoc[XML Configuration]. -[NOTE] -==== -**Combining Predicates** +==== Note +*Combining Predicates** When creating predicates (expressions that evaluate to `true` or `false`), you can combine several predicates -- regardless of the From 9da8cbb6eaac01c505653b48a2b1c914b7066230 Mon Sep 17 00:00:00 2001 From: aldettinger Date: Tue, 13 Nov 2018 22:19:42 +0100 Subject: [PATCH 015/125] Fixed typos --- .../component/file/GenericFileOperations.java | 2 +- .../src/main/java/org/apache/camel/spi/Policy.java | 2 +- .../camel/impl/ComponentConfigurationTest.java | 2 +- .../camel-cxf/src/main/docs/cxf-component.adoc | 4 ++-- .../camel/component/cxf/CxfProducerTest.java | 2 +- .../src/test/resources/hdfs-default.xml | 4 ++-- .../camel-hdfs2/src/test/resources/hdfs-test.xml | 4 ++-- .../internal/client/DefaultCompositeApiClient.java | 4 ++-- .../component/salesforce/LoginConfigHelper.java | 2 +- .../api/dto/approval/ApprovalRequestTest.java | 6 +++--- .../camel-scala/src/main/docs/scala-eip.adoc | 2 +- .../iso_schematron_skeleton_for_saxon.xsl | 2 +- .../apache/camel/component/smpp/SmppSplitter.java | 8 ++++---- ...upervisingRouteControllerAutoConfiguration.java | 2 +- .../addressing/ProducerParamsPrecedenceTest.java | 2 +- .../src/test/resources/urlrewrite.xml | 2 +- .../xmlsecurity/api/XAdESSignatureProperties.java | 14 +++++++------- .../xmlsecurity/XAdESSignaturePropertiesTest.java | 14 +++++++------- docs/user-manual/en/scala-dsl-eip.adoc | 2 +- docs/user-manual/en/servicepool.adoc | 2 +- .../example/micrometer/ScrapeRouteBuilder.java | 2 +- .../camel/itest/greeter/JmsToCxfInOutTest.java | 2 +- 22 files changed, 43 insertions(+), 43 deletions(-) diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java index 9d1b3c8c8511b..aaeb3df1ab922 100644 --- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java +++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java @@ -62,7 +62,7 @@ public interface GenericFileOperations { * folder already exists. * * @param directory the directory path to build as a relative string name - * @param absolute wether the directory is an absolute or relative path + * @param absolute whether the directory is an absolute or relative path * @return true if build or already exists, false if not possible (could be lack of permissions) * @throws GenericFileOperationFailedException can be thrown */ diff --git a/camel-core/src/main/java/org/apache/camel/spi/Policy.java b/camel-core/src/main/java/org/apache/camel/spi/Policy.java index aa806f6aaa69a..b5f91d94cc95d 100644 --- a/camel-core/src/main/java/org/apache/camel/spi/Policy.java +++ b/camel-core/src/main/java/org/apache/camel/spi/Policy.java @@ -41,7 +41,7 @@ public interface Policy { * Hook invoked before the wrap. *

* This allows you to do any custom logic before the processor is wrapped. For example to - * manipulate the {@link org.apache.camel.model.ProcessorDefinition definiton} + * manipulate the {@link org.apache.camel.model.ProcessorDefinition definition} * * @param routeContext the route context * @param definition the processor definition diff --git a/camel-core/src/test/java/org/apache/camel/impl/ComponentConfigurationTest.java b/camel-core/src/test/java/org/apache/camel/impl/ComponentConfigurationTest.java index 4d1a80b314784..b3da6da26ee8b 100644 --- a/camel-core/src/test/java/org/apache/camel/impl/ComponentConfigurationTest.java +++ b/camel-core/src/test/java/org/apache/camel/impl/ComponentConfigurationTest.java @@ -278,7 +278,7 @@ public void testIntrospectSedaEndpointParameters() throws Exception { /** * Shows we can introspect the parameters of a DefaultComponent (i.e. a non {@link UriEndpointComponent}) - * though we only get to introspect the parameter values from teh current configuration + * though we only get to introspect the parameter values from the current configuration */ @Test public void testIntrospectDefaultComponentParameters() throws Exception { diff --git a/components/camel-cxf/src/main/docs/cxf-component.adoc b/components/camel-cxf/src/main/docs/cxf-component.adoc index df9ea783f9506..bb006a5ef622f 100644 --- a/components/camel-cxf/src/main/docs/cxf-component.adoc +++ b/components/camel-cxf/src/main/docs/cxf-component.adoc @@ -812,7 +812,7 @@ response context with the following code: // Get the response context form outMessage Map responseContext = CastUtils.cast((Map)out.getHeader(Client.RESPONSE_CONTEXT)); assertNotNull(responseContext); - assertEquals("Get the wrong wsdl opertion name", "{http://apache.org/hello_world_soap_http}greetMe", + assertEquals("Get the wrong wsdl operation name", "{http://apache.org/hello_world_soap_http}greetMe", responseContext.get("javax.xml.ws.wsdl.operation").toString()); ------------------------------------------------------------------------------------------------------------- @@ -824,7 +824,7 @@ Attachment is not tested.  Since attachments are marshalled and unmarshalled into POJOs, users typically do not need to deal with the attachment themself.  Attachments are propagated to Camel message's attachments if the MTOM is not enabled, since Camel 2.12.3.  So, it is -possible to retreive attachments by Camel Message API +possible to retrieve attachments by Camel Message API [source,java] -------------------------------------------- diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerTest.java index 7b0a4f1241a2c..6df44421c9bd4 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerTest.java @@ -155,7 +155,7 @@ public void testInvokingJaxWsServerWithParams() throws Exception { LOG.info("Received output text: " + result); Map responseContext = CastUtils.cast((Map)out.getHeader(Client.RESPONSE_CONTEXT)); assertNotNull(responseContext); - assertEquals("Get the wrong wsdl opertion name", "{http://apache.org/hello_world_soap_http}greetMe", responseContext.get("javax.xml.ws.wsdl.operation").toString()); + assertEquals("Get the wrong wsdl operation name", "{http://apache.org/hello_world_soap_http}greetMe", responseContext.get("javax.xml.ws.wsdl.operation").toString()); assertEquals("reply body on Camel", "Hello " + TEST_MESSAGE, result); // check the other camel header copying diff --git a/components/camel-hdfs2/src/test/resources/hdfs-default.xml b/components/camel-hdfs2/src/test/resources/hdfs-default.xml index 4143e0844d950..53af074450d96 100644 --- a/components/camel-hdfs2/src/test/resources/hdfs-default.xml +++ b/components/camel-hdfs2/src/test/resources/hdfs-default.xml @@ -690,8 +690,8 @@ ${dfs.namenode.checkpoint.dir} Determines where on the local filesystem the DFS secondary name node should store the temporary edits to merge. - If this is a comma-delimited list of directoires then teh edits is - replicated in all of the directoires for redundancy. + If this is a comma-delimited list of directories then the edits is + replicated in all of the directories for redundancy. Default value is same as dfs.namenode.checkpoint.dir diff --git a/components/camel-hdfs2/src/test/resources/hdfs-test.xml b/components/camel-hdfs2/src/test/resources/hdfs-test.xml index 5462dbeaf966c..931556ea8a0bc 100644 --- a/components/camel-hdfs2/src/test/resources/hdfs-test.xml +++ b/components/camel-hdfs2/src/test/resources/hdfs-test.xml @@ -690,8 +690,8 @@ ${dfs.namenode.checkpoint.dir} Determines where on the local filesystem the DFS secondary name node should store the temporary edits to merge. - If this is a comma-delimited list of directoires then teh edits is - replicated in all of the directoires for redundancy. + If this is a comma-delimited list of directories then the edits is + replicated in all of the directories for redundancy. Default value is same as dfs.namenode.checkpoint.dir diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/DefaultCompositeApiClient.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/DefaultCompositeApiClient.java index 1777f0ca8c7ae..f95c8e53692e5 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/DefaultCompositeApiClient.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/DefaultCompositeApiClient.java @@ -74,7 +74,7 @@ public class DefaultCompositeApiClient extends AbstractClientBase implements Com private final Map, ObjectReader> readers = new HashMap<>(); - private final Map, ObjectWriter> writters = new HashMap<>(); + private final Map, ObjectWriter> writers = new HashMap<>(); private final XStream xStreamCompositeBatch; @@ -183,7 +183,7 @@ ObjectReader jsonReaderFor(final Class type) { ObjectWriter jsonWriterFor(final Object obj) { final Class type = obj.getClass(); - return Optional.ofNullable(writters.get(type)).orElseGet(() -> mapper.writerFor(type)); + return Optional.ofNullable(writers.get(type)).orElseGet(() -> mapper.writerFor(type)); } ContentProvider serialize(final XStream xstream, final Object body, final Class... additionalTypes) diff --git a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/LoginConfigHelper.java b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/LoginConfigHelper.java index fa3be30cc4fa5..f19658d560d0d 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/LoginConfigHelper.java +++ b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/LoginConfigHelper.java @@ -112,7 +112,7 @@ void validate(final SalesforceLoginConfig loginConfig) { System.out.println("| salesforce.keystore.password | SALESFORCE_KEYSTORE_PASSWORD | JWT |"); System.out.println("| salesforce.login.url | SALESFORCE_LOGIN_URL | ALL |"); System.out.println(); - System.out.println("* ALL - required allways"); + System.out.println("* ALL - required always"); System.out.println("* UP - when using username and password authentication"); System.out.println("* RT - when using refresh token flow"); System.out.println("* JWT - when using JWT flow"); diff --git a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/approval/ApprovalRequestTest.java b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/approval/ApprovalRequestTest.java index ddc7d7bb21e66..b264645287134 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/approval/ApprovalRequestTest.java +++ b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/approval/ApprovalRequestTest.java @@ -67,9 +67,9 @@ public void shouldApplyValuesFromTemplate() { assertThat("Combined approval request should be a new instance", combined, both(not(sameInstance(request))).and(not(sameInstance(template)))); - assertEquals("Action type should not be overwriten", request.getActionType(), combined.getActionType()); - assertEquals("Comment should not be overwriten", request.getComments(), combined.getComments()); - assertEquals("Context id should not be overwriten", request.getContextId(), combined.getContextId()); + assertEquals("Action type should not be overwritten", request.getActionType(), combined.getActionType()); + assertEquals("Comment should not be overwritten", request.getComments(), combined.getComments()); + assertEquals("Context id should not be overwritten", request.getContextId(), combined.getContextId()); assertEquals("Next approver id should be taken from template", template.getNextApproverIds(), combined.getNextApproverIds()); } diff --git a/components/camel-scala/src/main/docs/scala-eip.adoc b/components/camel-scala/src/main/docs/scala-eip.adoc index 1922ea527d8d5..ce363b922e43d 100644 --- a/components/camel-scala/src/main/docs/scala-eip.adoc +++ b/components/camel-scala/src/main/docs/scala-eip.adoc @@ -118,7 +118,7 @@ Delayer +++++++ Unlike a throttler, which only slows down messages if the rate exceeds a -treshold, a delayer delays every messages with a fixed amount of time. +threshold, a delayer delays every messages with a fixed amount of time. An example: to delay every message going from `seda:a` to `mock:a` with 1 second, you write... diff --git a/components/camel-schematron/src/main/resources/iso-schematron-xslt2/iso_schematron_skeleton_for_saxon.xsl b/components/camel-schematron/src/main/resources/iso-schematron-xslt2/iso_schematron_skeleton_for_saxon.xsl index 3142878363977..6dbbe5b042963 100644 --- a/components/camel-schematron/src/main/resources/iso-schematron-xslt2/iso_schematron_skeleton_for_saxon.xsl +++ b/components/camel-schematron/src/main/resources/iso-schematron-xslt2/iso_schematron_skeleton_for_saxon.xsl @@ -2207,7 +2207,7 @@ which require a preprocess. message text is taken from the strings below. We use XHTML, to provide the namespace. - If the $langCode is somethign else, then the XSLT engine will try to + If the $langCode is something else, then the XSLT engine will try to find a file called sch-messages-$langCode.xhtml in the same directory as this stylesheet. Expect a fatal error if the file does not exist. diff --git a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppSplitter.java b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppSplitter.java index 3c79eee4ed50a..89bce93f34793 100644 --- a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppSplitter.java +++ b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppSplitter.java @@ -49,9 +49,9 @@ public class SmppSplitter { /** * The value that identifier length of the SAR fragment. *

- * {@code 0x00} value must be used if the legnth of the reference number is + * {@code 0x00} value must be used if the length of the reference number is * 1 byte.
- * {@code 0x08} value must be used if the legnth of the reference number is + * {@code 0x08} value must be used if the length of the reference number is * 2 bytes. */ protected static final byte UDHIE_IDENTIFIER_SAR = 0x00; @@ -59,9 +59,9 @@ public class SmppSplitter { /** * The length of the SAR fragment. *

- * {@code 0x03} value must be used if the legnth of the reference number is + * {@code 0x03} value must be used if the length of the reference number is * 1 byte.
- * {@code 0x04} value must be used if the legnth of the reference number is + * {@code 0x04} value must be used if the length of the reference number is * 2 bytes. */ protected static final byte UDHIE_SAR_LENGTH = 0x03; diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SupervisingRouteControllerAutoConfiguration.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SupervisingRouteControllerAutoConfiguration.java index 0ac9994aa9ba7..9d5682030084e 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SupervisingRouteControllerAutoConfiguration.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SupervisingRouteControllerAutoConfiguration.java @@ -71,7 +71,7 @@ public RouteController routeController() { // Mark this route as excluded from supervisor controller.addFilter(new SupervisingRouteControllerFilters.BlackList(entry.getKey())); } else { - // configure teh route + // configure the route controller.setBackOff(entry.getKey(), configureBackOff(defaultBackOff, cfg.getBackOff())); } } diff --git a/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ProducerParamsPrecedenceTest.java b/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ProducerParamsPrecedenceTest.java index 7e9136978d4b8..8d3df0c1e8c2b 100644 --- a/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ProducerParamsPrecedenceTest.java +++ b/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ProducerParamsPrecedenceTest.java @@ -149,7 +149,7 @@ public void testFaultToPrecedence() throws Exception { Assertions.assertThat(wsaProperties).isNotNull(); Assertions.assertThat(wsaProperties.getFaultTo().getAddress()).isEqualTo(new URI("http://faultPrecedence.to")); // /we set in sample data all precendence fields for simplier tests - // otherwise it woudl be here annonymous + // otherwise it would be here anonymous Assertions.assertThat(wsaProperties.getReplyTo().getAddress()).isEqualTo(new URI("http://replyPrecedence.to")); } diff --git a/components/camel-urlrewrite/src/test/resources/urlrewrite.xml b/components/camel-urlrewrite/src/test/resources/urlrewrite.xml index 5c07d1d2e3384..1bfb4a47727fd 100644 --- a/components/camel-urlrewrite/src/test/resources/urlrewrite.xml +++ b/components/camel-urlrewrite/src/test/resources/urlrewrite.xml @@ -44,7 +44,7 @@ the url /rewrite-status will be rewritten to /test/status/. The above rule and this outbound-rule means that end users should never see the - url /rewrite-status only /test/status/ both in thier location bar and in hyperlinks + url /rewrite-status only /test/status/ both in their location bar and in hyperlinks in your pages. /rewrite-status diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/api/XAdESSignatureProperties.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/api/XAdESSignatureProperties.java index a83b39ed62ec5..594dbdb5903b8 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/api/XAdESSignatureProperties.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/api/XAdESSignatureProperties.java @@ -721,7 +721,7 @@ protected void addCommitmentTypeIndication(Element signedDataObjectProperties, D if (!qualifiers.isEmpty()) { Element qualifiersEl = createElement("CommitmentTypeQualifiers", doc, input); commitmentTypeIndication.appendChild(qualifiersEl); - String errorMessage = "The XAdES confguration is invalid. The list of the commitment type qualifiers contains the invalid entry '%s'. An entry must either be a text or an XML fragment " + String errorMessage = "The XAdES configuration is invalid. The list of the commitment type qualifiers contains the invalid entry '%s'. An entry must either be a text or an XML fragment " + "with the root element '%s' with the namespace '%s'."; for (String qualifier : getCommitmentTypeQualifiers()) { Element qualifierEl = createChildFromXmlFragmentOrText(doc, input, "CommitmentTypeQualifier", errorMessage, qualifier); @@ -868,7 +868,7 @@ protected void addSignerRole(Document doc, Element signedSignatureProperties, In LOG.debug("Adding claimed roles"); Element claimedRolesEl = createElement("ClaimedRoles", doc, input); signerRole.appendChild(claimedRolesEl); - String errorMessage = "The XAdES confguration is invalid. The list of the claimed roles contains the invalid entry '%s'." + String errorMessage = "The XAdES configuration is invalid. The list of the claimed roles contains the invalid entry '%s'." + " An entry must either be a text or an XML fragment with the root element '%s' with the namespace '%s'."; for (String claimedRole : claimedRoles) { Element claimedRoleEl = createChildFromXmlFragmentOrText(doc, input, "ClaimedRole", errorMessage, claimedRole); @@ -916,7 +916,7 @@ protected void addSignaturePolicyIdentifier(Document doc, Element signedProperti Element identifier = createElement("Identifier", doc, input); sigPolicyId.appendChild(identifier); if (getSigPolicyId() == null || getSigPolicyId().isEmpty()) { - throw new XmlSignatureException("The XAdES-EPES confguration is invalid. The signature policy identifier is missing."); + throw new XmlSignatureException("The XAdES-EPES configuration is invalid. The signature policy identifier is missing."); } identifier.setTextContent(getSigPolicyId()); if (getSigPolicyIdQualifier() != null && !getSigPolicyIdQualifier().isEmpty()) { @@ -942,14 +942,14 @@ protected void addSignaturePolicyIdentifier(Document doc, Element signedProperti id.appendChild(sigPolicyHash); if (getSignaturePolicyDigestAlgorithm() == null || getSignaturePolicyDigestAlgorithm().isEmpty()) { throw new XmlSignatureException( - "The XAdES-EPES confguration is invalid. The digest algorithm for the signature policy is missing."); + "The XAdES-EPES configuration is invalid. The digest algorithm for the signature policy is missing."); } Element digestMethod = createDigSigElement("DigestMethod", doc, input.getPrefixForXmlSignatureNamespace()); sigPolicyHash.appendChild(digestMethod); setAttribute(digestMethod, "Algorithm", getSignaturePolicyDigestAlgorithm()); if (getSignaturePolicyDigestValue() == null || getSignaturePolicyDigestValue().isEmpty()) { throw new XmlSignatureException( - "The XAdES-EPES confguration is invalid. The digest value for the signature policy is missing."); + "The XAdES-EPES configuration is invalid. The digest value for the signature policy is missing."); } Element digestValue = createDigSigElement("DigestValue", doc, input.getPrefixForXmlSignatureNamespace()); sigPolicyHash.appendChild(digestValue); @@ -959,7 +959,7 @@ protected void addSignaturePolicyIdentifier(Document doc, Element signedProperti if (!qualifiers.isEmpty()) { Element qualifiersEl = createElement("SigPolicyQualifiers", doc, input); id.appendChild(qualifiersEl); - String errorMessage = "The XAdES confguration is invalid. The list of the signatue policy qualifiers contains the invalid entry '%s'." + String errorMessage = "The XAdES configuration is invalid. The list of the signatue policy qualifiers contains the invalid entry '%s'." + " An entry must either be a text or an XML fragment with the root element '%s' with the namespace '%s'."; for (String elementOrText : getSigPolicyQualifiers()) { Element child = createChildFromXmlFragmentOrText(doc, input, "SigPolicyQualifier", errorMessage, elementOrText); @@ -992,7 +992,7 @@ protected Element createChildFromXmlFragmentOrText(Document doc, Input input, St if (!ns.equals(child.getNamespaceURI())) { throw new XmlSignatureException( String.format( - "The XAdES confguration is invalid. The root element '%s' of the provided XML fragment '%s' has the invalid namespace '%s'. The correct namespace is '%s'.", + "The XAdES configuration is invalid. The root element '%s' of the provided XML fragment '%s' has the invalid namespace '%s'. The correct namespace is '%s'.", child.getLocalName(), elementOrText, child.getNamespaceURI(), ns)); } } catch (SAXException e) { diff --git a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XAdESSignaturePropertiesTest.java b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XAdESSignaturePropertiesTest.java index c4eceb489d063..7ba603b54bafd 100644 --- a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XAdESSignaturePropertiesTest.java +++ b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XAdESSignaturePropertiesTest.java @@ -505,7 +505,7 @@ private void testExceptionSigPolicyIdMissing(String value) throws InterruptedExc sendBody("direct:enveloping", payload, Collections. emptyMap()); assertMockEndpointsSatisfied(); checkThrownException(mock, XmlSignatureException.class, - "The XAdES-EPES confguration is invalid. The signature policy identifier is missing.", null); + "The XAdES-EPES configuration is invalid. The signature policy identifier is missing.", null); } @Test @@ -527,7 +527,7 @@ private void testExceptionSigPolicyDigestMissing(String value) throws Interrupte sendBody("direct:enveloping", payload, Collections. emptyMap()); assertMockEndpointsSatisfied(); checkThrownException(mock, XmlSignatureException.class, - "The XAdES-EPES confguration is invalid. The digest value for the signature policy is missing.", null); + "The XAdES-EPES configuration is invalid. The digest value for the signature policy is missing.", null); } @Test @@ -549,7 +549,7 @@ private void testExceptionSigPolicyDigestAlgoMissing(String value) throws Interr sendBody("direct:enveloping", payload, Collections. emptyMap()); assertMockEndpointsSatisfied(); checkThrownException(mock, XmlSignatureException.class, - "The XAdES-EPES confguration is invalid. The digest algorithm for the signature policy is missing.", null); + "The XAdES-EPES configuration is invalid. The digest algorithm for the signature policy is missing.", null); } @Test @@ -564,7 +564,7 @@ public void invalidXmlFragmentForClaimedRole() throws Exception { checkThrownException( mock, XmlSignatureException.class, - "The XAdES confguration is invalid. The list of the claimed roles contains the invalid entry 'wrong XML fragment'. An entry must either be a text or" + "The XAdES configuration is invalid. The list of the claimed roles contains the invalid entry 'wrong XML fragment'. An entry must either be a text or" + " an XML fragment with the root element 'ClaimedRole' with the namespace 'http://uri.etsi.org/01903/v1.3.2#'.", null); } @@ -581,7 +581,7 @@ public void invalidXmlFragmentForCommitmentTypeQualifier() throws Exception { checkThrownException( mock, XmlSignatureException.class, - "The XAdES confguration is invalid. The list of the commitment type qualifiers contains the invalid entry 'wrong XML fragment'." + "The XAdES configuration is invalid. The list of the commitment type qualifiers contains the invalid entry 'wrong XML fragment'." + " An entry must either be a text or an XML fragment with the root element 'CommitmentTypeQualifier' with the namespace 'http://uri.etsi.org/01903/v1.3.2#'.", null); } @@ -598,7 +598,7 @@ public void invalidXmlFragmentForSigPolicyQualifier() throws Exception { checkThrownException( mock, XmlSignatureException.class, - "The XAdES confguration is invalid. The list of the signatue policy qualifiers contains the invalid entry 'wrong XML fragment'." + "The XAdES configuration is invalid. The list of the signatue policy qualifiers contains the invalid entry 'wrong XML fragment'." + " An entry must either be a text or an XML fragment with the root element 'SigPolicyQualifier' with the namespace 'http://uri.etsi.org/01903/v1.3.2#'.", null); } @@ -616,7 +616,7 @@ public void invalidNamespaceForTheRootElementInXmlFragmentForSigPolicyQualifier( checkThrownException( mock, XmlSignatureException.class, - "The XAdES confguration is invalid. The root element 'SigPolicyQualifier' of the provided XML fragment " + "The XAdES configuration is invalid. The root element 'SigPolicyQualifier' of the provided XML fragment " + "'XML fragment with wrong namespace for root element' has the invalid namespace 'http://invalid.com'." + " The correct namespace is 'http://uri.etsi.org/01903/v1.3.2#'.", null); } diff --git a/docs/user-manual/en/scala-dsl-eip.adoc b/docs/user-manual/en/scala-dsl-eip.adoc index 2c5201661a9d5..c6297dd73f5ad 100644 --- a/docs/user-manual/en/scala-dsl-eip.adoc +++ b/docs/user-manual/en/scala-dsl-eip.adoc @@ -174,7 +174,7 @@ Delayer +++++++ Unlike a throttler, which only slows down messages if the rate exceeds a -treshold, a delayer delays every messages with a fixed amount of time. +threshold, a delayer delays every messages with a fixed amount of time. An example: to delay every message going from `seda:a` to `mock:a` with 1 second, you write... diff --git a/docs/user-manual/en/servicepool.adoc b/docs/user-manual/en/servicepool.adoc index 675c053e866e5..a9b36e2dac708 100644 --- a/docs/user-manual/en/servicepool.adoc +++ b/docs/user-manual/en/servicepool.adoc @@ -48,7 +48,7 @@ Then set your custom pooling on the `CamelContext` with the The producer service pool identify a producer as being pool capable if the producer implements the marker interface -`org.apache.camel.SerivcePoolAware`. + +`org.apache.camel.ServicePoolAware`. + As the producer will be pooled and thus long lived, your producer should be able to automatic safely recover lost connection. Usually you implement logic that re connects if needed. diff --git a/examples/camel-example-micrometer/src/main/java/org/apache/camel/example/micrometer/ScrapeRouteBuilder.java b/examples/camel-example-micrometer/src/main/java/org/apache/camel/example/micrometer/ScrapeRouteBuilder.java index 2fd3eb41cd306..c4a53ab0eec8b 100644 --- a/examples/camel-example-micrometer/src/main/java/org/apache/camel/example/micrometer/ScrapeRouteBuilder.java +++ b/examples/camel-example-micrometer/src/main/java/org/apache/camel/example/micrometer/ScrapeRouteBuilder.java @@ -23,7 +23,7 @@ import org.springframework.stereotype.Component; /** - * Route Builder that exposes teh endpoint used by Prometheus to scrape + * Route Builder that exposes the endpoint used by Prometheus to scrape * monitoring data from the Camel application. When running in a Spring * Boot 2.x environment, this is not required as Spring Boot already exposes * this endpoint by default. diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java index 6ae765d8d2924..c2666a934f807 100644 --- a/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java +++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java @@ -47,7 +47,7 @@ public void testJmsToCxfInOut() throws Exception { String out = template.requestBodyAndHeader("jms:queue:bridge.cxf", "Willem", CxfConstants.OPERATION_NAME, "greetMe", String.class); assertEquals("Hello Willem", out); - // call for the other opertion + // call for the other operation out = template.requestBodyAndHeader("jms:queue:bridge.cxf", new Object[0], CxfConstants.OPERATION_NAME, "sayHi", String.class); assertEquals("Bonjour", out); } From 80e12e7b03aabf823d4ef6e943b772890f2c65e8 Mon Sep 17 00:00:00 2001 From: onders Date: Wed, 14 Nov 2018 04:11:23 +0300 Subject: [PATCH 016/125] CAMEL-12933 override populateHeaders considering backward compatibility --- .../org/apache/camel/component/file/remote/RemoteFile.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java index cd1d18eb3408a..e29c248488977 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java @@ -42,6 +42,11 @@ public void populateHeaders(GenericFileMessage message) { message.setHeader("CamelFileHost", getHostname()); } } + + @Override + public void populateHeaders(GenericFileMessage message, boolean isProbeContentTypeFromEndpoint) { + populateHeaders(message); + } public String getHostname() { return hostname; From 8ddfee77ff06ec3efbac10547d764b438f564260 Mon Sep 17 00:00:00 2001 From: Vilmos Nagy Date: Wed, 14 Nov 2018 10:51:09 +0100 Subject: [PATCH 017/125] Schematron component supports class `javax.xml.transform.Source` --- .../schematron/SchematronProducer.java | 27 +++++++++--- .../processor/SchematronProcessor.java | 12 +++++- .../schematron/SchematronProducerTest.java | 41 +++++++++++++++++++ 3 files changed, 72 insertions(+), 8 deletions(-) diff --git a/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronProducer.java b/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronProducer.java index debd27a2c8199..bef9c50805a7a 100644 --- a/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronProducer.java +++ b/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronProducer.java @@ -16,17 +16,19 @@ */ package org.apache.camel.component.schematron; -import java.util.HashMap; -import java.util.Map; - import org.apache.camel.Exchange; import org.apache.camel.component.schematron.constant.Constants; import org.apache.camel.component.schematron.exception.SchematronValidationException; +import org.apache.camel.component.schematron.processor.SchematronProcessor; import org.apache.camel.component.schematron.processor.SchematronProcessorFactory; import org.apache.camel.impl.DefaultProducer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.xml.transform.Source; +import java.util.HashMap; +import java.util.Map; + /** * The Schematron producer. */ @@ -50,9 +52,22 @@ public SchematronProducer(final SchematronEndpoint endpoint) { * @throws Exception */ public void process(Exchange exchange) throws Exception { - String payload = exchange.getIn().getBody(String.class); - logger.debug("Applying schematron validation on payload: {}", payload); - String report = SchematronProcessorFactory.newScehamtronEngine(endpoint.getRules()).validate(payload); + final SchematronProcessor schematronProcessor = SchematronProcessorFactory.newScehamtronEngine(endpoint.getRules()); + final Object payload = exchange.getIn().getBody(); + final String report; + + if (payload instanceof Source) { + logger.debug("Applying schematron validation on payload: {}", payload); + report = schematronProcessor.validate((Source) payload); + } else if (payload instanceof String) { + logger.debug("Applying schematron validation on payload: {}", payload); + report = schematronProcessor.validate((String) payload); + } else { + String stringPayload = exchange.getIn().getBody(String.class); + logger.debug("Applying schematron validation on payload: {}", stringPayload); + report = schematronProcessor.validate(stringPayload); + } + logger.debug("Schematron validation report \n {}", report); String status = getValidationStatus(report); logger.info("Schematron validation status : {}", status); diff --git a/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/processor/SchematronProcessor.java b/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/processor/SchematronProcessor.java index 574e26c8dbf16..af1e7b65a0160 100644 --- a/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/processor/SchematronProcessor.java +++ b/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/processor/SchematronProcessor.java @@ -52,7 +52,6 @@ public class SchematronProcessor { * @param templates */ public SchematronProcessor(XMLReader reader, Templates templates) { - this.reader = reader; this.templates = templates; } @@ -64,9 +63,18 @@ public SchematronProcessor(XMLReader reader, Templates templates) { * @return */ public String validate(final String xml) { + final Source source = new SAXSource(reader, new InputSource(IOUtils.toInputStream(xml))); + return validate(source); + } + /** + * Validates the given XML for given Rules. + * + * @param source + * @return + */ + public String validate(Source source) { try { - final Source source = new SAXSource(reader, new InputSource(IOUtils.toInputStream(xml))); final StringWriter writer = new StringWriter(); templates.newTransformer().transform(source, new StreamResult(writer)); return writer.toString(); diff --git a/components/camel-schematron/src/test/java/org/apache/camel/component/schematron/SchematronProducerTest.java b/components/camel-schematron/src/test/java/org/apache/camel/component/schematron/SchematronProducerTest.java index e78bc00b0037c..ebf2594c6816a 100644 --- a/components/camel-schematron/src/test/java/org/apache/camel/component/schematron/SchematronProducerTest.java +++ b/components/camel-schematron/src/test/java/org/apache/camel/component/schematron/SchematronProducerTest.java @@ -15,8 +15,12 @@ * limitations under the License. */ package org.apache.camel.component.schematron; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.Templates; import javax.xml.transform.TransformerFactory; +import javax.xml.transform.sax.SAXSource; import net.sf.saxon.TransformerFactoryImpl; import org.apache.camel.Exchange; @@ -26,8 +30,12 @@ import org.apache.camel.component.schematron.processor.TemplatesFactory; import org.apache.camel.impl.DefaultExchange; import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.commons.io.IOUtils; import org.junit.BeforeClass; import org.junit.Test; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; /** * Schematron Producer Unit Test. @@ -73,4 +81,37 @@ public void testProcessInValidXML() throws Exception { } + @Test + public void testProcessValidXMLAsSource() throws Exception { + Exchange exc = new DefaultExchange(context, ExchangePattern.InOut); + exc.getIn().setBody(new SAXSource(getXMLReader(), new InputSource(ClassLoader.getSystemResourceAsStream("xml/article-1.xml")))); + + // process xml payload + producer.process(exc); + + // assert + assertTrue(exc.getOut().getHeader(Constants.VALIDATION_STATUS).equals(Constants.SUCCESS)); + } + + @Test + public void testProcessInValidXMLAsSource() throws Exception { + Exchange exc = new DefaultExchange(context, ExchangePattern.InOut); + exc.getIn().setBody(new SAXSource(getXMLReader(), new InputSource(ClassLoader.getSystemResourceAsStream("xml/article-2.xml")))); + + // process xml payload + producer.process(exc); + + // assert + assertTrue(exc.getOut().getHeader(Constants.VALIDATION_STATUS).equals(Constants.FAILED)); + + } + + private static XMLReader getXMLReader() throws ParserConfigurationException, SAXException { + final SAXParserFactory fac = SAXParserFactory.newInstance(); + fac.setValidating(false); + final SAXParser parser = fac.newSAXParser(); + XMLReader reader = parser.getXMLReader(); + return reader; + } + } From aa1bd3e25e1ba41d5ba9af17c5b6238c0566c42d Mon Sep 17 00:00:00 2001 From: Andrea Tarocchi Date: Wed, 14 Nov 2018 16:12:20 +0100 Subject: [PATCH 018/125] CAMEL-12926: fixed null pointer exceptions accessing swagger url in blueprint projects --- .../main/java/org/apache/camel/swagger/RestSwaggerSupport.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java index dbbcb905e6215..b549634f1f961 100644 --- a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java +++ b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java @@ -18,6 +18,7 @@ import java.lang.management.ManagementFactory; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -210,7 +211,7 @@ public void renderResourceListing(RestApiResponseAdapter response, BeanConfig sw List rests = getRestDefinitions(contextId); if (rests != null) { - final Map apiProperties = configuration.getApiProperties(); + final Map apiProperties = configuration.getApiProperties() != null ? configuration.getApiProperties() : new HashMap<>(); if (json) { response.setHeader(Exchange.CONTENT_TYPE, (String) apiProperties.getOrDefault("api.specification.contentType.json", "application/json")); From 5d8ac7506ede74720f8675fe16891db0691cf466 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 15 Nov 2018 09:46:50 +0100 Subject: [PATCH 019/125] CAMEL-12932 - Camel-AHC-WS: Consumer parameters are not set --- .../java/org/apache/camel/component/ahc/ws/WsEndpoint.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java index c34b6aea1ee9b..876e051f5f4fe 100644 --- a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java +++ b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java @@ -68,7 +68,9 @@ public Producer createProducer() throws Exception { @Override public Consumer createConsumer(Processor processor) throws Exception { - return new WsConsumer(this, processor); + WsConsumer consumer = new WsConsumer(this, processor); + configureConsumer(consumer); + return consumer; } WebSocket getWebSocket() throws Exception { From 7ea92b42a2467d68f25f7b0664a100151561b6a1 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 15 Nov 2018 09:53:00 +0100 Subject: [PATCH 020/125] CAMEL-12932 - Fixed CS --- .../java/org/apache/camel/component/ahc/ws/WsEndpoint.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java index 876e051f5f4fe..9ce71a2d262d7 100644 --- a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java +++ b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java @@ -68,9 +68,9 @@ public Producer createProducer() throws Exception { @Override public Consumer createConsumer(Processor processor) throws Exception { - WsConsumer consumer = new WsConsumer(this, processor); - configureConsumer(consumer); - return consumer; + WsConsumer consumer = new WsConsumer(this, processor); + configureConsumer(consumer); + return consumer; } WebSocket getWebSocket() throws Exception { From 229d37d7e4de9030c19532f570e5683df7c2d4a1 Mon Sep 17 00:00:00 2001 From: Thomas Diesler Date: Fri, 14 Sep 2018 14:21:21 +0200 Subject: [PATCH 021/125] [IPFS] Add initial support for IPFS CAMEL-12810 --- .../src/main/descriptors/common-bin.xml | 1 + components/camel-ipfs/pom.xml | 62 +++++ .../src/main/docs/ipfs-component.adoc | 93 ++++++++ .../camel/component/ipfs/IPFSComponent.java | 64 ++++++ .../component/ipfs/IPFSConfiguration.java | 79 +++++++ .../camel/component/ipfs/IPFSEndpoint.java | 107 +++++++++ .../camel/component/ipfs/IPFSProducer.java | 87 +++++++ .../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++++++++++ .../src/main/resources/META-INF/NOTICE.txt | 11 + .../services/org/apache/camel/component/ipfs | 18 ++ .../camel/component/ipfs/SimpleIPFSTest.java | 217 ++++++++++++++++++ .../src/test/resources/html/chap/ch01.html | 13 ++ .../src/test/resources/html/css/default.css | 38 +++ .../src/test/resources/html/etc/userfile.txt | 1 + .../src/test/resources/html/img/logo.png | Bin 0 -> 6715 bytes .../src/test/resources/html/index.html | 13 ++ .../src/test/resources/log4j2.properties | 30 +++ components/pom.xml | 1 + parent/pom.xml | 6 + 19 files changed, 1044 insertions(+) create mode 100644 components/camel-ipfs/pom.xml create mode 100644 components/camel-ipfs/src/main/docs/ipfs-component.adoc create mode 100644 components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSComponent.java create mode 100644 components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSConfiguration.java create mode 100644 components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java create mode 100644 components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSProducer.java create mode 100644 components/camel-ipfs/src/main/resources/META-INF/LICENSE.txt create mode 100644 components/camel-ipfs/src/main/resources/META-INF/NOTICE.txt create mode 100644 components/camel-ipfs/src/main/resources/META-INF/services/org/apache/camel/component/ipfs create mode 100644 components/camel-ipfs/src/test/java/org/apache/camel/component/ipfs/SimpleIPFSTest.java create mode 100644 components/camel-ipfs/src/test/resources/html/chap/ch01.html create mode 100644 components/camel-ipfs/src/test/resources/html/css/default.css create mode 100644 components/camel-ipfs/src/test/resources/html/etc/userfile.txt create mode 100644 components/camel-ipfs/src/test/resources/html/img/logo.png create mode 100644 components/camel-ipfs/src/test/resources/html/index.html create mode 100644 components/camel-ipfs/src/test/resources/log4j2.properties diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml index 8c63bdbc68eb2..93dc9bd016ad1 100644 --- a/apache-camel/src/main/descriptors/common-bin.xml +++ b/apache-camel/src/main/descriptors/common-bin.xml @@ -134,6 +134,7 @@ org.apache.camel:camel-infinispan org.apache.camel:camel-influxdb org.apache.camel:camel-ignite + org.apache.camel:camel-ipfs org.apache.camel:camel-irc org.apache.camel:camel-ironmq org.apache.camel:camel-jackson diff --git a/components/camel-ipfs/pom.xml b/components/camel-ipfs/pom.xml new file mode 100644 index 0000000000000..20b6f7c959e61 --- /dev/null +++ b/components/camel-ipfs/pom.xml @@ -0,0 +1,62 @@ + + + + 4.0.0 + + + components + org.apache.camel + 2.23.0-SNAPSHOT + + + camel-ipfs + jar + Camel :: IPFS + Camel IPFS support + + + org.apache.camel.component.ipfs.* + org.apache.camel.spi.ComponentResolver;component=ipfs + + + + + org.apache.camel + camel-core + + + io.nessus + nessus-ipfs + + + + + junit + junit + test + + + org.apache.logging.log4j + log4j-slf4j-impl + test + + + + diff --git a/components/camel-ipfs/src/main/docs/ipfs-component.adoc b/components/camel-ipfs/src/main/docs/ipfs-component.adoc new file mode 100644 index 0000000000000..6a3fcc4ef23cf --- /dev/null +++ b/components/camel-ipfs/src/main/docs/ipfs-component.adoc @@ -0,0 +1,93 @@ +[[ipfs-component]] +== IPFS Component + +*Available as of Camel version 2.23* + +The *ipfs:* component provides access to the Interplanetary File System https://ipfs.io/[(IPFS)]. + +Maven users will need to add the following dependency to their `pom.xml` +for this component: + +[source,xml] +------------------------------------------------------------ + + org.apache.camel + camel-ipfs + x.x.x + + +------------------------------------------------------------ + +### URI format + +[source,java] +--------------------------------- +ipfs://cmd?options +--------------------------------- + +### Options + +// component options: START +The IPFS component has no options. +// component options: END + +// endpoint options: START +The IPFS endpoint is configured using URI syntax: + +---- +ipfs:cmd +---- + +with the following path and query parameters: + +==== Path Parameters (3 parameters): + + +[width="100%",cols="2,5,^1,2",options="header"] +|=== +| Name | Description | Default | Type +| *ipfsCmd* | The ipfs command | | String +| *ipfsHost* | The ipfs host | | String +| *ipfsPort* | The ipfs port | | int +|=== + + +==== Query Parameters (2 parameters): + + +[width="100%",cols="2,5,^1,2",options="header"] +|=== +| Name | Description | Default | Type +| *outdir* (producer) | The ipfs output directory | | Path +| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean +|=== +// endpoint options: END +// spring-boot-auto-configure options: START +=== Spring Boot Auto-Configuration + + +The component supports 2 options, which are listed below. + +[width="100%",cols="2,5,^1,2",options="header"] +|=== +| Name | Description | Default | Type +| *camel.component.ipfs.enabled* | Whether to enable auto configuration of the ipfs component. This is enabled by default. | | Boolean +| *camel.component.ipfs.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean +|=== +// spring-boot-auto-configure options: END + + +### Message Headers + +[TODO] + +### Samples + +In this sample we add a file to IPFS, get a file from IPFS and finally access the content of an IPFS file. + +[source,java] +--------------------------------------------------------------------------------------------- +from("direct:start").to("ipfs:add") +from("direct:start").to("ipfs:get?outdir=target") +from("direct:start").to("ipfs:cat"); +--------------------------------------------------------------------------------------------- diff --git a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSComponent.java b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSComponent.java new file mode 100644 index 0000000000000..9d5b228607fe9 --- /dev/null +++ b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSComponent.java @@ -0,0 +1,64 @@ +/** + * 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.camel.component.ipfs; + +import java.net.URI; +import java.util.Map; + +import org.apache.camel.Endpoint; +import org.apache.camel.impl.DefaultComponent; + +import io.nessus.ipfs.IPFSClient; +import io.nessus.ipfs.impl.DefaultIPFSClient; + +public class IPFSComponent extends DefaultComponent { + + private IPFSClient client; + + @Override + protected Endpoint createEndpoint(String urispec, String remaining, Map params) throws Exception { + + // Init the configuration + IPFSConfiguration config = new IPFSConfiguration(this); + setProperties(config, params); + + // Derive host:port and cmd from the give uri + URI uri = new URI(urispec); + String host = uri.getHost(); + int port = uri.getPort(); + String cmd = remaining; + if (!cmd.equals(host)) { + if (host != null) config.setIpfsHost(host); + if (port > 0) config.setIpfsPort(port); + int idx = cmd.indexOf('/'); + cmd = cmd.substring(idx + 1); + } + config.setIpfsCmd(cmd); + + client = createClient(config); + + return new IPFSEndpoint(urispec, this, config); + } + + public IPFSClient getIPFSClient() { + return client; + } + + private synchronized IPFSClient createClient(IPFSConfiguration config) { + return new DefaultIPFSClient(config.getIpfsHost(), config.getIpfsPort()); + } +} \ No newline at end of file diff --git a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSConfiguration.java b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSConfiguration.java new file mode 100644 index 0000000000000..5a78d6478549b --- /dev/null +++ b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSConfiguration.java @@ -0,0 +1,79 @@ +/** + * 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.camel.component.ipfs; + + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.apache.camel.spi.UriParam; +import org.apache.camel.spi.UriParams; +import org.apache.camel.spi.UriPath; +import org.apache.camel.util.ObjectHelper; + +@UriParams +public class IPFSConfiguration { + + // Available commands + public enum IPFSCommand { + add, cat, get, version + } + + @UriPath(description = "The ipfs command") + private String ipfsCmd; + @UriParam(description = "The ipfs output directory") + private Path outdir; + + private String ipfsHost = "127.0.0.1"; + private int ipfsPort = 5001; + + public IPFSConfiguration(IPFSComponent component) { + ObjectHelper.notNull(component, "component"); + } + + public String getIpfsCmd() { + return ipfsCmd; + } + + public void setIpfsCmd(String cmd) { + this.ipfsCmd = cmd; + } + + public String getIpfsHost() { + return ipfsHost; + } + + public void setIpfsHost(String ipfsHost) { + this.ipfsHost = ipfsHost; + } + + public int getIpfsPort() { + return ipfsPort; + } + + public void setIpfsPort(int ipfsPort) { + this.ipfsPort = ipfsPort; + } + + public Path getOutdir() { + return outdir; + } + + public void setOutdir(String outdir) { + this.outdir = Paths.get(outdir); + } +} diff --git a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java new file mode 100644 index 0000000000000..6709332d8300d --- /dev/null +++ b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java @@ -0,0 +1,107 @@ +/** + * 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.camel.component.ipfs; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Path; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.ipfs.IPFSConfiguration.IPFSCommand; +import org.apache.camel.impl.DefaultEndpoint; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; + +import io.nessus.ipfs.IPFSClient; + +/** + * The camel-ipfs component provides access to the Interplanetary File System (IPFS). + */ +@UriEndpoint(firstVersion = "2.23.0", scheme = "ipfs", title = "IPFS", syntax = "ipfs:host:port/cmd", producerOnly = true, label = "file,ipfs") +public class IPFSEndpoint extends DefaultEndpoint { + + @UriParam + private final IPFSConfiguration configuration; + + public IPFSEndpoint(String uri, IPFSComponent component, IPFSConfiguration configuration) { + super(uri, component); + this.configuration = configuration; + } + + @Override + public IPFSComponent getComponent() { + return (IPFSComponent) super.getComponent(); + } + + @Override + public Consumer createConsumer(Processor processor) throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public Producer createProducer() throws Exception { + return new IPFSProducer(this); + } + + @Override + public boolean isSingleton() { + return false; + } + + IPFSConfiguration getConfiguration() { + return configuration; + } + + IPFSCommand getCommand() { + String cmd = configuration.getIpfsCmd(); + try { + return IPFSCommand.valueOf(cmd); + } catch (IllegalArgumentException ex) { + throw new IllegalArgumentException("Unsupported command: " + cmd); + } + } + + String ipfsVersion() throws IOException { + return ipfs().version(); + } + + List ipfsAdd(Path path) throws IOException { + return ipfs().add(path); + } + + InputStream ipfsCat(String cid) throws IOException { + return ipfs().cat(cid); + } + + Path ipfsGet(String cid, Path outdir) throws IOException { + Future future = ipfs().get(cid, outdir); + try { + return future.get(); + } catch (InterruptedException | ExecutionException ex) { + throw new IOException("Cannot obtain: " + cid, ex); + } + } + + private IPFSClient ipfs() { + return getComponent().getIPFSClient(); + } +} diff --git a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSProducer.java b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSProducer.java new file mode 100644 index 0000000000000..0f6e5333911a3 --- /dev/null +++ b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSProducer.java @@ -0,0 +1,87 @@ +/** + * 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.camel.component.ipfs; + +import java.io.File; +import java.io.InputStream; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import org.apache.camel.Exchange; +import org.apache.camel.impl.DefaultProducer; + +import org.apache.camel.component.ipfs.IPFSConfiguration.IPFSCommand; + +public class IPFSProducer extends DefaultProducer { + + public IPFSProducer(IPFSEndpoint endpoint) { + super(endpoint); + } + + @Override + public IPFSEndpoint getEndpoint() { + return (IPFSEndpoint) super.getEndpoint(); + } + + @Override + public void process(Exchange exchange) throws Exception { + + IPFSEndpoint endpoint = getEndpoint(); + IPFSCommand cmd = endpoint.getCommand(); + + if (IPFSCommand.version == cmd) { + + String resp = endpoint.ipfsVersion(); + exchange.getMessage().setBody(resp); + + } else if (IPFSCommand.add == cmd) { + + Path path = pathFromBody(exchange); + List cids = endpoint.ipfsAdd(path); + Object resp = cids; + if (path.toFile().isFile()) { + resp = cids.size() > 0 ? cids.get(0) : null; + } + exchange.getMessage().setBody(resp); + + } else if (IPFSCommand.cat == cmd) { + + String cid = exchange.getMessage().getBody(String.class); + InputStream resp = endpoint.ipfsCat(cid); + exchange.getMessage().setBody(resp); + + } else if (IPFSCommand.get == cmd) { + + Path outdir = endpoint.getConfiguration().getOutdir(); + String cid = exchange.getMessage().getBody(String.class); + Path resp = endpoint.ipfsGet(cid, outdir); + exchange.getMessage().setBody(resp); + + } else { + throw new UnsupportedOperationException(cmd.toString()); + } + } + + private Path pathFromBody(Exchange exchange) { + Object body = exchange.getMessage().getBody(); + if (body instanceof Path) return (Path) body; + if (body instanceof String) return Paths.get((String) body); + if (body instanceof File) return ((File) body).toPath(); + throw new IllegalArgumentException("Invalid path: " + body); + } +} diff --git a/components/camel-ipfs/src/main/resources/META-INF/LICENSE.txt b/components/camel-ipfs/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000000..6b0b1270ff0ca --- /dev/null +++ b/components/camel-ipfs/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + diff --git a/components/camel-ipfs/src/main/resources/META-INF/NOTICE.txt b/components/camel-ipfs/src/main/resources/META-INF/NOTICE.txt new file mode 100644 index 0000000000000..2e215bf2e6b1f --- /dev/null +++ b/components/camel-ipfs/src/main/resources/META-INF/NOTICE.txt @@ -0,0 +1,11 @@ + ========================================================================= + == NOTICE file corresponding to the section 4 d of == + == the Apache License, Version 2.0, == + == in this case for the Apache Camel distribution. == + ========================================================================= + + This product includes software developed by + The Apache Software Foundation (http://www.apache.org/). + + Please read the different LICENSE files present in the licenses directory of + this distribution. diff --git a/components/camel-ipfs/src/main/resources/META-INF/services/org/apache/camel/component/ipfs b/components/camel-ipfs/src/main/resources/META-INF/services/org/apache/camel/component/ipfs new file mode 100644 index 0000000000000..179ce43a3beef --- /dev/null +++ b/components/camel-ipfs/src/main/resources/META-INF/services/org/apache/camel/component/ipfs @@ -0,0 +1,18 @@ +# +# 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. +# + +class=org.apache.camel.component.ipfs.IPFSComponent diff --git a/components/camel-ipfs/src/test/java/org/apache/camel/component/ipfs/SimpleIPFSTest.java b/components/camel-ipfs/src/test/java/org/apache/camel/component/ipfs/SimpleIPFSTest.java new file mode 100644 index 0000000000000..589b919c2dcf3 --- /dev/null +++ b/components/camel-ipfs/src/test/java/org/apache/camel/component/ipfs/SimpleIPFSTest.java @@ -0,0 +1,217 @@ +/* + * #%L + * Wildfly Camel :: Testsuite + * %% + * Copyright (C) 2013 - 2014 RedHat + * %% + * Licensed 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. + * #L% + */ + +package org.apache.camel.component.ipfs; + +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; + +import org.apache.camel.CamelContext; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.impl.DefaultCamelContext; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; + +import io.nessus.utils.StreamUtils; + +public class SimpleIPFSTest { + + @Test + public void ipfsVersion() throws Exception { + + CamelContext camelctx = new DefaultCamelContext(); + camelctx.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:startA").to("ipfs:version"); + from("direct:startB").to("ipfs:127.0.0.1/version"); + from("direct:startC").to("ipfs:127.0.0.1:5001/version"); + } + }); + + camelctx.start(); + assumeIPFS(camelctx); + + try { + ProducerTemplate producer = camelctx.createProducerTemplate(); + String resA = producer.requestBody("direct:startA", null, String.class); + String resB = producer.requestBody("direct:startB", null, String.class); + String resC = producer.requestBody("direct:startC", null, String.class); + Arrays.asList(resA, resB, resC).forEach(res -> { + Assert.assertTrue("Expecting 0.4 in: " + resA, resA.startsWith("0.4")); + }); + } finally { + camelctx.stop(); + } + } + + @Test + public void ipfsAddSingle() throws Exception { + + String HASH = "QmYgjSRbXFPdPYKqQSnUjmXLYLudVahEJQotMaAJKt6Lbd"; + + CamelContext camelctx = new DefaultCamelContext(); + camelctx.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start").to("ipfs:add"); + } + }); + + Path path = Paths.get("src/test/resources/html/index.html"); + + camelctx.start(); + assumeIPFS(camelctx); + + try { + ProducerTemplate producer = camelctx.createProducerTemplate(); + String res = producer.requestBody("direct:start", path, String.class); + Assert.assertEquals(HASH, res); + } finally { + camelctx.stop(); + } + } + + @Test + @SuppressWarnings("unchecked") + public void ipfsAddRecursive() throws Exception { + + String HASH = "Qme6hd6tYXTFb7bb7L3JZ5U6ygktpAHKxbaeffYyQN85mW"; + + CamelContext camelctx = new DefaultCamelContext(); + camelctx.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start").to("ipfs:add"); + } + }); + + Path path = Paths.get("src/test/resources/html"); + + camelctx.start(); + assumeIPFS(camelctx); + + try { + ProducerTemplate producer = camelctx.createProducerTemplate(); + List res = producer.requestBody("direct:start", path, List.class); + Assert.assertEquals(10, res.size()); + Assert.assertEquals(HASH, res.get(9)); + } finally { + camelctx.stop(); + } + } + + @Test + public void ipfsCat() throws Exception { + + String HASH = "QmUD7uG5prAMHbcCfp4x1G1mMSpywcSMHTGpq62sbpDAg6"; + + CamelContext camelctx = new DefaultCamelContext(); + camelctx.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start").to("ipfs:cat"); + } + }); + + camelctx.start(); + assumeIPFS(camelctx); + + try { + ProducerTemplate producer = camelctx.createProducerTemplate(); + InputStream res = producer.requestBody("direct:start", HASH, InputStream.class); + verifyFileContent(res); + } finally { + camelctx.stop(); + } + } + + @Test + public void ipfsGetSingle() throws Exception { + + String HASH = "QmUD7uG5prAMHbcCfp4x1G1mMSpywcSMHTGpq62sbpDAg6"; + + CamelContext camelctx = new DefaultCamelContext(); + camelctx.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start").to("ipfs:get?outdir=target"); + } + }); + + camelctx.start(); + assumeIPFS(camelctx); + + try { + ProducerTemplate producer = camelctx.createProducerTemplate(); + Path res = producer.requestBody("direct:start", HASH, Path.class); + Assert.assertEquals(Paths.get("target", HASH), res); + verifyFileContent(new FileInputStream(res.toFile())); + } finally { + camelctx.stop(); + } + } + + @Test + public void ipfsGetRecursive() throws Exception { + + String HASH = "Qme6hd6tYXTFb7bb7L3JZ5U6ygktpAHKxbaeffYyQN85mW"; + + CamelContext camelctx = new DefaultCamelContext(); + camelctx.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start").to("ipfs:get?outdir=target"); + } + }); + + camelctx.start(); + assumeIPFS(camelctx); + + try { + ProducerTemplate producer = camelctx.createProducerTemplate(); + Path res = producer.requestBody("direct:start", HASH, Path.class); + Assert.assertEquals(Paths.get("target", HASH), res); + Assert.assertTrue(res.toFile().isDirectory()); + Assert.assertTrue(res.resolve("index.html").toFile().exists()); + } finally { + camelctx.stop(); + } + } + + private void verifyFileContent(InputStream ins) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + StreamUtils.copyStream(ins, baos); + Assert.assertEquals("The quick brown fox jumps over the lazy dog.", new String (baos.toByteArray())); + } + + private void assumeIPFS(CamelContext camelctx) { + IPFSComponent comp = camelctx.getComponent("ipfs", IPFSComponent.class); + Assume.assumeTrue(comp.getIPFSClient().hasConnection()); + } +} \ No newline at end of file diff --git a/components/camel-ipfs/src/test/resources/html/chap/ch01.html b/components/camel-ipfs/src/test/resources/html/chap/ch01.html new file mode 100644 index 0000000000000..4edc3fd6b87d8 --- /dev/null +++ b/components/camel-ipfs/src/test/resources/html/chap/ch01.html @@ -0,0 +1,13 @@ + + + + IPFS + + + + +

Home

+

Chapter 01

+

logo

+ + diff --git a/components/camel-ipfs/src/test/resources/html/css/default.css b/components/camel-ipfs/src/test/resources/html/css/default.css new file mode 100644 index 0000000000000..8c0b2d558f3d0 --- /dev/null +++ b/components/camel-ipfs/src/test/resources/html/css/default.css @@ -0,0 +1,38 @@ +body { + font-family: "Verdana"; + color: #137cb9 +} + +a { + #text-decoration: none; + color: #137cb9 +} + +a.gray { + color: gray; +} + +h1 { + font-weight: normal; + font-size: 20px; +} + +h2 { + font-weight: normal; + font-size: 15px; +} + +th { + text-align: left; + font-weight: normal; + font-size: 14px; + color: gray; +} + +td.gray { + color: gray; +} +tr.gray { + color: gray; +} + diff --git a/components/camel-ipfs/src/test/resources/html/etc/userfile.txt b/components/camel-ipfs/src/test/resources/html/etc/userfile.txt new file mode 100644 index 0000000000000..8fe2a4b5ad117 --- /dev/null +++ b/components/camel-ipfs/src/test/resources/html/etc/userfile.txt @@ -0,0 +1 @@ +The quick brown fox jumps over the lazy dog. \ No newline at end of file diff --git a/components/camel-ipfs/src/test/resources/html/img/logo.png b/components/camel-ipfs/src/test/resources/html/img/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..ddda52e086e85692a94c2d014626bdf26f94e9c6 GIT binary patch literal 6715 zcmd5>_g53lwoT~LrG@|jLFt4lH3S5tC`Eb@siBC{lh8prNEJ~)se*z6(xsQsMY>e! zgf2Do&eQMSci(&e!JD;a&dixTd(WAl&N}n*k&ZeQIhY&(08nXasOtZ*ul{y2l0W0B z8m{J#0iyKPl>x>5Z0mm(H{3K#Q2+o1{of7*yiW)H0hl@(BG3qJEjgsCGt}DF)y59$ z?dHhu7416f98MPB3zvRK+w+>xDeWpI8|Id>^Sd2 zC845RaB@ygPMC+Sy_~+P+P{zgSt)QmMWfy1L`1y2yr5nZP*)EJ5iwa=SrJij5pi+h zKL}xzj|o`0~7fx{=Y8suSoy# z{s|RM4iov$v%$%=T6s+Y0Fa-i>ODhm;FdXs8~dmayxxz)*DQI7H}KUi2piVVp#PZQ z-m4((BnEMVT4&|Sm$yEJIjU$p1=~c$-bsrE((67~=B(*`Bgv`%^EH}0)?ibCPc z8}bMcS)kc#JB8xy#`Cq~jC%FQmNSKZB|^XSPp{wU)_WbNS2#59Z@sue9o_oW9tN~l z0@0HEe>HsFO0la2sbu&K3%We@hdKO z>Y|1XL`J>I(3*4+2*<2)z?Q2O{r3CnQ>7nMzlhP+CE?Lla&~ssF)?ATFUbDds4!$c z?q)E5HdjfHCy7!Y6@IdIPg18KU;Xr5Y&rc6qnVK+p{~6%uO0V>1#6cbiu9AStBBwA zFMMV&rtu?_#>JI-#Y{^FA9q8|3z5vUxb&*={_?sy4~x~G_08wMI5&zhbT93Ud-cBU zuhe$`s$ge(x`enlFW9cg-Ah`!(AGFR*mNm2xBoUp^E$y}j)ZC7nd6YH>?^HPw5YgV)^1 z(~c>stOl3$6(Gb}bfqLu?xI%s&}LF>6kPTP&uBF?k&ma;^dE}xfaTnjKAoRCOK0>? z=xmZE)1#F&>P>YHPVV%)B{KM-#3C&3d*O*T*}8aH9JX<7F}};Vd|HUadnYAn{g&a? zGg;;IY)J(5{{eJPD_-a0!?8jXwP*J$Va1bn--JW>#M~0G*B+&zmFn_xiSc{$kD0 z=u1JTT8VEz8>^TuwBK6VP{+$?`!sA>48Awa@?v*Bm~&=4U)||P8OJxmdelarbkh&q zV-!9y(@UV*ThnWkl7aD&WPgp#aGq?NH$grwa*~Fj^ z;;=JNnVoOC^z?KaRQ7-4VbgDKdFo}=?itmgzM(MGrrET|BJ+DCuRo$T#WS`{dd@90 zUih)}G$teM5aMoA)`J@z#h=}eX_%}<-5l?9VqX;s~%nH%W<47^!j&e;`m5caK?whmfx-dpTcXokG|YP@RI* zGSU2X+9hagiE>JIw%YTsJV>>lS>k{0b8uttCI!jo(uX?@tBa{p7LkdgT_>#OZ_S3M zH#xEQ(^0rZW0J|H9nvoY!eIK*B_^0=JE$0r{HYgWQ-*TDornf5QS?jdh z@+D{&R<^7mzMFOX=Ms>2phlC0;{s+Byl!m>^smkf9KRoc4M&fUO{U))vxg~fkH0+a zaiQvD+1kVg&0RK^km_))&%@JNZI@`KXG5hGUv#lIp4H~==792Z@@*_Bl;9JL+eCZ9 z5mc*yhDehKZyZ0alNtFMNZ2sVTJgtzR)6=52qD(nozZUjvD+j-;^wKdx4i{*>P<&C7EzmhdLut$Z zc}TP6LH{tD-RtDU`NyjM5XrwUxdW9i;m0yBv^N=Z(h z)a+Xem5_KJmX~S2_bpNc_L6pTr!Ko+-<$_vH3vBe&4Al6QbqjdQcl+fL0qC;9lvWj z%jvKd^EOt@*oJAHT$z5tCg2kSNy1ODHaV}ZSiH$jsH}cRjh0DqW!uS55|C*Si*@)J zXHvgPy3wUgRTz9cXOhak0;5s0s5pf6z1-~Nvxg{Rc3*)fs!iN8qmtR#TGRC&obw3Y zlrYJfHNnv|MvF-)-{MYm65TElc*9x#6}(Xq)Pb$V9%6NaH-Z$D3{_9QG=ft!vnTMi z&8d1tlH3qzGl3HkV#j|mkn0+8pvA!6LJ^J0{~QzjR8>jiqwwzh4k1Tw;dBRcVZm4? zX+_)bT{G9hf?sh3o-G97H&hH4Ks=Ovz#elPqV|SbjKs(@w;hYOvIMh(8Tv}^f&=?m ztV`{YWUmGuc87v+??me|vl2gokjEnwk0^&=x6>M=fGZzlJ&{=?nZ!__w_U|+o-9*w zk@}`_V6uE>8I<97p^|0lE4#f`Q{riQ7m1iHgbxPfEdsEfiHQp%8xh`JBhXz}2O zB(o^EUa)-=Bfvo|X1Yx)4Ev^Q$?3hH)s*PoB2ji);O}kwED4UU7Ocr4pdc9eMM`RL zlXWP|jg00|duUCE*z`=O9BzRo$oy+opYlY7krAo_3?GSercL%_%H@6B0`3;H9|~aC zIPe0LOn$D;1$`G}T~?ki0dzvzu>4s2c?rO984MbSKc>LG4Z3NMZq{^2=2095;f30L z^EHF)Xq0G9p4ys~8AWGenwY#rwHOpu-G>kw@Z|#f% zMaRUWsG?ALQL*xE$KIu^J<=KBnar?hx+AZ4`5N#tZaKJ)N*5g=&!vCXn;& z@e1E8_LJMecUq&4+sQg+vtO8bKlLg^SV8-IB?YU8=*#rkz}Ix5arHzSmCC0cejewY zQ?5VVyOAIf8Q${Hu21)mSF0GVdKMY!(JgEp#0=UlVMGb-h|i}7!$t+w>I<66GlMnX zJ~SGEbAE8D**LX>ULNG* z6`vr=g>$7oe?A|#R_4*>Le2^g;l9nS;mhX|?&d#kpyGG@96vZUSRvZkO-=O$QU2hr zkVOc#33!T{F@i3>!RN$eEh)0)us#eIOu`Txu;pzm@bym+BfgMM#Ca5im?LT}s5Bp% z*%8?IeBiy&dh(fC#n;oEflA$J(^y7+Qw;8VY|h>`;&DZWzj?pqBs`ZVujL7Sbj2V$ zWUS32I(&tiyFYk*VXe?}*54csVeiJ6Bpua6!AI~XZ6vw8qBBeh-BxdnA1F;*x`d{c zTPSBL0w)5XBr@sEB;N@n^KvJi3QZ}wem>A$CJ;gO zHfz6~qGIp4?xeZmEFQ-&DS>TzjHlJC-QkffejZFKX)@Y?#G(2)xPz_t z4@QZ&>++nX6e=$!Hxg_o&a?lBNdgsOZz^PtmhZVcb4xwIl8_G({gly-$BlOv<_7ql zfa2qWB-oV}l{@1I#3O@fd%4-W&wSs?EK(|La!fRu+0E;LO5E1^Op##AWid6e<#yme zm~}1bKxhgzs?9@-dF^J#OVk64qP&sCDoGRk+Kpvu=i;YQ5w*YNOZ(B&q~iruz)Iyf zJGBRDw6$+OU6%{_%8`eu9Crl^1Yu4T=DV=)pca^VSUO@!vQ1v;03np?bZa>awx=`5 z_p!8$MG2)bu=-y1z+oEMHT0D#f5F@huJO?QWLGE_CBu$Ag(wKQI*o7*=N4XA`Gpvz z$S&;})Kgk4UH#(2mO3ngb4d{qn7IitTu(?6*^nzuI52OOxXz84z_NP1%a=Ys$ zHb|x#rxJ)G2$EQ-4{9dfCee~zX()9p(k>3tI%RkrZ^lX8F6vFIoscK9usT0R8frJ| zGU#>eeoNMXjRoTv)g9ccEAoJMTI_+F!l9WsS#M;c>@j6kW z;(=5JAii|3PZB;1W6B}!nIq;)jsZm1vxs)WI0&{0iUGz1jX_@ojk_jC$oPEOqJsBT zfh(R9+Ik2{iS*T?yTnp$v2i^SE9Icb&GK2&EBcdLyE00->Nagm;!X|&HWn-?7CV3W*Z@UrvDMrNOXEYf<32Ex za5P(ch{O9rB**2^Gur`5Q|*YurPpy8G#<}2q^X$gS-h;lFKq-#c`j?hSGH^+A&25P z4XX^ux&;>0IHbIvJGfUv7DYPNws+wYji(hu)fMwacBZAOeYf;bWOd|8y-C0E!-osW zFnX~|DiR^)IZY(F^1a-;PRy!3^QB>I&IbqKXV(KnwlaLaO&o97^UjNw{Np0uv39pl zMCDfJ7(Y?U^W%SyIokpyCVa3tGs1h1en)2=Ksu&Q)+STY&Gf%|6PGe~kI5PnFYlA9 z>-P_@)xLlFd%c0WC9U=jyN}l8iAP;|i_dF`wjW|pi8649s$;yq3S`T1=y@@Z;R0R<-4H-8H*wouoc(x|FR5Clm~1F?nR=da-Z@AGql5lg zv1`9cH?N#cHQy*69SvDc!xk>cRWnwK#X~F!D0Yn_A|0}wrG6wHdllvx=<=uf)H!{u zIRyz>%C~Aifx!&jF)rtRb-%gcWhyDENO z_0NG^iyO=aJf826HUJ{y5&d>eiyY~=%$@fz0yfL01rcjR6)DsOdm$AKX zloW^6LL384$*%VLuViJ8^}c`C#n^VG#)y=c{2cX&w=B?7!O7i*vDQ#|1GB5Ur9D)F z?{}yq90-Sd&*1L63gE+dK+XicI!7;aUpxbu2lo^3HB&|e)- zJZ*PAc67Lrbwi>owh^^-4p?w|;d01jJTg5<4we!g*pgC~r z2itng!e~}NW=iALr^5~C2=3lx;>XvWcD{7#ZjFczEihD&pQF3$+r?r+T1{-mrZykJ zm{_yZ6;Cg`V$Mm>492Iz+`0^k2^83tIG!1Q{S7y_JJXwzVQZwF(**x)S&Hq-1znKa zud9ni`(_&)N(|mnpxsxIaWX=iKrB#I_;nVF86)z{RlgIuE_RWsYSd2(jyvO)y(Lj$ zV!R@(KkS19*v21obCf)BzrI|ZmnWZ74r+X@a$fLD+hQi-DeVt%G-;22>(Pj=2U0J2#wnP4$Q{EB7?O8f4a>qa(e$w20b$SV-UK`C+qa` z^1S*<1QaO@d83$>@MWw&YX|qC43~A9ksY*#*#)A=^1B`$AFT~cw3s!9sI!{5T6&!) z6{Q`?^dxsT-%CZDbD)a%h!`LdWqR`Cr|z!p4+J3-dns#bE*)$6#B=&f8!{H+sT2PooqcH6SWx5RfiaCo=7}O4AMHx z!4Ku{1gza2cXw@}y?)%=e7gW_e~O`C-fg3(EveaK;Y2LxAwY!he0V%fG-4vRFI!Yd zPkBi5smo7pZ-y4LqnoCGow6n~D!^aFWXO>4+|DkoGk(65^|k2aDmekCVo+GNL$emQ zn_K`n;)a*YyfA#El>bQSuA6-=C(FL}T5(;Y)Ah~RqFs)FH-{2)FTF0*9nK%Zc;cC- zc&=liA7A(i#ot#tqZ|yMD7k+{)w*}i(Lgsd`8aBgn}KRJ!|N6gX*Eb_Hharwk?PVB z)K7Rf!?P~%Glc#H5Z;-6{g8%7^z_+2b88@02mst-qXl z?_~JR1>l(&ub<63xV9XJ+Pk+)J@2Lyk&szCSO}%?_X>P^4L53z5~1fgP&6D$XsEML zY#J$pSD^73XB_<>Rztm)IQm&$=P!8tB(m)n24@vblrP&}?APACH&zc8VZg}`J7!tj zND7jIy|RdOD98KKxL9>?#2a-qUHbc-mzWw?vKdqf<#YV4vIazhK71=?xy-LmQQXCL z2}>j5kIGy0s zi<<+hesyyGD(cY(@pT3vco-4`|ijA05s6I;zFWRw4fdj6P18 literal 0 HcmV?d00001 diff --git a/components/camel-ipfs/src/test/resources/html/index.html b/components/camel-ipfs/src/test/resources/html/index.html new file mode 100644 index 0000000000000..3781300297051 --- /dev/null +++ b/components/camel-ipfs/src/test/resources/html/index.html @@ -0,0 +1,13 @@ + + + + IPFS + + + + +

Home

+

chapter one

+

logo

+ + diff --git a/components/camel-ipfs/src/test/resources/log4j2.properties b/components/camel-ipfs/src/test/resources/log4j2.properties new file mode 100644 index 0000000000000..081914f91a3be --- /dev/null +++ b/components/camel-ipfs/src/test/resources/log4j2.properties @@ -0,0 +1,30 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +rootLogger.level = DEBUG +rootLogger.appenderRef.file.ref = file + +appender.file.name = file +appender.file.type = File +appender.file.fileName = target/camel-test.log +appender.file.layout.type = PatternLayout +appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n + +appender.out.name = out +appender.out.type = Console +appender.out.layout.type = PatternLayout +appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n diff --git a/components/pom.xml b/components/pom.xml index 4356c930d7a27..a280e252942be 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -55,6 +55,7 @@ camel-http camel-http4 camel-hystrix + camel-ipfs camel-jetty-common camel-jetty camel-jetty9 diff --git a/parent/pom.xml b/parent/pom.xml index 983ecc6d2ec13..f3bc214e4e510 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -513,6 +513,7 @@ 2.4.2.Final 3.4.6 5.9.0.Final + 1.0.0.Beta1 1.0.0.RC4 3.0.1 1.9.22 @@ -4930,6 +4931,11 @@ ${pdfbox-version} + + io.nessus + nessus-ipfs + ${nessus-version} + From 16d6aeb2637cdd95fa6850906ce8fb442421afec Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 15 Nov 2018 13:33:46 +0100 Subject: [PATCH 022/125] CAMEL-12810 - Added explicit repository for Nessus and Spring Boot starter related --- components/camel-ipfs/pom.xml | 14 ++ .../src/main/docs/ipfs-component.adoc | 6 +- .../camel-ipfs-starter/pom.xml | 68 ++++++ .../IPFSComponentAutoConfiguration.java | 128 +++++++++++ .../IPFSComponentConfiguration.java | 55 +++++ .../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++++++++++++ .../src/main/resources/META-INF/NOTICE.txt | 11 + .../main/resources/META-INF/spring.factories | 19 ++ .../main/resources/META-INF/spring.provides | 17 ++ .../spring-boot/components-starter/pom.xml | 1 + 10 files changed, 518 insertions(+), 4 deletions(-) create mode 100644 platforms/spring-boot/components-starter/camel-ipfs-starter/pom.xml create mode 100644 platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/java/org/apache/camel/component/ipfs/springboot/IPFSComponentAutoConfiguration.java create mode 100644 platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/java/org/apache/camel/component/ipfs/springboot/IPFSComponentConfiguration.java create mode 100644 platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/LICENSE.txt create mode 100644 platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/NOTICE.txt create mode 100644 platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/spring.factories create mode 100644 platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/spring.provides diff --git a/components/camel-ipfs/pom.xml b/components/camel-ipfs/pom.xml index 20b6f7c959e61..f0ec0dc4dc7a9 100644 --- a/components/camel-ipfs/pom.xml +++ b/components/camel-ipfs/pom.xml @@ -36,6 +36,20 @@ org.apache.camel.spi.ComponentResolver;component=ipfs + + + jboss.ea + JBoss Repository + https://repository.jboss.org/nexus/content/groups/ea + + false + + + true + + + + org.apache.camel diff --git a/components/camel-ipfs/src/main/docs/ipfs-component.adoc b/components/camel-ipfs/src/main/docs/ipfs-component.adoc index 6a3fcc4ef23cf..a88cc1029f992 100644 --- a/components/camel-ipfs/src/main/docs/ipfs-component.adoc +++ b/components/camel-ipfs/src/main/docs/ipfs-component.adoc @@ -35,20 +35,18 @@ The IPFS component has no options. The IPFS endpoint is configured using URI syntax: ---- -ipfs:cmd +ipfs:host:port/cmd ---- with the following path and query parameters: -==== Path Parameters (3 parameters): +==== Path Parameters (1 parameters): [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type | *ipfsCmd* | The ipfs command | | String -| *ipfsHost* | The ipfs host | | String -| *ipfsPort* | The ipfs port | | int |=== diff --git a/platforms/spring-boot/components-starter/camel-ipfs-starter/pom.xml b/platforms/spring-boot/components-starter/camel-ipfs-starter/pom.xml new file mode 100644 index 0000000000000..76694fd5a45c4 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-ipfs-starter/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.camel + components-starter + 2.23.0-SNAPSHOT + + camel-ipfs-starter + jar + Spring-Boot Starter :: Camel :: IPFS + Spring-Boot Starter for Camel IPFS support + + + org.springframework.boot + spring-boot-starter + ${spring-boot-version} + + + org.apache.camel + camel-ipfs + ${project.version} + + + + org.apache.camel + camel-core-starter + + + org.apache.camel + camel-spring-boot-starter + + + + + + + jboss.ea + JBoss Repository + https://repository.jboss.org/nexus/content/groups/ea + + false + + + true + + + + + diff --git a/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/java/org/apache/camel/component/ipfs/springboot/IPFSComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/java/org/apache/camel/component/ipfs/springboot/IPFSComponentAutoConfiguration.java new file mode 100644 index 0000000000000..30f92ac146c3a --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/java/org/apache/camel/component/ipfs/springboot/IPFSComponentAutoConfiguration.java @@ -0,0 +1,128 @@ +/** + * 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.camel.component.ipfs.springboot; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.ipfs.IPFSComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.CamelPropertiesHelper; +import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; +import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; +import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@Conditional({ConditionalOnCamelContextAndAutoConfigurationBeans.class, + IPFSComponentAutoConfiguration.GroupConditions.class}) +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + IPFSComponentConfiguration.class}) +public class IPFSComponentAutoConfiguration { + + private static final Logger LOGGER = LoggerFactory + .getLogger(IPFSComponentAutoConfiguration.class); + @Autowired + private ApplicationContext applicationContext; + @Autowired + private CamelContext camelContext; + @Autowired + private IPFSComponentConfiguration configuration; + @Autowired(required = false) + private List> customizers; + + static class GroupConditions extends GroupCondition { + public GroupConditions() { + super("camel.component", "camel.component.ipfs"); + } + } + + @Lazy + @Bean(name = "ipfs-component") + @ConditionalOnMissingBean(IPFSComponent.class) + public IPFSComponent configureIPFSComponent() throws Exception { + IPFSComponent component = new IPFSComponent(); + component.setCamelContext(camelContext); + Map parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + CamelPropertiesHelper.setCamelProperties(camelContext, + nestedProperty, nestedParameters, false); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + CamelPropertiesHelper.setCamelProperties(camelContext, component, + parameters, false); + if (ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer customizer : customizers) { + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.ipfs.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.ipfs.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } + } + } + return component; + } +} \ No newline at end of file diff --git a/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/java/org/apache/camel/component/ipfs/springboot/IPFSComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/java/org/apache/camel/component/ipfs/springboot/IPFSComponentConfiguration.java new file mode 100644 index 0000000000000..8046aa3491893 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/java/org/apache/camel/component/ipfs/springboot/IPFSComponentConfiguration.java @@ -0,0 +1,55 @@ +/** + * 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.camel.component.ipfs.springboot; + +import javax.annotation.Generated; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * The camel-ipfs component provides access to the Interplanetary File System + * (IPFS). + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.ipfs") +public class IPFSComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { + + /** + * Whether to enable auto configuration of the ipfs component. This is + * enabled by default. + */ + private Boolean enabled; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file diff --git a/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/LICENSE.txt b/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000000..6b0b1270ff0ca --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + diff --git a/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/NOTICE.txt b/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/NOTICE.txt new file mode 100644 index 0000000000000..2e215bf2e6b1f --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/NOTICE.txt @@ -0,0 +1,11 @@ + ========================================================================= + == NOTICE file corresponding to the section 4 d of == + == the Apache License, Version 2.0, == + == in this case for the Apache Camel distribution. == + ========================================================================= + + This product includes software developed by + The Apache Software Foundation (http://www.apache.org/). + + Please read the different LICENSE files present in the licenses directory of + this distribution. diff --git a/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000000..d839f9786d29a --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,19 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +org.apache.camel.component.ipfs.springboot.IPFSComponentAutoConfiguration diff --git a/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/spring.provides b/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/spring.provides new file mode 100644 index 0000000000000..19172a6d9a1cf --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-ipfs-starter/src/main/resources/META-INF/spring.provides @@ -0,0 +1,17 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +provides: camel-ipfs diff --git a/platforms/spring-boot/components-starter/pom.xml b/platforms/spring-boot/components-starter/pom.xml index 8208920b731ef..d8d57c4a00ecd 100644 --- a/platforms/spring-boot/components-starter/pom.xml +++ b/platforms/spring-boot/components-starter/pom.xml @@ -204,6 +204,7 @@ camel-ignite-starter camel-infinispan-starter camel-influxdb-starter + camel-ipfs-starter camel-irc-starter camel-ironmq-starter camel-jackson-starter From 61517d6fa614b1568226955652217dcffc1e46d9 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 15 Nov 2018 13:38:17 +0100 Subject: [PATCH 023/125] CAMEL-12810 - Added camel-ipfs to kit --- apache-camel/src/main/descriptors/common-bin.xml | 1 + bom/camel-bom/pom.xml | 10 ++++++++++ parent/pom.xml | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml index 93dc9bd016ad1..3436d48a2047b 100644 --- a/apache-camel/src/main/descriptors/common-bin.xml +++ b/apache-camel/src/main/descriptors/common-bin.xml @@ -458,6 +458,7 @@ org.apache.camel:camel-ignite-starter org.apache.camel:camel-infinispan-starter org.apache.camel:camel-influxdb-starter + org.apache.camel:camel-ipfs-starter org.apache.camel:camel-irc-starter org.apache.camel:camel-ironmq-starter org.apache.camel:camel-jackson-starter diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml index 69a6f752ca5a3..b8266714fecfb 100644 --- a/bom/camel-bom/pom.xml +++ b/bom/camel-bom/pom.xml @@ -1188,6 +1188,16 @@ camel-influxdb-starter ${project.version} + + org.apache.camel + camel-ipfs + ${project.version} + + + org.apache.camel + camel-ipfs-starter + ${project.version} + org.apache.camel camel-irc diff --git a/parent/pom.xml b/parent/pom.xml index f3bc214e4e510..fa9b2d0aeaa25 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -1389,6 +1389,11 @@ camel-ignite ${project.version} + + org.apache.camel + camel-ipfs + ${project.version} + org.apache.camel camel-irc @@ -2908,6 +2913,11 @@ camel-influxdb-starter ${project.version} + + org.apache.camel + camel-ipfs-starter + ${project.version} + org.apache.camel camel-irc-starter From f8b59a591a67100ad482cdcb091ac2d97e06abd0 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 15 Nov 2018 14:20:08 +0100 Subject: [PATCH 024/125] Regen --- .../src/main/docs/aws-sqs-component.adoc | 3 +- .../src/main/docs/ipfs-component.adoc | 2 + components/readme.adoc | 5 +- docs/user-manual/en/SUMMARY.md | 1 + .../camel-spring-boot-dependencies/pom.xml | 164 +++++++++++------- 5 files changed, 107 insertions(+), 68 deletions(-) diff --git a/components/camel-aws/src/main/docs/aws-sqs-component.adoc b/components/camel-aws/src/main/docs/aws-sqs-component.adoc index 970bb77f4c014..d5dc6e82edde6 100644 --- a/components/camel-aws/src/main/docs/aws-sqs-component.adoc +++ b/components/camel-aws/src/main/docs/aws-sqs-component.adoc @@ -128,7 +128,7 @@ with the following path and query parameters: === Spring Boot Auto-Configuration -The component supports 30 options, which are listed below. +The component supports 31 options, which are listed below. @@ -142,6 +142,7 @@ The component supports 30 options, which are listed below. | *camel.component.aws-sqs.configuration.attribute-names* | A list of attribute names to receive when consuming. Multiple names can be separated by comma. | | String | *camel.component.aws-sqs.configuration.concurrent-consumers* | Allows you to use multiple threads to poll the sqs queue to increase throughput | 1 | Integer | *camel.component.aws-sqs.configuration.default-visibility-timeout* | The default visibility timeout (in seconds) | | Integer +| *camel.component.aws-sqs.configuration.delay-queue* | Define if you want to apply delaySeconds option to the queue or on single messages | false | Boolean | *camel.component.aws-sqs.configuration.delay-seconds* | Delay sending messages for a number of seconds. | | Integer | *camel.component.aws-sqs.configuration.delete-after-read* | Delete message from SQS after it has been read | true | Boolean | *camel.component.aws-sqs.configuration.delete-if-filtered* | Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | Boolean diff --git a/components/camel-ipfs/src/main/docs/ipfs-component.adoc b/components/camel-ipfs/src/main/docs/ipfs-component.adoc index a88cc1029f992..a975f43ad6063 100644 --- a/components/camel-ipfs/src/main/docs/ipfs-component.adoc +++ b/components/camel-ipfs/src/main/docs/ipfs-component.adoc @@ -66,6 +66,8 @@ with the following path and query parameters: The component supports 2 options, which are listed below. + + [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type diff --git a/components/readme.adoc b/components/readme.adoc index 5122b4217ecdd..163b1837c278a 100644 --- a/components/readme.adoc +++ b/components/readme.adoc @@ -2,7 +2,7 @@ Components ^^^^^^^^^^ // components: START -Number of Components: 303 in 205 JAR artifacts (22 deprecated) +Number of Components: 304 in 206 JAR artifacts (22 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -413,6 +413,9 @@ Number of Components: 303 in 205 JAR artifacts (22 deprecated) | link:camel-influxdb/src/main/docs/influxdb-component.adoc[InfluxDB] (camel-influxdb) + `influxdb:connectionBean` | 2.18 | The influxdb component allows you to interact with InfluxDB, a time series database. +| link:camel-ipfs/src/main/docs/ipfs-component.adoc[IPFS] (camel-ipfs) + +`ipfs:host:port/cmd` | 2.23 | The camel-ipfs component provides access to the Interplanetary File System (IPFS). + | link:camel-irc/src/main/docs/irc-component.adoc[IRC] (camel-irc) + `irc:hostname:port` | 1.1 | The irc component implements an IRC (Internet Relay Chat) transport. diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md index 628f5592b5da8..21fbd478ac290 100644 --- a/docs/user-manual/en/SUMMARY.md +++ b/docs/user-manual/en/SUMMARY.md @@ -294,6 +294,7 @@ * [IMAP](imap-component.adoc) * [Infinispan](infinispan-component.adoc) * [InfluxDB](influxdb-component.adoc) + * [IPFS](ipfs-component.adoc) * [IRC](irc-component.adoc) * [IronMQ](ironmq-component.adoc) * [JavaSpace](javaspace-component.adoc) diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml index 2d1d0f0b92744..0c7bb419ceea8 100644 --- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml +++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml @@ -171,6 +171,11 @@ httpunit 1.7 + + io.nessus + nessus-ipfs + 1.0.0.Beta1 + javax.annotation jsr250-api @@ -1389,6 +1394,16 @@ camel-influxdb-starter ${project.version} + + org.apache.camel + camel-ipfs + ${project.version} + + + org.apache.camel + camel-ipfs-starter + ${project.version} + org.apache.camel camel-irc @@ -3464,7 +3479,7 @@ org.knowm.xchange xchange-core - 4.3.11 + 4.3.12 org.mozilla @@ -3474,342 +3489,359 @@ org.optaplanner optaplanner-benchmark - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-benchmark - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-benchmark - 7.3.0.Final + 7.14.0.Final test-jar org.optaplanner optaplanner-benchmark - 7.3.0.Final + 7.14.0.Final javadoc org.optaplanner optaplanner-core - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-core - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-core - 7.3.0.Final + 7.14.0.Final test-jar org.optaplanner optaplanner-core - 7.3.0.Final + 7.14.0.Final javadoc org.optaplanner optaplanner-core-gwt - 7.3.0.Final + 7.14.0.Final gwt-lib org.optaplanner optaplanner-distribution - 7.3.0.Final + 7.14.0.Final zip org.optaplanner optaplanner-docs - 7.3.0.Final + 7.14.0.Final zip org.optaplanner optaplanner-examples - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-examples - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-examples - 7.3.0.Final + 7.14.0.Final test-jar org.optaplanner optaplanner-persistence-common - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-persistence-common - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-persistence-common - 7.3.0.Final + 7.14.0.Final test-jar org.optaplanner optaplanner-persistence-common - 7.3.0.Final + 7.14.0.Final javadoc org.optaplanner optaplanner-persistence-jackson - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-persistence-jackson - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-persistence-jackson - 7.3.0.Final + 7.14.0.Final test-jar org.optaplanner optaplanner-persistence-jackson - 7.3.0.Final + 7.14.0.Final javadoc org.optaplanner optaplanner-persistence-jaxb - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-persistence-jaxb - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-persistence-jaxb - 7.3.0.Final + 7.14.0.Final test-jar org.optaplanner optaplanner-persistence-jaxb - 7.3.0.Final + 7.14.0.Final javadoc org.optaplanner optaplanner-persistence-jpa - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-persistence-jpa - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-persistence-jpa - 7.3.0.Final + 7.14.0.Final test-jar org.optaplanner optaplanner-persistence-jpa - 7.3.0.Final + 7.14.0.Final javadoc org.optaplanner optaplanner-persistence-xstream - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-persistence-xstream - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-persistence-xstream - 7.3.0.Final + 7.14.0.Final test-jar org.optaplanner optaplanner-persistence-xstream - 7.3.0.Final + 7.14.0.Final javadoc org.optaplanner optaplanner-test - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-test - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-test - 7.3.0.Final + 7.14.0.Final test-jar org.optaplanner optaplanner-test - 7.3.0.Final + 7.14.0.Final javadoc org.optaplanner optaplanner-wb-domain-editor-api - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-wb-domain-editor-api - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-wb-domain-editor-backend - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-wb-domain-editor-backend - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-wb-domain-editor-client - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-wb-domain-editor-client - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-wb-guided-rule-editor-api - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-wb-guided-rule-editor-api - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-wb-guided-rule-editor-backend - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-wb-guided-rule-editor-backend - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-wb-guided-rule-editor-client - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-wb-guided-rule-editor-client - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-wb-solver-editor-api - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-wb-solver-editor-api - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-wb-solver-editor-backend - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-wb-solver-editor-backend - 7.3.0.Final + 7.14.0.Final sources org.optaplanner optaplanner-wb-solver-editor-client - 7.3.0.Final + 7.14.0.Final org.optaplanner optaplanner-wb-solver-editor-client - 7.3.0.Final + 7.14.0.Final sources org.optaplanner - optaplanner-wb-upstream-model - 7.3.0.Final + optaplanner-wb-ui + 7.14.0.Final + war org.optaplanner - optaplanner-wb-upstream-model - 7.3.0.Final - sources + optaplanner-webexamples + 7.14.0.Final + war org.optaplanner optaplanner-webexamples - 7.3.0.Final - war + 7.14.0.Final + sources org.optaplanner - optaplanner-webexamples - 7.3.0.Final + optaplanner-workbench-models-core + 7.14.0.Final + + + org.optaplanner + optaplanner-workbench-models-core + 7.14.0.Final + sources + + + org.optaplanner + optaplanner-workbench-models-datamodel-api + 7.14.0.Final + + + org.optaplanner + optaplanner-workbench-models-datamodel-api + 7.14.0.Final sources From 8e96df649421455c745988630e5256572b5dd2e8 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 15 Nov 2018 14:28:11 +0100 Subject: [PATCH 025/125] CAMEL-12810 - Fixed CS --- .../camel/component/ipfs/IPFSComponent.java | 22 +++--- .../camel/component/ipfs/IPFSEndpoint.java | 13 ++-- .../camel/component/ipfs/IPFSProducer.java | 39 +++++----- .../camel/component/ipfs/SimpleIPFSTest.java | 76 +++++++++---------- 4 files changed, 78 insertions(+), 72 deletions(-) diff --git a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSComponent.java b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSComponent.java index 9d5b228607fe9..f6cb6f85e3fd9 100644 --- a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSComponent.java +++ b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSComponent.java @@ -19,16 +19,16 @@ import java.net.URI; import java.util.Map; -import org.apache.camel.Endpoint; -import org.apache.camel.impl.DefaultComponent; - import io.nessus.ipfs.IPFSClient; import io.nessus.ipfs.impl.DefaultIPFSClient; +import org.apache.camel.Endpoint; +import org.apache.camel.impl.DefaultComponent; + public class IPFSComponent extends DefaultComponent { private IPFSClient client; - + @Override protected Endpoint createEndpoint(String urispec, String remaining, Map params) throws Exception { @@ -42,15 +42,19 @@ protected Endpoint createEndpoint(String urispec, String remaining, Map 0) config.setIpfsPort(port); + if (host != null) { + config.setIpfsHost(host); + } + if (port > 0) { + config.setIpfsPort(port); + } int idx = cmd.indexOf('/'); cmd = cmd.substring(idx + 1); } config.setIpfsCmd(cmd); - + client = createClient(config); - + return new IPFSEndpoint(urispec, this, config); } @@ -61,4 +65,4 @@ public IPFSClient getIPFSClient() { private synchronized IPFSClient createClient(IPFSConfiguration config) { return new DefaultIPFSClient(config.getIpfsHost(), config.getIpfsPort()); } -} \ No newline at end of file +} diff --git a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java index 6709332d8300d..049415185ff21 100644 --- a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java +++ b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java @@ -23,6 +23,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import io.nessus.ipfs.IPFSClient; + import org.apache.camel.Consumer; import org.apache.camel.Processor; import org.apache.camel.Producer; @@ -31,17 +33,16 @@ import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; -import io.nessus.ipfs.IPFSClient; - /** - * The camel-ipfs component provides access to the Interplanetary File System (IPFS). + * The camel-ipfs component provides access to the Interplanetary File System + * (IPFS). */ @UriEndpoint(firstVersion = "2.23.0", scheme = "ipfs", title = "IPFS", syntax = "ipfs:host:port/cmd", producerOnly = true, label = "file,ipfs") public class IPFSEndpoint extends DefaultEndpoint { @UriParam private final IPFSConfiguration configuration; - + public IPFSEndpoint(String uri, IPFSComponent component, IPFSConfiguration configuration) { super(uri, component); this.configuration = configuration; @@ -49,7 +50,7 @@ public IPFSEndpoint(String uri, IPFSComponent component, IPFSConfiguration confi @Override public IPFSComponent getComponent() { - return (IPFSComponent) super.getComponent(); + return (IPFSComponent)super.getComponent(); } @Override @@ -79,7 +80,7 @@ IPFSCommand getCommand() { throw new IllegalArgumentException("Unsupported command: " + cmd); } } - + String ipfsVersion() throws IOException { return ipfs().version(); } diff --git a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSProducer.java b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSProducer.java index 0f6e5333911a3..155492769f5c0 100644 --- a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSProducer.java +++ b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSProducer.java @@ -23,19 +23,18 @@ import java.util.List; import org.apache.camel.Exchange; -import org.apache.camel.impl.DefaultProducer; - import org.apache.camel.component.ipfs.IPFSConfiguration.IPFSCommand; +import org.apache.camel.impl.DefaultProducer; public class IPFSProducer extends DefaultProducer { - + public IPFSProducer(IPFSEndpoint endpoint) { super(endpoint); } @Override public IPFSEndpoint getEndpoint() { - return (IPFSEndpoint) super.getEndpoint(); + return (IPFSEndpoint)super.getEndpoint(); } @Override @@ -43,14 +42,14 @@ public void process(Exchange exchange) throws Exception { IPFSEndpoint endpoint = getEndpoint(); IPFSCommand cmd = endpoint.getCommand(); - + if (IPFSCommand.version == cmd) { - + String resp = endpoint.ipfsVersion(); exchange.getMessage().setBody(resp); - - } else if (IPFSCommand.add == cmd) { - + + } else if (IPFSCommand.add == cmd) { + Path path = pathFromBody(exchange); List cids = endpoint.ipfsAdd(path); Object resp = cids; @@ -58,20 +57,20 @@ public void process(Exchange exchange) throws Exception { resp = cids.size() > 0 ? cids.get(0) : null; } exchange.getMessage().setBody(resp); - - } else if (IPFSCommand.cat == cmd) { + + } else if (IPFSCommand.cat == cmd) { String cid = exchange.getMessage().getBody(String.class); InputStream resp = endpoint.ipfsCat(cid); exchange.getMessage().setBody(resp); - - } else if (IPFSCommand.get == cmd) { + + } else if (IPFSCommand.get == cmd) { Path outdir = endpoint.getConfiguration().getOutdir(); String cid = exchange.getMessage().getBody(String.class); Path resp = endpoint.ipfsGet(cid, outdir); exchange.getMessage().setBody(resp); - + } else { throw new UnsupportedOperationException(cmd.toString()); } @@ -79,9 +78,15 @@ public void process(Exchange exchange) throws Exception { private Path pathFromBody(Exchange exchange) { Object body = exchange.getMessage().getBody(); - if (body instanceof Path) return (Path) body; - if (body instanceof String) return Paths.get((String) body); - if (body instanceof File) return ((File) body).toPath(); + if (body instanceof Path) { + return (Path)body; + } + if (body instanceof String) { + return Paths.get((String)body); + } + if (body instanceof File) { + return ((File)body).toPath(); + } throw new IllegalArgumentException("Invalid path: " + body); } } diff --git a/components/camel-ipfs/src/test/java/org/apache/camel/component/ipfs/SimpleIPFSTest.java b/components/camel-ipfs/src/test/java/org/apache/camel/component/ipfs/SimpleIPFSTest.java index 589b919c2dcf3..07aec74ccb34c 100644 --- a/components/camel-ipfs/src/test/java/org/apache/camel/component/ipfs/SimpleIPFSTest.java +++ b/components/camel-ipfs/src/test/java/org/apache/camel/component/ipfs/SimpleIPFSTest.java @@ -1,12 +1,10 @@ -/* - * #%L - * Wildfly Camel :: Testsuite - * %% - * Copyright (C) 2013 - 2014 RedHat - * %% - * Licensed 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 +/** + * 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 * @@ -15,9 +13,7 @@ * 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. - * #L% */ - package org.apache.camel.component.ipfs; import java.io.ByteArrayOutputStream; @@ -29,6 +25,8 @@ import java.util.Arrays; import java.util.List; +import io.nessus.utils.StreamUtils; + import org.apache.camel.CamelContext; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; @@ -37,8 +35,6 @@ import org.junit.Assume; import org.junit.Test; -import io.nessus.utils.StreamUtils; - public class SimpleIPFSTest { @Test @@ -56,7 +52,7 @@ public void configure() throws Exception { camelctx.start(); assumeIPFS(camelctx); - + try { ProducerTemplate producer = camelctx.createProducerTemplate(); String resA = producer.requestBody("direct:startA", null, String.class); @@ -73,8 +69,8 @@ public void configure() throws Exception { @Test public void ipfsAddSingle() throws Exception { - String HASH = "QmYgjSRbXFPdPYKqQSnUjmXLYLudVahEJQotMaAJKt6Lbd"; - + String hash = "QmYgjSRbXFPdPYKqQSnUjmXLYLudVahEJQotMaAJKt6Lbd"; + CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override @@ -84,14 +80,14 @@ public void configure() throws Exception { }); Path path = Paths.get("src/test/resources/html/index.html"); - + camelctx.start(); assumeIPFS(camelctx); - + try { ProducerTemplate producer = camelctx.createProducerTemplate(); String res = producer.requestBody("direct:start", path, String.class); - Assert.assertEquals(HASH, res); + Assert.assertEquals(hash, res); } finally { camelctx.stop(); } @@ -101,8 +97,8 @@ public void configure() throws Exception { @SuppressWarnings("unchecked") public void ipfsAddRecursive() throws Exception { - String HASH = "Qme6hd6tYXTFb7bb7L3JZ5U6ygktpAHKxbaeffYyQN85mW"; - + String hash = "Qme6hd6tYXTFb7bb7L3JZ5U6ygktpAHKxbaeffYyQN85mW"; + CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override @@ -112,15 +108,15 @@ public void configure() throws Exception { }); Path path = Paths.get("src/test/resources/html"); - + camelctx.start(); assumeIPFS(camelctx); - + try { ProducerTemplate producer = camelctx.createProducerTemplate(); List res = producer.requestBody("direct:start", path, List.class); Assert.assertEquals(10, res.size()); - Assert.assertEquals(HASH, res.get(9)); + Assert.assertEquals(hash, res.get(9)); } finally { camelctx.stop(); } @@ -129,8 +125,8 @@ public void configure() throws Exception { @Test public void ipfsCat() throws Exception { - String HASH = "QmUD7uG5prAMHbcCfp4x1G1mMSpywcSMHTGpq62sbpDAg6"; - + String hash = "QmUD7uG5prAMHbcCfp4x1G1mMSpywcSMHTGpq62sbpDAg6"; + CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override @@ -141,10 +137,10 @@ public void configure() throws Exception { camelctx.start(); assumeIPFS(camelctx); - + try { ProducerTemplate producer = camelctx.createProducerTemplate(); - InputStream res = producer.requestBody("direct:start", HASH, InputStream.class); + InputStream res = producer.requestBody("direct:start", hash, InputStream.class); verifyFileContent(res); } finally { camelctx.stop(); @@ -154,8 +150,8 @@ public void configure() throws Exception { @Test public void ipfsGetSingle() throws Exception { - String HASH = "QmUD7uG5prAMHbcCfp4x1G1mMSpywcSMHTGpq62sbpDAg6"; - + String hash = "QmUD7uG5prAMHbcCfp4x1G1mMSpywcSMHTGpq62sbpDAg6"; + CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override @@ -166,11 +162,11 @@ public void configure() throws Exception { camelctx.start(); assumeIPFS(camelctx); - + try { ProducerTemplate producer = camelctx.createProducerTemplate(); - Path res = producer.requestBody("direct:start", HASH, Path.class); - Assert.assertEquals(Paths.get("target", HASH), res); + Path res = producer.requestBody("direct:start", hash, Path.class); + Assert.assertEquals(Paths.get("target", hash), res); verifyFileContent(new FileInputStream(res.toFile())); } finally { camelctx.stop(); @@ -180,8 +176,8 @@ public void configure() throws Exception { @Test public void ipfsGetRecursive() throws Exception { - String HASH = "Qme6hd6tYXTFb7bb7L3JZ5U6ygktpAHKxbaeffYyQN85mW"; - + String hash = "Qme6hd6tYXTFb7bb7L3JZ5U6ygktpAHKxbaeffYyQN85mW"; + CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override @@ -192,11 +188,11 @@ public void configure() throws Exception { camelctx.start(); assumeIPFS(camelctx); - + try { ProducerTemplate producer = camelctx.createProducerTemplate(); - Path res = producer.requestBody("direct:start", HASH, Path.class); - Assert.assertEquals(Paths.get("target", HASH), res); + Path res = producer.requestBody("direct:start", hash, Path.class); + Assert.assertEquals(Paths.get("target", hash), res); Assert.assertTrue(res.toFile().isDirectory()); Assert.assertTrue(res.resolve("index.html").toFile().exists()); } finally { @@ -207,11 +203,11 @@ public void configure() throws Exception { private void verifyFileContent(InputStream ins) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); StreamUtils.copyStream(ins, baos); - Assert.assertEquals("The quick brown fox jumps over the lazy dog.", new String (baos.toByteArray())); + Assert.assertEquals("The quick brown fox jumps over the lazy dog.", new String(baos.toByteArray())); } private void assumeIPFS(CamelContext camelctx) { IPFSComponent comp = camelctx.getComponent("ipfs", IPFSComponent.class); Assume.assumeTrue(comp.getIPFSClient().hasConnection()); } -} \ No newline at end of file +} From d0994de713f705332d48709bac1dbd6457f386a8 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 15 Nov 2018 15:11:05 +0100 Subject: [PATCH 026/125] CAMEL-12810 - Added a note about the Karaf feature missing --- components/camel-ipfs/src/main/docs/ipfs-component.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/camel-ipfs/src/main/docs/ipfs-component.adoc b/components/camel-ipfs/src/main/docs/ipfs-component.adoc index a975f43ad6063..78f6742a3c445 100644 --- a/components/camel-ipfs/src/main/docs/ipfs-component.adoc +++ b/components/camel-ipfs/src/main/docs/ipfs-component.adoc @@ -76,6 +76,9 @@ The component supports 2 options, which are listed below. |=== // spring-boot-auto-configure options: END +### Karaf support + +Actually this component is not supported in Karaf ### Message Headers From 047bf5c22ca0502f234100951313f90001756702 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 15 Nov 2018 15:50:33 +0100 Subject: [PATCH 027/125] CAMEL-12810 - Changed the referenced repository for nessus deps --- components/camel-ipfs/pom.xml | 4 ++-- .../spring-boot/components-starter/camel-ipfs-starter/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/camel-ipfs/pom.xml b/components/camel-ipfs/pom.xml index f0ec0dc4dc7a9..60fa640b91bb0 100644 --- a/components/camel-ipfs/pom.xml +++ b/components/camel-ipfs/pom.xml @@ -38,9 +38,9 @@ - jboss.ea + jboss.thirdparty JBoss Repository - https://repository.jboss.org/nexus/content/groups/ea + https://repository.jboss.org/nexus/service/local/repositories/thirdparty-releases/content/ false diff --git a/platforms/spring-boot/components-starter/camel-ipfs-starter/pom.xml b/platforms/spring-boot/components-starter/camel-ipfs-starter/pom.xml index 76694fd5a45c4..3e5b17be79b10 100644 --- a/platforms/spring-boot/components-starter/camel-ipfs-starter/pom.xml +++ b/platforms/spring-boot/components-starter/camel-ipfs-starter/pom.xml @@ -53,9 +53,9 @@ - jboss.ea + jboss.thirdparty JBoss Repository - https://repository.jboss.org/nexus/content/groups/ea + https://repository.jboss.org/nexus/service/local/repositories/thirdparty-releases/content/ false From 92cbacf2ab3c53a342bc193508f3001c4c3ae439 Mon Sep 17 00:00:00 2001 From: aldettinger Date: Thu, 15 Nov 2018 18:57:10 +0100 Subject: [PATCH 028/125] CAMEL-12940: Fixed an issue where dynamic doneFileName does not manage filename with 2 dots --- .../component/file/GenericFileEndpoint.java | 4 +- ...umeDynamicDoneFileNameWithTwoDotsTest.java | 68 +++++++++++++++++++ ...pleDynamicDoneFileNameWithTwoDotsTest.java | 68 +++++++++++++++++++ 3 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDynamicDoneFileNameWithTwoDotsTest.java create mode 100644 camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleDynamicDoneFileNameWithTwoDotsTest.java diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java index fac9e7e8fbe6f..c60312375aded 100644 --- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java +++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java @@ -1420,8 +1420,8 @@ protected String createDoneFileName(String fileName) { pattern = pattern.replaceFirst("\\$\\{file:name\\}", onlyName); pattern = pattern.replaceFirst("\\$simple\\{file:name\\}", onlyName); - pattern = pattern.replaceFirst("\\$\\{file:name.noext\\}", FileUtil.stripExt(onlyName)); - pattern = pattern.replaceFirst("\\$simple\\{file:name.noext\\}", FileUtil.stripExt(onlyName)); + pattern = pattern.replaceFirst("\\$\\{file:name.noext\\}", FileUtil.stripExt(onlyName, true)); + pattern = pattern.replaceFirst("\\$simple\\{file:name.noext\\}", FileUtil.stripExt(onlyName, true)); // must be able to resolve all placeholders supported if (StringHelper.hasStartToken(pattern, "simple")) { diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDynamicDoneFileNameWithTwoDotsTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDynamicDoneFileNameWithTwoDotsTest.java new file mode 100644 index 0000000000000..a45905a36b453 --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDynamicDoneFileNameWithTwoDotsTest.java @@ -0,0 +1,68 @@ +/** + * 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.camel.component.file; + +import java.io.File; +import java.lang.invoke.MethodHandles; + +import org.apache.camel.ContextTestSupport; +import org.apache.camel.Exchange; +import org.apache.camel.builder.NotifyBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.junit.Before; +import org.junit.Test; + +/** + * This class tests an issue where an input file is not picked up due to a dynamic + * doneFileName containing two dots. + */ +public class FileConsumeDynamicDoneFileNameWithTwoDotsTest extends ContextTestSupport { + + private static final String TARGET_DIR_NAME = "target/" + MethodHandles.lookup().lookupClass().getSimpleName(); + + @Override + @Before + public void setUp() throws Exception { + deleteDirectory(TARGET_DIR_NAME); + super.setUp(); + } + + @Test + public void testDynamicDoneFileNameContainingTwoDots() throws Exception { + NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create(); + getMockEndpoint("mock:result").expectedBodiesReceivedInAnyOrder("input-body"); + + template.sendBodyAndHeader("file:" + TARGET_DIR_NAME, "input-body", Exchange.FILE_NAME, "test.twodot.txt"); + template.sendBodyAndHeader("file:" + TARGET_DIR_NAME, "done-body", Exchange.FILE_NAME, "test.twodot.done"); + + assertMockEndpointsSatisfied(); + assertTrue(notify.matchesMockWaitTime()); + + assertFalse("Input file should be deleted", new File(TARGET_DIR_NAME, "test.twodot.txt").exists()); + assertFalse("Done file should be deleted", new File(TARGET_DIR_NAME, "test.twodot.done").exists()); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("file:" + TARGET_DIR_NAME + "?doneFileName=${file:name.noext}.done&initialDelay=0").to("mock:result"); + } + }; + } +} diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleDynamicDoneFileNameWithTwoDotsTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleDynamicDoneFileNameWithTwoDotsTest.java new file mode 100644 index 0000000000000..d1de7a94bc4af --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleDynamicDoneFileNameWithTwoDotsTest.java @@ -0,0 +1,68 @@ +/** + * 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.camel.component.file; + +import java.io.File; +import java.lang.invoke.MethodHandles; + +import org.apache.camel.ContextTestSupport; +import org.apache.camel.Exchange; +import org.apache.camel.builder.NotifyBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.junit.Before; +import org.junit.Test; + +/** + * This class tests an issue where an input file is not picked up due to a + * dynamic doneFileName using the simple syntax and containing two dots. + */ +public class FileConsumeSimpleDynamicDoneFileNameWithTwoDotsTest extends ContextTestSupport { + + private static final String TARGET_DIR_NAME = "target/" + MethodHandles.lookup().lookupClass().getSimpleName(); + + @Override + @Before + public void setUp() throws Exception { + deleteDirectory(TARGET_DIR_NAME); + super.setUp(); + } + + @Test + public void testSimpleDynamicDoneFileNameContainingTwoDots() throws Exception { + NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create(); + getMockEndpoint("mock:result").expectedBodiesReceivedInAnyOrder("input-body"); + + template.sendBodyAndHeader("file:" + TARGET_DIR_NAME, "input-body", Exchange.FILE_NAME, "test.twodot.txt"); + template.sendBodyAndHeader("file:" + TARGET_DIR_NAME, "done-body", Exchange.FILE_NAME, "test.twodot.done"); + + assertMockEndpointsSatisfied(); + assertTrue(notify.matchesMockWaitTime()); + + assertFalse("Input file should be deleted", new File(TARGET_DIR_NAME, "test.twodot.txt").exists()); + assertFalse("Done file should be deleted", new File(TARGET_DIR_NAME, "test.twodot.done").exists()); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("file:" + TARGET_DIR_NAME + "?doneFileName=$simple{file:name.noext}.done&initialDelay=0").to("mock:result"); + } + }; + } +} From e9eea21b6d1041410d3c1297336dae6946727d14 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Fri, 16 Nov 2018 09:28:34 +0100 Subject: [PATCH 029/125] Camel-Jbpm: Fixed CS --- .../component/jbpm/JBPMConfiguration.java | 28 ++-- .../camel/component/jbpm/JBPMEndpoint.java | 12 +- .../camel/component/jbpm/JBPMProducer.java | 148 +++++++++++------- .../jbpm/server/CamelKieServerExtension.java | 67 ++++---- .../jbpm/JBPMComponentIntegrationTest.java | 41 +++-- 5 files changed, 169 insertions(+), 127 deletions(-) diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConfiguration.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConfiguration.java index 9633aaa765ee6..b415bfea30564 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConfiguration.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMConfiguration.java @@ -30,11 +30,13 @@ @UriParams public class JBPMConfiguration { - @UriPath @Metadata(required = "true") + @UriPath + @Metadata(required = "true") private URL connectionURL; @UriParam(label = "producer", defaultValue = "startProcess") private String operation; - @UriParam @Metadata(required = "true") + @UriParam + @Metadata(required = "true") private String deploymentId; @UriParam private Long processInstanceId; @@ -84,7 +86,7 @@ public class JBPMConfiguration { private Class[] extraJaxbClasses; @UriParam private Boolean emitterSendItems; - + @UriPath private String eventListenerType; @@ -159,7 +161,8 @@ public Object getEvent() { } /** - * the data associated with this event when signalEvent operation is performed + * the data associated with this event when signalEvent operation is + * performed */ public void setEvent(Object event) { this.event = event; @@ -203,7 +206,7 @@ public Long getTaskId() { } /** - *the id of the task + * the id of the task */ public void setTaskId(Long taskId) { this.taskId = taskId; @@ -241,7 +244,7 @@ public Integer getPage() { public void setPage(Integer page) { this.page = page; } - + public Integer getPageSize() { return pageSize; } @@ -374,7 +377,6 @@ public void setExtraJaxbClasses(Class[] extraJaxbClasses) { this.extraJaxbClasses = extraJaxbClasses; } - public String getEventListenerType() { return eventListenerType; } @@ -385,13 +387,14 @@ public String getEventListenerType() { public void setEventListenerType(String eventListenerType) { this.eventListenerType = eventListenerType; } - + public Boolean getEmitterSendItems() { return emitterSendItems; } /** - * Sets if event produced by emitter should be sent as single items or complete collection + * Sets if event produced by emitter should be sent as single items or + * complete collection */ public void setEmitterSendItems(Boolean emiterSendItems) { this.emitterSendItems = emiterSendItems; @@ -399,6 +402,11 @@ public void setEmitterSendItems(Boolean emiterSendItems) { @Override public String toString() { - return "JBPMConfiguration [connectionURL=" + connectionURL + ", operation=" + operation + ", deploymentId=" + deploymentId + ", processInstanceId=" + processInstanceId + ", value=" + value + ", processId=" + processId + ", eventType=" + eventType + ", event=" + event + ", maxNumber=" + maxNumber + ", identifier=" + identifier + ", workItemId=" + workItemId + ", taskId=" + taskId + ", userId=" + userId + ", page=" + page + ", pageSize=" + pageSize + ", targetUserId=" + targetUserId + ", attachmentId=" + attachmentId + ", contentId=" + contentId + ", task=" + task + ", entities=" + entities + ", statuses=" + statuses + ", userName=" + userName + ", password=" + password + ", timeout=" + timeout + ", parameters=" + parameters + ", extraJaxbClasses=" + Arrays.toString(extraJaxbClasses) + ", eventListenerType=" + eventListenerType + "]"; + return "JBPMConfiguration [connectionURL=" + connectionURL + ", operation=" + operation + ", deploymentId=" + deploymentId + ", processInstanceId=" + processInstanceId + + ", value=" + value + ", processId=" + processId + ", eventType=" + eventType + ", event=" + event + ", maxNumber=" + maxNumber + ", identifier=" + identifier + + ", workItemId=" + workItemId + ", taskId=" + taskId + ", userId=" + userId + ", page=" + page + ", pageSize=" + pageSize + ", targetUserId=" + targetUserId + + ", attachmentId=" + attachmentId + ", contentId=" + contentId + ", task=" + task + ", entities=" + entities + ", statuses=" + statuses + ", userName=" + userName + + ", password=" + password + ", timeout=" + timeout + ", parameters=" + parameters + ", extraJaxbClasses=" + Arrays.toString(extraJaxbClasses) + + ", eventListenerType=" + eventListenerType + "]"; } } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMEndpoint.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMEndpoint.java index eb0472f94c6c2..a8af4eeff648e 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMEndpoint.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMEndpoint.java @@ -35,7 +35,8 @@ import org.slf4j.LoggerFactory; /** - * The jbpm component provides integration with jBPM (Business Process Management). + * The jbpm component provides integration with jBPM (Business Process + * Management). */ @UriEndpoint(firstVersion = "2.6.0", scheme = "jbpm", title = "JBPM", syntax = "jbpm:connectionURL", label = "process") public class JBPMEndpoint extends DefaultEndpoint { @@ -50,8 +51,9 @@ public JBPMEndpoint(String uri, JBPMComponent component, JBPMConfiguration confi } public Producer createProducer() throws Exception { - KieServicesConfiguration kieConfiguration = KieServicesFactory.newRestConfiguration(configuration.getConnectionURL().toExternalForm(), configuration.getUserName(), configuration.getPassword()); - + KieServicesConfiguration kieConfiguration = KieServicesFactory.newRestConfiguration(configuration.getConnectionURL().toExternalForm(), configuration.getUserName(), + configuration.getPassword()); + if (configuration.getTimeout() != null) { kieConfiguration.setTimeout(configuration.getTimeout()); } @@ -59,8 +61,8 @@ public Producer createProducer() throws Exception { List> classes = Arrays.asList(configuration.getExtraJaxbClasses()); kieConfiguration.addExtraClasses(new LinkedHashSet<>(classes)); } - - KieServicesClient kieServerClient = KieServicesFactory.newKieServicesClient(kieConfiguration); + + KieServicesClient kieServerClient = KieServicesFactory.newKieServicesClient(kieConfiguration); LOGGER.debug("JBPM Producer created with KieServerClient configured for {}", configuration.getConnectionURL()); return new JBPMProducer(this, kieServerClient); } diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMProducer.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMProducer.java index c9f218b3e940b..9688a40ff2e94 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMProducer.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/JBPMProducer.java @@ -49,15 +49,14 @@ public class JBPMProducer extends DefaultProducer { private static final transient Logger LOGGER = LoggerFactory.getLogger(JBPMProducer.class); private static KieCommands commandsFactory = KieServices.get().getCommands(); - + private JBPMConfiguration configuration; private KieServicesClient kieServicesClient; - public JBPMProducer(JBPMEndpoint endpoint, KieServicesClient kieServicesClient) { super(endpoint); this.configuration = endpoint.getConfiguration(); - this.kieServicesClient = kieServicesClient; + this.kieServicesClient = kieServicesClient; } @Override @@ -69,7 +68,7 @@ protected void doStart() throws Exception { @Override protected void doStop() throws Exception { - super.doStop(); + super.doStop(); } public void process(Exchange exchange) throws Exception { @@ -90,7 +89,7 @@ Operation getOperation(Exchange exchange) { enum Operation { - //PROCESS OPERATIONS + // PROCESS OPERATIONS startProcess { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { @@ -98,31 +97,36 @@ void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuratio Long processInstance = processClient.startProcess(configuration.getDeploymentId(), getProcessId(configuration, exchange), getParameters(configuration, exchange)); setResult(exchange, processInstance); } - }, abortProcessInstance { + }, + abortProcessInstance { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); processClient.abortProcessInstance(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange))); } - }, signalEvent { + }, + signalEvent { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); Long processInstanceId = getProcessInstanceId(configuration, exchange); if (processInstanceId != null) { - processClient.signalProcessInstance(configuration.getDeploymentId(), processInstanceId, getEventType(configuration, exchange), getEvent(configuration, exchange)); + processClient.signalProcessInstance(configuration.getDeploymentId(), processInstanceId, getEventType(configuration, exchange), + getEvent(configuration, exchange)); } else { processClient.signal(configuration.getDeploymentId(), getEventType(configuration, exchange), getEvent(configuration, exchange)); } } - }, getProcessInstance { + }, + getProcessInstance { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); ProcessInstance processInstance = processClient.getProcessInstance(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange))); setResult(exchange, processInstance); } - }, getProcessInstances { + }, + getProcessInstances { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { QueryServicesClient queryClient = kieServicesClient.getServicesClient(QueryServicesClient.class); @@ -131,24 +135,25 @@ void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuratio } }, - //RULE OPERATIONS + // RULE OPERATIONS fireAllRules { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { RuleServicesClient ruleClient = kieServicesClient.getServicesClient(RuleServicesClient.class); List> commands = new ArrayList>(); BatchExecutionCommand executionCommand = commandsFactory.newBatchExecution(commands); - + Integer max = getMaxNumber(configuration, exchange); if (max != null) { commands.add(commandsFactory.newFireAllRules(max)); } else { commands.add(commandsFactory.newFireAllRules()); } - ServiceResponse reply = ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); + ServiceResponse reply = ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); setResult(exchange, reply.getResult()); } - }, getGlobal { + }, + getGlobal { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { RuleServicesClient ruleClient = kieServicesClient.getServicesClient(RuleServicesClient.class); @@ -157,10 +162,11 @@ void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuratio String identifier = getIdentifier(configuration, exchange); commands.add(commandsFactory.newGetGlobal(identifier, identifier)); - ServiceResponse reply = ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); + ServiceResponse reply = ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); setResult(exchange, reply.getResult().getValue(identifier)); } - }, setGlobal { + }, + setGlobal { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { RuleServicesClient ruleClient = kieServicesClient.getServicesClient(RuleServicesClient.class); @@ -169,165 +175,196 @@ void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuratio commands.add(commandsFactory.newSetGlobal(getIdentifier(configuration, exchange), getValue(configuration, exchange))); - ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); + ruleClient.executeCommandsWithResults(configuration.getDeploymentId(), executionCommand); } }, - //WORK ITEM OPERATIONS + // WORK ITEM OPERATIONS abortWorkItem { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); processClient.abortWorkItem(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange)), safe(getWorkItemId(configuration, exchange))); } - }, completeWorkItem { + }, + completeWorkItem { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); - processClient.completeWorkItem(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange)), safe(getWorkItemId(configuration, exchange)), getParameters(configuration, exchange)); + processClient.completeWorkItem(configuration.getDeploymentId(), safe(getProcessInstanceId(configuration, exchange)), safe(getWorkItemId(configuration, exchange)), + getParameters(configuration, exchange)); } }, - //TASK OPERATIONS + // TASK OPERATIONS activateTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); taskClient.activateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } - }, claimTask { + }, + claimTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); taskClient.claimTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } - }, completeTask { + }, + completeTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.completeAutoProgress(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), getParameters(configuration, exchange)); + taskClient.completeAutoProgress(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), + getParameters(configuration, exchange)); } - }, delegateTask { + }, + delegateTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.delegateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), getTargetUserId(configuration, exchange)); + taskClient.delegateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), + getTargetUserId(configuration, exchange)); } - }, exitTask { + }, + exitTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); taskClient.exitTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } - }, failTask { + }, + failTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.failTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), getParameters(configuration, exchange)); + taskClient.failTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), + getParameters(configuration, exchange)); } - }, getAttachment { + }, + getAttachment { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - TaskAttachment attachment = taskClient.getTaskAttachmentById(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), safe(getAttachmentId(configuration, exchange))); + TaskAttachment attachment = taskClient.getTaskAttachmentById(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), + safe(getAttachmentId(configuration, exchange))); setResult(exchange, attachment); } - }, getTasksAssignedAsBusinessAdministrator { + }, + getTasksAssignedAsBusinessAdministrator { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - List taskSummaries = taskClient.findTasksAssignedAsBusinessAdministrator(getUserId(configuration, exchange), getPage(configuration, exchange), getPageSize(configuration, exchange)); + List taskSummaries = taskClient.findTasksAssignedAsBusinessAdministrator(getUserId(configuration, exchange), getPage(configuration, exchange), + getPageSize(configuration, exchange)); setResult(exchange, taskSummaries); } - }, getTasksAssignedAsPotentialOwnerByStatus { + }, + getTasksAssignedAsPotentialOwnerByStatus { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - List taskSummaries = taskClient.findTasksAssignedAsPotentialOwner(getUserId(configuration, exchange), getStatuses(configuration, exchange), getPage(configuration, exchange), getPageSize(configuration, exchange)); + List taskSummaries = taskClient.findTasksAssignedAsPotentialOwner(getUserId(configuration, exchange), getStatuses(configuration, exchange), + getPage(configuration, exchange), getPageSize(configuration, exchange)); setResult(exchange, taskSummaries); } - }, getTaskByWorkItem { + }, + getTaskByWorkItem { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); TaskInstance task = taskClient.findTaskByWorkItemId(safe(getWorkItemId(configuration, exchange))); setResult(exchange, task); } - }, getTaskBy { + }, + getTaskBy { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); TaskInstance task = taskClient.findTaskById(safe(getTaskId(configuration, exchange))); setResult(exchange, task); } - }, getTaskContent { + }, + getTaskContent { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); Map content = taskClient.getTaskOutputContentByTaskId(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange))); setResult(exchange, content); } - }, getTasksByProcessInstance { + }, + getTasksByProcessInstance { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); List processInstanceIds = taskClient.findTasksByStatusByProcessInstanceId(safe(getProcessInstanceId(configuration, exchange)), Collections.emptyList(), - getPage(configuration, exchange), getPageSize(configuration, exchange)); + getPage(configuration, exchange), getPageSize(configuration, exchange)); setResult(exchange, processInstanceIds); } - }, getTasksByStatusByProcessInstance { + }, + getTasksByStatusByProcessInstance { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - List taskSummaryList = taskClient.findTasksByStatusByProcessInstanceId( - safe(getProcessInstanceId(configuration, exchange)), getStatuses(configuration, exchange), - getPage(configuration, exchange), getPageSize(configuration, exchange)); + List taskSummaryList = taskClient.findTasksByStatusByProcessInstanceId(safe(getProcessInstanceId(configuration, exchange)), + getStatuses(configuration, exchange), getPage(configuration, exchange), + getPageSize(configuration, exchange)); setResult(exchange, taskSummaryList); } - }, getTasksOwned { + }, + getTasksOwned { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - List summaryList = taskClient.findTasksOwned(getUserId(configuration, exchange), getPage(configuration, exchange), getPageSize(configuration, exchange)); + List summaryList = taskClient.findTasksOwned(getUserId(configuration, exchange), getPage(configuration, exchange), + getPageSize(configuration, exchange)); setResult(exchange, summaryList); } - }, nominateTask { + }, + nominateTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); - taskClient.nominateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), getEntities(configuration, exchange)); + taskClient.nominateTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange), + getEntities(configuration, exchange)); } - }, releaseTask { + }, + releaseTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); taskClient.releaseTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } - }, resumeTask { + }, + resumeTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); taskClient.resumeTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } - }, skipTask { + }, + skipTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); taskClient.skipTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } - }, startTask { + }, + startTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); taskClient.startTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } - }, stopTask { + }, + stopTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); taskClient.stopTask(configuration.getDeploymentId(), safe(getTaskId(configuration, exchange)), getUserId(configuration, exchange)); } - }, suspendTask { + }, + suspendTask { @Override void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange) { UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class); @@ -382,7 +419,7 @@ Integer getPage(JBPMConfiguration configuration, Exchange exchange) { } return page; } - + Integer getPageSize(JBPMConfiguration configuration, Exchange exchange) { Integer pageSize = exchange.getIn().getHeader(JBPMConstants.RESULT_PAGE_SIZE, Integer.class); if (pageSize == null) { @@ -502,4 +539,3 @@ void setResult(Exchange exchange, Object result) { abstract void execute(KieServicesClient kieServicesClient, JBPMConfiguration configuration, Exchange exchange); } } - diff --git a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/server/CamelKieServerExtension.java b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/server/CamelKieServerExtension.java index 3a8a0ea9bb0d6..fbc4448d59cac 100644 --- a/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/server/CamelKieServerExtension.java +++ b/components/camel-jbpm/src/main/java/org/apache/camel/component/jbpm/server/CamelKieServerExtension.java @@ -36,29 +36,28 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; - public class CamelKieServerExtension implements KieServerExtension { public static final String EXTENSION_NAME = "Camel"; - private static final Logger logger = LoggerFactory.getLogger(CamelKieServerExtension.class); + private static final Logger LOGGER = LoggerFactory.getLogger(CamelKieServerExtension.class); - private static final Boolean disabled = Boolean.parseBoolean(System.getProperty("org.camel.server.ext.disabled", "false")); + private static final Boolean DISABLED = Boolean.parseBoolean(System.getProperty("org.camel.server.ext.disabled", "false")); protected DefaultCamelContext camel; - + protected boolean managedCamel; protected Map camelContexts = new HashMap<>(); - + public CamelKieServerExtension() { this.managedCamel = true; } - + public CamelKieServerExtension(DefaultCamelContext camel) { this.camel = camel; this.managedCamel = false; } - + @Override public boolean isInitialized() { return camel != null; @@ -66,7 +65,7 @@ public boolean isInitialized() { @Override public boolean isActive() { - return disabled == false; + return !DISABLED; } @Override @@ -74,55 +73,55 @@ public void init(KieServerImpl kieServer, KieServerRegistry registry) { if (this.managedCamel && this.camel == null) { this.camel = new DefaultCamelContext(); this.camel.setName("KIE Server Camel context"); - + try (InputStream is = this.getClass().getResourceAsStream("/global-camel-routes.xml")) { if (is != null) { - - RoutesDefinition routes = camel.loadRoutesDefinition(is); - camel.addRouteDefinitions(routes.getRoutes()); + + RoutesDefinition routes = camel.loadRoutesDefinition(is); + camel.addRouteDefinitions(routes.getRoutes()); } } catch (Exception e) { - logger.error("Error while adding Camel context for KIE Server", e); + LOGGER.error("Error while adding Camel context for KIE Server", e); } } - + ServiceRegistry.get().register("GlobalCamelService", this.camel); } @Override public void destroy(KieServerImpl kieServer, KieServerRegistry registry) { ServiceRegistry.get().remove("GlobalCamelService"); - + if (this.managedCamel && this.camel != null) { try { this.camel.stop(); } catch (Exception e) { - logger.error("Failed at stopping KIE Server extension {}", EXTENSION_NAME); + LOGGER.error("Failed at stopping KIE Server extension {}", EXTENSION_NAME); } } } @Override public void createContainer(String id, KieContainerInstance kieContainerInstance, Map parameters) { - + ClassLoader classloader = kieContainerInstance.getKieContainer().getClassLoader(); try (InputStream is = classloader.getResourceAsStream("camel-routes.xml")) { if (is != null) { - + DefaultCamelContext context = new DefaultCamelContext(); - context.setName("KIE Server Camel context for container " + kieContainerInstance.getContainerId()); - - RoutesDefinition routes = context.loadRoutesDefinition(is); + context.setName("KIE Server Camel context for container " + kieContainerInstance.getContainerId()); + + RoutesDefinition routes = context.loadRoutesDefinition(is); annotateKJarRoutes(routes, id); context.addRouteDefinitions(routes.getRoutes()); context.start(); camelContexts.put(id, context); - + ServiceRegistry.get().register(id + "_CamelService", this.camel); - + } } catch (Exception e) { - logger.error("Error while adding Camel context for {}", kieContainerInstance.getContainerId(), e); + LOGGER.error("Error while adding Camel context for {}", kieContainerInstance.getContainerId(), e); } } @@ -140,14 +139,14 @@ public boolean isUpdateContainerAllowed(String id, KieContainerInstance kieConta @Override public void disposeContainer(String id, KieContainerInstance kieContainerInstance, Map parameters) { DefaultCamelContext context = camelContexts.get(id); - + if (context != null) { - + ServiceRegistry.get().remove(id + "_CamelService"); try { context.stop(); } catch (Exception e) { - logger.error("Error while removing Camel context for container {}", id, e); + LOGGER.error("Error while removing Camel context for container {}", id, e); } } } @@ -181,18 +180,18 @@ public String getExtensionName() { public Integer getStartOrder() { return 50; } - + @Override public void serverStarted() { if (this.managedCamel && this.camel != null && !this.camel.isStarted()) { try { this.camel.start(); } catch (Exception e) { - logger.error("Failed at start Camel context", e); + LOGGER.error("Failed at start Camel context", e); } } } - + @Override public String toString() { return EXTENSION_NAME + " KIE Server extension"; @@ -200,12 +199,12 @@ public String toString() { protected void annotateKJarRoutes(RoutesDefinition routes, String deploymentId) { for (RouteDefinition route : routes.getRoutes()) { - + for (FromDefinition from : route.getInputs()) { - + if (from.getUri().startsWith("jbpm:events") && !from.getUri().contains("deploymentId")) { StringBuilder uri = new StringBuilder(from.getUri()); - + String[] split = from.getUri().split("\\?"); if (split.length == 1) { // no query given @@ -217,7 +216,7 @@ protected void annotateKJarRoutes(RoutesDefinition routes, String deploymentId) uri.append("deploymentId=").append(deploymentId); from.setUri(uri.toString()); } - + System.out.println(from.getUri()); } } diff --git a/components/camel-jbpm/src/test/java/org/apache/camel/component/jbpm/JBPMComponentIntegrationTest.java b/components/camel-jbpm/src/test/java/org/apache/camel/component/jbpm/JBPMComponentIntegrationTest.java index 18e1055a94d13..fbab216fb0055 100644 --- a/components/camel-jbpm/src/test/java/org/apache/camel/component/jbpm/JBPMComponentIntegrationTest.java +++ b/components/camel-jbpm/src/test/java/org/apache/camel/component/jbpm/JBPMComponentIntegrationTest.java @@ -29,11 +29,10 @@ import org.kie.server.api.model.instance.TaskSummary; /** - * To run this example you need jBPM to run locally, easiest is to use single zip - * distribution - download from jbpm.org - * - * Next, start it and import Evaluation sample project, build and deploy. - * Once done this test can be ran out of the box. + * To run this example you need jBPM to run locally, easiest is to use single + * zip distribution - download from jbpm.org Next, start it and import + * Evaluation sample project, build and deploy. Once done this test can be ran + * out of the box. */ @Ignore("This is an integration test that needs jBPM running on the local machine") public class JBPMComponentIntegrationTest extends CamelTestSupport { @@ -42,46 +41,46 @@ public class JBPMComponentIntegrationTest extends CamelTestSupport { @Test public void interactsOverRest() throws Exception { getMockEndpoint("mock:result").expectedMessageCount(1); - + // let's start process instance for evaluation process Map params = new HashMap<>(); params.put("employee", "wbadmin"); params.put("reason", "Camel asks for it"); - + Map headers = new HashMap<>(); headers.put(JBPMConstants.PROCESS_ID, "evaluation"); headers.put(JBPMConstants.PARAMETERS, params); - + template.sendBodyAndHeaders("direct:start", null, headers); assertMockEndpointsSatisfied(); - Long processInstanceId = (Long) getMockEndpoint("mock:result").getExchanges().get(0).getIn().getBody(); + Long processInstanceId = (Long)getMockEndpoint("mock:result").getExchanges().get(0).getIn().getBody(); assertNotNull(processInstanceId); - + // now let's collect user tasks - headers = new HashMap<>(); + headers = new HashMap<>(); headers.put(JBPMConstants.OPERATION, JBPMConstants.OPERATION + Operation.getTasksOwned); - + template.sendBodyAndHeaders("direct:start", null, headers); getMockEndpoint("mock:result").expectedMessageCount(2); assertMockEndpointsSatisfied(); - - List tasks = (List) getMockEndpoint("mock:result").getExchanges().get(1).getIn().getBody(); + + List tasks = (List)getMockEndpoint("mock:result").getExchanges().get(1).getIn().getBody(); assertEquals(1, tasks.size()); - + // let's complete first user task headers = new HashMap<>(); headers.put(JBPMConstants.TASK_ID, tasks.get(0).getId()); headers.put(JBPMConstants.OPERATION, JBPMConstants.OPERATION + Operation.completeTask); - + template.sendBodyAndHeaders("direct:start", null, headers); getMockEndpoint("mock:result").expectedMessageCount(3); assertMockEndpointsSatisfied(); - + // lastly let's abort process instance we just created headers = new HashMap<>(); headers.put(JBPMConstants.PROCESS_INSTANCE_ID, processInstanceId); headers.put(JBPMConstants.OPERATION, JBPMConstants.OPERATION + Operation.abortProcessInstance); - + template.sendBodyAndHeaders("direct:start", null, headers); getMockEndpoint("mock:result").expectedMessageCount(4); assertMockEndpointsSatisfied(); @@ -92,10 +91,8 @@ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() { - from("direct:start") - .to("jbpm:http://localhost:8080/kie-server/services/rest/server?userName=wbadmin&password=wbadmin" - + "&deploymentId=evaluation") - .to("mock:result"); + from("direct:start").to("jbpm:http://localhost:8080/kie-server/services/rest/server?userName=wbadmin&password=wbadmin" + "&deploymentId=evaluation") + .to("mock:result"); } }; } From 12113b86b650e1818d53f6af74c5546e5aa791c4 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Fri, 16 Nov 2018 09:33:39 +0100 Subject: [PATCH 030/125] Camel-Schematron: Fixed CS --- .../component/schematron/SchematronProducer.java | 14 +++++++------- .../schematron/SchematronProducerTest.java | 13 ++++++------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronProducer.java b/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronProducer.java index bef9c50805a7a..94770b55d59e5 100644 --- a/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronProducer.java +++ b/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronProducer.java @@ -16,6 +16,11 @@ */ package org.apache.camel.component.schematron; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.transform.Source; + import org.apache.camel.Exchange; import org.apache.camel.component.schematron.constant.Constants; import org.apache.camel.component.schematron.exception.SchematronValidationException; @@ -25,10 +30,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.xml.transform.Source; -import java.util.HashMap; -import java.util.Map; - /** * The Schematron producer. */ @@ -36,7 +37,6 @@ public class SchematronProducer extends DefaultProducer { private Logger logger = LoggerFactory.getLogger(SchematronProducer.class); private SchematronEndpoint endpoint; - /** * @param endpoint the schematron endpoint. */ @@ -58,10 +58,10 @@ public void process(Exchange exchange) throws Exception { if (payload instanceof Source) { logger.debug("Applying schematron validation on payload: {}", payload); - report = schematronProcessor.validate((Source) payload); + report = schematronProcessor.validate((Source)payload); } else if (payload instanceof String) { logger.debug("Applying schematron validation on payload: {}", payload); - report = schematronProcessor.validate((String) payload); + report = schematronProcessor.validate((String)payload); } else { String stringPayload = exchange.getIn().getBody(String.class); logger.debug("Applying schematron validation on payload: {}", stringPayload); diff --git a/components/camel-schematron/src/test/java/org/apache/camel/component/schematron/SchematronProducerTest.java b/components/camel-schematron/src/test/java/org/apache/camel/component/schematron/SchematronProducerTest.java index ebf2594c6816a..e588bd3d6070c 100644 --- a/components/camel-schematron/src/test/java/org/apache/camel/component/schematron/SchematronProducerTest.java +++ b/components/camel-schematron/src/test/java/org/apache/camel/component/schematron/SchematronProducerTest.java @@ -15,14 +15,19 @@ * limitations under the License. */ package org.apache.camel.component.schematron; + import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.Templates; import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXSource; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; import net.sf.saxon.TransformerFactoryImpl; + import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.component.schematron.constant.Constants; @@ -30,16 +35,11 @@ import org.apache.camel.component.schematron.processor.TemplatesFactory; import org.apache.camel.impl.DefaultExchange; import org.apache.camel.test.junit4.CamelTestSupport; -import org.apache.commons.io.IOUtils; import org.junit.BeforeClass; import org.junit.Test; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; /** * Schematron Producer Unit Test. - * */ public class SchematronProducerTest extends CamelTestSupport { @@ -50,8 +50,7 @@ public static void setUP() { SchematronEndpoint endpoint = new SchematronEndpoint(); TransformerFactory fac = new TransformerFactoryImpl(); fac.setURIResolver(new ClassPathURIResolver(Constants.SCHEMATRON_TEMPLATES_ROOT_DIR, endpoint.getUriResolver())); - Templates templates = TemplatesFactory.newInstance().getTemplates(ClassLoader. - getSystemResourceAsStream("sch/schematron-1.sch"), fac); + Templates templates = TemplatesFactory.newInstance().getTemplates(ClassLoader.getSystemResourceAsStream("sch/schematron-1.sch"), fac); endpoint.setRules(templates); producer = new SchematronProducer(endpoint); } From 0eb34c9752ddbd3c54d34217c86b926a675aec10 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 13 Nov 2018 10:28:39 +0100 Subject: [PATCH 031/125] Refactor dopbox tests --- components/camel-dropbox/pom.xml | 32 ++++-- .../dropbox/DropboxConsumerTest.java | 16 ++- .../integration/DropboxTestSupport.java | 66 +++++++++-- .../DropboxConsumerGetSingleTest.java | 25 ++--- .../DropboxConsumerSearchQueryTest.java | 23 ++-- .../consumer/DropboxConsumerSearchTest.java | 56 --------- .../producer/DropboxProducerDelTest.java | 54 +++------ .../DropboxProducerGetFolderTest.java | 106 +++++------------- .../DropboxProducerGetSingleTest.java | 61 ++++------ .../producer/DropboxProducerMoveTest.java | 59 ++++------ .../DropboxProducerPutSingleFileTest.java | 99 +++++++++------- ...oducerPutSingleFileWithRemotePathTest.java | 96 ---------------- .../DropboxProducerPutWithRemotePathTest.java | 95 ---------------- .../DropboxProducerSearchQueryTest.java | 66 ++++------- .../producer/DropboxProducerSearchTest.java | 92 --------------- .../test/resources/test-options.properties | 3 +- 16 files changed, 268 insertions(+), 681 deletions(-) delete mode 100644 components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchTest.java delete mode 100644 components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileWithRemotePathTest.java delete mode 100644 components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutWithRemotePathTest.java delete mode 100644 components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchTest.java diff --git a/components/camel-dropbox/pom.xml b/components/camel-dropbox/pom.xml index f93165b070f2f..dcbdeefe69ae2 100644 --- a/components/camel-dropbox/pom.xml +++ b/components/camel-dropbox/pom.xml @@ -97,27 +97,39 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + **/integration/** + + + + + + + - no-integration-test - - true - + dropbox-test org.apache.maven.plugins maven-surefire-plugin - - - - **/integration/** - - + + + **/*Test.java + + diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/DropboxConsumerTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/DropboxConsumerTest.java index 199d5daaba573..6fee8a640c4f2 100644 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/DropboxConsumerTest.java +++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/DropboxConsumerTest.java @@ -21,22 +21,20 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dropbox.integration.DropboxTestSupport; import org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollGetConsumer; +import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Assert; import org.junit.Test; -public class DropboxConsumerTest extends DropboxTestSupport { - - public DropboxConsumerTest() throws Exception { - } +public class DropboxConsumerTest extends CamelTestSupport { @Override - protected RouteBuilder createRouteBuilder() throws Exception { + protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { @Override public void configure() throws Exception { - from("dropbox://get?accessToken={{accessToken}}&remotePath=/path").to("mock:test1"); + from("dropbox://get?accessToken=accessToken&remotePath=/path").to("mock:test1"); - from("dropbox://get?accessToken={{accessToken}}&remotePath=/path with spaces/file").to("mock:test2"); + from("dropbox://get?accessToken=accessToken&remotePath=/path with spaces/file").to("mock:test2"); } }; } @@ -44,7 +42,7 @@ public void configure() throws Exception { @Test public void shouldCreateGetConsumer() throws Exception { // Given - Endpoint dropboxEndpoint1 = context.getEndpoint("dropbox://get?accessToken={{accessToken}}&remotePath=/path"); + Endpoint dropboxEndpoint1 = context.getEndpoint("dropbox://get?accessToken=accessToken&remotePath=/path"); // When Consumer consumer1 = dropboxEndpoint1.createConsumer(null); @@ -53,7 +51,7 @@ public void shouldCreateGetConsumer() throws Exception { Assert.assertTrue(consumer1 instanceof DropboxScheduledPollGetConsumer); // Given - Endpoint dropboxEndpoint2 = context.getEndpoint("dropbox://get?accessToken={{accessToken}}&remotePath=/path with spaces/file"); + Endpoint dropboxEndpoint2 = context.getEndpoint("dropbox://get?accessToken=accessToken&remotePath=/path with spaces/file"); // When Consumer consumer2 = dropboxEndpoint2.createConsumer(null); diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/DropboxTestSupport.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/DropboxTestSupport.java index 9636142b34599..ef174b7d611cc 100644 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/DropboxTestSupport.java +++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/DropboxTestSupport.java @@ -16,36 +16,78 @@ */ package org.apache.camel.component.dropbox.integration; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.net.URL; import java.util.Properties; - +import com.dropbox.core.DbxDownloader; +import com.dropbox.core.DbxException; +import com.dropbox.core.DbxRequestConfig; +import com.dropbox.core.v2.DbxClientV2; +import com.dropbox.core.v2.files.FileMetadata; import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Before; public class DropboxTestSupport extends CamelTestSupport { + protected final Properties properties; + protected String workdir; + protected String token; + private DbxClientV2 client; protected DropboxTestSupport() { - URL url = getClass().getResource("/test-options.properties"); - - InputStream inStream; - try { - inStream = url.openStream(); + properties = new Properties(); + try (InputStream inStream = getClass().getResourceAsStream("/test-options.properties")) { + properties.load(inStream); } catch (IOException e) { e.printStackTrace(); throw new IllegalAccessError("test-options.properties could not be found"); } - properties = new Properties(); + workdir = properties.getProperty("workDir"); + token = properties.getProperty("accessToken"); + + DbxRequestConfig config = DbxRequestConfig.newBuilder(properties.getProperty("clientIdentifier")).build(); + client = new DbxClientV2(config, token); + + } + + @Before + public void setUpWorkingFolder() throws DbxException { + createDir(workdir); + } + + protected void createDir(String name) throws DbxException { try { - properties.load(inStream); - } catch (IOException e) { - e.printStackTrace(); - throw new IllegalAccessError("test-options.properties could not be found"); + removeDir(name); + } finally { + client.files().createFolder(name); + } + } + + protected void removeDir(String name) throws DbxException { + client.files().delete(name); + } + + protected void createFile(String fileName, String content) throws IOException { + try { + client.files().uploadBuilder(workdir + "/" + fileName).uploadAndFinish(new ByteArrayInputStream(content.getBytes())); + } catch (DbxException e) { + log.info("folder is already created"); + } + + } + + protected String getFileContent(String path) throws DbxException, IOException { + ByteArrayOutputStream target = new ByteArrayOutputStream(); + DbxDownloader downloadedFile = client.files().download(path); + if (downloadedFile != null) { + downloadedFile.download(target); } + return new String(target.toByteArray()); } @Override diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerGetSingleTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerGetSingleTest.java index b9b340cdae0db..c923c682a0ae4 100644 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerGetSingleTest.java +++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerGetSingleTest.java @@ -16,9 +16,6 @@ */ package org.apache.camel.component.dropbox.integration.consumer; -import java.util.List; - -import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dropbox.integration.DropboxTestSupport; import org.apache.camel.component.dropbox.util.DropboxResultHeader; @@ -27,29 +24,27 @@ public class DropboxConsumerGetSingleTest extends DropboxTestSupport { - public DropboxConsumerGetSingleTest() throws Exception { } + public static final String FILE_NAME = "myFile.txt"; @Test public void testCamelDropbox() throws Exception { + final String content = "Hi camels"; + createFile(FILE_NAME, content); - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); + context.startRoute("consumer"); - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.DOWNLOADED_FILE.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(1); + mock.expectedBodiesReceived(content); + mock.expectedHeaderReceived(DropboxResultHeader.DOWNLOADED_FILE.name(), String.format("%s/%s", workdir, FILE_NAME)); + mock.assertIsSatisfied(); } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { - from("dropbox://get?accessToken={{accessToken}}&remotePath=XXX") - .to("file:XXX") + from(String.format("dropbox://get?accessToken={{accessToken}}&remotePath=%s/%s", workdir, FILE_NAME)).autoStartup(false).id("consumer") .to("mock:result"); } }; diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchQueryTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchQueryTest.java index 253efd1bc1bee..d343a7537ad3d 100644 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchQueryTest.java +++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchQueryTest.java @@ -16,9 +16,6 @@ */ package org.apache.camel.component.dropbox.integration.consumer; -import java.util.List; - -import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dropbox.integration.DropboxTestSupport; import org.apache.camel.component.dropbox.util.DropboxResultHeader; @@ -27,28 +24,26 @@ public class DropboxConsumerSearchQueryTest extends DropboxTestSupport { - public DropboxConsumerSearchQueryTest() throws Exception { } + public static final String FILE_NAME = "myTestFile.txt"; @Test public void testCamelDropbox() throws Exception { + final String content = "Hi camels"; + createFile(FILE_NAME, content); - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); + context.startRoute("consumer"); - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.FOUND_FILES.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(1); + mock.message(0).header(DropboxResultHeader.FOUND_FILES.name()).contains(String.format("%s/%s", workdir, FILE_NAME)); + mock.assertIsSatisfied(); } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { - from("dropbox://search?accessToken={{accessToken}}&remotePath=/XXX&query=XXX") + from(String.format("dropbox://search?accessToken={{accessToken}}&remotePath=%s&query=%s", workdir, FILE_NAME)).id("consumer").autoStartup(false) .to("mock:result"); } }; diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchTest.java deleted file mode 100644 index b6f32730d4d58..0000000000000 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchTest.java +++ /dev/null @@ -1,56 +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.camel.component.dropbox.integration.consumer; - -import java.util.List; - -import org.apache.camel.Exchange; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.dropbox.integration.DropboxTestSupport; -import org.apache.camel.component.dropbox.util.DropboxResultHeader; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -public class DropboxConsumerSearchTest extends DropboxTestSupport { - - public DropboxConsumerSearchTest() throws Exception { } - - @Test - public void testCamelDropbox() throws Exception { - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.FOUND_FILES.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() { - from("dropbox://search?accessToken={{accessToken}}&remotePath=/XXX") - .to("mock:result"); - } - }; - } -} diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerDelTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerDelTest.java index 766a22c897cde..1934edbcf0c7d 100644 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerDelTest.java +++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerDelTest.java @@ -16,63 +16,41 @@ */ package org.apache.camel.component.dropbox.integration.producer; -import java.util.List; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; +import java.io.IOException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dropbox.integration.DropboxTestSupport; import org.apache.camel.component.dropbox.util.DropboxConstants; import org.apache.camel.component.dropbox.util.DropboxResultHeader; import org.apache.camel.component.mock.MockEndpoint; +import org.junit.Before; import org.junit.Test; public class DropboxProducerDelTest extends DropboxTestSupport { - public DropboxProducerDelTest() throws Exception { } + public static final String FILE_NAME = "file.txt"; + + @Before + public void createFile() throws IOException { + createFile(FILE_NAME, "content"); + } @Test public void testCamelDropbox() throws Exception { - template.send("direct:start", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.DELETED_PATH.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); + test("direct:start"); } @Test public void testCamelDropboxWithOptionInHeader() throws Exception { - template.send("direct:start2", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); + test("direct:start2"); + } + private void test(String endpointURI) throws InterruptedException { + template.sendBody(endpointURI, null); MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); + mock.expectedHeaderReceived(DropboxResultHeader.DELETED_PATH.name(), workdir + "/" + FILE_NAME); assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.DELETED_PATH.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); } @Override @@ -80,11 +58,11 @@ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { from("direct:start") - .to("dropbox://del?accessToken={{accessToken}}&remotePath=/XXX") + .to("dropbox://del?accessToken={{accessToken}}&remotePath=" + workdir + "/" + FILE_NAME) .to("mock:result"); from("direct:start2") - .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant("/XXX")) + .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant(workdir + "/" + FILE_NAME)) .to("dropbox://del?accessToken={{accessToken}}") .to("mock:result"); } diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetFolderTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetFolderTest.java index f39d213c58789..6d8eb8288d0a2 100644 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetFolderTest.java +++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetFolderTest.java @@ -16,120 +16,74 @@ */ package org.apache.camel.component.dropbox.integration.producer; -import java.util.List; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; +import java.io.IOException; +import java.util.Map; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dropbox.integration.DropboxTestSupport; import org.apache.camel.component.dropbox.util.DropboxConstants; import org.apache.camel.component.dropbox.util.DropboxResultHeader; import org.apache.camel.component.mock.MockEndpoint; +import org.junit.Before; import org.junit.Test; public class DropboxProducerGetFolderTest extends DropboxTestSupport { - public DropboxProducerGetFolderTest() throws Exception { } + public static final String FILE_NAME1 = "myFile.txt"; + public static final String FILE_NAME2 = "myFile2.txt"; + private static final String CONTENT1 = "content1"; + private static final String CONTENT2 = "content2"; + + @Before + public void createFile() throws IOException { + createFile(FILE_NAME1, CONTENT1); + createFile(FILE_NAME2, CONTENT2); + } @Test public void testCamelDropbox() throws Exception { - template.send("direct:start", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.DOWNLOADED_FILES.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); + test("direct:start"); } @Test public void testCamelDropboxWithOptionInHeader() throws Exception { - template.send("direct:start2", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - - - template.send("direct:start3", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - exchange.getIn().setHeader(DropboxConstants.HEADER_REMOTE_PATH, "/XXX"); - } - }); - - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(2); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.DOWNLOADED_FILES.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); - - exchange = exchanges.get(1); - header = exchange.getIn().getHeader(DropboxResultHeader.DOWNLOADED_FILES.name()); - body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); + test("direct:start2"); } @Test public void testCamelDropboxHeaderHasPriorityOnParameter() throws Exception { - template.send("direct:start4", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); + test("direct:start3"); + } + private void test(String endpoint) throws InterruptedException { + template.sendBody(endpoint, null); MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); + mock.message(0).header(DropboxResultHeader.DOWNLOADED_FILES.name()).contains(String.format("%s/%s", workdir, FILE_NAME1)); + mock.message(0).header(DropboxResultHeader.DOWNLOADED_FILES.name()).contains(String.format("%s/%s", workdir, FILE_NAME2)); + mock.assertIsSatisfied(); - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.DOWNLOADED_FILES.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); + final Map items = mock.getExchanges().get(0).getIn().getBody(Map.class); + assertEquals(CONTENT1, new String(items.get(String.format("%s/%s", workdir, FILE_NAME1)))); + assertEquals(CONTENT2, new String(items.get(String.format("%s/%s", workdir, FILE_NAME2)))); } @Override - protected RouteBuilder createRouteBuilder() throws Exception { + protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { from("direct:start") - .to("dropbox://get?accessToken={{accessToken}}&remotePath=/XXX") + .to("dropbox://get?accessToken={{accessToken}}&remotePath=" + workdir) .to("mock:result"); from("direct:start2") - .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant("/XXX")) + .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant(workdir)) .to("dropbox://get?accessToken={{accessToken}}") .to("mock:result"); - from("direct:start3") - .to("dropbox://get?accessToken={{accessToken}}") - .to("mock:result"); - from("direct:start4") - .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant("/XXX")) + from("direct:start3") + .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant(workdir)) .to("dropbox://get?accessToken={{accessToken}}&remotePath=/aWrongPath") .to("mock:result"); diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetSingleTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetSingleTest.java index 27f604b95d217..fd4cbc228db7a 100644 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetSingleTest.java +++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetSingleTest.java @@ -16,63 +16,42 @@ */ package org.apache.camel.component.dropbox.integration.producer; -import java.util.List; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; +import java.io.IOException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dropbox.integration.DropboxTestSupport; import org.apache.camel.component.dropbox.util.DropboxConstants; import org.apache.camel.component.dropbox.util.DropboxResultHeader; import org.apache.camel.component.mock.MockEndpoint; +import org.junit.Before; import org.junit.Test; public class DropboxProducerGetSingleTest extends DropboxTestSupport { - public DropboxProducerGetSingleTest() throws Exception { } + public static final String FILE_NAME = "myFile.txt"; + public static final String CONTENT = "Hi camels"; + + @Before + public void createFile() throws IOException { + createFile(FILE_NAME, CONTENT); + } @Test public void testCamelDropbox() throws Exception { - template.send("direct:start", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.DOWNLOADED_FILE.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); + test("direct:start"); } @Test public void testCamelDropboxWithOptionInHeader() throws Exception { - template.send("direct:start2", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - + test("direct:start2"); + } + private void test(String endpoint) throws InterruptedException { + template.sendBody(endpoint, null); MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.DOWNLOADED_FILE.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); + mock.message(0).header(DropboxResultHeader.DOWNLOADED_FILE.name()).contains(String.format("%s/%s", workdir, FILE_NAME)); + mock.message(0).body(String.class).isEqualTo(CONTENT); + mock.assertIsSatisfied(); } @Override @@ -80,14 +59,12 @@ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { from("direct:start") - .to("dropbox://get?accessToken={{accessToken}}&remotePath=/XXX") - .to("file:///XXX?fileName=XXX") + .to("dropbox://get?accessToken={{accessToken}}&remotePath=" + workdir + "/" + FILE_NAME) .to("mock:result"); from("direct:start2") - .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant("/XXX")) + .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant(workdir + "/" + FILE_NAME)) .to("dropbox://get?accessToken={{accessToken}}") - .to("file:///XXX?fileName=XXX") .to("mock:result"); } }; diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerMoveTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerMoveTest.java index f396897374529..086ab583f0c57 100644 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerMoveTest.java +++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerMoveTest.java @@ -16,63 +16,44 @@ */ package org.apache.camel.component.dropbox.integration.producer; -import java.util.List; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; +import java.io.IOException; +import com.dropbox.core.DbxException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dropbox.integration.DropboxTestSupport; import org.apache.camel.component.dropbox.util.DropboxConstants; import org.apache.camel.component.dropbox.util.DropboxResultHeader; import org.apache.camel.component.mock.MockEndpoint; +import org.junit.Before; import org.junit.Test; public class DropboxProducerMoveTest extends DropboxTestSupport { - public DropboxProducerMoveTest() throws Exception { } + public static final String COPY_WORKDIR = "/test-workdir"; + public static final String FILE = "file.txt"; + + @Before + public void removeDir() throws DbxException, IOException { + createDir(COPY_WORKDIR); + createFile(FILE, "content"); + } @Test public void testCamelDropbox() throws Exception { - template.send("direct:start", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.MOVED_PATH.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); + test("direct:start"); } @Test public void testCamelDropboxWithOptionInHeader() throws Exception { - template.send("direct:start2", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); + test("direct:start2"); + } + private void test(String endpoint) throws InterruptedException { + template.sendBody(endpoint, null); MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); + mock.expectedHeaderReceived(DropboxResultHeader.MOVED_PATH.name(), workdir + "/" + FILE); assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.MOVED_PATH.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); } @Override @@ -80,12 +61,12 @@ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { from("direct:start") - .to("dropbox://move?accessToken={{accessToken}}&remotePath=/XXX&newRemotePath=/XXX") + .to(String.format("dropbox://move?accessToken={{accessToken}}&remotePath=%s&newRemotePath=%s", workdir + "/" + FILE, COPY_WORKDIR + "/" + FILE)) .to("mock:result"); from("direct:start2") - .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant("/XXX")) - .setHeader(DropboxConstants.HEADER_NEW_REMOTE_PATH, constant("/XXX")) + .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant(workdir + "/" + FILE)) + .setHeader(DropboxConstants.HEADER_NEW_REMOTE_PATH, constant(COPY_WORKDIR + "/" + FILE)) .to("dropbox://move?accessToken={{accessToken}}") .to("mock:result"); } diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileTest.java index a4acea71a381a..a7ba22d5afe5d 100644 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileTest.java +++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileTest.java @@ -16,64 +16,85 @@ */ package org.apache.camel.component.dropbox.integration.producer; -import java.util.List; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dropbox.integration.DropboxTestSupport; import org.apache.camel.component.dropbox.util.DropboxConstants; +import org.apache.camel.component.dropbox.util.DropboxException; import org.apache.camel.component.dropbox.util.DropboxResultHeader; import org.apache.camel.component.dropbox.util.DropboxUploadMode; import org.apache.camel.component.mock.MockEndpoint; +import org.hamcrest.core.IsInstanceOf; +import org.junit.Assert; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; public class DropboxProducerPutSingleFileTest extends DropboxTestSupport { + public static final String FILENAME = "newFile.txt"; - public DropboxProducerPutSingleFileTest() throws Exception { } + @Rule + public ExpectedException thrown = ExpectedException.none(); @Test - public void testCamelDropbox() throws Exception { - template.send("direct:start", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); + public void testCamelDropboxWithOptionInHeader() throws Exception { + final Path file = Files.createTempFile("camel", ".txt"); + final Map headers = new HashMap<>(); + headers.put(DropboxConstants.HEADER_LOCAL_PATH, file.toAbsolutePath().toString()); + headers.put(DropboxConstants.HEADER_UPLOAD_MODE, DropboxUploadMode.add); + template.sendBodyAndHeaders("direct:start", null, headers); + assertFileUploaded(); + } - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); + @Test + public void uploadBodyTest() throws Exception { + template.sendBodyAndHeader("direct:start", "Helo Camels", DropboxConstants.HEADER_UPLOAD_MODE, DropboxUploadMode.add); - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.UPLOADED_FILE.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); + assertFileUploaded(); } @Test - public void testCamelDropboxWithOptionInHeader() throws Exception { - template.send("direct:start2", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); + public void uploadIfExistsAddTest() throws Exception { + thrown.expectCause(IsInstanceOf.instanceOf(DropboxException.class)); + createFile(FILENAME, "content"); + final Path file = Files.createTempFile("camel", ".txt"); + final Map headers = new HashMap<>(); + headers.put(DropboxConstants.HEADER_LOCAL_PATH, file.toAbsolutePath().toString()); + headers.put(DropboxConstants.HEADER_UPLOAD_MODE, DropboxUploadMode.add); + template.sendBodyAndHeaders("direct:start", null, headers); + } + + @Test + public void uploadIfExistsForceTest() throws Exception { + final String newContent = UUID.randomUUID().toString(); + createFile(FILENAME, "Hi camels"); + final Path file = Files.createTempFile("camel", ".txt"); + try (BufferedWriter bw = new BufferedWriter(new FileWriter(file.toFile()))) { + bw.write(newContent); + bw.flush(); + } + final Map headers = new HashMap<>(); + headers.put(DropboxConstants.HEADER_LOCAL_PATH, file.toAbsolutePath().toString()); + headers.put(DropboxConstants.HEADER_UPLOAD_MODE, DropboxUploadMode.force); + template.sendBodyAndHeaders("direct:start", null, headers); + assertFileUploaded(); + Assert.assertEquals(newContent, getFileContent(workdir + "/" + FILENAME)); + } + + private void assertFileUploaded() throws InterruptedException { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); + mock.expectedHeaderReceived(DropboxResultHeader.UPLOADED_FILE.name(), workdir + "/" + FILENAME); assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.UPLOADED_FILE.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); } @Override @@ -81,13 +102,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { from("direct:start") - .to("dropbox://put?accessToken={{accessToken}}&uploadMode=add&localPath=/XXX") - .to("mock:result"); - - from("direct:start2") - .setHeader(DropboxConstants.HEADER_LOCAL_PATH, constant("/XXX")) - .setHeader(DropboxConstants.HEADER_UPLOAD_MODE, constant(DropboxUploadMode.add)) - .to("dropbox://put?accessToken={{accessToken}}") + .to("dropbox://put?accessToken={{accessToken}}&remotePath=" + workdir + "/" + FILENAME) .to("mock:result"); } }; diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileWithRemotePathTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileWithRemotePathTest.java deleted file mode 100644 index 42bd460018ac7..0000000000000 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileWithRemotePathTest.java +++ /dev/null @@ -1,96 +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.camel.component.dropbox.integration.producer; - -import java.util.List; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.dropbox.integration.DropboxTestSupport; -import org.apache.camel.component.dropbox.util.DropboxConstants; -import org.apache.camel.component.dropbox.util.DropboxResultHeader; -import org.apache.camel.component.dropbox.util.DropboxUploadMode; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -public class DropboxProducerPutSingleFileWithRemotePathTest extends DropboxTestSupport { - - public DropboxProducerPutSingleFileWithRemotePathTest() throws Exception { } - - @Test - public void testCamelDropbox() throws Exception { - template.send("direct:start", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.UPLOADED_FILE.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); - } - - @Test - public void testCamelDropboxWithOptionInHeader() throws Exception { - template.send("direct:start2", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.UPLOADED_FILE.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() { - from("direct:start") - .to("dropbox://put?accessToken={{accessToken}}&uploadMode=add&localPath=/XXX&remotePath=/XXX") - .to("mock:result"); - - from("direct:start2") - .setHeader(DropboxConstants.HEADER_UPLOAD_MODE, constant(DropboxUploadMode.add)) - .setHeader(DropboxConstants.HEADER_LOCAL_PATH, constant("/tmp/toto.txt")) - .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant("/test")) - .to("dropbox://put?accessToken={{accessToken}}") - .to("mock:result"); - } - }; - } -} diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutWithRemotePathTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutWithRemotePathTest.java deleted file mode 100644 index 2de352c631789..0000000000000 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutWithRemotePathTest.java +++ /dev/null @@ -1,95 +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.camel.component.dropbox.integration.producer; - -import java.util.List; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.dropbox.integration.DropboxTestSupport; -import org.apache.camel.component.dropbox.util.DropboxConstants; -import org.apache.camel.component.dropbox.util.DropboxResultHeader; -import org.apache.camel.component.dropbox.util.DropboxUploadMode; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -public class DropboxProducerPutWithRemotePathTest extends DropboxTestSupport { - - public DropboxProducerPutWithRemotePathTest() throws Exception { } - - @Test - public void testCamelDropbox() throws Exception { - template.send("direct:start", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.UPLOADED_FILES.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); - } - - @Test - public void testCamelDropboxWithOptionInHeader() throws Exception { - template.send("direct:start2", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.UPLOADED_FILES.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() { - from("direct:start") - .to("dropbox://put?accessToken={{accessToken}}&uploadMode=add&localPath=/XXX&remotePath=/XXX") - .to("mock:result"); - - from("direct:start2") - .setHeader(DropboxConstants.HEADER_LOCAL_PATH, constant("/XXX")) - .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant("/XXX")) - .setHeader(DropboxConstants.HEADER_UPLOAD_MODE, constant(DropboxUploadMode.add)) - .to("dropbox://put?accessToken={{accessToken}}") - .to("mock:result"); - } - }; - } -} diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchQueryTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchQueryTest.java index 4c8939fa1f380..2a541cd9b6085 100644 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchQueryTest.java +++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchQueryTest.java @@ -16,79 +16,57 @@ */ package org.apache.camel.component.dropbox.integration.producer; -import java.util.List; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; +import java.io.IOException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dropbox.integration.DropboxTestSupport; import org.apache.camel.component.dropbox.util.DropboxConstants; import org.apache.camel.component.dropbox.util.DropboxResultHeader; import org.apache.camel.component.mock.MockEndpoint; +import org.junit.Before; import org.junit.Test; public class DropboxProducerSearchQueryTest extends DropboxTestSupport { - public DropboxProducerSearchQueryTest() throws Exception { } - - @Test - public void testCamelDropbox() throws Exception { - template.send("direct:start", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.FOUND_FILES.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); + public static final String FILE_NAME = "myTestFile.txt"; + @Before + public void createFile() throws IOException { + final String content = "Hi camels"; + createFile(FILE_NAME, content); } + @Test + public void testCamelDropbox() throws Exception { + test("direct:start"); + } @Test public void testCamelDropboxWithOptionInHeader() throws Exception { - template.send("direct:start2", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); + test("direct:start2"); + } + + private void test(String endpoint) throws InterruptedException { + template.sendBody(endpoint, null); MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.FOUND_FILES.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); - + mock.message(0).header(DropboxResultHeader.FOUND_FILES.name()).contains(String.format("%s/%s", workdir, FILE_NAME)); + mock.assertIsSatisfied(); } @Override - protected RouteBuilder createRouteBuilder() throws Exception { + protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { from("direct:start") - .to("dropbox://search?accessToken={{accessToken}}&remotePath=/XXX&query=XXX") + .to(String.format("dropbox://search?accessToken={{accessToken}}&remotePath=%s&query=%s", workdir, FILE_NAME)) .to("mock:result"); from("direct:start2") - .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant("/XXX")) - .setHeader(DropboxConstants.HEADER_QUERY, constant("/XXX")) + .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant(workdir)) + .setHeader(DropboxConstants.HEADER_QUERY, constant(FILE_NAME)) .to("dropbox://search?accessToken={{accessToken}}") .to("mock:result"); } diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchTest.java deleted file mode 100644 index 38ce2aa683576..0000000000000 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchTest.java +++ /dev/null @@ -1,92 +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.camel.component.dropbox.integration.producer; - -import java.util.List; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.dropbox.integration.DropboxTestSupport; -import org.apache.camel.component.dropbox.util.DropboxConstants; -import org.apache.camel.component.dropbox.util.DropboxResultHeader; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -public class DropboxProducerSearchTest extends DropboxTestSupport { - - public DropboxProducerSearchTest() throws Exception { } - - @Test - public void testCamelDropbox() throws Exception { - template.send("direct:start", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.FOUND_FILES.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); - } - - @Test - public void testCamelDropboxWithOptionInHeader() throws Exception { - template.send("direct:start2", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("test", "test"); - } - }); - - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(); - - List exchanges = mock.getReceivedExchanges(); - Exchange exchange = exchanges.get(0); - Object header = exchange.getIn().getHeader(DropboxResultHeader.FOUND_FILES.name()); - Object body = exchange.getIn().getBody(); - assertNotNull(header); - assertNotNull(body); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() { - from("direct:start") - .to("dropbox://search?accessToken={{accessToken}}&remotePath=/XXX") - .to("mock:result"); - - from("direct:start") - .setHeader(DropboxConstants.HEADER_REMOTE_PATH, constant("/XXX")) - .to("dropbox://search?accessToken={{accessToken}}") - .to("mock:result"); - } - }; - } -} diff --git a/components/camel-dropbox/src/test/resources/test-options.properties b/components/camel-dropbox/src/test/resources/test-options.properties index 84dfb21745a84..5c07059032083 100644 --- a/components/camel-dropbox/src/test/resources/test-options.properties +++ b/components/camel-dropbox/src/test/resources/test-options.properties @@ -15,5 +15,6 @@ ## limitations under the License. ## --------------------------------------------------------------------------- -accessToken= +accessToken= clientIdentifier=camel-dropbox +workDir=/camel-test From 81b5625e67f1b1255359651eac98ae29845b5cbd Mon Sep 17 00:00:00 2001 From: Jan Date: Fri, 16 Nov 2018 09:14:20 +0100 Subject: [PATCH 032/125] [CAMEL-12942] Fix dropbox put operation --- .../dropbox/core/DropboxAPIFacade.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/core/DropboxAPIFacade.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/core/DropboxAPIFacade.java index 1b43179a3775d..d6e3c7b14ebc9 100644 --- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/core/DropboxAPIFacade.java +++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/core/DropboxAPIFacade.java @@ -92,31 +92,31 @@ public DropboxFileUploadResult put(String localPath, String remotePath, DropboxU // in case the remote path is not specified, the remotePath = localPath String dropboxPath = remotePath == null ? localPath : remotePath; - UploadUploader entry; + boolean isPresent = true; try { - entry = client.files().upload(dropboxPath); + client.files().getMetadata(dropboxPath); } catch (DbxException e) { - throw new DropboxException(dropboxPath + " does not exist or cannot obtain metadata", e); + isPresent = false; } if (localPath != null) { - return putFile(localPath, mode, dropboxPath, entry); + return putFile(localPath, mode, dropboxPath, isPresent); } else { - return putBody(exchange, mode, dropboxPath, entry); + return putBody(exchange, mode, dropboxPath, isPresent); } } - private DropboxFileUploadResult putFile(String localPath, DropboxUploadMode mode, String dropboxPath, UploadUploader entry) throws DropboxException { + private DropboxFileUploadResult putFile(String localPath, DropboxUploadMode mode, String dropboxPath, boolean isPresent) throws DropboxException { File fileLocalPath = new File(localPath); // verify uploading of a single file if (fileLocalPath.isFile()) { // check if dropbox file exists - if (entry != null && !DropboxUploadMode.force.equals(mode)) { - throw new DropboxException(dropboxPath + " exists on dropbox and is not a file!"); + if (isPresent && !DropboxUploadMode.force.equals(mode)) { + throw new DropboxException(dropboxPath + " exists on dropbox. Use force upload mode to override"); } // in case the entry not exists on dropbox check if the filename // should be appended - if (entry == null) { + if (!isPresent) { if (dropboxPath.endsWith(DropboxConstants.DROPBOX_FILE_SEPARATOR)) { dropboxPath = dropboxPath + fileLocalPath.getName(); } @@ -139,7 +139,7 @@ private DropboxFileUploadResult putFile(String localPath, DropboxUploadMode mode // verify uploading of a list of files inside a dir LOG.debug("Uploading a dir..."); // check if dropbox folder exists - if (entry != null && !DropboxUploadMode.force.equals(mode)) { + if (isPresent && !DropboxUploadMode.force.equals(mode)) { throw new DropboxException(dropboxPath + " exists on dropbox and is not a folder!"); } if (!dropboxPath.endsWith(DropboxConstants.DROPBOX_FILE_SEPARATOR)) { @@ -181,7 +181,7 @@ private DropboxFileUploadResult putFile(String localPath, DropboxUploadMode mode } } - private DropboxFileUploadResult putBody(Exchange exchange, DropboxUploadMode mode, String dropboxPath, UploadUploader entry) throws DropboxException { + private DropboxFileUploadResult putBody(Exchange exchange, DropboxUploadMode mode, String dropboxPath, boolean isPresent) throws DropboxException { String name = exchange.getIn().getHeader(HEADER_PUT_FILE_NAME, String.class); if (name == null) { // fallback to use CamelFileName @@ -194,7 +194,7 @@ private DropboxFileUploadResult putBody(Exchange exchange, DropboxUploadMode mod // in case the entry not exists on dropbox check if the filename should // be appended - if (entry == null) { + if (!isPresent) { if (dropboxPath.endsWith(DropboxConstants.DROPBOX_FILE_SEPARATOR)) { dropboxPath = dropboxPath + name; } From a95493768b5d5896368ef35d9b5aa4432994aec6 Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Thu, 15 Nov 2018 20:30:10 +0300 Subject: [PATCH 033/125] CAMEL-12865: camel-restdsl-swagger-plugin - Allow for specifying apiContextPath --- .../src/it/customized/pom.xml | 1 + .../src/it/customized/verify.groovy | 4 ++++ .../src/main/docs/camel-restdsl-swagger-plugin.adoc | 6 ++++-- .../maven/generator/swagger/AbstractGenerateMojo.java | 3 +++ .../camel/maven/generator/swagger/GenerateMojo.java | 4 ++++ .../camel/generator/swagger/RestDslGenerator.java | 10 ++++++++++ .../generator/swagger/RestDslSourceCodeGenerator.java | 3 +++ .../camel/generator/swagger/RestDslXmlGenerator.java | 9 +++++++-- 8 files changed, 36 insertions(+), 4 deletions(-) diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/it/customized/pom.xml b/tooling/maven/camel-restdsl-swagger-plugin/src/it/customized/pom.xml index b91faba0b69e7..3aaad869f61ab 100644 --- a/tooling/maven/camel-restdsl-swagger-plugin/src/it/customized/pom.xml +++ b/tooling/maven/camel-restdsl-swagger-plugin/src/it/customized/pom.xml @@ -53,6 +53,7 @@ MyRestRoute \t com.example.MyDestinationGenerator + /api-docs diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/it/customized/verify.groovy b/tooling/maven/camel-restdsl-swagger-plugin/src/it/customized/verify.groovy index f65964b72fefe..3c154edeb5f0d 100644 --- a/tooling/maven/camel-restdsl-swagger-plugin/src/it/customized/verify.groovy +++ b/tooling/maven/camel-restdsl-swagger-plugin/src/it/customized/verify.groovy @@ -18,3 +18,7 @@ def File restdsl = new File(basedir, "target/classes/generated/com/example/MyRestRoute.java") assert restdsl.exists() + +def String data = restdsl.text + +assert data.contains('restConfiguration().component("servlet").apiContextPath("/api-docs");') diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/main/docs/camel-restdsl-swagger-plugin.adoc b/tooling/maven/camel-restdsl-swagger-plugin/src/main/docs/camel-restdsl-swagger-plugin.adoc index 58066dec41638..356c0ba78eb52 100644 --- a/tooling/maven/camel-restdsl-swagger-plugin/src/main/docs/camel-restdsl-swagger-plugin.adoc +++ b/tooling/maven/camel-restdsl-swagger-plugin/src/main/docs/camel-restdsl-swagger-plugin.adoc @@ -66,7 +66,8 @@ in the `` tag. | `indent` | `"    "` | What identing character(s) to use, by default four spaces, you can use `\t` to signify tab character | `outputDirectory` | `generated-sources/restdsl-swagger` | Where to place the generated source file, by default `generated-sources/restdsl-swagger` within the project directory | `destinationGenerator` | | Fully qualified class name of the class that implements `org.apache.camel.generator.swagger.DestinationGenerator` interface for customizing destination endpoint -| `restConfiguration` | `true` | Whether to include generation of the rest configuration with detected rest component to be used. | +| `restConfiguration` | `true` | Whether to include generation of the rest configuration with detected rest component to be used. +| `apiContextPath` | | Define swagger endpoint path if `restConfiguration` is set to `true`. | |======================================== === Spring Boot Project with Servlet component @@ -138,7 +139,8 @@ in the `` tag. | `fileName` | `camel-rest.xml` | The name of the XML file as output. | `blueprint` | `false` | If enabled generates OSGi Blueprint XML instead of Spring XML. | `destinationGenerator` | | Fully qualified class name of the class that implements `org.apache.camel.generator.swagger.DestinationGenerator` interface for customizing destination endpoint -| `restConfiguration` | `true` | Whether to include generation of the rest configuration with detected rest component to be used. | +| `restConfiguration` | `true` | Whether to include generation of the rest configuration with detected rest component to be used. +| `apiContextPath` | | Define swagger endpoint path if `restConfiguration` is set to `true`. | |======================================== == camel-restdsl-swagger:generate-xml-with-dto diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java index 8dbbde73c03c5..7d1903dd3e15d 100644 --- a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java +++ b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java @@ -97,6 +97,9 @@ abstract class AbstractGenerateMojo extends AbstractMojo { @Parameter(defaultValue = "${session}", readonly = true) private MavenSession mavenSession; + + @Parameter + String apiContextPath; @Component private BuildPluginManager pluginManager; diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java index 41aaa9473fd30..74b370286799f 100644 --- a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java +++ b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java @@ -118,6 +118,10 @@ public void execute() throws MojoExecutionException { generator.withRestComponent("servlet"); } + + if (ObjectHelper.isNotEmpty(apiContextPath)) { + generator.withApiContextPath(apiContextPath); + } // if its a spring boot project and we use servlet then we should generate additional source code if (detectSpringBootFromClasspath() && "servlet".equals(comp)) { diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslGenerator.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslGenerator.java index a96f2aa5e3a3b..a896962052544 100644 --- a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslGenerator.java +++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslGenerator.java @@ -36,6 +36,7 @@ public abstract class RestDslGenerator { OperationFilter filter = new OperationFilter(); String restComponent; String restContextPath; + String apiContextPath; boolean springComponent; boolean springBootProject; @@ -92,6 +93,15 @@ public G withRestContextPath(String contextPath) { return that; } + + public G withApiContextPath(String contextPath) { + this.apiContextPath = contextPath; + + @SuppressWarnings("unchecked") + final G that = (G) this; + + return that; + } public G asSpringComponent() { this.springComponent = true; diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslSourceCodeGenerator.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslSourceCodeGenerator.java index a2fe715b35dad..7ec89222b7ad5 100644 --- a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslSourceCodeGenerator.java +++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslSourceCodeGenerator.java @@ -108,6 +108,9 @@ MethodSpec generateConfigureMethod(final Swagger swagger) { if (restContextPath != null) { configure.addCode(".contextPath(\"" + restContextPath + "\")"); } + if (ObjectHelper.isNotEmpty(apiContextPath)) { + configure.addCode(".apiContextPath(\"" + apiContextPath + "\")"); + } configure.addCode(";\n\n"); } diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslXmlGenerator.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslXmlGenerator.java index 20b849032fd22..36034d58bc79f 100644 --- a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslXmlGenerator.java +++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslXmlGenerator.java @@ -20,6 +20,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.model.ModelHelper; import org.apache.camel.model.rest.RestsDefinition; +import org.apache.camel.util.ObjectHelper; public class RestDslXmlGenerator extends RestDslGenerator { @@ -51,10 +52,14 @@ public String generate(final CamelContext context) throws Exception { xml = xml.replaceAll(" customId=\"false\"", ""); if (restComponent != null) { - String extra = ""; + String extra = ""; + extra = extra.concat(" contextPath=\"" + restContextPath + "\""); } + if (ObjectHelper.isNotEmpty(apiContextPath)) { + extra = extra.concat(" apiContextPath=\"" + apiContextPath + "\""); + } + extra = extra.concat("/>"); xml = xml.replaceFirst("", extra + "\n "); xml = xml.replaceFirst(" Date: Thu, 15 Nov 2018 18:51:21 +0300 Subject: [PATCH 034/125] CAMEL-12869: ReplyTo destination must match endpoint type (topic or queue) that the message is sent on --- .../camel-sjms/src/main/docs/sjms-component.adoc | 2 +- .../apache/camel/component/sjms/SjmsEndpoint.java | 2 ++ .../component/sjms/jms/DestinationNameParser.java | 13 +++++++++++++ .../component/sjms/producer/InOutProducer.java | 11 ++++++++--- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/components/camel-sjms/src/main/docs/sjms-component.adoc b/components/camel-sjms/src/main/docs/sjms-component.adoc index 6e9ad12f220a1..bff4665a164af 100644 --- a/components/camel-sjms/src/main/docs/sjms-component.adoc +++ b/components/camel-sjms/src/main/docs/sjms-component.adoc @@ -150,7 +150,7 @@ with the following path and query parameters: | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern | *messageSelector* (consumer) | Sets the JMS Message selector syntax. | | String -| *namedReplyTo* (producer) | Sets the reply to destination name used for InOut producer endpoints. | | String +| *namedReplyTo* (producer) | Sets the reply to destination name used for InOut producer endpoints. The type of the reply to destination can be determined by the starting prefix (topic: or queue:) in its name. | | String | *persistent* (producer) | Flag used to enable/disable message persistence. | true | boolean | *producerCount* (producer) | Sets the number of producers used for this endpoint. | 1 | int | *ttl* (producer) | Flag used to adjust the Time To Live value of produced messages. | -1 | long diff --git a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsEndpoint.java b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsEndpoint.java index c73ebb0847a55..faa01d0e62be4 100644 --- a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsEndpoint.java +++ b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsEndpoint.java @@ -563,6 +563,8 @@ public String getNamedReplyTo() { /** * Sets the reply to destination name used for InOut producer endpoints. + * The type of the reply to destination can be determined by the starting + * prefix (topic: or queue:) in its name. */ public void setNamedReplyTo(String namedReplyTo) { this.namedReplyTo = namedReplyTo; diff --git a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/DestinationNameParser.java b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/DestinationNameParser.java index 41eab2d089e08..095d1c991b2f6 100644 --- a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/DestinationNameParser.java +++ b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/DestinationNameParser.java @@ -27,6 +27,19 @@ public boolean isTopic(String destinationName) { } return destinationName.startsWith("topic:"); } + + public boolean isNamedReplyToTopic(String namedReplyTo, boolean isDestinationTopic) { + if (namedReplyTo == null) { + throw new IllegalArgumentException("namedReplyTo is null"); + } + if (namedReplyTo.startsWith("topic:")) { + return true; + } else if (namedReplyTo.startsWith("queue:")) { + return false; + } else { + return isDestinationTopic; + } + } public String getShortName(String destinationName) { if (destinationName == null) { diff --git a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/producer/InOutProducer.java b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/producer/InOutProducer.java index 1be3630e37088..53be09eca7211 100644 --- a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/producer/InOutProducer.java +++ b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/producer/InOutProducer.java @@ -38,6 +38,7 @@ import org.apache.camel.component.sjms.SjmsMessage; import org.apache.camel.component.sjms.SjmsProducer; import org.apache.camel.component.sjms.jms.ConnectionResource; +import org.apache.camel.component.sjms.jms.DestinationNameParser; import org.apache.camel.component.sjms.jms.JmsConstants; import org.apache.camel.component.sjms.jms.JmsMessageHelper; import org.apache.camel.spi.UuidGenerator; @@ -87,12 +88,16 @@ public MessageConsumerResources makeObject() throws Exception { } Destination replyToDestination; + boolean isReplyToTopic = false; if (ObjectHelper.isEmpty(getNamedReplyTo())) { - replyToDestination = getEndpoint().getDestinationCreationStrategy().createTemporaryDestination(session, isTopic()); + isReplyToTopic = isTopic(); + replyToDestination = getEndpoint().getDestinationCreationStrategy().createTemporaryDestination(session, isReplyToTopic); } else { - replyToDestination = getEndpoint().getDestinationCreationStrategy().createDestination(session, getNamedReplyTo(), isTopic()); + DestinationNameParser parser = new DestinationNameParser(); + isReplyToTopic = parser.isNamedReplyToTopic(getNamedReplyTo(), isTopic()); + replyToDestination = getEndpoint().getDestinationCreationStrategy().createDestination(session, getNamedReplyTo(), isReplyToTopic); } - MessageConsumer messageConsumer = getEndpoint().getJmsObjectFactory().createMessageConsumer(session, replyToDestination, null, isTopic(), null, true, false, false); + MessageConsumer messageConsumer = getEndpoint().getJmsObjectFactory().createMessageConsumer(session, replyToDestination, null, isReplyToTopic, null, true, false, false); messageConsumer.setMessageListener(new MessageListener() { @Override public void onMessage(final Message message) { From 9ee4dae67419b242b44f0fda190f935ba3352715 Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Thu, 1 Nov 2018 20:25:04 +0300 Subject: [PATCH 035/125] CAMEL-12908: Add reproducer code --- .../resources/org/apache/camel/component/rest/RestRefTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/camel-spring/src/test/resources/org/apache/camel/component/rest/RestRefTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/component/rest/RestRefTest.xml index c53d943f7d204..246c2a9079965 100644 --- a/components/camel-spring/src/test/resources/org/apache/camel/component/rest/RestRefTest.xml +++ b/components/camel-spring/src/test/resources/org/apache/camel/component/rest/RestRefTest.xml @@ -54,7 +54,7 @@ Hello World - + Bye World From fb9df2dbed717517ca50994d15b74f34aa9e7e37 Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Tue, 13 Nov 2018 16:43:59 +0300 Subject: [PATCH 036/125] CAMEL-12908: Cannot start route using rest dsl due to a mysterious duplicate route id --- .../camel/model/RouteDefinitionHelper.java | 33 ++++++++++++++++++- .../camel/model/rest/RestDefinition.java | 6 +++- .../camel/model/rest/VerbDefinition.java | 2 +- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java b/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java index 041bdc212dcf9..b0059553bae64 100644 --- a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java +++ b/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java @@ -19,14 +19,18 @@ import java.io.UnsupportedEncodingException; import java.net.URISyntaxException; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Set; import org.apache.camel.CamelContext; import org.apache.camel.builder.ErrorHandlerBuilder; +import org.apache.camel.model.rest.RestDefinition; +import org.apache.camel.model.rest.VerbDefinition; import org.apache.camel.util.CamelContextHelper; import org.apache.camel.util.EndpointHelper; import org.apache.camel.util.ObjectHelper; @@ -145,10 +149,11 @@ public void run() { for (final RouteDefinition route : routes) { if (route.getId() == null) { // keep assigning id's until we find a free name + boolean done = false; String id = null; while (!done) { - id = context.getNodeIdFactory().createId(route); + id = route.idOrCreate(context.getNodeIdFactory()); done = !customIds.contains(id); } route.setId(id); @@ -162,6 +167,32 @@ public void run() { route.setCustomId(false); customIds.add(route.getId()); } + RestDefinition rest = route.getRestDefinition(); + if (rest != null && route.isRest()) { + for (VerbDefinition verb : rest.getVerbs()) { + String id = verb.idOrCreate(context.getNodeIdFactory()); + if (!verb.getUsedForGeneratingNodeId()) { + id = route.getId(); + } + verb.setRouteId(id); + } + List fromDefinitions = route.getInputs(); + + if (ObjectHelper.isNotEmpty(fromDefinitions)) { + FromDefinition fromDefinition = fromDefinitions.get(0); + String endpointUri = fromDefinition.getEndpointUri(); + if (ObjectHelper.isNotEmpty(endpointUri)) { + Map options = new HashMap(); + options.put("routeId", route.getId()); + endpointUri = URISupport.appendParametersToURI(endpointUri, options); + + // replace uri with new routeId + fromDefinition.setUri(endpointUri); + fromDefinitions.set(0, fromDefinition); + route.setInputs(fromDefinitions); + } + } + } } } diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java index 946fb76c16e15..a960827a36762 100644 --- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java @@ -903,6 +903,7 @@ private void addRouteDefinition(CamelContext camelContext, List options.put("outType", outType); } // if no route id has been set, then use the verb id as route id + /* if (!route.hasCustomIdAssigned()) { // use id of verb as route id String id = verb.getId(); @@ -910,7 +911,9 @@ private void addRouteDefinition(CamelContext camelContext, List route.setId(id); } } + */ + /* String routeId = verb.idOrCreate(camelContext.getNodeIdFactory()); if (!verb.getUsedForGeneratingNodeId()) { @@ -919,6 +922,7 @@ private void addRouteDefinition(CamelContext camelContext, List verb.setRouteId(routeId); options.put("routeId", routeId); + */ if (component != null && !component.isEmpty()) { options.put("componentName", component); } @@ -1012,7 +1016,7 @@ private void addRouteDefinition(CamelContext camelContext, List // the route should be from this rest endpoint route.fromRest(from); - route.routeId(routeId); + //route.routeId(routeId); route.setRestDefinition(this); answer.add(route); } diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java index bf56005782ecd..acbe38a6b4b85 100644 --- a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java @@ -141,7 +141,7 @@ public List getResponseMsgs() { /** * Sets swagger operation response messages. */ - public void setResponseMsgs(List params) { + public void setResponseMsgs(List responseMsgs) { this.responseMsgs = responseMsgs; } From 1a9b479047eddc475be7de39b6e78633a821f266 Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Tue, 13 Nov 2018 16:53:26 +0300 Subject: [PATCH 037/125] CAMEL-12908: Fix CS --- .../camel/model/rest/RestDefinition.java | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java index a960827a36762..5fcce056d7b0a 100644 --- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java @@ -902,27 +902,7 @@ private void addRouteDefinition(CamelContext camelContext, List if (outType != null) { options.put("outType", outType); } - // if no route id has been set, then use the verb id as route id - /* - if (!route.hasCustomIdAssigned()) { - // use id of verb as route id - String id = verb.getId(); - if (id != null) { - route.setId(id); - } - } - */ - - /* - String routeId = verb.idOrCreate(camelContext.getNodeIdFactory()); - - if (!verb.getUsedForGeneratingNodeId()) { - routeId = route.idOrCreate(camelContext.getNodeIdFactory()); - } - verb.setRouteId(routeId); - options.put("routeId", routeId); - */ if (component != null && !component.isEmpty()) { options.put("componentName", component); } @@ -1016,7 +996,6 @@ private void addRouteDefinition(CamelContext camelContext, List // the route should be from this rest endpoint route.fromRest(from); - //route.routeId(routeId); route.setRestDefinition(this); answer.add(route); } From cb6e8c2f11b31b25ae6f976ab36ee305307dfa8e Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Fri, 16 Nov 2018 11:16:53 +0100 Subject: [PATCH 038/125] Upgrade Ehcache to version 3.6.2 --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index fa9b2d0aeaa25..92615765b9e3a 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -190,7 +190,7 @@ 2.1.5 2.1.5_1 2.10.6 - 3.6.1 + 3.6.2 5.3.0 2.4.4_1 18.0 From 732f55adaa89bd8f42b3586880a21b09658710c5 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Fri, 16 Nov 2018 11:58:37 +0100 Subject: [PATCH 039/125] CAMEL-12759 - Misleading documentation for Netty components - Netty4 --- .../src/main/docs/netty4-component.adoc | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/components/camel-netty4/src/main/docs/netty4-component.adoc b/components/camel-netty4/src/main/docs/netty4-component.adoc index 0d6296442f098..0fce4abf529eb 100644 --- a/components/camel-netty4/src/main/docs/netty4-component.adoc +++ b/components/camel-netty4/src/main/docs/netty4-component.adoc @@ -37,7 +37,7 @@ The URI scheme for a netty component is as follows [source,text] ---- -netty4:tcp://localhost:99999[?options] +netty4:tcp://0.0.0.0:99999[?options] netty4:udp://remotehost:99999/[?options] ---- @@ -360,7 +360,7 @@ operations. ---- RouteBuilder builder = new RouteBuilder() { public void configure() { - from("netty4:udp://localhost:5155?sync=true") + from("netty4:udp://0.0.0.0:5155?sync=true") .process(new Processor() { public void process(Exchange exchange) throws Exception { Poetry poetry = (Poetry) exchange.getIn().getBody(); @@ -378,7 +378,7 @@ RouteBuilder builder = new RouteBuilder() { ---- RouteBuilder builder = new RouteBuilder() { public void configure() { - from("netty4:tcp://localhost:5150") + from("netty4:tcp://0.0.0.0:5150") .to("mock:result"); } }; @@ -432,7 +432,7 @@ Spring DSL based configuration of endpoint ... ... - + ... ---- @@ -450,7 +450,7 @@ context.createRegistry(registry); context.addRoutes(new RouteBuilder() { public void configure() { String netty_ssl_endpoint = - "netty4:tcp://localhost:5150?sync=true&ssl=true&passphrase=#password" + "netty4:tcp://0.0.0.0:5150?sync=true&ssl=true&passphrase=#password" + "&keyStoreFile=#ksf&trustStoreFile=#tsf"; String return_string = "When You Go Home, Tell Them Of Us And Say," @@ -578,9 +578,9 @@ a comma separated list or contained in a List e.g. [source,java] ---- - from("direct:multiple-codec").to("netty4:tcp://localhost:{{port}}?encoders=#encoders&sync=false"); + from("direct:multiple-codec").to("netty4:tcp://0.0.0.0:{{port}}?encoders=#encoders&sync=false"); - from("netty4:tcp://localhost:{{port}}?decoders=#length-decoder,#string-decoder&sync=false").to("mock:multiple-codec"); + from("netty4:tcp://0.0.0.0:{{port}}?decoders=#length-decoder,#string-decoder&sync=false").to("mock:multiple-codec"); ---- or via XML. @@ -590,10 +590,10 @@ or via XML. - + - + @@ -615,7 +615,7 @@ written the bye message back to the client: [source,java] ---- -from("netty4:tcp://localhost:8080").process(new Processor() { +from("netty4:tcp://0.0.0.0:8080").process(new Processor() { public void process(Exchange exchange) throws Exception { String body = exchange.getIn().getBody(String.class); exchange.getOut().setBody("Bye " + body); @@ -685,7 +685,7 @@ registry.bind("spf", factory); context.addRoutes(new RouteBuilder() { public void configure() { String netty_ssl_endpoint = - "netty4:tcp://localhost:5150?serverInitializerFactory=#spf" + "netty4:tcp://0.0.0.0:5150?serverInitializerFactory=#spf" String return_string = "When You Go Home, Tell Them Of Us And Say," + "For Your Tomorrow, We Gave Our Today."; @@ -738,7 +738,7 @@ as shown below: [source,xml] ---- - + ... @@ -749,7 +749,7 @@ And if we have another route we can refer to the shared worker pool: [source,xml] ---- - + ... From c065ce18af9c9465f1746ce9f05b58c2dc4fa166 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Fri, 16 Nov 2018 12:00:26 +0100 Subject: [PATCH 040/125] CAMEL-12759 - Misleading documentation for Netty components - Netty4-http --- .../src/main/docs/netty4-http-component.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/camel-netty4-http/src/main/docs/netty4-http-component.adoc b/components/camel-netty4-http/src/main/docs/netty4-http-component.adoc index 6018cbde8ef06..144a257149562 100644 --- a/components/camel-netty4-http/src/main/docs/netty4-http-component.adoc +++ b/components/camel-netty4-http/src/main/docs/netty4-http-component.adoc @@ -39,7 +39,7 @@ The URI scheme for a netty component is as follows [source,java] ------------------------------------------- -netty4-http:http://localhost:8080[?options] +netty4-http:http://0.0.0.0:8080[?options] ------------------------------------------- You can append query options to the URI in the following format, @@ -362,7 +362,7 @@ ProducerTemplate as shown below: [source,java] ------------------------------------------------------------------------------------------------------------ - String out = template.requestBody("netty4-http:http://localhost:8080/foo", "Hello World", String.class); + String out = template.requestBody("netty4-http:http://0.0.0.0:8080/foo", "Hello World", String.class); System.out.println(out); ------------------------------------------------------------------------------------------------------------ From c0ff44454b823f2e8f69401ff8c3be3b5af389da Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Fri, 16 Nov 2018 12:01:23 +0100 Subject: [PATCH 041/125] CAMEL-12759 - Misleading documentation for Netty components - Netty --- .../src/main/docs/netty-component.adoc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/components/camel-netty/src/main/docs/netty-component.adoc b/components/camel-netty/src/main/docs/netty-component.adoc index f4f6012cf6713..b0a56a90d90e8 100644 --- a/components/camel-netty/src/main/docs/netty-component.adoc +++ b/components/camel-netty/src/main/docs/netty-component.adoc @@ -40,7 +40,7 @@ The URI scheme for a netty component is as follows [source,java] --------------------------------------- -netty:tcp://localhost:99999[?options] +netty:tcp://0.0.0.0:99999[?options] netty:udp://remotehost:99999/[?options] --------------------------------------- @@ -385,7 +385,7 @@ netty. ------------------------------------------------------------------ RouteBuilder builder = new RouteBuilder() { public void configure() { - from("netty:udp://localhost:5155?sync=true") + from("netty:udp://0.0.0.0:5155?sync=true") .process(new Processor() { public void process(Exchange exchange) throws Exception { Poetry poetry = (Poetry) exchange.getIn().getBody(); @@ -403,7 +403,7 @@ RouteBuilder builder = new RouteBuilder() { ------------------------------------------- RouteBuilder builder = new RouteBuilder() { public void configure() { - from("netty:tcp://localhost:5150") + from("netty:tcp://0.0.0.0:5150") .to("mock:result"); } }; @@ -457,7 +457,7 @@ Spring DSL based configuration of endpoint ... ... - + ... ------------------------------------------------------------------------------------------------------ @@ -475,7 +475,7 @@ context.createRegistry(registry); context.addRoutes(new RouteBuilder() { public void configure() { String netty_ssl_endpoint = - "netty:tcp://localhost:5150?sync=true&ssl=true&passphrase=#password" + "netty:tcp://0.0.0.0:5150?sync=true&ssl=true&passphrase=#password" + "&keyStoreFile=#ksf&trustStoreFile=#tsf"; String return_string = "When You Go Home, Tell Them Of Us And Say," @@ -561,7 +561,7 @@ written the bye message back to the client: [source,java] -------------------------------------------------------------------------------------------------------- - from("netty:tcp://localhost:8080").process(new Processor() { + from("netty:tcp://0.0.0.0:8080").process(new Processor() { public void process(Exchange exchange) throws Exception { String body = exchange.getIn().getBody(String.class); exchange.getOut().setBody("Bye " + body); @@ -632,7 +632,7 @@ registry.bind("spf", serverPipelineFactory); context.addRoutes(new RouteBuilder() { public void configure() { String netty_ssl_endpoint = - "netty:tcp://localhost:5150?serverPipelineFactory=#spf" + "netty:tcp://0.0.0.0:5150?serverPipelineFactory=#spf" String return_string = "When You Go Home, Tell Them Of Us And Say," + "For Your Tomorrow, We Gave Our Today."; @@ -687,7 +687,7 @@ as shown below: [source,xml] ----------------------------------------------------------------------------------------------------------------------------------------- - + ... @@ -698,7 +698,7 @@ And if we have another route we can refer to the shared worker pool: [source,xml] ----------------------------------------------------------------------------------------------------------------------------------------- - + ... From 69f30d3921688075fa23f52567445e0db4bc8fa0 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Fri, 16 Nov 2018 12:02:44 +0100 Subject: [PATCH 042/125] CAMEL-12759 - Misleading documentation for Netty components - Netty-http --- .../camel-netty-http/src/main/docs/netty-http-component.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/camel-netty-http/src/main/docs/netty-http-component.adoc b/components/camel-netty-http/src/main/docs/netty-http-component.adoc index 1d3641bc480d9..2984a0e64ade1 100644 --- a/components/camel-netty-http/src/main/docs/netty-http-component.adoc +++ b/components/camel-netty-http/src/main/docs/netty-http-component.adoc @@ -42,7 +42,7 @@ The URI scheme for a netty component is as follows [source,java] ------------------------------------------ -netty-http:http://localhost:8080[?options] +netty-http:http://0.0.0.0:8080[?options] ------------------------------------------ You can append query options to the URI in the following format, @@ -353,7 +353,7 @@ ProducerTemplate as shown below: [source,java] ----------------------------------------------------------------------------------------------------------- - String out = template.requestBody("netty-http:http://localhost:8080/foo", "Hello World", String.class); + String out = template.requestBody("netty-http:http://0.0.0.0:8080/foo", "Hello World", String.class); System.out.println(out); ----------------------------------------------------------------------------------------------------------- From 16a7508fdd0be0fa179204f40beb6bfdda1f0467 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Fri, 16 Nov 2018 13:30:25 +0100 Subject: [PATCH 043/125] CAMEL-12631 - SFTP: Socket timeout overwrites Server Alive Interval --- .../camel/component/file/remote/SftpOperations.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java index b912151f119c1..23abe1e48b4d6 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java @@ -354,8 +354,12 @@ public String[] promptKeyboardInteractive(String destination, String name, }); // set the SO_TIMEOUT for the time after the connect phase - if (configuration.getSoTimeout() > 0) { - session.setTimeout(configuration.getSoTimeout()); + if (sftpConfig.getServerAliveInterval() == 0) { + if (configuration.getSoTimeout() > 0) { + session.setTimeout(configuration.getSoTimeout()); + } + } else { + LOG.debug("The Server Alive Internal is already set, the socket timeout won't be considered to avoid overidding the provided Server alive interval value"); } // set proxy if configured From 4856ecda0a293e34f836d6e1542b5b2b3a8c5657 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Fri, 16 Nov 2018 13:47:02 +0100 Subject: [PATCH 044/125] CAMEL-12631 - Fixed CS --- .../component/file/remote/SftpOperations.java | 114 ++++++++++-------- 1 file changed, 65 insertions(+), 49 deletions(-) diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java index 23abe1e48b4d6..834595aedbb58 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java @@ -47,6 +47,7 @@ import com.jcraft.jsch.SocketFactory; import com.jcraft.jsch.UIKeyboardInteractive; import com.jcraft.jsch.UserInfo; + import org.apache.camel.Exchange; import org.apache.camel.InvalidPayloadException; import org.apache.camel.LoggingLevel; @@ -70,7 +71,8 @@ /** * SFTP remote file operations *

- * The JSCH session and channel are not thread-safe so we need to synchronize access to using this operation. + * The JSCH session and channel are not thread-safe so we need to synchronize + * access to using this operation. */ public class SftpOperations implements RemoteFileOperations { private static final Logger LOG = LoggerFactory.getLogger(SftpOperations.class); @@ -88,13 +90,14 @@ public SftpOperations(Proxy proxy) { } /** - * Extended user info which supports interactive keyboard mode, by entering the password. + * Extended user info which supports interactive keyboard mode, by entering + * the password. */ public interface ExtendedUserInfo extends UserInfo, UIKeyboardInteractive { } public void setEndpoint(GenericFileEndpoint endpoint) { - this.endpoint = (SftpEndpoint) endpoint; + this.endpoint = (SftpEndpoint)endpoint; } public synchronized boolean connect(RemoteFileConfiguration configuration) throws GenericFileOperationFailedException { @@ -126,7 +129,7 @@ public synchronized boolean connect(RemoteFileConfiguration configuration) throw } LOG.trace("Channel isn't connected, trying to recreate and connect."); - channel = (ChannelSftp) session.openChannel("sftp"); + channel = (ChannelSftp)session.openChannel("sftp"); if (endpoint.getConfiguration().getConnectTimeout() > 0) { LOG.trace("Connecting use connectTimeout: {} ...", endpoint.getConfiguration().getConnectTimeout()); @@ -191,7 +194,7 @@ protected Session createSession(final RemoteFileConfiguration configuration) thr final JSch jsch = new JSch(); JSch.setLogger(new JSchLogger(endpoint.getConfiguration().getJschLoggingLevel())); - SftpConfiguration sftpConfig = (SftpConfiguration) configuration; + SftpConfiguration sftpConfig = (SftpConfiguration)configuration; if (isNotEmpty(sftpConfig.getCiphers())) { LOG.debug("Using ciphers: {}", sftpConfig.getCiphers()); @@ -333,7 +336,8 @@ public boolean promptPassphrase(String s) { public boolean promptYesNo(String s) { LOG.warn("Server asks for confirmation (yes|no): {}. Camel will answer no.", s); - // Return 'false' indicating modification of the hosts file is disabled. + // Return 'false' indicating modification of the hosts file is + // disabled. return false; } @@ -341,13 +345,12 @@ public void showMessage(String s) { LOG.trace("Message received from Server: {}", s); } - public String[] promptKeyboardInteractive(String destination, String name, - String instruction, String[] prompt, boolean[] echo) { + public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt, boolean[] echo) { // must return an empty array if password is null if (configuration.getPassword() == null) { return new String[0]; } else { - return new String[]{configuration.getPassword()}; + return new String[] {configuration.getPassword()}; } } @@ -356,10 +359,10 @@ public String[] promptKeyboardInteractive(String destination, String name, // set the SO_TIMEOUT for the time after the connect phase if (sftpConfig.getServerAliveInterval() == 0) { if (configuration.getSoTimeout() > 0) { - session.setTimeout(configuration.getSoTimeout()); + session.setTimeout(configuration.getSoTimeout()); } } else { - LOG.debug("The Server Alive Internal is already set, the socket timeout won't be considered to avoid overidding the provided Server alive interval value"); + LOG.debug("The Server Alive Internal is already set, the socket timeout won't be considered to avoid overidding the provided Server alive interval value"); } // set proxy if configured @@ -486,7 +489,7 @@ public synchronized boolean renameFile(String from, String to) throws GenericFil LOG.debug("Renaming file: {} to: {}", from, to); try { reconnectIfNecessary(); - //make use of the '/' separator because JSch expects this + // make use of the '/' separator because JSch expects this // as the file separator even on Windows to = FileUtil.compactPath(to, '/'); channel.rename(from, to); @@ -511,7 +514,8 @@ public synchronized boolean buildDirectory(String directory, boolean absolute) t channel.ls(directory); success = true; } catch (SftpException e) { - // ignore, we could not change directory so try to create it instead + // ignore, we could not change directory so try to create it + // instead } if (!success) { @@ -521,7 +525,8 @@ public synchronized boolean buildDirectory(String directory, boolean absolute) t channel.mkdir(directory); success = true; } catch (SftpException e) { - // we are here if the server side doesn't create intermediate folders + // we are here if the server side doesn't create + // intermediate folders // so create the folder one by one success = buildDirectoryChunks(directory); } @@ -582,8 +587,10 @@ public synchronized void changeCurrentDirectory(String path) throws GenericFileO return; } - // must compact path so SFTP server can traverse correctly, make use of the '/' - // separator because JSch expects this as the file separator even on Windows + // must compact path so SFTP server can traverse correctly, make use of + // the '/' + // separator because JSch expects this as the file separator even on + // Windows String before = path; char separatorChar = '/'; path = FileUtil.compactPath(path, separatorChar); @@ -597,8 +604,9 @@ public synchronized void changeCurrentDirectory(String path) throws GenericFileO return; } if (getCurrentDirectory().startsWith(path)) { - // extract the path segment relative to the target path and make sure it keeps the preceding '/' for the regex op - String p = getCurrentDirectory().substring(path.length() - (path.endsWith("/") ? 1 : 0)); + // extract the path segment relative to the target path and make + // sure it keeps the preceding '/' for the regex op + String p = getCurrentDirectory().substring(path.length() - (path.endsWith("/") ? 1 : 0)); if (p.length() == 0) { return; } @@ -606,7 +614,8 @@ public synchronized void changeCurrentDirectory(String path) throws GenericFileO path = UP_DIR_PATTERN.matcher(p).replaceAll("/..").substring(1); } - // if it starts with the root path then a little special handling for that + // if it starts with the root path then a little special handling for + // that if (FileUtil.hasLeadingSeparator(path)) { // change to root path if (!FileUtil.isWindows()) { @@ -677,7 +686,7 @@ public synchronized List listFiles(String path) throws GenericFi // can return either null or an empty list depending on FTP servers if (files != null) { for (Object file : files) { - list.add(new SftpRemoteFileJCraft((ChannelSftp.LsEntry) file)); + list.add(new SftpRemoteFileJCraft((ChannelSftp.LsEntry)file)); } } return list; @@ -689,7 +698,8 @@ public synchronized List listFiles(String path) throws GenericFi public synchronized boolean retrieveFile(String name, Exchange exchange, long size) throws GenericFileOperationFailedException { LOG.trace("retrieveFile({})", name); if (ObjectHelper.isNotEmpty(endpoint.getLocalWorkDirectory())) { - // local work directory is configured so we should store file content as files in this local directory + // local work directory is configured so we should store file + // content as files in this local directory return retrieveFileToFileInLocalWorkDirectory(name, exchange); } else { // store file content directory as stream on the body @@ -713,8 +723,7 @@ public synchronized void releaseRetrievedFileResources(Exchange exchange) throws private boolean retrieveFileToStreamInBody(String name, Exchange exchange) throws GenericFileOperationFailedException { String currentDir = null; try { - GenericFile target = - (GenericFile) exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE); + GenericFile target = (GenericFile)exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE); ObjectHelper.notNull(target, "Exchange should have the " + FileComponent.FILE_EXCHANGE_FILE + " set"); String remoteName = name; @@ -723,12 +732,14 @@ private boolean retrieveFileToStreamInBody(String name, Exchange exchange) throw currentDir = getCurrentDirectory(); // change directory to path where the file is to be retrieved - // (must do this as some FTP servers cannot retrieve using absolute path) + // (must do this as some FTP servers cannot retrieve using + // absolute path) String path = FileUtil.onlyPath(name); if (path != null) { changeCurrentDirectory(path); } - // remote name is now only the file name as we just changed directory + // remote name is now only the file name as we just changed + // directory remoteName = FileUtil.stripPath(name); } @@ -764,8 +775,7 @@ private boolean retrieveFileToFileInLocalWorkDirectory(String name, Exchange exc File temp; File local = new File(endpoint.getLocalWorkDirectory()); OutputStream os; - GenericFile file = - (GenericFile) exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE); + GenericFile file = (GenericFile)exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE); ObjectHelper.notNull(file, "Exchange should have the " + FileComponent.FILE_EXCHANGE_FILE + " set"); try { // use relative filename in local work directory @@ -794,7 +804,8 @@ private boolean retrieveFileToFileInLocalWorkDirectory(String name, Exchange exc throw new GenericFileOperationFailedException("Cannot create new local work file: " + temp); } - // store content as a file in the local work directory in the temp handle + // store content as a file in the local work directory in the temp + // handle os = new FileOutputStream(temp); // set header with the path to the local work file @@ -813,12 +824,14 @@ private boolean retrieveFileToFileInLocalWorkDirectory(String name, Exchange exc currentDir = getCurrentDirectory(); // change directory to path where the file is to be retrieved - // (must do this as some FTP servers cannot retrieve using absolute path) + // (must do this as some FTP servers cannot retrieve using + // absolute path) String path = FileUtil.onlyPath(name); if (path != null) { changeCurrentDirectory(path); } - // remote name is now only the file name as we just changed directory + // remote name is now only the file name as we just changed + // directory remoteName = FileUtil.stripPath(name); } @@ -826,7 +839,8 @@ private boolean retrieveFileToFileInLocalWorkDirectory(String name, Exchange exc } catch (SftpException e) { LOG.trace("Error occurred during retrieving file: {} to local directory. Deleting local work file: {}", name, temp); - // failed to retrieve the file so we need to close streams and delete in progress file + // failed to retrieve the file so we need to close streams and + // delete in progress file // must close stream before deleting file IOHelper.close(os, "retrieve: " + name, LOG); boolean deleted = FileUtil.deleteFile(temp); @@ -845,7 +859,8 @@ private boolean retrieveFileToFileInLocalWorkDirectory(String name, Exchange exc LOG.debug("Retrieve file to local work file result: true"); - // operation went okay so rename temp to local after we have retrieved the data + // operation went okay so rename temp to local after we have retrieved + // the data LOG.trace("Renaming local in progress file from: {} to: {}", temp, local); try { if (!FileUtil.renameFile(temp, local, false)) { @@ -871,13 +886,15 @@ public synchronized boolean storeFile(String name, Exchange exchange, long size) try { if (path != null && endpoint.getConfiguration().isStepwise()) { - // must remember current dir so we stay in that directory after the write + // must remember current dir so we stay in that directory after + // the write currentDir = getCurrentDirectory(); // change to path of name changeCurrentDirectory(path); - // the target name should be without path, as we have changed directory + // the target name should be without path, as we have changed + // directory targetName = FileUtil.stripPath(name); } @@ -897,9 +914,7 @@ private boolean doStoreFile(String name, String targetName, Exchange exchange) t LOG.trace("doStoreFile({})", targetName); // if an existing file already exists what should we do? - if (endpoint.getFileExist() == GenericFileExist.Ignore - || endpoint.getFileExist() == GenericFileExist.Fail - || endpoint.getFileExist() == GenericFileExist.Move) { + if (endpoint.getFileExist() == GenericFileExist.Ignore || endpoint.getFileExist() == GenericFileExist.Fail || endpoint.getFileExist() == GenericFileExist.Move) { boolean existFile = existsFile(targetName); if (existFile && endpoint.getFileExist() == GenericFileExist.Ignore) { // ignore but indicate that the file was written @@ -918,7 +933,7 @@ private boolean doStoreFile(String name, String targetName, Exchange exchange) t // Do an explicit test for a null body and decide what to do if (endpoint.isAllowNullBody()) { LOG.trace("Writing empty file."); - is = new ByteArrayInputStream(new byte[]{}); + is = new ByteArrayInputStream(new byte[] {}); } else { throw new GenericFileOperationFailedException("Cannot write null body to file: " + name); } @@ -949,8 +964,7 @@ private boolean doStoreFile(String name, String targetName, Exchange exchange) t } if (LOG.isDebugEnabled()) { long time = watch.taken(); - LOG.debug("Took {} ({} millis) to store file: {} and FTP client returned: true", - new Object[]{TimeUtils.printDuration(time), time, targetName}); + LOG.debug("Took {} ({} millis) to store file: {} and FTP client returned: true", new Object[] {TimeUtils.printDuration(time), time, targetName}); } // after storing file, we may set chmod on the file @@ -974,7 +988,7 @@ private boolean doStoreFile(String name, String targetName, Exchange exchange) t IOHelper.close(is, "store: " + name, LOG); } } - + public synchronized boolean existsFile(String name) throws GenericFileOperationFailedException { LOG.trace("existsFile({})", name); if (endpoint.isFastExistsCheck()) { @@ -996,7 +1010,7 @@ public synchronized boolean existsFile(String name) throws GenericFileOperationF return false; } for (Object file : files) { - ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) file; + ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry)file; String existing = entry.getFilename(); LOG.trace("Existing file: {}, target file: {}", existing, name); existing = FileUtil.stripPath(existing); @@ -1006,7 +1020,8 @@ public synchronized boolean existsFile(String name) throws GenericFileOperationF } return false; } catch (SftpException e) { - // or an exception can be thrown with id 2 which means file does not exists + // or an exception can be thrown with id 2 which means file does not + // exists if (ChannelSftp.SSH_FX_NO_SUCH_FILE == e.id) { return false; } @@ -1025,7 +1040,8 @@ protected boolean fastExistsFile(String name) throws GenericFileOperationFailedE } return files.size() >= 1; } catch (SftpException e) { - // or an exception can be thrown with id 2 which means file does not exists + // or an exception can be thrown with id 2 which means file does not + // exists if (ChannelSftp.SSH_FX_NO_SUCH_FILE == e.id) { return false; } @@ -1054,10 +1070,9 @@ public synchronized boolean sendSiteCommand(String command) throws GenericFileOp } /* - * adapted from com.jcraft.jsch.Util.createSocket(String, int, int) - * - * added possibility to specify the address of the local network interface, against the - * connection should bind + * adapted from com.jcraft.jsch.Util.createSocket(String, int, int) added + * possibility to specify the address of the local network interface, + * against the connection should bind */ static Socket createSocketUtil(final String host, final int port, final String bindAddress, final int timeout) { Socket socket = null; @@ -1086,7 +1101,8 @@ public void run() { if (sockp[0] != null && sockp[0].isConnected()) { try { sockp[0].close(); - } catch (Exception eee) { } + } catch (Exception eee) { + } } sockp[0] = null; } From ca6a1bf711a0248c820962d2a39257b17a39540c Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Fri, 16 Nov 2018 15:18:59 +0100 Subject: [PATCH 045/125] Upgrade TestContainers to version 1.10.1 --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index 92615765b9e3a..f45cb79484728 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -679,7 +679,7 @@ 4.0.8 1.2.1_1 1.2.1 - 1.10.0 + 1.10.1 6.14.2 2.1.1 1.19.1 From 4c55060b8ce277504296bab92c2ef3a8543be7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Gru=CC=88ndler?= Date: Fri, 16 Nov 2018 15:02:34 +0100 Subject: [PATCH 046/125] UPDATED RestBindingAdvice - Support for the catchAll */* MimeType - Added some logs to ease debugging when clientRequestValidation is turned on --- .../apache/camel/processor/RestBindingAdvice.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java b/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java index 7b401ac19c372..90fe9d4e332aa 100644 --- a/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java +++ b/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java @@ -34,6 +34,8 @@ import org.apache.camel.util.ExchangeHelper; import org.apache.camel.util.MessageHelper; import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A {@link org.apache.camel.processor.CamelInternalProcessorAdvice} that binds the REST DSL incoming @@ -47,6 +49,8 @@ * @see CamelInternalProcessor */ public class RestBindingAdvice implements CamelInternalProcessorAdvice> { + + private static final Logger LOG = LoggerFactory.getLogger(RestBindingAdvice.class); private static final String STATE_KEY_DO_MARSHAL = "doMarshal"; private static final String STATE_KEY_ACCEPT = "accept"; private static final String STATE_JSON = "json"; @@ -198,6 +202,7 @@ private void unmarshal(Exchange exchange, Map state) throws Exce if (clientRequestValidation) { // check if the content-type is accepted according to consumes if (!isValidOrAcceptedContentType(consumes, contentType)) { + LOG.trace("Consuming content type does not match contentType header {}. Stopping routing.", contentType); // the content-type is not something we can process so its a HTTP_ERROR 415 exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 415); // stop routing and return @@ -207,6 +212,7 @@ private void unmarshal(Exchange exchange, Map state) throws Exce // check if what is produces is accepted by the client if (!isValidOrAcceptedContentType(produces, accept)) { + LOG.trace("Produced content type does not match accept header {}. Stopping routing.", contentType); // the response type is not accepted by the client so its a HTTP_ERROR 406 exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 406); // stop routing and return @@ -507,6 +513,12 @@ private static boolean isValidOrAcceptedContentType(String valid, String target) return true; } + // Any MIME type + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept#Directives + if ("*/*".equals(target)) { + return true; + } + boolean isXml = valid.toLowerCase(Locale.ENGLISH).contains("xml"); boolean isJson = valid.toLowerCase(Locale.ENGLISH).contains("json"); From c704b6d3422db09cc321870feff5c4bc3e798ff3 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Fri, 16 Nov 2018 15:33:16 +0100 Subject: [PATCH 047/125] Camel-Ipfs: Removed html folder from test resources --- .../src/test/resources/html/chap/ch01.html | 13 ------ .../src/test/resources/html/css/default.css | 38 ------------------ .../src/test/resources/html/etc/userfile.txt | 1 - .../src/test/resources/html/img/logo.png | Bin 6715 -> 0 bytes .../src/test/resources/html/index.html | 13 ------ 5 files changed, 65 deletions(-) delete mode 100644 components/camel-ipfs/src/test/resources/html/chap/ch01.html delete mode 100644 components/camel-ipfs/src/test/resources/html/css/default.css delete mode 100644 components/camel-ipfs/src/test/resources/html/etc/userfile.txt delete mode 100644 components/camel-ipfs/src/test/resources/html/img/logo.png delete mode 100644 components/camel-ipfs/src/test/resources/html/index.html diff --git a/components/camel-ipfs/src/test/resources/html/chap/ch01.html b/components/camel-ipfs/src/test/resources/html/chap/ch01.html deleted file mode 100644 index 4edc3fd6b87d8..0000000000000 --- a/components/camel-ipfs/src/test/resources/html/chap/ch01.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - IPFS - - - - -

Home

-

Chapter 01

-

logo

- - diff --git a/components/camel-ipfs/src/test/resources/html/css/default.css b/components/camel-ipfs/src/test/resources/html/css/default.css deleted file mode 100644 index 8c0b2d558f3d0..0000000000000 --- a/components/camel-ipfs/src/test/resources/html/css/default.css +++ /dev/null @@ -1,38 +0,0 @@ -body { - font-family: "Verdana"; - color: #137cb9 -} - -a { - #text-decoration: none; - color: #137cb9 -} - -a.gray { - color: gray; -} - -h1 { - font-weight: normal; - font-size: 20px; -} - -h2 { - font-weight: normal; - font-size: 15px; -} - -th { - text-align: left; - font-weight: normal; - font-size: 14px; - color: gray; -} - -td.gray { - color: gray; -} -tr.gray { - color: gray; -} - diff --git a/components/camel-ipfs/src/test/resources/html/etc/userfile.txt b/components/camel-ipfs/src/test/resources/html/etc/userfile.txt deleted file mode 100644 index 8fe2a4b5ad117..0000000000000 --- a/components/camel-ipfs/src/test/resources/html/etc/userfile.txt +++ /dev/null @@ -1 +0,0 @@ -The quick brown fox jumps over the lazy dog. \ No newline at end of file diff --git a/components/camel-ipfs/src/test/resources/html/img/logo.png b/components/camel-ipfs/src/test/resources/html/img/logo.png deleted file mode 100644 index ddda52e086e85692a94c2d014626bdf26f94e9c6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6715 zcmd5>_g53lwoT~LrG@|jLFt4lH3S5tC`Eb@siBC{lh8prNEJ~)se*z6(xsQsMY>e! zgf2Do&eQMSci(&e!JD;a&dixTd(WAl&N}n*k&ZeQIhY&(08nXasOtZ*ul{y2l0W0B z8m{J#0iyKPl>x>5Z0mm(H{3K#Q2+o1{of7*yiW)H0hl@(BG3qJEjgsCGt}DF)y59$ z?dHhu7416f98MPB3zvRK+w+>xDeWpI8|Id>^Sd2 zC845RaB@ygPMC+Sy_~+P+P{zgSt)QmMWfy1L`1y2yr5nZP*)EJ5iwa=SrJij5pi+h zKL}xzj|o`0~7fx{=Y8suSoy# z{s|RM4iov$v%$%=T6s+Y0Fa-i>ODhm;FdXs8~dmayxxz)*DQI7H}KUi2piVVp#PZQ z-m4((BnEMVT4&|Sm$yEJIjU$p1=~c$-bsrE((67~=B(*`Bgv`%^EH}0)?ibCPc z8}bMcS)kc#JB8xy#`Cq~jC%FQmNSKZB|^XSPp{wU)_WbNS2#59Z@sue9o_oW9tN~l z0@0HEe>HsFO0la2sbu&K3%We@hdKO z>Y|1XL`J>I(3*4+2*<2)z?Q2O{r3CnQ>7nMzlhP+CE?Lla&~ssF)?ATFUbDds4!$c z?q)E5HdjfHCy7!Y6@IdIPg18KU;Xr5Y&rc6qnVK+p{~6%uO0V>1#6cbiu9AStBBwA zFMMV&rtu?_#>JI-#Y{^FA9q8|3z5vUxb&*={_?sy4~x~G_08wMI5&zhbT93Ud-cBU zuhe$`s$ge(x`enlFW9cg-Ah`!(AGFR*mNm2xBoUp^E$y}j)ZC7nd6YH>?^HPw5YgV)^1 z(~c>stOl3$6(Gb}bfqLu?xI%s&}LF>6kPTP&uBF?k&ma;^dE}xfaTnjKAoRCOK0>? z=xmZE)1#F&>P>YHPVV%)B{KM-#3C&3d*O*T*}8aH9JX<7F}};Vd|HUadnYAn{g&a? zGg;;IY)J(5{{eJPD_-a0!?8jXwP*J$Va1bn--JW>#M~0G*B+&zmFn_xiSc{$kD0 z=u1JTT8VEz8>^TuwBK6VP{+$?`!sA>48Awa@?v*Bm~&=4U)||P8OJxmdelarbkh&q zV-!9y(@UV*ThnWkl7aD&WPgp#aGq?NH$grwa*~Fj^ z;;=JNnVoOC^z?KaRQ7-4VbgDKdFo}=?itmgzM(MGrrET|BJ+DCuRo$T#WS`{dd@90 zUih)}G$teM5aMoA)`J@z#h=}eX_%}<-5l?9VqX;s~%nH%W<47^!j&e;`m5caK?whmfx-dpTcXokG|YP@RI* zGSU2X+9hagiE>JIw%YTsJV>>lS>k{0b8uttCI!jo(uX?@tBa{p7LkdgT_>#OZ_S3M zH#xEQ(^0rZW0J|H9nvoY!eIK*B_^0=JE$0r{HYgWQ-*TDornf5QS?jdh z@+D{&R<^7mzMFOX=Ms>2phlC0;{s+Byl!m>^smkf9KRoc4M&fUO{U))vxg~fkH0+a zaiQvD+1kVg&0RK^km_))&%@JNZI@`KXG5hGUv#lIp4H~==792Z@@*_Bl;9JL+eCZ9 z5mc*yhDehKZyZ0alNtFMNZ2sVTJgtzR)6=52qD(nozZUjvD+j-;^wKdx4i{*>P<&C7EzmhdLut$Z zc}TP6LH{tD-RtDU`NyjM5XrwUxdW9i;m0yBv^N=Z(h z)a+Xem5_KJmX~S2_bpNc_L6pTr!Ko+-<$_vH3vBe&4Al6QbqjdQcl+fL0qC;9lvWj z%jvKd^EOt@*oJAHT$z5tCg2kSNy1ODHaV}ZSiH$jsH}cRjh0DqW!uS55|C*Si*@)J zXHvgPy3wUgRTz9cXOhak0;5s0s5pf6z1-~Nvxg{Rc3*)fs!iN8qmtR#TGRC&obw3Y zlrYJfHNnv|MvF-)-{MYm65TElc*9x#6}(Xq)Pb$V9%6NaH-Z$D3{_9QG=ft!vnTMi z&8d1tlH3qzGl3HkV#j|mkn0+8pvA!6LJ^J0{~QzjR8>jiqwwzh4k1Tw;dBRcVZm4? zX+_)bT{G9hf?sh3o-G97H&hH4Ks=Ovz#elPqV|SbjKs(@w;hYOvIMh(8Tv}^f&=?m ztV`{YWUmGuc87v+??me|vl2gokjEnwk0^&=x6>M=fGZzlJ&{=?nZ!__w_U|+o-9*w zk@}`_V6uE>8I<97p^|0lE4#f`Q{riQ7m1iHgbxPfEdsEfiHQp%8xh`JBhXz}2O zB(o^EUa)-=Bfvo|X1Yx)4Ev^Q$?3hH)s*PoB2ji);O}kwED4UU7Ocr4pdc9eMM`RL zlXWP|jg00|duUCE*z`=O9BzRo$oy+opYlY7krAo_3?GSercL%_%H@6B0`3;H9|~aC zIPe0LOn$D;1$`G}T~?ki0dzvzu>4s2c?rO984MbSKc>LG4Z3NMZq{^2=2095;f30L z^EHF)Xq0G9p4ys~8AWGenwY#rwHOpu-G>kw@Z|#f% zMaRUWsG?ALQL*xE$KIu^J<=KBnar?hx+AZ4`5N#tZaKJ)N*5g=&!vCXn;& z@e1E8_LJMecUq&4+sQg+vtO8bKlLg^SV8-IB?YU8=*#rkz}Ix5arHzSmCC0cejewY zQ?5VVyOAIf8Q${Hu21)mSF0GVdKMY!(JgEp#0=UlVMGb-h|i}7!$t+w>I<66GlMnX zJ~SGEbAE8D**LX>ULNG* z6`vr=g>$7oe?A|#R_4*>Le2^g;l9nS;mhX|?&d#kpyGG@96vZUSRvZkO-=O$QU2hr zkVOc#33!T{F@i3>!RN$eEh)0)us#eIOu`Txu;pzm@bym+BfgMM#Ca5im?LT}s5Bp% z*%8?IeBiy&dh(fC#n;oEflA$J(^y7+Qw;8VY|h>`;&DZWzj?pqBs`ZVujL7Sbj2V$ zWUS32I(&tiyFYk*VXe?}*54csVeiJ6Bpua6!AI~XZ6vw8qBBeh-BxdnA1F;*x`d{c zTPSBL0w)5XBr@sEB;N@n^KvJi3QZ}wem>A$CJ;gO zHfz6~qGIp4?xeZmEFQ-&DS>TzjHlJC-QkffejZFKX)@Y?#G(2)xPz_t z4@QZ&>++nX6e=$!Hxg_o&a?lBNdgsOZz^PtmhZVcb4xwIl8_G({gly-$BlOv<_7ql zfa2qWB-oV}l{@1I#3O@fd%4-W&wSs?EK(|La!fRu+0E;LO5E1^Op##AWid6e<#yme zm~}1bKxhgzs?9@-dF^J#OVk64qP&sCDoGRk+Kpvu=i;YQ5w*YNOZ(B&q~iruz)Iyf zJGBRDw6$+OU6%{_%8`eu9Crl^1Yu4T=DV=)pca^VSUO@!vQ1v;03np?bZa>awx=`5 z_p!8$MG2)bu=-y1z+oEMHT0D#f5F@huJO?QWLGE_CBu$Ag(wKQI*o7*=N4XA`Gpvz z$S&;})Kgk4UH#(2mO3ngb4d{qn7IitTu(?6*^nzuI52OOxXz84z_NP1%a=Ys$ zHb|x#rxJ)G2$EQ-4{9dfCee~zX()9p(k>3tI%RkrZ^lX8F6vFIoscK9usT0R8frJ| zGU#>eeoNMXjRoTv)g9ccEAoJMTI_+F!l9WsS#M;c>@j6kW z;(=5JAii|3PZB;1W6B}!nIq;)jsZm1vxs)WI0&{0iUGz1jX_@ojk_jC$oPEOqJsBT zfh(R9+Ik2{iS*T?yTnp$v2i^SE9Icb&GK2&EBcdLyE00->Nagm;!X|&HWn-?7CV3W*Z@UrvDMrNOXEYf<32Ex za5P(ch{O9rB**2^Gur`5Q|*YurPpy8G#<}2q^X$gS-h;lFKq-#c`j?hSGH^+A&25P z4XX^ux&;>0IHbIvJGfUv7DYPNws+wYji(hu)fMwacBZAOeYf;bWOd|8y-C0E!-osW zFnX~|DiR^)IZY(F^1a-;PRy!3^QB>I&IbqKXV(KnwlaLaO&o97^UjNw{Np0uv39pl zMCDfJ7(Y?U^W%SyIokpyCVa3tGs1h1en)2=Ksu&Q)+STY&Gf%|6PGe~kI5PnFYlA9 z>-P_@)xLlFd%c0WC9U=jyN}l8iAP;|i_dF`wjW|pi8649s$;yq3S`T1=y@@Z;R0R<-4H-8H*wouoc(x|FR5Clm~1F?nR=da-Z@AGql5lg zv1`9cH?N#cHQy*69SvDc!xk>cRWnwK#X~F!D0Yn_A|0}wrG6wHdllvx=<=uf)H!{u zIRyz>%C~Aifx!&jF)rtRb-%gcWhyDENO z_0NG^iyO=aJf826HUJ{y5&d>eiyY~=%$@fz0yfL01rcjR6)DsOdm$AKX zloW^6LL384$*%VLuViJ8^}c`C#n^VG#)y=c{2cX&w=B?7!O7i*vDQ#|1GB5Ur9D)F z?{}yq90-Sd&*1L63gE+dK+XicI!7;aUpxbu2lo^3HB&|e)- zJZ*PAc67Lrbwi>owh^^-4p?w|;d01jJTg5<4we!g*pgC~r z2itng!e~}NW=iALr^5~C2=3lx;>XvWcD{7#ZjFczEihD&pQF3$+r?r+T1{-mrZykJ zm{_yZ6;Cg`V$Mm>492Iz+`0^k2^83tIG!1Q{S7y_JJXwzVQZwF(**x)S&Hq-1znKa zud9ni`(_&)N(|mnpxsxIaWX=iKrB#I_;nVF86)z{RlgIuE_RWsYSd2(jyvO)y(Lj$ zV!R@(KkS19*v21obCf)BzrI|ZmnWZ74r+X@a$fLD+hQi-DeVt%G-;22>(Pj=2U0J2#wnP4$Q{EB7?O8f4a>qa(e$w20b$SV-UK`C+qa` z^1S*<1QaO@d83$>@MWw&YX|qC43~A9ksY*#*#)A=^1B`$AFT~cw3s!9sI!{5T6&!) z6{Q`?^dxsT-%CZDbD)a%h!`LdWqR`Cr|z!p4+J3-dns#bE*)$6#B=&f8!{H+sT2PooqcH6SWx5RfiaCo=7}O4AMHx z!4Ku{1gza2cXw@}y?)%=e7gW_e~O`C-fg3(EveaK;Y2LxAwY!he0V%fG-4vRFI!Yd zPkBi5smo7pZ-y4LqnoCGow6n~D!^aFWXO>4+|DkoGk(65^|k2aDmekCVo+GNL$emQ zn_K`n;)a*YyfA#El>bQSuA6-=C(FL}T5(;Y)Ah~RqFs)FH-{2)FTF0*9nK%Zc;cC- zc&=liA7A(i#ot#tqZ|yMD7k+{)w*}i(Lgsd`8aBgn}KRJ!|N6gX*Eb_Hharwk?PVB z)K7Rf!?P~%Glc#H5Z;-6{g8%7^z_+2b88@02mst-qXl z?_~JR1>l(&ub<63xV9XJ+Pk+)J@2Lyk&szCSO}%?_X>P^4L53z5~1fgP&6D$XsEML zY#J$pSD^73XB_<>Rztm)IQm&$=P!8tB(m)n24@vblrP&}?APACH&zc8VZg}`J7!tj zND7jIy|RdOD98KKxL9>?#2a-qUHbc-mzWw?vKdqf<#YV4vIazhK71=?xy-LmQQXCL z2}>j5kIGy0s zi<<+hesyyGD(cY(@pT3vco-4`|ijA05s6I;zFWRw4fdj6P18 diff --git a/components/camel-ipfs/src/test/resources/html/index.html b/components/camel-ipfs/src/test/resources/html/index.html deleted file mode 100644 index 3781300297051..0000000000000 --- a/components/camel-ipfs/src/test/resources/html/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - IPFS - - - - -

Home

-

chapter one

-

logo

- - From ba41842546dcbaa563058dbc7b777e9c5a9d13c5 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Mon, 19 Nov 2018 08:49:07 +0100 Subject: [PATCH 048/125] Camel-RestDsl-Swagger-plugin: Fixed CS --- .../camel/maven/generator/swagger/AbstractGenerateMojo.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java index 7d1903dd3e15d..83bd4ec3a5339 100644 --- a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java +++ b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java @@ -92,14 +92,14 @@ abstract class AbstractGenerateMojo extends AbstractMojo { @Parameter(defaultValue = "true") String modelWithXml; + @Parameter + String apiContextPath; + @Parameter(defaultValue = "${project}", readonly = true) private MavenProject mavenProject; @Parameter(defaultValue = "${session}", readonly = true) private MavenSession mavenSession; - - @Parameter - String apiContextPath; @Component private BuildPluginManager pluginManager; From e490135fc7ff4c51743b9b78dc15ee34ae55f435 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Mon, 19 Nov 2018 08:52:29 +0100 Subject: [PATCH 049/125] Camel-Core: Fixed CS in RestBindingAdvice --- .../java/org/apache/camel/processor/RestBindingAdvice.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java b/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java index 90fe9d4e332aa..3b6cabce491bb 100644 --- a/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java +++ b/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java @@ -516,7 +516,7 @@ private static boolean isValidOrAcceptedContentType(String valid, String target) // Any MIME type // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept#Directives if ("*/*".equals(target)) { - return true; + return true; } boolean isXml = valid.toLowerCase(Locale.ENGLISH).contains("xml"); @@ -534,4 +534,4 @@ private static boolean isValidOrAcceptedContentType(String valid, String target) return true; } -} \ No newline at end of file +} From 7cd202ea014d927ed1531c416cbed0f42446cfe6 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Mon, 19 Nov 2018 09:17:37 +0100 Subject: [PATCH 050/125] Revert "Camel-Ipfs: Removed html folder from test resources" This reverts commit c704b6d3422db09cc321870feff5c4bc3e798ff3. --- .../src/test/resources/html/chap/ch01.html | 13 ++++++ .../src/test/resources/html/css/default.css | 38 ++++++++++++++++++ .../src/test/resources/html/etc/userfile.txt | 1 + .../src/test/resources/html/img/logo.png | Bin 0 -> 6715 bytes .../src/test/resources/html/index.html | 13 ++++++ 5 files changed, 65 insertions(+) create mode 100644 components/camel-ipfs/src/test/resources/html/chap/ch01.html create mode 100644 components/camel-ipfs/src/test/resources/html/css/default.css create mode 100644 components/camel-ipfs/src/test/resources/html/etc/userfile.txt create mode 100644 components/camel-ipfs/src/test/resources/html/img/logo.png create mode 100644 components/camel-ipfs/src/test/resources/html/index.html diff --git a/components/camel-ipfs/src/test/resources/html/chap/ch01.html b/components/camel-ipfs/src/test/resources/html/chap/ch01.html new file mode 100644 index 0000000000000..4edc3fd6b87d8 --- /dev/null +++ b/components/camel-ipfs/src/test/resources/html/chap/ch01.html @@ -0,0 +1,13 @@ + + + + IPFS + + + + +

Home

+

Chapter 01

+

logo

+ + diff --git a/components/camel-ipfs/src/test/resources/html/css/default.css b/components/camel-ipfs/src/test/resources/html/css/default.css new file mode 100644 index 0000000000000..8c0b2d558f3d0 --- /dev/null +++ b/components/camel-ipfs/src/test/resources/html/css/default.css @@ -0,0 +1,38 @@ +body { + font-family: "Verdana"; + color: #137cb9 +} + +a { + #text-decoration: none; + color: #137cb9 +} + +a.gray { + color: gray; +} + +h1 { + font-weight: normal; + font-size: 20px; +} + +h2 { + font-weight: normal; + font-size: 15px; +} + +th { + text-align: left; + font-weight: normal; + font-size: 14px; + color: gray; +} + +td.gray { + color: gray; +} +tr.gray { + color: gray; +} + diff --git a/components/camel-ipfs/src/test/resources/html/etc/userfile.txt b/components/camel-ipfs/src/test/resources/html/etc/userfile.txt new file mode 100644 index 0000000000000..8fe2a4b5ad117 --- /dev/null +++ b/components/camel-ipfs/src/test/resources/html/etc/userfile.txt @@ -0,0 +1 @@ +The quick brown fox jumps over the lazy dog. \ No newline at end of file diff --git a/components/camel-ipfs/src/test/resources/html/img/logo.png b/components/camel-ipfs/src/test/resources/html/img/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..ddda52e086e85692a94c2d014626bdf26f94e9c6 GIT binary patch literal 6715 zcmd5>_g53lwoT~LrG@|jLFt4lH3S5tC`Eb@siBC{lh8prNEJ~)se*z6(xsQsMY>e! zgf2Do&eQMSci(&e!JD;a&dixTd(WAl&N}n*k&ZeQIhY&(08nXasOtZ*ul{y2l0W0B z8m{J#0iyKPl>x>5Z0mm(H{3K#Q2+o1{of7*yiW)H0hl@(BG3qJEjgsCGt}DF)y59$ z?dHhu7416f98MPB3zvRK+w+>xDeWpI8|Id>^Sd2 zC845RaB@ygPMC+Sy_~+P+P{zgSt)QmMWfy1L`1y2yr5nZP*)EJ5iwa=SrJij5pi+h zKL}xzj|o`0~7fx{=Y8suSoy# z{s|RM4iov$v%$%=T6s+Y0Fa-i>ODhm;FdXs8~dmayxxz)*DQI7H}KUi2piVVp#PZQ z-m4((BnEMVT4&|Sm$yEJIjU$p1=~c$-bsrE((67~=B(*`Bgv`%^EH}0)?ibCPc z8}bMcS)kc#JB8xy#`Cq~jC%FQmNSKZB|^XSPp{wU)_WbNS2#59Z@sue9o_oW9tN~l z0@0HEe>HsFO0la2sbu&K3%We@hdKO z>Y|1XL`J>I(3*4+2*<2)z?Q2O{r3CnQ>7nMzlhP+CE?Lla&~ssF)?ATFUbDds4!$c z?q)E5HdjfHCy7!Y6@IdIPg18KU;Xr5Y&rc6qnVK+p{~6%uO0V>1#6cbiu9AStBBwA zFMMV&rtu?_#>JI-#Y{^FA9q8|3z5vUxb&*={_?sy4~x~G_08wMI5&zhbT93Ud-cBU zuhe$`s$ge(x`enlFW9cg-Ah`!(AGFR*mNm2xBoUp^E$y}j)ZC7nd6YH>?^HPw5YgV)^1 z(~c>stOl3$6(Gb}bfqLu?xI%s&}LF>6kPTP&uBF?k&ma;^dE}xfaTnjKAoRCOK0>? z=xmZE)1#F&>P>YHPVV%)B{KM-#3C&3d*O*T*}8aH9JX<7F}};Vd|HUadnYAn{g&a? zGg;;IY)J(5{{eJPD_-a0!?8jXwP*J$Va1bn--JW>#M~0G*B+&zmFn_xiSc{$kD0 z=u1JTT8VEz8>^TuwBK6VP{+$?`!sA>48Awa@?v*Bm~&=4U)||P8OJxmdelarbkh&q zV-!9y(@UV*ThnWkl7aD&WPgp#aGq?NH$grwa*~Fj^ z;;=JNnVoOC^z?KaRQ7-4VbgDKdFo}=?itmgzM(MGrrET|BJ+DCuRo$T#WS`{dd@90 zUih)}G$teM5aMoA)`J@z#h=}eX_%}<-5l?9VqX;s~%nH%W<47^!j&e;`m5caK?whmfx-dpTcXokG|YP@RI* zGSU2X+9hagiE>JIw%YTsJV>>lS>k{0b8uttCI!jo(uX?@tBa{p7LkdgT_>#OZ_S3M zH#xEQ(^0rZW0J|H9nvoY!eIK*B_^0=JE$0r{HYgWQ-*TDornf5QS?jdh z@+D{&R<^7mzMFOX=Ms>2phlC0;{s+Byl!m>^smkf9KRoc4M&fUO{U))vxg~fkH0+a zaiQvD+1kVg&0RK^km_))&%@JNZI@`KXG5hGUv#lIp4H~==792Z@@*_Bl;9JL+eCZ9 z5mc*yhDehKZyZ0alNtFMNZ2sVTJgtzR)6=52qD(nozZUjvD+j-;^wKdx4i{*>P<&C7EzmhdLut$Z zc}TP6LH{tD-RtDU`NyjM5XrwUxdW9i;m0yBv^N=Z(h z)a+Xem5_KJmX~S2_bpNc_L6pTr!Ko+-<$_vH3vBe&4Al6QbqjdQcl+fL0qC;9lvWj z%jvKd^EOt@*oJAHT$z5tCg2kSNy1ODHaV}ZSiH$jsH}cRjh0DqW!uS55|C*Si*@)J zXHvgPy3wUgRTz9cXOhak0;5s0s5pf6z1-~Nvxg{Rc3*)fs!iN8qmtR#TGRC&obw3Y zlrYJfHNnv|MvF-)-{MYm65TElc*9x#6}(Xq)Pb$V9%6NaH-Z$D3{_9QG=ft!vnTMi z&8d1tlH3qzGl3HkV#j|mkn0+8pvA!6LJ^J0{~QzjR8>jiqwwzh4k1Tw;dBRcVZm4? zX+_)bT{G9hf?sh3o-G97H&hH4Ks=Ovz#elPqV|SbjKs(@w;hYOvIMh(8Tv}^f&=?m ztV`{YWUmGuc87v+??me|vl2gokjEnwk0^&=x6>M=fGZzlJ&{=?nZ!__w_U|+o-9*w zk@}`_V6uE>8I<97p^|0lE4#f`Q{riQ7m1iHgbxPfEdsEfiHQp%8xh`JBhXz}2O zB(o^EUa)-=Bfvo|X1Yx)4Ev^Q$?3hH)s*PoB2ji);O}kwED4UU7Ocr4pdc9eMM`RL zlXWP|jg00|duUCE*z`=O9BzRo$oy+opYlY7krAo_3?GSercL%_%H@6B0`3;H9|~aC zIPe0LOn$D;1$`G}T~?ki0dzvzu>4s2c?rO984MbSKc>LG4Z3NMZq{^2=2095;f30L z^EHF)Xq0G9p4ys~8AWGenwY#rwHOpu-G>kw@Z|#f% zMaRUWsG?ALQL*xE$KIu^J<=KBnar?hx+AZ4`5N#tZaKJ)N*5g=&!vCXn;& z@e1E8_LJMecUq&4+sQg+vtO8bKlLg^SV8-IB?YU8=*#rkz}Ix5arHzSmCC0cejewY zQ?5VVyOAIf8Q${Hu21)mSF0GVdKMY!(JgEp#0=UlVMGb-h|i}7!$t+w>I<66GlMnX zJ~SGEbAE8D**LX>ULNG* z6`vr=g>$7oe?A|#R_4*>Le2^g;l9nS;mhX|?&d#kpyGG@96vZUSRvZkO-=O$QU2hr zkVOc#33!T{F@i3>!RN$eEh)0)us#eIOu`Txu;pzm@bym+BfgMM#Ca5im?LT}s5Bp% z*%8?IeBiy&dh(fC#n;oEflA$J(^y7+Qw;8VY|h>`;&DZWzj?pqBs`ZVujL7Sbj2V$ zWUS32I(&tiyFYk*VXe?}*54csVeiJ6Bpua6!AI~XZ6vw8qBBeh-BxdnA1F;*x`d{c zTPSBL0w)5XBr@sEB;N@n^KvJi3QZ}wem>A$CJ;gO zHfz6~qGIp4?xeZmEFQ-&DS>TzjHlJC-QkffejZFKX)@Y?#G(2)xPz_t z4@QZ&>++nX6e=$!Hxg_o&a?lBNdgsOZz^PtmhZVcb4xwIl8_G({gly-$BlOv<_7ql zfa2qWB-oV}l{@1I#3O@fd%4-W&wSs?EK(|La!fRu+0E;LO5E1^Op##AWid6e<#yme zm~}1bKxhgzs?9@-dF^J#OVk64qP&sCDoGRk+Kpvu=i;YQ5w*YNOZ(B&q~iruz)Iyf zJGBRDw6$+OU6%{_%8`eu9Crl^1Yu4T=DV=)pca^VSUO@!vQ1v;03np?bZa>awx=`5 z_p!8$MG2)bu=-y1z+oEMHT0D#f5F@huJO?QWLGE_CBu$Ag(wKQI*o7*=N4XA`Gpvz z$S&;})Kgk4UH#(2mO3ngb4d{qn7IitTu(?6*^nzuI52OOxXz84z_NP1%a=Ys$ zHb|x#rxJ)G2$EQ-4{9dfCee~zX()9p(k>3tI%RkrZ^lX8F6vFIoscK9usT0R8frJ| zGU#>eeoNMXjRoTv)g9ccEAoJMTI_+F!l9WsS#M;c>@j6kW z;(=5JAii|3PZB;1W6B}!nIq;)jsZm1vxs)WI0&{0iUGz1jX_@ojk_jC$oPEOqJsBT zfh(R9+Ik2{iS*T?yTnp$v2i^SE9Icb&GK2&EBcdLyE00->Nagm;!X|&HWn-?7CV3W*Z@UrvDMrNOXEYf<32Ex za5P(ch{O9rB**2^Gur`5Q|*YurPpy8G#<}2q^X$gS-h;lFKq-#c`j?hSGH^+A&25P z4XX^ux&;>0IHbIvJGfUv7DYPNws+wYji(hu)fMwacBZAOeYf;bWOd|8y-C0E!-osW zFnX~|DiR^)IZY(F^1a-;PRy!3^QB>I&IbqKXV(KnwlaLaO&o97^UjNw{Np0uv39pl zMCDfJ7(Y?U^W%SyIokpyCVa3tGs1h1en)2=Ksu&Q)+STY&Gf%|6PGe~kI5PnFYlA9 z>-P_@)xLlFd%c0WC9U=jyN}l8iAP;|i_dF`wjW|pi8649s$;yq3S`T1=y@@Z;R0R<-4H-8H*wouoc(x|FR5Clm~1F?nR=da-Z@AGql5lg zv1`9cH?N#cHQy*69SvDc!xk>cRWnwK#X~F!D0Yn_A|0}wrG6wHdllvx=<=uf)H!{u zIRyz>%C~Aifx!&jF)rtRb-%gcWhyDENO z_0NG^iyO=aJf826HUJ{y5&d>eiyY~=%$@fz0yfL01rcjR6)DsOdm$AKX zloW^6LL384$*%VLuViJ8^}c`C#n^VG#)y=c{2cX&w=B?7!O7i*vDQ#|1GB5Ur9D)F z?{}yq90-Sd&*1L63gE+dK+XicI!7;aUpxbu2lo^3HB&|e)- zJZ*PAc67Lrbwi>owh^^-4p?w|;d01jJTg5<4we!g*pgC~r z2itng!e~}NW=iALr^5~C2=3lx;>XvWcD{7#ZjFczEihD&pQF3$+r?r+T1{-mrZykJ zm{_yZ6;Cg`V$Mm>492Iz+`0^k2^83tIG!1Q{S7y_JJXwzVQZwF(**x)S&Hq-1znKa zud9ni`(_&)N(|mnpxsxIaWX=iKrB#I_;nVF86)z{RlgIuE_RWsYSd2(jyvO)y(Lj$ zV!R@(KkS19*v21obCf)BzrI|ZmnWZ74r+X@a$fLD+hQi-DeVt%G-;22>(Pj=2U0J2#wnP4$Q{EB7?O8f4a>qa(e$w20b$SV-UK`C+qa` z^1S*<1QaO@d83$>@MWw&YX|qC43~A9ksY*#*#)A=^1B`$AFT~cw3s!9sI!{5T6&!) z6{Q`?^dxsT-%CZDbD)a%h!`LdWqR`Cr|z!p4+J3-dns#bE*)$6#B=&f8!{H+sT2PooqcH6SWx5RfiaCo=7}O4AMHx z!4Ku{1gza2cXw@}y?)%=e7gW_e~O`C-fg3(EveaK;Y2LxAwY!he0V%fG-4vRFI!Yd zPkBi5smo7pZ-y4LqnoCGow6n~D!^aFWXO>4+|DkoGk(65^|k2aDmekCVo+GNL$emQ zn_K`n;)a*YyfA#El>bQSuA6-=C(FL}T5(;Y)Ah~RqFs)FH-{2)FTF0*9nK%Zc;cC- zc&=liA7A(i#ot#tqZ|yMD7k+{)w*}i(Lgsd`8aBgn}KRJ!|N6gX*Eb_Hharwk?PVB z)K7Rf!?P~%Glc#H5Z;-6{g8%7^z_+2b88@02mst-qXl z?_~JR1>l(&ub<63xV9XJ+Pk+)J@2Lyk&szCSO}%?_X>P^4L53z5~1fgP&6D$XsEML zY#J$pSD^73XB_<>Rztm)IQm&$=P!8tB(m)n24@vblrP&}?APACH&zc8VZg}`J7!tj zND7jIy|RdOD98KKxL9>?#2a-qUHbc-mzWw?vKdqf<#YV4vIazhK71=?xy-LmQQXCL z2}>j5kIGy0s zi<<+hesyyGD(cY(@pT3vco-4`|ijA05s6I;zFWRw4fdj6P18 literal 0 HcmV?d00001 diff --git a/components/camel-ipfs/src/test/resources/html/index.html b/components/camel-ipfs/src/test/resources/html/index.html new file mode 100644 index 0000000000000..3781300297051 --- /dev/null +++ b/components/camel-ipfs/src/test/resources/html/index.html @@ -0,0 +1,13 @@ + + + + IPFS + + + + +

Home

+

chapter one

+

logo

+ + From ea00eecddf26e1c1f6bb18475227496a5bb3794d Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Mon, 19 Nov 2018 13:53:17 +0100 Subject: [PATCH 051/125] Upgrade Qpid JMS client to version 0.38.0 --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index f45cb79484728..4f59cc2b144c7 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -570,7 +570,7 @@ 4.20.0 7.0.6 0.29.0 - 0.37.0 + 0.38.0 1.8.6_1 1.8.6 [1.8,2) From c90c8d34eec8ffdc028bf6ae8eb41335bf7bcba7 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Mon, 19 Nov 2018 13:53:39 +0100 Subject: [PATCH 052/125] Upgrade Proton J to version 0.30.0 --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index 4f59cc2b144c7..61174f3fb00c6 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -569,7 +569,7 @@ 1.8 4.20.0 7.0.6 - 0.29.0 + 0.30.0 0.38.0 1.8.6_1 1.8.6 From 303c9b857216ee25d01a3d9018c656b75b761557 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Tue, 20 Nov 2018 11:08:31 +0100 Subject: [PATCH 053/125] Upgrade Awaitility to version 3.1.3 --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index 61174f3fb00c6..ca1657ff4542b 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -80,7 +80,7 @@ 1.8.2 1.8.2_1 1.8.2_1 - 3.1.2 + 3.1.3 1.11.438_1 1.11.438 2.0.1 From 1ee596d7f85bd6dc4fd4f5e02aaac5dd3756e163 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Tue, 20 Nov 2018 14:38:30 +0100 Subject: [PATCH 054/125] CAMEL-12774 - Error during type conversion from type: java.lang.String to the required type: org.elasticsearch.action.update.UpdateRequest - Take 2 --- .../converter/ElasticsearchActionRequestConverter.java | 2 +- .../ElasticsearchGetSearchDeleteExistsUpdateTest.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java index 1347219e8cf11..6572c960b5172 100644 --- a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java +++ b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java @@ -61,7 +61,7 @@ private static UpdateRequest createUpdateRequest(Object document, Exchange excha } else if (document instanceof Map) { updateRequest.doc((Map) document); } else if (document instanceof String) { - updateRequest.doc(XContentFactory.xContent((String) document), (String) document); + updateRequest.doc((String) document, XContentFactory.xContentType((String) document)); } else if (document instanceof XContentBuilder) { updateRequest.doc((XContentBuilder) document); } else { diff --git a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java index 96e994fee9314..161e629c6c95a 100644 --- a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java +++ b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java @@ -49,6 +49,7 @@ public void testGet() throws Exception { GetResponse response = template.requestBody("direct:get", indexId, GetResponse.class); assertNotNull("response should not be null", response); assertNotNull("response source should not be null", response.getSource()); + System.err.println(response.getSource()); } @Test @@ -303,12 +304,15 @@ public void testStringUpdate() throws Exception { String indexId = template.requestBody("direct:index", map, String.class); assertNotNull("indexId should be set", indexId); - String body = "{\"id\" : 1}"; + String body = "{\"teststringupdate-key\" : \"teststringupdate-updated\"}"; Map headers = new HashMap<>(); headers.put(ElasticsearchConstants.PARAM_INDEX_ID, indexId); indexId = template.requestBodyAndHeaders("direct:update", body, headers, String.class); assertNotNull("indexId should be set", indexId); + + GetResponse response = template.requestBody("direct:get", indexId, GetResponse.class); + assertEquals("teststringupdate-updated", response.getSource().get("teststringupdate-key")); } @Override From e665dadbf866833fd9aa099a3c5b674dcd24988f Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Wed, 21 Nov 2018 08:45:05 +0100 Subject: [PATCH 055/125] Upgrade Infinispan to version 9.4.2.Final --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index ca1657ff4542b..c7e2e8b883c0a 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -313,7 +313,7 @@ 2.3.4.726 1.0.7 2.6.0 - 9.4.1.Final + 9.4.2.Final 2.1.0.Final 2.14 2.14_1 From bf2eb7b2418c1a2203ee4d625ae9b7a1cde5626b Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Wed, 21 Nov 2018 09:21:37 +0100 Subject: [PATCH 056/125] Add Camel-NSQ to apache-camel POM --- apache-camel/pom.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index be1d5431c77f6..625694ec431b9 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -760,6 +760,10 @@ org.apache.camel camel-netty4-http + + + org.apache.camel + camel-nsq org.apache.camel @@ -2062,6 +2066,11 @@ camel-netty-starter ${project.version} + + org.apache.camel + camel-nsq-starter + ${project.version} + org.apache.camel camel-ognl-starter From 613a0fd9220927b608a87c6d8c5f54d6113cec0e Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Wed, 21 Nov 2018 09:25:19 +0100 Subject: [PATCH 057/125] Added camel-ipfs to Apache-Camel POM --- apache-camel/pom.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index 625694ec431b9..af37d5ea136a9 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -490,6 +490,10 @@ org.apache.camel camel-influxdb + + org.apache.camel + camel-ipfs + org.apache.camel camel-irc @@ -1741,6 +1745,11 @@ camel-influxdb-starter ${project.version} + + org.apache.camel + camel-ipfs-starter + ${project.version} + org.apache.camel camel-irc-starter From 886995ae955644253d1a6b9205ec6e4158126e87 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Wed, 21 Nov 2018 10:03:18 +0100 Subject: [PATCH 058/125] Regen --- .../spring-boot-dm/camel-spring-boot-dependencies/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml index 0c7bb419ceea8..f0ef8f43e3e25 100644 --- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml +++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml @@ -3402,7 +3402,7 @@ org.awaitility awaitility - 3.1.2 + 3.1.3 org.cassandraunit From 9469254ade49887e663833b2ae9906e9f9b43524 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Wed, 21 Nov 2018 13:06:11 +0100 Subject: [PATCH 059/125] Upgrade AWS Xray to version 2.1.0 --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index c7e2e8b883c0a..94ee256118810 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -83,7 +83,7 @@ 3.1.3 1.11.438_1 1.11.438 - 2.0.1 + 2.1.0 1.2.14 8.0.0 8.0.0_1 From 5f4530c7077e9871f56b49a59ea8f11f2cdd03eb Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 21 Nov 2018 18:05:10 +0100 Subject: [PATCH 060/125] [CAMEL-12688] Fix generation and improve the generated code --- .../camel/tools/apt/ConverterProcessor.java | 161 ++++++++++++++---- 1 file changed, 127 insertions(+), 34 deletions(-) diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/ConverterProcessor.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/ConverterProcessor.java index ac372e1123676..1757f21e6d647 100644 --- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/ConverterProcessor.java +++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/ConverterProcessor.java @@ -21,9 +21,12 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.io.Writer; +import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; @@ -33,6 +36,8 @@ import javax.annotation.processing.SupportedAnnotationTypes; import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; @@ -50,20 +55,25 @@ public class ConverterProcessor extends AbstractProcessor { @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { try { - if (this.processingEnv.getElementUtils().getTypeElement("org.apache.camel.impl.converter.CoreFallbackConverter") != null) { + if (roundEnv.processingOver()) { return false; } - if (roundEnv.processingOver()) { + if (this.processingEnv.getElementUtils().getTypeElement("org.apache.camel.impl.converter.CoreStaticTypeConverterLoader") != null) { + return false; + } + + // We're in tests, do not generate anything + if (this.processingEnv.getElementUtils().getTypeElement("org.apache.camel.converter.ObjectConverter") == null) { return false; } Comparator comparator = (o1, o2) -> processingEnv.getTypeUtils().isAssignable(o1, o2) ? -1 : processingEnv.getTypeUtils().isAssignable(o2, o1) ? +1 : o1.toString().compareTo(o2.toString()); - Map> converters = new HashMap<>(); - TypeElement annotationType = this.processingEnv.getElementUtils().getTypeElement("org.apache.camel.Converter"); - for (Element element : roundEnv.getElementsAnnotatedWith(annotationType)) { + Map> converters = new TreeMap<>(); + TypeElement converterAnnotationType = this.processingEnv.getElementUtils().getTypeElement("org.apache.camel.Converter"); + for (Element element : roundEnv.getElementsAnnotatedWith(converterAnnotationType)) { if (element.getKind() == ElementKind.METHOD) { ExecutableElement ee = (ExecutableElement) element; TypeMirror to = ee.getReturnType(); @@ -81,57 +91,127 @@ public boolean process(Set annotations, RoundEnvironment converters.computeIfAbsent(toString(to), c -> new TreeMap<>(comparator)).put(from, ee); } } - - // We're in tests, do not generate anything - if (this.processingEnv.getElementUtils().getTypeElement("org.apache.camel.converter.ObjectConverter") == null) { - return false; + TypeElement fallbackAnnotationType = this.processingEnv.getElementUtils().getTypeElement("org.apache.camel.FallbackConverter"); + List fallbackConverters = new ArrayList<>(); + for (Element element : roundEnv.getElementsAnnotatedWith(fallbackAnnotationType)) { + if (element.getKind() == ElementKind.METHOD) { + ExecutableElement ee = (ExecutableElement) element; + fallbackConverters.add(ee); + } } String p = "org.apache.camel.impl.converter"; - String c = "CoreFallbackConverter"; + String c = "CoreStaticTypeConverterLoader"; JavaFileObject jfo = processingEnv.getFiler().createSourceFile(p + "." + c); Set converterClasses = new LinkedHashSet<>(); try (Writer writer = jfo.openWriter()) { writer.append("package ").append(p).append(";\n"); writer.append("\n"); - writer.append("import org.apache.camel.support.TypeConverterSupport;\n"); writer.append("import org.apache.camel.Exchange;\n"); writer.append("import org.apache.camel.TypeConversionException;\n"); + writer.append("import org.apache.camel.TypeConverterLoaderException;\n"); + writer.append("import org.apache.camel.spi.TypeConverterLoader;\n"); + writer.append("import org.apache.camel.spi.TypeConverterRegistry;\n"); + writer.append("import org.apache.camel.support.TypeConverterSupport;\n"); writer.append("\n"); writer.append("@SuppressWarnings(\"unchecked\")\n"); - writer.append("public class ").append(c).append(" extends TypeConverterSupport {\n"); + writer.append("public class ").append(c).append(" implements TypeConverterLoader {\n"); + writer.append("\n"); + writer.append(" static abstract class SimpleTypeConverter extends TypeConverterSupport {\n"); + writer.append(" private final boolean allowNull;\n"); writer.append("\n"); - writer.append(" public T convertTo(Class type, Exchange exchange, Object value) throws TypeConversionException {\n"); - writer.append(" try {\n"); - writer.append(" return (T) doConvert(type, exchange, value);\n"); - writer.append(" } catch (TypeConversionException e) {\n"); - writer.append(" throw e;\n"); - writer.append(" } catch (Exception e) {\n"); - writer.append(" throw new TypeConversionException(value, type, e);\n"); + writer.append(" public SimpleTypeConverter(boolean allowNull) {\n"); + writer.append(" this.allowNull = allowNull;\n"); writer.append(" }\n"); - writer.append(" }\n"); writer.append("\n"); - writer.append(" private Object doConvert(Class type, Exchange exchange, Object value) throws Exception {\n"); - writer.append(" switch (type.getName()) {\n"); + writer.append(" @Override\n"); + writer.append(" public boolean allowNull() {\n"); + writer.append(" return allowNull;\n"); + writer.append(" }\n"); + writer.append("\n"); + writer.append(" @Override\n"); + writer.append(" public T convertTo(Class type, Exchange exchange, Object value) throws TypeConversionException {\n"); + writer.append(" try {\n"); + writer.append(" return (T) doConvert(exchange, value);\n"); + writer.append(" } catch (TypeConversionException e) {\n"); + writer.append(" throw e;\n"); + writer.append(" } catch (Exception e) {\n"); + writer.append(" throw new TypeConversionException(value, type, e);\n"); + writer.append(" }\n"); + writer.append(" }\n"); + writer.append(" protected abstract Object doConvert(Exchange exchange, Object value) throws Exception;\n"); + writer.append(" };\n"); + writer.append("\n"); + writer.append(" @Override\n"); + writer.append(" public void load(TypeConverterRegistry registry) throws TypeConverterLoaderException {\n"); + for (Map.Entry> to : converters.entrySet()) { - writer.append(" case \"").append(to.getKey()).append("\": {\n"); for (Map.Entry from : to.getValue().entrySet()) { - String name = toString(from.getKey()); - if ("java.lang.Object".equals(name)) { - writer.append(" if (value != null) {\n"); - } else { - writer.append(" if (value instanceof ").append(name).append(") {\n"); + boolean allowNull = false; + for (AnnotationMirror ann : from.getValue().getAnnotationMirrors()) { + if (ann.getAnnotationType().asElement() == converterAnnotationType) { + for (Map.Entry entry : ann.getElementValues().entrySet()) { + switch (entry.getKey().getSimpleName().toString()) { + case "allowNull": + allowNull = (Boolean) entry.getValue().getValue(); + break; + default: + throw new IllegalStateException(); + } + } + } + } + writer.append(" registry.addTypeConverter(").append(to.getKey()).append(".class").append(", ") + .append(toString(from.getKey())).append(".class, new SimpleTypeConverter(") + .append(Boolean.toString(allowNull)).append(") {\n"); + writer.append(" @Override\n"); + writer.append(" public Object doConvert(Exchange exchange, Object value) throws Exception {\n"); + writer.append(" return ").append(toJava(from.getValue(), converterClasses)).append(";\n"); + writer.append(" }\n"); + writer.append(" });\n"); + } + } + + for (ExecutableElement ee : fallbackConverters) { + boolean allowNull = false; + boolean canPromote = false; + for (AnnotationMirror ann : ee.getAnnotationMirrors()) { + if (ann.getAnnotationType().asElement() == fallbackAnnotationType) { + for (Map.Entry entry : ann.getElementValues().entrySet()) { + switch (entry.getKey().getSimpleName().toString()) { + case "allowNull": + allowNull = (Boolean) entry.getValue().getValue(); + break; + case "canPromote": + canPromote = (Boolean) entry.getValue().getValue(); + break; + default: + throw new IllegalStateException(); + } + } } - writer.append(" return ").append(toJava(from.getValue(), converterClasses)).append(";\n"); - writer.append(" }\n"); } - writer.append(" break;\n"); + writer.append(" registry.addFallbackTypeConverter(new TypeConverterSupport() {\n"); + writer.append(" @Override\n"); + writer.append(" public boolean allowNull() {\n"); + writer.append(" return ").append(Boolean.toString(allowNull)).append(";\n"); writer.append(" }\n"); + writer.append(" @Override\n"); + writer.append(" public T convertTo(Class type, Exchange exchange, Object value) throws TypeConversionException {\n"); + writer.append(" try {\n"); + writer.append(" return (T) ").append(toJavaFallback(ee, converterClasses)).append(";\n"); + writer.append(" } catch (TypeConversionException e) {\n"); + writer.append(" throw e;\n"); + writer.append(" } catch (Exception e) {\n"); + writer.append(" throw new TypeConversionException(value, type, e);\n"); + writer.append(" }\n"); + writer.append(" }\n"); + writer.append(" }, ").append(Boolean.toString(canPromote)).append(");\n"); } - writer.append(" }\n"); - writer.append(" return null;\n"); + writer.append("\n"); writer.append(" }\n"); + writer.append("\n"); for (String f : converterClasses) { String s = f.substring(f.lastIndexOf('.') + 1); @@ -154,7 +234,7 @@ public boolean process(Set annotations, RoundEnvironment } } catch (Throwable e) { - processingEnv.getMessager().printMessage(Kind.ERROR, "Unable to process elements annotated with @UriEndpoint: " + e.getMessage()); + processingEnv.getMessager().printMessage(Kind.ERROR, "Unable to process elements annotated with @Converter: " + e.getMessage()); dumpExceptionToErrorFile("camel-apt-error.log", "Error processing @Converter", e); } return false; @@ -177,6 +257,19 @@ private String toJava(ExecutableElement converter, Set converterClasses) return pfx + "(" + cast + "value" + (converter.getParameters().size() == 2 ? ", exchange" : "") + ")"; } + private String toJavaFallback(ExecutableElement converter, Set converterClasses) { + String pfx; + if (converter.getModifiers().contains(Modifier.STATIC)) { + pfx = converter.getEnclosingElement().toString() + "." + converter.getSimpleName(); + } else { + converterClasses.add(converter.getEnclosingElement().toString()); + pfx = "get" + converter.getEnclosingElement().getSimpleName() + "()." + converter.getSimpleName(); + } + String type = toString(converter.getParameters().get(converter.getParameters().size() - 2).asType()); + String cast = type.equals("java.lang.Object") ? "" : "(" + type + ") "; + return pfx + "(type, " + (converter.getParameters().size() == 4 ? "exchange, " : "") + cast + "value" + ", registry)"; + } + public static void dumpExceptionToErrorFile(String fileName, String message, Throwable e) { File file = new File(fileName); try { From e3cd3dc96a6e84393aade79a1c597db6b6a56639 Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Mon, 19 Nov 2018 19:22:27 +0300 Subject: [PATCH 061/125] CAMEL-12943: Rest DSL generates invalid swagger operation Id --- .../camel/model/RouteDefinitionHelper.java | 29 ++++++++++- .../camel/model/rest/RestDefinition.java | 10 +++- .../camel/impl/RouteIdRestDefinitionTest.java | 52 +++++++++++++++++++ ...waggerReaderEnableVendorExtensionTest.java | 2 +- 4 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 camel-core/src/test/java/org/apache/camel/impl/RouteIdRestDefinitionTest.java diff --git a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java b/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java index b0059553bae64..83e79f34748b5 100644 --- a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java +++ b/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java @@ -142,6 +142,19 @@ public void run() { }); } customIds.add(id); + } else { + RestDefinition rest = route.getRestDefinition(); + if (rest != null && route.isRest()) { + VerbDefinition verb = findVerbDefinition(rest, route.getInputs().get(0).getUri()); + if (verb != null) { + String id = verb.getId(); + if (verb.hasCustomIdAssigned() && ObjectHelper.isNotEmpty(id) && !customIds.contains(id)) { + route.setId(id); + customIds.add(id); + break; + } + } + } } } @@ -169,7 +182,8 @@ public void run() { } RestDefinition rest = route.getRestDefinition(); if (rest != null && route.isRest()) { - for (VerbDefinition verb : rest.getVerbs()) { + VerbDefinition verb = findVerbDefinition(rest, route.getInputs().get(0).getUri()); + if (verb != null) { String id = verb.idOrCreate(context.getNodeIdFactory()); if (!verb.getUsedForGeneratingNodeId()) { id = route.getId(); @@ -195,6 +209,19 @@ public void run() { } } } + + /** + * Find verb associated with the route by mapping uri + */ + private static VerbDefinition findVerbDefinition(RestDefinition rest, String endpointUri) { + for (VerbDefinition verb : rest.getVerbs()) { + String verbUri = rest.buildFromUri(verb); + if (endpointUri.startsWith(verbUri)) { + return verb; + } + } + return null; + } /** * Validates that the target route has no duplicate id's from any of the existing routes. diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java index 5fcce056d7b0a..3e09b9a14060b 100644 --- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java @@ -658,6 +658,13 @@ public RouteDefinition route() { verb.setRoute(route); return route; } + + /** + * Build the from endpoint uri for the verb + */ + public String buildFromUri(VerbDefinition verb) { + return "rest:" + verb.asVerb() + ":" + buildUri(verb); + } // Implementation //------------------------------------------------------------------------- @@ -799,6 +806,7 @@ public static RouteDefinition asRouteApiDefinition(CamelContext camelContext, Re return answer; } + @SuppressWarnings("rawtypes") private void addRouteDefinition(CamelContext camelContext, List answer, String component) { for (VerbDefinition verb : getVerbs()) { // either the verb has a singular to or a embedded route @@ -877,7 +885,7 @@ private void addRouteDefinition(CamelContext camelContext, List route.setRestBindingDefinition(binding); // create the from endpoint uri which is using the rest component - String from = "rest:" + verb.asVerb() + ":" + buildUri(verb); + String from = buildFromUri(verb); // append options Map options = new HashMap<>(); diff --git a/camel-core/src/test/java/org/apache/camel/impl/RouteIdRestDefinitionTest.java b/camel-core/src/test/java/org/apache/camel/impl/RouteIdRestDefinitionTest.java new file mode 100644 index 0000000000000..30b132765d998 --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/impl/RouteIdRestDefinitionTest.java @@ -0,0 +1,52 @@ +/** + * 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.camel.impl; + +import org.apache.camel.ContextTestSupport; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.rest.DummyRestConsumerFactory; +import org.apache.camel.component.rest.DummyRestProcessorFactory; +import org.junit.Test; + +public class RouteIdRestDefinitionTest extends ContextTestSupport { + + @Override + protected JndiRegistry createRegistry() throws Exception { + JndiRegistry jndi = super.createRegistry(); + jndi.bind("dummy-rest", new DummyRestConsumerFactory()); + jndi.bind("dummy-rest-api", new DummyRestProcessorFactory()); + return jndi; + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start1?timeout=30000").to("mock:result"); + from("direct:start2").to("mock:result"); + rest("/say/hello").get("/bar").id("getSayHelloBar").to("mock:result"); + } + }; + } + + @Test + public void testSayHelloBar() { + assertEquals("getSayHelloBar", context.getRouteDefinitions().get(2).getId()); + } + +} \ No newline at end of file diff --git a/components/camel-swagger-java/src/test/java/org/apache/camel/swagger/RestSwaggerReaderEnableVendorExtensionTest.java b/components/camel-swagger-java/src/test/java/org/apache/camel/swagger/RestSwaggerReaderEnableVendorExtensionTest.java index ac838059e34b2..a7b2d45e6e3b9 100644 --- a/components/camel-swagger-java/src/test/java/org/apache/camel/swagger/RestSwaggerReaderEnableVendorExtensionTest.java +++ b/components/camel-swagger-java/src/test/java/org/apache/camel/swagger/RestSwaggerReaderEnableVendorExtensionTest.java @@ -58,7 +58,7 @@ public void configure() throws Exception { .param().name("body").type(RestParamType.body).description("The user to update or create").endParam() .to("bean:userService?method=updateUser") - .get("/findAll").description("Find all users").outTypeList(User.class) + .get("/findAll").description("Find all users").outType(User[].class) .responseMessage().message("All the found users").endResponseMessage() .to("bean:userService?method=listUsers"); } From 9c672800c515ba9620e8b3b922205fdc4c0c7faa Mon Sep 17 00:00:00 2001 From: Erhun Baycelik Date: Thu, 22 Nov 2018 09:54:02 +0200 Subject: [PATCH 062/125] Fix typo. --- examples/camel-example-kafka/README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/camel-example-kafka/README.adoc b/examples/camel-example-kafka/README.adoc index d1f35cb4dad93..f439cde6c9c54 100644 --- a/examples/camel-example-kafka/README.adoc +++ b/examples/camel-example-kafka/README.adoc @@ -2,7 +2,7 @@ === Introduction -An example which shows how to integrate Camel with Kakfa. +An example which shows how to integrate Camel with Kafka. This project consists of the following examples: From 44597ebb1010cf1b33e865f690523bf9c445e12e Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Thu, 22 Nov 2018 09:11:45 +0100 Subject: [PATCH 063/125] Avoid constants in interfaces --- .../bigquery/GoogleBigQueryConstants.java | 17 ++++++++++----- .../internal/GoogleCalendarConstants.java | 13 +++++++++--- .../stream/GoogleCalendarStreamConstants.java | 21 ++++++++++++------- .../drive/internal/GoogleDriveConstants.java | 13 +++++++++--- .../mail/internal/GoogleMailConstants.java | 13 +++++++++--- .../stream/GoogleMailStreamConstants.java | 21 ++++++++++++------- 6 files changed, 70 insertions(+), 28 deletions(-) diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConstants.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConstants.java index 89d0eebac9238..cfd3c574df65d 100644 --- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConstants.java +++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConstants.java @@ -16,9 +16,16 @@ */ package org.apache.camel.component.google.bigquery; -public interface GoogleBigQueryConstants { - String TABLE_SUFFIX = "CamelGoogleBigQueryTableSuffix"; - String TABLE_ID = "CamelGoogleBigQueryTableId"; - String INSERT_ID = "CamelGoogleBigQueryInsertId"; - String PARTITION_DECORATOR = "CamelGoogleBigQueryPartitionDecorator"; +public final class GoogleBigQueryConstants { + public static final String TABLE_SUFFIX = "CamelGoogleBigQueryTableSuffix"; + public static final String TABLE_ID = "CamelGoogleBigQueryTableId"; + public static final String INSERT_ID = "CamelGoogleBigQueryInsertId"; + public static final String PARTITION_DECORATOR = "CamelGoogleBigQueryPartitionDecorator"; + + /** + * Prevent instantiation. + */ + private GoogleBigQueryConstants() { + super(); + } } diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/internal/GoogleCalendarConstants.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/internal/GoogleCalendarConstants.java index b604ad036c72f..f25f84c59d934 100644 --- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/internal/GoogleCalendarConstants.java +++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/internal/GoogleCalendarConstants.java @@ -19,11 +19,18 @@ /** * Constants for GoogleCalendar component. */ -public interface GoogleCalendarConstants { +public final class GoogleCalendarConstants { // suffix for parameters when passed as exchange header properties - String PROPERTY_PREFIX = "CamelGoogleCalendar."; + public static final String PROPERTY_PREFIX = "CamelGoogleCalendar."; // thread profile name for this component - String THREAD_PROFILE_NAME = "CamelGoogleCalendar"; + public static final String THREAD_PROFILE_NAME = "CamelGoogleCalendar"; + + /** + * Prevent instantiation. + */ + private GoogleCalendarConstants() { + super(); + } } diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConstants.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConstants.java index c671c544471d5..e590b743d6bd1 100644 --- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConstants.java +++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConstants.java @@ -19,12 +19,19 @@ /** * Constants used in Camel Google Calendar Stream */ -public interface GoogleCalendarStreamConstants { +public final class GoogleCalendarStreamConstants { - String MAIL_TO = "CamelGoogleMailStreamTo"; - String MAIL_FROM = "CamelGoogleMailStreamFrom"; - String MAIL_CC = "CamelGoogleMailStreamCc"; - String MAIL_BCC = "CamelGoogleMailStreamBcc"; - String MAIL_SUBJECT = "CamelGoogleMailStreamSubject"; - String MAIL_ID = "CamelGoogleMailId"; + public static final String MAIL_TO = "CamelGoogleMailStreamTo"; + public static final String MAIL_FROM = "CamelGoogleMailStreamFrom"; + public static final String MAIL_CC = "CamelGoogleMailStreamCc"; + public static final String MAIL_BCC = "CamelGoogleMailStreamBcc"; + public static final String MAIL_SUBJECT = "CamelGoogleMailStreamSubject"; + public static final String MAIL_ID = "CamelGoogleMailId"; + + /** + * Prevent instantiation. + */ + private GoogleCalendarStreamConstants() { + super(); + } } diff --git a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/internal/GoogleDriveConstants.java b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/internal/GoogleDriveConstants.java index 9f824f539c303..d19ba20c9abc6 100644 --- a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/internal/GoogleDriveConstants.java +++ b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/internal/GoogleDriveConstants.java @@ -19,11 +19,18 @@ /** * Constants for GoogleDrive component. */ -public interface GoogleDriveConstants { +public final class GoogleDriveConstants { // suffix for parameters when passed as exchange header properties - String PROPERTY_PREFIX = "CamelGoogleDrive."; + public static final String PROPERTY_PREFIX = "CamelGoogleDrive."; // thread profile name for this component - String THREAD_PROFILE_NAME = "CamelGoogleDrive"; + public static final String THREAD_PROFILE_NAME = "CamelGoogleDrive"; + + /** + * Prevent instantiation. + */ + private GoogleDriveConstants() { + super(); + } } diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/internal/GoogleMailConstants.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/internal/GoogleMailConstants.java index f788ff3c6e06f..a834549589370 100644 --- a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/internal/GoogleMailConstants.java +++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/internal/GoogleMailConstants.java @@ -19,11 +19,18 @@ /** * Constants for GoogleMail component. */ -public interface GoogleMailConstants { +public final class GoogleMailConstants { // suffix for parameters when passed as exchange header properties - String PROPERTY_PREFIX = "CamelGoogleMail."; + public static final String PROPERTY_PREFIX = "CamelGoogleMail."; // thread profile name for this component - String THREAD_PROFILE_NAME = "CamelGoogleMail"; + public static final String THREAD_PROFILE_NAME = "CamelGoogleMail"; + + /** + * Prevent instantiation. + */ + private GoogleMailConstants() { + super(); + } } diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/stream/GoogleMailStreamConstants.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/stream/GoogleMailStreamConstants.java index ccd2c0fb6f181..e8ca7c2d224b3 100644 --- a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/stream/GoogleMailStreamConstants.java +++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/stream/GoogleMailStreamConstants.java @@ -19,12 +19,19 @@ /** * Constants used in Camel Google Mail Stream */ -public interface GoogleMailStreamConstants { +public final class GoogleMailStreamConstants { - String MAIL_TO = "CamelGoogleMailStreamTo"; - String MAIL_FROM = "CamelGoogleMailStreamFrom"; - String MAIL_CC = "CamelGoogleMailStreamCc"; - String MAIL_BCC = "CamelGoogleMailStreamBcc"; - String MAIL_SUBJECT = "CamelGoogleMailStreamSubject"; - String MAIL_ID = "CamelGoogleMailId"; + public static final String MAIL_TO = "CamelGoogleMailStreamTo"; + public static final String MAIL_FROM = "CamelGoogleMailStreamFrom"; + public static final String MAIL_CC = "CamelGoogleMailStreamCc"; + public static final String MAIL_BCC = "CamelGoogleMailStreamBcc"; + public static final String MAIL_SUBJECT = "CamelGoogleMailStreamSubject"; + public static final String MAIL_ID = "CamelGoogleMailId"; + + /** + * Prevent instantiation. + */ + private GoogleMailStreamConstants() { + super(); + } } From 81b4776ac788a82e2ebfb06d3dbb1ecdd9f65f82 Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Thu, 22 Nov 2018 09:13:18 +0100 Subject: [PATCH 064/125] Remove gmail related naming from calendar component --- .../google-calendar-stream-component.adoc | 18 ++++++++-------- .../stream/GoogleCalendarStreamComponent.java | 9 ++++---- .../GoogleCalendarStreamConfiguration.java | 21 +++++++++---------- .../stream/GoogleCalendarStreamConstants.java | 7 +------ .../stream/GoogleCalendarStreamEndpoint.java | 21 +++++++------------ ...stractGoogleCalendarStreamTestSupport.java | 6 +++--- ...eCalendarStreamComponentConfiguration.java | 10 ++++----- 7 files changed, 40 insertions(+), 52 deletions(-) diff --git a/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc b/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc index 93090f493b722..624e34240746f 100644 --- a/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc +++ b/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc @@ -12,7 +12,7 @@ Google Calendar uses the https://developers.google.com/accounts/docs/OAuth2[OAuth 2.0 protocol] for authenticating a Google account and authorizing access to user data. Before you can use this component, you will need -to https://developers.google.com/gmail/api/auth/web-server[create an +to https://developers.google.com/calendar/auth[create an account and generate OAuth credentials]. Credentials comprise of a clientId, clientSecret, and a refreshToken. A handy resource for generating a long-lived refreshToken is @@ -27,7 +27,7 @@ for this component: camel-google-calendar 2.23.0 - + ------------------------------------------------------ ### URI Format @@ -36,10 +36,10 @@ The Google Calendar Component uses the following URI format: -------------------------------------------------------- google-calendar-stream://index?[options] - + -------------------------------------------------------- -### GoogleMailStreamComponent +### GoogleCalendarStreamComponent // component options: START @@ -88,14 +88,14 @@ with the following path and query parameters: | *applicationName* (consumer) | Google Calendar application name. Example would be camel-google-calendar/1.0 | | String | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | *calendarId* (consumer) | The calendarId to be used | primary | String -| *clientId* (consumer) | Client ID of the mail application | | String -| *clientSecret* (consumer) | Client secret of the mail application | | String +| *clientId* (consumer) | Client ID of the calendar application | | String +| *clientSecret* (consumer) | Client secret of the calendar application | | String | *considerLastUpdate* (consumer) | Take into account the lastUpdate of the last event polled as start date for the next poll | false | boolean | *consumeFromNow* (consumer) | Consume events in the selected calendar from now on | true | boolean | *maxResults* (consumer) | Max results to be returned | 10 | int | *query* (consumer) | The query to execute on calendar | | String | *refreshToken* (consumer) | OAuth 2 refresh token. Using this, the Google Calendar component can obtain a new accessToken whenever the current one expires - a necessity if the application is long-lived. | | String -| *scopes* (consumer) | Specifies the level of permissions you want a mail application to have to a user account. See https://developers.google.com/calendar/api/auth/scopes for more info. | | List +| *scopes* (consumer) | Specifies the level of permissions you want a calendar application to have to a user account. See https://developers.google.com/calendar/auth for more info. | | List | *sendEmptyMessageWhenIdle* (consumer) | If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. | false | boolean | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern @@ -148,7 +148,7 @@ The component supports 15 options, which are listed below. ### Consumer -The consumer will poll by default with maxResults equals to 10. +The consumer will poll by default with maxResults equals to 5. For example @@ -157,6 +157,6 @@ For example from("google-calendar-stream://test?markAsRead=true&delay=5000&maxResults=5").to("mock:result"); --------------------------------------------------------- -This route will consume the next ten events starting from the date of polling. +This route will consume the next five events starting from the date of polling.    diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamComponent.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamComponent.java index 150e432fb36ca..4c55eef6f222c 100644 --- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamComponent.java +++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamComponent.java @@ -19,7 +19,6 @@ import java.util.Map; import com.google.api.services.calendar.Calendar; - import org.apache.camel.CamelContext; import org.apache.camel.Endpoint; import org.apache.camel.component.google.calendar.BatchGoogleCalendarClientFactory; @@ -49,11 +48,11 @@ public GoogleCalendarStreamComponent(CamelContext context) { this.configuration = new GoogleCalendarStreamConfiguration(); } - public Calendar getClient(GoogleCalendarStreamConfiguration googleMailConfiguration) { + public Calendar getClient(GoogleCalendarStreamConfiguration endpointConfiguration) { if (client == null) { - client = getClientFactory().makeClient(googleMailConfiguration.getClientId(), googleMailConfiguration.getClientSecret(), configuration.getScopes(), - googleMailConfiguration.getApplicationName(), googleMailConfiguration.getRefreshToken(), - googleMailConfiguration.getAccessToken(), null, null, "me"); + client = getClientFactory().makeClient(endpointConfiguration.getClientId(), endpointConfiguration.getClientSecret(), endpointConfiguration.getScopes(), + endpointConfiguration.getApplicationName(), endpointConfiguration.getRefreshToken(), + endpointConfiguration.getAccessToken(), null, null, "me"); } return client; } diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConfiguration.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConfiguration.java index 8b5648d56df89..4fbc43ecd3705 100644 --- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConfiguration.java +++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConfiguration.java @@ -16,11 +16,10 @@ */ package org.apache.camel.component.google.calendar.stream; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import com.google.api.services.calendar.CalendarScopes; - import org.apache.camel.RuntimeCamelException; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -31,7 +30,7 @@ */ @UriParams public class GoogleCalendarStreamConfiguration implements Cloneable { - private static final List DEFAULT_SCOPES = Arrays.asList(CalendarScopes.CALENDAR); + private static final List DEFAULT_SCOPES = Collections.singletonList(CalendarScopes.CALENDAR); @UriPath private String index; @@ -59,13 +58,13 @@ public class GoogleCalendarStreamConfiguration implements Cloneable { @UriParam(defaultValue = "10") private int maxResults = 10; - + @UriParam(defaultValue = "primary") private String calendarId = "primary"; - + @UriParam(defaultValue = "true") private boolean consumeFromNow = true; - + @UriParam(defaultValue = "false") private boolean considerLastUpdate; @@ -74,7 +73,7 @@ public String getClientId() { } /** - * Client ID of the mail application + * Client ID of the calendar application */ public void setClientId(String clientId) { this.clientId = clientId; @@ -85,7 +84,7 @@ public String getClientSecret() { } /** - * Client secret of the mail application + * Client secret of the calendar application */ public void setClientSecret(String clientSecret) { this.clientSecret = clientSecret; @@ -132,8 +131,8 @@ public List getScopes() { } /** - * Specifies the level of permissions you want a mail application to have to - * a user account. See https://developers.google.com/calendar/api/auth/scopes + * Specifies the level of permissions you want a calendar application to have to + * a user account. See https://developers.google.com/calendar/auth * for more info. */ public void setScopes(List scopes) { @@ -187,7 +186,7 @@ public void setCalendarId(String calendarId) { public boolean isConsumeFromNow() { return consumeFromNow; } - + /** * Consume events in the selected calendar from now on */ diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConstants.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConstants.java index e590b743d6bd1..6f61d54a9d499 100644 --- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConstants.java +++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConstants.java @@ -21,12 +21,7 @@ */ public final class GoogleCalendarStreamConstants { - public static final String MAIL_TO = "CamelGoogleMailStreamTo"; - public static final String MAIL_FROM = "CamelGoogleMailStreamFrom"; - public static final String MAIL_CC = "CamelGoogleMailStreamCc"; - public static final String MAIL_BCC = "CamelGoogleMailStreamBcc"; - public static final String MAIL_SUBJECT = "CamelGoogleMailStreamSubject"; - public static final String MAIL_ID = "CamelGoogleMailId"; + public static final String EVENT_ID = "CamelGoogleCalendarEventId"; /** * Prevent instantiation. diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamEndpoint.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamEndpoint.java index eab297bd02f1b..a2d55bfb40c1f 100644 --- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamEndpoint.java +++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamEndpoint.java @@ -16,12 +16,8 @@ */ package org.apache.camel.component.google.calendar.stream; -import java.io.UnsupportedEncodingException; - import com.google.api.services.calendar.Calendar; -import com.google.api.services.calendar.model.CalendarListEntry; import com.google.api.services.calendar.model.Event; - import org.apache.camel.Consumer; import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; @@ -32,22 +28,21 @@ import org.apache.camel.impl.ScheduledPollEndpoint; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; -import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * The google-calendar component provides access to Google Calendar in a streaming mod. */ -@UriEndpoint(firstVersion = "2.23.0", - scheme = "google-calendar-stream", - title = "Google Calendar Stream", - syntax = "google-calendar-stream:index", +@UriEndpoint(firstVersion = "2.23.0", + scheme = "google-calendar-stream", + title = "Google Calendar Stream", + syntax = "google-calendar-stream:index", consumerClass = GoogleCalendarStreamConsumer.class, consumerOnly = true, label = "api,cloud") public class GoogleCalendarStreamEndpoint extends ScheduledPollEndpoint { - + private static final Logger LOG = LoggerFactory.getLogger(GoogleCalendarStreamEndpoint.class); @UriParam @@ -91,11 +86,11 @@ public boolean isSingleton() { return true; } - public Exchange createExchange(ExchangePattern pattern, Event event) throws UnsupportedEncodingException { - - Exchange exchange = super.createExchange(); + public Exchange createExchange(ExchangePattern pattern, Event event) { + Exchange exchange = super.createExchange(pattern); Message message = exchange.getIn(); message.setBody(event); + message.setHeader(GoogleCalendarStreamConstants.EVENT_ID, event.getId()); return exchange; } } diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java index 6cf4a25af4255..56e24fbf2af30 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java @@ -26,7 +26,7 @@ import org.apache.camel.util.IntrospectionSupport; /** - * Abstract base class for GoogleMail Integration tests generated by Camel API + * Abstract base class for GoogleCalendar Integration tests generated by Camel API * component maven plugin. */ public class AbstractGoogleCalendarStreamTestSupport extends CamelTestSupport { @@ -40,7 +40,7 @@ protected CamelContext createCamelContext() throws Exception { final CamelContext context = super.createCamelContext(); - // read GoogleMail component configuration from TEST_OPTIONS_PROPERTIES + // read GoogleCalendar component configuration from TEST_OPTIONS_PROPERTIES final Properties properties = new Properties(); try { properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES)); @@ -56,7 +56,7 @@ protected CamelContext createCamelContext() throws Exception { final GoogleCalendarStreamConfiguration configuration = new GoogleCalendarStreamConfiguration(); IntrospectionSupport.setProperties(configuration, options); - // add GoogleMailComponent to Camel context + // add GoogleCalendarComponent to Camel context final GoogleCalendarStreamComponent component = new GoogleCalendarStreamComponent(context); component.setConfiguration(configuration); context.addComponent("google-calendar-stream", component); diff --git a/platforms/spring-boot/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConfiguration.java index 5acded1012a5d..d8efcb8cf9c56 100644 --- a/platforms/spring-boot/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConfiguration.java @@ -24,7 +24,7 @@ /** * The google-calendar component provides access to Google Calendar in a * streaming mod. - * + * * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @@ -84,11 +84,11 @@ public void setResolvePropertyPlaceholders( public static class GoogleCalendarStreamConfigurationNestedConfiguration { public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.google.calendar.stream.GoogleCalendarStreamConfiguration.class; /** - * Client ID of the mail application + * Client ID of the calendar application */ private String clientId; /** - * Client secret of the mail application + * Client secret of the calendar application */ private String clientSecret; /** @@ -108,9 +108,9 @@ public static class GoogleCalendarStreamConfigurationNestedConfiguration { */ private String applicationName; /** - * Specifies the level of permissions you want a mail application to + * Specifies the level of permissions you want a calendar application to * have to a user account. See - * https://developers.google.com/calendar/api/auth/scopes for more info. + * https://developers.google.com/calendar/auth for more info. */ private List scopes; /** From 9353638da4d95aaf37deaee097bd9e8b92191ba1 Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Thu, 22 Nov 2018 09:14:12 +0100 Subject: [PATCH 065/125] Remove unused oauth scopes in google mail component --- .../docs/google-mail-stream-component.adoc | 7 +++--- .../stream/GoogleMailStreamConfiguration.java | 23 ------------------- ...oogleMailStreamComponentConfiguration.java | 17 +------------- 3 files changed, 4 insertions(+), 43 deletions(-) diff --git a/components/camel-google-mail/src/main/docs/google-mail-stream-component.adoc b/components/camel-google-mail/src/main/docs/google-mail-stream-component.adoc index ed2086bc1eb1c..f6160dacf8568 100644 --- a/components/camel-google-mail/src/main/docs/google-mail-stream-component.adoc +++ b/components/camel-google-mail/src/main/docs/google-mail-stream-component.adoc @@ -27,7 +27,7 @@ for this component: camel-google-mail 2.22-SNAPSHOT - + ------------------------------------------------------ ### URI Format @@ -36,7 +36,7 @@ The GoogleMail Component uses the following URI format: -------------------------------------------------------- google-mail-stream://index?[options] - + -------------------------------------------------------- ### GoogleMailStreamComponent @@ -78,7 +78,7 @@ with the following path and query parameters: |=== -==== Query Parameters (29 parameters): +==== Query Parameters (28 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -94,7 +94,6 @@ with the following path and query parameters: | *maxResults* (consumer) | Max results to be returned | 10 | long | *query* (consumer) | The query to execute on gmail box | is:unread | String | *refreshToken* (consumer) | OAuth 2 refresh token. Using this, the Google Calendar component can obtain a new accessToken whenever the current one expires - a necessity if the application is long-lived. | | String -| *scopes* (consumer) | Specifies the level of permissions you want a mail application to have to a user account. See https://developers.google.com/gmail/api/auth/scopes for more info. | | List | *sendEmptyMessageWhenIdle* (consumer) | If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. | false | boolean | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/stream/GoogleMailStreamConfiguration.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/stream/GoogleMailStreamConfiguration.java index a69f719d19fac..d8164782c321a 100644 --- a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/stream/GoogleMailStreamConfiguration.java +++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/stream/GoogleMailStreamConfiguration.java @@ -16,11 +16,6 @@ */ package org.apache.camel.component.google.mail.stream; -import java.util.Arrays; -import java.util.List; - -import com.google.api.services.gmail.GmailScopes; - import org.apache.camel.RuntimeCamelException; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -31,14 +26,9 @@ */ @UriParams public class GoogleMailStreamConfiguration implements Cloneable { - private static final List DEFAULT_SCOPES = Arrays.asList(GmailScopes.GMAIL_COMPOSE, GmailScopes.GMAIL_MODIFY, GmailScopes.MAIL_GOOGLE_COM); - @UriPath private String index; - @UriParam - private List scopes = DEFAULT_SCOPES; - @UriParam private String clientId; @@ -124,19 +114,6 @@ public void setApplicationName(String applicationName) { this.applicationName = applicationName; } - public List getScopes() { - return scopes; - } - - /** - * Specifies the level of permissions you want a mail application to have to - * a user account. See https://developers.google.com/gmail/api/auth/scopes - * for more info. - */ - public void setScopes(List scopes) { - this.scopes = scopes; - } - public String getIndex() { return index; } diff --git a/platforms/spring-boot/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentConfiguration.java index 0a5d1e4323379..c790e30d370f6 100644 --- a/platforms/spring-boot/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentConfiguration.java @@ -16,14 +16,13 @@ */ package org.apache.camel.component.google.mail.stream.springboot; -import java.util.List; import javax.annotation.Generated; import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; /** * The google-mail component provides access to Google Mail. - * + * * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @@ -104,12 +103,6 @@ public static class GoogleMailStreamConfigurationNestedConfiguration { * Google mail application name. Example would be camel-google-mail/1.0 */ private String applicationName; - /** - * Specifies the level of permissions you want a mail application to - * have to a user account. See - * https://developers.google.com/gmail/api/auth/scopes for more info. - */ - private List scopes; /** * Specifies an index for the endpoint */ @@ -171,14 +164,6 @@ public void setApplicationName(String applicationName) { this.applicationName = applicationName; } - public List getScopes() { - return scopes; - } - - public void setScopes(List scopes) { - this.scopes = scopes; - } - public String getIndex() { return index; } From 1540303df397fbfc57fe1059b0b6a2a37a690d3e Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Thu, 22 Nov 2018 09:15:54 +0100 Subject: [PATCH 066/125] Use given exchange pattern when creating the exchange for incoming mail events --- .../mail/stream/GoogleMailStreamEndpoint.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/stream/GoogleMailStreamEndpoint.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/stream/GoogleMailStreamEndpoint.java index 4f49ebaedd14f..34428dd9b61e2 100644 --- a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/stream/GoogleMailStreamEndpoint.java +++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/stream/GoogleMailStreamEndpoint.java @@ -16,13 +16,10 @@ */ package org.apache.camel.component.google.mail.stream; -import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import javax.mail.internet.AddressException; - import com.google.api.client.util.Base64; import com.google.api.services.gmail.Gmail; import com.google.api.services.gmail.model.Label; @@ -30,7 +27,6 @@ import com.google.api.services.gmail.model.MessagePart; import com.google.api.services.gmail.model.MessagePartHeader; import com.google.common.base.Splitter; - import org.apache.camel.Consumer; import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; @@ -46,10 +42,10 @@ /** * The google-mail component provides access to Google Mail. */ -@UriEndpoint(firstVersion = "2.22.0", - scheme = "google-mail-stream", - title = "Google Mail Stream", - syntax = "google-mail-stream:index", +@UriEndpoint(firstVersion = "2.22.0", + scheme = "google-mail-stream", + title = "Google Mail Stream", + syntax = "google-mail-stream:index", consumerClass = GoogleMailStreamConsumer.class, consumerOnly = true, label = "api,cloud,mail") @@ -116,14 +112,14 @@ public boolean isSingleton() { return true; } - public Exchange createExchange(ExchangePattern pattern, com.google.api.services.gmail.model.Message mail) throws UnsupportedEncodingException { + public Exchange createExchange(ExchangePattern pattern, com.google.api.services.gmail.model.Message mail) { - Exchange exchange = super.createExchange(); + Exchange exchange = super.createExchange(pattern); Message message = exchange.getIn(); exchange.getIn().setHeader(GoogleMailStreamConstants.MAIL_ID, mail.getId()); List parts = mail.getPayload().getParts(); if (parts != null && parts.get(0).getBody().getData() != null) { - byte[] bodyBytes = Base64.decodeBase64(parts.get(0).getBody().getData().trim().toString()); + byte[] bodyBytes = Base64.decodeBase64(parts.get(0).getBody().getData().trim()); String body = new String(bodyBytes, StandardCharsets.UTF_8); message.setBody(body); } @@ -151,8 +147,8 @@ private void setHeaders(Message message, List headers) { } } } - - private List splitLabels(String labels) throws AddressException { + + private List splitLabels(String labels) { return Splitter.on(',').splitToList(labels); } } From d4427da10b6238ff3720af1f6509addec1aeff62 Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Thu, 22 Nov 2018 09:01:35 +0100 Subject: [PATCH 067/125] Move integration Maven profile to camel-parent pom.xml in order to enable proper configuration propagation to submodules --- parent/pom.xml | 33 +++++++++++++++++++++++++++++++++ pom.xml | 29 ----------------------------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index 94ee256118810..e7dca50dfc903 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -5679,6 +5679,39 @@ + + integration + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin-version} + + 300 + false + true + false + alphabetical + 0 + + target/derby.log + ${java.awt.headless} + + + **/*Test.* + **/*IntegrationTest.* + + + **/*XXXTest.* + + + + + + + ekstazi diff --git a/pom.xml b/pom.xml index fe6cf76e750f2..5d37e86f6252c 100644 --- a/pom.xml +++ b/pom.xml @@ -560,35 +560,6 @@ - - integration - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin-version} - - 300 - false - true - false - alphabetical - - target/derby.log - ${java.awt.headless} - - - **/*Test.* - **/*IntegrationTest.* - - - - - - - deploy From e21f9b4f81cc0c43d3a82c7a531209f59fa049f4 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 22 Nov 2018 11:11:01 +0100 Subject: [PATCH 068/125] Regen --- .../src/main/docs/google-calendar-stream-component.adoc | 6 +++--- .../src/main/docs/google-mail-stream-component.adoc | 3 +-- .../GoogleCalendarStreamComponentConfiguration.java | 2 +- .../springboot/GoogleMailStreamComponentConfiguration.java | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc b/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc index 624e34240746f..bcfe0362e89d4 100644 --- a/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc +++ b/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc @@ -131,15 +131,15 @@ The component supports 15 options, which are listed below. | *camel.component.google-calendar-stream.configuration.access-token* | OAuth 2 access token. This typically expires after an hour so refreshToken is recommended for long term usage. | | String | *camel.component.google-calendar-stream.configuration.application-name* | Google Calendar application name. Example would be camel-google-calendar/1.0 | | String | *camel.component.google-calendar-stream.configuration.calendar-id* | The calendarId to be used | primary | String -| *camel.component.google-calendar-stream.configuration.client-id* | Client ID of the mail application | | String -| *camel.component.google-calendar-stream.configuration.client-secret* | Client secret of the mail application | | String +| *camel.component.google-calendar-stream.configuration.client-id* | Client ID of the calendar application | | String +| *camel.component.google-calendar-stream.configuration.client-secret* | Client secret of the calendar application | | String | *camel.component.google-calendar-stream.configuration.consider-last-update* | Take into account the lastUpdate of the last event polled as start date for the next poll | false | Boolean | *camel.component.google-calendar-stream.configuration.consume-from-now* | Consume events in the selected calendar from now on | true | Boolean | *camel.component.google-calendar-stream.configuration.index* | Specifies an index for the endpoint | | String | *camel.component.google-calendar-stream.configuration.max-results* | Max results to be returned | 10 | Integer | *camel.component.google-calendar-stream.configuration.query* | The query to execute on calendar | | String | *camel.component.google-calendar-stream.configuration.refresh-token* | OAuth 2 refresh token. Using this, the Google Calendar component can obtain a new accessToken whenever the current one expires - a necessity if the application is long-lived. | | String -| *camel.component.google-calendar-stream.configuration.scopes* | Specifies the level of permissions you want a mail application to have to a user account. See https://developers.google.com/calendar/api/auth/scopes for more info. | | List +| *camel.component.google-calendar-stream.configuration.scopes* | Specifies the level of permissions you want a calendar application to have to a user account. See https://developers.google.com/calendar/auth for more info. | | List | *camel.component.google-calendar-stream.enabled* | Whether to enable auto configuration of the google-calendar-stream component. This is enabled by default. | | Boolean | *camel.component.google-calendar-stream.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean |=== diff --git a/components/camel-google-mail/src/main/docs/google-mail-stream-component.adoc b/components/camel-google-mail/src/main/docs/google-mail-stream-component.adoc index f6160dacf8568..ae40384e74c2a 100644 --- a/components/camel-google-mail/src/main/docs/google-mail-stream-component.adoc +++ b/components/camel-google-mail/src/main/docs/google-mail-stream-component.adoc @@ -118,7 +118,7 @@ with the following path and query parameters: === Spring Boot Auto-Configuration -The component supports 14 options, which are listed below. +The component supports 13 options, which are listed below. @@ -136,7 +136,6 @@ The component supports 14 options, which are listed below. | *camel.component.google-mail-stream.configuration.max-results* | Max results to be returned | 10 | Long | *camel.component.google-mail-stream.configuration.query* | The query to execute on gmail box | is:unread | String | *camel.component.google-mail-stream.configuration.refresh-token* | OAuth 2 refresh token. Using this, the Google Calendar component can obtain a new accessToken whenever the current one expires - a necessity if the application is long-lived. | | String -| *camel.component.google-mail-stream.configuration.scopes* | Specifies the level of permissions you want a mail application to have to a user account. See https://developers.google.com/gmail/api/auth/scopes for more info. | | List | *camel.component.google-mail-stream.enabled* | Whether to enable auto configuration of the google-mail-stream component. This is enabled by default. | | Boolean | *camel.component.google-mail-stream.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean |=== diff --git a/platforms/spring-boot/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConfiguration.java index d8efcb8cf9c56..0689c8dc9ae46 100644 --- a/platforms/spring-boot/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConfiguration.java @@ -24,7 +24,7 @@ /** * The google-calendar component provides access to Google Calendar in a * streaming mod. - * + * * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") diff --git a/platforms/spring-boot/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentConfiguration.java index c790e30d370f6..92074ed753883 100644 --- a/platforms/spring-boot/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentConfiguration.java @@ -22,7 +22,7 @@ /** * The google-mail component provides access to Google Mail. - * + * * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") From adae140be9466855798c1d6ffc7080b058fc90c1 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 20 Nov 2018 18:44:16 +0100 Subject: [PATCH 069/125] Refactor irc tests --- components/camel-irc/pom.xml | 37 ++++++++++ .../irc/it/IrcIntegrationTestSupport.java | 68 +++++++++++++++++++ .../{ => it}/IrcMultiChannelRouteTest.java | 63 +++++++++-------- .../irc/{ => it}/IrcOnReplyTest.java | 18 ++--- .../irc/{ => it}/IrcPrivmsgTest.java | 27 +++----- .../component/irc/{ => it}/IrcRouteTest.java | 34 +++++----- .../IrcsListUsersTest.java} | 32 +++------ .../component/irc/{ => it}/IrcsRouteTest.java | 17 ++--- .../IrcsWithSslContextParamsRouteTest.java | 2 +- ...t-users.properties => it-tests.properties} | 12 +++- 10 files changed, 195 insertions(+), 115 deletions(-) create mode 100644 components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcIntegrationTestSupport.java rename components/camel-irc/src/test/java/org/apache/camel/component/irc/{ => it}/IrcMultiChannelRouteTest.java (59%) rename components/camel-irc/src/test/java/org/apache/camel/component/irc/{ => it}/IrcOnReplyTest.java (81%) rename components/camel-irc/src/test/java/org/apache/camel/component/irc/{ => it}/IrcPrivmsgTest.java (80%) rename components/camel-irc/src/test/java/org/apache/camel/component/irc/{ => it}/IrcRouteTest.java (81%) rename components/camel-irc/src/test/java/org/apache/camel/component/irc/{IrcsListUsersIntegrationTest.java => it/IrcsListUsersTest.java} (74%) rename components/camel-irc/src/test/java/org/apache/camel/component/irc/{ => it}/IrcsRouteTest.java (64%) rename components/camel-irc/src/test/java/org/apache/camel/component/irc/{ => it}/IrcsWithSslContextParamsRouteTest.java (98%) rename components/camel-irc/src/test/resources/{it-list-users.properties => it-tests.properties} (84%) diff --git a/components/camel-irc/pom.xml b/components/camel-irc/pom.xml index 85b7e179039fe..a65b459bcb104 100644 --- a/components/camel-irc/pom.xml +++ b/components/camel-irc/pom.xml @@ -39,6 +39,43 @@ + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + **/it/** + + + + + + + + + + it-tests + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*Test.java + + + + + + + + + diff --git a/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcIntegrationTestSupport.java b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcIntegrationTestSupport.java new file mode 100644 index 0000000000000..b459749310dc9 --- /dev/null +++ b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcIntegrationTestSupport.java @@ -0,0 +1,68 @@ +/** + * 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.camel.component.irc.it; + +import java.io.IOException; +import java.util.Properties; +import java.util.concurrent.TimeUnit; +import org.apache.camel.EndpointInject; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Before; + +public class IrcIntegrationTestSupport extends CamelTestSupport { + + @EndpointInject(uri = "mock:result") + protected MockEndpoint resultEndpoint; + + protected Properties properties; + + @Before + public void doBefore() throws IOException { + properties = loadProperties(); + resetMock(resultEndpoint); + } + + protected void resetMock(MockEndpoint mock) { + mock.reset(); + mock.setResultWaitTime(TimeUnit.MINUTES.toMillis(1)); + } + + private Properties loadProperties() throws IOException { + Properties p = new Properties(); + p.load(this.getClass().getResourceAsStream("/it-tests.properties")); + return p; + } + + @Override + protected Properties useOverridePropertiesWithPropertiesComponent() { + try { + return loadProperties(); + } catch (IOException e) { + log.error("Can't load configuration properties"); + return null; + } + } + + protected String sendUri() { + return "ircs://{{camelTo}}@{{server}}?channels={{channel1}}"; + } + + protected String fromUri() { + return "ircs://{{camelFrom}}@{{server}}?&channels={{channel1}}"; + } +} diff --git a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcMultiChannelRouteTest.java b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcMultiChannelRouteTest.java similarity index 59% rename from components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcMultiChannelRouteTest.java rename to components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcMultiChannelRouteTest.java index dd1dd73e9d4cb..51f62b20703ad 100644 --- a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcMultiChannelRouteTest.java +++ b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcMultiChannelRouteTest.java @@ -14,34 +14,40 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.irc; +package org.apache.camel.component.irc.it; import java.util.List; - +import java.util.concurrent.TimeUnit; +import org.apache.camel.EndpointInject; import org.apache.camel.Exchange; -import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.irc.IrcConstants; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Ignore; import org.junit.Test; /** * @version */ -public class IrcMultiChannelRouteTest extends CamelTestSupport { - protected MockEndpoint resultEndpoint; +public class IrcMultiChannelRouteTest extends IrcIntegrationTestSupport { protected String body1 = "Message One"; protected String body2 = "Message Two"; protected String body3 = "Message Three"; - private boolean sentMessages; - @Ignore("test manual, irc.codehaus.org has been closed") + @EndpointInject(uri = "mock:joined") + private MockEndpoint joined; + + @Test public void testIrcMessages() throws Exception { - resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class); + resetMock(joined); + joined.expectedMessageCount(2); + joined.expectedHeaderValuesReceivedInAnyOrder(IrcConstants.IRC_TARGET, properties.get("channel1"), properties.get("channel2")); + joined.assertIsSatisfied(); + + sendMessages(); + //consumer is going to receive two copies of body3 - resultEndpoint.expectedBodiesReceived(body1, body2, body3, body3); + resultEndpoint.expectedBodiesReceivedInAnyOrder(body1, body2, body3, body3); resultEndpoint.assertIsSatisfied(); @@ -56,38 +62,31 @@ protected RouteBuilder createRouteBuilder() throws Exception { public void configure() throws Exception { from(fromUri()). choice(). - when(header(IrcConstants.IRC_MESSAGE_TYPE).isEqualTo("PRIVMSG")).to("mock:result"). - when(header(IrcConstants.IRC_MESSAGE_TYPE).isEqualTo("JOIN")).to("seda:consumerJoined"); + when(header(IrcConstants.IRC_MESSAGE_TYPE).isEqualTo("PRIVMSG")).to("direct:mock"). + when(header(IrcConstants.IRC_MESSAGE_TYPE).isEqualTo("JOIN")).to(joined); - from("seda:consumerJoined").process(new Processor() { - public void process(Exchange exchange) throws Exception { - sendMessages(); - } - }); + from("direct:mock").filter(e -> !e.getIn().getBody(String.class).contains("VERSION")).to(resultEndpoint); } }; } - protected String sendUri() { - return "irc://camel-prd@irc.codehaus.org:6667?nickname=camel-prd&channels=#camel-test1,#camel-test2"; - } - protected String fromUri() { - return "irc://camel-con@irc.codehaus.org:6667?nickname=camel-con&channels=#camel-test1,#camel-test2"; - } - /** * Lets send messages once the consumer has joined */ protected void sendMessages() { - if (!sentMessages) { - sentMessages = true; + template.sendBodyAndHeader(sendUri(), body1, "irc.target", properties.get("channel1")); + template.sendBodyAndHeader(sendUri(), body2, "irc.target", properties.get("channel2")); + template.sendBody(sendUri(), body3); + } - // now the consumer has joined, lets send some messages + @Override + protected String sendUri() { + return "ircs://camel-prd@{{server}}?nickname=camel-prd&channels={{channel1}},{{channel2}}"; + } - template.sendBodyAndHeader(sendUri(), body1, "irc.target", "#camel-test1"); - template.sendBodyAndHeader(sendUri(), body2, "irc.target", "#camel-test2"); - template.sendBody(sendUri(), body3); - } + @Override + protected String fromUri() { + return "ircs://camel-con@{{server}}??nickname=camel-con&channels={{channel1}},{{channel2}}"; } } diff --git a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcOnReplyTest.java b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcOnReplyTest.java similarity index 81% rename from components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcOnReplyTest.java rename to components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcOnReplyTest.java index 7f7b076eaf053..6a80301fd8d83 100644 --- a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcOnReplyTest.java +++ b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcOnReplyTest.java @@ -14,31 +14,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.irc; +package org.apache.camel.component.irc.it; import java.util.List; - import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.irc.IrcConstants; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Ignore; import org.junit.Test; /** * @version */ -public class IrcOnReplyTest extends CamelTestSupport { - protected MockEndpoint resultEndpoint; +public class IrcOnReplyTest extends IrcIntegrationTestSupport { protected String command = "WHO #camel-test"; - protected String resultEnd = "End of WHO list"; - private boolean sentMessages; + protected String resultEnd = "End of /WHO list."; + private boolean sentMessages; - @Ignore("test manual, irc.codehaus.org has been closed") @Test public void testIrcMessages() throws Exception { - resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class); resultEndpoint.expectedBodiesReceived(resultEnd); resultEndpoint.assertIsSatisfied(); @@ -67,7 +62,8 @@ public void process(Exchange exchange) throws Exception { } protected String fromUri() { - return "irc://camel-con@irc.codehaus.org:6667?nickname=camel-con&channels=#camel-test&onReply=true"; + StringBuilder sb = new StringBuilder(super.fromUri()); + return sb.append("&onReply=true").toString(); } /** diff --git a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcPrivmsgTest.java b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcPrivmsgTest.java similarity index 80% rename from components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcPrivmsgTest.java rename to components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcPrivmsgTest.java index 22716a2783572..9c06081afe7b3 100644 --- a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcPrivmsgTest.java +++ b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcPrivmsgTest.java @@ -14,13 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.irc; +package org.apache.camel.component.irc.it; import java.util.List; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.irc.IrcConstants; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Ignore; @@ -29,9 +30,7 @@ /** * @version */ -public class IrcPrivmsgTest extends CamelTestSupport { - protected MockEndpoint resultEndpoint; - +public class IrcPrivmsgTest extends IrcIntegrationTestSupport { protected String expectedBody1 = "Message One"; protected String expectedBody2 = "Message Two"; @@ -40,10 +39,8 @@ public class IrcPrivmsgTest extends CamelTestSupport { private boolean sentMessages; - @Ignore("test manual, irc.codehaus.org has been closed") @Test public void testIrcPrivateMessages() throws Exception { - resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class); resultEndpoint.expectedBodiesReceived(expectedBody1, expectedBody2); resultEndpoint.assertIsSatisfied(); @@ -59,7 +56,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { public void configure() throws Exception { from(fromUri()). choice(). - when(header(IrcConstants.IRC_MESSAGE_TYPE).isEqualTo("PRIVMSG")).to("mock:result"). + when(header(IrcConstants.IRC_MESSAGE_TYPE).isEqualTo("PRIVMSG")).to("direct:mock"). when(header(IrcConstants.IRC_MESSAGE_TYPE).isEqualTo("JOIN")).to("seda:consumerJoined"); from("seda:consumerJoined") @@ -68,28 +65,26 @@ public void process(Exchange exchange) throws Exception { sendMessages(); } }); + + from("direct:mock").filter(e -> !e.getIn().getBody(String.class).contains("VERSION")).to(resultEndpoint); } }; } + @Override protected String sendUri() { - return "irc://camel-prd@irc.codehaus.org:6667/#camel-test?nickname=camel-prd"; + return "ircs://{{camelTo}}@{{server}}?channels={{channel1}}&username={{username}}&password={{password}}"; } - protected String fromUri() { - return "irc://camel-con@irc.codehaus.org:6667/#camel-test?nickname=camel-con"; - } - /** * Lets send messages once the consumer has joined */ - protected void sendMessages() { + protected void sendMessages() throws InterruptedException { if (!sentMessages) { sentMessages = true; - // now the consumer has joined, lets send some messages - template.sendBodyAndHeader(sendUri(), body1, "irc.target", "camel-con"); - template.sendBodyAndHeader(sendUri(), body2, "irc.target", "camel-con"); + template.sendBodyAndHeader(sendUri(), body1, "irc.target", properties.get("camelFrom")); + template.sendBodyAndHeader(sendUri(), body2, "irc.target", properties.get("camelFrom")); } } } diff --git a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcRouteTest.java b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcRouteTest.java similarity index 81% rename from components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcRouteTest.java rename to components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcRouteTest.java index 7b3d60ff8148d..43d6ce0895a0c 100644 --- a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcRouteTest.java +++ b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcRouteTest.java @@ -14,13 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.irc; +package org.apache.camel.component.irc.it; import java.util.List; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.irc.IrcConstants; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Ignore; @@ -29,32 +30,37 @@ /** * @version */ -public class IrcRouteTest extends CamelTestSupport { - protected MockEndpoint resultEndpoint; +public class IrcRouteTest extends IrcIntegrationTestSupport { protected String body1 = "Message One"; protected String body2 = "Message Two"; private boolean sentMessages; - @Ignore("test manual, irc.codehaus.org has been closed") @Test public void testIrcMessages() throws Exception { - resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class); - resultEndpoint.expectedBodiesReceived(body1, body2); - + resultEndpoint.expectedBodiesReceivedInAnyOrder(body1, body2); resultEndpoint.assertIsSatisfied(); List list = resultEndpoint.getReceivedExchanges(); for (Exchange exchange : list) { log.info("Received exchange: " + exchange + " headers: " + exchange.getIn().getHeaders()); } - } + } + + protected String sendUri() { + return "irc://{{camelTo}}@{{non.ssl.server}}?channels={{channel1}}"; + } + + protected String fromUri() { + return "irc://{{camelFrom}}@{{non.ssl.server}}?&channels={{channel1}}"; + } protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { from(fromUri()). choice(). - when(header(IrcConstants.IRC_MESSAGE_TYPE).isEqualTo("PRIVMSG")).to("mock:result"). + when(header(IrcConstants.IRC_MESSAGE_TYPE).isEqualTo("PRIVMSG")) + .to("direct:mock"). when(header(IrcConstants.IRC_MESSAGE_TYPE).isEqualTo("JOIN")).to("seda:consumerJoined"); from("seda:consumerJoined").process(new Processor() { @@ -62,17 +68,11 @@ public void process(Exchange exchange) throws Exception { sendMessages(); } }); + + from("direct:mock").filter(e -> !e.getIn().getBody(String.class).contains("VERSION")).to(resultEndpoint); } }; } - - protected String sendUri() { - return "irc://camel-prd-user@irc.codehaus.org:6667/#camel-test?nickname=camel-prd"; - } - - protected String fromUri() { - return "irc://camel-con-user@irc.codehaus.org:6667/#camel-test?nickname=camel-con"; - } /** * Lets send messages once the consumer has joined diff --git a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsListUsersIntegrationTest.java b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcsListUsersTest.java similarity index 74% rename from components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsListUsersIntegrationTest.java rename to components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcsListUsersTest.java index 7e629ee294f42..29569015c6061 100644 --- a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsListUsersIntegrationTest.java +++ b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcsListUsersTest.java @@ -14,17 +14,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.irc; +package org.apache.camel.component.irc.it; import java.io.IOException; import java.io.InputStream; import java.util.Properties; +import java.util.concurrent.TimeUnit; import org.apache.camel.EndpointInject; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.irc.IrcConfiguration; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,27 +37,15 @@ * Joins a channel and asserts that the username of the current test user is * listed for the channel. */ -public class IrcsListUsersIntegrationTest extends CamelTestSupport { +public class IrcsListUsersTest extends IrcIntegrationTestSupport { - private static final Logger LOGGER = LoggerFactory.getLogger(IrcsListUsersIntegrationTest.class); + private static final Logger LOGGER = LoggerFactory.getLogger(IrcsListUsersTest.class); /** message code for a reply to a NAMES command. */ private static final String IRC_RPL_NAMREPLY = "353"; /** irc component uri. configured by properties */ - private static final String PRODUCER_URI = "ircs:{{test.user}}@{{test.server}}/{{test.room}}"; - - @EndpointInject(uri = "mock:result") - protected MockEndpoint resultEndpoint; - - protected Properties properties; - - public IrcsListUsersIntegrationTest() throws IOException { - super(); - properties = new Properties(); - InputStream resourceAsStream = this.getClass().getResourceAsStream("/it-list-users.properties"); - properties.load(resourceAsStream); - } + private static final String PRODUCER_URI = "ircs:{{camelFrom}}@{{server}}/{{channel1}}"; @Override protected RoutesBuilder createRouteBuilder() throws Exception { @@ -76,17 +67,12 @@ public void configure() throws Exception { @Test public void test() throws Exception { - resultEndpoint.setMinimumExpectedMessageCount(1); + resultEndpoint.expectedMessageCount(1); resultEndpoint.assertIsSatisfied(); String body = resultEndpoint.getExchanges().get(0).getIn().getBody(String.class); LOGGER.debug("Received usernames: [{}]", body); - String username = properties.getProperty("test.user"); + String username = properties.getProperty("camelFrom"); assertTrue("userlist does not contain test user", body.contains(username)); } - @Override - protected Properties useOverridePropertiesWithPropertiesComponent() { - return properties; - } - } diff --git a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsRouteTest.java b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcsRouteTest.java similarity index 64% rename from components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsRouteTest.java rename to components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcsRouteTest.java index d79e5ae21d092..466a9c5a1da71 100644 --- a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsRouteTest.java +++ b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcsRouteTest.java @@ -14,25 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.irc; +package org.apache.camel.component.irc.it; -import org.junit.Ignore; - -@Ignore public class IrcsRouteTest extends IrcRouteTest { - // TODO This test is disabled until we can find a public SSL enabled IRC - // server to test against. To use this you'll need to change the server - // information below and the username/password. - @Override protected String sendUri() { - return "ircs://camel-prd@irc.codehaus.org:6667/#camel-test?nickname=camel-prd&password=blah"; + return "ircs://{{camelTo}}@{{server}}?channels={{channel1}}"; } - @Override + @Override protected String fromUri() { - return "ircs://camel-con@irc.codehaus.org:6667/#camel-test?nickname=camel-con&password=blah"; - } + return "ircs://{{camelFrom}}@{{server}}?channels={{channel1}}"; + } } \ No newline at end of file diff --git a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsWithSslContextParamsRouteTest.java b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcsWithSslContextParamsRouteTest.java similarity index 98% rename from components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsWithSslContextParamsRouteTest.java rename to components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcsWithSslContextParamsRouteTest.java index 8faab1a89ca79..819771a9c99b2 100644 --- a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsWithSslContextParamsRouteTest.java +++ b/components/camel-irc/src/test/java/org/apache/camel/component/irc/it/IrcsWithSslContextParamsRouteTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.irc; +package org.apache.camel.component.irc.it; import org.apache.camel.impl.JndiRegistry; import org.apache.camel.util.jsse.KeyStoreParameters; diff --git a/components/camel-irc/src/test/resources/it-list-users.properties b/components/camel-irc/src/test/resources/it-tests.properties similarity index 84% rename from components/camel-irc/src/test/resources/it-list-users.properties rename to components/camel-irc/src/test/resources/it-tests.properties index bebe5fbbc2e9b..81bc728649c0b 100644 --- a/components/camel-irc/src/test/resources/it-list-users.properties +++ b/components/camel-irc/src/test/resources/it-tests.properties @@ -15,6 +15,12 @@ ## limitations under the License. ## --------------------------------------------------------------------------- -test.server=chat.freenode.net:6697 -test.room=#testroom123 -test.user=camel-irc-ituser +server=chat.freenode.net:6697 +non.ssl.server=chat.freenode.net:8002 +channel1=#camel-test1 +channel2=#testroom2 +username= +password= +camelFrom=camel-irc-ituser +camelTo=camel-prod + From 8240ed3fc919da6058f561053361fc57d88d1a13 Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Thu, 22 Nov 2018 09:41:52 +0100 Subject: [PATCH 070/125] CAMEL-12950: Add google-sheets component --- apache-camel/pom.xml | 11 +- .../src/main/descriptors/common-bin.xml | 4 +- bom/camel-bom/pom.xml | 10 + components/camel-google-sheets/pom.xml | 289 ++++++++++++++++++ .../main/docs/google-sheets-component.adoc | 180 +++++++++++ .../docs/google-sheets-stream-component.adoc | 164 ++++++++++ .../BatchGoogleSheetsClientFactory.java | 66 ++++ .../sheets/GoogleSheetsClientFactory.java | 25 ++ .../google/sheets/GoogleSheetsComponent.java | 102 +++++++ .../sheets/GoogleSheetsConfiguration.java | 130 ++++++++ .../google/sheets/GoogleSheetsConsumer.java | 52 ++++ .../google/sheets/GoogleSheetsEndpoint.java | 115 +++++++ .../google/sheets/GoogleSheetsProducer.java | 54 ++++ .../sheets/GoogleSheetsVerifierExtension.java | 80 +++++ .../internal/GoogleSheetsConstants.java | 33 ++ .../GoogleSheetsPropertiesHelper.java | 39 +++ .../stream/GoogleSheetsStreamComponent.java | 96 ++++++ .../GoogleSheetsStreamConfiguration.java | 255 ++++++++++++++++ .../stream/GoogleSheetsStreamConstants.java | 37 +++ .../stream/GoogleSheetsStreamConsumer.java | 120 ++++++++ .../stream/GoogleSheetsStreamEndpoint.java | 99 ++++++ .../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++++++ .../src/main/resources/META-INF/NOTICE.txt | 11 + .../org/apache/camel/component/google-sheets | 17 ++ .../camel/component/google-sheets-stream | 17 ++ .../AbstractGoogleSheetsTestSupport.java | 164 ++++++++++ .../GoogleSheetsVerifierExtensionTest.java | 68 +++++ .../sheets/SheetsConfigurationTest.java | 64 ++++ .../SheetsSpreadsheetsIntegrationTest.java | 114 +++++++ ...eetsSpreadsheetsValuesIntegrationTest.java | 159 ++++++++++ ...AbstractGoogleSheetsStreamTestSupport.java | 44 +++ .../SheetsStreamConsumerIntegrationTest.java | 70 +++++ .../src/test/resources/log4j2.properties | 28 ++ .../test/resources/test-options.properties | 26 ++ components/pom.xml | 3 +- components/readme.adoc | 8 +- docs/user-manual/en/SUMMARY.md | 2 + parent/pom.xml | 15 +- .../features/src/main/resources/features.xml | 38 ++- .../camel-google-sheets-starter/pom.xml | 61 ++++ ...oogleSheetsComponentAutoConfiguration.java | 129 ++++++++ .../GoogleSheetsComponentConfiguration.java | 174 +++++++++++ ...heetsStreamComponentAutoConfiguration.java | 130 ++++++++ ...gleSheetsStreamComponentConfiguration.java | 252 +++++++++++++++ .../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++++++ .../src/main/resources/META-INF/NOTICE.txt | 11 + .../main/resources/META-INF/spring.factories | 21 ++ .../main/resources/META-INF/spring.provides | 17 ++ .../spring-boot/components-starter/pom.xml | 1 + .../camel-spring-boot-dependencies/pom.xml | 10 + .../itest/karaf/CamelGoogleSheetsTest.java | 33 ++ 51 files changed, 4036 insertions(+), 18 deletions(-) create mode 100644 components/camel-google-sheets/pom.xml create mode 100644 components/camel-google-sheets/src/main/docs/google-sheets-component.adoc create mode 100644 components/camel-google-sheets/src/main/docs/google-sheets-stream-component.adoc create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/BatchGoogleSheetsClientFactory.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/GoogleSheetsClientFactory.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/GoogleSheetsComponent.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/GoogleSheetsConfiguration.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/GoogleSheetsConsumer.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/GoogleSheetsEndpoint.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/GoogleSheetsProducer.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/GoogleSheetsVerifierExtension.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/internal/GoogleSheetsConstants.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/internal/GoogleSheetsPropertiesHelper.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/stream/GoogleSheetsStreamComponent.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/stream/GoogleSheetsStreamConfiguration.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/stream/GoogleSheetsStreamConstants.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/stream/GoogleSheetsStreamConsumer.java create mode 100644 components/camel-google-sheets/src/main/java/org/apache/camel/component/google/sheets/stream/GoogleSheetsStreamEndpoint.java create mode 100644 components/camel-google-sheets/src/main/resources/META-INF/LICENSE.txt create mode 100644 components/camel-google-sheets/src/main/resources/META-INF/NOTICE.txt create mode 100644 components/camel-google-sheets/src/main/resources/META-INF/services/org/apache/camel/component/google-sheets create mode 100644 components/camel-google-sheets/src/main/resources/META-INF/services/org/apache/camel/component/google-sheets-stream create mode 100644 components/camel-google-sheets/src/test/java/org/apache/camel/component/google/sheets/AbstractGoogleSheetsTestSupport.java create mode 100644 components/camel-google-sheets/src/test/java/org/apache/camel/component/google/sheets/GoogleSheetsVerifierExtensionTest.java create mode 100644 components/camel-google-sheets/src/test/java/org/apache/camel/component/google/sheets/SheetsConfigurationTest.java create mode 100644 components/camel-google-sheets/src/test/java/org/apache/camel/component/google/sheets/SheetsSpreadsheetsIntegrationTest.java create mode 100644 components/camel-google-sheets/src/test/java/org/apache/camel/component/google/sheets/SheetsSpreadsheetsValuesIntegrationTest.java create mode 100644 components/camel-google-sheets/src/test/java/org/apache/camel/component/google/sheets/stream/AbstractGoogleSheetsStreamTestSupport.java create mode 100644 components/camel-google-sheets/src/test/java/org/apache/camel/component/google/sheets/stream/SheetsStreamConsumerIntegrationTest.java create mode 100644 components/camel-google-sheets/src/test/resources/log4j2.properties create mode 100644 components/camel-google-sheets/src/test/resources/test-options.properties create mode 100644 platforms/spring-boot/components-starter/camel-google-sheets-starter/pom.xml create mode 100644 platforms/spring-boot/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/springboot/GoogleSheetsComponentAutoConfiguration.java create mode 100644 platforms/spring-boot/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/springboot/GoogleSheetsComponentConfiguration.java create mode 100644 platforms/spring-boot/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/stream/springboot/GoogleSheetsStreamComponentAutoConfiguration.java create mode 100644 platforms/spring-boot/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/stream/springboot/GoogleSheetsStreamComponentConfiguration.java create mode 100644 platforms/spring-boot/components-starter/camel-google-sheets-starter/src/main/resources/META-INF/LICENSE.txt create mode 100644 platforms/spring-boot/components-starter/camel-google-sheets-starter/src/main/resources/META-INF/NOTICE.txt create mode 100644 platforms/spring-boot/components-starter/camel-google-sheets-starter/src/main/resources/META-INF/spring.factories create mode 100644 platforms/spring-boot/components-starter/camel-google-sheets-starter/src/main/resources/META-INF/spring.provides create mode 100644 tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelGoogleSheetsTest.java diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index af37d5ea136a9..24ecbb2cb8d9e 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -366,6 +366,10 @@ org.apache.camel camel-google-calendar + + org.apache.camel + camel-google-sheets + org.apache.camel camel-google-drive @@ -1549,7 +1553,7 @@ org.apache.camel camel-fhir-starter ${project.version} - + org.apache.camel camel-flatpack-starter @@ -1605,6 +1609,11 @@ camel-google-calendar-starter ${project.version} + + org.apache.camel + camel-google-sheets-starter + ${project.version} + org.apache.camel camel-google-drive-starter diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml index 3436d48a2047b..22c929a667001 100644 --- a/apache-camel/src/main/descriptors/common-bin.xml +++ b/apache-camel/src/main/descriptors/common-bin.xml @@ -105,6 +105,7 @@ org.apache.camel:camel-git org.apache.camel:camel-github org.apache.camel:camel-google-calendar + org.apache.camel:camel-google-sheets org.apache.camel:camel-google-drive org.apache.camel:camel-google-mail org.apache.camel:camel-google-bigquery @@ -430,6 +431,7 @@ org.apache.camel:camel-git-starter org.apache.camel:camel-google-bigquery-starter org.apache.camel:camel-google-calendar-starter + org.apache.camel:camel-google-sheets-starter org.apache.camel:camel-google-drive-starter org.apache.camel:camel-google-mail-starter org.apache.camel:camel-google-pubsub-starter @@ -506,7 +508,7 @@ org.apache.camel:camel-mail-starter org.apache.camel:camel-master-starter org.apache.camel:camel-metrics-starter - org.apache.camel:camel-micrometer-starter + org.apache.camel:camel-micrometer-starter org.apache.camel:camel-milo-starter org.apache.camel:camel-mina2-starter org.apache.camel:camel-mllp-starter diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml index b8266714fecfb..fc9cacf8a5399 100644 --- a/bom/camel-bom/pom.xml +++ b/bom/camel-bom/pom.xml @@ -928,6 +928,16 @@ camel-google-pubsub-starter ${project.version} + + org.apache.camel + camel-google-sheets + ${project.version} + + + org.apache.camel + camel-google-sheets-starter + ${project.version} + org.apache.camel camel-gora diff --git a/components/camel-google-sheets/pom.xml b/components/camel-google-sheets/pom.xml new file mode 100644 index 0000000000000..da26bd64c5828 --- /dev/null +++ b/components/camel-google-sheets/pom.xml @@ -0,0 +1,289 @@ + + + + + 4.0.0 + + + org.apache.camel + components + 2.23.0-SNAPSHOT + + + camel-google-sheets + jar + Camel :: GoogleSheets + Camel Component for GoogleSheets + + + google-sheets + GoogleSheets + org.apache.camel.component.google.sheets + org.apache.camel.component.google.sheets.internal + org.apache.camel.component.google.sheets.internal + org.apache.camel.component.google.sheets + org.apache.camel.spi.ComponentResolver;component=google-sheets + + + + + org.apache.camel + camel-core + + + com.google.api-client + google-api-client + ${google-api-client-version} + + + com.google.oauth-client + google-oauth-client + ${google-api-client-version} + + + com.google.http-client + google-http-client-jackson2 + ${google-api-client-version} + + + com.google.apis + google-api-services-sheets + ${google-api-services-sheets-version} + + + + + org.apache.camel + spi-annotations + ${project.version} + provided + + + + + com.google.apis + google-api-services-sheets + ${google-api-services-sheets-version} + javadoc + provided + + + + + org.apache.logging.log4j + log4j-api + test + + + org.apache.logging.log4j + log4j-core + test + + + org.apache.logging.log4j + log4j-slf4j-impl + test + + + + + org.apache.camel + camel-test + test + + + + + install + + + + + + org.apache.camel + camel-api-component-maven-plugin + + + generate-test-component-classes + + fromApis + + + + + spreadsheets + com.google.api.services.sheets.v4.Sheets$Spreadsheets + + + + data + com.google.api.services.sheets.v4.Sheets$Spreadsheets$Values + + + + + + ^.+$ + content + com.google.api.services.sheets.v4.model.ValueRange + values + + + ^.+$ + content + com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetRequest + batchUpdateSpreadsheetRequest + + + ^.+$ + content + com.google.api.services.sheets.v4.model.GetSpreadsheetByDataFilterRequest + getSpreadsheetByDataFilterRequest + + + ^.+$ + content + com.google.api.services.sheets.v4.model.ClearValuesRequest + clearValuesRequest + + + ^.+$ + content + com.google.api.services.sheets.v4.model.BatchClearValuesRequest + batchClearValuesRequest + + + ^.+$ + content + com.google.api.services.sheets.v4.model.BatchUpdateValuesByDataFilterRequest + batchUpdateValuesByDataFilterRequest + + + ^.+$ + content + com.google.api.services.sheets.v4.model.BatchGetValuesByDataFilterRequest + batchGetValuesByDataFilterRequest + + + ^.+$ + content + com.google.api.services.sheets.v4.model.BatchUpdateValuesRequest + batchUpdateValuesRequest + + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + add-generated-sources + + add-source + + + + ${project.build.directory}/generated-sources/camel-component + + + + + add-generated-test-sources + + add-test-source + + + + ${project.build.directory}/generated-test-sources/camel-component + + + + + + + + + + + + org.apache.camel + camel-api-component-maven-plugin + ${project.version} + + ${schemeName} + ${componentName} + ${componentPackage} + ${outPackage} + + + + + + + + + + + org.apache.camel + camel-api-component-maven-plugin + ${project.version} + + ${schemeName} + ${componentName} + ${componentPackage} + ${outPackage} + + + + + + + + google-sheets-test + + + + maven-surefire-plugin + + false + true + 1 + true + 300 + + **/*XXXTest.java + + + **/*Test.java + + + + + + + + + diff --git a/components/camel-google-sheets/src/main/docs/google-sheets-component.adoc b/components/camel-google-sheets/src/main/docs/google-sheets-component.adoc new file mode 100644 index 0000000000000..0cba9c99b51ca --- /dev/null +++ b/components/camel-google-sheets/src/main/docs/google-sheets-component.adoc @@ -0,0 +1,180 @@ +[[google-sheets-component]] +== Google Sheets Component + +*Available as of Camel version 2.23* + +The Google Sheets component provides access +to http://google.com/sheets[Google Sheets] via +the https://developers.google.com/sheets/api/reference/rest/[Google +Sheets Web APIs]. + +Google Sheets uses +the https://developers.google.com/accounts/docs/OAuth2[OAuth 2.0 +protocol] for authenticating a Google account and authorizing access to +user data. Before you can use this component, you will need +to https://developers.google.com/google-apps/sheets/auth[create an +account and generate OAuth credentials]. Credentials comprise of a +clientId, clientSecret, and a refreshToken. A handy resource for +generating a long-lived refreshToken is +the https://developers.google.com/oauthplayground[OAuth playground]. + +Maven users will need to add the following dependency to their pom.xml +for this component: + +---------------------------------------------------------- + + org.apache.camel + camel-google-sheets + 2.23.0 + + +---------------------------------------------------------- + +### URI Format + +The GoogleSheets Component uses the following URI format: + +------------------------------------------------------------ + google-sheets://endpoint-prefix/endpoint?[options] + +------------------------------------------------------------ + +Endpoint prefix can be one of: + +* spreadsheets +* data + +### GoogleSheetsComponent + + + + + +// component options: START +The Google Sheets component supports 3 options, which are listed below. + + + +[width="100%",cols="2,5,^1,2",options="header"] +|=== +| Name | Description | Default | Type +| *configuration* (common) | To use the shared configuration | | GoogleSheets Configuration +| *clientFactory* (advanced) | To use the GoogleSheetsClientFactory as factory for creating the client. Will by default use BatchGoogleSheetsClientFactory | | GoogleSheetsClient Factory +| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean +|=== +// component options: END + + + + + + + +// endpoint options: START +The Google Sheets endpoint is configured using URI syntax: + +---- +google-sheets:apiName/methodName +---- + +with the following path and query parameters: + +==== Path Parameters (2 parameters): + + +[width="100%",cols="2,5,^1,2",options="header"] +|=== +| Name | Description | Default | Type +| *apiName* | *Required* What kind of operation to perform | | GoogleSheetsApiName +| *methodName* | *Required* What sub operation to use for the selected operation | | String +|=== + + +==== Query Parameters (10 parameters): + + +[width="100%",cols="2,5,^1,2",options="header"] +|=== +| Name | Description | Default | Type +| *accessToken* (common) | OAuth 2 access token. This typically expires after an hour so refreshToken is recommended for long term usage. | | String +| *applicationName* (common) | Google Sheets application name. Example would be camel-google-sheets/1.0 | | String +| *clientId* (common) | Client ID of the sheets application | | String +| *clientSecret* (common) | Client secret of the sheets application | | String +| *inBody* (common) | Sets the name of a parameter to be passed in the exchange In Body | | String +| *refreshToken* (common) | OAuth 2 refresh token. Using this, the Google Sheets component can obtain a new accessToken whenever the current one expires - a necessity if the application is long-lived. | | String +| *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean +| *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler +| *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern +| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean +|=== +// endpoint options: END +// spring-boot-auto-configure options: START +=== Spring Boot Auto-Configuration + + +The component supports 10 options, which are listed below. + + + +[width="100%",cols="2,5,^1,2",options="header"] +|=== +| Name | Description | Default | Type +| *camel.component.google-sheets.client-factory* | To use the GoogleSheetsClientFactory as factory for creating the client. Will by default use BatchGoogleSheetsClientFactory. The option is a org.apache.camel.component.google.sheets.GoogleSheetsClientFactory type. | | String +| *camel.component.google-sheets.configuration.access-token* | OAuth 2 access token. This typically expires after an hour so refreshToken is recommended for long term usage. | | String +| *camel.component.google-sheets.configuration.api-name* | What kind of operation to perform | | GoogleSheetsApiName +| *camel.component.google-sheets.configuration.application-name* | Google Sheets application name. Example would be camel-google-sheets/1.0 | | String +| *camel.component.google-sheets.configuration.client-id* | Client ID of the sheets application | | String +| *camel.component.google-sheets.configuration.client-secret* | Client secret of the sheets application | | String +| *camel.component.google-sheets.configuration.method-name* | What sub operation to use for the selected operation | | String +| *camel.component.google-sheets.configuration.refresh-token* | OAuth 2 refresh token. Using this, the Google Sheets component can obtain a new accessToken whenever the current one expires - a necessity if the application is long-lived. | | String +| *camel.component.google-sheets.enabled* | Whether to enable auto configuration of the google-sheets component. This is enabled by default. | | Boolean +| *camel.component.google-sheets.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean +|=== +// spring-boot-auto-configure options: END + + + + +### Producer Endpoints + +Producer endpoints can use endpoint prefixes followed by endpoint names +and associated options described next. A shorthand alias can be used for +some endpoints. The endpoint URI MUST contain a prefix. + +Endpoint options that are not mandatory are denoted by []. When there +are no mandatory options for an endpoint, one of the set of [] options +MUST be provided. Producer endpoints can also use a special option +*`inBody`* that in turn should contain the name of the endpoint option +whose value will be contained in the Camel Exchange In message. + +Any of the endpoint options can be provided in either the endpoint URI, +or dynamically in a message header. The message header name must be of +the format `CamelGoogleSheets.