JCLOUDS-660: Atmos portable container ACLs

This commit is contained in:
Andrew Gaul 2015-02-08 17:02:10 -08:00
parent a19795800a
commit c1549e8ae2
4 changed files with 46 additions and 1 deletions

View File

@ -175,4 +175,12 @@ public interface AtmosClient extends Closeable {
@Fallback(FalseOnNotFoundOr404.class)
boolean isPublic(@PathParam("path") String path);
@Named("SetObjectMetadata")
@POST
@Path("/{path}")
@QueryParams(keys = "acl")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Fallback(ThrowKeyNotFoundOn404.class)
@Consumes(MediaType.WILDCARD)
void setGroupAcl(@PathParam("path") String path, PutOptions options);
}

View File

@ -36,6 +36,7 @@ import org.jclouds.atmos.util.AtmosUtils;
import org.jclouds.blobstore.BlobStoreContext;
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.functions.BlobToHttpGetOptions;
@ -118,6 +119,26 @@ public class AtmosBlobStore extends BaseBlobStore {
return sync.createDirectory(container) != null;
}
@Override
public ContainerAccess getContainerAccess(String container) {
if (sync.isPublic(container)) {
return ContainerAccess.PUBLIC_READ;
} else {
return ContainerAccess.PRIVATE;
}
}
@Override
public void setContainerAccess(String container, ContainerAccess access) {
org.jclouds.atmos.options.PutOptions options = new org.jclouds.atmos.options.PutOptions();
if (access == ContainerAccess.PUBLIC_READ) {
options.publicRead();
} else {
options.publicNone();
}
sync.setGroupAcl(container, options);
}
/**
* This implementation invokes {@link AtmosClient#createDirectory}
*

View File

@ -177,7 +177,12 @@ public class SignRequest implements HttpRequestFilter {
@VisibleForTesting
void appendCanonicalizedResource(HttpRequest request, StringBuilder toSign) {
// Path portion of the HTTP request URI, in lowercase.
toSign.append(request.getEndpoint().getRawPath().toLowerCase()).append("\n");
toSign.append(request.getEndpoint().getRawPath().toLowerCase());
String query = request.getEndpoint().getRawQuery();
if (query != null) {
toSign.append("?").append(query);
}
toSign.append("\n");
}
}

View File

@ -47,6 +47,12 @@ public class PutOptions extends BaseHttpRequestOptions {
return this;
}
public PutOptions publicNone() {
this.replaceHeader("x-emc-useracl", "root=FULL_CONTROL");
this.replaceHeader("x-emc-groupacl", "other=NONE");
return this;
}
public static class Builder {
/**
@ -56,5 +62,10 @@ public class PutOptions extends BaseHttpRequestOptions {
PutOptions options = new PutOptions();
return options.publicRead();
}
public static PutOptions publicNone() {
PutOptions options = new PutOptions();
return options.publicNone();
}
}
}