Issue 69: updated to new Redirect and ErrorHandler api

git-svn-id: http://jclouds.googlecode.com/svn/trunk@1461 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-06-24 18:32:51 +00:00
parent 256ec34af6
commit 502b9e1bac
4 changed files with 21 additions and 4 deletions

View File

@ -23,6 +23,8 @@
*/
package org.jclouds.aws.s3.config;
import java.net.MalformedURLException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
@ -36,6 +38,8 @@ import org.jclouds.http.HttpConstants;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.HttpRequestFilter;
import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
import org.jclouds.logging.Logger;
@ -77,7 +81,10 @@ public class LiveS3ConnectionModule extends AbstractModule {
}
protected void bindErrorHandler() {
bind(HttpErrorHandler.class).to(ParseAWSErrorFromXmlContent.class).in(Scopes.SINGLETON);
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(
ParseAWSErrorFromXmlContent.class).in(Scopes.SINGLETON);
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(
ParseAWSErrorFromXmlContent.class).in(Scopes.SINGLETON);
}
@Provides
@ -88,4 +95,15 @@ public class LiveS3ConnectionModule extends AbstractModule {
return filters;
}
@Singleton
@Provides
protected URI provideAddress(@Named(HttpConstants.PROPERTY_HTTP_ADDRESS) String address,
@Named(HttpConstants.PROPERTY_HTTP_PORT) int port,
@Named(HttpConstants.PROPERTY_HTTP_SECURE) boolean isSecure)
throws MalformedURLException {
return URI.create(String.format("%1$s://%2$s:%3$s", isSecure ? "https" : "http", address,
port));
}
}

View File

@ -51,7 +51,6 @@ public class S3ContextModule extends AbstractModule {
FactoryProvider.newFactory(GuiceS3Context.S3InputStreamMapFactory.class,
LiveS3InputStreamMap.class));
bind(S3Context.class).to(GuiceS3Context.class);
}
}

View File

@ -58,7 +58,7 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler {
this.parserFactory = parserFactory;
}
public void handle(HttpFutureCommand<?> command, HttpResponse response) {
public void handleError(HttpFutureCommand<?> command, HttpResponse response) {
AWSError error = new AWSError();
error.setRequestId(response.getFirstHeaderOrNull(S3Headers.REQUEST_ID));
error.setRequestToken(response

View File

@ -60,7 +60,7 @@ public class ParseSunCloudS3ErrorFromXmlContent implements HttpErrorHandler {
this.parserFactory = parserFactory;
}
public void handle(HttpFutureCommand<?> command, HttpResponse response) {
public void handleError(HttpFutureCommand<?> command, HttpResponse response) {
SunCloudS3Error error = new SunCloudS3Error();
error.setRequestId(response.getFirstHeaderOrNull(S3Headers.REQUEST_ID));
error.setRequestToken(response.getFirstHeaderOrNull(S3Headers.REQUEST_TOKEN));