diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java index 1889c35883..8ecc0c1f16 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java @@ -21,6 +21,7 @@ import java.util.Set; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobBuilder; import org.jclouds.blobstore.domain.BlobMetadata; +import org.jclouds.blobstore.domain.ContainerAccess; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.options.CreateContainerOptions; @@ -91,6 +92,10 @@ public interface BlobStore { */ boolean createContainerInLocation(@Nullable Location location, String container, CreateContainerOptions options); + ContainerAccess getContainerAccess(String container); + + void setContainerAccess(String container, ContainerAccess access); + /** * Lists all resources in a container non-recursive. * diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/ContainerAccess.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/ContainerAccess.java new file mode 100644 index 0000000000..67dbe79fa9 --- /dev/null +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/ContainerAccess.java @@ -0,0 +1,25 @@ +/* + * 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; + +public enum ContainerAccess { + /** Only allow bucket owner to read and write objects. */ + PRIVATE, + /** Allow all users to read objects but only allow owner to write objects. */ + PUBLIC_READ; +} diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java index 41542e45d7..732e350673 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java @@ -37,8 +37,10 @@ import java.util.concurrent.TimeoutException; import javax.ws.rs.core.MediaType; +import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; +import org.jclouds.blobstore.domain.ContainerAccess; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.options.ListContainerOptions; @@ -475,6 +477,23 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { } } + @Test(groups = { "integration", "live" }) + public void testSetContainerAccess() throws Exception { + BlobStore blobStore = view.getBlobStore(); + String containerName = getContainerName(); + try { + assertThat(blobStore.getContainerAccess(containerName)).isEqualTo(ContainerAccess.PRIVATE); + + blobStore.setContainerAccess(containerName, ContainerAccess.PUBLIC_READ); + assertThat(blobStore.getContainerAccess(containerName)).isEqualTo(ContainerAccess.PUBLIC_READ); + + blobStore.setContainerAccess(containerName, ContainerAccess.PRIVATE); + assertThat(blobStore.getContainerAccess(containerName)).isEqualTo(ContainerAccess.PRIVATE); + } finally { + recycleContainerAndAddToPool(containerName); + } + } + protected void addAlphabetUnderRoot(String containerName) throws InterruptedException { for (char letter = 'a'; letter <= 'z'; letter++) { view.getBlobStore().putBlob(containerName,