Skip to content
Permalink
Browse files
JCLOUDS-457: List containers and remove blob
List containers and remove blob operations have
been added.
  • Loading branch information
rcoedo authored and gaul committed Jul 26, 2014
1 parent 6a8586a commit 36e8cbda3572a47d15a4305e4a0ea1e5f6c2fe5a
Showing 5 changed files with 106 additions and 3 deletions.
@@ -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 @@ 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 @@ protected boolean deleteAndVerifyContainerGone(String container) {

@Override
public PageSet<? extends StorageMetadata> list() {
throw new UnsupportedOperationException();
return vaultsToContainers.apply(sync.listVaults());
}

@Override
@@ -118,6 +121,6 @@ public Blob getBlob(String container, String key, GetOptions getOptions) {

@Override
public void removeBlob(String container, String key) {
throw new UnsupportedOperationException();
sync.deleteArchive(container, key);
}
}
@@ -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 @@ protected void configure() {
bind(AsyncBlobStore.class).to(GlacierAsyncBlobStore.class);
bind(MultipartUploadStrategy.class).to(SequentialMultipartUploadStrategy.class);
bind(SlicingStrategy.class).to(BaseSlicingStrategy.class);
bind(ClearListStrategy.class).to(ClearVaultStrategy.class);
}
}
@@ -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());
}
}
@@ -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());
}
}
@@ -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;
}
}

0 comments on commit 36e8cbd

Please sign in to comment.