You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2016/01/14 21:12:45 UTC
usergrid git commit: Fixed assets tests and fixed oversight of not
updating entity metadata for AWS binary assets. Also changed tests so they
will run with properties set the way its done occasionally.
Repository: usergrid
Updated Branches:
refs/heads/USERGRID-1047 ee8c7c4d0 -> d97f6e3c5
Fixed assets tests and fixed oversight of not updating entity metadata for AWS binary assets.
Also changed tests so they will run with properties set the way its done occasionally.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/d97f6e3c
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/d97f6e3c
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/d97f6e3c
Branch: refs/heads/USERGRID-1047
Commit: d97f6e3c5d219ed8ca69be492d5d0dc9c45fd3a4
Parents: ee8c7c4
Author: George Reyes <gr...@apache.org>
Authored: Thu Jan 14 12:12:42 2016 -0800
Committer: George Reyes <gr...@apache.org>
Committed: Thu Jan 14 12:12:42 2016 -0800
----------------------------------------------------------------------
.../rest/applications/assets/AwsAssetResourceIT.java | 9 +++++++--
.../rest/applications/assets/aws/NoAWSCredsRule.java | 4 ++--
.../usergrid/services/assets/data/AwsSdkS3BinaryStore.java | 8 +++++++-
3 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/d97f6e3c/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
index 4561199..914d253 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
@@ -34,6 +34,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.ClientErrorException;
+import javax.ws.rs.ForbiddenException;
+import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
@@ -151,7 +153,7 @@ public class AwsAssetResourceIT extends AbstractRestIT {
}catch ( AwsPropertiesNotFoundException e ){
fail("Shouldn't interrupt runtime if access key isnt found.");
}
- catch( ClientErrorException uie){
+ catch( InternalServerErrorException uie){
assertEquals( 500, uie.getResponse().getStatus() );
}
finally{
@@ -193,7 +195,10 @@ public class AwsAssetResourceIT extends AbstractRestIT {
}catch ( AwsPropertiesNotFoundException e ){
fail("Shouldn't interrupt runtime if access key isnt found.");
}
- catch( ClientErrorException uie){
+ catch(ForbiddenException fe){
+ assertEquals( 403, fe.getResponse().getStatus() );
+ }
+ catch( InternalServerErrorException uie){
assertEquals( 500, uie.getResponse().getStatus() );
}
finally{
http://git-wip-us.apache.org/repos/asf/usergrid/blob/d97f6e3c/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 1dd00ff..40a6b45 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
@@ -57,8 +57,8 @@ public class NoAWSCredsRule extends AbstractRestIT implements TestRule {
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 );
+ accessId = (String)System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
+ secretKey = (String)System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
bucketName =(String) properties.get( "usergrid.binary.bucketname" );
if(accessId==null||secretKey==null||bucketName==null){
http://git-wip-us.apache.org/repos/asf/usergrid/blob/d97f6e3c/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 d81f023..47a99c0 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
@@ -140,6 +140,9 @@ public class AwsSdkS3BinaryStore implements BinaryStore {
Boolean overSizeLimit = false;
+ EntityManager em = emf.getEntityManager( appId );
+
+
if ( written < FIVE_MB ) { // total smaller than 5mb
ObjectMetadata om = new ObjectMetadata();
@@ -156,6 +159,9 @@ public class AwsSdkS3BinaryStore implements BinaryStore {
if(md5sum != null)
fileMetadata.put( AssetUtils.CHECKSUM, md5sum );
fileMetadata.put( AssetUtils.E_TAG, eTag );
+
+ em.update( entity );
+
}
else { // bigger than 5mb... dump 5 mb tmp files and upload from them
written = 0; //reset written to 0, we still haven't wrote anything in fact
@@ -236,7 +242,6 @@ public class AwsSdkS3BinaryStore implements BinaryStore {
//check for flag here then abort.
if(overSizeLimit) {
- EntityManager em = emf.getEntityManager( appId );
AbortMultipartUploadRequest abortRequest =
new AbortMultipartUploadRequest( bucketName, uploadFileName, initResponse.getUploadId() );
@@ -282,6 +287,7 @@ public class AwsSdkS3BinaryStore implements BinaryStore {
CompleteMultipartUploadResult amazonResult = getS3Client().completeMultipartUpload( request );
fileMetadata.put( AssetUtils.CONTENT_LENGTH, written );
fileMetadata.put( AssetUtils.E_TAG, amazonResult.getETag() );
+ em.update( entity );
}
}
}