You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/10/14 18:54:16 UTC
[20/39] usergrid git commit: remove properties
remove properties
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/a7700248
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/a7700248
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/a7700248
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: a770024818e478bceae39d8535e593cf56dcb2f4
Parents: e6c6c36
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 25 17:33:35 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 25 17:33:35 2015 -0600
----------------------------------------------------------------------
.../assets/data/AwsSdkS3BinaryStore.java | 42 ++++++++------------
1 file changed, 16 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a7700248/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 688e7bf..6cf5149 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
@@ -93,6 +93,9 @@ public class AwsSdkS3BinaryStore implements BinaryStore {
@Autowired
private EntityManagerFactory emf;
+ @Autowired
+ private Properties properties;
+
public AwsSdkS3BinaryStore( ) {
}
@@ -100,38 +103,25 @@ public class AwsSdkS3BinaryStore implements BinaryStore {
//ideally it should only do one. and the client should be initlized at the beginning of the run.
private AmazonS3 getS3Client() throws Exception{
- this.accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
- if(accessId == null){
- logger.error( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR + " not properly set so amazon access key is null" );
- throw new AwsPropertiesNotFoundException( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
-
- }
- this.secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
-
- if(secretKey == null){
- logger.error( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR + " not properly set so amazon secret key is null" );
- throw new AwsPropertiesNotFoundException( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
+ this.bucketName = properties.getProperty( "usergrid.binary.bucketname" );
+ if(bucketName == null){
+ logger.error( "usergrid.binary.bucketname not properly set so amazon bucket is null" );
+ throw new AwsPropertiesNotFoundException( "usergrid.binary.bucketname" );
- }
- this.bucketName = System.getProperty( "usergrid.binary.bucketname" );
- if(bucketName == null){
- logger.error( "usergrid.binary.bucketname not properly set so amazon bucket is null" );
- throw new AwsPropertiesNotFoundException( "usergrid.binary.bucketname" );
-
- }
+ }
- AWSCredentials credentials = new BasicAWSCredentials(accessId, secretKey);
- ClientConfiguration clientConfig = new ClientConfiguration();
- clientConfig.setProtocol(Protocol.HTTP);
+ final UsergridAwsCredentialsProvider ugProvider = new UsergridAwsCredentialsProvider();
+ AWSCredentials credentials = ugProvider.getCredentials();
+ ClientConfiguration clientConfig = new ClientConfiguration();
+ clientConfig.setProtocol(Protocol.HTTP);
- s3Client = new AmazonS3Client(credentials, clientConfig);
- if(regionName != null)
- s3Client.setRegion( Region.getRegion(Regions.fromName(regionName)) );
+ s3Client = new AmazonS3Client(credentials, clientConfig);
+ if(regionName != null)
+ s3Client.setRegion( Region.getRegion(Regions.fromName(regionName)) );
return s3Client;
}
-
@Override
public void write( final UUID appId, final Entity entity, InputStream inputStream ) throws Exception {
@@ -186,7 +176,7 @@ public class AwsSdkS3BinaryStore implements BinaryStore {
// determine max size file allowed, default to 50mb
long maxSizeBytes = 50 * FileUtils.ONE_MB;
- String maxSizeMbString = System.getProperty( "usergrid.binary.max-size-mb", "50" );
+ String maxSizeMbString = properties.getProperty( "usergrid.binary.max-size-mb", "50" );
if ( StringUtils.isNumeric( maxSizeMbString )) {
maxSizeBytes = Long.parseLong( maxSizeMbString ) * FileUtils.ONE_MB;
}