usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [31/50] [abbrv] git commit: Added Mock S3 class that writes file buffer into local file. Added two tests that read Json files from local file written by stream. One tests connections. Added filename param to S3Export copying. Fixed formatting of json cod
Date Tue, 25 Feb 2014 06:21:45 GMT
Added Mock S3 class that writes file buffer into local file.
Added two tests that read Json files from local file written by stream. One tests connections.
Added filename param to S3Export copying.
Fixed formatting of json code so that entities are grouped correctly.


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

Branch: refs/pull/60/merge
Commit: 5137656624e614d14df8e6e2f9d17ae6abb3ec8b
Parents: bc70a3d
Author: George Reyes <ApigeeCorporation@George-Reyess-MacBook-Pro.local>
Authored: Fri Feb 14 19:17:56 2014 -0800
Committer: George Reyes <ApigeeCorporation@George-Reyess-MacBook-Pro.local>
Committed: Fri Feb 14 19:17:56 2014 -0800

----------------------------------------------------------------------
 .../management/export/ExportServiceImpl.java    |  21 +-
 .../usergrid/management/export/S3Export.java    |   2 +-
 .../management/export/S3ExportImpl.java         |   6 +-
 .../cassandra/ManagementServiceIT.java          | 266 +++++++++++++++++--
 .../management/cassandra/MockS3ExportImpl.java  | 104 ++++++++
 5 files changed, 376 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/51376566/stack/services/src/main/java/org/usergrid/management/export/ExportServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/usergrid/management/export/ExportServiceImpl.java
b/stack/services/src/main/java/org/usergrid/management/export/ExportServiceImpl.java
index dbbe520..287813d 100644
--- a/stack/services/src/main/java/org/usergrid/management/export/ExportServiceImpl.java
+++ b/stack/services/src/main/java/org/usergrid/management/export/ExportServiceImpl.java
@@ -265,10 +265,17 @@ public class ExportServiceImpl implements ExportService {
             Map<String, Object> metadata = em.getApplicationCollectionMetadata();
             long starting_time = System.currentTimeMillis();
 
+            //jg.writeStartObject();
+
+
             // Loop through the collections. This is the only way to loop
             // through the entities in the application (former namespace).
+            //could support queries, just need to implement that in the rest endpoint.
             for ( String collectionName : metadata.keySet() ) {
 
+                //jg.writeFieldName( "EntityInfo" );
+
+
 
                 Query query = new Query();
                 query.setLimit( MAX_ENTITY_FETCH );
@@ -282,8 +289,11 @@ public class ExportServiceImpl implements ExportService {
                 while ( entities.size() > 0 ) {
                     jobExecution.heartbeat();
                     for ( Entity entity : entities ) {
+                        jg.writeStartObject();
+                        jg.writeFieldName( "Metadata" );
                         jg.writeObject( entity );
                         saveCollectionMembers( jg, em, application.getValue(), entity );
+                        jg.writeEndObject();
                     }
 
                     //we're done
@@ -295,12 +305,15 @@ public class ExportServiceImpl implements ExportService {
                     query.setCursor( entities.getCursor() );
 
                     entities = em.searchCollection( em.getApplicationRef(), collectionName,
query );
+
                 }
+
             }
 
             // Close writer and file for this application.
 
             // logger.warn();
+            //jg.writeEndObject();
             jg.writeEndArray();
             jg.close();
             baos.flush();
@@ -308,7 +321,7 @@ public class ExportServiceImpl implements ExportService {
 
 
             InputStream is = new ByteArrayInputStream( baos.toByteArray() );
-            s3Export.copyToS3( is, config );
+            s3Export.copyToS3( is, config , appFileName);
         }
     }
 
@@ -335,9 +348,8 @@ public class ExportServiceImpl implements ExportService {
     private void saveCollectionMembers( JsonGenerator jg, EntityManager em, String application,
Entity entity )
             throws Exception {
 
-        long timestamp = System.currentTimeMillis();
-
         Set<String> collections = em.getCollections( entity );
+        //jg.writeStartObject();
 
         // Only create entry for Entities that have collections
         if ( ( collections == null ) || collections.isEmpty() ) {
@@ -350,6 +362,7 @@ public class ExportServiceImpl implements ExportService {
             jg.writeFieldName( collectionName );
             jg.writeStartArray();
 
+            //is 100000 an arbitary number?
             Results collectionMembers =
                     em.getCollection( entity, collectionName, null, 100000, Results.Level.IDS,
false );
 
@@ -372,7 +385,7 @@ public class ExportServiceImpl implements ExportService {
         saveDictionaries( entity, em, jg );
 
         // End the object if it was Started
-        jg.writeEndObject();
+        //jg.writeEndObject();
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/51376566/stack/services/src/main/java/org/usergrid/management/export/S3Export.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/usergrid/management/export/S3Export.java b/stack/services/src/main/java/org/usergrid/management/export/S3Export.java
index cc4486c..e61d64c 100644
--- a/stack/services/src/main/java/org/usergrid/management/export/S3Export.java
+++ b/stack/services/src/main/java/org/usergrid/management/export/S3Export.java
@@ -11,6 +11,6 @@ import org.usergrid.management.ExportInfo;
  *
  */
 public interface S3Export {
-    void copyToS3( InputStream inputStream, ExportInfo exportInfo );
+    void copyToS3( InputStream inputStream, ExportInfo exportInfo, String filename );
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/51376566/stack/services/src/main/java/org/usergrid/management/export/S3ExportImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/usergrid/management/export/S3ExportImpl.java
b/stack/services/src/main/java/org/usergrid/management/export/S3ExportImpl.java
index 52afb71..3419785 100644
--- a/stack/services/src/main/java/org/usergrid/management/export/S3ExportImpl.java
+++ b/stack/services/src/main/java/org/usergrid/management/export/S3ExportImpl.java
@@ -29,7 +29,7 @@ import com.google.inject.Module;
 public class S3ExportImpl implements S3Export {
 
     @Override
-    public void copyToS3( final InputStream inputStream, final ExportInfo exportInfo ) {
+    public void copyToS3( final InputStream inputStream, final ExportInfo exportInfo, String
filename ) {
 
         Logger logger = LoggerFactory.getLogger( ExportServiceImpl.class );
         /*won't need any of the properties as I have the export info*/
@@ -60,7 +60,7 @@ public class S3ExportImpl implements S3Export {
         }
         catch ( Exception ex ) {
             logger.error( "Could not start binary service: {}", ex.getMessage() );
-            throw new RuntimeException( ex );
+            //throw new RuntimeException( ex );
         }
 
         try {
@@ -68,7 +68,7 @@ public class S3ExportImpl implements S3Export {
 
             AsyncBlobStore blobStore = context.getAsyncBlobStore();
             BlobBuilder blobBuilder =
-                    blobStore.blobBuilder( "test.json" ).payload( inputStream ).calculateMD5().contentType(
"text/plain" );
+                    blobStore.blobBuilder( filename ).payload( inputStream ).calculateMD5().contentType(
"text/plain" );
 
 
             Blob blob = blobBuilder.build();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/51376566/stack/services/src/test/java/org/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/usergrid/management/cassandra/ManagementServiceIT.java
b/stack/services/src/test/java/org/usergrid/management/cassandra/ManagementServiceIT.java
index 2c630eb..db085b1 100644
--- a/stack/services/src/test/java/org/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/usergrid/management/cassandra/ManagementServiceIT.java
@@ -1,14 +1,19 @@
 package org.usergrid.management.cassandra;
 
 
+import java.io.File;
+import java.io.FileReader;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -25,6 +30,7 @@ import org.usergrid.management.ExportInfo;
 import org.usergrid.management.OrganizationInfo;
 import org.usergrid.management.UserInfo;
 import org.usergrid.management.export.ExportJob;
+import org.usergrid.management.export.ExportService;
 import org.usergrid.management.export.S3Export;
 import org.usergrid.management.export.S3ExportImpl;
 import org.usergrid.persistence.CredentialsInfo;
@@ -736,9 +742,58 @@ public class ManagementServiceIT {
 
     /*Make this test the do export test and verify that it works using a mock method. */
     //This test really should be called testDoExport as it mocks out sending it to s3.
+    //the test below walks through very similar code as the following test.
+//    @Test
+//    public void testS3Export() throws Exception {
+//
+//        HashMap<String, Object> payload = new HashMap<String, Object>();
+//        Map<String, Object> properties = new HashMap<String, Object>();
+//        Map<String, Object> storage_info = new HashMap<String, Object>();
+//        storage_info.put( "admin_token","insert_token_data_here" );
+//        //TODO: always put dummy values here and ignore this test.
+//        //TODO: add a ret for when s3 values are invalid.
+//        storage_info.put( "s3_key","insert key here" );
+//        storage_info.put( "s3_accessId","insert access id here");
+//        storage_info.put( "bucket_location","insert bucket name here");
+//
+//
+//        properties.put( "storage_provider","s3");
+//        properties.put( "storage_info",storage_info);
+//
+//        payload.put( "path", "test-organization/test-app/user");
+//        payload.put( "properties", properties);
+//
+//
+//        ExportInfo exportInfo = new ExportInfo(payload);
+//
+//
+//        S3Export s3Export = mock( S3Export.class );
+//
+//        try {
+//            setup.getExportService().setS3Export( s3Export );
+//            setup.getExportService().doExport( exportInfo,  );
+//        }catch (Exception e) {
+//            assert(false);
+//        }
+//        assert(true);
+//    }
+
+    //Tests to make sure we can call the job with mock data and it runs.
     @Test
-    public void testS3Export() throws Exception {
+    public void testFileConnections() throws Exception {
+
+        File f = null;
+
 
+        try {
+            f = new File ("test.json");
+            f.delete();
+        }   catch (Exception e) {
+            //consumed because this checks to see if the file exisits. If it doesn't then
don't do anything and carry on.
+        }
+
+        S3Export s3Export = new MockS3ExportImpl();
+        ExportService exportService = setup.getExportService();
         HashMap<String, Object> payload = new HashMap<String, Object>();
         Map<String, Object> properties = new HashMap<String, Object>();
         Map<String, Object> storage_info = new HashMap<String, Object>();
@@ -748,30 +803,145 @@ public class ManagementServiceIT {
         storage_info.put( "s3_key","insert key here" );
         storage_info.put( "s3_accessId","insert access id here");
         storage_info.put( "bucket_location","insert bucket name here");
+        properties.put( "storage_provider","s3");
+        properties.put( "storage_info",storage_info);
+
+        payload.put( "path", "test-organization/test-app/user");
+        payload.put( "properties", properties);
+
+        ExportInfo exportInfo = new ExportInfo(payload);
+
+        JobData jobData = new JobData();
+        jobData.setProperty( "jobName", "exportJob" );
+        jobData.setProperty( "ExportInfo", exportInfo );
+
+        JobExecution jobExecution = mock ( JobExecution.class);
+
+
+        UUID uuid = UUIDUtils.newTimeUUID();
+        EntityManager em = setup.getEmf().getEntityManager( applicationId );
+        Map<String, Object> userProperties = null;
+        Entity[] entity;
+        entity = new Entity[10];
+        for (int i = 0; i< 10;i++) {
+            userProperties = new LinkedHashMap<String, Object>();
+            userProperties.put( "username", "billybob" + i );
+            userProperties.put( "email", "test"+i+"@anuff.com");//String.format( "test%i@anuff.com",
i ) );
+
+            entity[i] = em.create( "user", userProperties );
+
+        }
+        em.createConnection( em.getRef( entity[0].getUuid() ),"Vibrations",em.getRef( entity[1].getUuid()
) );
+        em.createConnection( em.getRef( entity[1].getUuid() ),"Vibrations",em.getRef( entity[0].getUuid()
) );
+
+
+        exportService.setS3Export( s3Export );
+        exportService.doExport( exportInfo, jobExecution  );
+
+        JSONParser parser = new JSONParser();
+
+
+
+        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse(new FileReader(f));
 
+        if (a.size() > 0) {
+            org.json.simple.JSONObject objOrg = ( org.json.simple.JSONObject) a.get( 0 );
+            String appName = (String) objOrg.get( "applicationName" );
 
+            assertEquals("ed-application",  appName );
+
+            String path = (String) objOrg.get( "name" );
+            assertEquals("ed-organization/ed-application",path );
+
+        }
+        else {
+            assert(false);
+        }
+
+        org.json.simple.JSONObject objEnt = ( org.json.simple.JSONObject) a.get( 1 );
+        org.json.simple.JSONObject objConnections = ( org.json.simple.JSONObject) objEnt.get(
"connections" );
+
+        org.json.simple.JSONArray objVibrations = ( org.json.simple.JSONArray ) objConnections.get("Vibrations");
+
+        assertNotNull( objVibrations );
+
+        f.delete();
+    }
+
+
+    @Test
+    public void testFileValidity() throws Exception {
+
+        File f = null;
+
+
+        try {
+             f = new File ("test.json");
+             f.delete();
+        }   catch (Exception e) {
+            //consumed because this checks to see if the file exisits. If it doesn't then
don't do anything and carry on.
+        }
+
+
+
+        S3Export s3Export = new MockS3ExportImpl();
+        ExportService exportService = setup.getExportService();
+        HashMap<String, Object> payload = new HashMap<String, Object>();
+        Map<String, Object> properties = new HashMap<String, Object>();
+        Map<String, Object> storage_info = new HashMap<String, Object>();
+        storage_info.put( "admin_token","insert_token_data_here" );
+        //TODO: always put dummy values here and ignore this test.
+        //TODO: add a ret for when s3 values are invalid.
+        storage_info.put( "s3_key","insert key here" );
+        storage_info.put( "s3_accessId","insert access id here");
+        storage_info.put( "bucket_location","insert bucket name here");
         properties.put( "storage_provider","s3");
         properties.put( "storage_info",storage_info);
 
         payload.put( "path", "test-organization/test-app/user");
         payload.put( "properties", properties);
 
-
         ExportInfo exportInfo = new ExportInfo(payload);
 
+        JobData jobData = new JobData();
+        jobData.setProperty( "jobName", "exportJob" );
+        jobData.setProperty( "ExportInfo", exportInfo );
 
-        S3Export s3Export = mock( S3Export.class );
+        JobExecution jobExecution = mock ( JobExecution.class);
 
-        try {
-            setup.getExportService().setS3Export( s3Export );
-            setup.getExportService().doExport( exportInfo );
-        }catch (Exception e) {
+
+        exportService.setS3Export( s3Export );
+        exportService.doExport( exportInfo, jobExecution  );
+
+        JSONParser parser = new JSONParser();
+
+        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse(new FileReader(f));
+
+        if (a.size() > 0) {
+            org.json.simple.JSONObject entity = ( org.json.simple.JSONObject) a.get( 0 );
+            String appName = (String) entity.get( "applicationName" );
+
+            assertEquals("ed-application",  appName );
+
+            String path = (String) entity.get( "name" );
+            assertEquals("ed-organization/ed-application",path );
+
+        }
+        else {
             assert(false);
         }
-        assert(true);
+
+
+        for (int i = 1; a.size() < i;i++ )
+        {
+            org.json.simple.JSONObject entity = ( org.json.simple.JSONObject) a.get( i );
+            org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata"
);
+            assertNotNull( entityData );
+
+        }
+        f.delete();
     }
 
-    //Tests to make sure we can call the job with mock data and it runs.
     @Test
     public void testExportDoJob() throws Exception {
 
@@ -823,7 +993,7 @@ public class ManagementServiceIT {
 
     //tests that with empty job data, the export still runs.
     @Test
-    public void testExportEmptyJob() throws Exception {
+    public void testExportEmptyJobData() throws Exception {
 
         JobData jobData = new JobData();
 
@@ -844,6 +1014,7 @@ public class ManagementServiceIT {
 
     }
 
+
     @Test
     public void testNullJobExecution () {
 
@@ -866,8 +1037,56 @@ public class ManagementServiceIT {
 
     }
 
-    @Test
-    public void testS3IntegrationExport() throws Exception {
+    @Ignore
+    public void testS3IntegrationExport100Entities() throws Exception {
+
+        //EntityManager em = setup.getEmf().getEntityManager( MANAGEMENT_APPLICATION_ID );
+
+        HashMap<String, Object> payload = new HashMap<String, Object>();
+        Map<String, Object> properties = new HashMap<String, Object>();
+        Map<String, Object> storage_info = new HashMap<String, Object>();
+        storage_info.put( "admin_token","insert_token_data_here" );
+        //TODO: always put dummy values here and ignore this test.
+        //TODO: add a ret for when s3 values are invalid.
+
+
+        properties.put( "storage_provider","s3");
+        properties.put( "storage_info",storage_info);
+
+        payload.put( "path", "test-organization/test-app/user");
+        payload.put( "properties", properties);
+
+        ExportInfo exportInfo = new ExportInfo(payload);
+        S3Export s3Export = new S3ExportImpl();
+        ExportJob job = new ExportJob();
+        JobExecution jobExecution = mock (JobExecution.class);
+
+
+        UUID uuid = UUIDUtils.newTimeUUID();
+        EntityManager em = setup.getEmf().getEntityManager( applicationId );
+        Map<String, Object> userProperties = null;
+        for (int i = 0; i< 100;i++) {
+        userProperties = new LinkedHashMap<String, Object>();
+            userProperties.put( "username", "billybob" + i );
+            userProperties.put( "email", "test"+i+"@anuff.com");//String.format( "test%i@anuff.com",
i ) );
+
+            em.create( "user", userProperties );
+
+        }
+        try {
+            setup.getExportService().setS3Export( s3Export );
+            setup.getExportService().doExport( exportInfo, jobExecution );
+        }catch (Exception e) {
+            e.printStackTrace();
+            assert(false);
+        }
+        assert(true);
+    }
+
+    @Ignore
+    public void testS3IntegrationExport10Connections() throws Exception {
+
+        //EntityManager em = setup.getEmf().getEntityManager( MANAGEMENT_APPLICATION_ID );
 
         HashMap<String, Object> payload = new HashMap<String, Object>();
         Map<String, Object> properties = new HashMap<String, Object>();
@@ -888,13 +1107,30 @@ public class ManagementServiceIT {
         ExportInfo exportInfo = new ExportInfo(payload);
 
 
-        S3Export s3Export = new S3ExportImpl(); //mock( S3Export.class );
+        S3Export s3Export = new S3ExportImpl();
+        JobExecution jobExecution = mock (JobExecution.class);
+
 
-        //when(s3Export.copyToS3( any( InputStream.class),exportInfo ));
 
+        UUID uuid = UUIDUtils.newTimeUUID();
+        EntityManager em = setup.getEmf().getEntityManager( applicationId );
+        Map<String, Object> userProperties = null;
+        Entity[] entity;
+        entity = new Entity[10];
+        for (int i = 0; i< 10;i++) {
+            userProperties = new LinkedHashMap<String, Object>();
+            userProperties.put( "username", "billybob" + i );
+            userProperties.put( "email", "test"+i+"@anuff.com");//String.format( "test%i@anuff.com",
i ) );
+
+            entity[i] = em.create( "user", userProperties );
+
+        }
+        //em.createConnection(  )
+          em.createConnection( em.getRef( entity[0].getUuid() ),"Likes",em.getRef( entity[1].getUuid()
) );
+        em.createConnection( em.getRef( entity[1].getUuid() ),"Likes",em.getRef( entity[0].getUuid()
) );
         try {
             setup.getExportService().setS3Export( s3Export );
-            setup.getExportService().doExport( exportInfo );
+            setup.getExportService().doExport( exportInfo, jobExecution );
         }catch (Exception e) {
             e.printStackTrace();
             assert(false);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/51376566/stack/services/src/test/java/org/usergrid/management/cassandra/MockS3ExportImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/usergrid/management/cassandra/MockS3ExportImpl.java
b/stack/services/src/test/java/org/usergrid/management/cassandra/MockS3ExportImpl.java
new file mode 100644
index 0000000..604c1bb
--- /dev/null
+++ b/stack/services/src/test/java/org/usergrid/management/cassandra/MockS3ExportImpl.java
@@ -0,0 +1,104 @@
+package org.usergrid.management.cassandra;
+
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.usergrid.management.ExportInfo;
+import org.usergrid.management.export.S3Export;
+
+
+/**
+ * Writes to file instead of s3.
+ *
+ */
+public class MockS3ExportImpl implements S3Export {
+    @Override
+    public void copyToS3( final InputStream inputStream, final ExportInfo exportInfo, String
filename ) {
+        Logger logger = LoggerFactory.getLogger( MockS3ExportImpl.class );
+        int read = 0;
+        byte[] bytes = new byte[1024];
+        OutputStream outputStream = null;
+        //FileInputStream fis = new PrintWriter( inputStream );
+
+        try {
+            outputStream = new FileOutputStream( new File("test.json") );
+
+        }
+        catch ( FileNotFoundException e ) {
+            e.printStackTrace();
+        }
+
+
+        try {
+            while ( (read = (inputStream.read( bytes ))) != -1) {
+                outputStream.write( bytes, 0, read );
+            }
+              
+        }
+        catch ( IOException e ) {
+            e.printStackTrace();
+        }
+
+
+
+
+
+        //        Logger logger = LoggerFactory.getLogger( ExportServiceImpl.class );
+//        /*won't need any of the properties as I have the export info*/
+//        String bucketName = exportInfo.getBucket_location();
+//        String accessId = exportInfo.getS3_accessId();
+//        String secretKey = exportInfo.getS3_key();
+//
+//        Properties overrides = new Properties();
+//        overrides.setProperty( "s3" + ".identity", accessId );
+//        overrides.setProperty( "s3" + ".credential", secretKey );
+//
+//        final Iterable<? extends Module> MODULES = ImmutableSet
+//                .of( new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(),
new NettyPayloadModule
+//                        () );
+//
+//        BlobStoreContext context =
+//                ContextBuilder.newBuilder( "s3" ).credentials( accessId, secretKey ).modules(
MODULES )
+//                              .overrides( overrides ).buildView( BlobStoreContext.class
);
+//
+//        // Create Container (the bucket in s3)
+//        try {
+//            AsyncBlobStore blobStore = context.getAsyncBlobStore(); // it can be changed
to sync
+//            // BlobStore (returns false if it already exists)
+//            ListenableFuture<Boolean> container = blobStore.createContainerInLocation(
null, bucketName );
+//            if ( container.get() ) {
+//                logger.info( "Created bucket " + bucketName );
+//            }
+//        }
+//        catch ( Exception ex ) {
+//            logger.error( "Could not start binary service: {}", ex.getMessage() );
+//            //throw new RuntimeException( ex );
+//        }
+//
+//        try {
+//
+//
+//            AsyncBlobStore blobStore = context.getAsyncBlobStore();
+//            BlobBuilder blobBuilder =
+//                    blobStore.blobBuilder( filename ).payload( inputStream ).calculateMD5().contentType(
"text/plain" );
+//
+//
+//            Blob blob = blobBuilder.build();
+//
+//            ListenableFuture<String> futureETag = blobStore.putBlob( bucketName,
blob, PutOptions.Builder.multipart() );
+//
+//            logger.info( "Uploaded file etag=" + futureETag.get() );
+//        }
+//        catch ( Exception e ) {
+//            logger.error( "Error uploading to blob store", e );
+//        }
+
+    }
+}


Mime
View raw message