polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [11/50] [abbrv] zest-qi4j git commit: JClouds EntityStore now use JClouds 1.7.3
Date Fri, 17 Apr 2015 16:08:23 GMT
JClouds EntityStore now use JClouds 1.7.3


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/b28f2c41
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/b28f2c41
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/b28f2c41

Branch: refs/heads/3.0
Commit: b28f2c41761aae92838571edb2d3a90425c60488
Parents: a4cf8c7
Author: Paul Merlin <paul@nosphere.org>
Authored: Thu Jun 12 14:56:47 2014 +0200
Committer: Paul Merlin <paul@nosphere.org>
Committed: Thu Jun 12 14:56:47 2014 +0200

----------------------------------------------------------------------
 extensions/entitystore-jclouds/build.gradle     |   2 -
 .../jclouds/JCloudsMapEntityStoreMixin.java     | 175 ++++++++++---------
 libraries.gradle                                |   4 +-
 3 files changed, 98 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b28f2c41/extensions/entitystore-jclouds/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/build.gradle b/extensions/entitystore-jclouds/build.gradle
index 7b5e1e9..413503b 100644
--- a/extensions/entitystore-jclouds/build.gradle
+++ b/extensions/entitystore-jclouds/build.gradle
@@ -6,13 +6,11 @@ dependencies {
 
     compile project( ":org.qi4j.core:org.qi4j.core.bootstrap" )
     compile project( ":org.qi4j.libraries:org.qi4j.library.locking" )
-    compile libraries.guava
     compile libraries.jclouds_core
     compile libraries.jclouds_blobstore
 
     testCompile project( ":org.qi4j.core:org.qi4j.core.testsupport" )
     testCompile(project(":org.qi4j.extensions:org.qi4j.extension.valueserialization-orgjson"))
-    testCompile libraries.jclouds_filesystem
 
     testRuntime project( ":org.qi4j.core:org.qi4j.core.runtime" )
     testRuntime libraries.logback

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b28f2c41/extensions/entitystore-jclouds/src/main/java/org/qi4j/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/main/java/org/qi4j/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
b/extensions/entitystore-jclouds/src/main/java/org/qi4j/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
index 6b22463..c250dcd 100644
--- a/extensions/entitystore-jclouds/src/main/java/org/qi4j/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
+++ b/extensions/entitystore-jclouds/src/main/java/org/qi4j/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Paul Merlin. All Rights Reserved.
+ * Copyright (c) 2012-2014, Paul Merlin. All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@ package org.qi4j.entitystore.jclouds;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
+import com.google.common.io.ByteSource;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -54,6 +55,7 @@ import org.qi4j.spi.entitystore.helpers.MapEntityStore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Charsets.UTF_8;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.collect.Iterables.contains;
 import static org.qi4j.api.entity.EntityReference.parseEntityReference;
@@ -73,13 +75,19 @@ public class JCloudsMapEntityStoreMixin
 
     private static final Logger LOGGER = LoggerFactory.getLogger( "org.qi4j.entitystore.jclouds"
);
 
-    private static final Map<String, ApiMetadata> allApis = Maps.uniqueIndex( Apis.viewableAs(
BlobStoreContext.class ), Apis
-        .idFunction() );
+    private static final Map<String, ApiMetadata> allApis = Maps.uniqueIndex(
+        Apis.viewableAs( BlobStoreContext.class ),
+        Apis.idFunction()
+    );
 
-    private static final Map<String, ProviderMetadata> appProviders = Maps.uniqueIndex(
Providers.viewableAs( BlobStoreContext.class ), Providers
-        .idFunction() );
+    private static final Map<String, ProviderMetadata> appProviders = Maps.uniqueIndex(
+        Providers.viewableAs( BlobStoreContext.class ),
+        Providers.idFunction()
+    );
 
-    private static final Set<String> allKeys = ImmutableSet.copyOf( Iterables.concat(
appProviders.keySet(), allApis.keySet() ) );
+    private static final Set<String> allKeys = ImmutableSet.copyOf(
+        Iterables.concat( appProviders.keySet(), allApis.keySet() )
+    );
 
     @This
     private Configuration<JCloudsMapEntityStoreConfiguration> configuration;
@@ -165,9 +173,10 @@ public class JCloudsMapEntityStoreMixin
         {
             throw new EntityNotFoundException( entityReference );
         }
-        InputStream input = payload.getInput();
+        InputStream input = null;
         try
         {
+            input = payload.openStream();
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             Inputs.byteBuffer( input, 4096 ).transferTo( Outputs.byteBuffer( baos ) );
             return new StringReader( baos.toString( "UTF-8" ) );
@@ -178,12 +187,15 @@ public class JCloudsMapEntityStoreMixin
         }
         finally
         {
-            try
-            {
-                input.close();
-            }
-            catch( IOException ignored )
+            if( input != null )
             {
+                try
+                {
+                    input.close();
+                }
+                catch( IOException ignored )
+                {
+                }
             }
         }
     }
@@ -193,61 +205,63 @@ public class JCloudsMapEntityStoreMixin
         throws IOException
     {
         final BlobStore blobStore = storeContext.getBlobStore();
-
-        changes.visitMap( new MapChanger()
-        {
-
-            @Override
-            public Writer newEntity( final EntityReference ref, EntityDescriptor entityDescriptor
)
-                throws IOException
+        changes.visitMap(
+            new MapChanger()
             {
-                return new StringWriter()
+                @Override
+                public Writer newEntity( final EntityReference ref, EntityDescriptor entityDescriptor
)
+                    throws IOException
                 {
-
-                    @Override
-                    public void close()
-                        throws IOException
+                    return new StringWriter()
                     {
-                        super.close();
-                        Blob blob = blobStore.blobBuilder( ref.identity() ).payload( toString()
).build();
-                        blobStore.putBlob( container, blob );
-                    }
-                };
-            }
-
-            @Override
-            public Writer updateEntity( final EntityReference ref, EntityDescriptor entityDescriptor
)
-                throws IOException
-            {
-                if( !blobStore.blobExists( container, ref.identity() ) )
-                {
-                    throw new EntityNotFoundException( ref );
+                        @Override
+                        public void close()
+                        throws IOException
+                        {
+                            super.close();
+                            Blob blob = blobStore.blobBuilder( ref.identity() )
+                                .payload( ByteSource.wrap( toString().getBytes( UTF_8 ) )
)
+                                .build();
+                            blobStore.putBlob( container, blob );
+                        }
+                    };
                 }
-                return new StringWriter()
-                {
 
-                    @Override
-                    public void close()
-                        throws IOException
+                @Override
+                public Writer updateEntity( final EntityReference ref, EntityDescriptor entityDescriptor
)
+                    throws IOException
+                {
+                    if( !blobStore.blobExists( container, ref.identity() ) )
                     {
-                        super.close();
-                        Blob blob = blobStore.blobBuilder( ref.identity() ).payload( toString()
).build();
-                        blobStore.putBlob( container, blob );
+                        throw new EntityNotFoundException( ref );
                     }
-                };
-            }
+                    return new StringWriter()
+                    {
+                        @Override
+                        public void close()
+                        throws IOException
+                        {
+                            super.close();
+                            Blob blob = blobStore.blobBuilder( ref.identity() )
+                                .payload( ByteSource.wrap( toString().getBytes( UTF_8 ) )
)
+                                .build();
+                            blobStore.putBlob( container, blob );
+                        }
+                    };
+                }
 
-            @Override
-            public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor
)
-                throws EntityNotFoundException
-            {
-                if( !blobStore.blobExists( container, ref.identity() ) )
+                @Override
+                public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor
)
+                    throws EntityNotFoundException
                 {
-                    throw new EntityNotFoundException( ref );
+                    if( !blobStore.blobExists( container, ref.identity() ) )
+                    {
+                        throw new EntityNotFoundException( ref );
+                    }
+                    blobStore.removeBlob( container, ref.identity() );
                 }
-                blobStore.removeBlob( container, ref.identity() );
             }
-        } );
+        );
     }
 
     @Override
@@ -255,45 +269,48 @@ public class JCloudsMapEntityStoreMixin
     {
         return new Input<Reader, IOException>()
         {
-
             @Override
             public <ReceiverThrowableType extends Throwable> void transferTo( Output<?
super Reader, ReceiverThrowableType> output )
                 throws IOException, ReceiverThrowableType
             {
-                output.receiveFrom( new Sender<Reader, IOException>()
-                {
-
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<?
super Reader, ReceiverThrowableType> receiver )
-                        throws ReceiverThrowableType, IOException
+                output.receiveFrom(
+                    new Sender<Reader, IOException>()
                     {
-                        for( StorageMetadata stored : storeContext.getBlobStore().list()
)
+                        @Override
+                        public <ReceiverThrowableType extends Throwable> void sendTo(
Receiver<? super Reader, ReceiverThrowableType> receiver )
+                            throws ReceiverThrowableType, IOException
                         {
-                            Payload payload = storeContext.getBlobStore().getBlob( container,
stored.getName() ).getPayload();
-                            if( payload == null )
-                            {
-                                throw new EntityNotFoundException( parseEntityReference(
stored.getName() ) );
-                            }
-                            InputStream input = payload.getInput();
-                            try
-                            {
-                                receiver.receive( new InputStreamReader( input, "UTF-8" )
);
-                            }
-                            finally
+                            for( StorageMetadata stored : storeContext.getBlobStore().list()
)
                             {
+                                Payload payload = storeContext.getBlobStore().getBlob( container,
stored.getName() ).getPayload();
+                                if( payload == null )
+                                {
+                                    throw new EntityNotFoundException( parseEntityReference(
stored.getName() ) );
+                                }
+                                InputStream input = null;
                                 try
                                 {
-                                    input.close();
+                                    input = payload.openStream();
+                                    receiver.receive( new InputStreamReader( input, "UTF-8"
) );
                                 }
-                                catch( IOException ignored )
+                                finally
                                 {
+                                    if( input != null )
+                                    {
+                                        try
+                                        {
+                                            input.close();
+                                        }
+                                        catch( IOException ignored )
+                                        {
+                                        }
+                                    }
                                 }
                             }
                         }
                     }
-                } );
+                );
             }
         };
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b28f2c41/libraries.gradle
----------------------------------------------------------------------
diff --git a/libraries.gradle b/libraries.gradle
index f162e44..b2a3391a 100644
--- a/libraries.gradle
+++ b/libraries.gradle
@@ -23,7 +23,7 @@ def httpClientVersion = '4.2.2' // 4.3.4 exists
 def jacksonVersion = '2.4.0'
 def javascriptVersion = '1.7R4'
 def javasqlgeneratorVersion = '0.3.2'
-def jcloudsVersion = '1.7.0'
+def jcloudsVersion = '1.7.3'
 def jdbmVersion = '2.4'
 def jdomVersion = '2.0.2'
 def jedisVersion = '2.5.1'
@@ -208,7 +208,7 @@ rootProject.ext {
           h2: "com.h2database:h2:$h2Version",
           hazelcast: "com.hazelcast:hazelcast:$hazelcastVersion",
           jclouds_core: "org.apache.jclouds:jclouds-core:$jcloudsVersion",
-          jclouds_blobstore: "org.apache.jclouds:jclouds-blobstore:$jcloudsVersion",
+          jclouds_blobstore: "org.apache.jclouds:jclouds-allblobstore:$jcloudsVersion",
           jclouds_filesystem: "org.apache.jclouds.api:filesystem:$jcloudsVersion",
           jdbm: "jdbm:jdbm:$jdbmVersion",
           jedis: "redis.clients:jedis:$jedisVersion",


Mime
View raw message