JCLOUDS-660: portable container ACLs

This commit is contained in:
Andrew Gaul 2015-02-06 10:42:40 -08:00
parent eacfc8fdf1
commit a19795800a
3 changed files with 49 additions and 0 deletions

View File

@ -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.
*

View File

@ -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;
}

View File

@ -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,