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 2018/01/17 15:22:04 UTC

[camel] branch master updated (96b20a1 -> 86d407b)

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 96b20a1  CAMEL-12153 Upgrade OpenTracing Java API version to 0.31
     new 54a7982  CAMEL-12152 - Camel-AWS DDB: Add the ability to specify credentials and region at component level
     new 6574654  Camel AWS DDB - secretKey and accessKey are secret
     new 86d407b  Camel AWS DDB - Regen docs

The 3 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:
 .../camel-aws/src/main/docs/aws-ddb-component.adoc |  18 +-
 .../camel/component/aws/ddb/DdbComponent.java      |  67 ++++++-
 .../camel/component/aws/ddb/DdbConfiguration.java  |  19 +-
 .../DdbComponentConfigurationTest.java}            |  19 +-
 .../ddb/springboot/DdbComponentConfiguration.java  | 218 +++++++++++++++++++++
 5 files changed, 325 insertions(+), 16 deletions(-)
 copy components/camel-aws/src/test/java/org/apache/camel/component/aws/{swf/SWFComponentConfigurationTest.java => ddb/DdbComponentConfigurationTest.java} (73%)

-- 
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <co...@camel.apache.org>'].

[camel] 01/03: CAMEL-12152 - Camel-AWS DDB: Add the ability to specify credentials and region at component level

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 54a79828eb329eb4786026279c2b5fda383a5aaf
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jan 17 16:18:41 2018 +0100

    CAMEL-12152 - Camel-AWS DDB: Add the ability to specify credentials and region at component level
---
 .../camel-aws/src/main/docs/aws-ddb-component.adoc |  14 +-
 .../camel/component/aws/ddb/DdbComponent.java      |  67 ++++++-
 .../camel/component/aws/ddb/DdbConfiguration.java  |  15 +-
 .../aws/ddb/DdbComponentConfigurationTest.java     |  52 +++++
 .../ddb/springboot/DdbComponentConfiguration.java  | 218 +++++++++++++++++++++
 5 files changed, 363 insertions(+), 3 deletions(-)

diff --git a/components/camel-aws/src/main/docs/aws-ddb-component.adoc b/components/camel-aws/src/main/docs/aws-ddb-component.adoc
index cc3145b..59eb6d2 100644
--- a/components/camel-aws/src/main/docs/aws-ddb-component.adoc
+++ b/components/camel-aws/src/main/docs/aws-ddb-component.adoc
@@ -25,7 +25,19 @@ You can append query options to the URI in the following format,
 
 
 // component options: START
-The AWS DynamoDB component has no options.
+The AWS DynamoDB component supports 5 options which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *configuration* (advanced) | The AWS DDB default configuration |  | DdbConfiguration
+| *accessKey* (producer) | Amazon AWS Access Key |  | String
+| *secretKey* (producer) | Amazon AWS Secret Key |  | String
+| *region* (producer) | The region in which DDB client needs to work |  | String
+| *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
 
 
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java
index a49fae1..91c18a3 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java
@@ -21,9 +21,20 @@ import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.util.ObjectHelper;
 
 public class DdbComponent extends DefaultComponent {
 
+    @Metadata
+    private String accessKey;
+    @Metadata
+    private String secretKey;
+    @Metadata
+    private String region;
+    @Metadata(label = "advanced")    
+    private DdbConfiguration configuration;
+    
     public DdbComponent() {
         this(null);
     }
@@ -31,11 +42,12 @@ public class DdbComponent extends DefaultComponent {
     public DdbComponent(CamelContext context) {
         super(context);
         
+        this.configuration = new DdbConfiguration();
         registerExtension(new DdbComponentVerifierExtension());
     }
 
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        DdbConfiguration configuration = new DdbConfiguration();
+        DdbConfiguration configuration = this.configuration.copy();
         setProperties(configuration, parameters);
 
         if (remaining == null || remaining.trim().length() == 0) {
@@ -43,6 +55,15 @@ public class DdbComponent extends DefaultComponent {
         }
         configuration.setTableName(remaining);
 
+        if (ObjectHelper.isEmpty(configuration.getAccessKey())) {
+            setAccessKey(accessKey);
+        }
+        if (ObjectHelper.isEmpty(configuration.getSecretKey())) {
+            setSecretKey(secretKey);
+        }
+        if (ObjectHelper.isEmpty(configuration.getRegion())) {
+            setRegion(region);
+        }
         if (configuration.getAmazonDDBClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("amazonDDBClient or accessKey and secretKey must be specified");
         }
@@ -50,4 +71,48 @@ public class DdbComponent extends DefaultComponent {
         DdbEndpoint endpoint = new DdbEndpoint(uri, this, configuration);
         return endpoint;
     }
+    
+    public DdbConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    /**
+     * The AWS DDB default configuration
+     */
+    public void setConfiguration(DdbConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    public String getAccessKey() {
+        return configuration.getAccessKey();
+    }
+    
+    /**
+     * Amazon AWS Access Key
+     */
+    public void setAccessKey(String accessKey) {
+        configuration.setAccessKey(accessKey);
+    }
+
+    public String getSecretKey() {
+        return configuration.getSecretKey();
+    }
+
+    /**
+     * Amazon AWS Secret Key
+     */
+    public void setSecretKey(String secretKey) {
+        configuration.setSecretKey(secretKey);
+    }
+    
+    /**
+     * The region in which DDB client needs to work
+     */
+    public String getRegion() {
+        return configuration.getRegion();
+    }
+
+    public void setRegion(String region) {
+        configuration.setRegion(region);
+    }
 }
\ No newline at end of file
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbConfiguration.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbConfiguration.java
index f95fc7a..352b2a8 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbConfiguration.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbConfiguration.java
@@ -18,13 +18,14 @@ package org.apache.camel.component.aws.ddb;
 
 import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
 
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import org.apache.camel.spi.UriPath;
 
 @UriParams
-public class DdbConfiguration {
+public class DdbConfiguration implements Cloneable {
 
     @UriPath @Metadata(required = "true")
     private String tableName;
@@ -208,4 +209,16 @@ public class DdbConfiguration {
     public void setRegion(String region) {
         this.region = region;
     }
+    
+    // *************************************************
+    //
+    // *************************************************
+
+    public DdbConfiguration copy() {
+        try {
+            return (DdbConfiguration)super.clone();
+        } catch (CloneNotSupportedException e) {
+            throw new RuntimeCamelException(e);
+        }
+    }
 }
diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DdbComponentConfigurationTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DdbComponentConfigurationTest.java
new file mode 100644
index 0000000..56b9236
--- /dev/null
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DdbComponentConfigurationTest.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.component.aws.ddb;
+
+import com.amazonaws.regions.Regions;
+
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class DdbComponentConfigurationTest extends CamelTestSupport {
+    
+    @Test
+    public void createEndpointWithComponentElements() throws Exception {
+        DdbComponent component = new DdbComponent(context);
+        component.setAccessKey("XXX");
+        component.setSecretKey("YYY");
+        DdbEndpoint endpoint = (DdbEndpoint)component.createEndpoint("aws-ddb://myTable");
+        
+        assertEquals("myTable", endpoint.getConfiguration().getTableName());
+        assertEquals("XXX", endpoint.getConfiguration().getAccessKey());
+        assertEquals("YYY", endpoint.getConfiguration().getSecretKey());
+    }
+    
+    @Test
+    public void createEndpointWithComponentAndEndpointElements() throws Exception {
+        DdbComponent component = new DdbComponent(context);
+        component.setAccessKey("XXX");
+        component.setSecretKey("YYY");
+        component.setRegion(Regions.US_WEST_1.toString());
+        DdbEndpoint endpoint = (DdbEndpoint)component.createEndpoint("aws-myTable://myTable?accessKey=xxxxxx&secretKey=yyyyy&region=US_EAST_1");
+        
+        assertEquals("myTable", endpoint.getConfiguration().getTableName());
+        assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey());
+        assertEquals("yyyyy", endpoint.getConfiguration().getSecretKey());
+        assertEquals("US_EAST_1", endpoint.getConfiguration().getRegion());
+    }
+    
+}
\ No newline at end of file
diff --git a/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/ddb/springboot/DdbComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/ddb/springboot/DdbComponentConfiguration.java
index daa0de7..1beee46 100644
--- a/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/ddb/springboot/DdbComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/ddb/springboot/DdbComponentConfiguration.java
@@ -17,6 +17,9 @@
 package org.apache.camel.component.aws.ddb.springboot;
 
 import javax.annotation.Generated;
+import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
+import org.apache.camel.component.aws.ddb.DdbComponent;
+import org.apache.camel.component.aws.ddb.DdbOperations;
 import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
@@ -33,12 +36,61 @@ public class DdbComponentConfiguration
             ComponentConfigurationPropertiesCommon {
 
     /**
+     * The AWS DDB default configuration
+     */
+    private DdbConfigurationNestedConfiguration configuration;
+    /**
+     * Amazon AWS Access Key
+     */
+    private String accessKey;
+    /**
+     * Amazon AWS Secret Key
+     */
+    private String secretKey;
+    /**
+     * The region in which DDB client needs to work
+     */
+    private String region;
+    /**
      * 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 DdbConfigurationNestedConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    public void setConfiguration(
+            DdbConfigurationNestedConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getSecretKey() {
+        return secretKey;
+    }
+
+    public void setSecretKey(String secretKey) {
+        this.secretKey = secretKey;
+    }
+
+    public String getRegion() {
+        return region;
+    }
+
+    public void setRegion(String region) {
+        this.region = region;
+    }
+
     public Boolean getResolvePropertyPlaceholders() {
         return resolvePropertyPlaceholders;
     }
@@ -47,4 +99,170 @@ public class DdbComponentConfiguration
             Boolean resolvePropertyPlaceholders) {
         this.resolvePropertyPlaceholders = resolvePropertyPlaceholders;
     }
+
+    public static class DdbConfigurationNestedConfiguration {
+        public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.aws.ddb.DdbConfiguration.class;
+        /**
+         * The endpoint with which the AWS-DDB client wants to work with.
+         */
+        private String amazonDdbEndpoint;
+        /**
+         * Amazon AWS Access Key
+         */
+        private String accessKey;
+        /**
+         * Amazon AWS Secret Key
+         */
+        private String secretKey;
+        /**
+         * To use the AmazonDynamoDB as the client
+         */
+        private AmazonDynamoDB amazonDDBClient;
+        /**
+         * The name of the table currently worked with.
+         */
+        private String tableName;
+        /**
+         * What operation to perform
+         */
+        private DdbOperations operation = DdbOperations.PutItem;
+        /**
+         * Determines whether or not strong consistency should be enforced when
+         * data is read.
+         */
+        private Boolean consistentRead = false;
+        /**
+         * The provisioned throughput to reserve for reading resources from your
+         * table
+         */
+        private Long readCapacity;
+        /**
+         * The provisioned throughput to reserved for writing resources to your
+         * table
+         */
+        private Long writeCapacity;
+        /**
+         * Attribute name when creating table
+         */
+        private String keyAttributeName;
+        /**
+         * Attribute type when creating table
+         */
+        private String keyAttributeType;
+        private String proxyHost;
+        private Integer proxyPort;
+        private String region;
+
+        public String getAmazonDdbEndpoint() {
+            return amazonDdbEndpoint;
+        }
+
+        public void setAmazonDdbEndpoint(String amazonDdbEndpoint) {
+            this.amazonDdbEndpoint = amazonDdbEndpoint;
+        }
+
+        public String getAccessKey() {
+            return accessKey;
+        }
+
+        public void setAccessKey(String accessKey) {
+            this.accessKey = accessKey;
+        }
+
+        public String getSecretKey() {
+            return secretKey;
+        }
+
+        public void setSecretKey(String secretKey) {
+            this.secretKey = secretKey;
+        }
+
+        public AmazonDynamoDB getAmazonDDBClient() {
+            return amazonDDBClient;
+        }
+
+        public void setAmazonDDBClient(AmazonDynamoDB amazonDDBClient) {
+            this.amazonDDBClient = amazonDDBClient;
+        }
+
+        public String getTableName() {
+            return tableName;
+        }
+
+        public void setTableName(String tableName) {
+            this.tableName = tableName;
+        }
+
+        public DdbOperations getOperation() {
+            return operation;
+        }
+
+        public void setOperation(DdbOperations operation) {
+            this.operation = operation;
+        }
+
+        public Boolean getConsistentRead() {
+            return consistentRead;
+        }
+
+        public void setConsistentRead(Boolean consistentRead) {
+            this.consistentRead = consistentRead;
+        }
+
+        public Long getReadCapacity() {
+            return readCapacity;
+        }
+
+        public void setReadCapacity(Long readCapacity) {
+            this.readCapacity = readCapacity;
+        }
+
+        public Long getWriteCapacity() {
+            return writeCapacity;
+        }
+
+        public void setWriteCapacity(Long writeCapacity) {
+            this.writeCapacity = writeCapacity;
+        }
+
+        public String getKeyAttributeName() {
+            return keyAttributeName;
+        }
+
+        public void setKeyAttributeName(String keyAttributeName) {
+            this.keyAttributeName = keyAttributeName;
+        }
+
+        public String getKeyAttributeType() {
+            return keyAttributeType;
+        }
+
+        public void setKeyAttributeType(String keyAttributeType) {
+            this.keyAttributeType = keyAttributeType;
+        }
+
+        public String getProxyHost() {
+            return proxyHost;
+        }
+
+        public void setProxyHost(String proxyHost) {
+            this.proxyHost = proxyHost;
+        }
+
+        public Integer getProxyPort() {
+            return proxyPort;
+        }
+
+        public void setProxyPort(Integer proxyPort) {
+            this.proxyPort = proxyPort;
+        }
+
+        public String getRegion() {
+            return region;
+        }
+
+        public void setRegion(String region) {
+            this.region = region;
+        }
+    }
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.

[camel] 02/03: Camel AWS DDB - secretKey and accessKey are secret

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 65746540eec0b6fa1984bbd922f06ddee473e880
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jan 17 16:19:15 2018 +0100

    Camel AWS DDB - secretKey and accessKey are secret
---
 .../java/org/apache/camel/component/aws/ddb/DdbConfiguration.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbConfiguration.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbConfiguration.java
index 352b2a8..cecd2c5 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbConfiguration.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbConfiguration.java
@@ -29,9 +29,9 @@ public class DdbConfiguration implements Cloneable {
 
     @UriPath @Metadata(required = "true")
     private String tableName;
-    @UriParam
+    @UriParam(label = "security", secret = true)
     private String accessKey;
-    @UriParam
+    @UriParam(label = "security", secret = true)
     private String secretKey;
     @UriParam
     private AmazonDynamoDB amazonDDBClient;

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.

[camel] 03/03: Camel AWS DDB - Regen docs

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 86d407b942556d902dd8b0ebe795147887d03a67
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jan 17 16:21:33 2018 +0100

    Camel AWS DDB - Regen docs
---
 components/camel-aws/src/main/docs/aws-ddb-component.adoc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws/src/main/docs/aws-ddb-component.adoc b/components/camel-aws/src/main/docs/aws-ddb-component.adoc
index 59eb6d2..5ddc69d 100644
--- a/components/camel-aws/src/main/docs/aws-ddb-component.adoc
+++ b/components/camel-aws/src/main/docs/aws-ddb-component.adoc
@@ -65,7 +65,6 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *accessKey* (producer) | Amazon AWS Access Key |  | String
 | *amazonDDBClient* (producer) | To use the AmazonDynamoDB as the client |  | AmazonDynamoDB
 | *amazonDdbEndpoint* (producer) | The endpoint with which the AWS-DDB client wants to work with. |  | String
 | *consistentRead* (producer) | Determines whether or not strong consistency should be enforced when data is read. | false | boolean
@@ -76,9 +75,10 @@ with the following path and query parameters:
 | *proxyPort* (producer) | To define a proxy port when instantiating the DDB client |  | Integer
 | *readCapacity* (producer) | The provisioned throughput to reserve for reading resources from your table |  | Long
 | *region* (producer) | The region in which DDB client needs to work |  | String
-| *secretKey* (producer) | Amazon AWS Secret Key |  | String
 | *writeCapacity* (producer) | The provisioned throughput to reserved for writing resources to your table |  | Long
 | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean
+| *accessKey* (security) | Amazon AWS Access Key |  | String
+| *secretKey* (security) | Amazon AWS Secret Key |  | String
 |===
 // endpoint options: END
 

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.