mirror of https://github.com/apache/jclouds.git
Removed mistaken functionality to parse an S3 item's CannedAccessPolicy from HTTP response headers. S3 does not actually return this information, the ACL settings are only available via the ACL-specific API operations.
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1598 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
7366d5c1cc
commit
d029659a63
|
@ -27,7 +27,6 @@ import java.util.Map.Entry;
|
|||
|
||||
import org.jclouds.aws.s3.domain.S3Object;
|
||||
import org.jclouds.aws.s3.domain.S3Object.Metadata;
|
||||
import org.jclouds.aws.s3.domain.acl.CannedAccessPolicy;
|
||||
import org.jclouds.aws.s3.reference.S3Headers;
|
||||
import org.jclouds.aws.s3.util.S3Utils;
|
||||
import org.jclouds.aws.util.DateService;
|
||||
|
@ -64,7 +63,6 @@ public class ParseMetadataFromHeaders extends HttpFutureCommand.ResponseCallable
|
|||
|
||||
addUserMetadataTo(metadata);
|
||||
addMd5To(metadata);
|
||||
addCannedAccessPolicyTo(metadata);
|
||||
|
||||
parseLastModifiedOrThrowException(metadata);
|
||||
setContentTypeOrThrowException(metadata);
|
||||
|
@ -124,13 +122,6 @@ public class ParseMetadataFromHeaders extends HttpFutureCommand.ResponseCallable
|
|||
}
|
||||
}
|
||||
|
||||
private void addCannedAccessPolicyTo(S3Object.Metadata metadata) {
|
||||
String aclHeader = getResponse().getFirstHeaderOrNull(S3Headers.CANNED_ACL);
|
||||
if (aclHeader != null) {
|
||||
metadata.setCannedAccessPolicy(CannedAccessPolicy.fromHeader(aclHeader));
|
||||
}
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
|
|
@ -23,19 +23,22 @@
|
|||
*/
|
||||
package org.jclouds.aws.s3.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.*;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.jclouds.aws.s3.commands.options.GetObjectOptions;
|
||||
import org.jclouds.aws.s3.domain.acl.CannedAccessPolicy;
|
||||
import org.jclouds.aws.s3.util.S3Utils;
|
||||
import org.jclouds.aws.s3.util.S3Utils.Md5InputStreamResult;
|
||||
import org.jclouds.http.ContentTypes;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
* Amazon S3 is designed to store objects. Objects are stored in
|
||||
|
@ -97,7 +100,6 @@ public class S3Object {
|
|||
private String cacheControl;
|
||||
private String dataDisposition;
|
||||
private String dataEncoding;
|
||||
private CannedAccessPolicy cannedAccessPolicy;
|
||||
private AccessControlList accessControlList;
|
||||
|
||||
// only parsed on list
|
||||
|
@ -323,14 +325,6 @@ public class S3Object {
|
|||
this.allHeaders = allHeaders;
|
||||
}
|
||||
|
||||
public void setCannedAccessPolicy(CannedAccessPolicy policy) {
|
||||
this.cannedAccessPolicy = policy;
|
||||
}
|
||||
|
||||
public CannedAccessPolicy getCannedAccessPolicy() {
|
||||
return this.cannedAccessPolicy;
|
||||
}
|
||||
|
||||
public void setAccessControlList(AccessControlList acl) {
|
||||
this.accessControlList = acl;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ package org.jclouds.aws.s3.commands.callables;
|
|||
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.reset;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -33,8 +32,6 @@ import static org.testng.Assert.assertEquals;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.jclouds.aws.s3.domain.S3Object;
|
||||
import org.jclouds.aws.s3.domain.S3Object.Metadata;
|
||||
import org.jclouds.aws.s3.domain.acl.CannedAccessPolicy;
|
||||
import org.jclouds.aws.s3.reference.S3Headers;
|
||||
import org.jclouds.aws.util.DateService;
|
||||
import org.jclouds.http.HttpException;
|
||||
import org.jclouds.http.HttpHeaders;
|
||||
|
@ -95,44 +92,6 @@ public class ParseObjectFromHeadersAndHttpContentTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseObjectFromHeadersWithCannedAccessPolicy() throws HttpException {
|
||||
DateService dateService = new DateService();
|
||||
ParseMetadataFromHeaders metadataParser = new ParseMetadataFromHeaders(dateService);
|
||||
metadataParser.setKey("object-key");
|
||||
ParseObjectFromHeadersAndHttpContent callable = new ParseObjectFromHeadersAndHttpContent(
|
||||
metadataParser);
|
||||
|
||||
HttpResponse response = createNiceMock(HttpResponse.class);
|
||||
callable.setResponse(response);
|
||||
|
||||
S3Object object;
|
||||
|
||||
// Test with no policy
|
||||
buildDefaultResponseMock(response);
|
||||
expect(response.getFirstHeaderOrNull(S3Headers.CANNED_ACL)).andReturn(null);
|
||||
replay(response);
|
||||
object = callable.call();
|
||||
assertEquals(object.getMetadata().getCannedAccessPolicy(), null);
|
||||
|
||||
// Test setting the "private" policy
|
||||
buildDefaultResponseMock(response);
|
||||
expect(response.getFirstHeaderOrNull(S3Headers.CANNED_ACL)).andReturn(
|
||||
CannedAccessPolicy.PRIVATE.toString());
|
||||
replay(response);
|
||||
object = callable.call();
|
||||
assertEquals(object.getMetadata().getCannedAccessPolicy(), CannedAccessPolicy.PRIVATE);
|
||||
|
||||
// Test setting the "authenticated read" policy
|
||||
buildDefaultResponseMock(response);
|
||||
expect(response.getFirstHeaderOrNull(S3Headers.CANNED_ACL)).andReturn(
|
||||
CannedAccessPolicy.AUTHENTICATED_READ.toString());
|
||||
replay(response);
|
||||
object = callable.call();
|
||||
assertEquals(object.getMetadata().getCannedAccessPolicy(),
|
||||
CannedAccessPolicy.AUTHENTICATED_READ);
|
||||
}
|
||||
|
||||
private void buildDefaultResponseMock(HttpResponse response) {
|
||||
reset(response);
|
||||
|
||||
|
|
Loading…
Reference in New Issue