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 2016/06/14 12:24:51 UTC
[1/2] camel git commit: Added option for path-style access to S3;
useful when testing or for other S3 REST API providers (such as
OpenStack Swift)
Repository: camel
Updated Branches:
refs/heads/master 65b7a5ce2 -> 150240d9d
Added option for path-style access to S3; useful when testing or for other S3 REST API providers (such as OpenStack Swift)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6977bf61
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6977bf61
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6977bf61
Branch: refs/heads/master
Commit: 6977bf612c0019996f574e15bc189789e5eb66a0
Parents: 65b7a5c
Author: Milo\u0161 Milivojevi\u0107 <fi...@gmail.com>
Authored: Tue Jun 14 14:12:50 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Jun 14 14:19:09 2016 +0200
----------------------------------------------------------------------
.../camel/component/aws/s3/S3Configuration.java | 19 ++++++++++++++
.../camel/component/aws/s3/S3Endpoint.java | 26 ++++++++++++--------
2 files changed, 35 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6977bf61/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
index 83c33d2..abaad4d 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.aws.s3;
import com.amazonaws.services.s3.AmazonS3;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
+import org.apache.camel.util.ObjectHelper;
@UriParams
public class S3Configuration implements Cloneable {
@@ -58,6 +59,8 @@ public class S3Configuration implements Cloneable {
private Integer proxyPort;
@UriParam(label = "consumer", defaultValue = "true")
private boolean includeBody = true;
+ @UriParam
+ private boolean pathStyleAccess;
public long getPartSize() {
return partSize;
@@ -265,4 +268,20 @@ public class S3Configuration implements Cloneable {
public void setProxyPort(Integer proxyPort) {
this.proxyPort = proxyPort;
}
+
+ /**
+ * Whether or not the S3 client should use path style access
+ */
+ public void setPathStyleAccess(final boolean pathStyleAccess) {
+ this.pathStyleAccess = pathStyleAccess;
+ }
+
+ public boolean isPathStyleAccess() {
+ return pathStyleAccess;
+ }
+
+ boolean hasProxyConfiguration() {
+ return ObjectHelper.isNotEmpty(getProxyHost()) && ObjectHelper.isNotEmpty(getProxyPort());
+
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/6977bf61/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java
index 9e5b2ad..038bc91 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java
@@ -24,6 +24,7 @@ import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
+import com.amazonaws.services.s3.S3ClientOptions;
import com.amazonaws.services.s3.model.CreateBucketRequest;
import com.amazonaws.services.s3.model.ListObjectsRequest;
import com.amazonaws.services.s3.model.ObjectMetadata;
@@ -43,6 +44,7 @@ import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriPath;
import org.apache.camel.util.ObjectHelper;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -130,7 +132,7 @@ public class S3Endpoint extends ScheduledPollEndpoint {
createBucketRequest.setRegion(getConfiguration().getRegion());
}
- LOG.trace("Creating bucket [{}] in region [{}] with request [{}]...", new Object[]{configuration.getBucketName(), configuration.getRegion(), createBucketRequest});
+ LOG.trace("Creating bucket [{}] in region [{}] with request [{}]...", configuration.getBucketName(), configuration.getRegion(), createBucketRequest);
s3Client.createBucket(createBucketRequest);
@@ -214,19 +216,23 @@ public class S3Endpoint extends ScheduledPollEndpoint {
* Provide the possibility to override this method for an mock implementation
*/
AmazonS3 createS3Client() {
- AmazonS3 client = null;
AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
- if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
- ClientConfiguration clientConfiguration = new ClientConfiguration();
- clientConfiguration.setProxyHost(configuration.getProxyHost());
- clientConfiguration.setProxyPort(configuration.getProxyPort());
- client = new AmazonS3Client(credentials, clientConfiguration);
- } else {
- client = new AmazonS3Client(credentials);
- }
+ AmazonS3Client client = configuration.hasProxyConfiguration() ? createClientWithProxy(credentials) : new AmazonS3Client(credentials);
+
+ S3ClientOptions clientOptions = S3ClientOptions.builder()
+ .setPathStyleAccess(configuration.isPathStyleAccess())
+ .build();
+ client.setS3ClientOptions(clientOptions);
return client;
}
+ private AmazonS3Client createClientWithProxy(final AWSCredentials credentials) {
+ ClientConfiguration clientConfiguration = new ClientConfiguration();
+ clientConfiguration.setProxyHost(configuration.getProxyHost());
+ clientConfiguration.setProxyPort(configuration.getProxyPort());
+ return new AmazonS3Client(credentials, clientConfiguration);
+ }
+
public int getMaxMessagesPerPoll() {
return maxMessagesPerPoll;
}
[2/2] camel git commit: Updated AWS component docs
Posted by ac...@apache.org.
Updated AWS component docs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/150240d9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/150240d9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/150240d9
Branch: refs/heads/master
Commit: 150240d9d34919f855228888f4a98d512db25a60
Parents: 6977bf6
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Jun 14 14:24:05 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Jun 14 14:24:05 2016 +0200
----------------------------------------------------------------------
components/camel-aws/src/main/docs/aws-s3.adoc | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/150240d9/components/camel-aws/src/main/docs/aws-s3.adoc
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/docs/aws-s3.adoc b/components/camel-aws/src/main/docs/aws-s3.adoc
index 368abeb..04597b7 100644
--- a/components/camel-aws/src/main/docs/aws-s3.adoc
+++ b/components/camel-aws/src/main/docs/aws-s3.adoc
@@ -42,8 +42,9 @@ The AWS S3 Storage Service component has no options.
+
// endpoint options: START
-The AWS S3 Storage Service component supports 38 endpoint options which are listed below:
+The AWS S3 Storage Service component supports 39 endpoint options which are listed below:
{% raw %}
[width="100%",cols="2s,1,1m,1m,5",options="header"]
@@ -53,6 +54,7 @@ The AWS S3 Storage Service component supports 38 endpoint options which are list
| accessKey | common | | String | Amazon AWS Access Key
| amazonS3Client | common | | AmazonS3 | Reference to a com.amazonaws.services.sqs.AmazonS3 in the link:registry.htmlRegistry.
| amazonS3Endpoint | common | | String | The region with which the AWS-S3 client wants to work with.
+| pathStyleAccess | common | false | boolean | Whether or not the S3 client should use path style access
| policy | common | | String | Camel 2.8.4: The policy for this queue to set in the com.amazonaws.services.s3.AmazonS3setBucketPolicy() method.
| proxyHost | common | | String | Camel 2.16: To define a proxy host when instantiating the SQS client
| proxyPort | common | | Integer | Camel 2.16: Specify a proxy port to be used inside the client definition.
@@ -96,6 +98,7 @@ The AWS S3 Storage Service component supports 38 endpoint options which are list
+
Required S3 component options
You have to provide the amazonS3Client in the