cleaning cruft

git-svn-id: http://jclouds.googlecode.com/svn/trunk@418 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-05-06 22:09:35 +00:00
parent 9287a2a6c1
commit 186504b7e8
165 changed files with 1987 additions and 908 deletions

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@ -23,9 +23,10 @@
*/
package org.jclouds.http;
import static com.google.common.base.Preconditions.checkNotNull;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -39,7 +40,6 @@ import java.util.List;
import javax.annotation.Resource;
import org.apache.commons.io.IOUtils;
import org.jclouds.Utils;
import org.jclouds.logging.Logger;
import com.google.inject.Inject;
@ -53,7 +53,7 @@ public class JavaUrlHttpFutureCommandClient implements HttpFutureCommandClient {
private URL target;
private List<HttpRequestFilter> requestFilters = Collections.emptyList();
@Resource
private Logger logger = Logger.NULL;
protected Logger logger = Logger.NULL;
public List<HttpRequestFilter> getRequestFilters() {
return requestFilters;
@ -71,7 +71,7 @@ public class JavaUrlHttpFutureCommandClient implements HttpFutureCommandClient {
}
public void submit(HttpFutureCommand<?> command) {
HttpRequest request = (HttpRequest) command.getRequest();
HttpRequest request = command.getRequest();
HttpURLConnection connection = null;
try {
for (HttpRequestFilter filter : getRequestFilters()) {
@ -79,56 +79,23 @@ public class JavaUrlHttpFutureCommandClient implements HttpFutureCommandClient {
}
HttpResponse response = null;
for (;;) {
try {
logger.trace("%1s - converting request %2s", target,
request);
connection = openJavaConnection(request);
logger.trace("%1s - submitting request %2s", target,
connection);
response = getResponse(connection);
logger.trace("%1s - received response %2s", target,
response);
if (request.isReplayable()
&& response.getStatusCode() >= 500) {
logger.info("resubmitting command: %1s", command);
continue;
}
break;
} catch (IOException e) {
if (request.isReplayable()
&& e.getMessage().indexOf(
"Server returned HTTP response code: 5") >= 0) {
logger.info("resubmitting command: %1s", command);
continue;
}
throw e;
logger.trace("%1s - converting request %2s", target, request);
connection = openJavaConnection(request);
logger
.trace("%1s - submitting request %2s", target,
connection);
response = getResponse(connection);
logger.trace("%1s - received response %2s", target, response);
if (command.getRequest().isReplayable()
&& response.getStatusCode() >= 500) {
logger.info("resubmitting command: %1s", command);
continue;
}
break;
}
command.getResponseFuture().setResponse(response);
command.getResponseFuture().run();
} catch (FileNotFoundException e) {
HttpResponse response = new HttpResponse();
response.setStatusCode(404);
command.getResponseFuture().setResponse(response);
command.getResponseFuture().run();
} catch (Exception e) {
if (connection != null) {
StringBuilder errors = new StringBuilder();
try {
for (InputStream in : new InputStream[] {
connection.getErrorStream(),
connection.getInputStream() }) {
if (in != null) {
errors.append(Utils.toStringAndClose(in)).append(
"\n");
}
}
logger.error(e,
"error encountered during the exception: %1s",
errors.toString());
} catch (IOException e2) {
}
}
command.setException(e);
} finally {
// DO NOT disconnect, as it will also close the unconsumed
@ -138,9 +105,20 @@ public class JavaUrlHttpFutureCommandClient implements HttpFutureCommandClient {
}
}
private HttpResponse getResponse(HttpURLConnection connection)
protected HttpResponse getResponse(HttpURLConnection connection)
throws IOException {
HttpResponse response = new HttpResponse();
InputStream in;
try {
in = connection.getInputStream();
} catch (IOException e) {
in = connection.getErrorStream();
}
if (in != null) {
response.setContent(in);
response.setContentType(connection
.getHeaderField(HttpConstants.CONTENT_TYPE));
}
response.setStatusCode(connection.getResponseCode());
for (String header : connection.getHeaderFields().keySet()) {
response.getHeaders().putAll(header,
@ -148,15 +126,10 @@ public class JavaUrlHttpFutureCommandClient implements HttpFutureCommandClient {
}
response.setMessage(connection.getResponseMessage());
if (!connection.getRequestMethod().equals("HEAD")) {
response.setContent(connection.getInputStream());
response.setContentType(connection
.getHeaderField(HttpConstants.CONTENT_TYPE));
}
return response;
}
private HttpURLConnection openJavaConnection(HttpRequest request)
protected HttpURLConnection openJavaConnection(HttpRequest request)
throws IOException {
URL url = new URL(target, request.getUri());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
@ -169,8 +142,9 @@ public class JavaUrlHttpFutureCommandClient implements HttpFutureCommandClient {
connection.setRequestProperty(header, value);
}
if (request.getContent() != null) {
connection.setRequestProperty(HttpConstants.CONTENT_TYPE, request
.getContentType());
connection.setRequestProperty(HttpConstants.CONTENT_TYPE,
checkNotNull(request.getContentType(),
"request.getContentType()"));
OutputStream out = connection.getOutputStream();
try {
if (request.getContent() instanceof String) {

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@ -45,6 +45,10 @@ public class JavaUrlHttpFutureCommandClientModule extends AbstractModule {
@Override
protected void configure() {
bindClient();
}
protected void bindClient() {
// note this is not threadsafe, so it cannot be singleton
bind(HttpFutureCommandClient.class).to(
JavaUrlHttpFutureCommandClient.class);

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@ -110,14 +110,13 @@ public class JCloudsS3Service extends S3Service {
/**
* {@inheritDoc}
*
* @see S3Connection#deleteBucket(org.jclouds.aws.s3.domain.S3Bucket)
* @see S3Connection#deleteBucketIfNotEmpty(org.jclouds.aws.s3.domain.S3Bucket)
*/
@Override
protected void deleteBucketImpl(String bucketName)
throws S3ServiceException {
try {
connection.deleteBucket(
new org.jclouds.aws.s3.domain.S3Bucket(bucketName)).get(
connection.deleteBucketIfNotEmpty(bucketName).get(
requestTimeoutMilliseconds, TimeUnit.MILLISECONDS);
} catch (Exception e) {
Utils.<S3ServiceException> rethrowIfRuntimeOrSameType(e);
@ -136,10 +135,8 @@ public class JCloudsS3Service extends S3Service {
protected void deleteObjectImpl(String bucketName, String objectKey)
throws S3ServiceException {
try {
connection.deleteObject(
new org.jclouds.aws.s3.domain.S3Bucket(bucketName),
objectKey).get(requestTimeoutMilliseconds,
TimeUnit.MILLISECONDS);
connection.deleteObject(bucketName, objectKey).get(
requestTimeoutMilliseconds, TimeUnit.MILLISECONDS);
} catch (Exception e) {
Utils.<S3ServiceException> rethrowIfRuntimeOrSameType(e);
throw new S3ServiceException(String.format(
@ -210,17 +207,17 @@ public class JCloudsS3Service extends S3Service {
@Override
protected S3Bucket[] listAllBucketsImpl() throws S3ServiceException {
try {
List<org.jclouds.aws.s3.domain.S3Bucket> jcBucketList = connection
.getBuckets().get(requestTimeoutMilliseconds,
TimeUnit.MILLISECONDS);
List<org.jclouds.aws.s3.domain.S3Bucket.MetaData> jcBucketList = connection
.getMetaDataOfOwnedBuckets().get(
requestTimeoutMilliseconds, TimeUnit.MILLISECONDS);
ArrayList<org.jets3t.service.model.S3Bucket> jsBucketList = new ArrayList<org.jets3t.service.model.S3Bucket>();
for (org.jclouds.aws.s3.domain.S3Bucket jcBucket : jcBucketList) {
for (org.jclouds.aws.s3.domain.S3Bucket.MetaData jcBucket : jcBucketList) {
org.jets3t.service.model.S3Bucket jsBucket = new org.jets3t.service.model.S3Bucket(
jcBucket.getName());
jsBucket.setOwner(new org.jets3t.service.model.S3Owner(jcBucket
.getMetaData().getCanonicalUser().getId(), jcBucket
.getMetaData().getCanonicalUser().getDisplayName()));
.getCanonicalUser().getId(), jcBucket
.getCanonicalUser().getDisplayName()));
jsBucketList.add(jsBucket);
}
return (org.jets3t.service.model.S3Bucket[]) jsBucketList

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@ -101,19 +101,13 @@ public class JCloudsS3ServiceTest extends S3IntegrationTest {
public void testDeleteBucketImplString() throws S3ServiceException,
InterruptedException, ExecutionException, TimeoutException {
String bucketName = bucketPrefix + ".testDeleteBucketImplString";
org.jclouds.aws.s3.domain.S3Bucket jcloudsBucket = createBucket(bucketName);
service.deleteBucket(new S3Bucket(bucketName));
assert !client.bucketExists(jcloudsBucket).get(10, TimeUnit.SECONDS);
service.deleteBucket(bucketName);
assert !client.bucketExists(bucketName).get(10, TimeUnit.SECONDS);
}
private org.jclouds.aws.s3.domain.S3Bucket createBucket(String bucketName)
throws InterruptedException, ExecutionException, TimeoutException {
org.jclouds.aws.s3.domain.S3Bucket jcloudsBucket = new org.jclouds.aws.s3.domain.S3Bucket(
bucketName);
client.createBucketIfNotExists(jcloudsBucket).get(10, TimeUnit.SECONDS);
return jcloudsBucket;
private void createBucket(String bucketName) throws InterruptedException,
ExecutionException, TimeoutException {
client.createBucketIfNotExists(bucketName).get(10, TimeUnit.SECONDS);
}
@Test
@ -123,25 +117,21 @@ public class JCloudsS3ServiceTest extends S3IntegrationTest {
String objectKey = "key";
String objectValue = "test";
org.jclouds.aws.s3.domain.S3Bucket jcloudsBucket = addNewObject(
bucketName, objectKey, objectValue);
addNewObject(bucketName, objectKey, objectValue);
service.deleteObject(bucketName, objectKey);
assertEquals(client.getObjectMetaData(jcloudsBucket, objectKey).get(10,
assertEquals(client.getObjectMetaData(bucketName, objectKey).get(10,
TimeUnit.SECONDS), org.jclouds.aws.s3.domain.S3Object.NOT_FOUND);
}
private org.jclouds.aws.s3.domain.S3Bucket addNewObject(String name,
String objectKey, String objectValue) throws InterruptedException,
ExecutionException, TimeoutException {
org.jclouds.aws.s3.domain.S3Bucket jcloudsBucket = createBucket(name);
private void addNewObject(String name, String objectKey, String objectValue)
throws InterruptedException, ExecutionException, TimeoutException {
createBucket(name);
org.jclouds.aws.s3.domain.S3Object jcloudsObject = new org.jclouds.aws.s3.domain.S3Object(
objectKey);
jcloudsObject.setData(objectValue);
client.addObject(jcloudsBucket, jcloudsObject)
.get(10, TimeUnit.SECONDS);
return jcloudsBucket;
client.addObject(name, jcloudsObject).get(10, TimeUnit.SECONDS);
}
@Test
@ -189,29 +179,30 @@ public class JCloudsS3ServiceTest extends S3IntegrationTest {
ExecutionException, TimeoutException, S3ServiceException {
// Ensure there is at least 1 bucket in S3 account to list and compare.
String bucketName = bucketPrefix + ".testListAllBucketsImplString";
org.jclouds.aws.s3.domain.S3Bucket jcloudsBucket = createBucket(bucketName);
createBucket(bucketName);
S3Bucket[] jsBuckets = service.listAllBuckets();
List<org.jclouds.aws.s3.domain.S3Bucket> jcBuckets = client
.getBuckets().get(10, TimeUnit.SECONDS);
List<org.jclouds.aws.s3.domain.S3Bucket.MetaData> jcBuckets = client
.getMetaDataOfOwnedBuckets().get(10, TimeUnit.SECONDS);
assert jsBuckets.length == jcBuckets.size();
Iterator<org.jclouds.aws.s3.domain.S3Bucket> jcBucketsIter = jcBuckets
Iterator<org.jclouds.aws.s3.domain.S3Bucket.MetaData> jcBucketsIter = jcBuckets
.iterator();
for (S3Bucket jsBucket : jsBuckets) {
assert jcBucketsIter.hasNext();
org.jclouds.aws.s3.domain.S3Bucket jcBucket = jcBucketsIter.next();
org.jclouds.aws.s3.domain.S3Bucket.MetaData jcBucket = jcBucketsIter
.next();
assert jsBucket.getName().equals(jcBucket.getName());
assert jsBucket.getOwner().getId().equals(
jcBucket.getMetaData().getCanonicalUser().getId());
jcBucket.getCanonicalUser().getId());
assert jsBucket.getOwner().getDisplayName().equals(
jcBucket.getMetaData().getCanonicalUser().getDisplayName());
jcBucket.getCanonicalUser().getDisplayName());
}
client.deleteBucket(jcloudsBucket);
client.deleteBucketIfNotEmpty(bucketName);
}
@Test

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
====
Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
====================================================================
Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,5 +1,5 @@
Copyright (C) ${year} Adrian Cole <adriancole@jclouds.org>
Copyright (C) ${year} Adrian Cole <adrian@jclouds.org>
====================================================================
Licensed to the Apache Software Foundation (ASF) under one

View File

@ -2,7 +2,7 @@
<!--
Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
====================================================================
Licensed to the Apache Software Foundation (ASF) under one

View File

@ -2,7 +2,7 @@
<!--
Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
====================================================================
Licensed to the Apache Software Foundation (ASF) under one

View File

@ -2,7 +2,7 @@
<!--
Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
====================================================================
Licensed to the Apache Software Foundation (ASF) under one

View File

@ -2,7 +2,7 @@
<!--
Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
====================================================================
Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@ -27,8 +27,6 @@ import java.io.File;
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
import org.jclouds.aws.s3.domain.S3Bucket;
/**
* // TODO: Adrian: Document this!
*
@ -56,45 +54,41 @@ public abstract class BaseJCloudsPerformance extends BasePerformance {
@Override
protected boolean putByteArray(String bucket, String key, byte[] data,
String contentType) throws Exception {
S3Bucket s3Bucket = new S3Bucket(bucket);
org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
key);
object.getMetaData().setContentType(contentType);
object.setData(data);
return client.addObject(s3Bucket, object).get(120, TimeUnit.SECONDS) != null;
return client.addObject(bucket, object).get(120, TimeUnit.SECONDS) != null;
}
@Override
protected boolean putFile(String bucket, String key, File data,
String contentType) throws Exception {
S3Bucket s3Bucket = new S3Bucket(bucket);
org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
key);
object.getMetaData().setContentType(contentType);
object.setData(data);
return client.addObject(s3Bucket, object).get(120, TimeUnit.SECONDS) != null;
return client.addObject(bucket, object).get(120, TimeUnit.SECONDS) != null;
}
@Override
protected boolean putInputStream(String bucket, String key,
InputStream data, String contentType) throws Exception {
S3Bucket s3Bucket = new S3Bucket(bucket);
org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
key);
object.getMetaData().setContentType(contentType);
object.setData(data);
object.getMetaData().setSize(data.available());
return client.addObject(s3Bucket, object).get(120, TimeUnit.SECONDS) != null;
return client.addObject(bucket, object).get(120, TimeUnit.SECONDS) != null;
}
@Override
protected boolean putString(String bucket, String key, String data,
String contentType) throws Exception {
S3Bucket s3Bucket = new S3Bucket(bucket);
org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
key);
object.getMetaData().setContentType(contentType);
object.setData(data);
return client.addObject(s3Bucket, object).get(120, TimeUnit.SECONDS) != null;
return client.addObject(bucket, object).get(120, TimeUnit.SECONDS) != null;
}
}

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@ -38,7 +38,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.jclouds.aws.s3.S3Constants;
import org.jclouds.aws.s3.S3IntegrationTest;
import org.jclouds.aws.s3.domain.S3Bucket;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Optional;
@ -91,8 +90,7 @@ public abstract class BasePerformance extends S3IntegrationTest {
@Optional String AWSSecretAccessKey) throws Exception {
super.setUpClient(AWSAccessKeyId, AWSSecretAccessKey);
for (String bucket : BUCKETS) {
client.createBucketIfNotExists(new S3Bucket(bucket)).get(10,
TimeUnit.SECONDS);
client.createBucketIfNotExists(bucket).get(10, TimeUnit.SECONDS);
}
}

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@ -118,7 +118,7 @@ public class S3ParserTest extends org.jclouds.aws.s3.commands.S3ParserTest {
private ListAllMyBucketsResponse runAmazonParseListAllMyBuckets()
throws IOException {
ListAllMyBucketsResponse response = new ListAllMyBucketsResponse(
new MockHttpURLConnection(listAllMyBucketsResult));
new MockHttpURLConnection(listAllMyBucketsResultOn200));
return response;
}

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@ -26,33 +26,111 @@ package org.jclouds.aws.s3;
import java.util.List;
import java.util.concurrent.Future;
import org.jclouds.aws.s3.commands.options.CreateBucketOptions;
import org.jclouds.aws.s3.domain.S3Bucket;
import org.jclouds.aws.s3.domain.S3Object;
/**
* // TODO: Adrian: Document this!
* Provides access to S3 via their REST API.
*
* All commands return a Future of the result from S3. Any exceptions incurred
* during processing will be wrapped in an {@link ExecutionException} as
* documented in {@link Future#get()}.
*
* @author Adrian Cole
*/
public interface S3Connection {
Future<S3Object> getObject(S3Bucket s3Bucket, String key);
Future<S3Object.MetaData> getObjectMetaData(S3Bucket s3Bucket, String key);
/**
* Retrieves the object and metadata associated with the key.
*
* @param bucketName
* namespace of the object you are retrieving
*
* @param key
* unique key in the s3Bucket identifying the object
* @return fully populated S3Object containing data stored in S3
*/
Future<S3Object> getObject(String bucketName, String key);
Future<Boolean> deleteObject(S3Bucket s3Bucket, String key);
/**
* Retrieves the metadata of the object associated with the key.
*
* @param bucketName
* namespace of the metadata you are retrieving
*
* @param key
* unique key in the s3Bucket identifying the object
* @return metadata associated with the key
*/
Future<S3Object.MetaData> getObjectMetaData(String bucketName, String key);
Future<String> addObject(S3Bucket s3Bucket, S3Object object);
/**
* Removes the object and metadata associated with the key.
*
* @param bucketName
* namespace of the object you are deleting
* @param key
* unique key in the s3Bucket identifying the object
* @return true if deleted
*/
Future<Boolean> deleteObject(String bucketName, String key);
Future<Boolean> createBucketIfNotExists(S3Bucket s3Bucket);
/**
* Store data by creating or overwriting an object.
*
* @param bucketName
* namespace of the object you are storing
* @param object
* contains the data and metadata to create or overwrite
* @return ETAG which is a hex MD5 hash of the content uploaded
*/
Future<String> addObject(String bucketName, S3Object object);
Future<Boolean> deleteBucket(S3Bucket s3Bucket);
/**
* Create and name your own bucket in which to store your objects.
*
* @return true, if the bucket was created
*/
Future<Boolean> createBucketIfNotExists(String name);
Future<Boolean> copyObject(S3Bucket sourceBucket, S3Object sourceObject,
S3Bucket destinationBucket, S3Object destinationObject);
/**
* Create and name your own bucket in which to store your objects.
*
* @param options
* for creating your bucket
* @return true, if the bucket was created
* @see CreateBucketOptions
*/
Future<Boolean> createBucketIfNotExists(String name,
CreateBucketOptions options);
Future<Boolean> bucketExists(S3Bucket s3Bucket);
/**
* Deletes the bucket, if it is empty.
*
* @param s3Bucket
* what to delete
* @return false, if the bucket was not empty and therefore not deleted
*/
Future<Boolean> deleteBucketIfNotEmpty(String s3Bucket);
Future<S3Bucket> getBucket(S3Bucket s3Bucket);
/**
* Copies one object to another bucket
*
* @return metaData populated with lastModified and etag of the new object
*/
Future<S3Object.MetaData> copyObject(String sourceBucket,
String sourceObject, String destinationBucket,
String destinationObject);
Future<List<S3Bucket>> getBuckets();
Future<Boolean> bucketExists(String name);
/**
*
* @param s3Bucket
* @return
*/
Future<S3Bucket> getBucket(String name);
Future<List<S3Bucket.MetaData>> getMetaDataOfOwnedBuckets();
}

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@ -23,7 +23,6 @@
*/
package org.jclouds.aws.s3;
import org.jclouds.aws.s3.domain.S3Bucket;
public interface S3Context {
@ -39,7 +38,7 @@ public interface S3Context {
* @param bucket
* @return
*/
S3InputStreamMap createInputStreamMap(S3Bucket bucket);
S3InputStreamMap createInputStreamMap(String bucket);
/**
* Creates a <code>Map<String,S3Object></code> view of the specified bucket.
@ -47,7 +46,7 @@ public interface S3Context {
* @param bucket
* @return
*/
S3ObjectMap createS3ObjectMap(S3Bucket bucket);
S3ObjectMap createS3ObjectMap(String bucket);
/**
* Closes all connections to S3.

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@ -39,8 +39,8 @@ import java.util.List;
import java.util.Properties;
import org.jclouds.aws.s3.config.S3ContextModule;
import org.jclouds.aws.s3.config.S3JavaUrlHttpFutureCommandClientModule;
import org.jclouds.http.config.HttpFutureCommandClientModule;
import org.jclouds.http.config.JavaUrlHttpFutureCommandClientModule;
import org.jclouds.logging.config.LoggingModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
@ -165,7 +165,7 @@ public class S3ContextFactory {
/**
* Bind the given properties and install the list of modules. If no modules
* are specified, install the default {@link JDKLoggingModule}
* {@link JavaUrlHttpFutureCommandClientModule}
* {@link S3JavaUrlHttpFutureCommandClientModule}
*
* @param properties
* - contains constants used by jclouds
@ -201,7 +201,7 @@ public class S3ContextFactory {
}
}))
modules.add(new JavaUrlHttpFutureCommandClientModule());
modules.add(new S3JavaUrlHttpFutureCommandClientModule());
}
@VisibleForTesting

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -0,0 +1,57 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.aws.s3;
import org.jclouds.aws.s3.domain.S3Error;
import org.jclouds.http.HttpResponse;
public class S3ResponseException extends RuntimeException {
private static final long serialVersionUID = 1L;
private S3Error error;
private HttpResponse response;
public S3ResponseException(S3Error error, HttpResponse response) {
super(error.toString());
this.setError(error);
this.setResponse(response);
}
public void setError(S3Error error) {
this.error = error;
}
public S3Error getError() {
return error;
}
public void setResponse(HttpResponse response) {
this.response = response;
}
public HttpResponse getResponse() {
return response;
}
}

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@ -23,7 +23,6 @@
*/
package org.jclouds.aws.s3.commands;
import org.jclouds.aws.s3.domain.S3Bucket;
import org.jclouds.http.commands.callables.ReturnTrueIf200;
import com.google.inject.Inject;
@ -34,7 +33,7 @@ public class BucketExists extends S3FutureCommand<Boolean> {
@Inject
public BucketExists(@Named("jclouds.http.address") String amazonHost,
ReturnTrueIf200 callable, @Assisted S3Bucket s3Bucket) {
ReturnTrueIf200 callable, @Assisted String s3Bucket) {
super("HEAD", "/", callable, amazonHost, s3Bucket);
}
}

View File

@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2009 Adrian Cole <adriancole@jclouds.org>
* Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@ -25,29 +25,32 @@ package org.jclouds.aws.s3.commands;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.aws.s3.commands.callables.CopyObjectCallable;
import org.jclouds.aws.s3.domain.S3Bucket;
import org.jclouds.aws.s3.domain.S3Object;
import org.jclouds.aws.s3.xml.CopyObjectHandler;
import org.jclouds.http.commands.callables.xml.ParseSax;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.name.Named;
public class CopyObject extends S3FutureCommand<Boolean> {
public class CopyObject extends S3FutureCommand<S3Object.MetaData> {
@Inject
public CopyObject(@Named("jclouds.http.address") String amazonHost,
CopyObjectCallable callable,
@Assisted("sourceBucket") S3Bucket sourceBucket,
@Assisted("sourceObject") S3Object sourceObject,
@Assisted("destinationBucket") S3Bucket destinationBucket,
@Assisted("destinationObject") S3Object destinationObject) {
super("PUT", "/" + checkNotNull(destinationObject.getKey(),"destinationObject.getKey()"), callable,
amazonHost, destinationBucket);
ParseSax<S3Object.MetaData> callable,
@Assisted("sourceBucket") String sourceBucket,
@Assisted("sourceObject") String sourceObject,
@Assisted("destinationBucket") String destinationBucket,
@Assisted("destinationObject") String destinationObject) {
super("PUT",
"/" + checkNotNull(destinationObject, "destinationObject"),
callable, amazonHost, destinationBucket);
CopyObjectHandler handler = (CopyObjectHandler) callable.getHandler();
handler.setKey(destinationObject);
getRequest().getHeaders().put(
"x-amz-copy-source",
String.format("/%1s/%2s", checkNotNull(sourceBucket.getName(),
"sourceBucket.getName()"), checkNotNull(sourceObject
.getKey(), "sourceObject.getKey()")));
String.format("/%1s/%2s", checkNotNull(sourceBucket,
"sourceBucket").toLowerCase(), checkNotNull(
sourceObject, "sourceObject")));
}
}

Some files were not shown because too many files have changed in this diff Show More