usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject incubator-usergrid git commit: Removed bucket named from the credentials provider as it wasn't working as intended. Added properties to the NoAwsCredsRule so it could properly register what properties were currently in use. Using properties in the AwsSdk
Date Fri, 24 Jul 2015 14:19:02 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-869 2159ab1c1 -> 63f76f408


Removed bucket named from the credentials provider as it wasn't working as intended.
Added properties to the NoAwsCredsRule so it could properly register what properties were
currently in use.
Using properties in the AwsSdkBinaryStore instead of the provider.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/63f76f40
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/63f76f40
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/63f76f40

Branch: refs/heads/USERGRID-869
Commit: 63f76f40841656c2e22258ada67d28a3f4d4e5da
Parents: 2159ab1
Author: GERey <greyes@apigee.com>
Authored: Fri Jul 24 07:18:56 2015 -0700
Committer: GERey <greyes@apigee.com>
Committed: Fri Jul 24 07:18:56 2015 -0700

----------------------------------------------------------------------
 .../impl/UsergridAwsCredentialsProvider.java    |  8 ++----
 .../applications/assets/aws/NoAWSCredsRule.java | 30 ++++++++++++++++----
 .../assets/data/AwsSdkS3BinaryStore.java        | 22 +++++++-------
 3 files changed, 38 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/63f76f40/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/UsergridAwsCredentialsProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/UsergridAwsCredentialsProvider.java
b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/UsergridAwsCredentialsProvider.java
index 7307f71..1472654 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/UsergridAwsCredentialsProvider.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/UsergridAwsCredentialsProvider.java
@@ -18,6 +18,8 @@
 package org.apache.usergrid.persistence.queue.impl;
 
 
+import java.util.Properties;
+
 import org.apache.commons.lang.StringUtils;
 
 import com.amazonaws.AmazonClientException;
@@ -31,6 +33,7 @@ import com.amazonaws.auth.AWSCredentialsProvider;
  */
 public class UsergridAwsCredentialsProvider implements AWSCredentialsProvider {
 
+
     private AWSCredentials creds = new UsergridAwsCredentials();
 
 
@@ -52,11 +55,6 @@ public class UsergridAwsCredentialsProvider implements AWSCredentialsProvider
{
         return creds;
     }
 
-    public String getBucketName(){
-
-        return getBucketName();
-    }
-
     @Override
     public void refresh() {
         init();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/63f76f40/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/aws/NoAWSCredsRule.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/aws/NoAWSCredsRule.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/aws/NoAWSCredsRule.java
index c5f3278..5f7779e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/aws/NoAWSCredsRule.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/aws/NoAWSCredsRule.java
@@ -20,15 +20,21 @@
 package org.apache.usergrid.rest.applications.assets.aws;
 
 
+import java.util.Map;
+import java.util.Properties;
+
 import org.junit.Assume;
 import org.junit.internal.runners.model.MultipleFailureException;
 import org.junit.rules.TestRule;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import org.apache.usergrid.services.exceptions.AwsPropertiesNotFoundException;
+import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 
 import com.amazonaws.AmazonClientException;
+import com.amazonaws.SDKGlobalConfiguration;
 import com.sun.jersey.api.client.UniformInterfaceException;
 
 
@@ -38,15 +44,31 @@ import com.sun.jersey.api.client.UniformInterfaceException;
  *
  * Until then, simply marks as passed, which is a bit dangerous
  */
-public class NoAWSCredsRule implements TestRule {
+public class NoAWSCredsRule  extends AbstractRestIT implements TestRule {
+
+    @Autowired
+    private Properties properties;
+
 
     public Statement apply( final Statement base, final Description description ) {
         return new Statement() {
             @Override
             public void evaluate() throws Throwable {
-
+                String accessId;
+                String secretKey;
+                String bucketName;
                 try {
+                     Map<String,Object> properties = getRemoteTestProperties();
+                    //TODO: GREY change this so that it checks for the properties, then if
it doesn't have them, mark the tests as ignored.
+                    accessId = (String)properties.get( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR
);
+                    secretKey = (String)properties.get( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR
);
+                    bucketName =(String) properties.get( "usergrid.binary.bucketname" );
+
+                    if(accessId==null||secretKey==null||bucketName==null){
+                        throw new AwsPropertiesNotFoundException( "Access Keys" );
+                    }
                     base.evaluate();
+
                 }
                 catch ( Throwable t ) {
 
@@ -77,10 +99,6 @@ public class NoAWSCredsRule implements TestRule {
             }
         }
 
-        if(t instanceof UniformInterfaceException){
-            return true;
-        }
-
         if( t instanceof AwsPropertiesNotFoundException ){
             return true;
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/63f76f40/stack/services/src/main/java/org/apache/usergrid/services/assets/data/AwsSdkS3BinaryStore.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/assets/data/AwsSdkS3BinaryStore.java
b/stack/services/src/main/java/org/apache/usergrid/services/assets/data/AwsSdkS3BinaryStore.java
index cf01bb1..c69d44e 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/assets/data/AwsSdkS3BinaryStore.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/assets/data/AwsSdkS3BinaryStore.java
@@ -46,6 +46,7 @@ import org.apache.commons.io.IOUtils;
 import com.amazonaws.AmazonClientException;
 import com.amazonaws.ClientConfiguration;
 import com.amazonaws.Protocol;
+import com.amazonaws.SDKGlobalConfiguration;
 import com.amazonaws.auth.AWSCredentials;
 import com.amazonaws.auth.BasicAWSCredentials;
 import com.amazonaws.regions.Region;
@@ -113,17 +114,14 @@ public class AwsSdkS3BinaryStore implements BinaryStore {
 
     private AmazonS3 getS3Client() {
         if ( s3Client == null ) {
-            try {
-                final UsergridAwsCredentialsProvider ugProvider = new UsergridAwsCredentialsProvider();
-                this.accessId = ugProvider.getCredentials().getAWSAccessKeyId();
-                this.secretKey = ugProvider.getCredentials().getAWSSecretKey();
-                this.bucketName = ugProvider.getBucketName();
-            }
-            catch(Exception e){
-                if(e instanceof AmazonClientException){
-                    //TODO:GREY Move this exception into the service tier
-                    throw new AwsPropertiesNotFoundException( "Access Keys" );
-                }
+
+
+            this.accessId = properties.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR
);
+            this.secretKey = properties.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR
);
+            this.bucketName = properties.getProperty( "usergrid.binary.bucketname" );
+
+            if(accessId==null||secretKey==null||bucketName==null){
+                throw new AwsPropertiesNotFoundException( "Access Keys" );
 
             }
 
@@ -182,6 +180,8 @@ public class AwsSdkS3BinaryStore implements BinaryStore {
             Boolean isFirstChunck = true;
             List<PartETag> partETags = new ArrayList<PartETag>();
 
+            //get the s3 client in order to initialize the multipart request
+            getS3Client();
             InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(bucketName,
uploadFileName);
             InitiateMultipartUploadResult initResponse = getS3Client().initiateMultipartUpload(initRequest);
 


Mime
View raw message