mirror of https://github.com/apache/jclouds.git
fixed tokenizing of copy and put object options for non-aws s3 clients
This commit is contained in:
parent
d306dcbdec
commit
7fd6cb3673
|
@ -262,7 +262,7 @@ public class CopyObjectOptions extends BaseHttpRequestOptions {
|
|||
checkState(metadataPrefix != null, "metadataPrefix should have been injected!");
|
||||
Multimap<String, String> returnVal = LinkedHashMultimap.create();
|
||||
for (Entry<String, String> entry : headers.entries()) {
|
||||
returnVal.put(entry.getKey().replace("aws", headerTag), entry.getValue());
|
||||
returnVal.put(entry.getKey().replace("amz", headerTag), entry.getValue());
|
||||
}
|
||||
if (metadata != null) {
|
||||
for (String key : metadata.keySet()) {
|
||||
|
|
|
@ -73,7 +73,7 @@ public class PutObjectOptions extends BaseHttpRequestOptions {
|
|||
checkState(headerTag != null, "headerTag should have been injected!");
|
||||
Multimap<String, String> returnVal = LinkedHashMultimap.create();
|
||||
for (Entry<String, String> entry : headers.entries()) {
|
||||
returnVal.put(entry.getKey().replace("aws", headerTag), entry.getValue());
|
||||
returnVal.put(entry.getKey().replace("amz", headerTag), entry.getValue());
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
|
|
|
@ -86,6 +86,12 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
}
|
||||
}
|
||||
|
||||
protected URL getObjectURL(String containerName, String key) throws Exception {
|
||||
URL url = new URL(String.format("http://%s.%s/%s", containerName, context.getProviderSpecificContext()
|
||||
.getEndpoint().getHost(), key));
|
||||
return url;
|
||||
}
|
||||
|
||||
public void testPutCannedAccessPolicyPublic() throws Exception {
|
||||
String containerName = getContainerName();
|
||||
try {
|
||||
|
@ -97,7 +103,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
|
||||
withAcl(CannedAccessPolicy.PUBLIC_READ));
|
||||
|
||||
URL url = new URL(String.format("http://%1$s.s3.amazonaws.com/%2$s", containerName, key));
|
||||
URL url = this.getObjectURL(containerName, key);
|
||||
Strings2.toStringAndClose(url.openStream());
|
||||
} finally {
|
||||
returnContainer(containerName);
|
||||
|
@ -117,7 +123,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
|
||||
validateContent(destinationContainer, destinationKey);
|
||||
|
||||
URL url = new URL(String.format("http://%1$s.s3.amazonaws.com/%2$s", destinationContainer, destinationKey));
|
||||
URL url = getObjectURL(destinationContainer, destinationKey);
|
||||
Strings2.toStringAndClose(url.openStream());
|
||||
|
||||
} finally {
|
||||
|
@ -292,9 +298,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
getApi().putObject(containerName, object);
|
||||
|
||||
S3Object newObject = validateObject(containerName, key);
|
||||
|
||||
assert (newObject.getMetadata().getCacheControl().indexOf("no-cache") != -1) : newObject.getMetadata()
|
||||
.getCacheControl();
|
||||
assertCacheControl(newObject, "no-cache");
|
||||
assertEquals(newObject.getMetadata().getContentMetadata().getContentDisposition(),
|
||||
"attachment; filename=hello.txt");
|
||||
} finally {
|
||||
|
@ -302,6 +306,15 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
}
|
||||
}
|
||||
|
||||
protected void assertCacheControl(S3Object newObject, String string) {
|
||||
assert (newObject.getMetadata().getCacheControl().indexOf(string) != -1) : newObject.getMetadata()
|
||||
.getCacheControl();
|
||||
}
|
||||
|
||||
protected void assertContentEncoding(S3Object newObject, String string) {
|
||||
assertEquals(newObject.getMetadata().getContentMetadata().getContentEncoding(), string);
|
||||
}
|
||||
|
||||
@Test(groups = { "integration", "live" })
|
||||
public void testMetadataContentEncoding() throws Exception {
|
||||
String key = "hello";
|
||||
|
@ -314,8 +327,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
try {
|
||||
getApi().putObject(containerName, object);
|
||||
S3Object newObject = validateObject(containerName, key);
|
||||
|
||||
assertEquals(newObject.getMetadata().getContentMetadata().getContentEncoding(), "x-compress");
|
||||
assertContentEncoding(newObject, "x-compress");
|
||||
} finally {
|
||||
returnContainer(containerName);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,12 @@
|
|||
|
||||
package org.jclouds.walrus;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import org.jclouds.s3.S3ClientLiveTest;
|
||||
import org.jclouds.s3.domain.S3Object;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -29,5 +34,23 @@ import org.testng.annotations.Test;
|
|||
*/
|
||||
@Test(groups = "live", sequential = true, testName = "WalrusClientLiveTest")
|
||||
public class WalrusClientLiveTest extends S3ClientLiveTest {
|
||||
// path based, not virtual host
|
||||
@Override
|
||||
protected URL getObjectURL(String containerName, String key) throws Exception {
|
||||
URL url = new URL(String.format(context.getProviderSpecificContext().getEndpoint().toASCIIString()
|
||||
+ "/services/Walrus/%s/%s", containerName, key));
|
||||
return url;
|
||||
}
|
||||
|
||||
// no support for content encoding
|
||||
@Override
|
||||
protected void assertContentEncoding(S3Object newObject, String string) {
|
||||
assertEquals(newObject.getMetadata().getContentMetadata().getContentEncoding(), null);
|
||||
}
|
||||
|
||||
// no support for cache control
|
||||
@Override
|
||||
protected void assertCacheControl(S3Object newObject, String string) {
|
||||
assertEquals(newObject.getMetadata().getCacheControl(), null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,8 @@ public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends Bas
|
|||
return !(input.version.equals("") && input.is64Bit)
|
||||
&& !(input.version.equals("5.3") && input.is64Bit);
|
||||
case WINDOWS:
|
||||
return !(input.version.equals("") && input.is64Bit);
|
||||
return !(input.version.equals("") && input.is64Bit)
|
||||
&& !(input.version.equals("2008") && input.is64Bit);
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.googlestorage;
|
||||
|
||||
import static org.jclouds.blobstore.attr.BlobScopes.CONTAINER;
|
||||
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
|
||||
import org.jclouds.blobstore.attr.BlobScope;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.Headers;
|
||||
import org.jclouds.rest.annotations.ParamValidators;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.SkipEncoding;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.s3.Bucket;
|
||||
import org.jclouds.s3.S3AsyncClient;
|
||||
import org.jclouds.s3.S3Client;
|
||||
import org.jclouds.s3.binders.BindAsHostPrefixIfConfigured;
|
||||
import org.jclouds.s3.domain.ObjectMetadata;
|
||||
import org.jclouds.s3.filters.RequestAuthorizeSignature;
|
||||
import org.jclouds.s3.options.CopyObjectOptions;
|
||||
import org.jclouds.s3.predicates.validators.BucketNameValidator;
|
||||
import org.jclouds.s3.xml.CopyObjectHandler;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@SkipEncoding('/')
|
||||
@RequestFilters(RequestAuthorizeSignature.class)
|
||||
@BlobScope(CONTAINER)
|
||||
public interface GoogleStorageAsyncClient extends S3AsyncClient {
|
||||
/**
|
||||
* @see S3Client#copyObject
|
||||
*/
|
||||
@Override
|
||||
@PUT
|
||||
@Path("/{destinationObject}")
|
||||
@Headers(keys = "x-goog-copy-source", values = "/{sourceBucket}/{sourceObject}")
|
||||
@XMLResponseParser(CopyObjectHandler.class)
|
||||
ListenableFuture<ObjectMetadata> copyObject(
|
||||
@PathParam("sourceBucket") String sourceBucket,
|
||||
@PathParam("sourceObject") String sourceObject,
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String destinationBucket,
|
||||
@PathParam("destinationObject") String destinationObject, CopyObjectOptions... options);
|
||||
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
package org.jclouds.googlestorage.config;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.googlestorage.GoogleStorageAsyncClient;
|
||||
import org.jclouds.googlestorage.binders.BindGoogleStorageObjectMetadataToRequest;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
@ -8,16 +11,18 @@ import org.jclouds.s3.S3Client;
|
|||
import org.jclouds.s3.binders.BindS3ObjectMetadataToRequest;
|
||||
import org.jclouds.s3.config.S3RestClientModule;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
@RequiresHttp
|
||||
public class GoogleStorageRestClientModule extends S3RestClientModule<S3Client, S3AsyncClient> {
|
||||
public class GoogleStorageRestClientModule extends S3RestClientModule<S3Client, GoogleStorageAsyncClient> {
|
||||
|
||||
public GoogleStorageRestClientModule() {
|
||||
super(S3Client.class, S3AsyncClient.class);
|
||||
super(S3Client.class, GoogleStorageAsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,4 +31,10 @@ public class GoogleStorageRestClientModule extends S3RestClientModule<S3Client,
|
|||
super.configure();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
S3AsyncClient provideS3AsyncClient(GoogleStorageAsyncClient in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue