Author: amitj
Date: Fri May 19 09:11:50 2017
New Revision: 1795600

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

merge r1795594 from trunk

Modified:
    jackrabbit/oak/branches/1.6/   (props changed)
    
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/aws/s3/S3Backend.java
    
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java
    
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Constants.java
    
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/TestS3DataStore.java

Propchange: jackrabbit/oak/branches/1.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri May 19 09:11:50 2017
@@ -1,3 +1,3 @@
 /jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1781068,1781075,1781248,1781386,1781846,1781907,1782000,1782029,1782196,1782447,1782476,1782770,1782945,1782966,1782973,1782990,1783061,1783066,1783089,1783104-1783105,1783110,1783619,1783720,1783731,1783733,1783738,1783742,1783773,1783855,1783891,1784023,1784034,1784130,1784162,1784251,1784401,1784551,1784574,1784689,1785095,1785108,1785283,1785838,1785919,1785946,1787074,1787217,1787425,1788378,1788387-1788389,1788850,1789056,1790382,1792463,1792742,1792746,1793088,1793618,1793627,1793644,1795314,1795330,1795475,1795488,1795491,1795502
+/jackrabbit/oak/trunk:1781068,1781075,1781248,1781386,1781846,1781907,1782000,1782029,1782196,1782447,1782476,1782770,1782945,1782966,1782973,1782990,1783061,1783066,1783089,1783104-1783105,1783110,1783619,1783720,1783731,1783733,1783738,1783742,1783773,1783855,1783891,1784023,1784034,1784130,1784162,1784251,1784401,1784551,1784574,1784689,1785095,1785108,1785283,1785838,1785919,1785946,1787074,1787217,1787425,1788378,1788387-1788389,1788850,1789056,1790382,1792463,1792742,1792746,1793088,1793618,1793627,1793644,1795314,1795330,1795475,1795488,1795491,1795502,1795594
 /jackrabbit/trunk:1345480

Modified: 
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/aws/s3/S3Backend.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/aws/s3/S3Backend.java?rev=1795600&r1=1795599&r2=1795600&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/aws/s3/S3Backend.java
 (original)
+++ 
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/aws/s3/S3Backend.java
 Fri May 19 09:11:50 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/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java?rev=1795600&r1=1795599&r2=1795600&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java
 (original)
+++ 
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java
 Fri May 19 09:11:50 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/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Constants.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Constants.java?rev=1795600&r1=1795599&r2=1795600&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Constants.java
 (original)
+++ 
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Constants.java
 Fri May 19 09:11:50 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/branches/1.6/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/TestS3DataStore.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/TestS3DataStore.java?rev=1795600&r1=1795599&r2=1795600&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/TestS3DataStore.java
 (original)
+++ 
jackrabbit/oak/branches/1.6/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/TestS3DataStore.java
 Fri May 19 09:11:50 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