mirror of https://github.com/apache/jclouds.git
Issue 9
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1416 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
d806a056ff
commit
818489e9a3
|
@ -28,7 +28,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jclouds.aws.AWSResponseException;
|
||||
import org.jclouds.http.HttpResponseException;
|
||||
import org.jclouds.http.commands.callables.ReturnTrueIf2xx;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.util.concurrent.TimeoutException;
|
|||
|
||||
import org.jclouds.aws.AWSResponseException;
|
||||
import org.jclouds.aws.s3.domain.AccessControlList;
|
||||
import org.jclouds.http.HttpResponseException;
|
||||
import org.jclouds.http.commands.callables.xml.ParseSax;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
|
|
@ -72,6 +72,12 @@ public class ListBucket extends S3FutureCommand<S3Bucket> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code bucketParser} is only enacted when the http status code is 2xx. Amazon treats
|
||||
* NoSuchBucket as an exception, while we regard this as a valid response. Accordingly, we check
|
||||
* for this {@code NoSuchBucket} message and return {@code S3Bucket#NOT_FOUND} if present.
|
||||
*
|
||||
*/
|
||||
@VisibleForTesting
|
||||
S3Bucket attemptNotFound(ExecutionException e) throws ExecutionException {
|
||||
if (e.getCause() != null && e.getCause() instanceof AWSResponseException) {
|
||||
|
|
|
@ -32,17 +32,16 @@ import org.jclouds.command.FutureCommand;
|
|||
import org.jclouds.logging.Logger;
|
||||
|
||||
/**
|
||||
* // TODO: Adrian: Document this!
|
||||
* HttpFutureCommand associates a request with a {@link ResponseCallable response parser} which
|
||||
* extracts the result object specified as generic type <code>T</code> from the HttpResponse.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class HttpFutureCommand<T> extends
|
||||
FutureCommand<HttpRequest, HttpResponse, T> {
|
||||
public class HttpFutureCommand<T> extends FutureCommand<HttpRequest, HttpResponse, T> {
|
||||
|
||||
public HttpFutureCommand(String method, String uri,
|
||||
ResponseCallable<T> responseCallable) {
|
||||
super(new HttpRequest(checkNotNull(method, "method"), checkNotNull(uri,
|
||||
"uri")), responseCallable);
|
||||
public HttpFutureCommand(String method, String uri, ResponseCallable<T> responseCallable) {
|
||||
super(new HttpRequest(checkNotNull(method, "method"), checkNotNull(uri, "uri")),
|
||||
responseCallable);
|
||||
}
|
||||
|
||||
protected void addHostHeader(String host) {
|
||||
|
@ -51,15 +50,10 @@ public class HttpFutureCommand<T> extends
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getClass().getName() + "{" + "request=" + this.getRequest()
|
||||
+ "," + "responseFuture=" + this.getResponseFuture() + '}';
|
||||
return this.getClass().getName() + "{" + "request=" + this.getRequest() + ","
|
||||
+ "responseFuture=" + this.getResponseFuture() + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* // TODO: Adrian: Document this!
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public abstract static class ResponseCallable<T> implements
|
||||
FutureCommand.ResponseCallable<HttpResponse, T> {
|
||||
@Resource
|
||||
|
@ -67,9 +61,9 @@ public class HttpFutureCommand<T> extends
|
|||
|
||||
public void checkCode() {
|
||||
int code = getResponse().getStatusCode();
|
||||
if (code >= 300){
|
||||
if (code >= 300) {
|
||||
IOUtils.closeQuietly(getResponse().getContent());
|
||||
throw new IllegalStateException("incorrect code for this operation: "+getResponse());
|
||||
throw new IllegalStateException("incorrect code for this operation: " + getResponse());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue