You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2017/02/26 22:47:46 UTC

[24/50] [abbrv] polygene-java git commit: jclouds-es: add convenience ‘endpoint’ configuration property

jclouds-es: add convenience \u2018endpoint\u2019 configuration property

It was already possible to set it using the \u2018properties\u2019 configuration
property, added for convenience.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/5a2782c8
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/5a2782c8
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/5a2782c8

Branch: refs/heads/serialization-3.0
Commit: 5a2782c8194801e4f2bf56fcd50a5ecb4f5553ae
Parents: 120a15c
Author: Paul Merlin <pa...@apache.org>
Authored: Sun Feb 26 12:32:28 2017 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Sun Feb 26 12:32:28 2017 +0100

----------------------------------------------------------------------
 .../JCloudsMapEntityStoreConfiguration.java     |  4 +++
 .../jclouds/JCloudsMapEntityStoreMixin.java     | 33 +++++++++++++-------
 2 files changed, 25 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5a2782c8/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreConfiguration.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreConfiguration.java b/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreConfiguration.java
index 452994c..3123555 100644
--- a/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreConfiguration.java
+++ b/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreConfiguration.java
@@ -47,6 +47,10 @@ public interface JCloudsMapEntityStoreConfiguration
      * Name of the JClouds container to use. Defaults to 'polygene-entities'.
      */
     @Optional Property<String> container();
+    /**
+     * Endpoint for the BlobStore provider.
+     */
+    @Optional Property<String> endpoint();
     // END SNIPPET: config
 
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5a2782c8/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java b/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
index 21a2abb..38cdd80 100644
--- a/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
+++ b/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
@@ -104,6 +104,7 @@ public class JCloudsMapEntityStoreMixin
         String provider = configuration.get().provider().get();
         String identifier = configuration.get().identifier().get();
         String credentials = configuration.get().credential().get();
+        String endpoint = configuration.get().endpoint().get();
         Map<String, String> properties = configuration.get().properties().get();
         container = configuration.get().container().get();
         if( provider != null )
@@ -118,10 +119,11 @@ public class JCloudsMapEntityStoreMixin
         {
             container = "polygene-entities";
         }
-        storeContext = ContextBuilder.newBuilder( provider ).
-            credentials( identifier, credentials ).
-            overrides( asProperties( properties ) ).
-            buildView( BlobStoreContext.class );
+        storeContext = ContextBuilder.newBuilder( provider )
+                                     .endpoint( endpoint == null ? "" : endpoint )
+                                     .credentials( identifier, credentials )
+                                     .overrides( asProperties( properties ) )
+                                     .buildView( BlobStoreContext.class );
         BlobStore blobStore = storeContext.getBlobStore();
         if( !blobStore.containerExists( container ) )
         {
@@ -200,12 +202,14 @@ public class JCloudsMapEntityStoreMixin
                     {
                         @Override
                         public void close()
-                        throws IOException
+                            throws IOException
                         {
                             super.close();
+                            ByteSource payload = ByteSource.wrap( toString().getBytes( UTF_8 ) );
                             Blob blob = blobStore.blobBuilder( ref.identity().toString() )
-                                .payload( ByteSource.wrap( toString().getBytes( UTF_8 ) ) )
-                                .build();
+                                                 .payload( payload )
+                                                 .contentLength( payload.size() )
+                                                 .build();
                             blobStore.putBlob( container, blob );
                         }
                     };
@@ -223,12 +227,14 @@ public class JCloudsMapEntityStoreMixin
                     {
                         @Override
                         public void close()
-                        throws IOException
+                            throws IOException
                         {
                             super.close();
+                            ByteSource payload = ByteSource.wrap( toString().getBytes( UTF_8 ) );
                             Blob blob = blobStore.blobBuilder( ref.identity().toString() )
-                                .payload( ByteSource.wrap( toString().getBytes( UTF_8 ) ) )
-                                .build();
+                                                 .payload( payload )
+                                                 .contentLength( payload.size() )
+                                                 .build();
                             blobStore.putBlob( container, blob );
                         }
                     };
@@ -255,10 +261,13 @@ public class JCloudsMapEntityStoreMixin
             .getBlobStore().list( container ).stream()
             .map( metadata ->
                   {
-                      Payload payload = storeContext.getBlobStore().getBlob( container, metadata.getName() ).getPayload();
+                      Payload payload = storeContext.getBlobStore()
+                                                    .getBlob( container, metadata.getName() )
+                                                    .getPayload();
                       if( payload == null )
                       {
-                          throw new EntityNotFoundException( EntityReference.parseEntityReference( metadata.getName() ) );
+                          EntityReference reference = EntityReference.parseEntityReference( metadata.getName() );
+                          throw new EntityNotFoundException( reference );
                       }
                       try( InputStream input = payload.openStream() )
                       {