JCLOUDS-457: List containers and remove blob
List containers and remove blob operations have
been added.
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.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 @@
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 @@
@Override
public PageSet<? extends StorageMetadata> list() {
- throw new UnsupportedOperationException();
+ return vaultsToContainers.apply(sync.listVaults());
}
@Override
@@ -118,6 +121,6 @@
@Override
public void removeBlob(String container, String key) {
- throw new UnsupportedOperationException();
+ sync.deleteArchive(container, key);
}
}
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 @@
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 @@
bind(AsyncBlobStore.class).to(GlacierAsyncBlobStore.class);
bind(MultipartUploadStrategy.class).to(SequentialMultipartUploadStrategy.class);
bind(SlicingStrategy.class).to(BaseSlicingStrategy.class);
+ bind(ClearListStrategy.class).to(ClearVaultStrategy.class);
}
}
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());
+ }
+}
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());
+ }
+}
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;
+ }
+}