Author: amitj
Date: Fri May 19 08:21:51 2017
New Revision: 1795594

URL: http://svn.apache.org/viewvc?rev=1795594&view=rev
Log:
OAK-6242: Add 'container' as an acceptable property name for s3 bucket

- Now s3 bucket can also be specified using the container property

Modified:
    
jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/aws/s3/S3Backend.java
    
jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java
    
jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Constants.java
    
jackrabbit/oak/trunk/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/TestS3DataStore.java

Modified: 
jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/aws/s3/S3Backend.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/aws/s3/S3Backend.java?rev=1795594&r1=1795593&r2=1795594&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/aws/s3/S3Backend.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/aws/s3/S3Backend.java
 Fri May 19 08:21:51 2017
@@ -38,6 +38,7 @@ import java.util.concurrent.TimeUnit;
 import com.amazonaws.services.s3.model.ListObjectsRequest;
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
+import com.google.common.base.Strings;
 import com.google.common.collect.AbstractIterator;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
@@ -149,6 +150,10 @@ public class S3Backend implements Shared
             s3service = Utils.openService(prop);
             if (bucket == null || "".equals(bucket.trim())) {
                 bucket = prop.getProperty(S3Constants.S3_BUCKET);
+                // Alternately check if the 'container' property is set
+                if (Strings.isNullOrEmpty(bucket)) {
+                    bucket = prop.getProperty(S3Constants.S3_CONTAINER);
+                }
             }
             String region = prop.getProperty(S3Constants.S3_REGION);
             Region s3Region = null;

Modified: 
jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java?rev=1795594&r1=1795593&r2=1795594&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java
 Fri May 19 08:21:51 2017
@@ -109,6 +109,10 @@ public class S3Backend extends AbstractS
             s3service = Utils.openService(properties);
             if (bucket == null || "".equals(bucket.trim())) {
                 bucket = properties.getProperty(S3Constants.S3_BUCKET);
+                // Alternately check if the 'container' property is set
+                if (Strings.isNullOrEmpty(bucket)) {
+                    bucket = properties.getProperty(S3Constants.S3_CONTAINER);
+                }
             }
             secret = properties.getProperty("secret");
             String region = properties.getProperty(S3Constants.S3_REGION);

Modified: 
jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Constants.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Constants.java?rev=1795594&r1=1795593&r2=1795594&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Constants.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Constants.java
 Fri May 19 08:21:51 2017
@@ -58,6 +58,11 @@ public final class S3Constants {
     public static final String S3_BUCKET = "s3Bucket";
 
     /**
+     * Amazon aws S3 bucket (alternate property name).
+     */
+    public static final String S3_CONTAINER = "container";
+
+    /**
      * Amazon aws S3 region.
      */
     public static final String S3_REGION = "s3Region";

Modified: 
jackrabbit/oak/trunk/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/TestS3DataStore.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/TestS3DataStore.java?rev=1795594&r1=1795593&r2=1795594&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/TestS3DataStore.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/TestS3DataStore.java
 Fri May 19 08:21:51 2017
@@ -145,4 +145,22 @@ public class TestS3DataStore {
 
         assertEquals(id, ref);
     }
+
+    @Test
+    public void testAlternateBucketProp() throws Exception {
+        assumeTrue(isS3Configured());
+
+        Random randomGen = new Random();
+        props = S3DataStoreUtils.getS3Config();
+        //Replace bucket in props with container
+        String bucket = props.getProperty(S3Constants.S3_BUCKET);
+        props.remove(S3Constants.S3_BUCKET);
+        props.put(S3Constants.S3_CONTAINER, bucket);
+
+        ds = getS3DataStore(s3Class, props, dataStoreDir.getAbsolutePath());
+        byte[] data = new byte[4096];
+        randomGen.nextBytes(data);
+        DataRecord rec = ds.addRecord(new ByteArrayInputStream(data));
+        assertEquals(data.length, rec.getLength());
+    }
 }


Reply via email to