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


The following commit(s) were added to refs/heads/master by this push:
     new 2acf4a5  CAMEL-14568 - Fixed AWS Translate
2acf4a5 is described below

commit 2acf4a53b4eceeccf99906270fcfe2780d37f3e6
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Fri Feb 28 17:00:11 2020 +0100

    CAMEL-14568 - Fixed AWS Translate
---
 .../translate/TranslateComponentConfigurer.java    |  7 ++--
 .../component/aws/translate/aws-translate.json     |  8 ++--
 .../src/main/docs/aws-translate-component.adoc     |  2 +-
 .../aws/translate/TranslateComponent.java          | 46 +---------------------
 .../dsl/AwsTranslateComponentBuilderFactory.java   | 32 +++++++--------
 5 files changed, 26 insertions(+), 69 deletions(-)

diff --git 
a/components/camel-aws-translate/src/generated/java/org/apache/camel/component/aws/translate/TranslateComponentConfigurer.java
 
b/components/camel-aws-translate/src/generated/java/org/apache/camel/component/aws/translate/TranslateComponentConfigurer.java
index c418b63..2eb2f70 100644
--- 
a/components/camel-aws-translate/src/generated/java/org/apache/camel/component/aws/translate/TranslateComponentConfigurer.java
+++ 
b/components/camel-aws-translate/src/generated/java/org/apache/camel/component/aws/translate/TranslateComponentConfigurer.java
@@ -23,9 +23,10 @@ public class TranslateComponentConfigurer extends 
PropertyConfigurerSupport impl
         TranslateComponent target = (TranslateComponent) obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "accesskey":
-        case "accessKey": target.setAccessKey(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "accessKey": 
getOrCreateConfiguration(target).setAccessKey(property(camelContext, 
java.lang.String.class, value)); return true;
         case "autodetectsourcelanguage":
         case "autodetectSourceLanguage": 
getOrCreateConfiguration(target).setAutodetectSourceLanguage(property(camelContext,
 boolean.class, value)); return true;
+        case "configuration": target.setConfiguration(property(camelContext, 
org.apache.camel.component.aws.translate.TranslateConfiguration.class, value)); 
return true;
         case "lazystartproducer":
         case "lazyStartProducer": 
target.setLazyStartProducer(property(camelContext, boolean.class, value)); 
return true;
         case "operation": 
getOrCreateConfiguration(target).setOperation(property(camelContext, 
org.apache.camel.component.aws.translate.TranslateOperations.class, value)); 
return true;
@@ -35,10 +36,9 @@ public class TranslateComponentConfigurer extends 
PropertyConfigurerSupport impl
         case "proxyPort": 
getOrCreateConfiguration(target).setProxyPort(property(camelContext, 
java.lang.Integer.class, value)); return true;
         case "proxyprotocol":
         case "proxyProtocol": 
getOrCreateConfiguration(target).setProxyProtocol(property(camelContext, 
com.amazonaws.Protocol.class, value)); return true;
-        case "region": target.setRegion(property(camelContext, 
java.lang.String.class, value)); return true;
         case "region": 
getOrCreateConfiguration(target).setRegion(property(camelContext, 
java.lang.String.class, value)); return true;
         case "secretkey":
-        case "secretKey": target.setSecretKey(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "secretKey": 
getOrCreateConfiguration(target).setSecretKey(property(camelContext, 
java.lang.String.class, value)); return true;
         case "sourcelanguage":
         case "sourceLanguage": 
getOrCreateConfiguration(target).setSourceLanguage(property(camelContext, 
java.lang.String.class, value)); return true;
         case "targetlanguage":
@@ -47,7 +47,6 @@ public class TranslateComponentConfigurer extends 
PropertyConfigurerSupport impl
         case "translateClient": 
getOrCreateConfiguration(target).setTranslateClient(property(camelContext, 
com.amazonaws.services.translate.AmazonTranslate.class, value)); return true;
         case "basicpropertybinding":
         case "basicPropertyBinding": 
target.setBasicPropertyBinding(property(camelContext, boolean.class, value)); 
return true;
-        case "configuration": target.setConfiguration(property(camelContext, 
org.apache.camel.component.aws.translate.TranslateConfiguration.class, value)); 
return true;
         default: return false;
         }
     }
diff --git 
a/components/camel-aws-translate/src/generated/resources/org/apache/camel/component/aws/translate/aws-translate.json
 
b/components/camel-aws-translate/src/generated/resources/org/apache/camel/component/aws/translate/aws-translate.json
index f03617e..f52c251 100644
--- 
a/components/camel-aws-translate/src/generated/resources/org/apache/camel/component/aws/translate/aws-translate.json
+++ 
b/components/camel-aws-translate/src/generated/resources/org/apache/camel/component/aws/translate/aws-translate.json
@@ -19,20 +19,20 @@
     "version": "3.2.0-SNAPSHOT"
   },
   "componentProperties": {
-    "accessKey": { "kind": "property", "displayName": "Access Key", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "secret": false, "description": 
"Amazon AWS Access Key" },
+    "accessKey": { "kind": "property", "displayName": "Access Key", "group": 
"producer", "label": "producer", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "secret": true, 
"configurationClass": 
"org.apache.camel.component.aws.translate.TranslateConfiguration", 
"configurationField": "configuration", "description": "Amazon AWS Access Key" },
     "autodetectSourceLanguage": { "kind": "property", "displayName": 
"Autodetect Source Language", "group": "producer", "label": "producer", 
"required": false, "type": "boolean", "javaType": "boolean", "deprecated": 
false, "secret": false, "defaultValue": "false", "configurationClass": 
"org.apache.camel.component.aws.translate.TranslateConfiguration", 
"configurationField": "configuration", "description": "Being able to autodetect 
the source language" },
+    "configuration": { "kind": "property", "displayName": "Configuration", 
"group": "producer", "label": "", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.aws.translate.TranslateConfiguration", 
"deprecated": false, "secret": false, "description": "The 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": "producer", "required": true, "type": "object", 
"javaType": "org.apache.camel.component.aws.translate.TranslateOperations", 
"enum": [ "translateText" ], "deprecated": false, "deprecationNote": "", 
"secret": false, "defaultValue": "translateText", "configurationClass": 
"org.apache.camel.component.aws.translate.TranslateConfiguration", 
"configurationField": "configuration", "description": "The  [...]
     "proxyHost": { "kind": "property", "displayName": "Proxy Host", "group": 
"producer", "label": "producer", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.aws.translate.TranslateConfiguration", 
"configurationField": "configuration", "description": "To define a proxy host 
when instantiating the Translate client" },
     "proxyPort": { "kind": "property", "displayName": "Proxy Port", "group": 
"producer", "label": "producer", "required": false, "type": "integer", 
"javaType": "java.lang.Integer", "deprecated": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.aws.translate.TranslateConfiguration", 
"configurationField": "configuration", "description": "To define a proxy port 
when instantiating the Translate client" },
     "proxyProtocol": { "kind": "property", "displayName": "Proxy Protocol", 
"group": "producer", "label": "", "required": false, "type": "object", 
"javaType": "com.amazonaws.Protocol", "enum": [ "HTTP", "HTTPS" ], 
"deprecated": false, "secret": false, "defaultValue": "HTTPS", 
"configurationClass": 
"org.apache.camel.component.aws.translate.TranslateConfiguration", 
"configurationField": "configuration", "description": "To define a proxy 
protocol when instantiating the Translate client" },
     "region": { "kind": "property", "displayName": "Region", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "secret": false, "configurationClass": 
"org.apache.camel.component.aws.translate.TranslateConfiguration", 
"configurationField": "configuration", "description": "The region in which 
Translate client needs to work. When using this parameter, the configuration 
will expect the capitalized name of the region (f [...]
-    "secretKey": { "kind": "property", "displayName": "Secret Key", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "secret": false, "description": 
"Amazon AWS Secret Key" },
+    "secretKey": { "kind": "property", "displayName": "Secret Key", "group": 
"producer", "label": "producer", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "secret": true, 
"configurationClass": 
"org.apache.camel.component.aws.translate.TranslateConfiguration", 
"configurationField": "configuration", "description": "Amazon AWS Secret Key" },
     "sourceLanguage": { "kind": "property", "displayName": "Source Language", 
"group": "producer", "label": "producer", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.aws.translate.TranslateConfiguration", 
"configurationField": "configuration", "description": "Source language to use" 
},
     "targetLanguage": { "kind": "property", "displayName": "Target Language", 
"group": "producer", "label": "producer", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.aws.translate.TranslateConfiguration", 
"configurationField": "configuration", "description": "Target language to use" 
},
     "translateClient": { "kind": "property", "displayName": "Translate 
Client", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "com.amazonaws.services.translate.AmazonTranslate", 
"deprecated": false, "secret": false, "configurationClass": 
"org.apache.camel.component.aws.translate.TranslateConfiguration", 
"configurationField": "configuration", "description": "To use a existing 
configured AWS Translate as client" },
-    "basicPropertyBinding": { "kind": "property", "displayName": "Basic 
Property Binding", "group": "advanced", "label": "advanced", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, 
"defaultValue": false, "description": "Whether the component should use basic 
property binding (Camel 2.x) or the newer property binding with additional 
capabilities" },
-    "configuration": { "kind": "property", "displayName": "Configuration", 
"group": "advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.aws.translate.TranslateConfiguration", 
"deprecated": false, "secret": false, "description": "The AWS Translate default 
configuration" }
+    "basicPropertyBinding": { "kind": "property", "displayName": "Basic 
Property Binding", "group": "advanced", "label": "advanced", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, 
"defaultValue": false, "description": "Whether the component should use basic 
property binding (Camel 2.x) or the newer property binding with additional 
capabilities" }
   },
   "properties": {
     "label": { "kind": "path", "displayName": "Label", "group": "producer", 
"label": "", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "deprecationNote": "", "secret": 
false, "configurationClass": 
"org.apache.camel.component.aws.translate.TranslateConfiguration", 
"configurationField": "configuration", "description": "Logical name" },
diff --git 
a/components/camel-aws-translate/src/main/docs/aws-translate-component.adoc 
b/components/camel-aws-translate/src/main/docs/aws-translate-component.adoc
index 4b77c5b..47b8471 100644
--- a/components/camel-aws-translate/src/main/docs/aws-translate-component.adoc
+++ b/components/camel-aws-translate/src/main/docs/aws-translate-component.adoc
@@ -39,6 +39,7 @@ The AWS Translate component supports 14 options, which are 
listed below.
 | Name | Description | Default | Type
 | *accessKey* (producer) | Amazon AWS Access Key |  | String
 | *autodetectSourceLanguage* (producer) | Being able to autodetect the source 
language | false | boolean
+| *configuration* (producer) | The component configuration |  | 
TranslateConfiguration
 | *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. The value can 
be one of: translateText | translateText | TranslateOperations
 | *proxyHost* (producer) | To define a proxy host when instantiating the 
Translate client |  | String
@@ -50,7 +51,6 @@ The AWS Translate component supports 14 options, which are 
listed below.
 | *targetLanguage* (producer) | Target language to use |  | String
 | *translateClient* (producer) | To use a existing configured AWS Translate as 
client |  | AmazonTranslate
 | *basicPropertyBinding* (advanced) | Whether the component should use basic 
property binding (Camel 2.x) or the newer property binding with additional 
capabilities | false | boolean
-| *configuration* (advanced) | The AWS Translate default configuration |  | 
TranslateConfiguration
 |===
 // component options: END
 
diff --git 
a/components/camel-aws-translate/src/main/java/org/apache/camel/component/aws/translate/TranslateComponent.java
 
b/components/camel-aws-translate/src/main/java/org/apache/camel/component/aws/translate/TranslateComponent.java
index 2e16b16..b38d791 100644
--- 
a/components/camel-aws-translate/src/main/java/org/apache/camel/component/aws/translate/TranslateComponent.java
+++ 
b/components/camel-aws-translate/src/main/java/org/apache/camel/component/aws/translate/TranslateComponent.java
@@ -34,13 +34,7 @@ import org.apache.camel.util.ObjectHelper;
 public class TranslateComponent extends DefaultComponent {
 
     @Metadata
-    private String accessKey;
-    @Metadata
-    private String secretKey;
-    @Metadata
-    private String region;
-    @Metadata(label = "advanced")
-    private TranslateConfiguration configuration;
+    private TranslateConfiguration configuration = new 
TranslateConfiguration();
 
     public TranslateComponent() {
         this(null);
@@ -57,9 +51,6 @@ public class TranslateComponent extends DefaultComponent {
         TranslateConfiguration configuration = this.configuration != null ? 
this.configuration.copy() : new TranslateConfiguration();
 
         TranslateEndpoint endpoint = new TranslateEndpoint(uri, this, 
configuration);
-        endpoint.getConfiguration().setAccessKey(accessKey);
-        endpoint.getConfiguration().setSecretKey(secretKey);
-        endpoint.getConfiguration().setRegion(region);
         setProperties(endpoint, parameters);
         checkAndSetRegistryClient(configuration);
         if (configuration.getTranslateClient() == null && 
(configuration.getAccessKey() == null || configuration.getSecretKey() == null)) 
{
@@ -73,45 +64,12 @@ public class TranslateComponent extends DefaultComponent {
     }
 
     /**
-     * The AWS Translate default configuration
+     * The component configuration
      */
     public void setConfiguration(TranslateConfiguration configuration) {
         this.configuration = configuration;
     }
 
-    public String getAccessKey() {
-        return accessKey;
-    }
-
-    /**
-     * Amazon AWS Access Key
-     */
-    public void setAccessKey(String accessKey) {
-        this.accessKey = accessKey;
-    }
-
-    public String getSecretKey() {
-        return secretKey;
-    }
-
-    /**
-     * Amazon AWS Secret Key
-     */
-    public void setSecretKey(String secretKey) {
-        this.secretKey = secretKey;
-    }
-
-    public String getRegion() {
-        return region;
-    }
-
-    /**
-     * The region in which Translate client needs to work
-     */
-    public void setRegion(String region) {
-        this.region = region;
-    }
-
     private void checkAndSetRegistryClient(TranslateConfiguration 
configuration) {
         Set<AmazonTranslate> clients = 
getCamelContext().getRegistry().findByType(AmazonTranslate.class);
         if (clients.size() == 1) {
diff --git 
a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsTranslateComponentBuilderFactory.java
 
b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsTranslateComponentBuilderFactory.java
index 7d929bb..e408199 100644
--- 
a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsTranslateComponentBuilderFactory.java
+++ 
b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsTranslateComponentBuilderFactory.java
@@ -74,6 +74,19 @@ public interface AwsTranslateComponentBuilderFactory {
             return this;
         }
         /**
+         * The component configuration.
+         * 
+         * The option is a:
+         * 
<code>org.apache.camel.component.aws.translate.TranslateConfiguration</code> 
type.
+         * 
+         * Group: producer
+         */
+        default AwsTranslateComponentBuilder configuration(
+                
org.apache.camel.component.aws.translate.TranslateConfiguration configuration) {
+            doSetProperty("configuration", configuration);
+            return this;
+        }
+        /**
          * 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
@@ -222,19 +235,6 @@ public interface AwsTranslateComponentBuilderFactory {
             doSetProperty("basicPropertyBinding", basicPropertyBinding);
             return this;
         }
-        /**
-         * The AWS Translate default configuration.
-         * 
-         * The option is a:
-         * 
<code>org.apache.camel.component.aws.translate.TranslateConfiguration</code> 
type.
-         * 
-         * Group: advanced
-         */
-        default AwsTranslateComponentBuilder configuration(
-                
org.apache.camel.component.aws.translate.TranslateConfiguration configuration) {
-            doSetProperty("configuration", configuration);
-            return this;
-        }
     }
 
     class AwsTranslateComponentBuilderImpl
@@ -259,20 +259,20 @@ public interface AwsTranslateComponentBuilderFactory {
                 String name,
                 Object value) {
             switch (name) {
-            case "accessKey": ((TranslateComponent) 
component).setAccessKey((java.lang.String) value); return true;
+            case "accessKey": getOrCreateConfiguration((TranslateComponent) 
component).setAccessKey((java.lang.String) value); return true;
             case "autodetectSourceLanguage": 
getOrCreateConfiguration((TranslateComponent) 
component).setAutodetectSourceLanguage((boolean) value); return true;
+            case "configuration": ((TranslateComponent) 
component).setConfiguration((org.apache.camel.component.aws.translate.TranslateConfiguration)
 value); return true;
             case "lazyStartProducer": ((TranslateComponent) 
component).setLazyStartProducer((boolean) value); return true;
             case "operation": getOrCreateConfiguration((TranslateComponent) 
component).setOperation((org.apache.camel.component.aws.translate.TranslateOperations)
 value); return true;
             case "proxyHost": getOrCreateConfiguration((TranslateComponent) 
component).setProxyHost((java.lang.String) value); return true;
             case "proxyPort": getOrCreateConfiguration((TranslateComponent) 
component).setProxyPort((java.lang.Integer) value); return true;
             case "proxyProtocol": 
getOrCreateConfiguration((TranslateComponent) 
component).setProxyProtocol((com.amazonaws.Protocol) value); return true;
             case "region": getOrCreateConfiguration((TranslateComponent) 
component).setRegion((java.lang.String) value); return true;
-            case "secretKey": ((TranslateComponent) 
component).setSecretKey((java.lang.String) value); return true;
+            case "secretKey": getOrCreateConfiguration((TranslateComponent) 
component).setSecretKey((java.lang.String) value); return true;
             case "sourceLanguage": 
getOrCreateConfiguration((TranslateComponent) 
component).setSourceLanguage((java.lang.String) value); return true;
             case "targetLanguage": 
getOrCreateConfiguration((TranslateComponent) 
component).setTargetLanguage((java.lang.String) value); return true;
             case "translateClient": 
getOrCreateConfiguration((TranslateComponent) 
component).setTranslateClient((com.amazonaws.services.translate.AmazonTranslate)
 value); return true;
             case "basicPropertyBinding": ((TranslateComponent) 
component).setBasicPropertyBinding((boolean) value); return true;
-            case "configuration": ((TranslateComponent) 
component).setConfiguration((org.apache.camel.component.aws.translate.TranslateConfiguration)
 value); return true;
             default: return false;
             }
         }

Reply via email to