diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java index a31edee8e0..782850f39a 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java @@ -52,6 +52,7 @@ import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.blobstore.internal.BaseAsyncBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; @@ -255,7 +256,8 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore { } @Override - public ListenableFuture putBlobMultipart(String container, Blob blob) { + public ListenableFuture putBlob(String container, Blob blob, PutOptions options) { + // TODO implement options return putBlob(container, blob); } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java index c058253276..e0b8344a85 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java @@ -44,6 +44,7 @@ import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.blobstore.internal.BaseBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; @@ -214,7 +215,8 @@ public class AtmosBlobStore extends BaseBlobStore { * Since there is no etag support in atmos, we just return the path. */ @Override - public String putBlobMultipart(String container, Blob blob) { + public String putBlob(String container, Blob blob, PutOptions options) { + // TODO implement options return putBlob(container, blob); } diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java index 52a3b45dcb..ef861375cb 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java @@ -82,6 +82,7 @@ import org.jclouds.blobstore.internal.BaseAsyncBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.GetOptions; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.strategy.IfDirectoryReturnNameStrategy; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; @@ -663,7 +664,8 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore { } @Override - public ListenableFuture putBlobMultipart(String container, Blob blob) { + public ListenableFuture putBlob(String container, Blob blob, PutOptions options) { + // TODO implement options return putBlob(container, blob); } diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStore.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStore.java index 983518f88d..d9b721c334 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStore.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStore.java @@ -28,5 +28,5 @@ import org.jclouds.concurrent.Timeout; * * @author Alfredo "Rainbowbreeze" Morresi */ -@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) public interface FilesystemBlobStore extends BlobStore { +@Timeout(duration = 2, timeUnit = TimeUnit.MINUTES) public interface FilesystemBlobStore extends BlobStore { } diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java index 6ec8a8172a..591cb2258a 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java @@ -41,6 +41,7 @@ import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.blobstore.internal.BaseAsyncBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; @@ -252,7 +253,8 @@ public class S3AsyncBlobStore extends BaseAsyncBlobStore { } @Override - public ListenableFuture putBlobMultipart(String container, Blob blob) { + public ListenableFuture putBlob(String container, Blob blob, PutOptions options) { + // TODO implement options return putBlob(container, blob); } diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java index 5bfda8bbba..479a565195 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java @@ -38,6 +38,7 @@ import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.blobstore.internal.BaseBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; @@ -247,8 +248,9 @@ public class S3BlobStore extends BaseBlobStore { * object */ @Override - public String putBlobMultipart(String container, Blob blob) { - return sync.putObject(container, blob2Object.apply(blob)); + public String putBlob(String container, Blob blob, PutOptions options) { + // TODO implement options + return putBlob(container, blob); } /** diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java index 6509df96c8..5be3fef43b 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java @@ -41,6 +41,7 @@ import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.blobstore.internal.BaseAsyncBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; @@ -237,7 +238,8 @@ public class SwiftAsyncBlobStore extends BaseAsyncBlobStore { } @Override - public ListenableFuture putBlobMultipart(String container, Blob blob) { + public ListenableFuture putBlob(String container, Blob blob, PutOptions options) { + // TODO implement options return putBlob(container, blob); } diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java index 68239ceda4..6dc175e50c 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java @@ -38,6 +38,7 @@ import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.blobstore.internal.BaseBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; @@ -205,7 +206,8 @@ public class SwiftBlobStore extends BaseBlobStore { * object */ @Override - public String putBlobMultipart(String container, Blob blob) { + public String putBlob(String container, Blob blob, PutOptions options) { + // TODO implement options return putBlob(container, blob); } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java index 6340dd422a..2aa2025873 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java @@ -31,9 +31,9 @@ import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.GetOptions; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.domain.Location; -import com.google.common.annotations.Beta; import com.google.common.util.concurrent.ListenableFuture; /** @@ -130,15 +130,14 @@ public interface AsyncBlobStore { ListenableFuture blobExists(String container, String name); /** - * @see BlobStore#putBlob + * @see BlobStore#putBlob(String,Blob) */ ListenableFuture putBlob(String container, Blob blob); /** - * @see BlobStore#putBlobMultipart + * @see BlobStore#putBlob(String,Blob,PutOptions) */ - @Beta - ListenableFuture putBlobMultipart(String container, Blob blob); + ListenableFuture putBlob(String container, Blob blob, PutOptions options); /** * @see BlobStore#blobMetadata diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java index 2a51305434..2e51bcfdae 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java @@ -31,10 +31,9 @@ import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.GetOptions; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.domain.Location; -import com.google.common.annotations.Beta; - /** * Synchronous access to a BlobStore such as Amazon S3 * @@ -214,20 +213,19 @@ public interface BlobStore { /** * Adds a {@code Blob} representing the data at location {@code container/blob.metadata.name} - * using multipart strategies. + * options using multipart strategies. * * @param container * container to place the blob. * @param blob * fully qualified name relative to the container. * @param options - * byte range or condition options + * byte range options * @return etag of the blob you uploaded, possibly null where etags are unsupported * @throws ContainerNotFoundException * if the container doesn't exist */ - @Beta - String putBlobMultipart(String container, Blob blob); + String putBlob(String container, Blob blob, PutOptions options); /** * Retrieves the metadata of a {@code Blob} at location {@code container/name} diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java index 5504dc9c6a..78736da3e8 100755 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java @@ -81,6 +81,7 @@ import org.jclouds.blobstore.internal.BaseAsyncBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.GetOptions; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.strategy.IfDirectoryReturnNameStrategy; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; @@ -689,8 +690,8 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore { } @Override - public ListenableFuture putBlobMultipart(String container, Blob blob) { - // TODO implement + public ListenableFuture putBlob(String container, Blob blob, PutOptions options) { + // TODO implement options return putBlob(container, blob); } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/binders/BindMapToHeadersWithPrefix.java b/blobstore/src/main/java/org/jclouds/blobstore/binders/BindMapToHeadersWithPrefix.java index fe94f26e3c..0cd75bac9d 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/binders/BindMapToHeadersWithPrefix.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/binders/BindMapToHeadersWithPrefix.java @@ -67,7 +67,7 @@ public class BindMapToHeadersWithPrefix implements Binder { @Override public R bindToRequest(R request, Object input) { - checkArgument(checkNotNull(input, "input") instanceof Map, "this binder is only valid for Maps!"); + checkArgument(checkNotNull(input, "input") instanceof Map, "this binder is only valid for Maps!"); checkNotNull(request, "request"); @SuppressWarnings("unchecked") diff --git a/blobstore/src/main/java/org/jclouds/blobstore/options/PutOptions.java b/blobstore/src/main/java/org/jclouds/blobstore/options/PutOptions.java new file mode 100644 index 0000000000..0c3c467646 --- /dev/null +++ b/blobstore/src/main/java/org/jclouds/blobstore/options/PutOptions.java @@ -0,0 +1,109 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.blobstore.options; + +/** + * Contains options supported in the put blob operation.

+ * Usage

The recommended way to instantiate a PutOptions object is to statically import + * PutOptions.* and invoke a static creation method followed by an instance mutator (if needed): + *

+ * + * import static org.jclouds.blobstore.options.PutOptions.Builder.* + * eTag = blobStore.putBlob("container", blob, multipart()); + * + * + * @author Adrian Cole + */ +public class PutOptions implements Cloneable { + + public static final ImmutablePutOptions NONE = new ImmutablePutOptions(new PutOptions()); + + private boolean multipart; + + public PutOptions() { + } + + PutOptions(boolean multipart) { + this.multipart = multipart; + } + + public static class ImmutablePutOptions extends PutOptions { + private final PutOptions delegate; + + public ImmutablePutOptions(PutOptions delegate) { + this.delegate = delegate; + } + + @Override + public boolean isMultipart() { + return delegate.isMultipart(); + } + + @Override + public PutOptions multipart() { + throw new UnsupportedOperationException(); + } + + @Override + public PutOptions clone() { + return delegate.clone(); + } + + @Override + public String toString() { + return delegate.toString(); + } + + } + + public boolean isMultipart() { + return multipart; + } + + /** + * split large blobs into pieces, if supported by the provider + */ + public PutOptions multipart() { + this.multipart = true; + return this; + } + + public static class Builder { + + /** + * @see PutOptions#multipart() + */ + public static PutOptions multipart() { + PutOptions options = new PutOptions(); + return options.multipart(); + } + + } + + @Override + public PutOptions clone() { + return new PutOptions(multipart); + } + + @Override + public String toString() { + return "[multipart=" + multipart + "]"; + } +} diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java index 0b4b5cfeab..4bd3ad01c5 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java @@ -34,6 +34,7 @@ import org.jclouds.aws.s3.blobstore.strategy.AsyncMultipartUploadStrategy; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.functions.BlobToHttpGetOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; @@ -74,7 +75,7 @@ public class AWSS3AsyncBlobStore extends S3AsyncBlobStore { } @Override - public ListenableFuture putBlobMultipart(String container, Blob blob) { + public ListenableFuture putBlob(String container, Blob blob, PutOptions options) { // need to use a provider if the strategy object is stateful return multipartUploadStrategy.get().execute(container, blob); } diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java index f00b14617d..698af2556b 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java @@ -30,6 +30,7 @@ import org.jclouds.aws.s3.blobstore.strategy.MultipartUploadStrategy; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.functions.BlobToHttpGetOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; @@ -69,8 +70,8 @@ public class AWSS3BlobStore extends S3BlobStore { } @Override - public String putBlobMultipart(String container, Blob blob) { - // need to use a provider if the strategy object is stateful + public String putBlob(String container, Blob blob, PutOptions options) { + // need to use a provider if the strategy object is stateful return multipartUploadStrategy.get().execute(container, blob); } } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java index 6833bda5b1..50159a148b 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java @@ -36,6 +36,7 @@ import java.util.zip.GZIPInputStream; import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.KeyNotFoundException; import org.jclouds.blobstore.domain.Blob; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.http.BaseJettyTest; import org.jclouds.http.apachehc.config.ApacheHCHttpCommandExecutorServiceModule; import org.jclouds.io.Payload; @@ -153,7 +154,7 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest { blobStore.createContainerInLocation(null, containerName); Blob blob = blobStore.blobBuilder("const.txt") .payload(new File("target/const.txt")).build(); - blobStore.putBlobMultipart(containerName, blob); + blobStore.putBlob(containerName, blob, PutOptions.Builder.multipart()); } finally { returnContainer(containerName); } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java index 1229716b0b..64329934d1 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java @@ -54,6 +54,7 @@ import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.blobstore.internal.BaseAsyncBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; import org.jclouds.concurrent.Futures; @@ -246,7 +247,8 @@ public class AzureAsyncBlobStore extends BaseAsyncBlobStore { } @Override - public ListenableFuture putBlobMultipart(String container, Blob blob) { + public ListenableFuture putBlob(String container, Blob blob, PutOptions options) { + // TODO implement options return putBlob(container, blob); } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java index 84fb45c0fc..b43d0f4ab1 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java @@ -48,6 +48,7 @@ import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.blobstore.internal.BaseBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; import org.jclouds.domain.Location; @@ -203,7 +204,8 @@ public class AzureBlobStore extends BaseBlobStore { * object */ @Override - public String putBlobMultipart(String container, Blob blob) { + public String putBlob(String container, Blob blob, PutOptions options) { + // TODO implement options return putBlob(container, blob); }