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 2015/07/28 17:27:35 UTC
[2/4] incubator-usergrid git commit: fixed assets resource
fixed assets resource
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/fb1d552c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/fb1d552c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/fb1d552c
Branch: refs/heads/two-dot-o-dev
Commit: fb1d552cd2eb87513328051bd749f5c59358f768
Parents: 4a7ce9a
Author: GERey <gr...@apigee.com>
Authored: Mon Jul 27 16:44:34 2015 -0700
Committer: GERey <gr...@apigee.com>
Committed: Mon Jul 27 16:44:34 2015 -0700
----------------------------------------------------------------------
.../applications/assets/AssetsResource.java | 37 ++++++++++++++++++--
.../main/resources/usergrid-rest-context.xml | 3 --
2 files changed, 35 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb1d552c/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java
index ef43cfd..fedffc4 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java
@@ -26,7 +26,9 @@ import org.apache.usergrid.rest.AbstractContextResource;
import org.apache.usergrid.rest.applications.ServiceResource;
import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
import org.apache.usergrid.services.assets.data.AssetUtils;
+import org.apache.usergrid.services.assets.data.AwsSdkS3BinaryStore;
import org.apache.usergrid.services.assets.data.BinaryStore;
+import org.apache.usergrid.services.assets.data.LocalFileBinaryStore;
import org.apache.usergrid.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,6 +43,8 @@ import java.util.Date;
import java.util.Map;
import java.util.UUID;
+import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_USERGRID_BINARY_UPLOADER;
+
/** @deprecated */
@Component("org.apache.usergrid.rest.applications.assets.AssetsResource")
@@ -50,9 +54,16 @@ public class AssetsResource extends ServiceResource {
private Logger logger = LoggerFactory.getLogger( AssetsResource.class );
- @Autowired
+ //@Autowired
private BinaryStore binaryStore;
+ @Autowired
+ private LocalFileBinaryStore localFileBinaryStore;
+
+ @Autowired
+ private AwsSdkS3BinaryStore awsSdkS3BinaryStore;
+
+
@Override
@Path("{itemName}")
@@ -99,7 +110,15 @@ public class AssetsResource extends ServiceResource {
public Response uploadData( @FormDataParam("file") InputStream uploadedInputStream,
// @FormDataParam("file") FormDataContentDisposition fileDetail,
@PathParam("entityId") PathSegment entityId ) throws Exception {
- if (uploadedInputStream != null ) {
+
+ if(properties.getProperty( PROPERTIES_USERGRID_BINARY_UPLOADER ).equals( "local" )){
+ this.binaryStore = localFileBinaryStore;
+ }
+ else{
+ this.binaryStore = awsSdkS3BinaryStore;
+ }
+
+ if (uploadedInputStream != null ) {
UUID assetId = UUID.fromString( entityId.getPath() );
logger.info( "In AssetsResource.uploadData with id: {}", assetId );
EntityManager em = emf.getEntityManager( getApplicationId() );
@@ -131,6 +150,13 @@ public class AssetsResource extends ServiceResource {
public Response uploadDataStream( @PathParam("entityId") PathSegment entityId, InputStream uploadedInputStream )
throws Exception {
+ if(properties.getProperty( PROPERTIES_USERGRID_BINARY_UPLOADER ).equals( "local" )){
+ this.binaryStore = localFileBinaryStore;
+ }
+ else{
+ this.binaryStore = awsSdkS3BinaryStore;
+ }
+
UUID assetId = UUID.fromString( entityId.getPath() );
logger.info( "In AssetsResource.uploadDataStream with id: {}", assetId );
EntityManager em = emf.getEntityManager( getApplicationId() );
@@ -148,6 +174,13 @@ public class AssetsResource extends ServiceResource {
public Response findAsset( @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback,
@PathParam("entityId") PathSegment entityId, @HeaderParam("range") String range,
@HeaderParam("if-modified-since") String modifiedSince ) throws Exception {
+ if(properties.getProperty( PROPERTIES_USERGRID_BINARY_UPLOADER ).equals( "local" )){
+ this.binaryStore = localFileBinaryStore;
+ }
+ else{
+ this.binaryStore = awsSdkS3BinaryStore;
+ }
+
UUID assetId = UUID.fromString( entityId.getPath() );
logger.info( "In AssetsResource.findAsset with id: {}, range: {}, modifiedSince: {}",
new Object[] { assetId, range, modifiedSince } );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb1d552c/stack/rest/src/main/resources/usergrid-rest-context.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/resources/usergrid-rest-context.xml b/stack/rest/src/main/resources/usergrid-rest-context.xml
index 438cd1c..23312f9 100644
--- a/stack/rest/src/main/resources/usergrid-rest-context.xml
+++ b/stack/rest/src/main/resources/usergrid-rest-context.xml
@@ -75,9 +75,6 @@
</bean>
<bean id="awsS3BinaryStore" class="org.apache.usergrid.services.assets.data.AwsSdkS3BinaryStore">
- <constructor-arg name="accessId" value="xx" />
- <constructor-arg name="secretKey" value="xx" />
- <constructor-arg name="bucketName" value="xx" />
</bean>