mirror of https://github.com/apache/jclouds.git
JCLOUDS-660: Transient portable container ACLs
This commit is contained in:
parent
9c92487c29
commit
1bd9c46600
|
@ -19,7 +19,9 @@ package org.jclouds.blobstore;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
|
import org.jclouds.blobstore.domain.ContainerAccess;
|
||||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||||
|
import org.jclouds.blobstore.options.CreateContainerOptions;
|
||||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
|
@ -47,7 +49,11 @@ public interface LocalStorageStrategy {
|
||||||
* @param container
|
* @param container
|
||||||
* @return
|
* @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
|
* Deletes a container and all its content
|
||||||
|
|
|
@ -30,10 +30,12 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.domain.Blob.Factory;
|
import org.jclouds.blobstore.domain.Blob.Factory;
|
||||||
|
import org.jclouds.blobstore.domain.ContainerAccess;
|
||||||
import org.jclouds.blobstore.domain.MutableStorageMetadata;
|
import org.jclouds.blobstore.domain.MutableStorageMetadata;
|
||||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||||
import org.jclouds.blobstore.domain.StorageType;
|
import org.jclouds.blobstore.domain.StorageType;
|
||||||
import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl;
|
import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl;
|
||||||
|
import org.jclouds.blobstore.options.CreateContainerOptions;
|
||||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
|
@ -58,6 +60,7 @@ import com.google.common.net.HttpHeaders;
|
||||||
public class TransientStorageStrategy implements LocalStorageStrategy {
|
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, Blob>> containerToBlobs = new ConcurrentHashMap<String, ConcurrentMap<String, Blob>>();
|
||||||
private final ConcurrentMap<String, StorageMetadata> containerMetadata = new ConcurrentHashMap<String, StorageMetadata>();
|
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;
|
private final Supplier<Location> defaultLocation;
|
||||||
private final DateService dateService;
|
private final DateService dateService;
|
||||||
private final Factory blobFactory;
|
private final Factory blobFactory;
|
||||||
|
@ -83,7 +86,7 @@ public class TransientStorageStrategy implements LocalStorageStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createContainerInLocation(final String containerName, final Location location) {
|
public boolean createContainerInLocation(String containerName, Location location, CreateContainerOptions options) {
|
||||||
ConcurrentMap<String, Blob> origValue = containerToBlobs.putIfAbsent(
|
ConcurrentMap<String, Blob> origValue = containerToBlobs.putIfAbsent(
|
||||||
containerName, new ConcurrentHashMap<String, Blob>());
|
containerName, new ConcurrentHashMap<String, Blob>());
|
||||||
if (origValue != null) {
|
if (origValue != null) {
|
||||||
|
@ -96,9 +99,23 @@ public class TransientStorageStrategy implements LocalStorageStrategy {
|
||||||
metadata.setLocation(location);
|
metadata.setLocation(location);
|
||||||
metadata.setCreationDate(new Date());
|
metadata.setCreationDate(new Date());
|
||||||
containerMetadata.put(containerName, metadata);
|
containerMetadata.put(containerName, metadata);
|
||||||
|
|
||||||
|
containerAccessMap.put(containerName, options.isPublicRead()
|
||||||
|
? ContainerAccess.PUBLIC_READ : ContainerAccess.PRIVATE);
|
||||||
return true;
|
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
|
@Override
|
||||||
public void deleteContainer(final String containerName) {
|
public void deleteContainer(final String containerName) {
|
||||||
containerToBlobs.remove(containerName);
|
containerToBlobs.remove(containerName);
|
||||||
|
|
|
@ -391,17 +391,17 @@ public final class LocalBlobStore implements BlobStore {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createContainerInLocation(Location location, String name) {
|
public boolean createContainerInLocation(Location location, String name) {
|
||||||
return storageStrategy.createContainerInLocation(name, location);
|
return storageStrategy.createContainerInLocation(name, location, CreateContainerOptions.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContainerAccess getContainerAccess(String container) {
|
public ContainerAccess getContainerAccess(String container) {
|
||||||
throw new UnsupportedOperationException("not implemented");
|
return storageStrategy.getContainerAccess(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContainerAccess(String container, ContainerAccess access) {
|
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) {
|
private Blob loadBlob(final String container, final String key) {
|
||||||
|
@ -624,8 +624,6 @@ public final class LocalBlobStore implements BlobStore {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) {
|
public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) {
|
||||||
if (options.isPublicRead())
|
return storageStrategy.createContainerInLocation(container, location, options);
|
||||||
throw new UnsupportedOperationException("publicRead");
|
|
||||||
return createContainerInLocation(location, container);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.jclouds.blobstore.domain.StorageMetadata;
|
||||||
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
|
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.testng.SkipException;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
@ -81,9 +80,4 @@ public class TransientContainerIntegrationTest extends BaseContainerIntegrationT
|
||||||
created = blobStore.createContainerInLocation(location, container);
|
created = blobStore.createContainerInLocation(location, container);
|
||||||
assertFalse(created);
|
assertFalse(created);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testSetContainerAccess() throws Exception {
|
|
||||||
throw new SkipException("Intentionally not implemented for the transient provider");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue