Return-Path: X-Original-To: apmail-zest-commits-archive@minotaur.apache.org Delivered-To: apmail-zest-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 04D3A17E13 for ; Fri, 17 Apr 2015 16:08:14 +0000 (UTC) Received: (qmail 47370 invoked by uid 500); 17 Apr 2015 16:08:13 -0000 Delivered-To: apmail-zest-commits-archive@zest.apache.org Received: (qmail 47319 invoked by uid 500); 17 Apr 2015 16:08:13 -0000 Mailing-List: contact commits-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list commits@zest.apache.org Received: (qmail 47240 invoked by uid 99); 17 Apr 2015 16:08:13 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Apr 2015 16:08:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9BB8AE0280; Fri, 17 Apr 2015 16:08:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: niclas@apache.org To: commits@zest.apache.org Date: Fri, 17 Apr 2015 16:08:23 -0000 Message-Id: <3418c796fa4640fc858c69ef104e9f48@git.apache.org> In-Reply-To: <2da16a2ab3144bd6bd2beabd68134615@git.apache.org> References: <2da16a2ab3144bd6bd2beabd68134615@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [11/50] [abbrv] zest-qi4j git commit: JClouds EntityStore now use JClouds 1.7.3 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 Authored: Thu Jun 12 14:56:47 2014 +0200 Committer: Paul Merlin 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 allApis = Maps.uniqueIndex( Apis.viewableAs( BlobStoreContext.class ), Apis - .idFunction() ); + private static final Map allApis = Maps.uniqueIndex( + Apis.viewableAs( BlobStoreContext.class ), + Apis.idFunction() + ); - private static final Map appProviders = Maps.uniqueIndex( Providers.viewableAs( BlobStoreContext.class ), Providers - .idFunction() ); + private static final Map appProviders = Maps.uniqueIndex( + Providers.viewableAs( BlobStoreContext.class ), + Providers.idFunction() + ); - private static final Set allKeys = ImmutableSet.copyOf( Iterables.concat( appProviders.keySet(), allApis.keySet() ) ); + private static final Set allKeys = ImmutableSet.copyOf( + Iterables.concat( appProviders.keySet(), allApis.keySet() ) + ); @This private Configuration 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() { - @Override public void transferTo( Output output ) throws IOException, ReceiverThrowableType { - output.receiveFrom( new Sender() - { - - @Override - public void sendTo( Receiver receiver ) - throws ReceiverThrowableType, IOException + output.receiveFrom( + new Sender() { - for( StorageMetadata stored : storeContext.getBlobStore().list() ) + @Override + public void sendTo( Receiver 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",