Repository: jclouds-labs-aws Updated Branches: refs/heads/master 6a8586ab0 -> 36e8cbda3
JCLOUDS-457: List containers and remove blob List containers and remove blob operations have been added. Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/commit/36e8cbda Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/tree/36e8cbda Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/diff/36e8cbda Branch: refs/heads/master Commit: 36e8cbda3572a47d15a4305e4a0ea1e5f6c2fe5a Parents: 6a8586a Author: Roman Coedo <[email protected]> Authored: Sun Jul 13 22:54:23 2014 +0200 Committer: Andrew Gaul <[email protected]> Committed: Fri Jul 25 22:47:33 2014 -0700 ---------------------------------------------------------------------- .../glacier/blobstore/GlacierBlobStore.java | 9 ++++-- .../config/GlacierBlobStoreContextModule.java | 3 ++ ...ginatedVaultCollectionToStorageMetadata.java | 34 ++++++++++++++++++++ .../VaultMetadataToStorageMetadata.java | 33 +++++++++++++++++++ .../blobstore/strategy/ClearVaultStrategy.java | 30 +++++++++++++++++ 5 files changed, 106 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/36e8cbda/glacier/src/main/java/org/jclouds/glacier/blobstore/GlacierBlobStore.java ---------------------------------------------------------------------- diff --git a/glacier/src/main/java/org/jclouds/glacier/blobstore/GlacierBlobStore.java b/glacier/src/main/java/org/jclouds/glacier/blobstore/GlacierBlobStore.java index 1600d22..15ebdc3 100644 --- a/glacier/src/main/java/org/jclouds/glacier/blobstore/GlacierBlobStore.java +++ b/glacier/src/main/java/org/jclouds/glacier/blobstore/GlacierBlobStore.java @@ -35,6 +35,7 @@ import org.jclouds.collect.Memoized; import org.jclouds.crypto.Crypto; import org.jclouds.domain.Location; import org.jclouds.glacier.GlacierClient; +import org.jclouds.glacier.blobstore.functions.PaginatedVaultCollectionToStorageMetadata; import org.jclouds.glacier.blobstore.strategy.MultipartUploadStrategy; import org.jclouds.javax.annotation.Nullable; @@ -46,12 +47,14 @@ public class GlacierBlobStore extends BaseBlobStore { private final GlacierClient sync; private final Crypto crypto; private final Provider<MultipartUploadStrategy> multipartUploadStrategy; + private final PaginatedVaultCollectionToStorageMetadata vaultsToContainers; @Inject GlacierBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation, @Memoized Supplier<Set<? extends Location>> locations, GlacierClient sync, Crypto crypto, - Provider<MultipartUploadStrategy> multipartUploadStrategy) { + Provider<MultipartUploadStrategy> multipartUploadStrategy, PaginatedVaultCollectionToStorageMetadata vaultsToContainers) { super(context, blobUtils, defaultLocation, locations); + this.vaultsToContainers = checkNotNull(vaultsToContainers, "vaultsToContainers"); this.multipartUploadStrategy = checkNotNull(multipartUploadStrategy, "multipartUploadStrategy"); this.sync = checkNotNull(sync, "sync"); this.crypto = checkNotNull(crypto, "crypto"); @@ -64,7 +67,7 @@ public class GlacierBlobStore extends BaseBlobStore { @Override public PageSet<? extends StorageMetadata> list() { - throw new UnsupportedOperationException(); + return vaultsToContainers.apply(sync.listVaults()); } @Override @@ -118,6 +121,6 @@ public class GlacierBlobStore extends BaseBlobStore { @Override public void removeBlob(String container, String key) { - throw new UnsupportedOperationException(); + sync.deleteArchive(container, key); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/36e8cbda/glacier/src/main/java/org/jclouds/glacier/blobstore/config/GlacierBlobStoreContextModule.java ---------------------------------------------------------------------- diff --git a/glacier/src/main/java/org/jclouds/glacier/blobstore/config/GlacierBlobStoreContextModule.java b/glacier/src/main/java/org/jclouds/glacier/blobstore/config/GlacierBlobStoreContextModule.java index 302a341..e330c53 100644 --- a/glacier/src/main/java/org/jclouds/glacier/blobstore/config/GlacierBlobStoreContextModule.java +++ b/glacier/src/main/java/org/jclouds/glacier/blobstore/config/GlacierBlobStoreContextModule.java @@ -19,8 +19,10 @@ package org.jclouds.glacier.blobstore.config; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.attr.ConsistencyModel; +import org.jclouds.blobstore.strategy.ClearListStrategy; import org.jclouds.glacier.blobstore.GlacierAsyncBlobStore; import org.jclouds.glacier.blobstore.GlacierBlobStore; +import org.jclouds.glacier.blobstore.strategy.ClearVaultStrategy; import org.jclouds.glacier.blobstore.strategy.MultipartUploadStrategy; import org.jclouds.glacier.blobstore.strategy.SlicingStrategy; import org.jclouds.glacier.blobstore.strategy.internal.BaseSlicingStrategy; @@ -36,5 +38,6 @@ public class GlacierBlobStoreContextModule extends AbstractModule { bind(AsyncBlobStore.class).to(GlacierAsyncBlobStore.class); bind(MultipartUploadStrategy.class).to(SequentialMultipartUploadStrategy.class); bind(SlicingStrategy.class).to(BaseSlicingStrategy.class); + bind(ClearListStrategy.class).to(ClearVaultStrategy.class); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/36e8cbda/glacier/src/main/java/org/jclouds/glacier/blobstore/functions/PaginatedVaultCollectionToStorageMetadata.java ---------------------------------------------------------------------- diff --git a/glacier/src/main/java/org/jclouds/glacier/blobstore/functions/PaginatedVaultCollectionToStorageMetadata.java b/glacier/src/main/java/org/jclouds/glacier/blobstore/functions/PaginatedVaultCollectionToStorageMetadata.java new file mode 100644 index 0000000..67e4d9c --- /dev/null +++ b/glacier/src/main/java/org/jclouds/glacier/blobstore/functions/PaginatedVaultCollectionToStorageMetadata.java @@ -0,0 +1,34 @@ +/* + * 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.glacier.blobstore.functions; + +import org.jclouds.blobstore.domain.PageSet; +import org.jclouds.blobstore.domain.StorageMetadata; +import org.jclouds.blobstore.domain.internal.PageSetImpl; +import org.jclouds.glacier.domain.PaginatedVaultCollection; + +import com.google.common.base.Function; +import com.google.common.collect.Iterables; + +public class PaginatedVaultCollectionToStorageMetadata implements Function<PaginatedVaultCollection, + PageSet<? extends StorageMetadata>> { + @Override + public PageSet<? extends StorageMetadata> apply(PaginatedVaultCollection vaults) { + return new PageSetImpl<StorageMetadata>(Iterables.transform(vaults, new VaultMetadataToStorageMetadata()), + (String) vaults.nextMarker().orNull()); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/36e8cbda/glacier/src/main/java/org/jclouds/glacier/blobstore/functions/VaultMetadataToStorageMetadata.java ---------------------------------------------------------------------- diff --git a/glacier/src/main/java/org/jclouds/glacier/blobstore/functions/VaultMetadataToStorageMetadata.java b/glacier/src/main/java/org/jclouds/glacier/blobstore/functions/VaultMetadataToStorageMetadata.java new file mode 100644 index 0000000..54e8ba3 --- /dev/null +++ b/glacier/src/main/java/org/jclouds/glacier/blobstore/functions/VaultMetadataToStorageMetadata.java @@ -0,0 +1,33 @@ +/* + * 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.glacier.blobstore.functions; + +import org.jclouds.blobstore.domain.StorageMetadata; +import org.jclouds.blobstore.domain.StorageType; +import org.jclouds.blobstore.domain.internal.StorageMetadataImpl; +import org.jclouds.glacier.domain.VaultMetadata; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableMap; + +public class VaultMetadataToStorageMetadata implements Function<VaultMetadata, StorageMetadata> { + @Override + public StorageMetadata apply(VaultMetadata vault) { + return new StorageMetadataImpl(StorageType.CONTAINER, vault.getVaultARN(), vault.getVaultName(), null, null, null, + vault.getCreationDate(), vault.getLastInventoryDate(), ImmutableMap.<String, String>of()); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/36e8cbda/glacier/src/main/java/org/jclouds/glacier/blobstore/strategy/ClearVaultStrategy.java ---------------------------------------------------------------------- diff --git a/glacier/src/main/java/org/jclouds/glacier/blobstore/strategy/ClearVaultStrategy.java b/glacier/src/main/java/org/jclouds/glacier/blobstore/strategy/ClearVaultStrategy.java new file mode 100644 index 0000000..f378ec2 --- /dev/null +++ b/glacier/src/main/java/org/jclouds/glacier/blobstore/strategy/ClearVaultStrategy.java @@ -0,0 +1,30 @@ +/* + * 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.glacier.blobstore.strategy; + +import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.strategy.ClearListStrategy; + +import com.google.inject.Singleton; + +@Singleton +public class ClearVaultStrategy implements ClearListStrategy { + @Override + public void execute(String s, ListContainerOptions listContainerOptions) { + return; + } +}
