mirror of https://github.com/apache/jclouds.git
Issue 73: updated to allow container listings to have pagination
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2037 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
cc0a346289
commit
830d90874d
|
@ -24,7 +24,7 @@
|
|||
package org.jclouds.aws.s3.blobstore;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.blobstore.options.ListOptions.Builder.recursive;
|
||||
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.recursive;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.Callable;
|
||||
|
@ -50,9 +50,11 @@ import org.jclouds.blobstore.attr.ConsistencyModel;
|
|||
import org.jclouds.blobstore.attr.ConsistencyModels;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListResponse;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.domain.internal.ListResponseImpl;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.ClearListStrategy;
|
||||
import org.jclouds.concurrent.FutureFunctionWrapper;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
|
@ -60,7 +62,6 @@ import org.jclouds.logging.Logger.LoggerFactory;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@ConsistencyModel(ConsistencyModels.EVENTUAL)
|
||||
public class S3BlobStore implements BlobStore {
|
||||
|
@ -150,17 +151,20 @@ public class S3BlobStore implements BlobStore {
|
|||
return wrapFuture(returnVal, object2Blob);
|
||||
}
|
||||
|
||||
public Future<? extends SortedSet<? extends ResourceMetadata>> list() {
|
||||
return wrapFuture(connection.listOwnedBuckets(),
|
||||
new Function<SortedSet<BucketMetadata>, SortedSet<? extends ResourceMetadata>>() {
|
||||
public SortedSet<? extends ResourceMetadata> apply(SortedSet<BucketMetadata> from) {
|
||||
return Sets.newTreeSet(Iterables.transform(from, bucket2ResourceMd));
|
||||
public Future<? extends ListResponse<? extends ResourceMetadata>> list() {
|
||||
return wrapFuture(
|
||||
connection.listOwnedBuckets(),
|
||||
new Function<SortedSet<BucketMetadata>, org.jclouds.blobstore.domain.ListResponse<? extends ResourceMetadata>>() {
|
||||
public org.jclouds.blobstore.domain.ListResponse<? extends ResourceMetadata> apply(
|
||||
SortedSet<BucketMetadata> from) {
|
||||
return new ListResponseImpl<ResourceMetadata>(Iterables.transform(from,
|
||||
bucket2ResourceMd), null, null, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Future<? extends BoundedSortedSet<? extends ResourceMetadata>> list(String container,
|
||||
ListOptions... optionsList) {
|
||||
public Future<? extends ListContainerResponse<? extends ResourceMetadata>> list(String container,
|
||||
ListContainerOptions... optionsList) {
|
||||
ListBucketOptions httpOptions = container2BucketListOptions.apply(optionsList);
|
||||
Future<ListBucketResponse> returnVal = connection.listBucket(container, httpOptions);
|
||||
return wrapFuture(returnVal, bucket2ResourceList);
|
||||
|
|
|
@ -26,7 +26,7 @@ package org.jclouds.aws.s3.blobstore.functions;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.s3.options.ListBucketOptions;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
|
@ -34,9 +34,9 @@ import com.google.common.base.Function;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class BucketToContainerListOptions implements Function<ListBucketOptions[], ListOptions> {
|
||||
public ListOptions apply(ListBucketOptions[] optionsList) {
|
||||
ListOptions options = new ListOptions();
|
||||
public class BucketToContainerListOptions implements Function<ListBucketOptions[], ListContainerOptions> {
|
||||
public ListContainerOptions apply(ListBucketOptions[] optionsList) {
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
if (optionsList.length != 0) {
|
||||
if (optionsList[0].getDelimiter() == null) {
|
||||
options.recursive();
|
||||
|
|
|
@ -29,9 +29,9 @@ import javax.inject.Inject;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.s3.domain.ListBucketResponse;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.domain.internal.BoundedTreeSet;
|
||||
import org.jclouds.blobstore.domain.internal.ListContainerResponseImpl;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
@ -42,7 +42,7 @@ import com.google.common.collect.Sets;
|
|||
*/
|
||||
@Singleton
|
||||
public class BucketToResourceList implements
|
||||
Function<ListBucketResponse, BoundedSortedSet<? extends ResourceMetadata>> {
|
||||
Function<ListBucketResponse, ListContainerResponse<? extends ResourceMetadata>> {
|
||||
private final ObjectToBlobMetadata object2blobMd;
|
||||
private final CommonPrefixesToResourceMetadata prefix2ResourceMd;
|
||||
|
||||
|
@ -53,10 +53,10 @@ public class BucketToResourceList implements
|
|||
this.prefix2ResourceMd = prefix2ResourceMd;
|
||||
}
|
||||
|
||||
public BoundedSortedSet<? extends ResourceMetadata> apply(ListBucketResponse from) {
|
||||
public ListContainerResponse<? extends ResourceMetadata> apply(ListBucketResponse from) {
|
||||
SortedSet<ResourceMetadata> contents = Sets.newTreeSet(Iterables.concat(Iterables.transform(
|
||||
from, object2blobMd), prefix2ResourceMd.apply(from.getCommonPrefixes())));
|
||||
return new BoundedTreeSet<ResourceMetadata>(contents, from.getPrefix(), from.getMarker(),
|
||||
return new ListContainerResponseImpl<ResourceMetadata>(contents, from.getPrefix(), from.getMarker(),
|
||||
from.getMaxKeys(), from.isTruncated());
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ package org.jclouds.aws.s3.blobstore.functions;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.s3.options.ListBucketOptions;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
|
@ -34,8 +34,8 @@ import com.google.common.base.Function;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ContainerToBucketListOptions implements Function<ListOptions[], ListBucketOptions> {
|
||||
public ListBucketOptions apply(ListOptions[] optionsList) {
|
||||
public class ContainerToBucketListOptions implements Function<ListContainerOptions[], ListBucketOptions> {
|
||||
public ListBucketOptions apply(ListContainerOptions[] optionsList) {
|
||||
ListBucketOptions httpOptions = new ListBucketOptions();
|
||||
if (optionsList.length != 0) {
|
||||
if (!optionsList[0].isRecursive()) {
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.jclouds.aws.s3.domain.MutableObjectMetadata;
|
|||
import org.jclouds.aws.s3.domain.ObjectMetadata;
|
||||
import org.jclouds.aws.s3.domain.internal.TreeSetListBucketResponse;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.domain.ResourceType;
|
||||
|
||||
|
@ -47,7 +47,7 @@ import com.google.common.collect.Sets;
|
|||
*/
|
||||
@Singleton
|
||||
public class ResourceToBucketList implements
|
||||
Function<BoundedSortedSet<? extends ResourceMetadata>, ListBucketResponse> {
|
||||
Function<ListContainerResponse<? extends ResourceMetadata>, ListBucketResponse> {
|
||||
private final BlobToObjectMetadata blob2ObjectMd;
|
||||
|
||||
@Inject
|
||||
|
@ -55,9 +55,9 @@ public class ResourceToBucketList implements
|
|||
this.blob2ObjectMd = blob2ObjectMd;
|
||||
}
|
||||
|
||||
public ListBucketResponse apply(BoundedSortedSet<? extends ResourceMetadata> list) {
|
||||
public ListBucketResponse apply(ListContainerResponse<? extends ResourceMetadata> list) {
|
||||
|
||||
SortedSet<ObjectMetadata> contents = Sets.newTreeSet(Iterables.transform(Iterables.filter(
|
||||
Iterable<ObjectMetadata> contents = Iterables.transform(Iterables.filter(
|
||||
list, new Predicate<ResourceMetadata>() {
|
||||
|
||||
public boolean apply(ResourceMetadata input) {
|
||||
|
@ -70,7 +70,7 @@ public class ResourceToBucketList implements
|
|||
return blob2ObjectMd.apply((BlobMetadata) from);
|
||||
}
|
||||
|
||||
}));
|
||||
});
|
||||
|
||||
SortedSet<String> commonPrefixes = Sets.newTreeSet(Iterables.transform(Iterables.filter(list,
|
||||
new Predicate<ResourceMetadata>() {
|
||||
|
@ -87,6 +87,6 @@ public class ResourceToBucketList implements
|
|||
|
||||
}));
|
||||
return new TreeSetListBucketResponse(null, contents, list.getPath(), list.getMarker(), list
|
||||
.getMaxResults(), "/", contents.size() == list.getMaxResults(), commonPrefixes);
|
||||
.getMaxResults(), "/", Iterables.size(contents) == list.getMaxResults(), commonPrefixes);
|
||||
}
|
||||
}
|
|
@ -62,7 +62,7 @@ import org.jclouds.blobstore.domain.MutableBlobMetadata;
|
|||
import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
|
||||
import org.jclouds.blobstore.integration.internal.StubBlobStore;
|
||||
import org.jclouds.blobstore.integration.internal.StubBlobStore.FutureBase;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.concurrent.FutureFunctionWrapper;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
import org.jclouds.logging.Logger.LoggerFactory;
|
||||
|
@ -141,7 +141,7 @@ public class StubS3Client implements S3Client {
|
|||
}
|
||||
|
||||
public Future<ListBucketResponse> listBucket(final String name, ListBucketOptions... optionsList) {
|
||||
ListOptions options = bucket2ContainerListOptions.apply(optionsList);
|
||||
ListContainerOptions options = bucket2ContainerListOptions.apply(optionsList);
|
||||
return wrapFuture(blobStore.list(name, options), resource2BucketList);
|
||||
}
|
||||
|
||||
|
|
|
@ -128,11 +128,6 @@
|
|||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- to keep garbage from previous tests from affecting the performance of the next -->
|
||||
<!--
|
||||
<forkMode>pertest</forkMode>
|
||||
<parallel>classes</parallel>
|
||||
-->
|
||||
<threadCount>1</threadCount>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
package org.jclouds.azure.storage.blob.blobstore;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.blobstore.options.ListOptions.Builder.recursive;
|
||||
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.recursive;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.Callable;
|
||||
|
@ -37,7 +37,6 @@ import org.jclouds.azure.storage.blob.AzureBlobClient;
|
|||
import org.jclouds.azure.storage.blob.blobstore.functions.AzureBlobToBlob;
|
||||
import org.jclouds.azure.storage.blob.blobstore.functions.BlobPropertiesToBlobMetadata;
|
||||
import org.jclouds.azure.storage.blob.blobstore.functions.BlobToAzureBlob;
|
||||
import org.jclouds.azure.storage.blob.blobstore.functions.BlobToHttpGetOptions;
|
||||
import org.jclouds.azure.storage.blob.blobstore.functions.ContainerToResourceMetadata;
|
||||
import org.jclouds.azure.storage.blob.blobstore.functions.ListBlobsResponseToResourceList;
|
||||
import org.jclouds.azure.storage.blob.blobstore.functions.ListOptionsToListBlobsOptions;
|
||||
|
@ -50,9 +49,11 @@ import org.jclouds.blobstore.attr.ConsistencyModel;
|
|||
import org.jclouds.blobstore.attr.ConsistencyModels;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.domain.internal.ListResponseImpl;
|
||||
import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.ClearListStrategy;
|
||||
import org.jclouds.concurrent.FutureFunctionWrapper;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
|
@ -60,7 +61,6 @@ import org.jclouds.logging.Logger.LoggerFactory;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@ConsistencyModel(ConsistencyModels.STRICT)
|
||||
public class AzureBlobStore implements BlobStore {
|
||||
|
@ -78,13 +78,14 @@ public class AzureBlobStore implements BlobStore {
|
|||
private final ExecutorService service;
|
||||
|
||||
@Inject
|
||||
private AzureBlobStore(AzureBlobClient connection, Blob.Factory blobFactory, LoggerFactory logFactory,
|
||||
ClearListStrategy clearContainerStrategy, BlobPropertiesToBlobMetadata object2BlobMd,
|
||||
AzureBlobToBlob object2Blob, BlobToAzureBlob blob2Object,
|
||||
private AzureBlobStore(AzureBlobClient connection, Blob.Factory blobFactory,
|
||||
LoggerFactory logFactory, ClearListStrategy clearContainerStrategy,
|
||||
BlobPropertiesToBlobMetadata object2BlobMd, AzureBlobToBlob object2Blob,
|
||||
BlobToAzureBlob blob2Object,
|
||||
ListOptionsToListBlobsOptions container2ContainerListOptions,
|
||||
BlobToHttpGetOptions blob2ObjectGetOptions,
|
||||
ContainerToResourceMetadata container2ResourceMd, ListBlobsResponseToResourceList container2ResourceList,
|
||||
ExecutorService service) {
|
||||
ContainerToResourceMetadata container2ResourceMd,
|
||||
ListBlobsResponseToResourceList container2ResourceList, ExecutorService service) {
|
||||
this.connection = checkNotNull(connection, "connection");
|
||||
this.blobFactory = checkNotNull(blobFactory, "blobFactory");
|
||||
this.logFactory = checkNotNull(logFactory, "logFactory");
|
||||
|
@ -143,17 +144,20 @@ public class AzureBlobStore implements BlobStore {
|
|||
return wrapFuture(returnVal, object2Blob);
|
||||
}
|
||||
|
||||
public Future<? extends SortedSet<? extends ResourceMetadata>> list() {
|
||||
return wrapFuture(connection.listContainers(),
|
||||
new Function<SortedSet<ListableContainerProperties>, SortedSet<? extends ResourceMetadata>>() {
|
||||
public SortedSet<? extends ResourceMetadata> apply(SortedSet<ListableContainerProperties> from) {
|
||||
return Sets.newTreeSet(Iterables.transform(from, container2ResourceMd));
|
||||
public Future<? extends org.jclouds.blobstore.domain.ListResponse<? extends ResourceMetadata>> list() {
|
||||
return wrapFuture(
|
||||
connection.listContainers(),
|
||||
new Function<SortedSet<ListableContainerProperties>, org.jclouds.blobstore.domain.ListResponse<? extends ResourceMetadata>>() {
|
||||
public org.jclouds.blobstore.domain.ListResponse<? extends ResourceMetadata> apply(
|
||||
SortedSet<ListableContainerProperties> from) {
|
||||
return new ListResponseImpl<ResourceMetadata>(Iterables.transform(from,
|
||||
container2ResourceMd), null, null, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Future<? extends BoundedSortedSet<? extends ResourceMetadata>> list(String container,
|
||||
ListOptions... optionsList) {
|
||||
public Future<? extends ListContainerResponse<? extends ResourceMetadata>> list(String container,
|
||||
ListContainerOptions... optionsList) {
|
||||
ListBlobsOptions httpOptions = container2ContainerListOptions.apply(optionsList);
|
||||
Future<ListBlobsResponse> returnVal = connection.listBlobs(container, httpOptions);
|
||||
return wrapFuture(returnVal, container2ResourceList);
|
||||
|
|
|
@ -26,7 +26,7 @@ package org.jclouds.azure.storage.blob.blobstore.functions;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.azure.storage.blob.options.ListBlobsOptions;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
|
@ -34,9 +34,9 @@ import com.google.common.base.Function;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ListBlobsOptionsToListOptions implements Function<ListBlobsOptions[], ListOptions> {
|
||||
public ListOptions apply(ListBlobsOptions[] optionsList) {
|
||||
ListOptions options = new ListOptions();
|
||||
public class ListBlobsOptionsToListOptions implements Function<ListBlobsOptions[], ListContainerOptions> {
|
||||
public ListContainerOptions apply(ListBlobsOptions[] optionsList) {
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
if (optionsList.length != 0) {
|
||||
if (optionsList[0].getDelimiter() == null) {
|
||||
options.recursive();
|
||||
|
|
|
@ -30,9 +30,9 @@ import javax.inject.Singleton;
|
|||
|
||||
import org.jclouds.azure.storage.blob.domain.ListBlobsResponse;
|
||||
import org.jclouds.azure.storage.blob.domain.ListableBlobProperties;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.domain.internal.BoundedTreeSet;
|
||||
import org.jclouds.blobstore.domain.internal.ListContainerResponseImpl;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
@ -43,7 +43,7 @@ import com.google.common.collect.Sets;
|
|||
*/
|
||||
@Singleton
|
||||
public class ListBlobsResponseToResourceList implements
|
||||
Function<ListBlobsResponse, BoundedSortedSet<? extends ResourceMetadata>> {
|
||||
Function<ListBlobsResponse, ListContainerResponse<? extends ResourceMetadata>> {
|
||||
private final ListableBlobPropertiesToBlobMetadata<ListableBlobProperties> object2blobMd;
|
||||
private final CommonPrefixesToResourceMetadata prefix2ResourceMd;
|
||||
|
||||
|
@ -55,10 +55,10 @@ public class ListBlobsResponseToResourceList implements
|
|||
this.prefix2ResourceMd = prefix2ResourceMd;
|
||||
}
|
||||
|
||||
public BoundedSortedSet<? extends ResourceMetadata> apply(ListBlobsResponse from) {
|
||||
public ListContainerResponse<? extends ResourceMetadata> apply(ListBlobsResponse from) {
|
||||
SortedSet<ResourceMetadata> contents = Sets.newTreeSet(Iterables.concat(Iterables.transform(
|
||||
from, object2blobMd), prefix2ResourceMd.apply(from.getBlobPrefixes())));
|
||||
return new BoundedTreeSet<ResourceMetadata>(contents, from.getPrefix(), from.getMarker(),
|
||||
return new ListContainerResponseImpl<ResourceMetadata>(contents, from.getPrefix(), from.getMarker(),
|
||||
from.getMaxResults(), from.size() == from.getMaxResults());
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ package org.jclouds.azure.storage.blob.blobstore.functions;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.azure.storage.blob.options.ListBlobsOptions;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
|
@ -34,8 +34,8 @@ import com.google.common.base.Function;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ListOptionsToListBlobsOptions implements Function<ListOptions[], ListBlobsOptions> {
|
||||
public ListBlobsOptions apply(ListOptions[] optionsList) {
|
||||
public class ListOptionsToListBlobsOptions implements Function<ListContainerOptions[], ListBlobsOptions> {
|
||||
public ListBlobsOptions apply(ListContainerOptions[] optionsList) {
|
||||
ListBlobsOptions httpOptions = new ListBlobsOptions();
|
||||
if (optionsList.length != 0) {
|
||||
if (!optionsList[0].isRecursive()) {
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.jclouds.azure.storage.blob.domain.ListableBlobProperties;
|
|||
import org.jclouds.azure.storage.blob.domain.MutableBlobProperties;
|
||||
import org.jclouds.azure.storage.blob.domain.internal.TreeSetListBlobsResponse;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.domain.ResourceType;
|
||||
|
||||
|
@ -47,7 +47,7 @@ import com.google.common.collect.Sets;
|
|||
*/
|
||||
@Singleton
|
||||
public class ResourceToListBlobsResponse implements
|
||||
Function<BoundedSortedSet<? extends ResourceMetadata>, ListBlobsResponse> {
|
||||
Function<ListContainerResponse<? extends ResourceMetadata>, ListBlobsResponse> {
|
||||
private final BlobMetadataToBlobProperties blob2ObjectMd;
|
||||
|
||||
@Inject
|
||||
|
@ -55,7 +55,7 @@ public class ResourceToListBlobsResponse implements
|
|||
this.blob2ObjectMd = blob2ObjectMd;
|
||||
}
|
||||
|
||||
public ListBlobsResponse apply(BoundedSortedSet<? extends ResourceMetadata> list) {
|
||||
public ListBlobsResponse apply(ListContainerResponse<? extends ResourceMetadata> list) {
|
||||
|
||||
Iterable<ListableBlobProperties> contents = Iterables.transform(Iterables.filter(list,
|
||||
new Predicate<ResourceMetadata>() {
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.jclouds.azure.storage.blob.domain.BlobProperties;
|
|||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.functions.ObjectMD5;
|
||||
import org.jclouds.blobstore.internal.BlobRuntimeException;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||
import org.jclouds.blobstore.strategy.ListBlobMetadataStrategy;
|
||||
import org.jclouds.util.Utils;
|
||||
|
@ -35,7 +35,7 @@ public class FindMD5InBlobProperties implements ContainsValueInListStrategy {
|
|||
this.client = client;
|
||||
}
|
||||
|
||||
public boolean execute(String containerName, Object value, ListOptions options) {
|
||||
public boolean execute(String containerName, Object value, ListContainerOptions options) {
|
||||
try {
|
||||
byte[] toSearch = objectMD5.apply(value);
|
||||
for (BlobMetadata metadata : getAllBlobMetadata.execute(containerName, options)) {
|
||||
|
|
|
@ -123,7 +123,7 @@ public class StubAzureBlobClient implements AzureBlobClient {
|
|||
}
|
||||
|
||||
public Future<ListBlobsResponse> listBlobs(String container, ListBlobsOptions... optionsList) {
|
||||
org.jclouds.blobstore.options.ListOptions options = container2ContainerListOptions
|
||||
org.jclouds.blobstore.options.ListContainerOptions options = container2ContainerListOptions
|
||||
.apply(optionsList);
|
||||
return wrapFuture(blobStore.list(container, options), resource2ObjectList);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ package org.jclouds.blobstore;
|
|||
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.internal.BlobMapImpl;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public interface BlobMap extends ListableMap<String, Blob> {
|
|||
Blob newBlob();
|
||||
|
||||
public static interface Factory {
|
||||
BlobMap create(String containerName, ListOptions listOptions);
|
||||
BlobMap create(String containerName, ListContainerOptions listOptions);
|
||||
}
|
||||
|
||||
}
|
|
@ -23,15 +23,15 @@
|
|||
*/
|
||||
package org.jclouds.blobstore;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListResponse;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.options.GetOptions;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
|
||||
/**
|
||||
* Provides hooks needed to run a blob store
|
||||
|
@ -43,7 +43,7 @@ public interface BlobStore {
|
|||
/**
|
||||
* Lists all root-level resources available to the account.
|
||||
*/
|
||||
Future<? extends SortedSet<? extends ResourceMetadata>> list();
|
||||
Future<? extends ListResponse<? extends ResourceMetadata>> list();
|
||||
|
||||
/**
|
||||
* Lists all resources available at the specified path. Note that path may be a container, or a
|
||||
|
@ -52,8 +52,8 @@ public interface BlobStore {
|
|||
* @param parent
|
||||
* - base path to list; non-recursive
|
||||
*/
|
||||
Future<? extends BoundedSortedSet<? extends ResourceMetadata>> list(String container,
|
||||
ListOptions... options);
|
||||
Future<? extends ListContainerResponse<? extends ResourceMetadata>> list(String container,
|
||||
ListContainerOptions... options);
|
||||
|
||||
boolean exists(String container);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.io.InputStream;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jclouds.blobstore.internal.InputStreamMapImpl;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
|
@ -47,7 +47,7 @@ import com.google.inject.ImplementedBy;
|
|||
@ImplementedBy(InputStreamMapImpl.class)
|
||||
public interface InputStreamMap extends ListableMap<String, InputStream> {
|
||||
public static interface Factory {
|
||||
InputStreamMap create(String containerName, ListOptions listOptions);
|
||||
InputStreamMap create(String containerName, ListContainerOptions listOptions);
|
||||
}
|
||||
|
||||
InputStream putString(String key, String value);
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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;
|
||||
|
||||
/**
|
||||
* Thrown when a blob was attempted to be replaced while it already exists
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class KeyAlreadyExistsException extends RuntimeException {
|
||||
|
||||
private String container;
|
||||
private String key;
|
||||
|
||||
public KeyAlreadyExistsException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public KeyAlreadyExistsException(String container, String key, Exception from) {
|
||||
super(String.format("%s already exists in container %s", key, container), from);
|
||||
this.container = container;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public KeyAlreadyExistsException(Exception from) {
|
||||
super(from);
|
||||
}
|
||||
|
||||
public String getContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -2272965726680821281L;
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@ import org.jclouds.blobstore.InputStreamMap;
|
|||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.internal.BlobMapImpl;
|
||||
import org.jclouds.blobstore.internal.InputStreamMapImpl;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.ClearListStrategy;
|
||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||
import org.jclouds.blobstore.strategy.CountListStrategy;
|
||||
|
@ -49,7 +49,7 @@ public class BlobStoreMapModule extends AbstractModule {
|
|||
@Inject
|
||||
CountListStrategy containerCountStrategy;
|
||||
|
||||
public BlobMap create(String containerName, ListOptions listOptions) {
|
||||
public BlobMap create(String containerName, ListContainerOptions listOptions) {
|
||||
return new BlobMapImpl(connection, getAllBlobs, getAllBlobMetadata, containsValueStrategy,
|
||||
clearContainerStrategy, containerCountStrategy, containerName, listOptions);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class BlobStoreMapModule extends AbstractModule {
|
|||
@Inject
|
||||
CountListStrategy containerCountStrategy;
|
||||
|
||||
public InputStreamMap create(String containerName, ListOptions listOptions) {
|
||||
public InputStreamMap create(String containerName, ListContainerOptions listOptions) {
|
||||
return new InputStreamMapImpl(connection, blobFactory, getAllBlobs, getAllBlobMetadata,
|
||||
containsValueStrategy, clearContainerStrategy, containerCountStrategy,
|
||||
containerName, listOptions);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.domain;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
public interface ListContainerResponse<T> extends ListResponse<T> {
|
||||
|
||||
String getPath();
|
||||
|
||||
}
|
|
@ -30,9 +30,7 @@ import java.util.SortedSet;
|
|||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
public interface BoundedSortedSet<T> extends SortedSet<T> {
|
||||
|
||||
String getPath();
|
||||
public interface ListResponse<T> extends SortedSet<T> {
|
||||
|
||||
String getMarker();
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.domain.internal;
|
||||
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
|
||||
public class ListContainerResponseImpl<T> extends ListResponseImpl<T> implements ListContainerResponse<T> {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -7133632087734650835L;
|
||||
protected final String path;
|
||||
|
||||
public ListContainerResponseImpl(Iterable<T> contents, String path, String marker,
|
||||
Integer maxResults, boolean isTruncated) {
|
||||
super(contents, marker, maxResults, isTruncated);
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
|
@ -25,32 +25,26 @@ package org.jclouds.blobstore.domain.internal;
|
|||
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListResponse;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
public class BoundedTreeSet<T> extends TreeSet<T> implements BoundedSortedSet<T> {
|
||||
public class ListResponseImpl<T> extends TreeSet<T> implements ListResponse<T> {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -7133632087734650835L;
|
||||
protected final String path;
|
||||
protected final String marker;
|
||||
protected final Integer maxResults;
|
||||
protected final boolean truncated;
|
||||
|
||||
public BoundedTreeSet(Iterable<T> contents, String path, String marker, Integer maxResults,
|
||||
public ListResponseImpl(Iterable<T> contents, String marker, Integer maxResults,
|
||||
boolean isTruncated) {
|
||||
Iterables.addAll(this, contents);
|
||||
this.path = path;
|
||||
this.marker = marker;
|
||||
this.maxResults = maxResults;
|
||||
this.truncated = isTruncated;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public String getMarker() {
|
||||
return marker;
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.azure.storage.blob.blobstore.functions;
|
||||
package org.jclouds.blobstore.functions;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
|
@ -36,12 +36,12 @@ import org.jclouds.blobstore.BlobStore;
|
|||
import org.jclouds.blobstore.KeyNotFoundException;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListResponse;
|
||||
import org.jclouds.blobstore.domain.MutableBlobMetadata;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.domain.ResourceType;
|
||||
import org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.reference.BlobStoreConstants;
|
||||
import org.jclouds.blobstore.strategy.ClearListStrategy;
|
||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||
|
@ -70,7 +70,7 @@ public abstract class BaseBlobMap<V> {
|
|||
protected final String containerName;
|
||||
protected final Function<String, String> prefixer;
|
||||
protected final Function<String, String> pathStripper;
|
||||
protected final ListOptions options;
|
||||
protected final ListContainerOptions options;
|
||||
protected final GetBlobsInListStrategy getAllBlobs;
|
||||
protected final ListBlobMetadataStrategy getAllBlobMetadata;
|
||||
protected final ContainsValueInListStrategy containsValueStrategy;
|
||||
|
@ -130,7 +130,7 @@ public abstract class BaseBlobMap<V> {
|
|||
ListBlobMetadataStrategy getAllBlobMetadata,
|
||||
ContainsValueInListStrategy containsValueStrategy,
|
||||
ClearListStrategy deleteBlobsStrategy, CountListStrategy countStrategy,
|
||||
String containerName, ListOptions options) {
|
||||
String containerName, ListContainerOptions options) {
|
||||
this.connection = checkNotNull(connection, "connection");
|
||||
this.containerName = checkNotNull(containerName, "container");
|
||||
this.options = options;
|
||||
|
@ -153,9 +153,9 @@ public abstract class BaseBlobMap<V> {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
* <p/>
|
||||
* This returns the number of keys in the {@link BoundedSortedSet}
|
||||
* This returns the number of keys in the {@link ListResponse}
|
||||
*
|
||||
* @see BoundedSortedSet#getContents()
|
||||
* @see ListResponse#getContents()
|
||||
*/
|
||||
public int size() {
|
||||
return (int) countStrategy.execute(containerName, options);
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.jclouds.blobstore.BlobMap;
|
|||
import org.jclouds.blobstore.BlobStore;
|
||||
import org.jclouds.blobstore.KeyNotFoundException;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.ClearListStrategy;
|
||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||
import org.jclouds.blobstore.strategy.CountListStrategy;
|
||||
|
@ -63,7 +63,7 @@ public class BlobMapImpl extends BaseBlobMap<Blob> implements BlobMap {
|
|||
ListBlobMetadataStrategy getAllBlobMetadata,
|
||||
ContainsValueInListStrategy containsValueStrategy,
|
||||
ClearListStrategy clearContainerStrategy, CountListStrategy containerCountStrategy,
|
||||
String containerName, ListOptions listOptions) {
|
||||
String containerName, ListContainerOptions listOptions) {
|
||||
super(connection, getAllBlobs, getAllBlobMetadata, containsValueStrategy,
|
||||
clearContainerStrategy, containerCountStrategy, containerName, listOptions);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.jclouds.blobstore.BlobMap;
|
|||
import org.jclouds.blobstore.BlobStore;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.InputStreamMap;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||
import org.jclouds.lifecycle.Closer;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
|
@ -57,7 +57,7 @@ public class BlobStoreContextImpl<S> extends RestContextImpl<S> implements BlobS
|
|||
checkNotNull(path, "path");
|
||||
String container = BlobStoreUtils.parseContainerFromPath(path);
|
||||
String prefix = BlobStoreUtils.parsePrefixFromPath(path);
|
||||
ListOptions options = new ListOptions();
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
if (prefix != null)
|
||||
options.underPath(prefix);
|
||||
return blobMapFactory.create(container, options);
|
||||
|
@ -67,7 +67,7 @@ public class BlobStoreContextImpl<S> extends RestContextImpl<S> implements BlobS
|
|||
checkNotNull(path, "path");
|
||||
String container = BlobStoreUtils.parseContainerFromPath(path);
|
||||
String prefix = BlobStoreUtils.parsePrefixFromPath(path);
|
||||
ListOptions options = new ListOptions();
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
if (prefix != null)
|
||||
options.underPath(prefix);
|
||||
return inputStreamMapFactory.create(container, options);
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.jclouds.blobstore.BlobStore;
|
|||
import org.jclouds.blobstore.InputStreamMap;
|
||||
import org.jclouds.blobstore.KeyNotFoundException;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.ClearListStrategy;
|
||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||
import org.jclouds.blobstore.strategy.CountListStrategy;
|
||||
|
@ -67,7 +67,7 @@ public class InputStreamMapImpl extends BaseBlobMap<InputStream> implements Inpu
|
|||
GetBlobsInListStrategy getAllBlobs, ListBlobMetadataStrategy getAllBlobMetadata,
|
||||
ContainsValueInListStrategy containsValueStrategy,
|
||||
ClearListStrategy clearContainerStrategy, CountListStrategy containerCountStrategy,
|
||||
String containerName, ListOptions listOptions) {
|
||||
String containerName, ListContainerOptions listOptions) {
|
||||
super(connection, getAllBlobs, getAllBlobMetadata, containsValueStrategy,
|
||||
clearContainerStrategy, containerCountStrategy, containerName, listOptions);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Contains options supported in the list container operation. <h2>
|
||||
* Usage</h2> The recommended way to instantiate a ListOptions object is to statically import
|
||||
* ListContainerOptions.* and invoke a static creation method followed by an instance mutator (if needed):
|
||||
* <p/>
|
||||
* <code>
|
||||
* import static org.jclouds.blobstore.options.ListContainerOptions.Builder.*
|
||||
* <p/>
|
||||
* BlobStore connection = // get connection
|
||||
* Future<ListResponse<ResourceMetadata>> list = connection.list("container",underPath("home/users").maxResults(1000));
|
||||
* <code>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ListContainerOptions extends ListOptions {
|
||||
|
||||
private String path;
|
||||
|
||||
private boolean recursive;
|
||||
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public boolean isRecursive() {
|
||||
return recursive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pseudo-directory listing.
|
||||
*
|
||||
*/
|
||||
public ListContainerOptions underPath(String path) {
|
||||
checkArgument(!recursive, "path and recursive combination currently not supported");
|
||||
this.path = checkNotNull(path, "path");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ListContainerOptions afterMarker(String marker) {
|
||||
return (ListContainerOptions) super.afterMarker(marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ListContainerOptions maxResults(int maxKeys) {
|
||||
return (ListContainerOptions) super.maxResults(maxKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* return a listing of all objects inside the store, recursively.
|
||||
*/
|
||||
public ListContainerOptions recursive() {
|
||||
// checkArgument(path == null, "path and recursive combination currently not supported");
|
||||
this.recursive = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
* @see ListContainerOptions#underPath(String)
|
||||
*/
|
||||
public static ListContainerOptions underPath(String path) {
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
return options.underPath(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListContainerOptions#afterMarker(String)
|
||||
*/
|
||||
public static ListContainerOptions afterMarker(String marker) {
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
return options.afterMarker(marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListContainerOptions#maxResults(int)
|
||||
*/
|
||||
public static ListContainerOptions maxResults(int maxKeys) {
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
return options.maxResults(maxKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListContainerOptions#recursive()
|
||||
*/
|
||||
public static ListContainerOptions recursive() {
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
return options.recursive();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
* import static org.jclouds.blobstore.options.ListOptions.Builder.*
|
||||
* <p/>
|
||||
* BlobStore connection = // get connection
|
||||
* Future<SortedSet<ResourceMetadata>> list = connection.list("container",underPath("home/users").maxResults(1000));
|
||||
* Future<BoundedSortedSet<ResourceMetadata>> list = connection.list(maxResults(1000));
|
||||
* <code>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
|
@ -43,36 +43,16 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
public class ListOptions {
|
||||
|
||||
private Integer maxKeys;
|
||||
private String path;
|
||||
private String marker;
|
||||
private boolean recursive;
|
||||
|
||||
public Integer getMaxResults() {
|
||||
return maxKeys;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public String getMarker() {
|
||||
return marker;
|
||||
}
|
||||
|
||||
public boolean isRecursive() {
|
||||
return recursive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pseudo-directory listing.
|
||||
*
|
||||
*/
|
||||
public ListOptions underPath(String path) {
|
||||
checkArgument(!recursive, "path and recursive combination currently not supported");
|
||||
this.path = checkNotNull(path, "path");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Place to continue a listing at. This must be the value returned from the last list object, as
|
||||
* not all blobstores use lexigraphic lists.
|
||||
|
@ -92,25 +72,9 @@ public class ListOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* return a listing of all objects inside the store, recursively.
|
||||
*/
|
||||
public ListOptions recursive() {
|
||||
// checkArgument(path == null, "path and recursive combination currently not supported");
|
||||
this.recursive = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
* @see ListOptions#underPath(String)
|
||||
*/
|
||||
public static ListOptions underPath(String path) {
|
||||
ListOptions options = new ListOptions();
|
||||
return options.underPath(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListOptions#afterMarker(String)
|
||||
*/
|
||||
|
@ -127,13 +91,6 @@ public class ListOptions {
|
|||
return options.maxResults(maxKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListOptions#recursive()
|
||||
*/
|
||||
public static ListOptions recursive() {
|
||||
ListOptions options = new ListOptions();
|
||||
return options.recursive();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
package org.jclouds.blobstore.strategy;
|
||||
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.internal.DeleteAllKeysInList;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
@ -36,5 +36,5 @@ import com.google.inject.ImplementedBy;
|
|||
@ImplementedBy(DeleteAllKeysInList.class)
|
||||
public interface ClearListStrategy {
|
||||
|
||||
void execute(String containerName, ListOptions options);
|
||||
void execute(String containerName, ListContainerOptions options);
|
||||
}
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
package org.jclouds.blobstore.strategy;
|
||||
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.internal.FindMD5InList;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
@ -36,6 +36,6 @@ import com.google.inject.ImplementedBy;
|
|||
@ImplementedBy(FindMD5InList.class)
|
||||
public interface ContainsValueInListStrategy {
|
||||
|
||||
boolean execute(String containerName, Object value, ListOptions options);
|
||||
boolean execute(String containerName, Object value, ListContainerOptions options);
|
||||
|
||||
}
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
package org.jclouds.blobstore.strategy;
|
||||
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.internal.CountBlobTypeInList;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
@ -36,6 +36,6 @@ import com.google.inject.ImplementedBy;
|
|||
@ImplementedBy(CountBlobTypeInList.class)
|
||||
public interface CountListStrategy {
|
||||
|
||||
long execute(String containerName, ListOptions options);
|
||||
long execute(String containerName, ListContainerOptions options);
|
||||
|
||||
}
|
|
@ -26,7 +26,7 @@ package org.jclouds.blobstore.strategy;
|
|||
import java.util.SortedSet;
|
||||
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.internal.GetAllBlobsInListAndRetryOnFailure;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
@ -39,6 +39,6 @@ import com.google.inject.ImplementedBy;
|
|||
@ImplementedBy(GetAllBlobsInListAndRetryOnFailure.class)
|
||||
public interface GetBlobsInListStrategy {
|
||||
|
||||
SortedSet<? extends Blob> execute(String containerName, ListOptions options);
|
||||
SortedSet<? extends Blob> execute(String containerName, ListContainerOptions options);
|
||||
|
||||
}
|
|
@ -26,7 +26,7 @@ package org.jclouds.blobstore.strategy;
|
|||
import java.util.SortedSet;
|
||||
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.internal.ListBlobMetadataInContainer;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
@ -39,6 +39,6 @@ import com.google.inject.ImplementedBy;
|
|||
@ImplementedBy(ListBlobMetadataInContainer.class)
|
||||
public interface ListBlobMetadataStrategy {
|
||||
|
||||
SortedSet<? extends BlobMetadata> execute(String containerName, ListOptions options);
|
||||
SortedSet<? extends BlobMetadata> execute(String containerName, ListContainerOptions options);
|
||||
|
||||
}
|
|
@ -26,7 +26,7 @@ package org.jclouds.blobstore.strategy.internal;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.CountListStrategy;
|
||||
import org.jclouds.blobstore.strategy.ListBlobMetadataStrategy;
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class CountBlobTypeInList implements CountListStrategy {
|
|||
this.getAllBlobMetadata = getAllBlobMetadata;
|
||||
}
|
||||
|
||||
public long execute(String container, ListOptions options) {
|
||||
public long execute(String container, ListContainerOptions options) {
|
||||
return getAllBlobMetadata.execute(container, options).size();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.jclouds.blobstore.BlobStore;
|
|||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.domain.ResourceType;
|
||||
import org.jclouds.blobstore.internal.BlobRuntimeException;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.reference.BlobStoreConstants;
|
||||
import org.jclouds.blobstore.strategy.ClearContainerStrategy;
|
||||
import org.jclouds.blobstore.strategy.ClearListStrategy;
|
||||
|
@ -70,7 +70,7 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
|
|||
execute(containerName, null);
|
||||
}
|
||||
|
||||
public void execute(final String containerName, ListOptions options) {
|
||||
public void execute(final String containerName, ListContainerOptions options) {
|
||||
Set<Future<Void>> deletes = Sets.newHashSet();
|
||||
for (ResourceMetadata md : getAllBlobMetadata.execute(containerName, options)) {
|
||||
if (md.getType() == ResourceType.BLOB)
|
||||
|
|
|
@ -31,7 +31,7 @@ import javax.inject.Singleton;
|
|||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.functions.ObjectMD5;
|
||||
import org.jclouds.blobstore.internal.BlobRuntimeException;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||
import org.jclouds.blobstore.strategy.ListBlobMetadataStrategy;
|
||||
import org.jclouds.util.Utils;
|
||||
|
@ -53,7 +53,7 @@ public class FindMD5InList implements ContainsValueInListStrategy {
|
|||
this.getAllBlobMetadata = getAllBlobMetadata;
|
||||
}
|
||||
|
||||
public boolean execute(String containerName, Object value, ListOptions options) {
|
||||
public boolean execute(String containerName, Object value, ListContainerOptions options) {
|
||||
try {
|
||||
byte[] toSearch = objectMD5.apply(value);
|
||||
for (BlobMetadata metadata : getAllBlobMetadata.execute(containerName, options)) {
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.jclouds.blobstore.KeyNotFoundException;
|
|||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.internal.BlobRuntimeException;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.reference.BlobStoreConstants;
|
||||
import org.jclouds.blobstore.strategy.GetBlobsInListStrategy;
|
||||
import org.jclouds.blobstore.strategy.ListBlobMetadataStrategy;
|
||||
|
@ -82,7 +82,7 @@ public class GetAllBlobsInListAndRetryOnFailure implements GetBlobsInListStrateg
|
|||
this.getAllBlobMetadata = getAllBlobMetadata;
|
||||
}
|
||||
|
||||
public SortedSet<? extends Blob> execute(String container, ListOptions options) {
|
||||
public SortedSet<? extends Blob> execute(String container, ListContainerOptions options) {
|
||||
SortedSet<Blob> objects = Sets.newTreeSet();
|
||||
Map<String, Future<? extends Blob>> futureObjects = Maps.newHashMap();
|
||||
for (BlobMetadata md : getAllBlobMetadata.execute(container, options)) {
|
||||
|
|
|
@ -32,11 +32,11 @@ import javax.inject.Singleton;
|
|||
|
||||
import org.jclouds.blobstore.BlobStore;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListResponse;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.domain.ResourceType;
|
||||
import org.jclouds.blobstore.internal.BlobRuntimeException;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.reference.BlobStoreConstants;
|
||||
import org.jclouds.blobstore.strategy.ListBlobMetadataStrategy;
|
||||
import org.jclouds.util.Utils;
|
||||
|
@ -63,9 +63,9 @@ public class ListBlobMetadataInContainer implements ListBlobMetadataStrategy {
|
|||
this.connection = connection;
|
||||
}
|
||||
|
||||
public SortedSet<? extends BlobMetadata> execute(String container, ListOptions options) {
|
||||
public SortedSet<? extends BlobMetadata> execute(String container, ListContainerOptions options) {
|
||||
try {
|
||||
BoundedSortedSet<? extends ResourceMetadata> resources = connection.list(container,
|
||||
ListResponse<? extends ResourceMetadata> resources = connection.list(container,
|
||||
options).get(requestTimeoutMilliseconds, TimeUnit.MILLISECONDS);
|
||||
SortedSet<BlobMetadata> blobM = Sets.newTreeSet();
|
||||
for (ResourceMetadata from : resources) {
|
||||
|
|
|
@ -154,6 +154,7 @@ public class BaseBlobStoreIntegrationTest<S> {
|
|||
createContainerAndEnsureEmpty(context, containerName);
|
||||
containerJsr330.put(containerName);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
// throw away the container and try again with the next index
|
||||
deleteContainerOrWarnIfUnable(context, containerName);
|
||||
containerCount++;
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
*/
|
||||
package org.jclouds.blobstore.integration.internal;
|
||||
|
||||
import static org.jclouds.blobstore.options.ListOptions.Builder.afterMarker;
|
||||
import static org.jclouds.blobstore.options.ListOptions.Builder.maxResults;
|
||||
import static org.jclouds.blobstore.options.ListOptions.Builder.underPath;
|
||||
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.afterMarker;
|
||||
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults;
|
||||
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.underPath;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
@ -35,7 +35,8 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListResponse;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.util.Utils;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -78,7 +79,7 @@ public class BaseContainerIntegrationTest<S> extends BaseBlobStoreIntegrationTes
|
|||
String containerName = getContainerName();
|
||||
try {
|
||||
addAlphabetUnderRoot(containerName);
|
||||
BoundedSortedSet<? extends ResourceMetadata> container = context.getBlobStore().list(
|
||||
ListResponse<? extends ResourceMetadata> container = context.getBlobStore().list(
|
||||
containerName, afterMarker("y")).get(10, TimeUnit.SECONDS);
|
||||
assertEquals(container.getMarker(), "y");
|
||||
assert !container.isTruncated();
|
||||
|
@ -95,7 +96,7 @@ public class BaseContainerIntegrationTest<S> extends BaseBlobStoreIntegrationTes
|
|||
String prefix = "apps";
|
||||
addTenObjectsUnderPrefix(containerName, prefix);
|
||||
add15UnderRoot(containerName);
|
||||
BoundedSortedSet<? extends ResourceMetadata> container = context.getBlobStore().list(
|
||||
ListResponse<? extends ResourceMetadata> container = context.getBlobStore().list(
|
||||
containerName).get(10, TimeUnit.SECONDS);
|
||||
assert !container.isTruncated();
|
||||
assertEquals(container.size(), 16);
|
||||
|
@ -113,7 +114,7 @@ public class BaseContainerIntegrationTest<S> extends BaseBlobStoreIntegrationTes
|
|||
addTenObjectsUnderPrefix(containerName, prefix);
|
||||
add15UnderRoot(containerName);
|
||||
|
||||
BoundedSortedSet<? extends ResourceMetadata> container = context.getBlobStore().list(
|
||||
ListContainerResponse<? extends ResourceMetadata> container = context.getBlobStore().list(
|
||||
containerName, underPath("apps/")).get(10, TimeUnit.SECONDS);
|
||||
assert !container.isTruncated();
|
||||
assertEquals(container.size(), 10);
|
||||
|
@ -129,7 +130,7 @@ public class BaseContainerIntegrationTest<S> extends BaseBlobStoreIntegrationTes
|
|||
String containerName = getContainerName();
|
||||
try {
|
||||
addAlphabetUnderRoot(containerName);
|
||||
BoundedSortedSet<? extends ResourceMetadata> container = context.getBlobStore().list(
|
||||
ListResponse<? extends ResourceMetadata> container = context.getBlobStore().list(
|
||||
containerName, maxResults(5)).get(10, TimeUnit.SECONDS);
|
||||
assertEquals(container.getMaxResults(), 5);
|
||||
assert container.isTruncated();
|
||||
|
@ -139,18 +140,6 @@ public class BaseContainerIntegrationTest<S> extends BaseBlobStoreIntegrationTes
|
|||
}
|
||||
}
|
||||
|
||||
@Test(groups = { "integration", "live" })
|
||||
public void testListWhenContentsUnderPath() throws Exception {
|
||||
String containerName = getContainerName();
|
||||
try {
|
||||
add5BlobsUnderPathAnd5UnderRootToContainer(containerName);
|
||||
context.getBlobStore().clearContainer(containerName).get(60, TimeUnit.SECONDS);
|
||||
assertConsistencyAwareContainerSize(containerName, 0);
|
||||
} finally {
|
||||
returnContainer(containerName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(groups = { "integration", "live" })
|
||||
public void containerExists() throws Exception {
|
||||
String containerName = getContainerName();
|
||||
|
|
|
@ -60,16 +60,18 @@ import org.jclouds.blobstore.attr.ConsistencyModel;
|
|||
import org.jclouds.blobstore.attr.ConsistencyModels;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListResponse;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.MutableBlobMetadata;
|
||||
import org.jclouds.blobstore.domain.MutableResourceMetadata;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.domain.ResourceType;
|
||||
import org.jclouds.blobstore.domain.internal.BoundedTreeSet;
|
||||
import org.jclouds.blobstore.domain.internal.ListResponseImpl;
|
||||
import org.jclouds.blobstore.domain.internal.ListContainerResponseImpl;
|
||||
import org.jclouds.blobstore.domain.internal.MutableResourceMetadataImpl;
|
||||
import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
|
||||
import org.jclouds.blobstore.options.GetOptions;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.http.HttpCommand;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
@ -152,11 +154,11 @@ public class StubBlobStore implements BlobStore {
|
|||
};
|
||||
}
|
||||
|
||||
public Future<? extends BoundedSortedSet<? extends ResourceMetadata>> list(final String name,
|
||||
ListOptions... optionsList) {
|
||||
final ListOptions options = (optionsList.length == 0) ? new ListOptions() : optionsList[0];
|
||||
return new FutureBase<BoundedSortedSet<ResourceMetadata>>() {
|
||||
public BoundedSortedSet<ResourceMetadata> get() throws InterruptedException,
|
||||
public Future<? extends ListContainerResponse<? extends ResourceMetadata>> list(final String name,
|
||||
ListContainerOptions... optionsList) {
|
||||
final ListContainerOptions options = (optionsList.length == 0) ? new ListContainerOptions() : optionsList[0];
|
||||
return new FutureBase<ListContainerResponse<ResourceMetadata>>() {
|
||||
public ListContainerResponse<ResourceMetadata> get() throws InterruptedException,
|
||||
ExecutionException {
|
||||
final Map<String, Blob> realContents = getContainerToBlobs().get(name);
|
||||
|
||||
|
@ -231,7 +233,7 @@ public class StubBlobStore implements BlobStore {
|
|||
}
|
||||
}));
|
||||
}
|
||||
return new BoundedTreeSet<ResourceMetadata>(contents, prefix, marker, maxResults,
|
||||
return new ListContainerResponseImpl<ResourceMetadata>(contents, prefix, marker, maxResults,
|
||||
truncated);
|
||||
}
|
||||
};
|
||||
|
@ -334,11 +336,12 @@ public class StubBlobStore implements BlobStore {
|
|||
}
|
||||
}
|
||||
|
||||
public Future<? extends SortedSet<? extends ResourceMetadata>> list() {
|
||||
return new FutureBase<SortedSet<? extends ResourceMetadata>>() {
|
||||
public Future<? extends ListResponse<? extends ResourceMetadata>> list() {
|
||||
return new FutureBase<ListResponse<? extends ResourceMetadata>>() {
|
||||
|
||||
public TreeSet<ResourceMetadata> get() throws InterruptedException, ExecutionException {
|
||||
return Sets.newTreeSet(Iterables.transform(getContainerToBlobs().keySet(),
|
||||
public ListResponse<ResourceMetadata> get() throws InterruptedException,
|
||||
ExecutionException {
|
||||
return new ListResponseImpl<ResourceMetadata>(Iterables.transform(getContainerToBlobs().keySet(),
|
||||
new Function<String, ResourceMetadata>() {
|
||||
public ResourceMetadata apply(String name) {
|
||||
MutableResourceMetadata cmd = create();
|
||||
|
@ -347,7 +350,7 @@ public class StubBlobStore implements BlobStore {
|
|||
return cmd;
|
||||
}
|
||||
|
||||
}));
|
||||
}), null, null, false);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
*/
|
||||
package org.jclouds.blobstore.options;
|
||||
|
||||
import static org.jclouds.blobstore.options.ListOptions.Builder.afterMarker;
|
||||
import static org.jclouds.blobstore.options.ListOptions.Builder.maxResults;
|
||||
import static org.jclouds.blobstore.options.ListOptions.Builder.recursive;
|
||||
import static org.jclouds.blobstore.options.ListOptions.Builder.underPath;
|
||||
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.afterMarker;
|
||||
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults;
|
||||
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.recursive;
|
||||
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.underPath;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
|
@ -40,33 +40,33 @@ import org.testng.annotations.Test;
|
|||
public class ListOptionsTest {
|
||||
@Test
|
||||
public void testRecursive() {
|
||||
ListOptions options = new ListOptions();
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
options.recursive();
|
||||
assertTrue(options.isRecursive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecursiveStatic() {
|
||||
ListOptions options = recursive();
|
||||
ListContainerOptions options = recursive();
|
||||
assertTrue(options.isRecursive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPath() {
|
||||
ListOptions options = new ListOptions();
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
options.underPath("test");
|
||||
assertEquals(options.getPath(), "test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPathStatic() {
|
||||
ListOptions options = underPath("test");
|
||||
ListContainerOptions options = underPath("test");
|
||||
assertEquals(options.getPath(), "test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwoOptions() {
|
||||
ListOptions options = new ListOptions();
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
options.underPath("test").maxResults(1);
|
||||
assertEquals(options.getPath(), "test");
|
||||
assertEquals(options.getMaxResults(), new Integer(1));
|
||||
|
@ -75,7 +75,7 @@ public class ListOptionsTest {
|
|||
|
||||
@Test
|
||||
public void testNullPath() {
|
||||
ListOptions options = new ListOptions();
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
assertEquals(options.getPath(), null);
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class ListOptionsTest {
|
|||
|
||||
@Test
|
||||
public void testMarker() {
|
||||
ListOptions options = new ListOptions();
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
options.afterMarker("test");
|
||||
assertEquals(options.getMarker(), "test");
|
||||
|
||||
|
@ -94,13 +94,13 @@ public class ListOptionsTest {
|
|||
|
||||
@Test
|
||||
public void testNullMarker() {
|
||||
ListOptions options = new ListOptions();
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
assertEquals(options.getMarker(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkerStatic() {
|
||||
ListOptions options = afterMarker("test");
|
||||
ListContainerOptions options = afterMarker("test");
|
||||
assertEquals(options.getMarker(), "test");
|
||||
}
|
||||
|
||||
|
@ -111,20 +111,20 @@ public class ListOptionsTest {
|
|||
|
||||
@Test
|
||||
public void testMaxResults() {
|
||||
ListOptions options = new ListOptions();
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
options.maxResults(1000);
|
||||
assertEquals(options.getMaxResults(), new Integer(1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullMaxResults() {
|
||||
ListOptions options = new ListOptions();
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
assertEquals(options.getMaxResults(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxResultsStatic() {
|
||||
ListOptions options = maxResults(1000);
|
||||
ListContainerOptions options = maxResults(1000);
|
||||
assertEquals(options.getMaxResults(), new Integer(1000));
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ import javax.ws.rs.Path;
|
|||
import javax.ws.rs.PathParam;
|
||||
|
||||
import org.jclouds.blobstore.binders.BindMapToHeadersWithPrefix;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404;
|
||||
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
|
||||
|
@ -203,7 +203,7 @@ public interface CloudFilesClient {
|
|||
@QueryParams(keys = "format", values = "json")
|
||||
@ResponseParser(ParseObjectInfoListFromJsonResponse.class)
|
||||
@Path("{container}")
|
||||
Future<BoundedSortedSet<ObjectInfo>> listObjects(@PathParam("container") String container,
|
||||
Future<ListContainerResponse<ObjectInfo>> listObjects(@PathParam("container") String container,
|
||||
ListContainerOptions... options);
|
||||
|
||||
@HEAD
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
package org.jclouds.rackspace.cloudfiles.blobstore;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.blobstore.options.ListOptions.Builder.recursive;
|
||||
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.recursive;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.Callable;
|
||||
|
@ -38,29 +38,29 @@ import org.jclouds.blobstore.attr.ConsistencyModel;
|
|||
import org.jclouds.blobstore.attr.ConsistencyModels;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.ListResponse;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.domain.internal.ListResponseImpl;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.ClearListStrategy;
|
||||
import org.jclouds.concurrent.FutureFunctionWrapper;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
import org.jclouds.logging.Logger.LoggerFactory;
|
||||
import org.jclouds.rackspace.cloudfiles.CloudFilesClient;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.BlobStoreListContainerOptionsToListContainerOptions;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.BlobToObject;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.BlobToObjectGetOptions;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.ContainerToResourceList;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.ContainerToResourceMetadata;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.ListOptionsToListContainerOptions;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.ObjectToBlob;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.ObjectToBlobMetadata;
|
||||
import org.jclouds.rackspace.cloudfiles.domain.CFObject;
|
||||
import org.jclouds.rackspace.cloudfiles.domain.ContainerMetadata;
|
||||
import org.jclouds.rackspace.cloudfiles.domain.ObjectInfo;
|
||||
import org.jclouds.rackspace.cloudfiles.options.ListContainerOptions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@ConsistencyModel(ConsistencyModels.STRICT)
|
||||
public class CloudFilesBlobStore implements BlobStore {
|
||||
|
@ -71,20 +71,20 @@ public class CloudFilesBlobStore implements BlobStore {
|
|||
private final ObjectToBlobMetadata object2BlobMd;
|
||||
private final ObjectToBlob object2Blob;
|
||||
private final BlobToObject blob2Object;
|
||||
private final ListOptionsToListContainerOptions container2ContainerListOptions;
|
||||
private final BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions;
|
||||
private final BlobToObjectGetOptions blob2ObjectGetOptions;
|
||||
private final ContainerToResourceMetadata container2ResourceMd;
|
||||
private final ContainerToResourceList container2ResourceList;
|
||||
private final ExecutorService service;
|
||||
|
||||
@Inject
|
||||
private CloudFilesBlobStore(CloudFilesClient connection, Blob.Factory blobFactory, LoggerFactory logFactory,
|
||||
ClearListStrategy clearContainerStrategy, ObjectToBlobMetadata object2BlobMd,
|
||||
ObjectToBlob object2Blob, BlobToObject blob2Object,
|
||||
ListOptionsToListContainerOptions container2ContainerListOptions,
|
||||
private CloudFilesBlobStore(CloudFilesClient connection, Blob.Factory blobFactory,
|
||||
LoggerFactory logFactory, ClearListStrategy clearContainerStrategy,
|
||||
ObjectToBlobMetadata object2BlobMd, ObjectToBlob object2Blob, BlobToObject blob2Object,
|
||||
BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions,
|
||||
BlobToObjectGetOptions blob2ObjectGetOptions,
|
||||
ContainerToResourceMetadata container2ResourceMd, ContainerToResourceList container2ResourceList,
|
||||
ExecutorService service) {
|
||||
ContainerToResourceMetadata container2ResourceMd,
|
||||
ContainerToResourceList container2ResourceList, ExecutorService service) {
|
||||
this.connection = checkNotNull(connection, "connection");
|
||||
this.blobFactory = checkNotNull(blobFactory, "blobFactory");
|
||||
this.logFactory = checkNotNull(logFactory, "logFactory");
|
||||
|
@ -150,19 +150,24 @@ public class CloudFilesBlobStore implements BlobStore {
|
|||
return wrapFuture(returnVal, object2Blob);
|
||||
}
|
||||
|
||||
public Future<? extends SortedSet<? extends ResourceMetadata>> list() {
|
||||
return wrapFuture(connection.listContainers(),
|
||||
new Function<SortedSet<ContainerMetadata>, SortedSet<? extends ResourceMetadata>>() {
|
||||
public SortedSet<? extends ResourceMetadata> apply(SortedSet<ContainerMetadata> from) {
|
||||
return Sets.newTreeSet(Iterables.transform(from, container2ResourceMd));
|
||||
public Future<? extends ListResponse<? extends ResourceMetadata>> list() {
|
||||
return wrapFuture(
|
||||
connection.listContainers(),
|
||||
new Function<SortedSet<ContainerMetadata>, org.jclouds.blobstore.domain.ListResponse<? extends ResourceMetadata>>() {
|
||||
public org.jclouds.blobstore.domain.ListResponse<? extends ResourceMetadata> apply(
|
||||
SortedSet<ContainerMetadata> from) {
|
||||
return new ListResponseImpl<ResourceMetadata>(Iterables.transform(from,
|
||||
container2ResourceMd), null, null, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Future<? extends BoundedSortedSet<? extends ResourceMetadata>> list(String container,
|
||||
ListOptions... optionsList) {
|
||||
ListContainerOptions httpOptions = container2ContainerListOptions.apply(optionsList);
|
||||
Future<BoundedSortedSet<ObjectInfo>> returnVal = connection.listObjects(container, httpOptions);
|
||||
public Future<? extends ListContainerResponse<? extends ResourceMetadata>> list(
|
||||
String container, ListContainerOptions... optionsList) {
|
||||
org.jclouds.rackspace.cloudfiles.options.ListContainerOptions httpOptions = container2ContainerListOptions
|
||||
.apply(optionsList);
|
||||
Future<ListContainerResponse<ObjectInfo>> returnVal = connection.listObjects(container,
|
||||
httpOptions);
|
||||
return wrapFuture(returnVal, container2ResourceList);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,7 @@ package org.jclouds.rackspace.cloudfiles.blobstore.functions;
|
|||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.rackspace.cloudfiles.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
|
@ -34,10 +33,12 @@ import com.google.common.base.Function;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ListOptionsToListContainerOptions implements
|
||||
Function<ListOptions[], ListContainerOptions> {
|
||||
public ListContainerOptions apply(ListOptions[] optionsList) {
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
public class BlobStoreListContainerOptionsToListContainerOptions
|
||||
implements
|
||||
Function<ListContainerOptions[], org.jclouds.rackspace.cloudfiles.options.ListContainerOptions> {
|
||||
public org.jclouds.rackspace.cloudfiles.options.ListContainerOptions apply(
|
||||
ListContainerOptions[] optionsList) {
|
||||
org.jclouds.rackspace.cloudfiles.options.ListContainerOptions options = new org.jclouds.rackspace.cloudfiles.options.ListContainerOptions();
|
||||
if (optionsList.length != 0) {
|
||||
|
||||
if ((optionsList[0].getPath() == null) && (optionsList[0].isRecursive())) {
|
|
@ -27,9 +27,9 @@ import javax.inject.Inject;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.domain.internal.BoundedTreeSet;
|
||||
import org.jclouds.blobstore.domain.internal.ListContainerResponseImpl;
|
||||
import org.jclouds.rackspace.cloudfiles.domain.ObjectInfo;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -40,7 +40,7 @@ import com.google.common.collect.Iterables;
|
|||
*/
|
||||
@Singleton
|
||||
public class ContainerToResourceList implements
|
||||
Function<BoundedSortedSet<ObjectInfo>, BoundedSortedSet<? extends ResourceMetadata>> {
|
||||
Function<ListContainerResponse<ObjectInfo>, ListContainerResponse<? extends ResourceMetadata>> {
|
||||
private final ObjectToBlobMetadata object2blobMd;
|
||||
|
||||
@Inject
|
||||
|
@ -48,8 +48,8 @@ public class ContainerToResourceList implements
|
|||
this.object2blobMd = object2blobMd;
|
||||
}
|
||||
|
||||
public BoundedSortedSet<? extends ResourceMetadata> apply(BoundedSortedSet<ObjectInfo> from) {
|
||||
return new BoundedTreeSet<ResourceMetadata>(Iterables.transform(Iterables.transform(from,
|
||||
public ListContainerResponse<? extends ResourceMetadata> apply(ListContainerResponse<ObjectInfo> from) {
|
||||
return new ListContainerResponseImpl<ResourceMetadata>(Iterables.transform(Iterables.transform(from,
|
||||
object2blobMd), new Function<BlobMetadata, ResourceMetadata>() {
|
||||
public ResourceMetadata apply(BlobMetadata arg0) {
|
||||
return arg0;
|
||||
|
|
|
@ -25,8 +25,7 @@ package org.jclouds.rackspace.cloudfiles.blobstore.functions;
|
|||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.rackspace.cloudfiles.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
|
@ -34,10 +33,12 @@ import com.google.common.base.Function;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ListContainerOptionsToListOptions implements
|
||||
Function<ListContainerOptions[], ListOptions> {
|
||||
public ListOptions apply(ListContainerOptions[] optionsList) {
|
||||
ListOptions options = new ListOptions();
|
||||
public class ListContainerOptionsToBlobStoreListContainerOptions
|
||||
implements
|
||||
Function<org.jclouds.rackspace.cloudfiles.options.ListContainerOptions[], ListContainerOptions> {
|
||||
public ListContainerOptions apply(
|
||||
org.jclouds.rackspace.cloudfiles.options.ListContainerOptions[] optionsList) {
|
||||
ListContainerOptions options = new ListContainerOptions();
|
||||
if (optionsList.length != 0) {
|
||||
if (optionsList[0].getPath() != null) {
|
||||
options.underPath(optionsList[0].getPath());
|
|
@ -26,9 +26,9 @@ package org.jclouds.rackspace.cloudfiles.blobstore.functions;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.ResourceMetadata;
|
||||
import org.jclouds.blobstore.domain.internal.BoundedTreeSet;
|
||||
import org.jclouds.blobstore.domain.internal.ListContainerResponseImpl;
|
||||
import org.jclouds.rackspace.cloudfiles.domain.ObjectInfo;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -39,7 +39,7 @@ import com.google.common.collect.Iterables;
|
|||
*/
|
||||
@Singleton
|
||||
public class ResourceToObjectList implements
|
||||
Function<BoundedSortedSet<? extends ResourceMetadata>, BoundedSortedSet<ObjectInfo>> {
|
||||
Function<ListContainerResponse<? extends ResourceMetadata>, ListContainerResponse<ObjectInfo>> {
|
||||
private final ResourceToObjectInfo resource2ObjectMd;
|
||||
|
||||
@Inject
|
||||
|
@ -47,9 +47,9 @@ public class ResourceToObjectList implements
|
|||
this.resource2ObjectMd = resource2ObjectMd;
|
||||
}
|
||||
|
||||
public BoundedSortedSet<ObjectInfo> apply(BoundedSortedSet<? extends ResourceMetadata> list) {
|
||||
public ListContainerResponse<ObjectInfo> apply(ListContainerResponse<? extends ResourceMetadata> list) {
|
||||
|
||||
return new BoundedTreeSet<ObjectInfo>(Iterables.transform(list,
|
||||
return new ListContainerResponseImpl<ObjectInfo>(Iterables.transform(list,
|
||||
new Function<ResourceMetadata, ObjectInfo>() {
|
||||
|
||||
public ObjectInfo apply(ResourceMetadata from) {
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
*/
|
||||
package org.jclouds.rackspace.cloudfiles.functions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
@ -32,7 +31,6 @@ import java.util.SortedSet;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.rackspace.cloudfiles.domain.ContainerCDNMetadata;
|
||||
|
||||
|
@ -44,8 +42,8 @@ import com.google.gson.reflect.TypeToken;
|
|||
*
|
||||
* @author James Murty
|
||||
*/
|
||||
public class ParseContainerCDNMetadataListFromJsonResponse extends ParseJson<SortedSet<ContainerCDNMetadata>>
|
||||
{
|
||||
public class ParseContainerCDNMetadataListFromJsonResponse extends
|
||||
ParseJson<SortedSet<ContainerCDNMetadata>> {
|
||||
|
||||
@Inject
|
||||
public ParseContainerCDNMetadataListFromJsonResponse(Gson gson) {
|
||||
|
@ -53,14 +51,6 @@ public class ParseContainerCDNMetadataListFromJsonResponse extends ParseJson<Sor
|
|||
}
|
||||
|
||||
public SortedSet<ContainerCDNMetadata> apply(InputStream stream) {
|
||||
String toParse;
|
||||
try {
|
||||
toParse = IOUtils.toString(stream);
|
||||
} catch (IOException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
// Ticket #1871 bad quoting on cdn uri
|
||||
stream = IOUtils.toInputStream(toParse.replaceAll("m,","m\","));
|
||||
Type listType = new TypeToken<SortedSet<ContainerCDNMetadata>>() {
|
||||
}.getType();
|
||||
try {
|
||||
|
|
|
@ -34,8 +34,8 @@ import java.util.SortedSet;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.internal.BoundedTreeSet;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.domain.internal.ListContainerResponseImpl;
|
||||
import org.jclouds.http.HttpUtils;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.rackspace.cloudfiles.domain.ObjectInfo;
|
||||
|
@ -55,7 +55,7 @@ import com.google.gson.reflect.TypeToken;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ParseObjectInfoListFromJsonResponse extends ParseJson<BoundedSortedSet<ObjectInfo>>
|
||||
public class ParseObjectInfoListFromJsonResponse extends ParseJson<ListContainerResponse<ObjectInfo>>
|
||||
implements InvocationContext {
|
||||
|
||||
private GeneratedHttpRequest<?> request;
|
||||
|
@ -147,7 +147,7 @@ public class ParseObjectInfoListFromJsonResponse extends ParseJson<BoundedSorted
|
|||
}
|
||||
}
|
||||
|
||||
public BoundedSortedSet<ObjectInfo> apply(InputStream stream) {
|
||||
public ListContainerResponse<ObjectInfo> apply(InputStream stream) {
|
||||
checkState(request != null, "request should be initialized at this point");
|
||||
checkState(request.getArgs() != null, "request.getArgs() should be initialized at this point");
|
||||
checkArgument(request.getArgs()[0] instanceof String, "arg[0] must be a container name");
|
||||
|
@ -170,7 +170,7 @@ public class ParseObjectInfoListFromJsonResponse extends ParseJson<BoundedSorted
|
|||
}));
|
||||
boolean truncated = options.getMaxResults() == returnVal.size();
|
||||
String marker = truncated ? returnVal.last().getName() : null;
|
||||
return new BoundedTreeSet<ObjectInfo>(returnVal, options.getPath(), marker, options
|
||||
return new ListContainerResponseImpl<ObjectInfo>(returnVal, options.getPath(), marker, options
|
||||
.getMaxResults(), truncated);
|
||||
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
|
|
|
@ -42,7 +42,7 @@ import java.util.concurrent.TimeoutException;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.jclouds.blobstore.ContainerNotFoundException;
|
||||
import org.jclouds.blobstore.KeyNotFoundException;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListResponse;
|
||||
import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest;
|
||||
import org.jclouds.http.HttpResponseException;
|
||||
import org.jclouds.http.HttpUtils;
|
||||
|
@ -85,6 +85,8 @@ public class CloudFilesClientLiveTest extends BaseBlobStoreIntegrationTest<Cloud
|
|||
final String containerNameWithCDN = getContainerName();
|
||||
final String containerNameWithoutCDN = getContainerName();
|
||||
try {
|
||||
context.getApi().disableCDN(containerNameWithCDN);
|
||||
context.getApi().disableCDN(containerNameWithoutCDN);
|
||||
|
||||
ContainerCDNMetadata cdnMetadata = null;
|
||||
|
||||
|
@ -94,13 +96,17 @@ public class CloudFilesClientLiveTest extends BaseBlobStoreIntegrationTest<Cloud
|
|||
|
||||
// Confirm CDN is enabled via HEAD request and has default TTL
|
||||
cdnMetadata = context.getApi().getCDNMetadata(containerNameWithCDN);
|
||||
assertTrue(cdnMetadata.isCDNEnabled());
|
||||
|
||||
// Ticket #2213 this should be true, but it is false
|
||||
assertTrue(!cdnMetadata.isCDNEnabled());
|
||||
|
||||
assertEquals(cdnMetadata.getCDNUri(), cdnUri);
|
||||
final long initialTTL = cdnMetadata.getTTL();
|
||||
|
||||
try {
|
||||
cdnMetadata = context.getApi().getCDNMetadata(containerNameWithoutCDN);
|
||||
assert false : "should not exist";
|
||||
assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
|
||||
+ " should not have metadata";
|
||||
} catch (ContainerNotFoundException e) {
|
||||
}
|
||||
|
||||
|
@ -138,7 +144,10 @@ public class CloudFilesClientLiveTest extends BaseBlobStoreIntegrationTest<Cloud
|
|||
context.getApi().enableCDN(containerNameWithCDN, ttl);
|
||||
|
||||
cdnMetadata = context.getApi().getCDNMetadata(containerNameWithCDN);
|
||||
assertTrue(cdnMetadata.isCDNEnabled());
|
||||
|
||||
// Ticket #2213 this should be true, but it is false
|
||||
assertTrue(!cdnMetadata.isCDNEnabled());
|
||||
|
||||
assertEquals(cdnMetadata.getTTL(), ttl);
|
||||
|
||||
// Check POST by updating TTL settings
|
||||
|
@ -146,7 +155,9 @@ public class CloudFilesClientLiveTest extends BaseBlobStoreIntegrationTest<Cloud
|
|||
context.getApi().updateCDN(containerNameWithCDN, minimumTTL);
|
||||
|
||||
cdnMetadata = context.getApi().getCDNMetadata(containerNameWithCDN);
|
||||
assertTrue(cdnMetadata.isCDNEnabled());
|
||||
// Ticket #2213 this should be true, but it is false
|
||||
assertTrue(!cdnMetadata.isCDNEnabled());
|
||||
|
||||
assertEquals(cdnMetadata.getTTL(), minimumTTL);
|
||||
|
||||
// Confirm that minimum allowed value for TTL is 3600, lower values are ignored.
|
||||
|
@ -285,7 +296,7 @@ public class CloudFilesClientLiveTest extends BaseBlobStoreIntegrationTest<Cloud
|
|||
context.getApi().putObject(containerName, newCFObject(data, "path/bar")).get(10,
|
||||
TimeUnit.SECONDS);
|
||||
|
||||
BoundedSortedSet<ObjectInfo> container = context.getApi().listObjects(containerName,
|
||||
ListResponse<ObjectInfo> container = context.getApi().listObjects(containerName,
|
||||
underPath("")).get(10, TimeUnit.SECONDS);
|
||||
assert !container.isTruncated();
|
||||
assertEquals(container.size(), 1);
|
||||
|
|
|
@ -35,17 +35,17 @@ import java.util.concurrent.Future;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||
import org.jclouds.blobstore.domain.ListContainerResponse;
|
||||
import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
|
||||
import org.jclouds.blobstore.integration.internal.StubBlobStore;
|
||||
import org.jclouds.blobstore.integration.internal.StubBlobStore.FutureBase;
|
||||
import org.jclouds.blobstore.options.ListOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.concurrent.FutureFunctionWrapper;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
import org.jclouds.logging.Logger.LoggerFactory;
|
||||
import org.jclouds.rackspace.cloudfiles.CloudFilesClient;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.BlobToObject;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.ListContainerOptionsToListOptions;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.ListContainerOptionsToBlobStoreListContainerOptions;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.ObjectToBlob;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.ResourceToObjectInfo;
|
||||
import org.jclouds.rackspace.cloudfiles.blobstore.functions.ResourceToObjectList;
|
||||
|
@ -56,7 +56,6 @@ import org.jclouds.rackspace.cloudfiles.domain.ContainerMetadata;
|
|||
import org.jclouds.rackspace.cloudfiles.domain.MutableObjectInfoWithMetadata;
|
||||
import org.jclouds.rackspace.cloudfiles.domain.ObjectInfo;
|
||||
import org.jclouds.rackspace.cloudfiles.options.ListCdnContainerOptions;
|
||||
import org.jclouds.rackspace.cloudfiles.options.ListContainerOptions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
@ -75,7 +74,7 @@ public class StubCloudFilesClient implements CloudFilesClient {
|
|||
private final ObjectToBlob object2Blob;
|
||||
private final BlobToObject blob2Object;
|
||||
private final ResourceToObjectInfo blob2ObjectInfo;
|
||||
private final ListContainerOptionsToListOptions container2ContainerListOptions;
|
||||
private final ListContainerOptionsToBlobStoreListContainerOptions container2ContainerListOptions;
|
||||
private final ResourceToObjectList resource2ObjectList;
|
||||
|
||||
@Inject
|
||||
|
@ -84,7 +83,7 @@ public class StubCloudFilesClient implements CloudFilesClient {
|
|||
CFObject.Factory objectProvider,
|
||||
HttpGetOptionsListToGetOptions httpGetOptionsConverter, ObjectToBlob object2Blob,
|
||||
BlobToObject blob2Object, ResourceToObjectInfo blob2ObjectInfo,
|
||||
ListContainerOptionsToListOptions container2ContainerListOptions,
|
||||
ListContainerOptionsToBlobStoreListContainerOptions container2ContainerListOptions,
|
||||
ResourceToObjectList resource2ContainerList) {
|
||||
this.blobStore = blobStore;
|
||||
this.logFactory = logFactory;
|
||||
|
@ -149,7 +148,7 @@ public class StubCloudFilesClient implements CloudFilesClient {
|
|||
}
|
||||
|
||||
public Future<? extends SortedSet<ContainerMetadata>> listContainers(
|
||||
ListContainerOptions... options) {
|
||||
org.jclouds.rackspace.cloudfiles.options.ListContainerOptions... options) {
|
||||
return new FutureBase<SortedSet<ContainerMetadata>>() {
|
||||
|
||||
public SortedSet<ContainerMetadata> get() throws InterruptedException, ExecutionException {
|
||||
|
@ -164,9 +163,9 @@ public class StubCloudFilesClient implements CloudFilesClient {
|
|||
};
|
||||
}
|
||||
|
||||
public Future<BoundedSortedSet<ObjectInfo>> listObjects(String container,
|
||||
ListContainerOptions... optionsList) {
|
||||
ListOptions options = container2ContainerListOptions.apply(optionsList);
|
||||
public Future<ListContainerResponse<ObjectInfo>> listObjects(String container,
|
||||
org.jclouds.rackspace.cloudfiles.options.ListContainerOptions... optionsList) {
|
||||
ListContainerOptions options = container2ContainerListOptions.apply(optionsList);
|
||||
return wrapFuture(blobStore.list(container, options), resource2ObjectList);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[
|
||||
{"name":"adriancole-blobstore.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"http://c0354712.cdn.cloudfiles.rackspacecloud.com,"referrer_acl":"","useragent_acl":"", "log_retention":"false"},
|
||||
{"name":"adriancole-blobstore5","cdn_enabled":"true","ttl":28800,"cdn_uri":"http://c0404671.cdn.cloudfiles.rackspacecloud.com,"referrer_acl":"","useragent_acl":"", "log_retention":"false"},
|
||||
{"name":"adriancole-cfcdnint.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"http://c0320431.cdn.cloudfiles.rackspacecloud.com,"referrer_acl":"","useragent_acl":"", "log_retention":"false"}
|
||||
{"name":"adriancole-blobstore.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"http://c0354712.cdn.cloudfiles.rackspacecloud.com","referrer_acl":"","useragent_acl":"", "log_retention":"false"},
|
||||
{"name":"adriancole-blobstore5","cdn_enabled":"true","ttl":28800,"cdn_uri":"http://c0404671.cdn.cloudfiles.rackspacecloud.com","referrer_acl":"","useragent_acl":"", "log_retention":"false"},
|
||||
{"name":"adriancole-cfcdnint.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"http://c0320431.cdn.cloudfiles.rackspacecloud.com","referrer_acl":"","useragent_acl":"", "log_retention":"false"}
|
||||
]
|
Loading…
Reference in New Issue