You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/04/15 10:49:16 UTC

[camel] branch master updated (c106879 -> 2dafbed)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from c106879  Camel-Package-Maven-Plugin: Fixed CS
     new 19e9b25  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq list brokers
     new 141d8fd  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq create broker
     new 0626d3d  CAMEL-14868 - Fixed build aws2-mq
     new 937cdbe  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq delete broker
     new 6af74dc  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq reboot broker
     new 8d45399  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq update broker
     new 9b77739  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq describe broker
     new 94eb3c5  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq fixed CS
     new f1002c7  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq regen
     new 2dafbed  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq regen docs website

The 10 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../component/aws2/mq/MQ2ComponentConfigurer.java  |   5 +
 .../component/aws2/mq/MQ2EndpointConfigurer.java   |   5 +
 .../apache/camel/component/aws2/mq/aws2-mq.json    |   2 +
 .../src/main/docs/aws2-mq-component.adoc           |   6 +-
 .../camel/component/aws2/mq/MQ2Configuration.java  |  13 +
 .../camel/component/aws2/mq/MQ2Producer.java       | 353 +++++++++++++--------
 .../dsl/Aws2MqComponentBuilderFactory.java         |  13 +
 .../endpoint/dsl/MQ2EndpointBuilderFactory.java    |  24 ++
 .../modules/ROOT/pages/aws2-mq-component.adoc      |   6 +-
 9 files changed, 292 insertions(+), 135 deletions(-)


[camel] 07/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq describe broker

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9b777395769cdbce0fbdc1e9e531b5db18644601
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 15 12:46:17 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq describe broker
---
 .../org/apache/camel/component/aws2/mq/MQ2Producer.java | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
index 591ef29..052e523 100644
--- a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
+++ b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
@@ -333,8 +333,22 @@ public class MQ2Producer extends DefaultProducer {
         }
     }
 
-    private void describeBroker(MqClient mqClient, Exchange exchange) {
+    private void describeBroker(MqClient mqClient, Exchange exchange) throws InvalidPayloadException {
         String brokerId;
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof DescribeBrokerRequest) {
+                DescribeBrokerResponse result;
+                try {
+                    result = mqClient.describeBroker((DescribeBrokerRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Reboot Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         DescribeBrokerRequest.Builder builder = DescribeBrokerRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ID))) {
             brokerId = exchange.getIn().getHeader(MQ2Constants.BROKER_ID, String.class);
@@ -351,6 +365,7 @@ public class MQ2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     public static Message getMessageForResponse(final Exchange exchange) {


[camel] 02/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq create broker

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 141d8fd77e0ae98fa3452369c8897af006ff4b31
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 15 12:38:51 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq create broker
---
 .../org/apache/camel/component/aws2/mq/MQ2Producer.java | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
index d9a769d..0cd5a89 100644
--- a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
+++ b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
@@ -146,7 +146,7 @@ public class MQ2Producer extends DefaultProducer {
     }
 
     @SuppressWarnings("unchecked")
-    private void createBroker(MqClient mqClient, Exchange exchange) {
+    private void createBroker(MqClient mqClient, Exchange exchange) throws InvalidPayloadException {
         String brokerName;
         String brokerEngine;
         String brokerEngineVersion;
@@ -154,6 +154,20 @@ public class MQ2Producer extends DefaultProducer {
         String instanceType;
         Boolean publiclyAccessible;
         List<User> users;
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof CreateBrokerRequest) {
+                CreateBrokerResponse result;
+                try {
+                    result = mqClient.createBroker((CreateBrokerRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Create Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         CreateBrokerRequest.Builder builder = CreateBrokerRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_NAME))) {
             brokerName = exchange.getIn().getHeader(MQ2Constants.BROKER_NAME, String.class);
@@ -206,6 +220,7 @@ public class MQ2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     private void deleteBroker(MqClient mqClient, Exchange exchange) {


[camel] 05/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq reboot broker

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6af74dc12567c1a8fa521665f7d628d5bdb6e235
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 15 12:43:40 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq reboot broker
---
 .../org/apache/camel/component/aws2/mq/MQ2Producer.java | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
index fae6804..0f32ba4 100644
--- a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
+++ b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
@@ -256,8 +256,22 @@ public class MQ2Producer extends DefaultProducer {
         }
     }
 
-    private void rebootBroker(MqClient mqClient, Exchange exchange) {
+    private void rebootBroker(MqClient mqClient, Exchange exchange) throws InvalidPayloadException {
         String brokerId;
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof RebootBrokerRequest) {
+                RebootBrokerResponse result;
+                try {
+                    result = mqClient.rebootBroker((RebootBrokerRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Reboot Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         RebootBrokerRequest.Builder builder = RebootBrokerRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ID))) {
             brokerId = exchange.getIn().getHeader(MQ2Constants.BROKER_ID, String.class);
@@ -274,6 +288,7 @@ public class MQ2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     private void updateBroker(MqClient mqClient, Exchange exchange) {


[camel] 06/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq update broker

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8d45399a3947601e803b0cc2b9309606eb53271c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 15 12:44:48 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq update broker
---
 .../org/apache/camel/component/aws2/mq/MQ2Producer.java | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
index 0f32ba4..591ef29 100644
--- a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
+++ b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
@@ -291,9 +291,23 @@ public class MQ2Producer extends DefaultProducer {
         }
     }
 
-    private void updateBroker(MqClient mqClient, Exchange exchange) {
+    private void updateBroker(MqClient mqClient, Exchange exchange) throws InvalidPayloadException {
         String brokerId;
         ConfigurationId configurationId;
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof UpdateBrokerRequest) {
+                UpdateBrokerResponse result;
+                try {
+                    result = mqClient.updateBroker((UpdateBrokerRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Update Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         UpdateBrokerRequest.Builder builder = UpdateBrokerRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ID))) {
             brokerId = exchange.getIn().getHeader(MQ2Constants.BROKER_ID, String.class);
@@ -316,6 +330,7 @@ public class MQ2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     private void describeBroker(MqClient mqClient, Exchange exchange) {


[camel] 09/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq regen

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f1002c7a1aba423e791ac72033947abf7b017d95
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 15 12:47:39 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq regen
---
 .../component/aws2/mq/MQ2ComponentConfigurer.java  |  5 +++++
 .../component/aws2/mq/MQ2EndpointConfigurer.java   |  5 +++++
 .../apache/camel/component/aws2/mq/aws2-mq.json    |  2 ++
 .../src/main/docs/aws2-mq-component.adoc           |  6 ++++--
 .../dsl/Aws2MqComponentBuilderFactory.java         | 13 ++++++++++++
 .../endpoint/dsl/MQ2EndpointBuilderFactory.java    | 24 ++++++++++++++++++++++
 6 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws2-mq/src/generated/java/org/apache/camel/component/aws2/mq/MQ2ComponentConfigurer.java b/components/camel-aws2-mq/src/generated/java/org/apache/camel/component/aws2/mq/MQ2ComponentConfigurer.java
index 940b3fc..d3f99c0 100644
--- a/components/camel-aws2-mq/src/generated/java/org/apache/camel/component/aws2/mq/MQ2ComponentConfigurer.java
+++ b/components/camel-aws2-mq/src/generated/java/org/apache/camel/component/aws2/mq/MQ2ComponentConfigurer.java
@@ -36,6 +36,8 @@ public class MQ2ComponentConfigurer extends PropertyConfigurerSupport implements
         case "lazystartproducer":
         case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
         case "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws2.mq.MQ2Operations.class, value)); return true;
+        case "pojorequest":
+        case "pojoRequest": getOrCreateConfiguration(target).setPojoRequest(property(camelContext, boolean.class, value)); return true;
         case "proxyhost":
         case "proxyHost": getOrCreateConfiguration(target).setProxyHost(property(camelContext, java.lang.String.class, value)); return true;
         case "proxyport":
@@ -58,6 +60,7 @@ public class MQ2ComponentConfigurer extends PropertyConfigurerSupport implements
         answer.put("configuration", org.apache.camel.component.aws2.mq.MQ2Configuration.class);
         answer.put("lazyStartProducer", boolean.class);
         answer.put("operation", org.apache.camel.component.aws2.mq.MQ2Operations.class);
+        answer.put("pojoRequest", boolean.class);
         answer.put("proxyHost", java.lang.String.class);
         answer.put("proxyPort", java.lang.Integer.class);
         answer.put("proxyProtocol", software.amazon.awssdk.core.Protocol.class);
@@ -80,6 +83,8 @@ public class MQ2ComponentConfigurer extends PropertyConfigurerSupport implements
         case "lazystartproducer":
         case "lazyStartProducer": return target.isLazyStartProducer();
         case "operation": return getOrCreateConfiguration(target).getOperation();
+        case "pojorequest":
+        case "pojoRequest": return getOrCreateConfiguration(target).isPojoRequest();
         case "proxyhost":
         case "proxyHost": return getOrCreateConfiguration(target).getProxyHost();
         case "proxyport":
diff --git a/components/camel-aws2-mq/src/generated/java/org/apache/camel/component/aws2/mq/MQ2EndpointConfigurer.java b/components/camel-aws2-mq/src/generated/java/org/apache/camel/component/aws2/mq/MQ2EndpointConfigurer.java
index 7e473c2..09c514e 100644
--- a/components/camel-aws2-mq/src/generated/java/org/apache/camel/component/aws2/mq/MQ2EndpointConfigurer.java
+++ b/components/camel-aws2-mq/src/generated/java/org/apache/camel/component/aws2/mq/MQ2EndpointConfigurer.java
@@ -28,6 +28,8 @@ public class MQ2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "lazystartproducer":
         case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
         case "operation": target.getConfiguration().setOperation(property(camelContext, org.apache.camel.component.aws2.mq.MQ2Operations.class, value)); return true;
+        case "pojorequest":
+        case "pojoRequest": target.getConfiguration().setPojoRequest(property(camelContext, boolean.class, value)); return true;
         case "proxyhost":
         case "proxyHost": target.getConfiguration().setProxyHost(property(camelContext, java.lang.String.class, value)); return true;
         case "proxyport":
@@ -50,6 +52,7 @@ public class MQ2EndpointConfigurer extends PropertyConfigurerSupport implements
         answer.put("basicPropertyBinding", boolean.class);
         answer.put("lazyStartProducer", boolean.class);
         answer.put("operation", org.apache.camel.component.aws2.mq.MQ2Operations.class);
+        answer.put("pojoRequest", boolean.class);
         answer.put("proxyHost", java.lang.String.class);
         answer.put("proxyPort", java.lang.Integer.class);
         answer.put("proxyProtocol", software.amazon.awssdk.core.Protocol.class);
@@ -72,6 +75,8 @@ public class MQ2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "lazystartproducer":
         case "lazyStartProducer": return target.isLazyStartProducer();
         case "operation": return target.getConfiguration().getOperation();
+        case "pojorequest":
+        case "pojoRequest": return target.getConfiguration().isPojoRequest();
         case "proxyhost":
         case "proxyHost": return target.getConfiguration().getProxyHost();
         case "proxyport":
diff --git a/components/camel-aws2-mq/src/generated/resources/org/apache/camel/component/aws2/mq/aws2-mq.json b/components/camel-aws2-mq/src/generated/resources/org/apache/camel/component/aws2/mq/aws2-mq.json
index f4e3c9c..5bcacfe 100644
--- a/components/camel-aws2-mq/src/generated/resources/org/apache/camel/component/aws2/mq/aws2-mq.json
+++ b/components/camel-aws2-mq/src/generated/resources/org/apache/camel/component/aws2/mq/aws2-mq.json
@@ -25,6 +25,7 @@
     "configuration": { "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws2.mq.MQ2Configuration", "deprecated": false, "secret": false, "description": "Component configuration" },
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the r [...]
     "operation": { "kind": "property", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.aws2.mq.MQ2Operations", "enum": [ "listBrokers", "createBroker", "deleteBroker", "rebootBroker", "updateBroker", "describeBroker" ], "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.aws2.mq.MQ2Configuration", "configurationField": "configuration", "desc [...]
+    "pojoRequest": { "kind": "property", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.mq.MQ2Configuration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" },
     "proxyHost": { "kind": "property", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.mq.MQ2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the MQ client" },
     "proxyPort": { "kind": "property", "displayName": "Proxy Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.mq.MQ2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the MQ client" },
     "proxyProtocol": { "kind": "property", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.mq.MQ2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the MQ client" },
@@ -38,6 +39,7 @@
     "amazonMqClient": { "kind": "parameter", "displayName": "Amazon Mq Client", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.mq.MqClient", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.mq.MQ2Configuration", "configurationField": "configuration", "description": "To use a existing configured AmazonMQClient as client" },
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the  [...]
     "operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.aws2.mq.MQ2Operations", "enum": [ "listBrokers", "createBroker", "deleteBroker", "rebootBroker", "updateBroker", "describeBroker" ], "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.aws2.mq.MQ2Configuration", "configurationField": "configuration", "des [...]
+    "pojoRequest": { "kind": "parameter", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.mq.MQ2Configuration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" },
     "proxyHost": { "kind": "parameter", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.mq.MQ2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the MQ client" },
     "proxyPort": { "kind": "parameter", "displayName": "Proxy Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.mq.MQ2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the MQ client" },
     "proxyProtocol": { "kind": "parameter", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.mq.MQ2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the MQ client" },
diff --git a/components/camel-aws2-mq/src/main/docs/aws2-mq-component.adoc b/components/camel-aws2-mq/src/main/docs/aws2-mq-component.adoc
index ad85cde..6d51dd9 100644
--- a/components/camel-aws2-mq/src/main/docs/aws2-mq-component.adoc
+++ b/components/camel-aws2-mq/src/main/docs/aws2-mq-component.adoc
@@ -39,7 +39,7 @@ You can append query options to the URI in the following format,
 
 
 // component options: START
-The AWS 2 MQ component supports 11 options, which are listed below.
+The AWS 2 MQ component supports 12 options, which are listed below.
 
 
 
@@ -50,6 +50,7 @@ The AWS 2 MQ component supports 11 options, which are listed below.
 | *configuration* (producer) | Component configuration |  | MQ2Configuration
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *operation* (producer) | *Required* The operation to perform. It can be listBrokers,createBroker,deleteBroker. The value can be one of: listBrokers, createBroker, deleteBroker, rebootBroker, updateBroker, describeBroker |  | MQ2Operations
+| *pojoRequest* (producer) | If we want to use a POJO request as body or not | false | boolean
 | *proxyHost* (producer) | To define a proxy host when instantiating the MQ client |  | String
 | *proxyPort* (producer) | To define a proxy port when instantiating the MQ client |  | Integer
 | *proxyProtocol* (producer) | To define a proxy protocol when instantiating the MQ client. The value can be one of: HTTP, HTTPS | HTTPS | Protocol
@@ -82,7 +83,7 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (11 parameters):
+=== Query Parameters (12 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -91,6 +92,7 @@ with the following path and query parameters:
 | *amazonMqClient* (producer) | To use a existing configured AmazonMQClient as client |  | MqClient
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *operation* (producer) | *Required* The operation to perform. It can be listBrokers,createBroker,deleteBroker. The value can be one of: listBrokers, createBroker, deleteBroker, rebootBroker, updateBroker, describeBroker |  | MQ2Operations
+| *pojoRequest* (producer) | If we want to use a POJO request as body or not | false | boolean
 | *proxyHost* (producer) | To define a proxy host when instantiating the MQ client |  | String
 | *proxyPort* (producer) | To define a proxy port when instantiating the MQ client |  | Integer
 | *proxyProtocol* (producer) | To define a proxy protocol when instantiating the MQ client. The value can be one of: HTTP, HTTPS | HTTPS | Protocol
diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2MqComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2MqComponentBuilderFactory.java
index 1e046dc..a93cf76 100644
--- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2MqComponentBuilderFactory.java
+++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2MqComponentBuilderFactory.java
@@ -109,6 +109,18 @@ public interface Aws2MqComponentBuilderFactory {
             return this;
         }
         /**
+         * If we want to use a POJO request as body or not.
+         * 
+         * The option is a: <code>boolean</code> type.
+         * 
+         * Default: false
+         * Group: producer
+         */
+        default Aws2MqComponentBuilder pojoRequest(boolean pojoRequest) {
+            doSetProperty("pojoRequest", pojoRequest);
+            return this;
+        }
+        /**
          * To define a proxy host when instantiating the MQ client.
          * 
          * The option is a: <code>java.lang.String</code> type.
@@ -222,6 +234,7 @@ public interface Aws2MqComponentBuilderFactory {
             case "configuration": ((MQ2Component) component).setConfiguration((org.apache.camel.component.aws2.mq.MQ2Configuration) value); return true;
             case "lazyStartProducer": ((MQ2Component) component).setLazyStartProducer((boolean) value); return true;
             case "operation": getOrCreateConfiguration((MQ2Component) component).setOperation((org.apache.camel.component.aws2.mq.MQ2Operations) value); return true;
+            case "pojoRequest": getOrCreateConfiguration((MQ2Component) component).setPojoRequest((boolean) value); return true;
             case "proxyHost": getOrCreateConfiguration((MQ2Component) component).setProxyHost((java.lang.String) value); return true;
             case "proxyPort": getOrCreateConfiguration((MQ2Component) component).setProxyPort((java.lang.Integer) value); return true;
             case "proxyProtocol": getOrCreateConfiguration((MQ2Component) component).setProxyProtocol((software.amazon.awssdk.core.Protocol) value); return true;
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MQ2EndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MQ2EndpointBuilderFactory.java
index 7e64566..91e2576 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MQ2EndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MQ2EndpointBuilderFactory.java
@@ -130,6 +130,30 @@ public interface MQ2EndpointBuilderFactory {
             return this;
         }
         /**
+         * If we want to use a POJO request as body or not.
+         * 
+         * The option is a: <code>boolean</code> type.
+         * 
+         * Default: false
+         * Group: producer
+         */
+        default MQ2EndpointBuilder pojoRequest(boolean pojoRequest) {
+            doSetProperty("pojoRequest", pojoRequest);
+            return this;
+        }
+        /**
+         * If we want to use a POJO request as body or not.
+         * 
+         * The option will be converted to a <code>boolean</code> type.
+         * 
+         * Default: false
+         * Group: producer
+         */
+        default MQ2EndpointBuilder pojoRequest(String pojoRequest) {
+            doSetProperty("pojoRequest", pojoRequest);
+            return this;
+        }
+        /**
          * To define a proxy host when instantiating the MQ client.
          * 
          * The option is a: <code>java.lang.String</code> type.


[camel] 01/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq list brokers

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 19e9b25897925178f278923c7e4f89e6b5a68cca
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 15 12:36:55 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq list brokers
---
 .../camel/component/aws2/mq/MQ2Configuration.java    | 13 +++++++++++++
 .../apache/camel/component/aws2/mq/MQ2Producer.java  | 20 +++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Configuration.java b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Configuration.java
index 32efa04..2128ab2 100644
--- a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Configuration.java
+++ b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Configuration.java
@@ -47,6 +47,8 @@ public class MQ2Configuration implements Cloneable {
     private Integer proxyPort;
     @UriParam
     private String region;
+    @UriParam(defaultValue = "false")
+    private boolean pojoRequest;
 
     public MqClient getAmazonMqClient() {
         return amazonMqClient;
@@ -138,6 +140,17 @@ public class MQ2Configuration implements Cloneable {
     public void setRegion(String region) {
         this.region = region;
     }
+    
+    public boolean isPojoRequest() {
+        return pojoRequest;
+    }
+
+    /**
+     * If we want to use a POJO request as body or not
+     */
+    public void setPojoRequest(boolean pojoRequest) {
+        this.pojoRequest = pojoRequest;
+    }
 
     // *************************************************
     //
diff --git a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
index c10bec6..d9a769d 100644
--- a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
+++ b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
@@ -20,6 +20,7 @@ import java.util.List;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.Message;
 import org.apache.camel.support.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
@@ -27,6 +28,8 @@ import org.apache.camel.util.URISupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import software.amazon.awssdk.awscore.exception.AwsServiceException;
+import software.amazon.awssdk.services.kms.model.ListKeysRequest;
+import software.amazon.awssdk.services.kms.model.ListKeysResponse;
 import software.amazon.awssdk.services.mq.MqClient;
 import software.amazon.awssdk.services.mq.model.ConfigurationId;
 import software.amazon.awssdk.services.mq.model.CreateBrokerRequest;
@@ -110,7 +113,21 @@ public class MQ2Producer extends DefaultProducer {
         return (MQ2Endpoint)super.getEndpoint();
     }
 
-    private void listBrokers(MqClient mqClient, Exchange exchange) {
+    private void listBrokers(MqClient mqClient, Exchange exchange) throws InvalidPayloadException {
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof ListBrokersRequest) {
+                ListBrokersResponse result;
+                try {
+                    result = mqClient.listBrokers((ListBrokersRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("List Brokers command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         ListBrokersRequest.Builder builder = ListBrokersRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.MAX_RESULTS))) {
             int maxResults = exchange.getIn().getHeader(MQ2Constants.MAX_RESULTS, Integer.class);
@@ -125,6 +142,7 @@ public class MQ2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     @SuppressWarnings("unchecked")


[camel] 10/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq regen docs website

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 2dafbed3a9a5cd8558a0b5a4985e1c0ab4de1159
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 15 12:48:45 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq regen docs website
---
 docs/components/modules/ROOT/pages/aws2-mq-component.adoc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/docs/components/modules/ROOT/pages/aws2-mq-component.adoc b/docs/components/modules/ROOT/pages/aws2-mq-component.adoc
index ee31559..ac3129d 100644
--- a/docs/components/modules/ROOT/pages/aws2-mq-component.adoc
+++ b/docs/components/modules/ROOT/pages/aws2-mq-component.adoc
@@ -41,7 +41,7 @@ You can append query options to the URI in the following format,
 
 
 // component options: START
-The AWS 2 MQ component supports 11 options, which are listed below.
+The AWS 2 MQ component supports 12 options, which are listed below.
 
 
 
@@ -52,6 +52,7 @@ The AWS 2 MQ component supports 11 options, which are listed below.
 | *configuration* (producer) | Component configuration |  | MQ2Configuration
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *operation* (producer) | *Required* The operation to perform. It can be listBrokers,createBroker,deleteBroker. The value can be one of: listBrokers, createBroker, deleteBroker, rebootBroker, updateBroker, describeBroker |  | MQ2Operations
+| *pojoRequest* (producer) | If we want to use a POJO request as body or not | false | boolean
 | *proxyHost* (producer) | To define a proxy host when instantiating the MQ client |  | String
 | *proxyPort* (producer) | To define a proxy port when instantiating the MQ client |  | Integer
 | *proxyProtocol* (producer) | To define a proxy protocol when instantiating the MQ client. The value can be one of: HTTP, HTTPS | HTTPS | Protocol
@@ -84,7 +85,7 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (11 parameters):
+=== Query Parameters (12 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -93,6 +94,7 @@ with the following path and query parameters:
 | *amazonMqClient* (producer) | To use a existing configured AmazonMQClient as client |  | MqClient
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *operation* (producer) | *Required* The operation to perform. It can be listBrokers,createBroker,deleteBroker. The value can be one of: listBrokers, createBroker, deleteBroker, rebootBroker, updateBroker, describeBroker |  | MQ2Operations
+| *pojoRequest* (producer) | If we want to use a POJO request as body or not | false | boolean
 | *proxyHost* (producer) | To define a proxy host when instantiating the MQ client |  | String
 | *proxyPort* (producer) | To define a proxy port when instantiating the MQ client |  | Integer
 | *proxyProtocol* (producer) | To define a proxy protocol when instantiating the MQ client. The value can be one of: HTTP, HTTPS | HTTPS | Protocol


[camel] 08/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq fixed CS

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 94eb3c5b7926e3b295a29f319c17df80aeab1181
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 15 12:47:01 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq fixed CS
---
 .../camel/component/aws2/mq/MQ2Producer.java       | 284 ++++++++++-----------
 1 file changed, 142 insertions(+), 142 deletions(-)

diff --git a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
index 052e523..9992337 100644
--- a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
+++ b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
@@ -117,7 +117,7 @@ public class MQ2Producer extends DefaultProducer {
             if (payload instanceof ListBrokersRequest) {
                 ListBrokersResponse result;
                 try {
-                    result = mqClient.listBrokers((ListBrokersRequest) payload);
+                    result = mqClient.listBrokers((ListBrokersRequest)payload);
                 } catch (AwsServiceException ase) {
                     LOG.trace("List Brokers command returned the error code {}", ase.awsErrorDetails().errorCode());
                     throw ase;
@@ -126,20 +126,20 @@ public class MQ2Producer extends DefaultProducer {
                 message.setBody(result);
             }
         } else {
-        ListBrokersRequest.Builder builder = ListBrokersRequest.builder();
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.MAX_RESULTS))) {
-            int maxResults = exchange.getIn().getHeader(MQ2Constants.MAX_RESULTS, Integer.class);
-            builder.maxResults(maxResults);
-        }
-        ListBrokersResponse result;
-        try {
-            result = mqClient.listBrokers(builder.build());
-        } catch (AwsServiceException ase) {
-            LOG.trace("List Brokers command returned the error code {}", ase.awsErrorDetails().errorCode());
-            throw ase;
-        }
-        Message message = getMessageForResponse(exchange);
-        message.setBody(result);
+            ListBrokersRequest.Builder builder = ListBrokersRequest.builder();
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.MAX_RESULTS))) {
+                int maxResults = exchange.getIn().getHeader(MQ2Constants.MAX_RESULTS, Integer.class);
+                builder.maxResults(maxResults);
+            }
+            ListBrokersResponse result;
+            try {
+                result = mqClient.listBrokers(builder.build());
+            } catch (AwsServiceException ase) {
+                LOG.trace("List Brokers command returned the error code {}", ase.awsErrorDetails().errorCode());
+                throw ase;
+            }
+            Message message = getMessageForResponse(exchange);
+            message.setBody(result);
         }
     }
 
@@ -157,7 +157,7 @@ public class MQ2Producer extends DefaultProducer {
             if (payload instanceof CreateBrokerRequest) {
                 CreateBrokerResponse result;
                 try {
-                    result = mqClient.createBroker((CreateBrokerRequest) payload);
+                    result = mqClient.createBroker((CreateBrokerRequest)payload);
                 } catch (AwsServiceException ase) {
                     LOG.trace("Create Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
                     throw ase;
@@ -166,58 +166,58 @@ public class MQ2Producer extends DefaultProducer {
                 message.setBody(result);
             }
         } else {
-        CreateBrokerRequest.Builder builder = CreateBrokerRequest.builder();
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_NAME))) {
-            brokerName = exchange.getIn().getHeader(MQ2Constants.BROKER_NAME, String.class);
-            builder.brokerName(brokerName);
-        } else {
-            throw new IllegalArgumentException("Broker Name must be specified");
-        }
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ENGINE))) {
-            brokerEngine = exchange.getIn().getHeader(MQ2Constants.BROKER_ENGINE, String.class);
-            builder.engineType(EngineType.fromValue(brokerEngine));
-        } else {
-            builder.engineType(EngineType.ACTIVEMQ.name());
-        }
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ENGINE_VERSION))) {
-            brokerEngineVersion = exchange.getIn().getHeader(MQ2Constants.BROKER_ENGINE_VERSION, String.class);
-            builder.engineVersion(brokerEngineVersion);
-        } else {
-            throw new IllegalArgumentException("Broker Engine Version must be specified");
-        }
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_DEPLOYMENT_MODE))) {
-            deploymentMode = exchange.getIn().getHeader(MQ2Constants.BROKER_DEPLOYMENT_MODE, String.class);
-            builder.deploymentMode(DeploymentMode.fromValue(deploymentMode));
-        } else {
-            throw new IllegalArgumentException("Deployment Mode must be specified");
-        }
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_INSTANCE_TYPE))) {
-            instanceType = exchange.getIn().getHeader(MQ2Constants.BROKER_INSTANCE_TYPE, String.class);
-            builder.hostInstanceType(instanceType);
-        } else {
-            throw new IllegalArgumentException("Instance Type must be specified");
-        }
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_USERS))) {
-            users = exchange.getIn().getHeader(MQ2Constants.BROKER_USERS, List.class);
-            builder.users(users);
-        } else {
-            throw new IllegalArgumentException("A Users list must be specified");
-        }
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_PUBLICLY_ACCESSIBLE))) {
-            publiclyAccessible = exchange.getIn().getHeader(MQ2Constants.BROKER_PUBLICLY_ACCESSIBLE, Boolean.class);
-            builder.publiclyAccessible(publiclyAccessible);
-        } else {
-            builder.publiclyAccessible(false);
-        }
-        CreateBrokerResponse result;
-        try {
-            result = mqClient.createBroker(builder.build());
-        } catch (AwsServiceException ase) {
-            LOG.trace("Create Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
-            throw ase;
-        }
-        Message message = getMessageForResponse(exchange);
-        message.setBody(result);
+            CreateBrokerRequest.Builder builder = CreateBrokerRequest.builder();
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_NAME))) {
+                brokerName = exchange.getIn().getHeader(MQ2Constants.BROKER_NAME, String.class);
+                builder.brokerName(brokerName);
+            } else {
+                throw new IllegalArgumentException("Broker Name must be specified");
+            }
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ENGINE))) {
+                brokerEngine = exchange.getIn().getHeader(MQ2Constants.BROKER_ENGINE, String.class);
+                builder.engineType(EngineType.fromValue(brokerEngine));
+            } else {
+                builder.engineType(EngineType.ACTIVEMQ.name());
+            }
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ENGINE_VERSION))) {
+                brokerEngineVersion = exchange.getIn().getHeader(MQ2Constants.BROKER_ENGINE_VERSION, String.class);
+                builder.engineVersion(brokerEngineVersion);
+            } else {
+                throw new IllegalArgumentException("Broker Engine Version must be specified");
+            }
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_DEPLOYMENT_MODE))) {
+                deploymentMode = exchange.getIn().getHeader(MQ2Constants.BROKER_DEPLOYMENT_MODE, String.class);
+                builder.deploymentMode(DeploymentMode.fromValue(deploymentMode));
+            } else {
+                throw new IllegalArgumentException("Deployment Mode must be specified");
+            }
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_INSTANCE_TYPE))) {
+                instanceType = exchange.getIn().getHeader(MQ2Constants.BROKER_INSTANCE_TYPE, String.class);
+                builder.hostInstanceType(instanceType);
+            } else {
+                throw new IllegalArgumentException("Instance Type must be specified");
+            }
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_USERS))) {
+                users = exchange.getIn().getHeader(MQ2Constants.BROKER_USERS, List.class);
+                builder.users(users);
+            } else {
+                throw new IllegalArgumentException("A Users list must be specified");
+            }
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_PUBLICLY_ACCESSIBLE))) {
+                publiclyAccessible = exchange.getIn().getHeader(MQ2Constants.BROKER_PUBLICLY_ACCESSIBLE, Boolean.class);
+                builder.publiclyAccessible(publiclyAccessible);
+            } else {
+                builder.publiclyAccessible(false);
+            }
+            CreateBrokerResponse result;
+            try {
+                result = mqClient.createBroker(builder.build());
+            } catch (AwsServiceException ase) {
+                LOG.trace("Create Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
+                throw ase;
+            }
+            Message message = getMessageForResponse(exchange);
+            message.setBody(result);
         }
     }
 
@@ -228,7 +228,7 @@ public class MQ2Producer extends DefaultProducer {
             if (payload instanceof DeleteBrokerRequest) {
                 DeleteBrokerResponse result;
                 try {
-                    result = mqClient.deleteBroker((DeleteBrokerRequest) payload);
+                    result = mqClient.deleteBroker((DeleteBrokerRequest)payload);
                 } catch (AwsServiceException ase) {
                     LOG.trace("Delete Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
                     throw ase;
@@ -237,22 +237,22 @@ public class MQ2Producer extends DefaultProducer {
                 message.setBody(result);
             }
         } else {
-        DeleteBrokerRequest.Builder builder = DeleteBrokerRequest.builder();
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ID))) {
-            brokerId = exchange.getIn().getHeader(MQ2Constants.BROKER_ID, String.class);
-            builder.brokerId(brokerId);
-        } else {
-            throw new IllegalArgumentException("Broker Name must be specified");
-        }
-        DeleteBrokerResponse result;
-        try {
-            result = mqClient.deleteBroker(builder.build());
-        } catch (AwsServiceException ase) {
-            LOG.trace("Delete Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
-            throw ase;
-        }
-        Message message = getMessageForResponse(exchange);
-        message.setBody(result);
+            DeleteBrokerRequest.Builder builder = DeleteBrokerRequest.builder();
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ID))) {
+                brokerId = exchange.getIn().getHeader(MQ2Constants.BROKER_ID, String.class);
+                builder.brokerId(brokerId);
+            } else {
+                throw new IllegalArgumentException("Broker Name must be specified");
+            }
+            DeleteBrokerResponse result;
+            try {
+                result = mqClient.deleteBroker(builder.build());
+            } catch (AwsServiceException ase) {
+                LOG.trace("Delete Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
+                throw ase;
+            }
+            Message message = getMessageForResponse(exchange);
+            message.setBody(result);
         }
     }
 
@@ -263,7 +263,7 @@ public class MQ2Producer extends DefaultProducer {
             if (payload instanceof RebootBrokerRequest) {
                 RebootBrokerResponse result;
                 try {
-                    result = mqClient.rebootBroker((RebootBrokerRequest) payload);
+                    result = mqClient.rebootBroker((RebootBrokerRequest)payload);
                 } catch (AwsServiceException ase) {
                     LOG.trace("Reboot Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
                     throw ase;
@@ -272,22 +272,22 @@ public class MQ2Producer extends DefaultProducer {
                 message.setBody(result);
             }
         } else {
-        RebootBrokerRequest.Builder builder = RebootBrokerRequest.builder();
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ID))) {
-            brokerId = exchange.getIn().getHeader(MQ2Constants.BROKER_ID, String.class);
-            builder.brokerId(brokerId);
-        } else {
-            throw new IllegalArgumentException("Broker Name must be specified");
-        }
-        RebootBrokerResponse result;
-        try {
-            result = mqClient.rebootBroker(builder.build());
-        } catch (AwsServiceException ase) {
-            LOG.trace("Reboot Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
-            throw ase;
-        }
-        Message message = getMessageForResponse(exchange);
-        message.setBody(result);
+            RebootBrokerRequest.Builder builder = RebootBrokerRequest.builder();
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ID))) {
+                brokerId = exchange.getIn().getHeader(MQ2Constants.BROKER_ID, String.class);
+                builder.brokerId(brokerId);
+            } else {
+                throw new IllegalArgumentException("Broker Name must be specified");
+            }
+            RebootBrokerResponse result;
+            try {
+                result = mqClient.rebootBroker(builder.build());
+            } catch (AwsServiceException ase) {
+                LOG.trace("Reboot Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
+                throw ase;
+            }
+            Message message = getMessageForResponse(exchange);
+            message.setBody(result);
         }
     }
 
@@ -299,7 +299,7 @@ public class MQ2Producer extends DefaultProducer {
             if (payload instanceof UpdateBrokerRequest) {
                 UpdateBrokerResponse result;
                 try {
-                    result = mqClient.updateBroker((UpdateBrokerRequest) payload);
+                    result = mqClient.updateBroker((UpdateBrokerRequest)payload);
                 } catch (AwsServiceException ase) {
                     LOG.trace("Update Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
                     throw ase;
@@ -308,28 +308,28 @@ public class MQ2Producer extends DefaultProducer {
                 message.setBody(result);
             }
         } else {
-        UpdateBrokerRequest.Builder builder = UpdateBrokerRequest.builder();
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ID))) {
-            brokerId = exchange.getIn().getHeader(MQ2Constants.BROKER_ID, String.class);
-            builder.brokerId(brokerId);
-        } else {
-            throw new IllegalArgumentException("Broker Name must be specified");
-        }
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.CONFIGURATION_ID))) {
-            configurationId = exchange.getIn().getHeader(MQ2Constants.CONFIGURATION_ID, ConfigurationId.class);
-            builder.configuration(configurationId);
-        } else {
-            throw new IllegalArgumentException("Broker Name must be specified");
-        }
-        UpdateBrokerResponse result;
-        try {
-            result = mqClient.updateBroker(builder.build());
-        } catch (AwsServiceException ase) {
-            LOG.trace("Update Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
-            throw ase;
-        }
-        Message message = getMessageForResponse(exchange);
-        message.setBody(result);
+            UpdateBrokerRequest.Builder builder = UpdateBrokerRequest.builder();
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ID))) {
+                brokerId = exchange.getIn().getHeader(MQ2Constants.BROKER_ID, String.class);
+                builder.brokerId(brokerId);
+            } else {
+                throw new IllegalArgumentException("Broker Name must be specified");
+            }
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.CONFIGURATION_ID))) {
+                configurationId = exchange.getIn().getHeader(MQ2Constants.CONFIGURATION_ID, ConfigurationId.class);
+                builder.configuration(configurationId);
+            } else {
+                throw new IllegalArgumentException("Broker Name must be specified");
+            }
+            UpdateBrokerResponse result;
+            try {
+                result = mqClient.updateBroker(builder.build());
+            } catch (AwsServiceException ase) {
+                LOG.trace("Update Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
+                throw ase;
+            }
+            Message message = getMessageForResponse(exchange);
+            message.setBody(result);
         }
     }
 
@@ -340,7 +340,7 @@ public class MQ2Producer extends DefaultProducer {
             if (payload instanceof DescribeBrokerRequest) {
                 DescribeBrokerResponse result;
                 try {
-                    result = mqClient.describeBroker((DescribeBrokerRequest) payload);
+                    result = mqClient.describeBroker((DescribeBrokerRequest)payload);
                 } catch (AwsServiceException ase) {
                     LOG.trace("Reboot Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
                     throw ase;
@@ -349,22 +349,22 @@ public class MQ2Producer extends DefaultProducer {
                 message.setBody(result);
             }
         } else {
-        DescribeBrokerRequest.Builder builder = DescribeBrokerRequest.builder();
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ID))) {
-            brokerId = exchange.getIn().getHeader(MQ2Constants.BROKER_ID, String.class);
-            builder.brokerId(brokerId);
-        } else {
-            throw new IllegalArgumentException("Broker Name must be specified");
-        }
-        DescribeBrokerResponse result;
-        try {
-            result = mqClient.describeBroker(builder.build());
-        } catch (AwsServiceException ase) {
-            LOG.trace("Reboot Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
-            throw ase;
-        }
-        Message message = getMessageForResponse(exchange);
-        message.setBody(result);
+            DescribeBrokerRequest.Builder builder = DescribeBrokerRequest.builder();
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ID))) {
+                brokerId = exchange.getIn().getHeader(MQ2Constants.BROKER_ID, String.class);
+                builder.brokerId(brokerId);
+            } else {
+                throw new IllegalArgumentException("Broker Name must be specified");
+            }
+            DescribeBrokerResponse result;
+            try {
+                result = mqClient.describeBroker(builder.build());
+            } catch (AwsServiceException ase) {
+                LOG.trace("Reboot Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
+                throw ase;
+            }
+            Message message = getMessageForResponse(exchange);
+            message.setBody(result);
         }
     }
 


[camel] 04/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq delete broker

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 937cdbe61ddf2e371e598a7f9556656039817dc2
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 15 12:40:19 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-mq delete broker
---
 .../org/apache/camel/component/aws2/mq/MQ2Producer.java | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
index 45e9e16..fae6804 100644
--- a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
+++ b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
@@ -221,8 +221,22 @@ public class MQ2Producer extends DefaultProducer {
         }
     }
 
-    private void deleteBroker(MqClient mqClient, Exchange exchange) {
+    private void deleteBroker(MqClient mqClient, Exchange exchange) throws InvalidPayloadException {
         String brokerId;
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof DeleteBrokerRequest) {
+                DeleteBrokerResponse result;
+                try {
+                    result = mqClient.deleteBroker((DeleteBrokerRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Delete Broker command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         DeleteBrokerRequest.Builder builder = DeleteBrokerRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQ2Constants.BROKER_ID))) {
             brokerId = exchange.getIn().getHeader(MQ2Constants.BROKER_ID, String.class);
@@ -239,6 +253,7 @@ public class MQ2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     private void rebootBroker(MqClient mqClient, Exchange exchange) {


[camel] 03/10: CAMEL-14868 - Fixed build aws2-mq

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0626d3d9c0423f83351722289494eb29b1a6e505
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 15 12:39:13 2020 +0200

    CAMEL-14868 - Fixed build aws2-mq
---
 .../src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java   | 2 --
 1 file changed, 2 deletions(-)

diff --git a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
index 0cd5a89..45e9e16 100644
--- a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
+++ b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
@@ -28,8 +28,6 @@ import org.apache.camel.util.URISupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import software.amazon.awssdk.awscore.exception.AwsServiceException;
-import software.amazon.awssdk.services.kms.model.ListKeysRequest;
-import software.amazon.awssdk.services.kms.model.ListKeysResponse;
 import software.amazon.awssdk.services.mq.MqClient;
 import software.amazon.awssdk.services.mq.model.ConfigurationId;
 import software.amazon.awssdk.services.mq.model.CreateBrokerRequest;