diff --git a/blobstore/src/main/java/org/jclouds/blobstore/LocalStorageStrategy.java b/blobstore/src/main/java/org/jclouds/blobstore/LocalStorageStrategy.java index 1cf8bac33d..5808267df0 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/LocalStorageStrategy.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/LocalStorageStrategy.java @@ -19,7 +19,9 @@ package org.jclouds.blobstore; import java.io.IOException; import org.jclouds.blobstore.domain.Blob; +import org.jclouds.blobstore.domain.ContainerAccess; import org.jclouds.blobstore.domain.StorageMetadata; +import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.domain.Location; @@ -47,7 +49,11 @@ public interface LocalStorageStrategy { * @param container * @return */ - boolean createContainerInLocation(String container, Location location); + boolean createContainerInLocation(String container, Location location, CreateContainerOptions options); + + ContainerAccess getContainerAccess(String container); + + void setContainerAccess(String container, ContainerAccess access); /** * Deletes a container and all its content diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientStorageStrategy.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientStorageStrategy.java index 98d8130dea..3c144efdb1 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientStorageStrategy.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientStorageStrategy.java @@ -30,10 +30,12 @@ import javax.inject.Inject; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; +import org.jclouds.blobstore.domain.ContainerAccess; import org.jclouds.blobstore.domain.MutableStorageMetadata; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.StorageType; import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl; +import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.util.BlobStoreUtils; import org.jclouds.date.DateService; @@ -58,6 +60,7 @@ import com.google.common.net.HttpHeaders; public class TransientStorageStrategy implements LocalStorageStrategy { private final ConcurrentMap> containerToBlobs = new ConcurrentHashMap>(); private final ConcurrentMap containerMetadata = new ConcurrentHashMap(); + private final ConcurrentMap containerAccessMap = new ConcurrentHashMap(); private final Supplier defaultLocation; private final DateService dateService; private final Factory blobFactory; @@ -83,7 +86,7 @@ public class TransientStorageStrategy implements LocalStorageStrategy { } @Override - public boolean createContainerInLocation(final String containerName, final Location location) { + public boolean createContainerInLocation(String containerName, Location location, CreateContainerOptions options) { ConcurrentMap origValue = containerToBlobs.putIfAbsent( containerName, new ConcurrentHashMap()); if (origValue != null) { @@ -96,9 +99,23 @@ public class TransientStorageStrategy implements LocalStorageStrategy { metadata.setLocation(location); metadata.setCreationDate(new Date()); containerMetadata.put(containerName, metadata); + + containerAccessMap.put(containerName, options.isPublicRead() + ? ContainerAccess.PUBLIC_READ : ContainerAccess.PRIVATE); return true; } + @Override + public ContainerAccess getContainerAccess(String container) { + ContainerAccess access = containerAccessMap.get(container); + return access == null ? ContainerAccess.PRIVATE : access; + } + + @Override + public void setContainerAccess(String container, ContainerAccess access) { + containerAccessMap.put(container, access); + } + @Override public void deleteContainer(final String containerName) { containerToBlobs.remove(containerName); diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java index e779bb9b2a..aa102e1e13 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java @@ -391,17 +391,17 @@ public final class LocalBlobStore implements BlobStore { @Override public boolean createContainerInLocation(Location location, String name) { - return storageStrategy.createContainerInLocation(name, location); + return storageStrategy.createContainerInLocation(name, location, CreateContainerOptions.NONE); } @Override public ContainerAccess getContainerAccess(String container) { - throw new UnsupportedOperationException("not implemented"); + return storageStrategy.getContainerAccess(container); } @Override public void setContainerAccess(String container, ContainerAccess access) { - throw new UnsupportedOperationException("not implemented"); + storageStrategy.setContainerAccess(container, access); } private Blob loadBlob(final String container, final String key) { @@ -624,8 +624,6 @@ public final class LocalBlobStore implements BlobStore { @Override public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) { - if (options.isPublicRead()) - throw new UnsupportedOperationException("publicRead"); - return createContainerInLocation(location, container); + return storageStrategy.createContainerInLocation(container, location, options); } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java index 7bbf8c3b54..bbca99df19 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java @@ -32,7 +32,6 @@ import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest; import org.jclouds.domain.Location; import org.testng.annotations.Test; -import org.testng.SkipException; import com.google.common.collect.ImmutableMap; @@ -81,9 +80,4 @@ public class TransientContainerIntegrationTest extends BaseContainerIntegrationT created = blobStore.createContainerInLocation(location, container); assertFalse(created); } - - @Override - public void testSetContainerAccess() throws Exception { - throw new SkipException("Intentionally not implemented for the transient provider"); - } }