jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shash...@apache.org
Subject svn commit: r1687897 - in /jackrabbit/trunk/jackrabbit-aws-ext/src/main/java/org/apache/jackrabbit/aws/ext: Utils.java ds/S3Backend.java
Date Sat, 27 Jun 2015 09:37:24 GMT
Author: shashank
Date: Sat Jun 27 09:37:24 2015
New Revision: 1687897

URL: http://svn.apache.org/r1687897
Log:
JCR-3886 [jackrabbit-aws-ext] Support IAM role to connect to S3 bucket

Fixed. If accesskey & secret key are not passed it tries to create AmazonS3Client from
environment. 

Modified:
    jackrabbit/trunk/jackrabbit-aws-ext/src/main/java/org/apache/jackrabbit/aws/ext/Utils.java
    jackrabbit/trunk/jackrabbit-aws-ext/src/main/java/org/apache/jackrabbit/aws/ext/ds/S3Backend.java

Modified: jackrabbit/trunk/jackrabbit-aws-ext/src/main/java/org/apache/jackrabbit/aws/ext/Utils.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/main/java/org/apache/jackrabbit/aws/ext/Utils.java?rev=1687897&r1=1687896&r2=1687897&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/main/java/org/apache/jackrabbit/aws/ext/Utils.java
(original)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/main/java/org/apache/jackrabbit/aws/ext/Utils.java
Sat Jun 27 09:37:24 2015
@@ -35,6 +35,7 @@ import com.amazonaws.services.s3.AmazonS
 import com.amazonaws.services.s3.AmazonS3Client;
 import com.amazonaws.services.s3.model.ObjectListing;
 import com.amazonaws.services.s3.model.S3ObjectSummary;
+import com.amazonaws.util.StringUtils;
 
 /**
  * Amazon S3 utilities.
@@ -77,10 +78,20 @@ public final class Utils {
      * @return {@link AmazonS3Client}
      */
     public static AmazonS3Client openService(final Properties prop) {
-        AWSCredentials credentials = new BasicAWSCredentials(
-            prop.getProperty(S3Constants.ACCESS_KEY),
-            prop.getProperty(S3Constants.SECRET_KEY));
-        AmazonS3Client s3service =  new AmazonS3Client(credentials, getClientConfiguration(prop));
+        String accessKey = prop.getProperty(S3Constants.ACCESS_KEY);
+        String secretKey = prop.getProperty(S3Constants.SECRET_KEY);
+        AmazonS3Client s3service = null;
+        if (StringUtils.isNullOrEmpty(accessKey)
+            || StringUtils.isNullOrEmpty(secretKey)) {
+            LOG.info("Configuring Amazon Client from environment");
+            s3service = new AmazonS3Client(getClientConfiguration(prop));
+        } else {
+            LOG.info("Configuring Amazon Client from property file.");
+            AWSCredentials credentials = new BasicAWSCredentials(accessKey,
+                secretKey);
+            s3service = new AmazonS3Client(credentials,
+                getClientConfiguration(prop));
+        }
         String region = prop.getProperty(S3Constants.S3_REGION);
         String endpoint = null;
         String propEndPoint = prop.getProperty(S3Constants.S3_END_POINT);

Modified: jackrabbit/trunk/jackrabbit-aws-ext/src/main/java/org/apache/jackrabbit/aws/ext/ds/S3Backend.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/main/java/org/apache/jackrabbit/aws/ext/ds/S3Backend.java?rev=1687897&r1=1687896&r2=1687897&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/main/java/org/apache/jackrabbit/aws/ext/ds/S3Backend.java
(original)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/main/java/org/apache/jackrabbit/aws/ext/ds/S3Backend.java
Sat Jun 27 09:37:24 2015
@@ -230,7 +230,7 @@ public class S3Backend implements Backen
             ObjectMetadata objectMetaData = s3service.getObjectMetadata(bucket,
                 key);
             if (objectMetaData != null) {
-                LOG.debug("exists [{}]: [true] took [{}] ms.",
+                LOG.trace("exists [{}]: [true] took [{}] ms.",
                     identifier, (System.currentTimeMillis() - start) );
                 return true;
             }
@@ -356,7 +356,7 @@ public class S3Backend implements Backen
                 LOG.debug("[{}] touched. time taken [{}] ms ", new Object[] {
                     identifier, (System.currentTimeMillis() - start) });
             } else {
-                LOG.debug("[{}] touch not required. time taken [{}] ms ",
+                LOG.trace("[{}] touch not required. time taken [{}] ms ",
                     new Object[] { identifier,
                         (System.currentTimeMillis() - start) });
             }



Mime
View raw message