mirror of https://github.com/apache/jclouds.git
cleaning cruft
git-svn-id: http://jclouds.googlecode.com/svn/trunk@418 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
9287a2a6c1
commit
186504b7e8
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@ -23,9 +23,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.http;
|
package org.jclouds.http;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
@ -39,7 +40,6 @@ import java.util.List;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.jclouds.Utils;
|
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
@ -53,7 +53,7 @@ public class JavaUrlHttpFutureCommandClient implements HttpFutureCommandClient {
|
||||||
private URL target;
|
private URL target;
|
||||||
private List<HttpRequestFilter> requestFilters = Collections.emptyList();
|
private List<HttpRequestFilter> requestFilters = Collections.emptyList();
|
||||||
@Resource
|
@Resource
|
||||||
private Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
public List<HttpRequestFilter> getRequestFilters() {
|
public List<HttpRequestFilter> getRequestFilters() {
|
||||||
return requestFilters;
|
return requestFilters;
|
||||||
|
@ -71,7 +71,7 @@ public class JavaUrlHttpFutureCommandClient implements HttpFutureCommandClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void submit(HttpFutureCommand<?> command) {
|
public void submit(HttpFutureCommand<?> command) {
|
||||||
HttpRequest request = (HttpRequest) command.getRequest();
|
HttpRequest request = command.getRequest();
|
||||||
HttpURLConnection connection = null;
|
HttpURLConnection connection = null;
|
||||||
try {
|
try {
|
||||||
for (HttpRequestFilter filter : getRequestFilters()) {
|
for (HttpRequestFilter filter : getRequestFilters()) {
|
||||||
|
@ -79,56 +79,23 @@ public class JavaUrlHttpFutureCommandClient implements HttpFutureCommandClient {
|
||||||
}
|
}
|
||||||
HttpResponse response = null;
|
HttpResponse response = null;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
try {
|
logger.trace("%1s - converting request %2s", target, request);
|
||||||
logger.trace("%1s - converting request %2s", target,
|
|
||||||
request);
|
|
||||||
connection = openJavaConnection(request);
|
connection = openJavaConnection(request);
|
||||||
logger.trace("%1s - submitting request %2s", target,
|
logger
|
||||||
|
.trace("%1s - submitting request %2s", target,
|
||||||
connection);
|
connection);
|
||||||
response = getResponse(connection);
|
response = getResponse(connection);
|
||||||
logger.trace("%1s - received response %2s", target,
|
logger.trace("%1s - received response %2s", target, response);
|
||||||
response);
|
if (command.getRequest().isReplayable()
|
||||||
if (request.isReplayable()
|
|
||||||
&& response.getStatusCode() >= 500) {
|
&& response.getStatusCode() >= 500) {
|
||||||
logger.info("resubmitting command: %1s", command);
|
logger.info("resubmitting command: %1s", command);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
command.getResponseFuture().setResponse(response);
|
|
||||||
command.getResponseFuture().run();
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
HttpResponse response = new HttpResponse();
|
|
||||||
response.setStatusCode(404);
|
|
||||||
command.getResponseFuture().setResponse(response);
|
command.getResponseFuture().setResponse(response);
|
||||||
command.getResponseFuture().run();
|
command.getResponseFuture().run();
|
||||||
} catch (Exception e) {
|
} 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);
|
command.setException(e);
|
||||||
} finally {
|
} finally {
|
||||||
// DO NOT disconnect, as it will also close the unconsumed
|
// 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 {
|
throws IOException {
|
||||||
HttpResponse response = new HttpResponse();
|
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());
|
response.setStatusCode(connection.getResponseCode());
|
||||||
for (String header : connection.getHeaderFields().keySet()) {
|
for (String header : connection.getHeaderFields().keySet()) {
|
||||||
response.getHeaders().putAll(header,
|
response.getHeaders().putAll(header,
|
||||||
|
@ -148,15 +126,10 @@ public class JavaUrlHttpFutureCommandClient implements HttpFutureCommandClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
response.setMessage(connection.getResponseMessage());
|
response.setMessage(connection.getResponseMessage());
|
||||||
if (!connection.getRequestMethod().equals("HEAD")) {
|
|
||||||
response.setContent(connection.getInputStream());
|
|
||||||
response.setContentType(connection
|
|
||||||
.getHeaderField(HttpConstants.CONTENT_TYPE));
|
|
||||||
}
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpURLConnection openJavaConnection(HttpRequest request)
|
protected HttpURLConnection openJavaConnection(HttpRequest request)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
URL url = new URL(target, request.getUri());
|
URL url = new URL(target, request.getUri());
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
@ -169,8 +142,9 @@ public class JavaUrlHttpFutureCommandClient implements HttpFutureCommandClient {
|
||||||
connection.setRequestProperty(header, value);
|
connection.setRequestProperty(header, value);
|
||||||
}
|
}
|
||||||
if (request.getContent() != null) {
|
if (request.getContent() != null) {
|
||||||
connection.setRequestProperty(HttpConstants.CONTENT_TYPE, request
|
connection.setRequestProperty(HttpConstants.CONTENT_TYPE,
|
||||||
.getContentType());
|
checkNotNull(request.getContentType(),
|
||||||
|
"request.getContentType()"));
|
||||||
OutputStream out = connection.getOutputStream();
|
OutputStream out = connection.getOutputStream();
|
||||||
try {
|
try {
|
||||||
if (request.getContent() instanceof String) {
|
if (request.getContent() instanceof String) {
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@ -45,6 +45,10 @@ public class JavaUrlHttpFutureCommandClientModule extends AbstractModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
bindClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void bindClient() {
|
||||||
// note this is not threadsafe, so it cannot be singleton
|
// note this is not threadsafe, so it cannot be singleton
|
||||||
bind(HttpFutureCommandClient.class).to(
|
bind(HttpFutureCommandClient.class).to(
|
||||||
JavaUrlHttpFutureCommandClient.class);
|
JavaUrlHttpFutureCommandClient.class);
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@ -110,14 +110,13 @@ public class JCloudsS3Service extends S3Service {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @see S3Connection#deleteBucket(org.jclouds.aws.s3.domain.S3Bucket)
|
* @see S3Connection#deleteBucketIfNotEmpty(org.jclouds.aws.s3.domain.S3Bucket)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void deleteBucketImpl(String bucketName)
|
protected void deleteBucketImpl(String bucketName)
|
||||||
throws S3ServiceException {
|
throws S3ServiceException {
|
||||||
try {
|
try {
|
||||||
connection.deleteBucket(
|
connection.deleteBucketIfNotEmpty(bucketName).get(
|
||||||
new org.jclouds.aws.s3.domain.S3Bucket(bucketName)).get(
|
|
||||||
requestTimeoutMilliseconds, TimeUnit.MILLISECONDS);
|
requestTimeoutMilliseconds, TimeUnit.MILLISECONDS);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Utils.<S3ServiceException> rethrowIfRuntimeOrSameType(e);
|
Utils.<S3ServiceException> rethrowIfRuntimeOrSameType(e);
|
||||||
|
@ -136,10 +135,8 @@ public class JCloudsS3Service extends S3Service {
|
||||||
protected void deleteObjectImpl(String bucketName, String objectKey)
|
protected void deleteObjectImpl(String bucketName, String objectKey)
|
||||||
throws S3ServiceException {
|
throws S3ServiceException {
|
||||||
try {
|
try {
|
||||||
connection.deleteObject(
|
connection.deleteObject(bucketName, objectKey).get(
|
||||||
new org.jclouds.aws.s3.domain.S3Bucket(bucketName),
|
requestTimeoutMilliseconds, TimeUnit.MILLISECONDS);
|
||||||
objectKey).get(requestTimeoutMilliseconds,
|
|
||||||
TimeUnit.MILLISECONDS);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Utils.<S3ServiceException> rethrowIfRuntimeOrSameType(e);
|
Utils.<S3ServiceException> rethrowIfRuntimeOrSameType(e);
|
||||||
throw new S3ServiceException(String.format(
|
throw new S3ServiceException(String.format(
|
||||||
|
@ -210,17 +207,17 @@ public class JCloudsS3Service extends S3Service {
|
||||||
@Override
|
@Override
|
||||||
protected S3Bucket[] listAllBucketsImpl() throws S3ServiceException {
|
protected S3Bucket[] listAllBucketsImpl() throws S3ServiceException {
|
||||||
try {
|
try {
|
||||||
List<org.jclouds.aws.s3.domain.S3Bucket> jcBucketList = connection
|
List<org.jclouds.aws.s3.domain.S3Bucket.MetaData> jcBucketList = connection
|
||||||
.getBuckets().get(requestTimeoutMilliseconds,
|
.getMetaDataOfOwnedBuckets().get(
|
||||||
TimeUnit.MILLISECONDS);
|
requestTimeoutMilliseconds, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
ArrayList<org.jets3t.service.model.S3Bucket> jsBucketList = new ArrayList<org.jets3t.service.model.S3Bucket>();
|
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(
|
org.jets3t.service.model.S3Bucket jsBucket = new org.jets3t.service.model.S3Bucket(
|
||||||
jcBucket.getName());
|
jcBucket.getName());
|
||||||
jsBucket.setOwner(new org.jets3t.service.model.S3Owner(jcBucket
|
jsBucket.setOwner(new org.jets3t.service.model.S3Owner(jcBucket
|
||||||
.getMetaData().getCanonicalUser().getId(), jcBucket
|
.getCanonicalUser().getId(), jcBucket
|
||||||
.getMetaData().getCanonicalUser().getDisplayName()));
|
.getCanonicalUser().getDisplayName()));
|
||||||
jsBucketList.add(jsBucket);
|
jsBucketList.add(jsBucket);
|
||||||
}
|
}
|
||||||
return (org.jets3t.service.model.S3Bucket[]) jsBucketList
|
return (org.jets3t.service.model.S3Bucket[]) jsBucketList
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@ -101,19 +101,13 @@ public class JCloudsS3ServiceTest extends S3IntegrationTest {
|
||||||
public void testDeleteBucketImplString() throws S3ServiceException,
|
public void testDeleteBucketImplString() throws S3ServiceException,
|
||||||
InterruptedException, ExecutionException, TimeoutException {
|
InterruptedException, ExecutionException, TimeoutException {
|
||||||
String bucketName = bucketPrefix + ".testDeleteBucketImplString";
|
String bucketName = bucketPrefix + ".testDeleteBucketImplString";
|
||||||
org.jclouds.aws.s3.domain.S3Bucket jcloudsBucket = createBucket(bucketName);
|
service.deleteBucket(bucketName);
|
||||||
|
assert !client.bucketExists(bucketName).get(10, TimeUnit.SECONDS);
|
||||||
service.deleteBucket(new S3Bucket(bucketName));
|
|
||||||
|
|
||||||
assert !client.bucketExists(jcloudsBucket).get(10, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private org.jclouds.aws.s3.domain.S3Bucket createBucket(String bucketName)
|
private void createBucket(String bucketName) throws InterruptedException,
|
||||||
throws InterruptedException, ExecutionException, TimeoutException {
|
ExecutionException, TimeoutException {
|
||||||
org.jclouds.aws.s3.domain.S3Bucket jcloudsBucket = new org.jclouds.aws.s3.domain.S3Bucket(
|
client.createBucketIfNotExists(bucketName).get(10, TimeUnit.SECONDS);
|
||||||
bucketName);
|
|
||||||
client.createBucketIfNotExists(jcloudsBucket).get(10, TimeUnit.SECONDS);
|
|
||||||
return jcloudsBucket;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -123,25 +117,21 @@ public class JCloudsS3ServiceTest extends S3IntegrationTest {
|
||||||
String objectKey = "key";
|
String objectKey = "key";
|
||||||
String objectValue = "test";
|
String objectValue = "test";
|
||||||
|
|
||||||
org.jclouds.aws.s3.domain.S3Bucket jcloudsBucket = addNewObject(
|
addNewObject(bucketName, objectKey, objectValue);
|
||||||
bucketName, objectKey, objectValue);
|
|
||||||
|
|
||||||
service.deleteObject(bucketName, objectKey);
|
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);
|
TimeUnit.SECONDS), org.jclouds.aws.s3.domain.S3Object.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
private org.jclouds.aws.s3.domain.S3Bucket addNewObject(String name,
|
private void addNewObject(String name, String objectKey, String objectValue)
|
||||||
String objectKey, String objectValue) throws InterruptedException,
|
throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
ExecutionException, TimeoutException {
|
createBucket(name);
|
||||||
org.jclouds.aws.s3.domain.S3Bucket jcloudsBucket = createBucket(name);
|
|
||||||
org.jclouds.aws.s3.domain.S3Object jcloudsObject = new org.jclouds.aws.s3.domain.S3Object(
|
org.jclouds.aws.s3.domain.S3Object jcloudsObject = new org.jclouds.aws.s3.domain.S3Object(
|
||||||
objectKey);
|
objectKey);
|
||||||
jcloudsObject.setData(objectValue);
|
jcloudsObject.setData(objectValue);
|
||||||
client.addObject(jcloudsBucket, jcloudsObject)
|
client.addObject(name, jcloudsObject).get(10, TimeUnit.SECONDS);
|
||||||
.get(10, TimeUnit.SECONDS);
|
|
||||||
return jcloudsBucket;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -189,29 +179,30 @@ public class JCloudsS3ServiceTest extends S3IntegrationTest {
|
||||||
ExecutionException, TimeoutException, S3ServiceException {
|
ExecutionException, TimeoutException, S3ServiceException {
|
||||||
// Ensure there is at least 1 bucket in S3 account to list and compare.
|
// Ensure there is at least 1 bucket in S3 account to list and compare.
|
||||||
String bucketName = bucketPrefix + ".testListAllBucketsImplString";
|
String bucketName = bucketPrefix + ".testListAllBucketsImplString";
|
||||||
org.jclouds.aws.s3.domain.S3Bucket jcloudsBucket = createBucket(bucketName);
|
createBucket(bucketName);
|
||||||
|
|
||||||
S3Bucket[] jsBuckets = service.listAllBuckets();
|
S3Bucket[] jsBuckets = service.listAllBuckets();
|
||||||
|
|
||||||
List<org.jclouds.aws.s3.domain.S3Bucket> jcBuckets = client
|
List<org.jclouds.aws.s3.domain.S3Bucket.MetaData> jcBuckets = client
|
||||||
.getBuckets().get(10, TimeUnit.SECONDS);
|
.getMetaDataOfOwnedBuckets().get(10, TimeUnit.SECONDS);
|
||||||
|
|
||||||
assert jsBuckets.length == jcBuckets.size();
|
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();
|
.iterator();
|
||||||
for (S3Bucket jsBucket : jsBuckets) {
|
for (S3Bucket jsBucket : jsBuckets) {
|
||||||
assert jcBucketsIter.hasNext();
|
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.getName().equals(jcBucket.getName());
|
||||||
assert jsBucket.getOwner().getId().equals(
|
assert jsBucket.getOwner().getId().equals(
|
||||||
jcBucket.getMetaData().getCanonicalUser().getId());
|
jcBucket.getCanonicalUser().getId());
|
||||||
assert jsBucket.getOwner().getDisplayName().equals(
|
assert jsBucket.getOwner().getDisplayName().equals(
|
||||||
jcBucket.getMetaData().getCanonicalUser().getDisplayName());
|
jcBucket.getCanonicalUser().getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
client.deleteBucket(jcloudsBucket);
|
client.deleteBucketIfNotEmpty(bucketName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@ -27,8 +27,6 @@ import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.aws.s3.domain.S3Bucket;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* // TODO: Adrian: Document this!
|
* // TODO: Adrian: Document this!
|
||||||
*
|
*
|
||||||
|
@ -56,45 +54,41 @@ public abstract class BaseJCloudsPerformance extends BasePerformance {
|
||||||
@Override
|
@Override
|
||||||
protected boolean putByteArray(String bucket, String key, byte[] data,
|
protected boolean putByteArray(String bucket, String key, byte[] data,
|
||||||
String contentType) throws Exception {
|
String contentType) throws Exception {
|
||||||
S3Bucket s3Bucket = new S3Bucket(bucket);
|
|
||||||
org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
|
org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
|
||||||
key);
|
key);
|
||||||
object.getMetaData().setContentType(contentType);
|
object.getMetaData().setContentType(contentType);
|
||||||
object.setData(data);
|
object.setData(data);
|
||||||
return client.addObject(s3Bucket, object).get(120, TimeUnit.SECONDS) != null;
|
return client.addObject(bucket, object).get(120, TimeUnit.SECONDS) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean putFile(String bucket, String key, File data,
|
protected boolean putFile(String bucket, String key, File data,
|
||||||
String contentType) throws Exception {
|
String contentType) throws Exception {
|
||||||
S3Bucket s3Bucket = new S3Bucket(bucket);
|
|
||||||
org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
|
org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
|
||||||
key);
|
key);
|
||||||
object.getMetaData().setContentType(contentType);
|
object.getMetaData().setContentType(contentType);
|
||||||
object.setData(data);
|
object.setData(data);
|
||||||
return client.addObject(s3Bucket, object).get(120, TimeUnit.SECONDS) != null;
|
return client.addObject(bucket, object).get(120, TimeUnit.SECONDS) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean putInputStream(String bucket, String key,
|
protected boolean putInputStream(String bucket, String key,
|
||||||
InputStream data, String contentType) throws Exception {
|
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(
|
org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
|
||||||
key);
|
key);
|
||||||
object.getMetaData().setContentType(contentType);
|
object.getMetaData().setContentType(contentType);
|
||||||
object.setData(data);
|
object.setData(data);
|
||||||
object.getMetaData().setSize(data.available());
|
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
|
@Override
|
||||||
protected boolean putString(String bucket, String key, String data,
|
protected boolean putString(String bucket, String key, String data,
|
||||||
String contentType) throws Exception {
|
String contentType) throws Exception {
|
||||||
S3Bucket s3Bucket = new S3Bucket(bucket);
|
|
||||||
org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
|
org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
|
||||||
key);
|
key);
|
||||||
object.getMetaData().setContentType(contentType);
|
object.getMetaData().setContentType(contentType);
|
||||||
object.setData(data);
|
object.setData(data);
|
||||||
return client.addObject(s3Bucket, object).get(120, TimeUnit.SECONDS) != null;
|
return client.addObject(bucket, object).get(120, TimeUnit.SECONDS) != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* 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.S3Constants;
|
||||||
import org.jclouds.aws.s3.S3IntegrationTest;
|
import org.jclouds.aws.s3.S3IntegrationTest;
|
||||||
import org.jclouds.aws.s3.domain.S3Bucket;
|
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Optional;
|
import org.testng.annotations.Optional;
|
||||||
|
@ -91,8 +90,7 @@ public abstract class BasePerformance extends S3IntegrationTest {
|
||||||
@Optional String AWSSecretAccessKey) throws Exception {
|
@Optional String AWSSecretAccessKey) throws Exception {
|
||||||
super.setUpClient(AWSAccessKeyId, AWSSecretAccessKey);
|
super.setUpClient(AWSAccessKeyId, AWSSecretAccessKey);
|
||||||
for (String bucket : BUCKETS) {
|
for (String bucket : BUCKETS) {
|
||||||
client.createBucketIfNotExists(new S3Bucket(bucket)).get(10,
|
client.createBucketIfNotExists(bucket).get(10, TimeUnit.SECONDS);
|
||||||
TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* 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()
|
private ListAllMyBucketsResponse runAmazonParseListAllMyBuckets()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
ListAllMyBucketsResponse response = new ListAllMyBucketsResponse(
|
ListAllMyBucketsResponse response = new ListAllMyBucketsResponse(
|
||||||
new MockHttpURLConnection(listAllMyBucketsResult));
|
new MockHttpURLConnection(listAllMyBucketsResultOn200));
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* 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.List;
|
||||||
import java.util.concurrent.Future;
|
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.S3Bucket;
|
||||||
import org.jclouds.aws.s3.domain.S3Object;
|
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
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public interface S3Connection {
|
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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@ -23,7 +23,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3;
|
package org.jclouds.aws.s3;
|
||||||
|
|
||||||
import org.jclouds.aws.s3.domain.S3Bucket;
|
|
||||||
|
|
||||||
public interface S3Context {
|
public interface S3Context {
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ public interface S3Context {
|
||||||
* @param bucket
|
* @param bucket
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
S3InputStreamMap createInputStreamMap(S3Bucket bucket);
|
S3InputStreamMap createInputStreamMap(String bucket);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a <code>Map<String,S3Object></code> view of the specified bucket.
|
* Creates a <code>Map<String,S3Object></code> view of the specified bucket.
|
||||||
|
@ -47,7 +46,7 @@ public interface S3Context {
|
||||||
* @param bucket
|
* @param bucket
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
S3ObjectMap createS3ObjectMap(S3Bucket bucket);
|
S3ObjectMap createS3ObjectMap(String bucket);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes all connections to S3.
|
* Closes all connections to S3.
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@ -39,8 +39,8 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.aws.s3.config.S3ContextModule;
|
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.HttpFutureCommandClientModule;
|
||||||
import org.jclouds.http.config.JavaUrlHttpFutureCommandClientModule;
|
|
||||||
import org.jclouds.logging.config.LoggingModule;
|
import org.jclouds.logging.config.LoggingModule;
|
||||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
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
|
* Bind the given properties and install the list of modules. If no modules
|
||||||
* are specified, install the default {@link JDKLoggingModule}
|
* are specified, install the default {@link JDKLoggingModule}
|
||||||
* {@link JavaUrlHttpFutureCommandClientModule}
|
* {@link S3JavaUrlHttpFutureCommandClientModule}
|
||||||
*
|
*
|
||||||
* @param properties
|
* @param properties
|
||||||
* - contains constants used by jclouds
|
* - contains constants used by jclouds
|
||||||
|
@ -201,7 +201,7 @@ public class S3ContextFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
}))
|
}))
|
||||||
modules.add(new JavaUrlHttpFutureCommandClientModule());
|
modules.add(new S3JavaUrlHttpFutureCommandClientModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
|
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@ -23,7 +23,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3.commands;
|
package org.jclouds.aws.s3.commands;
|
||||||
|
|
||||||
import org.jclouds.aws.s3.domain.S3Bucket;
|
|
||||||
import org.jclouds.http.commands.callables.ReturnTrueIf200;
|
import org.jclouds.http.commands.callables.ReturnTrueIf200;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
@ -34,7 +33,7 @@ public class BucketExists extends S3FutureCommand<Boolean> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BucketExists(@Named("jclouds.http.address") String amazonHost,
|
public BucketExists(@Named("jclouds.http.address") String amazonHost,
|
||||||
ReturnTrueIf200 callable, @Assisted S3Bucket s3Bucket) {
|
ReturnTrueIf200 callable, @Assisted String s3Bucket) {
|
||||||
super("HEAD", "/", callable, amazonHost, s3Bucket);
|
super("HEAD", "/", callable, amazonHost, s3Bucket);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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
|
* 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 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.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.Inject;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
import com.google.inject.name.Named;
|
import com.google.inject.name.Named;
|
||||||
|
|
||||||
public class CopyObject extends S3FutureCommand<Boolean> {
|
public class CopyObject extends S3FutureCommand<S3Object.MetaData> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CopyObject(@Named("jclouds.http.address") String amazonHost,
|
public CopyObject(@Named("jclouds.http.address") String amazonHost,
|
||||||
CopyObjectCallable callable,
|
ParseSax<S3Object.MetaData> callable,
|
||||||
@Assisted("sourceBucket") S3Bucket sourceBucket,
|
@Assisted("sourceBucket") String sourceBucket,
|
||||||
@Assisted("sourceObject") S3Object sourceObject,
|
@Assisted("sourceObject") String sourceObject,
|
||||||
@Assisted("destinationBucket") S3Bucket destinationBucket,
|
@Assisted("destinationBucket") String destinationBucket,
|
||||||
@Assisted("destinationObject") S3Object destinationObject) {
|
@Assisted("destinationObject") String destinationObject) {
|
||||||
super("PUT", "/" + checkNotNull(destinationObject.getKey(),"destinationObject.getKey()"), callable,
|
super("PUT",
|
||||||
amazonHost, destinationBucket);
|
"/" + checkNotNull(destinationObject, "destinationObject"),
|
||||||
|
callable, amazonHost, destinationBucket);
|
||||||
|
CopyObjectHandler handler = (CopyObjectHandler) callable.getHandler();
|
||||||
|
handler.setKey(destinationObject);
|
||||||
getRequest().getHeaders().put(
|
getRequest().getHeaders().put(
|
||||||
"x-amz-copy-source",
|
"x-amz-copy-source",
|
||||||
String.format("/%1s/%2s", checkNotNull(sourceBucket.getName(),
|
String.format("/%1s/%2s", checkNotNull(sourceBucket,
|
||||||
"sourceBucket.getName()"), checkNotNull(sourceObject
|
"sourceBucket").toLowerCase(), checkNotNull(
|
||||||
.getKey(), "sourceObject.getKey()")));
|
sourceObject, "sourceObject")));
|
||||||
}
|
}
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue