mirror of https://github.com/apache/jclouds.git
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:
parent
256ec34af6
commit
502b9e1bac
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
|
@ -51,7 +51,6 @@ public class S3ContextModule extends AbstractModule {
|
|||
FactoryProvider.newFactory(GuiceS3Context.S3InputStreamMapFactory.class,
|
||||
LiveS3InputStreamMap.class));
|
||||
bind(S3Context.class).to(GuiceS3Context.class);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue