JCLOUDS-732: Transient portable object ACLs

This commit is contained in:
Andrew Gaul 2015-03-31 15:26:20 -07:00
parent deff8d8413
commit 279a984fee
4 changed files with 36 additions and 9 deletions

View File

@ -19,6 +19,7 @@ package org.jclouds.blobstore;
import java.io.IOException;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobAccess;
import org.jclouds.blobstore.domain.ContainerAccess;
import org.jclouds.blobstore.domain.StorageMetadata;
import org.jclouds.blobstore.options.CreateContainerOptions;
@ -128,6 +129,10 @@ public interface LocalStorageStrategy {
*/
void removeBlob(String container, String key);
BlobAccess getBlobAccess(String container, String key);
void setBlobAccess(String container, String key, BlobAccess access);
/**
* @param containerName name of container
* @return Location of container or null

View File

@ -29,6 +29,7 @@ import java.util.concurrent.ConcurrentMap;
import javax.inject.Inject;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobAccess;
import org.jclouds.blobstore.domain.Blob.Factory;
import org.jclouds.blobstore.domain.ContainerAccess;
import org.jclouds.blobstore.domain.MutableStorageMetadata;
@ -59,6 +60,7 @@ import com.google.common.net.HttpHeaders;
public class TransientStorageStrategy implements LocalStorageStrategy {
private final ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs = new ConcurrentHashMap<String, ConcurrentMap<String, Blob>>();
private final ConcurrentMap<String, ConcurrentMap<String, BlobAccess>> containerToBlobAccess = new ConcurrentHashMap<String, ConcurrentMap<String, BlobAccess>>();
private final ConcurrentMap<String, StorageMetadata> containerMetadata = new ConcurrentHashMap<String, StorageMetadata>();
private final ConcurrentMap<String, ContainerAccess> containerAccessMap = new ConcurrentHashMap<String, ContainerAccess>();
private final Supplier<Location> defaultLocation;
@ -92,6 +94,7 @@ public class TransientStorageStrategy implements LocalStorageStrategy {
if (origValue != null) {
return false;
}
containerToBlobAccess.putIfAbsent(containerName, new ConcurrentHashMap<String, BlobAccess>());
MutableStorageMetadata metadata = new MutableStorageMetadataImpl();
metadata.setName(containerName);
@ -119,6 +122,7 @@ public class TransientStorageStrategy implements LocalStorageStrategy {
@Override
public void deleteContainer(final String containerName) {
containerToBlobs.remove(containerName);
containerToBlobAccess.remove(containerToBlobAccess);
}
@Override
@ -173,7 +177,9 @@ public class TransientStorageStrategy implements LocalStorageStrategy {
Blob newBlob = createUpdatedCopyOfBlobInContainer(containerName, blob, payload, actualHashCode);
Map<String, Blob> map = containerToBlobs.get(containerName);
map.put(newBlob.getMetadata().getName(), newBlob);
String blobName = newBlob.getMetadata().getName();
map.put(blobName, newBlob);
containerToBlobAccess.get(containerName).put(blobName, BlobAccess.PRIVATE);
return base16().lowerCase().encode(actualHashCode.asBytes());
}
@ -184,6 +190,28 @@ public class TransientStorageStrategy implements LocalStorageStrategy {
map.remove(blobName);
}
@Override
public BlobAccess getBlobAccess(String containerName, String blobName) {
Map<String, BlobAccess> map = containerToBlobAccess.get(containerName);
if (map == null) {
throw new ContainerNotFoundException(containerName, "in getBlobAccess");
}
BlobAccess access = map.get(blobName);
if (access == null) {
throw new KeyNotFoundException(containerName, blobName, "in getBlobAccess");
}
return access;
}
@Override
public void setBlobAccess(String containerName, String blobName, BlobAccess access) {
Map<String, BlobAccess> map = containerToBlobAccess.get(containerName);
if (map == null) {
throw new ContainerNotFoundException(containerName, "in setBlobAccess");
}
map.put(blobName, access);
}
@Override
public Location getLocation(final String containerName) {
return containerMetadata.get(containerName).getLocation();

View File

@ -347,12 +347,12 @@ public final class LocalBlobStore implements BlobStore {
@Override
public BlobAccess getBlobAccess(String container, String name) {
throw new UnsupportedOperationException("not implemented");
return storageStrategy.getBlobAccess(container, name);
}
@Override
public void setBlobAccess(String container, String name, BlobAccess access) {
throw new UnsupportedOperationException("not implemented");
storageStrategy.setBlobAccess(container, name, access);
}
@Override

View File

@ -18,16 +18,10 @@ package org.jclouds.blobstore.integration;
import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest;
import org.testng.annotations.Test;
import org.testng.SkipException;
@Test(groups = { "integration" })
public class TransientBlobIntegrationTest extends BaseBlobIntegrationTest {
public TransientBlobIntegrationTest() {
provider = "transient";
}
@Override
public void testSetBlobAccess() throws Exception {
throw new SkipException("Intentionally not implemented for the transient provider");
}
}