";
- }
- }
-
- /**
- * Report the location-constraint for a bucket.
- * A value of null indicates an error;
- * the empty string indicates no constraint;
- * and any other value is an actual location constraint value.
- */
- public String getLocation() {
- return location;
- }
-
- /**
- * Helper class to parse LocationConstraint response XML
- */
- static class LocationResponseHandler extends DefaultHandler {
- String location = null;
- private StringBuffer currText = null;
-
- public void startDocument() {
- }
-
- public void startElement(String uri, String name, String qName, Attributes attrs) {
- if (name.equals("LocationConstraint")) {
- this.currText = new StringBuffer();
- }
- }
-
- public void endElement(String uri, String name, String qName) {
- if (name.equals("LocationConstraint")) {
- location = this.currText.toString();
- this.currText = null;
- }
- }
-
- public void characters(char ch[], int start, int length) {
- if (currText != null)
- this.currText.append(ch, start, length);
- }
- }
-}
diff --git a/s3/perftest/src/main/java/com/amazon/s3/Owner.java b/s3/perftest/src/main/java/com/amazon/s3/Owner.java
deleted file mode 100644
index 4693bf740c..0000000000
--- a/s3/perftest/src/main/java/com/amazon/s3/Owner.java
+++ /dev/null
@@ -1,18 +0,0 @@
-// This software code is made available "AS IS" without warranties of any
-// kind. You may copy, display, modify and redistribute the software
-// code either by itself or as incorporated into your code; provided that
-// you do not remove any proprietary notices. Your use of this software
-// code is at your own risk and you waive any claim against Amazon
-// Digital Services, Inc. or its affiliates with respect to your use of
-// this software code. (c) 2006 Amazon Digital Services, Inc. or its
-// affiliates.
-
-package com.amazon.s3;
-
-/**
- * A structure representing the owner of an object, used as a part of ListEntry.
- */
-public class Owner {
- public String id;
- public String displayName;
-}
diff --git a/s3/perftest/src/main/java/com/amazon/s3/QueryStringAuthGenerator.java b/s3/perftest/src/main/java/com/amazon/s3/QueryStringAuthGenerator.java
deleted file mode 100644
index 4f2ee4baa6..0000000000
--- a/s3/perftest/src/main/java/com/amazon/s3/QueryStringAuthGenerator.java
+++ /dev/null
@@ -1,264 +0,0 @@
-// This software code is made available "AS IS" without warranties of any
-// kind. You may copy, display, modify and redistribute the software
-// code either by itself or as incorporated into your code; provided that
-// you do not remove any proprietary notices. Your use of this software
-// code is at your own risk and you waive any claim against Amazon
-// Digital Services, Inc. or its affiliates with respect to your use of
-// this software code. (c) 2006-2007 Amazon Digital Services, Inc. or its
-// affiliates.
-
-package com.amazon.s3;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * This class mimics the behavior of AWSAuthConnection, except instead of actually performing
- * the operation, QueryStringAuthGenerator will return URLs with query string parameters that
- * can be used to do the same thing. These parameters include an expiration date, so that
- * if you hand them off to someone else, they will only work for a limited amount of time.
- */
-public class QueryStringAuthGenerator {
-
- private String awsAccessKeyId;
- private String awsSecretAccessKey;
- private boolean isSecure;
- private String server;
- private int port;
- private CallingFormat callingFormat;
-
- private Long expiresIn = null;
- private Long expires = null;
-
- // by default, expire in 1 minute.
- private static final Long DEFAULT_EXPIRES_IN = new Long(60 * 1000);
-
- public QueryStringAuthGenerator(String awsAccessKeyId, String awsSecretAccessKey) {
- this(awsAccessKeyId, awsSecretAccessKey, true);
- }
-
- public QueryStringAuthGenerator(String awsAccessKeyId, String awsSecretAccessKey,
- boolean isSecure)
- {
- this(awsAccessKeyId, awsSecretAccessKey, isSecure, Utils.DEFAULT_HOST);
- }
-
- public QueryStringAuthGenerator(String awsAccessKeyId, String awsSecretAccessKey,
- boolean isSecure, String server)
- {
- this(awsAccessKeyId, awsSecretAccessKey, isSecure, server,
- isSecure ? Utils.SECURE_PORT : Utils.INSECURE_PORT);
- }
-
- public QueryStringAuthGenerator(String awsAccessKeyId, String awsSecretAccessKey,
- boolean isSecure, String server, int port)
- {
- this(awsAccessKeyId, awsSecretAccessKey, isSecure, server,
- port, CallingFormat.getSubdomainCallingFormat());
- }
-
- public QueryStringAuthGenerator(String awsAccessKeyId, String awsSecretAccessKey,
- boolean isSecure, String server, CallingFormat callingFormat)
- {
- this(awsAccessKeyId, awsSecretAccessKey, isSecure, server,
- isSecure ? Utils.SECURE_PORT : Utils.INSECURE_PORT,
- callingFormat);
- }
-
- public QueryStringAuthGenerator(String awsAccessKeyId, String awsSecretAccessKey,
- boolean isSecure, String server, int port, CallingFormat callingFormat)
- {
- this.awsAccessKeyId = awsAccessKeyId;
- this.awsSecretAccessKey = awsSecretAccessKey;
- this.isSecure = isSecure;
- this.server = server;
- this.port = port;
- this.callingFormat = callingFormat;
-
- this.expiresIn = DEFAULT_EXPIRES_IN;
- this.expires = null;
- }
-
-
- public void setCallingFormat(CallingFormat format) {
- this.callingFormat = format;
- }
-
- public void setExpires(long millisSinceEpoch) {
- expires = new Long(millisSinceEpoch);
- expiresIn = null;
- }
-
- public void setExpiresIn(long millis) {
- expiresIn = new Long(millis);
- expires = null;
- }
-
- public String createBucket(String bucket, Map headers)
- {
- // validate bucket name
- if (!Utils.validateBucketName(bucket, callingFormat, false))
- throw new IllegalArgumentException("Invalid S3Bucket Name: "+bucket);
-
- Map pathArgs = new HashMap();
- return generateURL("PUT", bucket, "", pathArgs, headers);
- }
-
- public String listBucket(String bucket, String prefix, String marker,
- Integer maxKeys, Map headers){
- return listBucket(bucket, prefix, marker, maxKeys, null, headers);
- }
-
- public String listBucket(String bucket, String prefix, String marker,
- Integer maxKeys, String delimiter, Map headers)
- {
- Map pathArgs = Utils.paramsForListOptions(prefix, marker, maxKeys, delimiter);
- return generateURL("GET", bucket, "", pathArgs, headers);
- }
-
- public String deleteBucket(String bucket, Map headers)
- {
- Map pathArgs = new HashMap();
- return generateURL("DELETE", bucket, "", pathArgs, headers);
- }
-
- public String put(String bucket, String key, S3Object object, Map headers) {
- Map metadata = null;
- Map pathArgs = new HashMap();
- if (object != null) {
- metadata = object.metadata;
- }
-
-
- return generateURL("PUT", bucket, Utils.urlencode(key), pathArgs, mergeMeta(headers, metadata));
- }
-
- public String get(String bucket, String key, Map headers)
- {
- Map pathArgs = new HashMap();
- return generateURL("GET", bucket, Utils.urlencode(key), pathArgs, headers);
- }
-
- public String delete(String bucket, String key, Map headers)
- {
- Map pathArgs = new HashMap();
- return generateURL("DELETE", bucket, Utils.urlencode(key), pathArgs, headers);
- }
-
- public String getBucketLogging(String bucket, Map headers) {
- Map pathArgs = new HashMap();
- pathArgs.put("logging", null);
- return generateURL("GET", bucket, "", pathArgs, headers);
- }
-
- public String putBucketLogging(String bucket, String loggingXMLDoc, Map headers) {
- Map pathArgs = new HashMap();
- pathArgs.put("logging", null);
- return generateURL("PUT", bucket, "", pathArgs, headers);
- }
-
- public String getBucketACL(String bucket, Map headers) {
- return getACL(bucket, "", headers);
- }
-
- public String getACL(String bucket, String key, Map headers)
- {
- Map pathArgs = new HashMap();
- pathArgs.put("acl", null);
- return generateURL("GET", bucket, Utils.urlencode(key), pathArgs, headers);
- }
-
- public String putBucketACL(String bucket, String aclXMLDoc, Map headers) {
- return putACL(bucket, "", aclXMLDoc, headers);
- }
-
- public String putACL(String bucket, String key, String aclXMLDoc, Map headers)
- {
- Map pathArgs = new HashMap();
- pathArgs.put("acl", null);
- return generateURL("PUT", bucket, Utils.urlencode(key), pathArgs, headers);
- }
-
- public String listAllMyBuckets(Map headers)
- {
- Map pathArgs = new HashMap();
- return generateURL("GET", "", "", pathArgs, headers);
- }
-
- public String makeBareURL(String bucket, String key) {
- StringBuffer buffer = new StringBuffer();
- if (this.isSecure) {
- buffer.append("https://");
- } else {
- buffer.append("http://");
- }
- buffer.append(this.server).append(":").append(this.port).append("/").append(bucket);
- buffer.append("/").append(Utils.urlencode(key));
-
- return buffer.toString();
- }
-
- private String generateURL(String method, String bucketName, String key, Map pathArgs, Map headers)
- {
- long expires = 0L;
- if (this.expiresIn != null) {
- expires = System.currentTimeMillis() + this.expiresIn.longValue();
- } else if (this.expires != null) {
- expires = this.expires.longValue();
- } else {
- throw new RuntimeException("Illegal expires state");
- }
-
- // convert to seconds
- expires /= 1000;
-
- String canonicalString = Utils.makeCanonicalString(method, bucketName, key, pathArgs, headers, ""+expires);
- String encodedCanonical = Utils.encode(this.awsSecretAccessKey, canonicalString, true);
-
- pathArgs.put("Signature", encodedCanonical);
- pathArgs.put("Expires", Long.toString(expires));
- pathArgs.put("AWSAccessKeyId", this.awsAccessKeyId);
-
- CallingFormat callingFormat = Utils.getCallingFormatForBucket( this.callingFormat, bucketName );
- if ( isSecure && callingFormat != CallingFormat.getPathCallingFormat() && bucketName.indexOf( "." ) != -1 ) {
- System.err.println( "You are making an SSL connection, however, the bucket contains periods and the wildcard certificate will not match by default. Please consider using HTTP." );
- }
-
- String returnString;
- try {
- URL url = callingFormat.getURL(isSecure, server, port, bucketName, key, pathArgs);
- returnString = url.toString();
- } catch (MalformedURLException e) {
- returnString = "Exception generating url " + e;
- }
-
- return returnString;
- }
-
- private Map mergeMeta(Map headers, Map metadata) {
- Map merged = new TreeMap();
- if (headers != null) {
- for (Iterator i = headers.keySet().iterator(); i.hasNext(); ) {
- String key = (String)i.next();
- merged.put(key, headers.get(key));
- }
- }
- if (metadata != null) {
- for (Iterator i = metadata.keySet().iterator(); i.hasNext(); ) {
- String key = (String)i.next();
- String metadataKey = Utils.METADATA_PREFIX + key;
- if (merged.containsKey(metadataKey)) {
- ((List)merged.get(metadataKey)).addAll((List)metadata.get(key));
- } else {
- merged.put(metadataKey, metadata.get(key));
- }
- }
- }
- return merged;
- }
-}
diff --git a/s3/perftest/src/main/java/com/amazon/s3/Response.java b/s3/perftest/src/main/java/com/amazon/s3/Response.java
deleted file mode 100644
index b6b5f01c58..0000000000
--- a/s3/perftest/src/main/java/com/amazon/s3/Response.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// This software code is made available "AS IS" without warranties of any
-// kind. You may copy, display, modify and redistribute the software
-// code either by itself or as incorporated into your code; provided that
-// you do not remove any proprietary notices. Your use of this software
-// code is at your own risk and you waive any claim against Amazon
-// Digital Services, Inc. or its affiliates with respect to your use of
-// this software code. (c) 2006 Amazon Digital Services, Inc. or its
-// affiliates.
-
-package com.amazon.s3;
-
-import java.net.HttpURLConnection;
-import java.io.IOException;
-
-/**
- * The parent class of all other Responses. This class keeps track of the
- * HttpURLConnection response.
- */
-public class Response {
- public HttpURLConnection connection;
-
- public Response(HttpURLConnection connection) throws IOException {
- this.connection = connection;
- }
-}
diff --git a/s3/perftest/src/main/java/com/amazon/s3/S3Object.java b/s3/perftest/src/main/java/com/amazon/s3/S3Object.java
deleted file mode 100644
index d43a3bca9f..0000000000
--- a/s3/perftest/src/main/java/com/amazon/s3/S3Object.java
+++ /dev/null
@@ -1,30 +0,0 @@
-// This software code is made available "AS IS" without warranties of any
-// kind. You may copy, display, modify and redistribute the software
-// code either by itself or as incorporated into your code; provided that
-// you do not remove any proprietary notices. Your use of this software
-// code is at your own risk and you waive any claim against Amazon
-// Digital Services, Inc. or its affiliates with respect to your use of
-// this software code. (c) 2006 Amazon Digital Services, Inc. or its
-// affiliates.
-
-package com.amazon.s3;
-
-import java.util.Map;
-
-/**
- * A representation of a single object stored in S3.
- */
-public class S3Object {
-
- public byte[] data;
-
- /**
- * A Map from String to List of Strings representing the object's metadata
- */
- public Map metadata;
-
- public S3Object(byte[] data, Map metadata) {
- this.data = data;
- this.metadata = metadata;
- }
-}
diff --git a/s3/perftest/src/main/java/com/amazon/s3/Utils.java b/s3/perftest/src/main/java/com/amazon/s3/Utils.java
deleted file mode 100644
index e57344c47f..0000000000
--- a/s3/perftest/src/main/java/com/amazon/s3/Utils.java
+++ /dev/null
@@ -1,324 +0,0 @@
-// This software code is made available "AS IS" without warranties of any
-// kind. You may copy, display, modify and redistribute the software
-// code either by itself or as incorporated into your code; provided that
-// you do not remove any proprietary notices. Your use of this software
-// code is at your own risk and you waive any claim against Amazon
-// Digital Services, Inc. or its affiliates with respect to your use of
-// this software code. (c) 2006-2007 Amazon Digital Services, Inc. or its
-// affiliates.
-
-package com.amazon.s3;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import javax.crypto.Mac;
-import javax.crypto.spec.SecretKeySpec;
-
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-import org.xml.sax.SAXException;
-
-import com.amazon.thirdparty.Base64;
-
-public class Utils {
- static final String METADATA_PREFIX = "x-amz-meta-";
- static final String AMAZON_HEADER_PREFIX = "x-amz-";
- static final String ALTERNATIVE_DATE_HEADER = "x-amz-date";
- public static final String DEFAULT_HOST = "s3.amazonaws.com";
-
- public static final int SECURE_PORT = 443;
- public static final int INSECURE_PORT = 80;
-
-
- /**
- * HMAC/SHA1 Algorithm per RFC 2104.
- */
- private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1";
-
- static String makeCanonicalString(String method, String bucket, String key, Map pathArgs, Map headers) {
- return makeCanonicalString(method, bucket, key, pathArgs, headers, null);
- }
-
- /**
- * Calculate the canonical string. When expires is non-null, it will be
- * used instead of the Date header.
- */
- static String makeCanonicalString(String method, String bucketName, String key, Map pathArgs,
- Map headers, String expires)
- {
- StringBuffer buf = new StringBuffer();
- buf.append(method + "\n");
-
- // Add all interesting headers to a list, then sort them. "Interesting"
- // is defined as Content-MD5, Content-Type, Date, and x-amz-
- SortedMap interestingHeaders = new TreeMap();
- if (headers != null) {
- for (Iterator i = headers.keySet().iterator(); i.hasNext(); ) {
- String hashKey = (String)i.next();
- if (hashKey == null) continue;
- String lk = hashKey.toLowerCase();
-
- // Ignore any headers that are not particularly interesting.
- if (lk.equals("content-type") || lk.equals("content-md5") || lk.equals("date") ||
- lk.startsWith(AMAZON_HEADER_PREFIX))
- {
- List s = (List)headers.get(hashKey);
- interestingHeaders.put(lk, concatenateList(s));
- }
- }
- }
-
- if (interestingHeaders.containsKey(ALTERNATIVE_DATE_HEADER)) {
- interestingHeaders.put("date", "");
- }
-
- // if the expires is non-null, use that for the date field. this
- // trumps the x-amz-date behavior.
- if (expires != null) {
- interestingHeaders.put("date", expires);
- }
-
- // these headers require that we still put a new line in after them,
- // even if they don't exist.
- if (! interestingHeaders.containsKey("content-type")) {
- interestingHeaders.put("content-type", "");
- }
- if (! interestingHeaders.containsKey("content-md5")) {
- interestingHeaders.put("content-md5", "");
- }
-
- // Finally, add all the interesting headers (i.e.: all that startwith x-amz- ;-))
- for (Iterator i = interestingHeaders.keySet().iterator(); i.hasNext(); ) {
- String headerKey = (String)i.next();
- if (headerKey.startsWith(AMAZON_HEADER_PREFIX)) {
- buf.append(headerKey).append(':').append(interestingHeaders.get(headerKey));
- } else {
- buf.append(interestingHeaders.get(headerKey));
- }
- buf.append("\n");
- }
-
- // build the path using the bucket and key
- if (bucketName != null && !bucketName.equals("")) {
- buf.append("/" + bucketName );
- }
-
- // append the key (it might be an empty string)
- // append a slash regardless
- buf.append("/");
- if(key != null) {
- buf.append(key);
- }
-
- // if there is an acl, logging or torrent parameter
- // add them to the string
- if (pathArgs != null ) {
- if (pathArgs.containsKey("acl")) {
- buf.append("?acl");
- } else if (pathArgs.containsKey("torrent")) {
- buf.append("?torrent");
- } else if (pathArgs.containsKey("logging")) {
- buf.append("?logging");
- } else if (pathArgs.containsKey("location")) {
- buf.append("?location");
- }
- }
-
- return buf.toString();
-
- }
-
- /**
- * Calculate the HMAC/SHA1 on a string.
- * @param data Data to sign
- * @param passcode Passcode to sign it with
- * @return Signature
- * @throws NoSuchAlgorithmException If the algorithm does not exist. Unlikely
- * @throws InvalidKeyException If the key is invalid.
- */
- static String encode(String awsSecretAccessKey, String canonicalString,
- boolean urlencode)
- {
- // The following HMAC/SHA1 code for the signature is taken from the
- // AWS Platform's implementation of RFC2104 (amazon.webservices.common.Signature)
- //
- // Acquire an HMAC/SHA1 from the raw key bytes.
- SecretKeySpec signingKey =
- new SecretKeySpec(awsSecretAccessKey.getBytes(), HMAC_SHA1_ALGORITHM);
-
- // Acquire the MAC instance and initialize with the signing key.
- Mac mac = null;
- try {
- mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
- } catch (NoSuchAlgorithmException e) {
- // should not happen
- throw new RuntimeException("Could not find sha1 algorithm", e);
- }
- try {
- mac.init(signingKey);
- } catch (InvalidKeyException e) {
- // also should not happen
- throw new RuntimeException("Could not initialize the MAC algorithm", e);
- }
-
- // Compute the HMAC on the digest, and set it.
- String b64 = Base64.encodeBytes(mac.doFinal(canonicalString.getBytes()));
-
- if (urlencode) {
- return urlencode(b64);
- } else {
- return b64;
- }
- }
-
- static Map paramsForListOptions(String prefix, String marker, Integer maxKeys) {
- return paramsForListOptions(prefix, marker, maxKeys, null);
- }
-
- static Map paramsForListOptions(String prefix, String marker, Integer maxKeys, String delimiter) {
-
- Map argParams = new HashMap();
- // these three params must be url encoded
- if (prefix != null)
- argParams.put("prefix", urlencode(prefix));
- if (marker != null)
- argParams.put("marker", urlencode(marker));
- if (delimiter != null)
- argParams.put("delimiter", urlencode(delimiter));
-
- if (maxKeys != null)
- argParams.put("max-keys", Integer.toString(maxKeys.intValue()));
-
- return argParams;
-
- }
-
- /**
- * Converts the Path Arguments from a map to String which can be used in url construction
- * @param pathArgs a map of arguments
- * @return a string representation of pathArgs
- */
- public static String convertPathArgsHashToString(Map pathArgs) {
- StringBuffer pathArgsString = new StringBuffer();
- String argumentValue;
- boolean firstRun = true;
- if (pathArgs != null) {
- for (Iterator argumentIterator = pathArgs.keySet().iterator(); argumentIterator.hasNext(); ) {
- String argument = (String)argumentIterator.next();
- if (firstRun) {
- firstRun = false;
- pathArgsString.append("?");
- } else {
- pathArgsString.append("&");
- }
-
- argumentValue = (String)pathArgs.get(argument);
- pathArgsString.append(argument);
- if (argumentValue != null) {
- pathArgsString.append("=");
- pathArgsString.append(argumentValue);
- }
- }
- }
-
- return pathArgsString.toString();
- }
-
-
-
-
- static String urlencode(String unencoded) {
- try {
- return URLEncoder.encode(unencoded, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- // should never happen
- throw new RuntimeException("Could not url encode to UTF-8", e);
- }
- }
-
- static XMLReader createXMLReader() {
- try {
- return XMLReaderFactory.createXMLReader();
- } catch (SAXException e) {
- // oops, lets try doing this (needed in 1.4)
- System.setProperty("org.xml.sax.driver", "org.apache.crimson.parser.XMLReaderImpl");
- }
- try {
- // try once more
- return XMLReaderFactory.createXMLReader();
- } catch (SAXException e) {
- throw new RuntimeException("Couldn't initialize a sax driver for the XMLReader");
- }
- }
-
- /**
- * Concatenates a bunch of header values, seperating them with a comma.
- * @param values List of header values.
- * @return String of all headers, with commas.
- */
- private static String concatenateList(List values) {
- StringBuffer buf = new StringBuffer();
- for (int i = 0, size = values.size(); i < size; ++ i) {
- buf.append(((String)values.get(i)).replaceAll("\n", "").trim());
- if (i != (size - 1)) {
- buf.append(",");
- }
- }
- return buf.toString();
- }
-
- /**
- * Validate bucket-name
- */
- static boolean validateBucketName(String bucketName, CallingFormat callingFormat, boolean located) {
- if (callingFormat == CallingFormat.getPathCallingFormat())
- {
- final int MIN_BUCKET_LENGTH = 3;
- final int MAX_BUCKET_LENGTH = 255;
- final String BUCKET_NAME_REGEX = "^[0-9A-Za-z\\.\\-_]*$";
-
- return null != bucketName &&
- bucketName.length() >= MIN_BUCKET_LENGTH &&
- bucketName.length() <= MAX_BUCKET_LENGTH &&
- bucketName.matches(BUCKET_NAME_REGEX);
- } else {
- return isValidSubdomainBucketName( bucketName );
- }
- }
-
- static boolean isValidSubdomainBucketName( String bucketName ) {
- final int MIN_BUCKET_LENGTH = 3;
- final int MAX_BUCKET_LENGTH = 63;
- // don't allow names that look like 127.0.0.1
- final String IPv4_REGEX = "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$";
- // dns sub-name restrictions
- final String BUCKET_NAME_REGEX = "^[a-z0-9]([a-z0-9\\-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9\\-]*[a-z0-9])?)*$";
-
- // If there wasn't a location-constraint, then the current actual
- // restriction is just that no 'part' of the name (i.e. sequence
- // of characters between any 2 '.'s has to be 63) but the recommendation
- // is to keep the entire bucket name under 63.
- return null != bucketName &&
- bucketName.length() >= MIN_BUCKET_LENGTH &&
- bucketName.length() <= MAX_BUCKET_LENGTH &&
- !bucketName.matches(IPv4_REGEX) &&
- bucketName.matches(BUCKET_NAME_REGEX);
- }
-
- static CallingFormat getCallingFormatForBucket( CallingFormat desiredFormat, String bucketName ) {
- CallingFormat callingFormat = desiredFormat;
- if ( callingFormat == CallingFormat.getSubdomainCallingFormat() && ! Utils.isValidSubdomainBucketName( bucketName ) ) {
- callingFormat = CallingFormat.getPathCallingFormat();
- }
- return callingFormat;
- }
-}
diff --git a/s3/perftest/src/main/java/com/amazon/thirdparty/Base64.java b/s3/perftest/src/main/java/com/amazon/thirdparty/Base64.java
deleted file mode 100644
index bda181c9c1..0000000000
--- a/s3/perftest/src/main/java/com/amazon/thirdparty/Base64.java
+++ /dev/null
@@ -1,1459 +0,0 @@
-//
-// NOTE: The following source code is the iHarder.net public domain
-// Base64 library and is provided here as a convenience. For updates,
-// problems, questions, etc. regarding this code, please visit:
-// http://iharder.sourceforge.net/current/java/base64/
-//
-
-package com.amazon.thirdparty;
-
-
-/**
- * Encodes and decodes to and from Base64 notation.
- *
- *
- * Change Log:
- *
- *
- * - v2.1 - Cleaned up javadoc comments and unused variables and methods. Added
- * some convenience methods for reading and writing to and from files.
- * - v2.0.2 - Now specifies UTF-8 encoding in places where the code fails on systems
- * with other encodings (like EBCDIC).
- * - v2.0.1 - Fixed an error when decoding a single byte, that is, when the
- * encoded data was a single byte.
- * - v2.0 - I got rid of methods that used booleans to set options.
- * Now everything is more consolidated and cleaner. The code now detects
- * when data that's being decoded is gzip-compressed and will decompress it
- * automatically. Generally things are cleaner. You'll probably have to
- * change some method calls that you were making to support the new
- * options format (ints that you "OR" together).
- * - v1.5.1 - Fixed bug when decompressing and decoding to a
- * byte[] using decode( String s, boolean gzipCompressed ).
- * Added the ability to "suspend" encoding in the Output Stream so
- * you can turn on and off the encoding if you need to embed base64
- * data in an otherwise "normal" stream (like an XML file).
- * - v1.5 - Output stream pases on flush() command but doesn't do anything itself.
- * This helps when using GZIP streams.
- * Added the ability to GZip-compress objects before encoding them.
- * - v1.4 - Added helper methods to read/write files.
- * - v1.3.6 - Fixed OutputStream.flush() so that 'position' is reset.
- * - v1.3.5 - Added flag to turn on and off line breaks. Fixed bug in input stream
- * where last buffer being read, if not completely full, was not returned.
- * - v1.3.4 - Fixed when "improperly padded stream" error was thrown at the wrong time.
- * - v1.3.3 - Fixed I/O streams which were totally messed up.
- *
- *
- *
- * I am placing this code in the Public Domain. Do with it as you will.
- * This software comes with no guarantees or warranties but with
- * plenty of well-wishing instead!
- * Please visit http://iharder.net/base64
- * periodically to check for updates or to contribute improvements.
- *
- *
- * @author Robert Harder
- * @author rob@iharder.net
- * @version 2.1
- */
-public class Base64
-{
-
-/* ******** P U B L I C F I E L D S ******** */
-
-
- /** No options specified. Value is zero. */
- public final static int NO_OPTIONS = 0;
-
- /** Specify encoding. */
- public final static int ENCODE = 1;
-
-
- /** Specify decoding. */
- public final static int DECODE = 0;
-
-
- /** Specify that data should be gzip-compressed. */
- public final static int GZIP = 2;
-
-
- /** Don't break lines when encoding (violates strict Base64 specification) */
- public final static int DONT_BREAK_LINES = 8;
-
-
-/* ******** P R I V A T E F I E L D S ******** */
-
-
- /** Maximum line length (76) of Base64 output. */
- private final static int MAX_LINE_LENGTH = 76;
-
-
- /** The equals sign (=) as a byte. */
- private final static byte EQUALS_SIGN = (byte)'=';
-
-
- /** The new line character (\n) as a byte. */
- private final static byte NEW_LINE = (byte)'\n';
-
-
- /** Preferred encoding. */
- private final static String PREFERRED_ENCODING = "UTF-8";
-
-
- /** The 64 valid Base64 values. */
- private final static byte[] ALPHABET;
- private final static byte[] _NATIVE_ALPHABET = /* May be something funny like EBCDIC */
- {
- (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', (byte)'G',
- (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', (byte)'N',
- (byte)'O', (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', (byte)'U',
- (byte)'V', (byte)'W', (byte)'X', (byte)'Y', (byte)'Z',
- (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g',
- (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n',
- (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u',
- (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z',
- (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5',
- (byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'+', (byte)'/'
- };
-
- /** Determine which ALPHABET to use. */
- static
- {
- byte[] __bytes;
- try
- {
- __bytes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".getBytes( PREFERRED_ENCODING );
- } // end try
- catch (java.io.UnsupportedEncodingException use)
- {
- __bytes = _NATIVE_ALPHABET; // Fall back to native encoding
- } // end catch
- ALPHABET = __bytes;
- } // end static
-
-
- /**
- * Translates a Base64 value to either its 6-bit reconstruction value
- * or a negative number indicating some other meaning.
- **/
- private final static byte[] DECODABET =
- {
- -9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 0 - 8
- -5,-5, // Whitespace: Tab and Linefeed
- -9,-9, // Decimal 11 - 12
- -5, // Whitespace: Carriage Return
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 14 - 26
- -9,-9,-9,-9,-9, // Decimal 27 - 31
- -5, // Whitespace: Space
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 33 - 42
- 62, // Plus sign at decimal 43
- -9,-9,-9, // Decimal 44 - 46
- 63, // Slash at decimal 47
- 52,53,54,55,56,57,58,59,60,61, // Numbers zero through nine
- -9,-9,-9, // Decimal 58 - 60
- -1, // Equals sign at decimal 61
- -9,-9,-9, // Decimal 62 - 64
- 0,1,2,3,4,5,6,7,8,9,10,11,12,13, // Letters 'A' through 'N'
- 14,15,16,17,18,19,20,21,22,23,24,25, // Letters 'O' through 'Z'
- -9,-9,-9,-9,-9,-9, // Decimal 91 - 96
- 26,27,28,29,30,31,32,33,34,35,36,37,38, // Letters 'a' through 'm'
- 39,40,41,42,43,44,45,46,47,48,49,50,51, // Letters 'n' through 'z'
- -9,-9,-9,-9 // Decimal 123 - 126
- /*,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 127 - 139
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 140 - 152
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 153 - 165
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 166 - 178
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 179 - 191
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 192 - 204
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 205 - 217
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 218 - 230
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 231 - 243
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */
- };
-
- // I think I end up not using the BAD_ENCODING indicator.
- //private final static byte BAD_ENCODING = -9; // Indicates error in encoding
- private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding
- private final static byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding
-
-
- /** Defeats instantiation. */
- private Base64(){}
-
-
-
-/* ******** E N C O D I N G M E T H O D S ******** */
-
-
- /**
- * Encodes up to the first three bytes of array threeBytes
- * and returns a four-byte array in Base64 notation.
- * The actual number of significant bytes in your array is
- * given by numSigBytes.
- * The array threeBytes needs only be as big as
- * numSigBytes.
- * Code can reuse a byte array by passing a four-byte array as b4.
- *
- * @param b4 A reusable byte array to reduce array instantiation
- * @param threeBytes the array to convert
- * @param numSigBytes the number of significant bytes in your array
- * @return four byte array in Base64 notation.
- * @since 1.5.1
- */
- private static byte[] encode3to4( byte[] b4, byte[] threeBytes, int numSigBytes )
- {
- encode3to4( threeBytes, 0, numSigBytes, b4, 0 );
- return b4;
- } // end encode3to4
-
-
- /**
- * Encodes up to three bytes of the array source
- * and writes the resulting four Base64 bytes to destination.
- * The source and destination arrays can be manipulated
- * anywhere along their length by specifying
- * srcOffset and destOffset.
- * This method does not check to make sure your arrays
- * are large enough to accomodate srcOffset + 3 for
- * the source array or destOffset + 4 for
- * the destination array.
- * The actual number of significant bytes in your array is
- * given by numSigBytes.
- *
- * @param source the array to convert
- * @param srcOffset the index where conversion begins
- * @param numSigBytes the number of significant bytes in your array
- * @param destination the array to hold the conversion
- * @param destOffset the index where output will be put
- * @return the destination array
- * @since 1.3
- */
- private static byte[] encode3to4(
- byte[] source, int srcOffset, int numSigBytes,
- byte[] destination, int destOffset )
- {
- // 1 2 3
- // 01234567890123456789012345678901 Bit position
- // --------000000001111111122222222 Array position from threeBytes
- // --------| || || || | Six bit groups to index ALPHABET
- // >>18 >>12 >> 6 >> 0 Right shift necessary
- // 0x3f 0x3f 0x3f Additional AND
-
- // Create buffer with zero-padding if there are only one or two
- // significant bytes passed in the array.
- // We have to shift left 24 in order to flush out the 1's that appear
- // when Java treats a value as negative that is cast from a byte to an int.
- int inBuff = ( numSigBytes > 0 ? ((source[ srcOffset ] << 24) >>> 8) : 0 )
- | ( numSigBytes > 1 ? ((source[ srcOffset + 1 ] << 24) >>> 16) : 0 )
- | ( numSigBytes > 2 ? ((source[ srcOffset + 2 ] << 24) >>> 24) : 0 );
-
- switch( numSigBytes )
- {
- case 3:
- destination[ destOffset ] = ALPHABET[ (inBuff >>> 18) ];
- destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ];
- destination[ destOffset + 2 ] = ALPHABET[ (inBuff >>> 6) & 0x3f ];
- destination[ destOffset + 3 ] = ALPHABET[ (inBuff ) & 0x3f ];
- return destination;
-
- case 2:
- destination[ destOffset ] = ALPHABET[ (inBuff >>> 18) ];
- destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ];
- destination[ destOffset + 2 ] = ALPHABET[ (inBuff >>> 6) & 0x3f ];
- destination[ destOffset + 3 ] = EQUALS_SIGN;
- return destination;
-
- case 1:
- destination[ destOffset ] = ALPHABET[ (inBuff >>> 18) ];
- destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ];
- destination[ destOffset + 2 ] = EQUALS_SIGN;
- destination[ destOffset + 3 ] = EQUALS_SIGN;
- return destination;
-
- default:
- return destination;
- } // end switch
- } // end encode3to4
-
-
-
- /**
- * Serializes an object and returns the Base64-encoded
- * version of that serialized object. If the object
- * cannot be serialized or there is another error,
- * the method will return null.
- * The object is not GZip-compressed before being encoded.
- *
- * @param serializableObject The object to encode
- * @return The Base64-encoded object
- * @since 1.4
- */
- public static String encodeObject( java.io.Serializable serializableObject )
- {
- return encodeObject( serializableObject, NO_OPTIONS );
- } // end encodeObject
-
-
-
- /**
- * Serializes an object and returns the Base64-encoded
- * version of that serialized object. If the object
- * cannot be serialized or there is another error,
- * the method will return null.
- *
- * Valid options:
- * GZIP: gzip-compresses object before encoding it.
- * DONT_BREAK_LINES: don't break lines at 76 characters
- * Note: Technically, this makes your encoding non-compliant.
- *
- *
- * Example: encodeObject( myObj, Base64.GZIP )
or
- *
- * Example: encodeObject( myObj, Base64.GZIP | Base64.DONT_BREAK_LINES )
- *
- * @param serializableObject The object to encode
- * @param options Specified options
- * @return The Base64-encoded object
- * @see Base64#GZIP
- * @see Base64#DONT_BREAK_LINES
- * @since 2.0
- */
- public static String encodeObject( java.io.Serializable serializableObject, int options )
- {
- // Streams
- java.io.ByteArrayOutputStream baos = null;
- java.io.OutputStream b64os = null;
- java.io.ObjectOutputStream oos = null;
- java.util.zip.GZIPOutputStream gzos = null;
-
- // Isolate options
- int gzip = (options & GZIP);
- int dontBreakLines = (options & DONT_BREAK_LINES);
-
- try
- {
- // ObjectOutputStream -> (GZIP) -> Base64 -> ByteArrayOutputStream
- baos = new java.io.ByteArrayOutputStream();
- b64os = new Base64.OutputStream( baos, ENCODE | dontBreakLines );
-
- // GZip?
- if( gzip == GZIP )
- {
- gzos = new java.util.zip.GZIPOutputStream( b64os );
- oos = new java.io.ObjectOutputStream( gzos );
- } // end if: gzip
- else
- oos = new java.io.ObjectOutputStream( b64os );
-
- oos.writeObject( serializableObject );
- } // end try
- catch( java.io.IOException e )
- {
- e.printStackTrace();
- return null;
- } // end catch
- finally
- {
- try{ oos.close(); } catch( Exception e ){}
- try{ gzos.close(); } catch( Exception e ){}
- try{ b64os.close(); } catch( Exception e ){}
- try{ baos.close(); } catch( Exception e ){}
- } // end finally
-
- // Return value according to relevant encoding.
- try
- {
- return new String( baos.toByteArray(), PREFERRED_ENCODING );
- } // end try
- catch (java.io.UnsupportedEncodingException uue)
- {
- return new String( baos.toByteArray() );
- } // end catch
-
- } // end encode
-
-
-
- /**
- * Encodes a byte array into Base64 notation.
- * Does not GZip-compress data.
- *
- * @param source The data to convert
- * @since 1.4
- */
- public static String encodeBytes( byte[] source )
- {
- return encodeBytes( source, 0, source.length, NO_OPTIONS );
- } // end encodeBytes
-
-
-
- /**
- * Encodes a byte array into Base64 notation.
- *
- * Valid options:
- * GZIP: gzip-compresses object before encoding it.
- * DONT_BREAK_LINES: don't break lines at 76 characters
- * Note: Technically, this makes your encoding non-compliant.
- *
- *
- * Example: encodeBytes( myData, Base64.GZIP )
or
- *
- * Example: encodeBytes( myData, Base64.GZIP | Base64.DONT_BREAK_LINES )
- *
- *
- * @param source The data to convert
- * @param options Specified options
- * @see Base64#GZIP
- * @see Base64#DONT_BREAK_LINES
- * @since 2.0
- */
- public static String encodeBytes( byte[] source, int options )
- {
- return encodeBytes( source, 0, source.length, options );
- } // end encodeBytes
-
-
- /**
- * Encodes a byte array into Base64 notation.
- * Does not GZip-compress data.
- *
- * @param source The data to convert
- * @param off Offset in array where conversion should begin
- * @param len Length of data to convert
- * @since 1.4
- */
- public static String encodeBytes( byte[] source, int off, int len )
- {
- return encodeBytes( source, off, len, NO_OPTIONS );
- } // end encodeBytes
-
-
-
- /**
- * Encodes a byte array into Base64 notation.
- *
- * Valid options:
- * GZIP: gzip-compresses object before encoding it.
- * DONT_BREAK_LINES: don't break lines at 76 characters
- * Note: Technically, this makes your encoding non-compliant.
- *
- *
- * Example: encodeBytes( myData, Base64.GZIP )
or
- *
- * Example: encodeBytes( myData, Base64.GZIP | Base64.DONT_BREAK_LINES )
- *
- *
- * @param source The data to convert
- * @param off Offset in array where conversion should begin
- * @param len Length of data to convert
- * @param options Specified options
- * @see Base64#GZIP
- * @see Base64#DONT_BREAK_LINES
- * @since 2.0
- */
- public static String encodeBytes( byte[] source, int off, int len, int options )
- {
- // Isolate options
- int dontBreakLines = ( options & DONT_BREAK_LINES );
- int gzip = ( options & GZIP );
-
- // Compress?
- if( gzip == GZIP )
- {
- java.io.ByteArrayOutputStream baos = null;
- java.util.zip.GZIPOutputStream gzos = null;
- Base64.OutputStream b64os = null;
-
-
- try
- {
- // GZip -> Base64 -> ByteArray
- baos = new java.io.ByteArrayOutputStream();
- b64os = new Base64.OutputStream( baos, ENCODE | dontBreakLines );
- gzos = new java.util.zip.GZIPOutputStream( b64os );
-
- gzos.write( source, off, len );
- gzos.close();
- } // end try
- catch( java.io.IOException e )
- {
- e.printStackTrace();
- return null;
- } // end catch
- finally
- {
- try{ gzos.close(); } catch( Exception e ){}
- try{ b64os.close(); } catch( Exception e ){}
- try{ baos.close(); } catch( Exception e ){}
- } // end finally
-
- // Return value according to relevant encoding.
- try
- {
- return new String( baos.toByteArray(), PREFERRED_ENCODING );
- } // end try
- catch (java.io.UnsupportedEncodingException uue)
- {
- return new String( baos.toByteArray() );
- } // end catch
- } // end if: compress
-
- // Else, don't compress. Better not to use streams at all then.
- else
- {
- // Convert option to boolean in way that code likes it.
- boolean breakLines = dontBreakLines == 0;
-
- int len43 = len * 4 / 3;
- byte[] outBuff = new byte[ ( len43 ) // Main 4:3
- + ( (len % 3) > 0 ? 4 : 0 ) // Account for padding
- + (breakLines ? ( len43 / MAX_LINE_LENGTH ) : 0) ]; // New lines
- int d = 0;
- int e = 0;
- int len2 = len - 2;
- int lineLength = 0;
- for( ; d < len2; d+=3, e+=4 )
- {
- encode3to4( source, d+off, 3, outBuff, e );
-
- lineLength += 4;
- if( breakLines && lineLength == MAX_LINE_LENGTH )
- {
- outBuff[e+4] = NEW_LINE;
- e++;
- lineLength = 0;
- } // end if: end of line
- } // en dfor: each piece of array
-
- if( d < len )
- {
- encode3to4( source, d+off, len - d, outBuff, e );
- e += 4;
- } // end if: some padding needed
-
-
- // Return value according to relevant encoding.
- try
- {
- return new String( outBuff, 0, e, PREFERRED_ENCODING );
- } // end try
- catch (java.io.UnsupportedEncodingException uue)
- {
- return new String( outBuff, 0, e );
- } // end catch
-
- } // end else: don't compress
-
- } // end encodeBytes
-
-
-
-
-
-/* ******** D E C O D I N G M E T H O D S ******** */
-
-
- /**
- * Decodes four bytes from array source
- * and writes the resulting bytes (up to three of them)
- * to destination.
- * The source and destination arrays can be manipulated
- * anywhere along their length by specifying
- * srcOffset and destOffset.
- * This method does not check to make sure your arrays
- * are large enough to accomodate srcOffset + 4 for
- * the source array or destOffset + 3 for
- * the destination array.
- * This method returns the actual number of bytes that
- * were converted from the Base64 encoding.
- *
- *
- * @param source the array to convert
- * @param srcOffset the index where conversion begins
- * @param destination the array to hold the conversion
- * @param destOffset the index where output will be put
- * @return the number of decoded bytes converted
- * @since 1.3
- */
- private static int decode4to3( byte[] source, int srcOffset, byte[] destination, int destOffset )
- {
- // Example: Dk==
- if( source[ srcOffset + 2] == EQUALS_SIGN )
- {
- // Two ways to do the same thing. Don't know which way I like best.
- //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
- // | ( ( DECODABET[ source[ srcOffset + 1] ] << 24 ) >>> 12 );
- int outBuff = ( ( DECODABET[ source[ srcOffset ] ] & 0xFF ) << 18 )
- | ( ( DECODABET[ source[ srcOffset + 1] ] & 0xFF ) << 12 );
-
- destination[ destOffset ] = (byte)( outBuff >>> 16 );
- return 1;
- }
-
- // Example: DkL=
- else if( source[ srcOffset + 3 ] == EQUALS_SIGN )
- {
- // Two ways to do the same thing. Don't know which way I like best.
- //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
- // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 )
- // | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 );
- int outBuff = ( ( DECODABET[ source[ srcOffset ] ] & 0xFF ) << 18 )
- | ( ( DECODABET[ source[ srcOffset + 1 ] ] & 0xFF ) << 12 )
- | ( ( DECODABET[ source[ srcOffset + 2 ] ] & 0xFF ) << 6 );
-
- destination[ destOffset ] = (byte)( outBuff >>> 16 );
- destination[ destOffset + 1 ] = (byte)( outBuff >>> 8 );
- return 2;
- }
-
- // Example: DkLE
- else
- {
- try{
- // Two ways to do the same thing. Don't know which way I like best.
- //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
- // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 )
- // | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 )
- // | ( ( DECODABET[ source[ srcOffset + 3 ] ] << 24 ) >>> 24 );
- int outBuff = ( ( DECODABET[ source[ srcOffset ] ] & 0xFF ) << 18 )
- | ( ( DECODABET[ source[ srcOffset + 1 ] ] & 0xFF ) << 12 )
- | ( ( DECODABET[ source[ srcOffset + 2 ] ] & 0xFF ) << 6)
- | ( ( DECODABET[ source[ srcOffset + 3 ] ] & 0xFF ) );
-
-
- destination[ destOffset ] = (byte)( outBuff >> 16 );
- destination[ destOffset + 1 ] = (byte)( outBuff >> 8 );
- destination[ destOffset + 2 ] = (byte)( outBuff );
-
- return 3;
- }catch( Exception e){
- System.out.println(""+source[srcOffset]+ ": " + ( DECODABET[ source[ srcOffset ] ] ) );
- System.out.println(""+source[srcOffset+1]+ ": " + ( DECODABET[ source[ srcOffset + 1 ] ] ) );
- System.out.println(""+source[srcOffset+2]+ ": " + ( DECODABET[ source[ srcOffset + 2 ] ] ) );
- System.out.println(""+source[srcOffset+3]+ ": " + ( DECODABET[ source[ srcOffset + 3 ] ] ) );
- return -1;
- } //e nd catch
- }
- } // end decodeToBytes
-
-
-
-
- /**
- * Very low-level access to decoding ASCII characters in
- * the form of a byte array. Does not support automatically
- * gunzipping or any other "fancy" features.
- *
- * @param source The Base64 encoded data
- * @param off The offset of where to begin decoding
- * @param len The length of characters to decode
- * @return decoded data
- * @since 1.3
- */
- public static byte[] decode( byte[] source, int off, int len )
- {
- int len34 = len * 3 / 4;
- byte[] outBuff = new byte[ len34 ]; // Upper limit on size of output
- int outBuffPosn = 0;
-
- byte[] b4 = new byte[4];
- int b4Posn = 0;
- int i = 0;
- byte sbiCrop = 0;
- byte sbiDecode = 0;
- for( i = off; i < off+len; i++ )
- {
- sbiCrop = (byte)(source[i] & 0x7f); // Only the low seven bits
- sbiDecode = DECODABET[ sbiCrop ];
-
- if( sbiDecode >= WHITE_SPACE_ENC ) // White space, Equals sign or better
- {
- if( sbiDecode >= EQUALS_SIGN_ENC )
- {
- b4[ b4Posn++ ] = sbiCrop;
- if( b4Posn > 3 )
- {
- outBuffPosn += decode4to3( b4, 0, outBuff, outBuffPosn );
- b4Posn = 0;
-
- // If that was the equals sign, break out of 'for' loop
- if( sbiCrop == EQUALS_SIGN )
- break;
- } // end if: quartet built
-
- } // end if: equals sign or better
-
- } // end if: white space, equals sign or better
- else
- {
- System.err.println( "Bad Base64 input character at " + i + ": " + source[i] + "(decimal)" );
- return null;
- } // end else:
- } // each input character
-
- byte[] out = new byte[ outBuffPosn ];
- System.arraycopy( outBuff, 0, out, 0, outBuffPosn );
- return out;
- } // end decode
-
-
-
-
- /**
- * Decodes data from Base64 notation, automatically
- * detecting gzip-compressed data and decompressing it.
- *
- * @param s the string to decode
- * @return the decoded data
- * @since 1.4
- */
- public static byte[] decode( String s )
- {
- byte[] bytes;
- try
- {
- bytes = s.getBytes( PREFERRED_ENCODING );
- } // end try
- catch( java.io.UnsupportedEncodingException uee )
- {
- bytes = s.getBytes();
- } // end catch
- //
-
- // Decode
- bytes = decode( bytes, 0, bytes.length );
-
-
- // Check to see if it's gzip-compressed
- // GZIP Magic Two-Byte Number: 0x8b1f (35615)
- if( bytes != null && bytes.length >= 4 )
- {
-
- int head = ((int)bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
- if( java.util.zip.GZIPInputStream.GZIP_MAGIC == head )
- {
- java.io.ByteArrayInputStream bais = null;
- java.util.zip.GZIPInputStream gzis = null;
- java.io.ByteArrayOutputStream baos = null;
- byte[] buffer = new byte[2048];
- int length = 0;
-
- try
- {
- baos = new java.io.ByteArrayOutputStream();
- bais = new java.io.ByteArrayInputStream( bytes );
- gzis = new java.util.zip.GZIPInputStream( bais );
-
- while( ( length = gzis.read( buffer ) ) >= 0 )
- {
- baos.write(buffer,0,length);
- } // end while: reading input
-
- // No error? Get new bytes.
- bytes = baos.toByteArray();
-
- } // end try
- catch( java.io.IOException e )
- {
- // Just return originally-decoded bytes
- } // end catch
- finally
- {
- try{ baos.close(); } catch( Exception e ){}
- try{ gzis.close(); } catch( Exception e ){}
- try{ bais.close(); } catch( Exception e ){}
- } // end finally
-
- } // end if: gzipped
- } // end if: bytes.length >= 2
-
- return bytes;
- } // end decode
-
-
-
-
- /**
- * Attempts to decode Base64 data and deserialize a Java
- * Object within. Returns null if there was an error.
- *
- * @param encodedObject The Base64 data to decode
- * @return The decoded and deserialized object
- * @since 1.5
- */
- public static Object decodeToObject( String encodedObject )
- {
- // Decode and gunzip if necessary
- byte[] objBytes = decode( encodedObject );
-
- java.io.ByteArrayInputStream bais = null;
- java.io.ObjectInputStream ois = null;
- Object obj = null;
-
- try
- {
- bais = new java.io.ByteArrayInputStream( objBytes );
- ois = new java.io.ObjectInputStream( bais );
-
- obj = ois.readObject();
- } // end try
- catch( java.io.IOException e )
- {
- e.printStackTrace();
- obj = null;
- } // end catch
- catch( java.lang.ClassNotFoundException e )
- {
- e.printStackTrace();
- obj = null;
- } // end catch
- finally
- {
- try{ bais.close(); } catch( Exception e ){}
- try{ ois.close(); } catch( Exception e ){}
- } // end finally
-
- return obj;
- } // end decodeObject
-
-
-
- /**
- * Convenience method for encoding data to a file.
- *
- * @param dataToEncode byte array of data to encode in base64 form
- * @param filename Filename for saving encoded data
- * @return true if successful, false otherwise
- *
- * @since 2.1
- */
- public static boolean encodeToFile( byte[] dataToEncode, String filename )
- {
- boolean success = false;
- Base64.OutputStream bos = null;
- try
- {
- bos = new Base64.OutputStream(
- new java.io.FileOutputStream( filename ), Base64.ENCODE );
- bos.write( dataToEncode );
- success = true;
- } // end try
- catch( java.io.IOException e )
- {
-
- success = false;
- } // end catch: IOException
- finally
- {
- try{ bos.close(); } catch( Exception e ){}
- } // end finally
-
- return success;
- } // end encodeToFile
-
-
- /**
- * Convenience method for decoding data to a file.
- *
- * @param dataToDecode Base64-encoded data as a string
- * @param filename Filename for saving decoded data
- * @return true if successful, false otherwise
- *
- * @since 2.1
- */
- public static boolean decodeToFile( String dataToDecode, String filename )
- {
- boolean success = false;
- Base64.OutputStream bos = null;
- try
- {
- bos = new Base64.OutputStream(
- new java.io.FileOutputStream( filename ), Base64.DECODE );
- bos.write( dataToDecode.getBytes( PREFERRED_ENCODING ) );
- success = true;
- } // end try
- catch( java.io.IOException e )
- {
- success = false;
- } // end catch: IOException
- finally
- {
- try{ bos.close(); } catch( Exception e ){}
- } // end finally
-
- return success;
- } // end decodeToFile
-
-
-
-
- /**
- * Convenience method for reading a base64-encoded
- * file and decoding it.
- *
- * @param filename Filename for reading encoded data
- * @return decoded byte array or null if unsuccessful
- *
- * @since 2.1
- */
- public static byte[] decodeFromFile( String filename )
- {
- byte[] decodedData = null;
- Base64.InputStream bis = null;
- try
- {
- // Set up some useful variables
- java.io.File file = new java.io.File( filename );
- byte[] buffer = null;
- int length = 0;
- int numBytes = 0;
-
- // Check for size of file
- if( file.length() > Integer.MAX_VALUE )
- {
- System.err.println( "File is too big for this convenience method (" + file.length() + " bytes)." );
- return null;
- } // end if: file too big for int index
- buffer = new byte[ (int)file.length() ];
-
- // Open a stream
- bis = new Base64.InputStream(
- new java.io.BufferedInputStream(
- new java.io.FileInputStream( file ) ), Base64.DECODE );
-
- // Read until done
- while( ( numBytes = bis.read( buffer, length, 4096 ) ) >= 0 )
- length += numBytes;
-
- // Save in a variable to return
- decodedData = new byte[ length ];
- System.arraycopy( buffer, 0, decodedData, 0, length );
-
- } // end try
- catch( java.io.IOException e )
- {
- System.err.println( "Error decoding from file " + filename );
- } // end catch: IOException
- finally
- {
- try{ bis.close(); } catch( Exception e) {}
- } // end finally
-
- return decodedData;
- } // end decodeFromFile
-
-
-
- /**
- * Convenience method for reading a binary file
- * and base64-encoding it.
- *
- * @param filename Filename for reading binary data
- * @return base64-encoded string or null if unsuccessful
- *
- * @since 2.1
- */
- public static String encodeFromFile( String filename )
- {
- String encodedData = null;
- Base64.InputStream bis = null;
- try
- {
- // Set up some useful variables
- java.io.File file = new java.io.File( filename );
- byte[] buffer = new byte[ (int)(file.length() * 1.4) ];
- int length = 0;
- int numBytes = 0;
-
- // Open a stream
- bis = new Base64.InputStream(
- new java.io.BufferedInputStream(
- new java.io.FileInputStream( file ) ), Base64.ENCODE );
-
- // Read until done
- while( ( numBytes = bis.read( buffer, length, 4096 ) ) >= 0 )
- length += numBytes;
-
- // Save in a variable to return
- encodedData = new String( buffer, 0, length, Base64.PREFERRED_ENCODING );
-
- } // end try
- catch( java.io.IOException e )
- {
- System.err.println( "Error encoding from file " + filename );
- } // end catch: IOException
- finally
- {
- try{ bis.close(); } catch( Exception e) {}
- } // end finally
-
- return encodedData;
- } // end encodeFromFile
-
-
-
-
- /* ******** I N N E R C L A S S I N P U T S T R E A M ******** */
-
-
-
- /**
- * A {@link Base64.InputStream} will read data from another
- * java.io.InputStream, given in the constructor,
- * and encode/decode to/from Base64 notation on the fly.
- *
- * @see Base64
- * @since 1.3
- */
- public static class InputStream extends java.io.FilterInputStream
- {
- private boolean encode; // Encoding or decoding
- private int position; // Current position in the buffer
- private byte[] buffer; // Small buffer holding converted data
- private int bufferLength; // Length of buffer (3 or 4)
- private int numSigBytes; // Number of meaningful bytes in the buffer
- private int lineLength;
- private boolean breakLines; // Break lines at less than 80 characters
-
-
- /**
- * Constructs a {@link Base64.InputStream} in DECODE mode.
- *
- * @param in the java.io.InputStream from which to read data.
- * @since 1.3
- */
- public InputStream( java.io.InputStream in )
- {
- this( in, DECODE );
- } // end constructor
-
-
- /**
- * Constructs a {@link Base64.InputStream} in
- * either ENCODE or DECODE mode.
- *
- * Valid options:
- * ENCODE or DECODE: Encode or Decode as data is read.
- * DONT_BREAK_LINES: don't break lines at 76 characters
- * (only meaningful when encoding)
- * Note: Technically, this makes your encoding non-compliant.
- *
- *
- * Example: new Base64.InputStream( in, Base64.DECODE )
- *
- *
- * @param in the java.io.InputStream from which to read data.
- * @param options Specified options
- * @see Base64#ENCODE
- * @see Base64#DECODE
- * @see Base64#DONT_BREAK_LINES
- * @since 2.0
- */
- public InputStream( java.io.InputStream in, int options )
- {
- super( in );
- this.breakLines = (options & DONT_BREAK_LINES) != DONT_BREAK_LINES;
- this.encode = (options & ENCODE) == ENCODE;
- this.bufferLength = encode ? 4 : 3;
- this.buffer = new byte[ bufferLength ];
- this.position = -1;
- this.lineLength = 0;
- } // end constructor
-
- /**
- * Reads enough of the input stream to convert
- * to/from Base64 and returns the next byte.
- *
- * @return next byte
- * @since 1.3
- */
- public int read() throws java.io.IOException
- {
- // Do we need to get data?
- if( position < 0 )
- {
- if( encode )
- {
- byte[] b3 = new byte[3];
- int numBinaryBytes = 0;
- for( int i = 0; i < 3; i++ )
- {
- try
- {
- int b = in.read();
-
- // If end of stream, b is -1.
- if( b >= 0 )
- {
- b3[i] = (byte)b;
- numBinaryBytes++;
- } // end if: not end of stream
-
- } // end try: read
- catch( java.io.IOException e )
- {
- // Only a problem if we got no data at all.
- if( i == 0 )
- throw e;
-
- } // end catch
- } // end for: each needed input byte
-
- if( numBinaryBytes > 0 )
- {
- encode3to4( b3, 0, numBinaryBytes, buffer, 0 );
- position = 0;
- numSigBytes = 4;
- } // end if: got data
- else
- {
- return -1;
- } // end else
- } // end if: encoding
-
- // Else decoding
- else
- {
- byte[] b4 = new byte[4];
- int i = 0;
- for( i = 0; i < 4; i++ )
- {
- // Read four "meaningful" bytes:
- int b = 0;
- do{ b = in.read(); }
- while( b >= 0 && DECODABET[ b & 0x7f ] <= WHITE_SPACE_ENC );
-
- if( b < 0 )
- break; // Reads a -1 if end of stream
-
- b4[i] = (byte)b;
- } // end for: each needed input byte
-
- if( i == 4 )
- {
- numSigBytes = decode4to3( b4, 0, buffer, 0 );
- position = 0;
- } // end if: got four characters
- else if( i == 0 ){
- return -1;
- } // end else if: also padded correctly
- else
- {
- // Must have broken out from above.
- throw new java.io.IOException( "Improperly padded Base64 input." );
- } // end
-
- } // end else: decode
- } // end else: get data
-
- // Got data?
- if( position >= 0 )
- {
- // End of relevant data?
- if( /*!encode &&*/ position >= numSigBytes )
- return -1;
-
- if( encode && breakLines && lineLength >= MAX_LINE_LENGTH )
- {
- lineLength = 0;
- return '\n';
- } // end if
- else
- {
- lineLength++; // This isn't important when decoding
- // but throwing an extra "if" seems
- // just as wasteful.
-
- int b = buffer[ position++ ];
-
- if( position >= bufferLength )
- position = -1;
-
- return b & 0xFF; // This is how you "cast" a byte that's
- // intended to be unsigned.
- } // end else
- } // end if: position >= 0
-
- // Else error
- else
- {
- // When JDK1.4 is more accepted, use an assertion here.
- throw new java.io.IOException( "Error in Base64 code reading stream." );
- } // end else
- } // end read
-
-
- /**
- * Calls {@link #read()} repeatedly until the end of stream
- * is reached or len bytes are read.
- * Returns number of bytes read into array or -1 if
- * end of stream is encountered.
- *
- * @param dest array to hold values
- * @param off offset for array
- * @param len max number of bytes to read into array
- * @return bytes read into array or -1 if end of stream is encountered.
- * @since 1.3
- */
- public int read( byte[] dest, int off, int len ) throws java.io.IOException
- {
- int i;
- int b;
- for( i = 0; i < len; i++ )
- {
- b = read();
-
- //if( b < 0 && i == 0 )
- // return -1;
-
- if( b >= 0 )
- dest[off + i] = (byte)b;
- else if( i == 0 )
- return -1;
- else
- break; // Out of 'for' loop
- } // end for: each byte read
- return i;
- } // end read
-
- } // end inner class InputStream
-
-
-
-
-
-
- /* ******** I N N E R C L A S S O U T P U T S T R E A M ******** */
-
-
-
- /**
- * A {@link Base64.OutputStream} will write data to another
- * java.io.OutputStream, given in the constructor,
- * and encode/decode to/from Base64 notation on the fly.
- *
- * @see Base64
- * @since 1.3
- */
- public static class OutputStream extends java.io.FilterOutputStream
- {
- private boolean encode;
- private int position;
- private byte[] buffer;
- private int bufferLength;
- private int lineLength;
- private boolean breakLines;
- private byte[] b4; // Scratch used in a few places
- private boolean suspendEncoding;
-
- /**
- * Constructs a {@link Base64.OutputStream} in ENCODE mode.
- *
- * @param out the java.io.OutputStream to which data will be written.
- * @since 1.3
- */
- public OutputStream( java.io.OutputStream out )
- {
- this( out, ENCODE );
- } // end constructor
-
-
- /**
- * Constructs a {@link Base64.OutputStream} in
- * either ENCODE or DECODE mode.
- *
- * Valid options:
- * ENCODE or DECODE: Encode or Decode as data is read.
- * DONT_BREAK_LINES: don't break lines at 76 characters
- * (only meaningful when encoding)
- * Note: Technically, this makes your encoding non-compliant.
- *
- *
- * Example: new Base64.OutputStream( out, Base64.ENCODE )
- *
- * @param out the java.io.OutputStream to which data will be written.
- * @param options Specified options.
- * @see Base64#ENCODE
- * @see Base64#DECODE
- * @see Base64#DONT_BREAK_LINES
- * @since 1.3
- */
- public OutputStream( java.io.OutputStream out, int options )
- {
- super( out );
- this.breakLines = (options & DONT_BREAK_LINES) != DONT_BREAK_LINES;
- this.encode = (options & ENCODE) == ENCODE;
- this.bufferLength = encode ? 3 : 4;
- this.buffer = new byte[ bufferLength ];
- this.position = 0;
- this.lineLength = 0;
- this.suspendEncoding = false;
- this.b4 = new byte[4];
- } // end constructor
-
-
- /**
- * Writes the byte to the output stream after
- * converting to/from Base64 notation.
- * When encoding, bytes are buffered three
- * at a time before the output stream actually
- * gets a write() call.
- * When decoding, bytes are buffered four
- * at a time.
- *
- * @param theByte the byte to write
- * @since 1.3
- */
- public void write(int theByte) throws java.io.IOException
- {
- // Encoding suspended?
- if( suspendEncoding )
- {
- super.out.write( theByte );
- return;
- } // end if: supsended
-
- // Encode?
- if( encode )
- {
- buffer[ position++ ] = (byte)theByte;
- if( position >= bufferLength ) // Enough to encode.
- {
- out.write( encode3to4( b4, buffer, bufferLength ) );
-
- lineLength += 4;
- if( breakLines && lineLength >= MAX_LINE_LENGTH )
- {
- out.write( NEW_LINE );
- lineLength = 0;
- } // end if: end of line
-
- position = 0;
- } // end if: enough to output
- } // end if: encoding
-
- // Else, Decoding
- else
- {
- // Meaningful Base64 character?
- if( DECODABET[ theByte & 0x7f ] > WHITE_SPACE_ENC )
- {
- buffer[ position++ ] = (byte)theByte;
- if( position >= bufferLength ) // Enough to output.
- {
- int len = Base64.decode4to3( buffer, 0, b4, 0 );
- out.write( b4, 0, len );
- //out.write( Base64.decode4to3( buffer ) );
- position = 0;
- } // end if: enough to output
- } // end if: meaningful base64 character
- else if( DECODABET[ theByte & 0x7f ] != WHITE_SPACE_ENC )
- {
- throw new java.io.IOException( "Invalid character in Base64 data." );
- } // end else: not white space either
- } // end else: decoding
- } // end write
-
-
-
- /**
- * Calls {@link #write(int)} repeatedly until len
- * bytes are written.
- *
- * @param theBytes array from which to read bytes
- * @param off offset for array
- * @param len max number of bytes to read into array
- * @since 1.3
- */
- public void write( byte[] theBytes, int off, int len ) throws java.io.IOException
- {
- // Encoding suspended?
- if( suspendEncoding )
- {
- super.out.write( theBytes, off, len );
- return;
- } // end if: supsended
-
- for( int i = 0; i < len; i++ )
- {
- write( theBytes[ off + i ] );
- } // end for: each byte written
-
- } // end write
-
-
-
- /**
- * Method added by PHIL. [Thanks, PHIL. -Rob]
- * This pads the buffer without closing the stream.
- */
- public void flushBase64() throws java.io.IOException
- {
- if( position > 0 )
- {
- if( encode )
- {
- out.write( encode3to4( b4, buffer, position ) );
- position = 0;
- } // end if: encoding
- else
- {
- throw new java.io.IOException( "Base64 input not properly padded." );
- } // end else: decoding
- } // end if: buffer partially full
-
- } // end flush
-
-
- /**
- * Flushes and closes (I think, in the superclass) the stream.
- *
- * @since 1.3
- */
- public void close() throws java.io.IOException
- {
- // 1. Ensure that pending characters are written
- flushBase64();
-
- // 2. Actually close the stream
- // Base class both flushes and closes.
- super.close();
-
- buffer = null;
- out = null;
- } // end close
-
-
-
- /**
- * Suspends encoding of the stream.
- * May be helpful if you need to embed a piece of
- * base640-encoded data in a stream.
- *
- * @since 1.5.1
- */
- public void suspendEncoding() throws java.io.IOException
- {
- flushBase64();
- this.suspendEncoding = true;
- } // end suspendEncoding
-
-
- /**
- * Resumes encoding of the stream.
- * May be helpful if you need to embed a piece of
- * base640-encoded data in a stream.
- *
- * @since 1.5.1
- */
- public void resumeEncoding()
- {
- this.suspendEncoding = false;
- } // end resumeEncoding
-
-
-
- } // end inner class OutputStream
-
-
-} // end class Base64
diff --git a/s3/perftest/src/main/resources/README b/s3/perftest/src/main/resources/README
deleted file mode 100644
index 3a8de1c414..0000000000
--- a/s3/perftest/src/main/resources/README
+++ /dev/null
@@ -1,84 +0,0 @@
-This is one of a collection of interface libraries that can be used to interact
-with the Amazon S3 system in a number of different languages. They each expose
-two main interface classes, AWSAuthConnection and QueryStringAuthGenerator.
-The first actually performs all the operations using the appropriate libraries
-for the language, including header signing. The second,
-QueryStringAuthGenerator, has the same interface, but instead of performing
-the operation, this class will return urls with the right query string
-authentication parameters set.
-
-
-Basic Operations:
-
-object requests:
-
-GetResponse get(bucketName, keyName) - retrieves an object
-GetResponse getACL(bucketName, keyName) - returns the xml acl doc
-Response put(bucketName, keyName, object) - writes an object
-Response putACL(bucketName, keyName, aclXMLDoc) - sets the xml acl doc
-Response delete(bucketName, keyName) - deletes an object
-
-bucket requests:
-
-Response createBucket(bucketName, location) - creates a bucket
-ListResponse listBucket(bucketName) - lists a bucket's contents
-LocationResponse getBucketLocation(bucketName) - return the location-constraint of this bucket
-GetResponse getBucketACL(bucketName) - returns the xml representation of this bucket's access control list
-Response putBucketAcl(bucketName, aclXMLDoc) - sets xml representation of the bucket acl
-Response deleteBucket(bucketName) - delete an empty bucket
-GetResponse getBucketLogging(bucketName) - returns the xml representation of this bucket's access logging configuration
-Response putBucketLogging(bucketName, loggingXMLDoc) - sets the xml representation of the bucket logging configuration
-
-ListAllMyBucketsResponse listAllMyBuckets() - returns a list of all buckets owned by this AWS Access Key Id
-
-
-
-Dependencies:
-
-None, beyond the standard libraries.
-
-
-Notes:
-
-Please note that this uses the public domain iHarder.net Base64 library. For updates to that library,
-see http://iharder.sourceforge.net/current/java/base64/ .
-
-If your bucket name contains periods, you will need to use a non-HTTPS connection as the SSL certificate
-presented by s3.amazonaws.com will not match if you do.
-
-Limitations:
-
-One of the main limitations of these sample AWSAuthConnection implementations
-is that the interfaces are not streaming. This means that you have to pass the
-data in as a string or as a byte array and the operation returns a string or a
-byte array back. This is conceptually simpler, and fine for smaller objects,
-but large objects, say a couple megabytes or greater, will show poor
-performance, since everything is being passed around in memory. More
-sophisticated libraries would pass streams in and out, and would only read the
-data on-demand, rather than storing it all in memory (S3 itself would have no
-problem with such streaming applications). Another upshot of this is that the
-interfaces are all blocking---that is, you cannot look at the data until all of
-it has downloaded. Again, this is fine for smaller objects, but unacceptable
-for larger ones.
-
-These libraries have nearly non-existent error handling. All errors from lower
-libraries are simply passed up. The response code in the connection object needs
-to be checked after each request to verify whether the request succeeded.
-
-Only the java library has proper handling for repeated headers. The others
-assume that each header will have only one value.
-
-It is our intention that these libraries act as a starting point for future
-development. They are meant to show off the various operations and provide an
-example of how to negotiate the authentication process.
-
-
-
-This software code is made available "AS IS" without warranties of any
-kind. You may copy, display, modify and redistribute the software
-code either by itself or as incorporated into your code; provided that
-you do not remove any proprietary notices. Your use of this software
-code is at your own risk and you waive any claim against Amazon
-Digital Services, Inc. or its affiliates with respect to your use of
-this software code. (c) 2006 Amazon Digital Services, Inc. or its
-affiliates.
diff --git a/s3/perftest/src/test/java/com/amazon/s3/AmazonPerformanceTest.java b/s3/perftest/src/test/java/com/amazon/s3/AmazonPerformanceTest.java
deleted file mode 100644
index 8b0482a89f..0000000000
--- a/s3/perftest/src/test/java/com/amazon/s3/AmazonPerformanceTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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 com.amazon.s3;
-
-import org.jclouds.aws.s3.reference.S3Constants;
-import org.testng.ITestContext;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Optional;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.ExecutionException;
-
-
-/**
- * Runs operations that amazon s3 sample code is capable of performing.
- *
- * @author Adrian Cole
- */
-@Test(sequential = true, timeOut = 2 * 60 * 1000, testName = "s3.AmazonPerformance")
-public class AmazonPerformanceTest extends BasePerformance {
- private AWSAuthConnection amzClient;
-
- @Override
- @BeforeTest
- @Parameters({S3Constants.PROPERTY_AWS_ACCESSKEYID,
- S3Constants.PROPERTY_AWS_SECRETACCESSKEY})
- protected void setUpCredentials(@Optional String AWSAccessKeyId,
- @Optional String AWSSecretAccessKey, ITestContext context) throws Exception {
- super.setUpCredentials(AWSAccessKeyId, AWSSecretAccessKey, context);
- amzClient = new AWSAuthConnection(AWSAccessKeyId, AWSSecretAccessKey,
- false);
- }
-
- @Override
- @Test(enabled = false)
- public void testPutFileSerial() throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Test(enabled = false)
- public void testPutFileParallel() throws InterruptedException,
- ExecutionException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Test(enabled = false)
- public void testPutInputStreamSerial() throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Test(enabled = false)
- public void testPutInputStreamParallel() throws InterruptedException,
- ExecutionException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Test(enabled = false)
- public void testPutStringSerial() throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Test(enabled = false)
- public void testPutStringParallel() throws InterruptedException,
- ExecutionException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected boolean putByteArray(String bucket, String key, byte[] data,
- String contentType) throws Exception {
- com.amazon.s3.S3Object object = new com.amazon.s3.S3Object(data, null);
- Map> headers = new TreeMap>();
- headers
- .put("Content-Type", Arrays
- .asList(new String[]{contentType}));
- return amzClient.put(bucket, key, object, headers).connection
- .getResponseMessage() != null;
- }
-
- @Override
- protected boolean putFile(String bucket, String key, File data,
- String contentType) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected boolean putInputStream(String bucket, String key,
- InputStream data, String contentType) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected boolean putString(String bucket, String key, String data,
- String contentType) throws Exception {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/s3/perftest/src/test/java/com/amazon/s3/BaseJCloudsPerformance.java b/s3/perftest/src/test/java/com/amazon/s3/BaseJCloudsPerformance.java
deleted file mode 100644
index db1aacf2ec..0000000000
--- a/s3/perftest/src/test/java/com/amazon/s3/BaseJCloudsPerformance.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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 com.amazon.s3;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.concurrent.TimeUnit;
-
-/**
- * // TODO: Adrian: Document this!
- *
- * @author Adrian Cole
- */
-public abstract class BaseJCloudsPerformance extends BasePerformance {
- // boolean get
- // (
- // int id) throws Exception {
- // S3Bucket s3Bucket = new S3Bucket();
- // s3Bucket.setName(bucketPrefix + "-jclouds-puts");
- // org.jclouds.aws.s3.domain.S3Object object = new
- // org.jclouds.aws.s3.domain.S3Object();
- // object.setKey(id + "");
- // //object.setContentType("text/plain");
- // object.setContentType("application/octetstream");
- // //object.setData("this is a test");
- // object.setData(test);
- // return clientProvider.getObject(s3Bucket,
- // object.getKey()).get(120,TimeUnit.SECONDS) !=
- // org.jclouds.aws.s3.domain.S3Object.NOT_FOUND;
-
- // }
-
- @Override
- protected boolean putByteArray(String bucket, String key, byte[] data,
- String contentType) throws Exception {
- org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
- key);
- object.getMetadata().setContentType(contentType);
- object.setData(data);
- return client.putObject(bucket, object).get(120, TimeUnit.SECONDS) != null;
- }
-
- @Override
- protected boolean putFile(String bucket, String key, File data,
- String contentType) throws Exception {
- org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
- key);
- object.getMetadata().setContentType(contentType);
- object.setData(data);
- return client.putObject(bucket, object).get(120, TimeUnit.SECONDS) != null;
- }
-
- @Override
- protected boolean putInputStream(String bucket, String key,
- InputStream data, String contentType) throws Exception {
- org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
- key);
- object.getMetadata().setContentType(contentType);
- object.setData(data);
- object.getMetadata().setSize(data.available());
- return client.putObject(bucket, object).get(120, TimeUnit.SECONDS) != null;
- }
-
- @Override
- protected boolean putString(String bucket, String key, String data,
- String contentType) throws Exception {
- org.jclouds.aws.s3.domain.S3Object object = new org.jclouds.aws.s3.domain.S3Object(
- key);
- object.getMetadata().setContentType(contentType);
- object.setData(data);
- return client.putObject(bucket, object).get(120, TimeUnit.SECONDS) != null;
- }
-}
diff --git a/s3/perftest/src/test/java/com/amazon/s3/BasePerformance.java b/s3/perftest/src/test/java/com/amazon/s3/BasePerformance.java
deleted file mode 100644
index 1724b24aba..0000000000
--- a/s3/perftest/src/test/java/com/amazon/s3/BasePerformance.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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 com.amazon.s3;
-
-import com.google.inject.Provider;
-import org.jclouds.aws.s3.S3IntegrationTest;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-import org.testng.ITestContext;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * // TODO: Adrian: Document this!
- *
- * @author Adrian Cole
- */
-@Test
-public abstract class BasePerformance extends S3IntegrationTest {
- protected boolean debugEnabled() {
- return false;
- }
-
- protected static int LOOP_COUNT = 100;
-
- protected ExecutorService exec;
- protected final String BUCKET_BYTES = bucketPrefix + "-bytes";
- protected final String BUCKET_INPUTSTREAM = bucketPrefix + "-inputstream";
- protected final String BUCKET_STRING = bucketPrefix + "-string";
- protected final String BUCKET_FILE = bucketPrefix + "-file";
- protected final String[] BUCKETS = {BUCKET_BYTES, BUCKET_INPUTSTREAM,
- BUCKET_STRING, BUCKET_FILE};
- protected PutBytesCallable putBytesCallable;
- protected PutFileCallable putFileCallable;
- protected PutInputStreamCallable putInputStreamCallable;
- protected PutStringCallable putStringCallable;
-
- protected CompletionService completer;
-
- @BeforeTest
- protected void setUpCallables() {
- putBytesCallable = new PutBytesCallable();
- putFileCallable = new PutFileCallable();
- putInputStreamCallable = new PutInputStreamCallable();
- putStringCallable = new PutStringCallable();
- exec = Executors.newCachedThreadPool();
- completer = new ExecutorCompletionService(exec);
- }
-
- @Override
- @BeforeTest
- protected void setUpClient(ITestContext context) throws Exception {
- super.setUpClient(context);
- for (String bucket : BUCKETS) {
- client.putBucketIfNotExists(bucket).get(10, TimeUnit.SECONDS);
- }
- }
-
- @AfterTest
- protected void tearDownExecutor() throws Exception {
- exec.shutdownNow();
- exec = null;
- }
-
- @Test(enabled = true)
- public void testPutBytesSerial() throws Exception {
- doSerial(putBytesCallable, LOOP_COUNT / 10);
- }
-
- @Test(enabled = true)
- public void testPutBytesParallel() throws InterruptedException,
- ExecutionException, TimeoutException {
- doParallel(putBytesCallable, LOOP_COUNT);
- }
-
- @Test(enabled = true)
- public void testPutFileSerial() throws Exception {
- doSerial(putFileCallable, LOOP_COUNT / 10);
- }
-
- @Test(enabled = true)
- public void testPutFileParallel() throws InterruptedException,
- ExecutionException, TimeoutException {
- doParallel(putFileCallable, LOOP_COUNT);
- }
-
- @Test(enabled = true)
- public void testPutInputStreamSerial() throws Exception {
- doSerial(putInputStreamCallable, LOOP_COUNT / 10);
- }
-
- @Test(enabled = true)
- public void testPutInputStreamParallel() throws InterruptedException,
- ExecutionException, TimeoutException {
- doParallel(putInputStreamCallable, LOOP_COUNT);
- }
-
- @Test(enabled = true)
- public void testPutStringSerial() throws Exception {
- doSerial(putStringCallable, LOOP_COUNT / 10);
- }
-
- @Test(enabled = true)
- public void testPutStringParallel() throws InterruptedException,
- ExecutionException, TimeoutException {
- doParallel(putStringCallable, LOOP_COUNT);
- }
-
- private void doSerial(Provider> provider, int loopCount)
- throws Exception, ExecutionException {
- for (int i = 0; i < loopCount; i++)
- assert provider.get().call();
- }
-
- private void doParallel(Provider> provider, int loopCount)
- throws InterruptedException, ExecutionException, TimeoutException {
- for (int i = 0; i < loopCount; i++)
- completer.submit(provider.get());
- for (int i = 0; i < loopCount; i++)
- assert completer.take().get(10, TimeUnit.SECONDS);
- }
-
- class PutBytesCallable implements Provider> {
- final AtomicInteger key = new AtomicInteger(0);
- protected byte[] test = new byte[1024 * 2];
-
- public Callable get() {
- return new Callable() {
- public Boolean call() throws Exception {
- return putByteArray(BUCKET_BYTES, key.getAndIncrement()
- + "", test, "application/octetstring");
- }
- };
-
- }
- }
-
- class PutFileCallable implements Provider> {
- final AtomicInteger key = new AtomicInteger(0);
- protected File file = new File("pom.xml");
-
- public Callable get() {
- return new Callable() {
- public Boolean call() throws Exception {
- return putFile(BUCKET_FILE, key.getAndIncrement() + "",
- file, "text/xml");
- }
- };
-
- }
- }
-
- class PutInputStreamCallable extends PutBytesCallable {
- final AtomicInteger key = new AtomicInteger(0);
-
- @Override
- public Callable get() {
- return new Callable() {
- public Boolean call() throws Exception {
- return putInputStream(BUCKET_INPUTSTREAM, key
- .getAndIncrement()
- + "", new ByteArrayInputStream(test),
- "application/octetstring");
- }
- };
-
- }
- }
-
- class PutStringCallable implements Provider> {
- final AtomicInteger key = new AtomicInteger(0);
- protected String testString = "hello world!";
-
- public Callable get() {
- return new Callable() {
- public Boolean call() throws Exception {
- return putString(BUCKET_STRING, key.getAndIncrement() + "",
- testString, "text/plain");
- }
- };
-
- }
- }
-
- protected abstract boolean putByteArray(String bucket, String key,
- byte[] data, String contentType) throws Exception;
-
- protected abstract boolean putFile(String bucket, String key, File data,
- String contentType) throws Exception;
-
- protected abstract boolean putInputStream(String bucket, String key,
- InputStream data, String contentType) throws Exception;
-
- protected abstract boolean putString(String bucket, String key,
- String data, String contentType) throws Exception;
-
- // private class BucketDeleter implements Callable {
- // private BucketDeleter(S3Bucket bucket) {
- // this.bucket = bucket;
- // }
- //
- // private S3Bucket bucket;
- //
- // @Override
- // public String toString() {
- // return "BucketDeleter{" + "bucket=" + bucket + '}';
- // }
- //
- // public Boolean call() throws Exception {
- // bucket =
- // clientProvider.get(10,TimeUnit.SECONDS).getBucket(bucket).get(10,TimeUnit.SECONDS);
- // List> deletes = new ArrayList>();
- // for (org.jclouds.aws.s3.domain.S3Object object : bucket
- // .getContents()) {
- // deletes.add(clientProvider.get(10,TimeUnit.SECONDS).deleteObject(bucket,
- // object.getKey()));
- // }
- // for (Future isdeleted : deletes)
- // assert isdeleted.get(10,TimeUnit.SECONDS) :
- // String.format("failed to delete %1$ss",
- // isdeleted);
- // return
- // clientProvider.get(10,TimeUnit.SECONDS).deleteBucket(bucket).get(10,TimeUnit.SECONDS);
- // }
- // }
-}
diff --git a/s3/perftest/src/test/java/com/amazon/s3/DateServiceTest.java b/s3/perftest/src/test/java/com/amazon/s3/DateServiceTest.java
deleted file mode 100644
index e0fb57a9d3..0000000000
--- a/s3/perftest/src/test/java/com/amazon/s3/DateServiceTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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 com.amazon.s3;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import org.jclouds.aws.PerformanceTest;
-import org.jclouds.aws.s3.util.DateService;
-import org.joda.time.DateTime;
-import org.testng.annotations.Test;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.SimpleTimeZone;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorCompletionService;
-
-/**
- * Compares performance of date operations
- *
- * @author Adrian Cole
- */
-@Test(sequential = true, timeOut = 2 * 60 * 1000, testName = "s3.DateTest")
-public class DateServiceTest extends PerformanceTest {
- Injector i = Guice.createInjector();
-
- DateService utils = i.getInstance(DateService.class);
- SimpleDateFormat dateParser;
-
- public DateServiceTest() {
- this.dateParser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
- this.dateParser.setTimeZone(new SimpleTimeZone(0, "GMT"));
- }
-
- Date amazonDateFromString(String toParse) throws ParseException {
- return this.dateParser.parse(toParse);
- }
-
- private static String toParse = "2009-03-12T02:00:07.000Z";
-
- @Test
- public void testParseDateSameAsAmazon() throws ParseException,
- ExecutionException, InterruptedException {
- Date java = dateParser.parse(toParse);
- DateTime joda = utils.dateTimeFromXMLFormat(toParse);
- assert java.equals(joda.toDate());
- }
-
- @Test
- public void testTimeStampDateSameAsAmazon() throws ExecutionException,
- InterruptedException {
- String java = AWSAuthConnection.httpDate();
- String joda = utils.timestampAsHeaderString();
- assert java.equals(joda);
- }
-
- @Test
- public void testToHeaderString() throws ExecutionException,
- InterruptedException {
- String joda1 = utils.toHeaderString(new DateTime());
- String joda = utils.timestampAsHeaderString();
- assert joda1.equals(joda);
- }
-
- @Test
- void testTimeStampSerialResponseTime() throws ExecutionException,
- InterruptedException {
- for (int i = 0; i < LOOP_COUNT; i++)
- utils.timestampAsHeaderString();
- }
-
- @Test
- void testAmazonTimeStampSerialResponseTime() {
- for (int i = 0; i < LOOP_COUNT; i++)
- AWSAuthConnection.httpDate();
- }
-
- @Test
- void testTimeStampParallelResponseTime() throws InterruptedException,
- ExecutionException {
- CompletionService completer = new ExecutorCompletionService(
- exec);
- for (int i = 0; i < LOOP_COUNT; i++)
- completer.submit(new Callable() {
- public Boolean call() throws ExecutionException,
- InterruptedException {
- utils.timestampAsHeaderString();
- return true;
- }
- });
- for (int i = 0; i < LOOP_COUNT; i++)
- assert completer.take().get();
- }
-
- @Test
- void testAmazonTimeStampParallelResponseTime() throws InterruptedException,
- ExecutionException {
- CompletionService completer = new ExecutorCompletionService(
- exec);
- for (int i = 0; i < LOOP_COUNT; i++)
- completer.submit(new Callable() {
- public Boolean call() {
- AWSAuthConnection.httpDate();
- return true;
- }
- });
- for (int i = 0; i < LOOP_COUNT; i++)
- assert completer.take().get();
- }
-
- @Test
- void testParseDateSerialResponseTime() throws ExecutionException,
- InterruptedException {
- for (int i = 0; i < LOOP_COUNT; i++)
- utils.dateTimeFromXMLFormat(toParse);
- }
-
- @Test
- void testAmazonParseDateSerialResponseTime() {
- for (int i = 0; i < LOOP_COUNT; i++)
- AWSAuthConnection.httpDate();
- }
-
- @Test
- void testParseDateParallelResponseTime() throws InterruptedException,
- ExecutionException {
- CompletionService completer = new ExecutorCompletionService(
- exec);
-
- for (int i = 0; i < LOOP_COUNT; i++)
- completer.submit(new Callable() {
- public Boolean call() throws ExecutionException,
- InterruptedException {
- utils.dateTimeFromXMLFormat(toParse);
- return true;
- }
- });
- for (int i = 0; i < LOOP_COUNT; i++)
- assert completer.take().get();
- }
-
- @Test
- void testAmazonParseDateParallelResponseTime() throws InterruptedException,
- ExecutionException {
- CompletionService completer = new ExecutorCompletionService(
- exec);
-
- for (int i = 0; i < LOOP_COUNT; i++)
- completer.submit(new Callable() {
- public Boolean call() {
- AWSAuthConnection.httpDate();
- return true;
- }
- });
- for (int i = 0; i < LOOP_COUNT; i++)
- assert completer.take().get();
- }
-
-}
\ No newline at end of file
diff --git a/s3/perftest/src/test/java/com/amazon/s3/JCloudsNioPerformanceTest.java b/s3/perftest/src/test/java/com/amazon/s3/JCloudsNioPerformanceTest.java
deleted file mode 100644
index ba37b83893..0000000000
--- a/s3/perftest/src/test/java/com/amazon/s3/JCloudsNioPerformanceTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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 com.amazon.s3;
-
-
-import java.util.Properties;
-
-import org.jclouds.http.httpnio.config.HttpNioConnectionPoolClientModule;
-import org.testng.annotations.Test;
-
-import com.google.inject.Module;
-
-@Test(sequential=true, testName = "s3.JCloudsNioPerformance")
-public class JCloudsNioPerformanceTest extends BaseJCloudsPerformance {
-
- @Override
- protected Properties buildS3Properties(String AWSAccessKeyId,
- String AWSSecretAccessKey) {
- Properties properties = super.buildS3Properties(AWSAccessKeyId, AWSSecretAccessKey);
- properties.setProperty("jclouds.http.pool.max_connection_reuse", "75");
- properties.setProperty("jclouds.http.pool.max_session_failures", "2");
- properties.setProperty("jclouds.http.pool.request_invoker_threads", "1");
- properties.setProperty("jclouds.http.pool.io_worker_threads", "2");
- properties.setProperty("jclouds.pool.max_connections", "12");
- return properties;
- }
-
- @Override
- protected Module createHttpModule() {
- return new HttpNioConnectionPoolClientModule();
- }
-}
\ No newline at end of file
diff --git a/s3/perftest/src/test/java/com/amazon/s3/JCloudsPerformanceTest.java b/s3/perftest/src/test/java/com/amazon/s3/JCloudsPerformanceTest.java
deleted file mode 100644
index 05d7149bb6..0000000000
--- a/s3/perftest/src/test/java/com/amazon/s3/JCloudsPerformanceTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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 com.amazon.s3;
-
-import org.testng.annotations.Test;
-
-/**
- * Tests the default JClouds client.
- *
- * @author Adrian Cole
- *
- */
-@Test(sequential = true, timeOut = 2 * 60 * 1000, testName = "s3.JCloudsPerformance")
-public class JCloudsPerformanceTest extends BaseJCloudsPerformance {
-
-}
\ No newline at end of file
diff --git a/s3/perftest/src/test/java/com/amazon/s3/Jets3tPerformanceTest.java b/s3/perftest/src/test/java/com/amazon/s3/Jets3tPerformanceTest.java
deleted file mode 100644
index a8518d6f19..0000000000
--- a/s3/perftest/src/test/java/com/amazon/s3/Jets3tPerformanceTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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 com.amazon.s3;
-
-import org.jets3t.service.S3Service;
-import org.jets3t.service.impl.rest.httpclient.RestS3Service;
-import org.jets3t.service.security.AWSCredentials;
-import org.testng.ITestContext;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.concurrent.ExecutionException;
-
-/**
- * Runs operations that jets3t is capable of performing.
- *
- * @author Adrian Cole
- */
-@Test(sequential = true, timeOut = 2 * 60 * 1000, testName = "s3.Jets3tPerformance")
-public class Jets3tPerformanceTest extends BasePerformance {
- private S3Service jetClient;
-
- @Override
- protected void setUpCredentials(String AWSAccessKeyId, String AWSSecretAccessKey, ITestContext context)
- throws Exception {
- super.setUpCredentials(AWSAccessKeyId, AWSSecretAccessKey, context);
- jetClient = new RestS3Service(new AWSCredentials(AWSAccessKeyId,
- AWSSecretAccessKey));
- }
-
- @Override
- @Test(enabled = false)
- public void testPutStringSerial() throws Exception {
- throw new UnsupportedOperationException();
- }
-
-
- @Override
- @Test(enabled = false)
- public void testPutBytesSerial() throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Test(enabled = false)
- public void testPutStringParallel() throws InterruptedException,
- ExecutionException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Test(enabled = false)
- public void testPutBytesParallel() throws InterruptedException,
- ExecutionException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Test(enabled = false)
- public void testPutInputStreamParallel() throws InterruptedException,
- ExecutionException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Test(enabled = false)
- public void testPutFileParallel() throws InterruptedException,
- ExecutionException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Test(enabled = false)
- protected boolean putByteArray(String bucket, String key, byte[] data,
- String contentType) throws Exception {
- throw new UnsupportedOperationException();
-
- }
-
- @Override
- protected boolean putFile(String bucket, String key, File data,
- String contentType) throws Exception {
- org.jets3t.service.model.S3Object object = new org.jets3t.service.model.S3Object(
- key);
- object.setContentType(contentType);
- object.setDataInputFile(data);
- object.setContentLength(data.length());
- return jetClient.putObject(bucket, object) != null;
- }
-
- @Override
- protected boolean putInputStream(String bucket, String key,
- InputStream data, String contentType) throws Exception {
- org.jets3t.service.model.S3Object object = new org.jets3t.service.model.S3Object(
- key);
- object.setContentType(contentType);
- object.setDataInputStream(data);
- object.setContentLength(data.available());
- return jetClient.putObject(bucket, object) != null;
- }
-
- @Override
- protected boolean putString(String bucket, String key, String data,
- String contentType) throws Exception {
- throw new UnsupportedOperationException();
- }
-
-}
\ No newline at end of file
diff --git a/s3/perftest/src/test/java/com/amazon/s3/S3ParserTest.java b/s3/perftest/src/test/java/com/amazon/s3/S3ParserTest.java
deleted file mode 100644
index 49dbf71cde..0000000000
--- a/s3/perftest/src/test/java/com/amazon/s3/S3ParserTest.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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 com.amazon.s3;
-
-import org.apache.commons.io.IOUtils;
-import org.joda.time.DateTime;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorCompletionService;
-
-/**
- * Compares performance of xml parsing apis.
- *
- * @author Adrian Cole
- */
-@Test(sequential = true, timeOut = 2 * 60 * 1000, testName = "s3.S3ParserTest")
-public class S3ParserTest extends org.jclouds.aws.s3.commands.S3ParserTest {
-
- class MockHttpURLConnection extends HttpURLConnection {
- private String content;
-
- @Override
- public InputStream getInputStream() throws IOException {
- return IOUtils.toInputStream(content);
- }
-
- protected MockHttpURLConnection(String content) {
- super(null);
- this.content = content;
- }
-
- public void disconnect() {
- }
-
- public boolean usingProxy() {
- return false;
- }
-
- @Override
- public int getResponseCode() throws IOException {
- return 200;
- }
-
- public void connect() throws IOException {
- }
- }
-
- @Test
- void testAmazonParseListAllMyBucketsSerialResponseTime() throws IOException {
- for (int i = 0; i < LOOP_COUNT; i++)
- runAmazonParseListAllMyBuckets();
- }
-
- @Test
- void testAmazonParseListAllMyBucketsParallelResponseTime()
- throws InterruptedException, ExecutionException {
- CompletionService completer = new ExecutorCompletionService(
- exec);
-
- for (int i = 0; i < LOOP_COUNT; i++)
- completer.submit(new Callable() {
- public Boolean call() throws IOException {
- runAmazonParseListAllMyBuckets();
- return true;
- }
- });
- for (int i = 0; i < LOOP_COUNT; i++)
- assert completer.take().get();
- }
-
- @SuppressWarnings("unchecked")
- @Test(enabled = false)
- public void testAmazonCanParseListAllMyBuckets() throws IOException {
- ListAllMyBucketsResponse response = runAmazonParseListAllMyBuckets();
- List buckets = response.entries;
- Bucket bucket1 = (Bucket) buckets.get(0);
- assert bucket1.name.equals("adrianjbosstest");
- Date expectedDate1 = new DateTime("2009-03-12T02:00:07.000Z").toDate();
- Date date1 = bucket1.creationDate;
- assert date1.toString().equals(expectedDate1.toString());
- Bucket bucket2 = (Bucket) buckets.get(1);
- assert bucket2.name.equals("adrianjbosstest2");
- Date expectedDate2 = new DateTime("2009-03-12T02:00:09.000Z").toDate();
- Date date2 = bucket2.creationDate;
- assert date2.toString().equals(expectedDate2.toString());
- assert buckets.size() == 2;
- }
-
- private ListAllMyBucketsResponse runAmazonParseListAllMyBuckets()
- throws IOException {
- ListAllMyBucketsResponse response = new ListAllMyBucketsResponse(
- new MockHttpURLConnection(listAllMyBucketsResultOn200));
- return response;
- }
-
- public void testAmazonCanParseListBucketResult() throws IOException {
- ListBucketResponse response = runAmazonParseListBucketResult();
- ListEntry content = (ListEntry) response.entries.get(0);
- assert content.key.equals("3366");
- assert content.lastModified.equals(new DateTime(
- "2009-03-12T02:00:13.000Z").toDate());
- assert content.eTag.equals("\"9d7bb64e8e18ee34eec06dd2cf37b766\"");
- assert content.size == 136;
- assert content.owner.id
- .equals("e1a5f66a480ca99a4fdfe8e318c3020446c9989d7004e7778029fbcc5d990fa0");
- assert content.owner.displayName.equals("ferncam");
- assert content.storageClass.equals("STANDARD");
- }
-
- private ListBucketResponse runAmazonParseListBucketResult()
- throws IOException {
- ListBucketResponse response = new ListBucketResponse(
- new MockHttpURLConnection(listBucketResult));
- return response;
- }
-
- @Test
- void testAmazonParseListBucketResultSerialResponseTime() throws IOException {
- for (int i = 0; i < LOOP_COUNT; i++)
- runAmazonParseListBucketResult();
- }
-
- @Test
- void testAmazonParseListBucketResultParallelResponseTime()
- throws InterruptedException, ExecutionException {
- CompletionService completer = new ExecutorCompletionService(
- exec);
-
- for (int i = 0; i < LOOP_COUNT; i++)
- completer.submit(new Callable() {
- public Boolean call() throws IOException {
- runAmazonParseListBucketResult();
- return true;
- }
- });
- for (int i = 0; i < LOOP_COUNT; i++)
- assert completer.take().get();
- }
-
-}
diff --git a/s3/perftest/src/test/java/com/amazon/s3/S3UtilsTest.java b/s3/perftest/src/test/java/com/amazon/s3/S3UtilsTest.java
deleted file mode 100644
index 403ece911f..0000000000
--- a/s3/perftest/src/test/java/com/amazon/s3/S3UtilsTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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 com.amazon.s3;
-
-import org.testng.annotations.Test;
-
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorCompletionService;
-
-/**
- * Compares performance of encryption operations.
- *
- * @author Adrian Cole
- *
- */
-@Test(sequential = true, timeOut = 2 * 60 * 1000, testName = "s3.S3UtilsTest")
-public class S3UtilsTest extends org.jclouds.aws.s3.S3UtilsTest {
-
- @Test(dataProvider = "hmacsha1")
- void testAmazonSampleDigestSerialResponseTime(byte[] key, String message, String base64Digest) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException {
- for (int i = 0; i < 10000; i++)
- testAmazonSampleDigest(key, message, base64Digest);
- }
-
- @Test(dataProvider = "hmacsha1")
- public void testAmazonSampleDigest(byte[] key, String message, String base64Digest) {
- String encoded = Utils.encode(new String(key), message, false);
- assert encoded.equals(base64Digest);
- }
-
- @Test(dataProvider = "hmacsha1")
- void testAmazonSampleDigestParallelResponseTime(final byte[] key, final String message, final String base64Digest) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, InterruptedException, ExecutionException {
- CompletionService completer = new ExecutorCompletionService(exec);
- for (int i = 0; i < 10000; i++)
- completer.submit(new Callable() {
- public Boolean call() {
- try {
- testAmazonSampleDigest(key, message, base64Digest);
- return true;
- } catch (Exception e) {
- return false;
- }
- }
- });
- for (int i = 0; i < 10000; i++) assert completer.take().get();
- }
-}
\ No newline at end of file
diff --git a/s3/pom.xml b/s3/pom.xml
deleted file mode 100644
index 1cc9c68760..0000000000
--- a/s3/pom.xml
+++ /dev/null
@@ -1,184 +0,0 @@
-
-
-
-
- org.jclouds
- jclouds-project
- 1.0-SNAPSHOT
- ../project/pom.xml
-
- 4.0.0
- org.jclouds
- jclouds-s3
- jclouds Amazon S3 Components Core
- jar
- jclouds Core components to access Amazon S3
-
-
- scm:svn:http://jclouds.googlecode.com/svn/trunk/s3
- scm:svn:https://jclouds.googlecode.com/svn/trunk/s3
- http://jclouds.googlecode.com/svn/trunk/s3
-
-
-
-
-
- http://apache.rediris.es/maven/binaries/apache-maven-2.1.0-bin.tar.bz2
-
- 9268c9de2cccfd0d8fbcdbcfaf517a87
-
-
-
-
- ${project.groupId}
- jclouds-core
- ${project.version}
-
-
- joda-time
- joda-time
- 1.6
-
-
- bouncycastle
- bcprov-jdk15
- 140
-
-
- xstream
- xstream
- 1.2
- test
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.4.3
-
-
- integration
- integration-test
-
- test
-
-
-
-
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
-
-
-
- jclouds.s3.httpstream.url
- ${jclouds.s3.httpstream.url}
-
-
- jclouds.s3.httpstream.md5
- ${jclouds.s3.httpstream.md5}
-
-
-
-
-
-
-
-
- **/*IntegrationTest.java
- **/*LiveTest.java
-
-
-
-
-
-
-
- live
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.4.3
-
-
- integration
- integration-test
-
- test
-
-
-
-
- none
-
-
- **/*IntegrationTest.java
- **/*LiveTest.java
-
-
-
- jclouds.aws.accesskeyid
- ${jclouds.aws.accesskeyid}
-
-
- jclouds.aws.secretaccesskey
- ${jclouds.aws.secretaccesskey}
-
-
- jclouds.s3.httpstream.url
- ${jclouds.s3.httpstream.url}
-
-
- jclouds.s3.httpstream.md5
- ${jclouds.s3.httpstream.md5}
-
-
-
-
-
-
-
-
-
-
-
diff --git a/s3/samples/googleappengine/README.txt b/s3/samples/googleappengine/README.txt
deleted file mode 100644
index 6221dd9b45..0000000000
--- a/s3/samples/googleappengine/README.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-====
-
- Copyright (C) 2009 Adrian Cole
-
- ====================================================================
- 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.
- ====================================================================
-====
-This samples uses the Google App Engine for Java SDK located at http://googleappengine.googlecode.com/files/appengine-java-sdk-1.2.0.zip
-
-Please unzip the above file and modify your maven settings.xml like below before attempting to run 'mvn install'
-
-
- appengine
-
- true
-
-
- /path/to/appengine-java-sdk-1.2.0
-
-
-
-
- aws
-
- true
-
-
- YOUR_ACCESS_KEY_ID
- YOUR_SECRET_KEY
-
-
-
-
-
- jclouds
- http://jclouds.googlecode.com/svn/trunk/repo
-
-
diff --git a/s3/samples/googleappengine/pom.xml b/s3/samples/googleappengine/pom.xml
deleted file mode 100644
index 235cadfc70..0000000000
--- a/s3/samples/googleappengine/pom.xml
+++ /dev/null
@@ -1,194 +0,0 @@
-
-
-
-
- jclouds-project
- org.jclouds
- 1.0-SNAPSHOT
- ../../../project/pom.xml
-
- 4.0.0
- jclouds-gae-s3-example
- war
- JClouds Sample for Google App Engine
- JClouds Sample for Google App Engine
-
-
-
- /Users/adriancole/Desktop/appengine-java-sdk-1.2.0
- localhost
- 8088
-
-
-
-
-
-
- guice-snapshot
- http://guice-maven.googlecode.com/svn/trunk
-
-
-
-
-
- Main Maven Repo
- http://repo1.maven.org/maven2/
-
-
-
-
-
- ${project.groupId}
- jclouds-gae
- ${project.version}
-
-
- ${project.groupId}
- jclouds-s3
- ${project.version}
-
-
- ${project.groupId}
- jclouds-s3
- ${project.version}
- test
- test-jar
-
-
- com.google.code.guice
- guice-servlet
- 2.0-r943
-
-
- standard
- taglibs
- 1.1.2
- jar
- runtime
-
-
- jstl
- javax.servlet
- 1.1.2
- jar
- compile
-
-
- org.apache.geronimo.specs
- geronimo-el_1.0_spec
- 1.0.1
- compile
-
-
- org.apache.geronimo.specs
- geronimo-jsp_2.1_spec
- 1.0.1
- provided
-
-
- org.apache.geronimo.specs
- geronimo-servlet_2.5_spec
- 1.2
- provided
-
-
-
- com.google.appengine
- appengine-tools-api
- 1.2.0
- system
- ${appengine.home}/lib/appengine-tools-api.jar
-
-
-
-
- ${project.artifactId}
- src/it/java
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.4.3
-
-
- integration
- integration-test
-
- test
-
-
- target/test-classes
-
-
- jclouds.aws.accesskeyid
- ${jclouds.aws.accesskeyid}
-
-
- jclouds.aws.secretaccesskey
- ${jclouds.aws.secretaccesskey}
-
-
- appengine.home
- ${appengine.home}
-
-
- devappserver.address
- ${devappserver.address}
-
-
- devappserver.port
- ${devappserver.port}
-
-
- warfile
- ${project.build.directory}/${project.artifactId}
-
-
-
- ${appengine.home}/lib/appengine-tools-api.jar
-
-
-
- true
- ${appengine.home}/bin
- ${appengine.home}/lib
- ${appengine.home}/config/sdk
-
-
-
-
-
-
- target/classes
-
-
-
-
-
-
diff --git a/s3/samples/googleappengine/src/it/java/org/jclouds/samples/googleappengine/functest/BaseGoogleAppEngineTest.java b/s3/samples/googleappengine/src/it/java/org/jclouds/samples/googleappengine/functest/BaseGoogleAppEngineTest.java
deleted file mode 100644
index d96d535231..0000000000
--- a/s3/samples/googleappengine/src/it/java/org/jclouds/samples/googleappengine/functest/BaseGoogleAppEngineTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.samples.googleappengine.functest;
-
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Properties;
-
-import org.testng.annotations.AfterTest;
-
-import com.google.appengine.tools.KickStart;
-
-/**
- * Basic functionality to start a local google app engine instance.
- *
- * @author Adrian Cole
- *
- */
-public abstract class BaseGoogleAppEngineTest {
-
- Thread server;
- URL url;
-
- protected void writePropertiesAndStartServer(final String address,
- final String port, final String warfile, Properties props)
- throws IOException, FileNotFoundException, InterruptedException {
- url = new URL(String.format("http://%1$s:%2$s", address, port));
-
- props.store(new FileOutputStream(String.format(
- "%1$s/WEB-INF/jclouds.properties", warfile)), "test");
- this.server = new Thread(new Runnable() {
- public void run() {
- KickStart
- .main(new String[] {
- "com.google.appengine.tools.development.DevAppServerMain",
- "--disable_update_check", "-a", address, "-p",
- port, warfile });
-
- }
-
- });
- server.start();
- Thread.sleep(7 * 1000);
- }
-
- @SuppressWarnings("deprecation")
- @AfterTest
- public void stopDevAppServer() throws Exception {
- server.stop();
- }
-
-}
\ No newline at end of file
diff --git a/s3/samples/googleappengine/src/it/java/org/jclouds/samples/googleappengine/functest/GoogleAppEngineTest.java b/s3/samples/googleappengine/src/it/java/org/jclouds/samples/googleappengine/functest/GoogleAppEngineTest.java
deleted file mode 100644
index 51240ae7f3..0000000000
--- a/s3/samples/googleappengine/src/it/java/org/jclouds/samples/googleappengine/functest/GoogleAppEngineTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.samples.googleappengine.functest;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Properties;
-
-import org.apache.commons.io.IOUtils;
-import org.jclouds.aws.s3.reference.S3Constants;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Optional;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-
-/**
- * Starts up the Google App Engine for Java Development environment and deploys
- * an application which tests S3.
- *
- * @author Adrian Cole
- *
- */
-@Test(groups = "integration", enabled = true, sequential = true, testName = "functionalTests")
-public class GoogleAppEngineTest extends BaseGoogleAppEngineTest {
-
- private static final String sysAWSAccessKeyId = System
- .getProperty(S3Constants.PROPERTY_AWS_ACCESSKEYID);
- private static final String sysAWSSecretAccessKey = System
- .getProperty(S3Constants.PROPERTY_AWS_SECRETACCESSKEY);
-
- @BeforeTest
- @Parameters( { "warfile", "devappserver.address", "devappserver.port",
- S3Constants.PROPERTY_AWS_ACCESSKEYID,
- S3Constants.PROPERTY_AWS_SECRETACCESSKEY })
- public void startDevAppServer(final String warfile, final String address,
- final String port, @Optional String AWSAccessKeyId,
- @Optional String AWSSecretAccessKey) throws Exception {
- AWSAccessKeyId = AWSAccessKeyId != null ? AWSAccessKeyId
- : sysAWSAccessKeyId;
- AWSSecretAccessKey = AWSSecretAccessKey != null ? AWSSecretAccessKey
- : sysAWSSecretAccessKey;
-
- checkNotNull(AWSAccessKeyId, "AWSAccessKeyId");
- checkNotNull(AWSSecretAccessKey, "AWSSecretAccessKey");
-
- Properties props = new Properties();
- props.put(S3Constants.PROPERTY_AWS_ACCESSKEYID, AWSAccessKeyId);
- props.put(S3Constants.PROPERTY_AWS_SECRETACCESSKEY, AWSSecretAccessKey);
- writePropertiesAndStartServer(address, port, warfile, props);
- }
-
- @Test
- public void shouldPass() throws InterruptedException, IOException {
- InputStream i = url.openStream();
- String string = IOUtils.toString(i);
- assert string.indexOf("Hello World!") >= 0 : string;
- }
-
- @Test(invocationCount = 5, enabled = true)
- public void testGuiceJCloudsSerial() throws InterruptedException,
- IOException {
- URL gurl = new URL(url, "/guice/listbuckets.s3");
- InputStream i = gurl.openStream();
- String string = IOUtils.toString(i);
- assert string.indexOf("List") >= 0 : string;
- }
-
- @Test(invocationCount = 50, enabled = true, threadPoolSize = 10)
- public void testGuiceJCloudsParallel() throws InterruptedException,
- IOException {
- URL gurl = new URL(url, "/guice/listbuckets.s3");
- InputStream i = gurl.openStream();
- String string = IOUtils.toString(i);
- assert string.indexOf("List") >= 0 : string;
- }
-}
diff --git a/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/JCloudsServlet.java b/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/JCloudsServlet.java
deleted file mode 100644
index aac9157983..0000000000
--- a/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/JCloudsServlet.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.samples.googleappengine;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import javax.annotation.Resource;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jclouds.aws.s3.S3Context;
-import org.jclouds.aws.s3.S3ResponseException;
-import org.jclouds.aws.s3.domain.S3Bucket;
-import org.jclouds.logging.Logger;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-/**
- * Shows an example of how to use @{link S3Connection} injected with Guice.
- *
- * @author Adrian Cole
- */
-@Singleton
-public class JCloudsServlet extends HttpServlet {
- private static final long serialVersionUID = 1L;
-
- @Inject
- S3Context context;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Override
- protected void doGet(HttpServletRequest httpServletRequest,
- HttpServletResponse httpServletResponse) throws ServletException,
- IOException {
- httpServletResponse.setContentType("text/plain");
- Writer writer = httpServletResponse.getWriter();
- try {
- List myBuckets = context.getConnection()
- .listOwnedBuckets().get(10, TimeUnit.SECONDS);
- writer.write("List:\n");
- for (S3Bucket.Metadata bucket : myBuckets) {
- writer.write(String.format(" %1$s", bucket));
- try {
- writer.write(String.format(": %1$s entries%n", context
- .createInputStreamMap(bucket.getName()).size()));
- } catch (S3ResponseException e) {
- String message = String.format(
- ": unable to list entries due to: %1$s%n", e
- .getError().getCode());
- writer.write(message);
- logger.warn(e, "message");
- }
-
- }
- } catch (Exception e) {
- throw new ServletException(e);
- }
- writer.flush();
- writer.close();
- }
-}
\ No newline at end of file
diff --git a/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java b/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java
deleted file mode 100644
index e5e0900c89..0000000000
--- a/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.samples.googleappengine.config;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-import javax.servlet.ServletContextEvent;
-
-import org.apache.commons.io.IOUtils;
-import org.jclouds.aws.s3.S3Context;
-import org.jclouds.aws.s3.S3ContextFactory;
-import org.jclouds.aws.s3.reference.S3Constants;
-import org.jclouds.gae.config.URLFetchServiceClientModule;
-import org.jclouds.samples.googleappengine.JCloudsServlet;
-
-
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.servlet.GuiceServletContextListener;
-import com.google.inject.servlet.ServletModule;
-
-/**
- * Setup Logging and create Injector for use in testing S3.
- *
- * @author Adrian Cole
- *
- */
-public class GuiceServletConfig extends GuiceServletContextListener {
- @Inject
- S3Context context;
- String accessKeyId;
- String secretAccessKey;
-
- @Override
- public void contextInitialized(ServletContextEvent servletContextEvent) {
- Properties props = loadJCloudsProperties(servletContextEvent);
- this.accessKeyId = props
- .getProperty(S3Constants.PROPERTY_AWS_ACCESSKEYID);
- this.secretAccessKey = props
- .getProperty(S3Constants.PROPERTY_AWS_SECRETACCESSKEY);
- super.contextInitialized(servletContextEvent);
- }
-
- private Properties loadJCloudsProperties(
- ServletContextEvent servletContextEvent) {
- InputStream input = servletContextEvent.getServletContext()
- .getResourceAsStream("/WEB-INF/jclouds.properties");
- Properties props = new Properties();
- try {
- props.load(input);
- } catch (IOException e) {
- throw new RuntimeException(e);
- } finally {
- IOUtils.closeQuietly(input);
- }
- return props;
- }
-
- @Override
- protected Injector getInjector() {
- return S3ContextFactory.createInjector(accessKeyId, secretAccessKey,
- false, new URLFetchServiceClientModule(),
- new ServletModule() {
- @Override
- protected void configureServlets() {
- serve("*.s3").with(JCloudsServlet.class);
- requestInjection(this);
- }
- });
- }
-
- @Override
- public void contextDestroyed(ServletContextEvent servletContextEvent) {
- context.close();
- super.contextDestroyed(servletContextEvent);
- }
-}
\ No newline at end of file
diff --git a/s3/samples/googleappengine/src/main/webapp/WEB-INF/appengine-web.xml b/s3/samples/googleappengine/src/main/webapp/WEB-INF/appengine-web.xml
deleted file mode 100644
index 8f17694b44..0000000000
--- a/s3/samples/googleappengine/src/main/webapp/WEB-INF/appengine-web.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
- jclouds-s3-example
- 1
-
diff --git a/s3/samples/googleappengine/src/main/webapp/WEB-INF/web.xml b/s3/samples/googleappengine/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 73a4a41c95..0000000000
--- a/s3/samples/googleappengine/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
- jclouds-s3-example
-
-
-
- guiceFilter
- com.google.inject.servlet.GuiceFilter
-
-
-
- guiceFilter
- /guice/*
-
-
-
-
- org.jclouds.samples.googleappengine.config.GuiceServletConfig
-
-
diff --git a/s3/samples/googleappengine/src/main/webapp/index.jsp b/s3/samples/googleappengine/src/main/webapp/index.jsp
deleted file mode 100644
index 6529d030ec..0000000000
--- a/s3/samples/googleappengine/src/main/webapp/index.jsp
+++ /dev/null
@@ -1,30 +0,0 @@
-<%--
-
-
- Copyright (C) 2009 Adrian Cole
-
- ====================================================================
- 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.
- ====================================================================
-
---%>
-
-
-Hello World!
-
-
diff --git a/s3/src/main/java/org/jclouds/aws/s3/S3Connection.java b/s3/src/main/java/org/jclouds/aws/s3/S3Connection.java
deleted file mode 100644
index 12bde45437..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/S3Connection.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands.options.*;
-import org.jclouds.aws.s3.domain.S3Bucket;
-import org.jclouds.aws.s3.domain.S3Object;
-
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-/**
- * 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
- * @see
- */
-public interface S3Connection {
-
- /**
- * Retrieve a complete S3Object
.
- *
- * @param bucketName namespace of the object you are retrieving
- * @param key unique key in the s3Bucket identifying the object
- * @return Future reference to a fully populated S3Object including data
- * stored in S3 or {@link S3Object#NOT_FOUND} if not present.
- * @see org.jclouds.aws.s3.commands.GetObject
- */
- Future getObject(String bucketName, String key);
-
- /**
- * Like {@link #getObject(String, String)} except you can use
- * {@link GetObjectOptions} to control delivery.
- *
- * @return S3Object containing data relevant to the
- * options specified or {@link S3Object#NOT_FOUND} if not present.
- * @throws org.jclouds.http.HttpResponseException
- * if the conditions requested set were not satisfied by the
- * object on the server.
- * @see #getObject(String, String)
- * @see GetObjectOptions
- */
- Future getObject(String bucketName, String key,
- GetObjectOptions options);
-
- /**
- * Retrieves the {@link org.jclouds.aws.s3.domain.S3Object.Metadata 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 or
- * {@link org.jclouds.aws.s3.domain.S3Object.Metadata#NOT_FOUND} if not present;
- * @see org.jclouds.aws.s3.commands.HeadObject
- */
- Future headObject(String bucketName, String key);
-
- /**
- * 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
- * @throws org.jclouds.http.HttpResponseException
- * if the bucket is not available
- * @see org.jclouds.aws.s3.commands.DeleteObject
- */
- Future deleteObject(String bucketName, String key);
-
- /**
- * Store data by creating or overwriting an object.
- *
- * This method will store the object with the default private
- * acl.
- *
- * @param bucketName namespace of the object you are storing
- * @param object contains the data and metadata to create or overwrite
- * @return MD5 hash of the content uploaded
- * @see org.jclouds.aws.s3.domain.acl.CannedAccessPolicy#PRIVATE
- * @see org.jclouds.aws.s3.commands.PutObject
- */
- Future putObject(String bucketName, S3Object object);
-
- /**
- * Like {@link #putObject(String, S3Object)} except you can use
- * {@link CopyObjectOptions} to specify an alternate
- * {@link org.jclouds.aws.s3.domain.acl.CannedAccessPolicy acl}, override
- * {@link org.jclouds.aws.s3.domain.S3Object.Metadata#getUserMetadata() userMetadata}, or specify
- * conditions for copying the object.
- *
- * @param options options for creating the object
- * @throws org.jclouds.http.HttpResponseException
- * if the conditions requested set are not satisfied by the
- * object on the server.
- * @see S3Connection#putObject(String, S3Object)
- * @see PutObjectOptions
- */
- Future putObject(String bucketName, S3Object object,
- PutObjectOptions options);
-
- /**
- * Create and name your own bucket in which to store your objects.
- *
- * @return true, if the bucket was created or already exists
- * @see org.jclouds.aws.s3.commands.PutBucket
- */
- Future putBucketIfNotExists(String name);
-
- /**
- * Like {@link #putBucketIfNotExists(String)} except that you can use
- * {@link PutBucketOptions} to create the bucket in EU. Create and name your
- *
- * @param options for creating your bucket
- * @see PutBucketOptions
- */
- Future putBucketIfNotExists(String name, PutBucketOptions options);
-
- /**
- * Deletes the bucket, if it is empty.
- *
- * @param s3Bucket what to delete
- * @return false, if the bucket was not empty and therefore not deleted
- * @see org.jclouds.aws.s3.commands.DeleteBucket
- */
- Future deleteBucketIfEmpty(String s3Bucket);
-
- /**
- * Copies one object to another bucket, retaining UserMetadata from the
- * source. The destination will have a private acl.
- *
- * @return metadata populated with lastModified and md5 of the new object
- * @see org.jclouds.aws.s3.commands.CopyObject
- */
- Future copyObject(String sourceBucket,
- String sourceObject, String destinationBucket,
- String destinationObject);
-
- /**
- * Like {@link #putObject(String, S3Object)} except you can use
- * {@link PutObjectOptions} to specify an alternate
- * {@link org.jclouds.aws.s3.domain.acl.CannedAccessPolicy acl}.
- *
- * @param options options for creating the object
- * @throws org.jclouds.http.HttpResponseException
- * if the conditions requested set are not satisfied by the
- * object on the server.
- * @see S3Connection#putObject(String, S3Object)
- * @see PutObjectOptions
- */
- Future copyObject(String sourceBucket,
- String sourceObject, String destinationBucket,
- String destinationObject, CopyObjectOptions options);
-
- /**
- * @see org.jclouds.aws.s3.commands.BucketExists
- */
- Future bucketExists(String name);
-
- /**
- * Retrieve a complete S3Bucket
listing.
- *
- * @param bucketName namespace of the objects you wish to list
- * @return Future reference to a fully populated S3Bucket including metadata
- * of the S3Objects it contains or {@link S3Bucket#NOT_FOUND} if not
- * present.
- * @see org.jclouds.aws.s3.commands.ListBucket
- */
- Future listBucket(String bucketName);
-
- /**
- * Like {@link #listBucket(String)} except you can use
- * {@link ListBucketOptions} to control the amount of S3Objects to return.
- *
- * @return S3Bucket containing a subset of {@link org.jclouds.aws.s3.domain.S3Object.Metadata}
- * depending on
- * options specified or {@link S3Bucket#NOT_FOUND} if not present.
- * @see #listBucket(String)
- * @see ListBucketOptions
- */
- Future listBucket(String name, ListBucketOptions options);
-
- /**
- * @return list of all of the buckets owned by the authenticated sender of
- * the request.
- * @see org.jclouds.aws.s3.commands.ListOwnedBuckets
- */
- Future> listOwnedBuckets();
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/S3Context.java b/s3/src/main/java/org/jclouds/aws/s3/S3Context.java
deleted file mode 100644
index c30ed21981..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/S3Context.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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;
-
-/**
- * Represents an authenticated context to S3.
- *
- * Note
Please issue {@link #close()} when you are finished with this
- * context in order to release resources.
- *
- *
- * @see S3Connection
- * @see S3InputStreamMap
- * @see S3ObjectMap
- * @author Adrian Cole
- *
- */
-public interface S3Context {
-
- /**
- * low-level api to S3. Threadsafe implementations will return a singleton.
- *
- * @return a connection to S3
- */
- S3Connection getConnection();
-
- /**
- * Creates a Map
view of the specified
- * bucket.
- *
- * @param bucket
- */
- S3InputStreamMap createInputStreamMap(String bucket);
-
- /**
- * Creates a Map
view of the specified bucket.
- *
- * @param bucket
- */
- S3ObjectMap createS3ObjectMap(String bucket);
-
- /**
- * Closes all connections to S3.
- */
- void close();
-
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/S3ContextFactory.java b/s3/src/main/java/org/jclouds/aws/s3/S3ContextFactory.java
deleted file mode 100644
index 12ca56047f..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/S3ContextFactory.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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 com.google.common.annotations.VisibleForTesting;
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-import com.google.inject.name.Names;
-import org.jclouds.aws.s3.config.LiveS3ConnectionModule;
-import org.jclouds.aws.s3.config.S3ConnectionModule;
-import org.jclouds.aws.s3.config.S3ContextModule;
-import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_AWS_ACCESSKEYID;
-import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_AWS_SECRETACCESSKEY;
-import org.jclouds.aws.s3.internal.LiveS3Connection;
-import static org.jclouds.command.pool.PoolConstants.*;
-import static org.jclouds.http.HttpConstants.*;
-import org.jclouds.http.config.HttpFutureCommandClientModule;
-import org.jclouds.http.config.JavaUrlHttpFutureCommandClientModule;
-import org.jclouds.logging.config.LoggingModule;
-import org.jclouds.logging.jdk.config.JDKLoggingModule;
-
-import java.util.List;
-import java.util.Properties;
-
-/**
- * Creates {@link S3Context} or {@link Injector} instances based on the most
- * commonly requested arguments.
- *
- * Note that Threadsafe objects will be bound as singletons to the Injector or
- * Context provided.
- *
- *
- * If no Module
s are specified, the default
- * {@link JDKLoggingModule logging} and
- * {@link JavaUrlHttpFutureCommandClientModule http transports} will be
- * installed.
- *
- * @author Adrian Cole
- * @see S3Context
- */
-public class S3ContextFactory {
-
- public static final Properties DEFAULT_PROPERTIES;
-
- static {
- DEFAULT_PROPERTIES = new Properties();
- DEFAULT_PROPERTIES.setProperty(PROPERTY_HTTP_ADDRESS,
- "s3.amazonaws.com");
- DEFAULT_PROPERTIES.setProperty(PROPERTY_HTTP_PORT, "443");
- DEFAULT_PROPERTIES.setProperty(PROPERTY_HTTP_SECURE, "true");
- DEFAULT_PROPERTIES
- .setProperty(PROPERTY_POOL_MAX_CONNECTION_REUSE, "75");
- DEFAULT_PROPERTIES.setProperty(PROPERTY_POOL_MAX_SESSION_FAILURES, "2");
- DEFAULT_PROPERTIES.setProperty(PROPERTY_POOL_REQUEST_INVOKER_THREADS,
- "1");
- DEFAULT_PROPERTIES.setProperty(PROPERTY_POOL_IO_WORKER_THREADS, "2");
- DEFAULT_PROPERTIES.setProperty(PROPERTY_POOL_MAX_CONNECTIONS, "12");
- }
-
- public static Injector createInjector(String awsAccessKeyId,
- String awsSecretAccessKey, Module... modules) {
- Properties properties = new Properties(DEFAULT_PROPERTIES);
- properties.setProperty(PROPERTY_AWS_ACCESSKEYID, awsAccessKeyId);
- properties
- .setProperty(PROPERTY_AWS_SECRETACCESSKEY, awsSecretAccessKey);
- return createInjector(properties, modules);
- }
-
- public static S3Context createS3Context(String awsAccessKeyId,
- String awsSecretAccessKey, Module... modules) {
- return createInjector(awsAccessKeyId, awsSecretAccessKey, modules)
- .getInstance(S3Context.class);
- }
-
- public static Injector createInjector(String awsAccessKeyId,
- String awsSecretAccessKey, boolean isSecure, Module... modules) {
- Properties properties = new Properties(DEFAULT_PROPERTIES);
- properties.setProperty(PROPERTY_AWS_ACCESSKEYID, awsAccessKeyId);
- properties
- .setProperty(PROPERTY_AWS_SECRETACCESSKEY, awsSecretAccessKey);
- properties
- .setProperty(PROPERTY_HTTP_SECURE, Boolean.toString(isSecure));
- if (!isSecure)
- properties.setProperty(PROPERTY_HTTP_PORT, "80");
- return createInjector(properties, modules);
- }
-
- public static S3Context createS3Context(String awsAccessKeyId,
- String awsSecretAccessKey, boolean isSecure, Module... modules) {
- return createInjector(awsAccessKeyId, awsSecretAccessKey, isSecure,
- modules).getInstance(S3Context.class);
- }
-
- public static Injector createInjector(String awsAccessKeyId,
- String awsSecretAccessKey, boolean isSecure, String server,
- Module... modules) {
- Properties properties = new Properties(DEFAULT_PROPERTIES);
- properties.setProperty(PROPERTY_AWS_ACCESSKEYID, awsAccessKeyId);
- properties
- .setProperty(PROPERTY_AWS_SECRETACCESSKEY, awsSecretAccessKey);
- properties
- .setProperty(PROPERTY_HTTP_SECURE, Boolean.toString(isSecure));
- properties.setProperty(PROPERTY_HTTP_ADDRESS, server);
- if (!isSecure)
- properties.setProperty(PROPERTY_HTTP_PORT, "80");
- return createInjector(properties, modules);
- }
-
- public static S3Context createS3Context(String awsAccessKeyId,
- String awsSecretAccessKey, boolean isSecure, String server,
- Module... modules) {
- return createInjector(awsAccessKeyId, awsSecretAccessKey, isSecure,
- server, modules).getInstance(S3Context.class);
- }
-
- public static S3Context createS3Context(String awsAccessKeyId,
- String awsSecretAccessKey, boolean isSecure, String server,
- int port, Module... modules) {
- return createInjector(awsAccessKeyId, awsSecretAccessKey, isSecure,
- server, port, modules).getInstance(S3Context.class);
- }
-
- public static Injector createInjector(String awsAccessKeyId,
- String awsSecretAccessKey, boolean isSecure, String server,
- int port, Module... modules) {
- Properties properties = new Properties(DEFAULT_PROPERTIES);
- properties.setProperty(PROPERTY_AWS_ACCESSKEYID, awsAccessKeyId);
- properties
- .setProperty(PROPERTY_AWS_SECRETACCESSKEY, awsSecretAccessKey);
- properties
- .setProperty(PROPERTY_HTTP_SECURE, Boolean.toString(isSecure));
- properties.setProperty(PROPERTY_HTTP_ADDRESS, server);
- properties.setProperty(PROPERTY_HTTP_PORT, port + "");
- return createInjector(properties, modules);
- }
-
- public static S3Context createS3Context(Properties properties,
- Module... modules) {
- return createInjector(properties, modules).getInstance(S3Context.class);
- }
-
- /**
- * Bind the given properties and install the list of modules. If no modules
- * are specified, install the default {@link JDKLoggingModule}
- * {@link JavaUrlHttpFutureCommandClientModule}
- *
- * @param properties - contains constants used by jclouds
- * {@link #DEFAULT_PROPERTIES}
- * @param configModules - alternative configuration modules
- */
- public static Injector createInjector(final Properties properties,
- Module... configModules) {
- final List modules = Lists.newArrayList(configModules);
-
- addLoggingModuleIfNotPresent(modules);
-
- addHttpModuleIfNeededAndNotPresent(modules);
-
- addS3ConnectionModuleIfNotPresent(modules);
-
- return Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- Names.bindProperties(binder(), checkNotNull(properties,
- "properties"));
- for (Module module : modules)
- install(module);
- }
- }, new S3ContextModule());
- }
-
- @VisibleForTesting
- static void addHttpModuleIfNeededAndNotPresent(final List modules) {
- if (Iterables.any(modules, new Predicate() {
- public boolean apply(Module input) {
- return input instanceof LiveS3ConnectionModule;
- }
-
- }) && (!Iterables.any(modules, new Predicate() {
- public boolean apply(Module input) {
- return input.getClass().isAnnotationPresent(
- HttpFutureCommandClientModule.class);
- }
-
- })))
- modules.add(new JavaUrlHttpFutureCommandClientModule());
- }
-
- @VisibleForTesting
- static void addS3ConnectionModuleIfNotPresent(final List modules) {
- if (!Iterables.any(modules, new Predicate() {
- public boolean apply(Module input) {
- return input.getClass().isAnnotationPresent(
- S3ConnectionModule
- .class);
- }
-
- })){
- modules.add(new LiveS3ConnectionModule());
- }
- }
-
- @VisibleForTesting
- static void addLoggingModuleIfNotPresent(final List modules) {
- if (!Iterables.any(modules, Predicates.instanceOf(LoggingModule.class)))
- modules.add(new JDKLoggingModule());
- }
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/S3InputStreamMap.java b/s3/src/main/java/org/jclouds/aws/s3/S3InputStreamMap.java
deleted file mode 100644
index f2b8194576..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/S3InputStreamMap.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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 java.io.File;
-import java.io.InputStream;
-import java.util.Map;
-
-/**
- * Map view of an {@link org.jclouds.aws.s3.domain.S3Bucket}. Provides additional methods for inserting
- * common object types.
- *
- * Note
All put
operations will invoke
- * {@link org.jclouds.aws.s3.domain.S3Object#generateMd5}. By extension, {@link #put(Object, Object)}
- * will result in the InputStream being converted to a byte array. For this
- * reason, do not use {@link #put(Object, Object)} to store files. Use
- * {@link #putFile(String, File)} or {@link S3ObjectMap} instead.
- *
- * @author Adrian Cole
- */
-public interface S3InputStreamMap extends S3Map {
- InputStream putString(String key, String value);
-
- InputStream putFile(String key, File value);
-
- InputStream putBytes(String key, byte[] value);
-
- void putAllStrings(Map extends String, ? extends String> map);
-
- void putAllBytes(Map extends String, ? extends byte[]> map);
-
- void putAllFiles(Map extends String, ? extends File> map);
-
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/S3Map.java b/s3/src/main/java/org/jclouds/aws/s3/S3Map.java
deleted file mode 100644
index b1ffd03970..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/S3Map.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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 java.util.Map;
-
-import org.jclouds.aws.s3.domain.S3Bucket;
-
-/**
- * All Map views of {@link S3Bucket}s provide means to access the underlying S3
- * object.
- *
- * @author Adrian Cole
- *
- */
-public interface S3Map extends Map {
-
- /**
- *
- * @return s3 bucket listing that this map represents
- */
- S3Bucket getBucket();
-
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/S3ObjectMap.java b/s3/src/main/java/org/jclouds/aws/s3/S3ObjectMap.java
deleted file mode 100644
index 2eda5a170d..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/S3ObjectMap.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.S3Bucket;
-import org.jclouds.aws.s3.domain.S3Object;
-
-/**
- * Map view of an {@link S3Bucket}.
- *
- *
- * This allows you to acces the underlying {@link S3Object} so that you can
- * manually set metadata such as length, content-type, or md5 hash.
- *
- * @author Adrian Cole
- *
- */
-public interface S3ObjectMap extends S3Map {
-
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/S3ResponseException.java b/s3/src/main/java/org/jclouds/aws/s3/S3ResponseException.java
deleted file mode 100644
index 1746cff4e2..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/S3ResponseException.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.HttpFutureCommand;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpResponseException;
-
-/**
- * Encapsulates an S3 Error from Amazon.
- *
- * @see
- * @see S3Error
- * @see org.jclouds.aws.s3.handlers.ParseS3ErrorFromXmlContent
- * @author Adrian Cole
- *
- */
-public class S3ResponseException extends HttpResponseException {
-
- private static final long serialVersionUID = 1L;
-
- private S3Error error = new S3Error();
-
- public S3ResponseException(HttpFutureCommand> command,
- HttpResponse response, S3Error error) {
- super(error.toString(), command, response);
- this.setError(error);
-
- }
-
- public S3ResponseException(HttpFutureCommand> command,
- HttpResponse response, S3Error error, Throwable cause) {
- super(error.toString(), command, response, cause);
- this.setError(error);
-
- }
-
- public S3ResponseException(String message, HttpFutureCommand> command,
- HttpResponse response, S3Error error) {
- super(message, command, response);
- this.setError(error);
-
- }
-
- public S3ResponseException(String message, HttpFutureCommand> command,
- HttpResponse response, S3Error error, Throwable cause) {
- super(message, command, response, cause);
- this.setError(error);
-
- }
-
- public void setError(S3Error error) {
- this.error = error;
- }
-
- public S3Error getError() {
- return error;
- }
-
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/BucketExists.java b/s3/src/main/java/org/jclouds/aws/s3/commands/BucketExists.java
deleted file mode 100644
index ae77b641b2..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/BucketExists.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands;
-
-import static org.jclouds.aws.s3.commands.options.ListBucketOptions.Builder.maxResults;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.http.commands.callables.ReturnTrueIf2xx;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.name.Named;
-
-/**
- * Issues a HEAD command to determine if the bucket exists or not.
- *
- * @author Adrian Cole
- *
- */
-public class BucketExists extends S3FutureCommand {
-
- @Inject
- public BucketExists(@Named("jclouds.http.address") String amazonHost,
- ReturnTrueIf2xx callable, @Assisted String s3Bucket) {
- super("HEAD", "/" + maxResults(0).buildQueryString(), callable,
- amazonHost, s3Bucket);
- }
-
- @Override
- public Boolean get() throws InterruptedException, ExecutionException {
- try {
- return super.get();
- } catch (ExecutionException e) {
- return attemptNotFound(e);
- }
- }
-
- @VisibleForTesting
- Boolean attemptNotFound(ExecutionException e) throws ExecutionException {
- if (e.getCause() != null
- && e.getCause() instanceof HttpResponseException) {
- HttpResponseException responseException = (HttpResponseException) e
- .getCause();
- if (responseException.getResponse().getStatusCode() == 404) {
- return false;
- }
- }
- throw e;
- }
-
- @Override
- public Boolean get(long l, TimeUnit timeUnit) throws InterruptedException,
- ExecutionException, TimeoutException {
- try {
- return super.get(l, timeUnit);
- } catch (ExecutionException e) {
- return attemptNotFound(e);
- }
- }
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/CopyObject.java b/s3/src/main/java/org/jclouds/aws/s3/commands/CopyObject.java
deleted file mode 100644
index f2eb938570..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/CopyObject.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.aws.s3.commands.options.CopyObjectOptions;
-import org.jclouds.aws.s3.domain.S3Object;
-import org.jclouds.aws.s3.xml.CopyObjectHandler;
-import org.jclouds.http.commands.callables.xml.ParseSax;
-
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.name.Named;
-
-/**
- * The copy operation creates a copy of an object that is already storedin
- * Amazon S3.
- *
- * When copying an object, you can preserve all metadata (default) or
- * {@link CopyObjectOptions#overrideMetadataWith(com.google.common.collect.Multimap)
- * specify new metadata}. However, the ACL is not preserved and is set to
- * private for the user making the request. To override the default ACL setting,
- * {@link CopyObjectOptions#overrideAcl(org.jclouds.aws.s3.domain.acl.CannedAccessPolicy)
- * specify a new ACL} when generating a copy request.
- *
- * @see
- * @see CopyObjectOptions
- * @see org.jclouds.aws.s3.domain.acl.CannedAccessPolicy
- * @author Adrian Cole
- *
- */
-public class CopyObject extends S3FutureCommand {
-
- @Inject
- public CopyObject(@Named("jclouds.http.address") String amazonHost,
- ParseSax callable,
- @Assisted("sourceBucket") String sourceBucket,
- @Assisted("sourceObject") String sourceObject,
- @Assisted("destinationBucket") String destinationBucket,
- @Assisted("destinationObject") String destinationObject,
- @Assisted CopyObjectOptions options) {
- super("PUT",
- "/" + checkNotNull(destinationObject, "destinationObject"),
- callable, amazonHost, destinationBucket);
- CopyObjectHandler handler = (CopyObjectHandler) callable.getHandler();
- handler.setKey(destinationObject);
- getRequest().getHeaders().put(
- "x-amz-copy-source",
- String.format("/%1$s/%2$s", checkNotNull(sourceBucket,
- "sourceBucket"), checkNotNull(sourceObject,
- "sourceObject")));
- getRequest().getHeaders().putAll(options.buildRequestHeaders());
- }
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/DeleteBucket.java b/s3/src/main/java/org/jclouds/aws/s3/commands/DeleteBucket.java
deleted file mode 100644
index f553cff325..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/DeleteBucket.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.jclouds.aws.s3.S3ResponseException;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.http.commands.callables.ReturnTrueIf2xx;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.name.Named;
-
-/**
- * The DELETE request operation deletes the bucket named in the URI. All objects
- * in the bucket must be deleted before the bucket itself can be deleted.
- *
- * Only the owner of a bucket can delete it, regardless of the bucket's access
- * control policy.
- *
- * @see
- * @author Adrian Cole
- */
-public class DeleteBucket extends S3FutureCommand {
-
- @Inject
- public DeleteBucket(@Named("jclouds.http.address") String amazonHost,
- ReturnTrueIf2xx callable, @Assisted String s3Bucket) {
- super("DELETE", "/", callable, amazonHost, s3Bucket);
- }
-
- @Override
- public Boolean get() throws InterruptedException, ExecutionException {
- try {
- return super.get();
- } catch (ExecutionException e) {
- return attemptNotFound(e);
- }
- }
-
- @VisibleForTesting
- Boolean attemptNotFound(ExecutionException e) throws ExecutionException {
- if (e.getCause() != null
- && e.getCause() instanceof HttpResponseException) {
- S3ResponseException responseException = (S3ResponseException) e
- .getCause();
- if (responseException.getResponse().getStatusCode() == 404) {
- return true;
- } else if ("BucketNotEmpty".equals(responseException.getError()
- .getCode())) {
- return false;
- }
- }
- throw e;
- }
-
- @Override
- public Boolean get(long l, TimeUnit timeUnit) throws InterruptedException,
- ExecutionException, TimeoutException {
- try {
- return super.get(l, timeUnit);
- } catch (ExecutionException e) {
- return attemptNotFound(e);
- }
- }
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/DeleteObject.java b/s3/src/main/java/org/jclouds/aws/s3/commands/DeleteObject.java
deleted file mode 100644
index ade7067868..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/DeleteObject.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.http.commands.callables.ReturnTrueIf2xx;
-
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.name.Named;
-
-/**
- * The DELETE request operation removes the specified object from Amazon S3.
- * Once deleted, there is no method to restore or undelete an object.
- *
- * @see
- * @author Adrian Cole
- */
-public class DeleteObject extends S3FutureCommand {
-
- @Inject
- public DeleteObject(@Named("jclouds.http.address") String amazonHost,
- ReturnTrueIf2xx callable, @Assisted("bucketName") String bucket,
- @Assisted("key") String key) {
- super("DELETE", "/" + checkNotNull(key), callable, amazonHost, bucket);
- }
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/GetObject.java b/s3/src/main/java/org/jclouds/aws/s3/commands/GetObject.java
deleted file mode 100644
index b51008d050..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/GetObject.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.jclouds.aws.s3.S3ResponseException;
-import org.jclouds.aws.s3.commands.callables.ParseObjectFromHeadersAndHttpContent;
-import org.jclouds.aws.s3.commands.options.GetObjectOptions;
-import org.jclouds.aws.s3.domain.S3Object;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.name.Named;
-
-/**
- * Retrieves the S3Object associated with the Key or {@link S3Object#NOT_FOUND}
- * if not available;
- *
- *
- * To use GET, you must have READ access to the object. If READ access is
- * granted to the anonymous user, you can request the object without an
- * authorization header.
- *
- *
- * This command allows you to specify {@link GetObjectOptions} to control
- * delivery of content.
- *
- * Note
If you specify any of the below options, you will receive
- * partial content:
- *
- * - {@link GetObjectOptions#range}
- * - {@link GetObjectOptions#startAt}
- * - {@link GetObjectOptions#tail}
- *
- *
- * @see GetObjectOptions
- * @see
- * @author Adrian Cole
- */
-public class GetObject extends S3FutureCommand {
-
- @Inject
- public GetObject(@Named("jclouds.http.address") String amazonHost,
- ParseObjectFromHeadersAndHttpContent callable,
- @Assisted("bucketName") String s3Bucket,
- @Assisted("key") String key, @Assisted GetObjectOptions options) {
- super("GET", "/" + checkNotNull(key), callable, amazonHost, s3Bucket);
- this.getRequest().getHeaders().putAll(options.buildRequestHeaders());
- callable.setKey(key);
- }
-
- @Override
- public S3Object get() throws InterruptedException, ExecutionException {
- try {
- return super.get();
- } catch (ExecutionException e) {
- return attemptNotFound(e);
- }
- }
-
- @VisibleForTesting
- S3Object attemptNotFound(ExecutionException e) throws ExecutionException {
- if (e.getCause() != null && e.getCause() instanceof S3ResponseException) {
- S3ResponseException responseException = (S3ResponseException) e
- .getCause();
- if ("NoSuchKey".equals(responseException.getError().getCode())) {
- return S3Object.NOT_FOUND;
- }
- }
- throw e;
- }
-
- @Override
- public S3Object get(long l, TimeUnit timeUnit) throws InterruptedException,
- ExecutionException, TimeoutException {
- try {
- return super.get(l, timeUnit);
- } catch (ExecutionException e) {
- return attemptNotFound(e);
- }
- }
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/HeadObject.java b/s3/src/main/java/org/jclouds/aws/s3/commands/HeadObject.java
deleted file mode 100644
index fba9352a08..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/HeadObject.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.jclouds.aws.s3.commands.callables.ParseMetadataFromHeaders;
-import org.jclouds.aws.s3.domain.S3Object;
-import org.jclouds.http.HttpResponseException;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.name.Named;
-
-/**
- * Retrieves the metadata associated with the Key or
- * {@link org.jclouds.aws.s3.domain.S3Object.Metadata#NOT_FOUND} if not available.
- *
- *
- * The HEAD operation is used to retrieve information about a specific object or
- * object size, without actually fetching the object itself. This is useful if
- * you're only interested in the object metadata, and don't want to waste
- * bandwidth on the object data.
- *
- * @see GetObject
- * @see
- * @author Adrian Cole
- *
- */
-public class HeadObject extends S3FutureCommand {
-
- @Inject
- public HeadObject(@Named("jclouds.http.address") String amazonHost,
- ParseMetadataFromHeaders callable,
- @Assisted("bucketName") String bucket, @Assisted("key") String key) {
- super("HEAD", "/" + checkNotNull(key), callable, amazonHost, bucket);
- callable.setKey(key);
- }
-
- @Override
- public S3Object.Metadata get() throws InterruptedException,
- ExecutionException {
- try {
- return super.get();
- } catch (ExecutionException e) {
- return attemptNotFound(e);
- }
- }
-
- @VisibleForTesting
- S3Object.Metadata attemptNotFound(ExecutionException e)
- throws ExecutionException {
- if (e.getCause() != null
- && e.getCause() instanceof HttpResponseException) {
- HttpResponseException responseException = (HttpResponseException) e
- .getCause();
- if (responseException.getResponse().getStatusCode() == 404) {
- return S3Object.Metadata.NOT_FOUND;
- }
- }
- throw e;
- }
-
- @Override
- public S3Object.Metadata get(long l, TimeUnit timeUnit)
- throws InterruptedException, ExecutionException, TimeoutException {
- try {
- return super.get(l, timeUnit);
- } catch (ExecutionException e) {
- return attemptNotFound(e);
- }
- }
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/ListBucket.java b/s3/src/main/java/org/jclouds/aws/s3/commands/ListBucket.java
deleted file mode 100644
index 7405ac1e24..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/ListBucket.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.jclouds.aws.s3.S3ResponseException;
-import org.jclouds.aws.s3.commands.options.ListBucketOptions;
-import org.jclouds.aws.s3.domain.S3Bucket;
-import org.jclouds.aws.s3.xml.ListBucketHandler;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.http.commands.callables.xml.ParseSax;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.name.Named;
-
-/**
- * A GET request operation using a bucket URI lists information about the
- * objects in the bucket.
- *
- * To list the keys of a bucket, you must have READ access to the bucket.
- *
- * List output is controllable via {@link ListBucketOptions}
- *
- * @see ListBucketOptions
- * @see
- * @author Adrian Cole
- *
- */
-public class ListBucket extends S3FutureCommand {
-
- @Inject
- public ListBucket(@Named("jclouds.http.address") String amazonHost,
- ParseSax bucketParser, @Assisted String bucket,
- @Assisted ListBucketOptions options) {
- super("GET", "/" + options.buildQueryString(), bucketParser,
- amazonHost, bucket);
- ListBucketHandler handler = (ListBucketHandler) bucketParser
- .getHandler();
- handler.setBucketName(bucket);
- }
-
- @Override
- public S3Bucket get() throws InterruptedException, ExecutionException {
- try {
- return super.get();
- } catch (ExecutionException e) {
- return attemptNotFound(e);
- }
- }
-
- @VisibleForTesting
- S3Bucket attemptNotFound(ExecutionException e) throws ExecutionException {
- if (e.getCause() != null
- && e.getCause() instanceof HttpResponseException) {
- S3ResponseException responseException = (S3ResponseException) e
- .getCause();
- if ("NoSuchBucket".equals(responseException.getError().getCode())) {
- return S3Bucket.NOT_FOUND;
- }
- }
- throw e;
- }
-
- @Override
- public S3Bucket get(long l, TimeUnit timeUnit) throws InterruptedException,
- ExecutionException, TimeoutException {
- try {
- return super.get(l, timeUnit);
- } catch (ExecutionException e) {
- return attemptNotFound(e);
- }
- }
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/ListOwnedBuckets.java b/s3/src/main/java/org/jclouds/aws/s3/commands/ListOwnedBuckets.java
deleted file mode 100644
index 53e9fb3c68..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/ListOwnedBuckets.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands;
-
-import java.util.List;
-
-import org.jclouds.aws.s3.domain.S3Bucket;
-import org.jclouds.http.commands.callables.xml.ParseSax;
-
-import com.google.inject.Inject;
-import com.google.inject.name.Named;
-
-/**
- * Returns a list of all of the buckets owned by the authenticated sender of the
- * request.
- *
- * @see
- * @author Adrian Cole
- *
- */
-public class ListOwnedBuckets extends S3FutureCommand> {
-
- @Inject
- public ListOwnedBuckets(@Named("jclouds.http.address") String amazonHost,
- ParseSax> callable) {
- super("GET", "/", callable, amazonHost);
- }
-
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/PutBucket.java b/s3/src/main/java/org/jclouds/aws/s3/commands/PutBucket.java
deleted file mode 100644
index 870693922c..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/PutBucket.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands;
-
-import org.jclouds.aws.s3.commands.options.PutBucketOptions;
-import org.jclouds.aws.s3.util.S3Utils;
-import org.jclouds.http.HttpHeaders;
-import org.jclouds.http.commands.callables.ReturnTrueIf2xx;
-
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.name.Named;
-
-/**
- * Create and name your own bucket in which to store your objects.
- *
- * The PUT request operation with a bucket URI creates a new bucket. Depending
- * on your latency and legal requirements, you can specify a location constraint
- * that will affect where your data physically resides. You can currently
- * specify a Europe (EU) location constraint via {@link PutBucketOptions}.
- *
- * @see PutBucketOptions
- * @see
- * @author Adrian Cole
- *
- */
-public class PutBucket extends S3FutureCommand {
-
- @Inject
- public PutBucket(@Named("jclouds.http.address") String amazonHost,
- ReturnTrueIf2xx callable, @Assisted String bucketName,
- @Assisted PutBucketOptions options) {
- super("PUT", "/", callable, amazonHost, S3Utils
- .validateBucketName(bucketName));
- getRequest().getHeaders().putAll(options.buildRequestHeaders());
- String payload = options.buildPayload();
- if (payload != null) {
- getRequest().setPayload(payload);
- getRequest().getHeaders().put(HttpHeaders.CONTENT_LENGTH,
- payload.getBytes().length + "");
- }
- }
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/PutObject.java b/s3/src/main/java/org/jclouds/aws/s3/commands/PutObject.java
deleted file mode 100644
index 853fd3772f..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/PutObject.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.aws.s3.commands.callables.ParseMd5FromETagHeader;
-import org.jclouds.aws.s3.commands.options.PutObjectOptions;
-import org.jclouds.aws.s3.domain.S3Object;
-import org.jclouds.aws.s3.util.S3Utils;
-import org.jclouds.http.HttpHeaders;
-
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.name.Named;
-
-/**
- * Store data by creating or overwriting an object.
- *
- *
- * This returns a byte[] of the md5 hash of what Amazon S3 received
- *
- *
- * This command allows you to specify {@link PutObjectOptions} to control
- * delivery of content.
- *
- *
- * @see PutObjectOptions
- * @see
- * @author Adrian Cole
- */
-public class PutObject extends S3FutureCommand {
-
- @Inject
- public PutObject(@Named("jclouds.http.address") String amazonHost,
- ParseMd5FromETagHeader callable, @Assisted String s3Bucket,
- @Assisted S3Object object, @Assisted PutObjectOptions options) {
- super("PUT", "/" + checkNotNull(object.getKey()), callable, amazonHost,
- s3Bucket);
- checkArgument(object.getMetadata().getSize() >= 0, "size must be set");
-
- getRequest().setPayload(
- checkNotNull(object.getData(), "object.getContent()"));
-
- getRequest().getHeaders().put(
- HttpHeaders.CONTENT_TYPE,
- checkNotNull(object.getMetadata().getContentType(),
- "object.metadata.contentType()"));
-
- getRequest().getHeaders().put(HttpHeaders.CONTENT_LENGTH,
- object.getMetadata().getSize() + "");
-
- if (object.getMetadata().getCacheControl() != null) {
- getRequest().getHeaders().put(HttpHeaders.CACHE_CONTROL,
- object.getMetadata().getCacheControl());
- }
- if (object.getMetadata().getContentDisposition() != null) {
- getRequest().getHeaders().put(HttpHeaders.CONTENT_DISPOSITION,
- object.getMetadata().getContentDisposition());
- }
- if (object.getMetadata().getContentEncoding() != null) {
- getRequest().getHeaders().put(HttpHeaders.CONTENT_ENCODING,
- object.getMetadata().getContentEncoding());
- }
-
- if (object.getMetadata().getMd5() != null)
- getRequest().getHeaders().put(HttpHeaders.CONTENT_MD5,
- S3Utils.toBase64String(object.getMetadata().getMd5()));
-
- getRequest().getHeaders()
- .putAll(object.getMetadata().getUserMetadata());
- getRequest().getHeaders().putAll(options.buildRequestHeaders());
-
- }
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/S3CommandFactory.java b/s3/src/main/java/org/jclouds/aws/s3/commands/S3CommandFactory.java
deleted file mode 100644
index 1cddd73e9a..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/S3CommandFactory.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands;
-
-import org.jclouds.aws.s3.commands.options.CopyObjectOptions;
-import org.jclouds.aws.s3.commands.options.GetObjectOptions;
-import org.jclouds.aws.s3.commands.options.ListBucketOptions;
-import org.jclouds.aws.s3.commands.options.PutBucketOptions;
-import org.jclouds.aws.s3.commands.options.PutObjectOptions;
-import org.jclouds.aws.s3.domain.S3Object;
-import org.jclouds.aws.s3.xml.S3ParserFactory;
-
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.name.Named;
-
-/**
- * Assembles the command objects for S3.
- *
- * @author Adrian Cole
- */
-public class S3CommandFactory {
- @Inject
- private S3ParserFactory parserFactory;
-
- @Inject
- private DeleteBucketFactory deleteBucketFactory;
-
- public static interface DeleteBucketFactory {
- DeleteBucket create(String bucket);
- }
-
- public DeleteBucket createDeleteBucket(String bucket) {
- return deleteBucketFactory.create(bucket);
- }
-
- @Inject
- private DeleteObjectFactory deleteObjectFactory;
-
- public static interface DeleteObjectFactory {
- DeleteObject create(@Assisted("bucketName") String bucket,
- @Assisted("key") String key);
- }
-
- public DeleteObject createDeleteObject(String bucket, String key) {
- return deleteObjectFactory.create(bucket, key);
- }
-
- @Inject
- private BucketExistsFactory headBucketFactory;
-
- public static interface BucketExistsFactory {
- BucketExists create(String bucket);
- }
-
- public BucketExists createHeadBucket(String bucket) {
- return headBucketFactory.create(bucket);
- }
-
- @Inject
- private PutBucketFactory putBucketFactoryOptions;
-
- public static interface PutBucketFactory {
- PutBucket create(String bucket, PutBucketOptions options);
- }
-
- public PutBucket createPutBucket(String bucket, PutBucketOptions options) {
- return putBucketFactoryOptions.create(bucket, options);
- }
-
- @Inject
- private PutObjectFactory putObjectFactory;
-
- public static interface PutObjectFactory {
- PutObject create(String bucket, S3Object object,
- PutObjectOptions options);
- }
-
- public PutObject createPutObject(String bucket, S3Object s3Object,
- PutObjectOptions options) {
- return putObjectFactory.create(bucket, s3Object, options);
- }
-
- @Inject
- private GetObjectFactory getObjectFactory;
-
- public static interface GetObjectFactory {
- GetObject create(@Assisted("bucketName") String bucket,
- @Assisted("key") String key, GetObjectOptions options);
- }
-
- public GetObject createGetObject(String bucket, String key,
- GetObjectOptions options) {
- return getObjectFactory.create(bucket, key, options);
- }
-
- @Inject
- private HeadMetadataFactory headMetadataFactory;
-
- public static interface HeadMetadataFactory {
- HeadObject create(@Assisted("bucketName") String bucket,
- @Assisted("key") String key);
- }
-
- public HeadObject createHeadMetadata(String bucket, String key) {
- return headMetadataFactory.create(bucket, key);
- }
-
- @Inject
- @Named("jclouds.http.address")
- String amazonHost;
-
- public ListOwnedBuckets createGetMetadataForOwnedBuckets() {
- return new ListOwnedBuckets(amazonHost, parserFactory
- .createListBucketsParser());
- }
-
- public ListBucket createListBucket(String bucket, ListBucketOptions options) {
- return new ListBucket(amazonHost, parserFactory
- .createListBucketParser(), bucket, options);
- }
-
- public CopyObject createCopyObject(String sourceBucket,
- String sourceObject, String destinationBucket,
- String destinationObject, CopyObjectOptions options) {
- return new CopyObject(amazonHost, parserFactory
- .createCopyObjectParser(), sourceBucket, sourceObject,
- destinationBucket, destinationObject, options);
- }
-
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/S3FutureCommand.java b/s3/src/main/java/org/jclouds/aws/s3/commands/S3FutureCommand.java
deleted file mode 100644
index 947cf79f65..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/S3FutureCommand.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.http.HttpFutureCommand;
-
-/**
- * Conditionally adds the amazon host header to requests.
- *
- * @author Adrian Cole
- *
- * @param
- */
-public class S3FutureCommand extends HttpFutureCommand {
-
- public S3FutureCommand(String method, String uri,
- ResponseCallable responseCallable, String amazonHost,
- String bucketName) {
- super(method, uri, responseCallable);
- addHostHeader(checkNotNull(amazonHost, "amazonHost"), checkNotNull(
- bucketName, "bucketName"));
- }
-
- public S3FutureCommand(String method, String uri,
- ResponseCallable responseCallable, String amazonHost) {
- super(method, uri, responseCallable);
- addHostHeader(checkNotNull(amazonHost, "amazonHost"));
- }
-
- protected void addHostHeader(String amazonHost, String bucketName) {
- addHostHeader(checkNotNull(bucketName) + "." + amazonHost);
- }
-
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/callables/ParseMd5FromETagHeader.java b/s3/src/main/java/org/jclouds/aws/s3/commands/callables/ParseMd5FromETagHeader.java
deleted file mode 100644
index 6d17882cef..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/callables/ParseMd5FromETagHeader.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands.callables;
-
-import org.apache.commons.io.IOUtils;
-import org.jclouds.aws.s3.reference.S3Headers;
-import org.jclouds.aws.s3.util.S3Utils;
-import org.jclouds.http.HttpException;
-import org.jclouds.http.HttpFutureCommand;
-
-
-/**
- * Parses an MD5 checksum from the header {@link S3Headers#ETAG}.
- *
- * @author Adrian Cole
- */
-public class ParseMd5FromETagHeader extends
- HttpFutureCommand.ResponseCallable {
-
- public byte[] call() throws HttpException {
- checkCode();
- IOUtils.closeQuietly(getResponse().getContent());
-
- String eTag = getResponse().getFirstHeaderOrNull(S3Headers.ETAG);
- if (eTag != null) {
- return S3Utils.fromHexString(eTag.replaceAll("\"", ""));
- }
- throw new HttpException("did not receive ETag");
- }
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/callables/ParseMetadataFromHeaders.java b/s3/src/main/java/org/jclouds/aws/s3/commands/callables/ParseMetadataFromHeaders.java
deleted file mode 100644
index dc07bae42c..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/callables/ParseMetadataFromHeaders.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands.callables;
-
-import java.util.Map.Entry;
-
-import org.jclouds.aws.s3.domain.S3Object;
-import org.jclouds.aws.s3.domain.S3Object.Metadata;
-import org.jclouds.aws.s3.reference.S3Headers;
-import org.jclouds.aws.s3.util.DateService;
-import org.jclouds.aws.s3.util.S3Utils;
-import org.jclouds.http.HttpException;
-import org.jclouds.http.HttpFutureCommand;
-import org.jclouds.http.HttpHeaders;
-
-import com.google.inject.Inject;
-
-/**
- * This parses @{link {@link org.jclouds.aws.s3.domain.S3Object.Metadata} from HTTP headers.
- *
- * @see
- * @author Adrian Cole
- */
-public class ParseMetadataFromHeaders extends
- HttpFutureCommand.ResponseCallable {
- private final DateService dateParser;
- private String key;
-
- @Inject
- public ParseMetadataFromHeaders(DateService dateParser) {
- this.dateParser = dateParser;
- }
-
- /**
- * parses the http response headers to create a new
- * {@link org.jclouds.aws.s3.domain.S3Object.Metadata} object.
- */
- public S3Object.Metadata call() throws HttpException {
- checkCode();
-
- S3Object.Metadata metadata = new S3Object.Metadata(key);
- addAllHeadersTo(metadata);
-
- addUserMetadataTo(metadata);
- addMd5To(metadata);
-
- parseLastModifiedOrThrowException(metadata);
- setContentTypeOrThrowException(metadata);
- setContentLengthOrThrowException(metadata);
-
- metadata.setCacheControl(getResponse().getFirstHeaderOrNull(
- HttpHeaders.CACHE_CONTROL));
- metadata.setContentDisposition(getResponse().getFirstHeaderOrNull(
- HttpHeaders.CONTENT_DISPOSITION));
- metadata.setContentEncoding(getResponse().getFirstHeaderOrNull(
- HttpHeaders.CONTENT_ENCODING));
- return metadata;
-
- }
-
- private void addAllHeadersTo(Metadata metadata) {
- metadata.getAllHeaders().putAll(getResponse().getHeaders());
- }
-
- private void setContentTypeOrThrowException(S3Object.Metadata metadata)
- throws HttpException {
- String contentType = getResponse().getFirstHeaderOrNull(
- HttpHeaders.CONTENT_TYPE);
- if (contentType == null)
- throw new HttpException(HttpHeaders.CONTENT_TYPE
- + " not found in headers");
- else
- metadata.setContentType(contentType);
- }
-
- private void setContentLengthOrThrowException(S3Object.Metadata metadata)
- throws HttpException {
- String contentLength = getResponse().getFirstHeaderOrNull(
- HttpHeaders.CONTENT_LENGTH);
- if (contentLength == null)
- throw new HttpException(HttpHeaders.CONTENT_LENGTH
- + " not found in headers");
- else
- metadata.setSize(Long.parseLong(contentLength));
- }
-
- private void parseLastModifiedOrThrowException(S3Object.Metadata metadata)
- throws HttpException {
- String lastModified = getResponse().getFirstHeaderOrNull(
- HttpHeaders.LAST_MODIFIED);
- metadata.setLastModified(dateParser
- .dateTimeFromHeaderFormat(lastModified));
- if (metadata.getLastModified() == null)
- throw new HttpException("could not parse: "
- + HttpHeaders.LAST_MODIFIED + ": " + lastModified);
- }
-
- private void addMd5To(S3Object.Metadata metadata) {
- String md5Header = getResponse()
- .getFirstHeaderOrNull(S3Headers.AMZ_MD5);
- if (md5Header != null) {
- metadata.setMd5(S3Utils.fromHexString(md5Header));
- }
- String eTag = getResponse().getFirstHeaderOrNull(S3Headers.ETAG);
- if (metadata.getMd5() == null && eTag != null) {
- metadata.setMd5(S3Utils.fromHexString(eTag.replaceAll("\"", "")));
- }
- }
-
- private void addUserMetadataTo(S3Object.Metadata metadata) {
- for (Entry header : getResponse().getHeaders()
- .entries()) {
- if (header.getKey() != null
- && header.getKey().startsWith(
- S3Headers.USER_METADATA_PREFIX))
- metadata.getUserMetadata().put(header.getKey(),
- header.getValue());
- }
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/callables/ParseObjectFromHeadersAndHttpContent.java b/s3/src/main/java/org/jclouds/aws/s3/commands/callables/ParseObjectFromHeadersAndHttpContent.java
deleted file mode 100644
index 99af0b9020..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/callables/ParseObjectFromHeadersAndHttpContent.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands.callables;
-
-import org.jclouds.aws.s3.domain.S3Object;
-import org.jclouds.http.HttpException;
-import org.jclouds.http.HttpFutureCommand;
-import org.jclouds.http.HttpHeaders;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.inject.Inject;
-
-/**
- * Parses response headers and creates a new S3Object from them and the HTTP
- * content.
- *
- * @see ParseMetadataFromHeaders
- * @author Adrian Cole
- */
-public class ParseObjectFromHeadersAndHttpContent extends
- HttpFutureCommand.ResponseCallable {
- private final ParseMetadataFromHeaders metadataParser;
-
- @Inject
- public ParseObjectFromHeadersAndHttpContent(
- ParseMetadataFromHeaders metadataParser) {
- this.metadataParser = metadataParser;
- }
-
- /**
- * First, calls {@link ParseMetadataFromHeaders}.
- *
- * Then, sets the object size based on the Content-Length header and adds
- * the content to the {@link S3Object} result.
- *
- * @throws org.jclouds.http.HttpException
- */
- public S3Object call() throws HttpException {
- checkCode();
- metadataParser.setResponse(getResponse());
- S3Object.Metadata metadata = metadataParser.call();
- S3Object object = new S3Object(metadata, getResponse().getContent());
- parseContentLengthOrThrowException(object);
- return object;
- }
-
- @VisibleForTesting
- void parseContentLengthOrThrowException(S3Object object)
- throws HttpException {
- String contentLength = getResponse().getFirstHeaderOrNull(
- HttpHeaders.CONTENT_LENGTH);
- String contentRange = getResponse().getFirstHeaderOrNull(
- HttpHeaders.CONTENT_RANGE);
- if (contentLength == null)
- throw new HttpException(HttpHeaders.CONTENT_LENGTH
- + " header not present in headers: "
- + getResponse().getHeaders());
- object.setContentLength(Long.parseLong(contentLength));
-
- if (contentRange == null) {
- object.getMetadata().setSize(object.getContentLength());
- } else {
- object.setContentRange(contentRange);
- object.getMetadata().setSize(
- Long.parseLong(contentRange.substring(contentRange
- .lastIndexOf('/') + 1)));
- }
- }
-
- public void setKey(String key) {
- this.metadataParser.setKey(key);
- }
-
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/callables/package-info.java b/s3/src/main/java/org/jclouds/aws/s3/commands/callables/package-info.java
deleted file mode 100644
index a88a03aa07..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/callables/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.
- * ====================================================================
- */
-/**
- * This package contains response handlers for S3 commands.
- * @author Adrian Cole
- */
-package org.jclouds.aws.s3.commands.callables;
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/config/S3CommandsModule.java b/s3/src/main/java/org/jclouds/aws/s3/commands/config/S3CommandsModule.java
deleted file mode 100644
index ca8895b54c..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/config/S3CommandsModule.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands.config;
-
-import org.jclouds.aws.s3.commands.BucketExists;
-import org.jclouds.aws.s3.commands.DeleteBucket;
-import org.jclouds.aws.s3.commands.DeleteObject;
-import org.jclouds.aws.s3.commands.GetObject;
-import org.jclouds.aws.s3.commands.HeadObject;
-import org.jclouds.aws.s3.commands.PutBucket;
-import org.jclouds.aws.s3.commands.PutObject;
-import org.jclouds.aws.s3.commands.S3CommandFactory;
-import org.jclouds.aws.s3.xml.config.S3ParserModule;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.assistedinject.FactoryProvider;
-
-/**
- * Creates the factories needed to produce S3 commands
- *
- * @author Adrian Cole
- */
-public class S3CommandsModule extends AbstractModule {
- @Override
- protected void configure() {
- install(new S3ParserModule());
-
- bind(S3CommandFactory.DeleteBucketFactory.class).toProvider(
- FactoryProvider.newFactory(
- S3CommandFactory.DeleteBucketFactory.class,
- DeleteBucket.class));
-
- bind(S3CommandFactory.DeleteObjectFactory.class).toProvider(
- FactoryProvider.newFactory(
- S3CommandFactory.DeleteObjectFactory.class,
- DeleteObject.class));
-
- bind(S3CommandFactory.BucketExistsFactory.class).toProvider(
- FactoryProvider.newFactory(
- S3CommandFactory.BucketExistsFactory.class,
- BucketExists.class));
-
- bind(S3CommandFactory.PutBucketFactory.class).toProvider(
- FactoryProvider.newFactory(
- S3CommandFactory.PutBucketFactory.class,
- PutBucket.class));
-
- bind(S3CommandFactory.PutObjectFactory.class).toProvider(
- FactoryProvider.newFactory(
- S3CommandFactory.PutObjectFactory.class,
- PutObject.class));
-
- bind(S3CommandFactory.GetObjectFactory.class).toProvider(
- FactoryProvider.newFactory(
- S3CommandFactory.GetObjectFactory.class,
- GetObject.class));
-
- bind(S3CommandFactory.HeadMetadataFactory.class).toProvider(
- FactoryProvider.newFactory(
- S3CommandFactory.HeadMetadataFactory.class,
- HeadObject.class));
-
- }
-
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/config/package-info.java b/s3/src/main/java/org/jclouds/aws/s3/commands/config/package-info.java
deleted file mode 100644
index 6e5c252858..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/config/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.
- * ====================================================================
- */
-/**
- * This package contains modules who manage the dependencies of S3 command objects.
- * @author Adrian Cole
- */
-package org.jclouds.aws.s3.commands.config;
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/options/CopyObjectOptions.java b/s3/src/main/java/org/jclouds/aws/s3/commands/options/CopyObjectOptions.java
deleted file mode 100644
index a0e72b25c5..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/options/CopyObjectOptions.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands.options;
-
-import com.google.common.base.Preconditions;
-import static com.google.common.base.Preconditions.*;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import org.jclouds.aws.s3.domain.acl.CannedAccessPolicy;
-import org.jclouds.aws.s3.reference.S3Headers;
-import org.jclouds.aws.s3.util.DateService;
-import org.jclouds.aws.s3.util.S3Utils;
-import org.jclouds.http.options.BaseHttpRequestOptions;
-import org.joda.time.DateTime;
-
-import java.io.UnsupportedEncodingException;
-
-/**
- * Contains options supported in the REST API for the COPY object operation.
- *
- * Usage
The recommended way to instantiate a CopyObjectOptions object
- * is to statically import CopyObjectOptions.Builder.* and invoke a static
- * creation method followed by an instance mutator (if needed):
- *
- *
- * import static org.jclouds.aws.s3.commands.options.CopyObjectOptions.Builder.*
- *
- * S3Connection connection = // get connection
- *
- * Multimap metadata = HashMultimap.create();
- * metadata.put("x-amz-meta-adrian", "foo");
- *
- * // this will copy the object, provided it wasn't modified since yesterday.
- * // it will not use metadata from the source, and instead use what we pass in.
- * Future object = connection.copyObject("sourceBucket", "objectName",
- * "destinationBucket", "destinationName",
- * overrideMetadataWith(meta).
- * ifSourceModifiedSince(new DateTime().minusDays(1))
- * );
- *
- *
- * @author Adrian Cole
- * @see
- */
-public class CopyObjectOptions extends BaseHttpRequestOptions {
- private final static DateService dateService = new DateService();
-
- public static final CopyObjectOptions NONE = new CopyObjectOptions();
-
- private Multimap metadata;
-
- private CannedAccessPolicy acl = CannedAccessPolicy.PRIVATE;
-
- /**
- * Override the default ACL (private) with the specified one.
- *
- * @see CannedAccessPolicy
- */
- public CopyObjectOptions overrideAcl(CannedAccessPolicy acl) {
- this.acl = checkNotNull(acl, "acl");
- if (!acl.equals(CannedAccessPolicy.PRIVATE))
- this.replaceHeader(S3Headers.CANNED_ACL, acl.toString());
- return this;
- }
-
- /**
- * @see CopyObjectOptions#overrideAcl(CannedAccessPolicy)
- */
- public CannedAccessPolicy getAcl() {
- return acl;
- }
-
- /**
- * For use in the header x-amz-copy-source-if-unmodified-since
- *
- * Copies the object if it hasn't been modified since the specified time;
- * otherwise returns a 412 (precondition failed).
- *
- * This header can be used with x-amz-copy-source-if-match, but cannot be
- * used with other conditional copy headers.
- *
- * @return valid HTTP date
- * @see
- * @see CopyObjectOptions#ifSourceModifiedSince(DateTime)
- */
- public String getIfModifiedSince() {
- return getFirstHeaderOrNull("x-amz-copy-source-if-modified-since");
- }
-
- /**
- * For use in the header x-amz-copy-source-if-modified-since
- *
- * Copies the object if it has been modified since the specified time;
- * otherwise returns a 412 (failed condition).
- *
- * This header can be used with x-amz-copy-source-if-none-match, but cannot
- * be used with other conditional copy headers.
- *
- * @return valid HTTP date
- * @see
- * @see CopyObjectOptions#ifSourceUnmodifiedSince(DateTime)
- */
- public String getIfUnmodifiedSince() {
- return getFirstHeaderOrNull("x-amz-copy-source-if-unmodified-since");
- }
-
- /**
- * For use in the request header: x-amz-copy-source-if-match
- *
- * Copies the object if its entity tag (ETag) matches the specified tag;
- * otherwise return a 412 (precondition failed).
- *
- * This header can be used with x-amz-copy-source-if-unmodified-since, but
- * cannot be used with other conditional copy headers.
- *
- * @see CopyObjectOptions#ifSourceMd5Matches(byte[])
- */
- public String getIfMatch() {
- return getFirstHeaderOrNull("x-amz-copy-source-if-match");
- }
-
- /**
- * For use in the request header: x-amz-copy-source-if-none-match
- *
- * Copies the object if its entity tag (ETag) is different than the
- * specified Etag; otherwise returns a 412 (failed condition).
- *
- * This header can be used with x-amz-copy-source-if-modified-since, but
- * cannot be used with other conditional copy headers.
- *
- * @see CopyObjectOptions#ifSourceMd5DoesntMatch(byte[])
- */
- public String getIfNoneMatch() {
- return getFirstHeaderOrNull("x-amz-copy-source-if-none-match");
- }
-
- /**
- * When not null, contains the header
- * [x-amz-copy-source-if-unmodified-since] -> [REPLACE] and metadata headers
- * passed in from the users.
- *
- * @see #overrideMetadataWith(Multimap)
- */
- public Multimap getMetadata() {
- return metadata;
- }
-
- /**
- * Only return the object if it has changed since this time.
- *
- * Not compatible with {@link #ifSourceMd5Matches(byte[])} or
- * {@link #ifSourceUnmodifiedSince(DateTime)}
- */
- public CopyObjectOptions ifSourceModifiedSince(DateTime ifModifiedSince) {
- checkState(getIfMatch() == null,
- "ifMd5Matches() is not compatible with ifModifiedSince()");
- checkState(getIfUnmodifiedSince() == null,
- "ifUnmodifiedSince() is not compatible with ifModifiedSince()");
- replaceHeader("x-amz-copy-source-if-modified-since",
- dateService.toHeaderString(checkNotNull(ifModifiedSince,
- "ifModifiedSince")));
- return this;
- }
-
- /**
- * Only return the object if it hasn't changed since this time.
- *
- * Not compatible with {@link #ifSourceMd5DoesntMatch(byte[])} or
- * {@link #ifSourceModifiedSince(DateTime)}
- */
- public CopyObjectOptions ifSourceUnmodifiedSince(DateTime ifUnmodifiedSince) {
- checkState(getIfNoneMatch() == null,
- "ifMd5DoesntMatch() is not compatible with ifUnmodifiedSince()");
- checkState(getIfModifiedSince() == null,
- "ifModifiedSince() is not compatible with ifUnmodifiedSince()");
- replaceHeader("x-amz-copy-source-if-unmodified-since", dateService
- .toHeaderString(checkNotNull(ifUnmodifiedSince,
- "ifUnmodifiedSince")));
- return this;
- }
-
- /**
- * The object's md5 hash should match the parameter md5
.
- *
- *
- * Not compatible with {@link #ifSourceMd5DoesntMatch(byte[])} or
- * {@link #ifSourceModifiedSince(DateTime)}
- *
- * @param md5 hash representing the entity
- * @throws UnsupportedEncodingException if there was a problem converting this into an S3 eTag string
- */
- public CopyObjectOptions ifSourceMd5Matches(byte[] md5)
- throws UnsupportedEncodingException {
- checkState(getIfNoneMatch() == null,
- "ifMd5DoesntMatch() is not compatible with ifMd5Matches()");
- checkState(getIfModifiedSince() == null,
- "ifModifiedSince() is not compatible with ifMd5Matches()");
- replaceHeader("x-amz-copy-source-if-match", String.format("\"%1$s\"",
- S3Utils.toHexString(checkNotNull(md5, "md5"))));
- return this;
- }
-
- /**
- * The object should not have a md5 hash corresponding with the parameter
- * md5
.
- *
- * Not compatible with {@link #ifSourceMd5Matches(byte[])} or
- * {@link #ifSourceUnmodifiedSince(DateTime)}
- *
- * @param md5 hash representing the entity
- * @throws UnsupportedEncodingException if there was a problem converting this into an S3 eTag string
- */
- public CopyObjectOptions ifSourceMd5DoesntMatch(byte[] md5)
- throws UnsupportedEncodingException {
- checkState(getIfMatch() == null,
- "ifMd5Matches() is not compatible with ifMd5DoesntMatch()");
- Preconditions
- .checkState(getIfUnmodifiedSince() == null,
- "ifUnmodifiedSince() is not compatible with ifMd5DoesntMatch()");
- replaceHeader("x-amz-copy-source-if-none-match", String.format(
- "\"%1$s\"", S3Utils.toHexString(checkNotNull(md5,
- "ifMd5DoesntMatch"))));
- return this;
- }
-
- @Override
- public Multimap buildRequestHeaders() {
- Multimap returnVal = HashMultimap.create();
- returnVal.putAll(headers);
- if (metadata != null) {
- returnVal.putAll(metadata);
- returnVal.put("x-amz-metadata-directive", "REPLACE");
- }
- return returnVal;
- }
-
- /**
- * Use the provided metadata instead of what is on the source object.
- */
- public CopyObjectOptions overrideMetadataWith(
- Multimap metadata) {
- checkNotNull(metadata, "metadata");
- for (String header : metadata.keySet()) {
- checkArgument(header.startsWith("x-amz-meta-"),
- "Metadata keys must start with x-amz-meta-");
- }
- this.metadata = metadata;
- return this;
- }
-
- public static class Builder {
- /**
- * @see CopyObjectOptions#overrideAcl(CannedAccessPolicy)
- */
- public static CopyObjectOptions overrideAcl(CannedAccessPolicy acl) {
- CopyObjectOptions options = new CopyObjectOptions();
- return options.overrideAcl(acl);
- }
-
- /**
- * @see CopyObjectOptions#getIfModifiedSince()
- */
- public static CopyObjectOptions ifSourceModifiedSince(
- DateTime ifModifiedSince) {
- CopyObjectOptions options = new CopyObjectOptions();
- return options.ifSourceModifiedSince(ifModifiedSince);
- }
-
- /**
- * @see CopyObjectOptions#ifSourceUnmodifiedSince(DateTime)
- */
- public static CopyObjectOptions ifSourceUnmodifiedSince(
- DateTime ifUnmodifiedSince) {
- CopyObjectOptions options = new CopyObjectOptions();
- return options.ifSourceUnmodifiedSince(ifUnmodifiedSince);
- }
-
- /**
- * @see CopyObjectOptions#ifSourceMd5Matches(byte[])
- */
- public static CopyObjectOptions ifSourceMd5Matches(byte[] md5)
- throws UnsupportedEncodingException {
- CopyObjectOptions options = new CopyObjectOptions();
- return options.ifSourceMd5Matches(md5);
- }
-
- /**
- * @see CopyObjectOptions#ifSourceMd5DoesntMatch(byte[])
- */
- public static CopyObjectOptions ifSourceMd5DoesntMatch(byte[] md5)
- throws UnsupportedEncodingException {
- CopyObjectOptions options = new CopyObjectOptions();
- return options.ifSourceMd5DoesntMatch(md5);
- }
-
- /**
- * @see #overrideMetadataWith(Multimap)
- */
- public static CopyObjectOptions overrideMetadataWith(
- Multimap metadata) {
- CopyObjectOptions options = new CopyObjectOptions();
- return options.overrideMetadataWith(metadata);
- }
- }
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/options/GetObjectOptions.java b/s3/src/main/java/org/jclouds/aws/s3/commands/options/GetObjectOptions.java
deleted file mode 100644
index c50d7a2389..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/options/GetObjectOptions.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands.options;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkArgument;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jclouds.aws.s3.util.DateService;
-import org.jclouds.aws.s3.util.S3Utils;
-import org.jclouds.http.HttpHeaders;
-import org.jclouds.http.options.BaseHttpRequestOptions;
-import org.joda.time.DateTime;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.Multimap;
-
-/**
- * Contains options supported in the REST API for the GET object operation.
- * Usage
The recommended way to instantiate a GetObjectOptions object is to
- * statically import GetObjectOptions.Builder.* and invoke a static creation
- * method followed by an instance mutator (if needed):
- *
- *
- * import static org.jclouds.aws.s3.commands.options.GetObjectOptions.Builder.*
- *
- * S3Connection connection = // get connection
- *
- * // this will get the first megabyte of an object, provided it wasn't modified since yesterday
- * Future object = connection.getObject("bucket","objectName",range(0,1024).ifUnmodifiedSince(new DateTime().minusDays(1)));
- *
- *
- * @see
- * @author Adrian Cole
- *
- *
- */
-public class GetObjectOptions extends BaseHttpRequestOptions {
- private final static DateService dateService = new DateService();
- public static final GetObjectOptions NONE = new GetObjectOptions();
- private final List ranges = new ArrayList();
-
- @Override
- public Multimap buildRequestHeaders() {
- Multimap headers = super.buildRequestHeaders();
- String range = getRange();
- if (range != null)
- headers.put(HttpHeaders.RANGE, this.getRange());
- return headers;
- }
-
- /**
- * download the specified range of the object.
- */
- public GetObjectOptions range(long start, long end) {
- checkArgument(start >= 0, "start must be >= 0");
- checkArgument(end >= 0, "end must be >= 0");
- ranges.add(String.format("%d-%d", start, end));
- return this;
- }
-
- /**
- * download the object offset at start
- */
- public GetObjectOptions startAt(long start) {
- checkArgument(start >= 0, "start must be >= 0");
- ranges.add(String.format("%d-", start));
- return this;
- }
-
- /**
- * download the last count
bytes of the object
- */
- public GetObjectOptions tail(long count) {
- checkArgument(count > 0, "count must be > 0");
- ranges.add(String.format("-%d", count));
- return this;
- }
-
- /**
- * For use in the header Range
- *
- *
- * @see GetObjectOptions#range(long, long)
- */
- public String getRange() {
- return (ranges.size() > 0) ? String.format("bytes=%s", Joiner.on(",")
- .join(ranges)) : null;
- }
-
- /**
- * Only return the object if it has changed since this time.
- *
- * Not compatible with {@link #ifMd5Matches(byte[])} or
- * {@link #ifUnmodifiedSince(DateTime)}
- */
- public GetObjectOptions ifModifiedSince(DateTime ifModifiedSince) {
- checkArgument(getIfMatch() == null,
- "ifMd5Matches() is not compatible with ifModifiedSince()");
- checkArgument(getIfUnmodifiedSince() == null,
- "ifUnmodifiedSince() is not compatible with ifModifiedSince()");
- this.headers.put(HttpHeaders.IF_MODIFIED_SINCE,
- dateService.toHeaderString(checkNotNull(ifModifiedSince,
- "ifModifiedSince")));
- return this;
- }
-
- /**
- * For use in the header If-Modified-Since
- *
- * Return the object only if it has been modified since the specified time,
- * otherwise return a 304 (not modified).
- *
- * @see GetObjectOptions#ifModifiedSince(DateTime)
- */
- public String getIfModifiedSince() {
- return this.getFirstHeaderOrNull(HttpHeaders.IF_MODIFIED_SINCE);
- }
-
- /**
- * Only return the object if it hasn't changed since this time.
- *
- * Not compatible with {@link #ifMd5DoesntMatch(byte[])} or
- * {@link #ifModifiedSince(DateTime)}
- */
- public GetObjectOptions ifUnmodifiedSince(DateTime ifUnmodifiedSince) {
- checkArgument(getIfNoneMatch() == null,
- "ifMd5DoesntMatch() is not compatible with ifUnmodifiedSince()");
- checkArgument(getIfModifiedSince() == null,
- "ifModifiedSince() is not compatible with ifUnmodifiedSince()");
- this.headers.put(HttpHeaders.IF_UNMODIFIED_SINCE, dateService
- .toHeaderString(checkNotNull(ifUnmodifiedSince,
- "ifUnmodifiedSince")));
- return this;
- }
-
- /**
- * For use in the header If-Unmodified-Since
- *
- * Return the object only if it has not been modified since the specified
- * time, otherwise return a 412 (precondition failed).
- *
- * @see GetObjectOptions#ifUnmodifiedSince(DateTime)
- */
- public String getIfUnmodifiedSince() {
- return this.getFirstHeaderOrNull(HttpHeaders.IF_UNMODIFIED_SINCE);
- }
-
- /**
- * The object's md5 hash should match the parameter md5
.
- *
- *
- * Not compatible with {@link #ifMd5DoesntMatch(byte[])} or
- * {@link #ifModifiedSince(DateTime)}
- *
- * @param md5
- * hash representing the entity
- * @throws UnsupportedEncodingException
- * if there was a problem converting this into an S3 eTag string
- */
- public GetObjectOptions ifMd5Matches(byte[] md5)
- throws UnsupportedEncodingException {
- checkArgument(getIfNoneMatch() == null,
- "ifMd5DoesntMatch() is not compatible with ifMd5Matches()");
- checkArgument(getIfModifiedSince() == null,
- "ifModifiedSince() is not compatible with ifMd5Matches()");
- this.headers.put(HttpHeaders.IF_MATCH, String.format("\"%1$s\"",
- S3Utils.toHexString(checkNotNull(md5, "md5"))));
- return this;
- }
-
- /**
- * For use in the request header: If-Match
- *
- * Return the object only if its entity tag (ETag) is the same as the md5
- * specified, otherwise return a 412 (precondition failed).
- *
- * @see GetObjectOptions#ifMd5Matches(byte[])
- */
- public String getIfMatch() {
- return this.getFirstHeaderOrNull(HttpHeaders.IF_MATCH);
- }
-
- /**
- * The object should not have a md5 hash corresponding with the parameter
- * md5
.
- *
- * Not compatible with {@link #ifMd5Matches(byte[])} or
- * {@link #ifUnmodifiedSince(DateTime)}
- *
- * @param md5
- * hash representing the entity
- * @throws UnsupportedEncodingException
- * if there was a problem converting this into an S3 eTag string
- */
- public GetObjectOptions ifMd5DoesntMatch(byte[] md5)
- throws UnsupportedEncodingException {
- checkArgument(getIfMatch() == null,
- "ifMd5Matches() is not compatible with ifMd5DoesntMatch()");
- checkArgument(getIfUnmodifiedSince() == null,
- "ifUnmodifiedSince() is not compatible with ifMd5DoesntMatch()");
- this.headers.put(HttpHeaders.IF_NONE_MATCH, String.format("\"%1$s\"",
- S3Utils.toHexString(checkNotNull(md5, "ifMd5DoesntMatch"))));
- return this;
- }
-
- /**
- * For use in the request header: If-None-Match
- *
- * Return the object only if its entity tag (ETag) is different from the one
- * specified, otherwise return a 304 (not modified).
- *
- * @see GetObjectOptions#ifMd5DoesntMatch(byte[])
- */
- public String getIfNoneMatch() {
- return this
- .getFirstHeaderOrNull(org.jclouds.http.HttpHeaders.IF_NONE_MATCH);
- }
-
- public static class Builder {
-
- /**
- * @see GetObjectOptions#range(long, long)
- */
- public static GetObjectOptions range(long start, long end) {
- GetObjectOptions options = new GetObjectOptions();
- return options.range(start, end);
- }
-
- /**
- * @see GetObjectOptions#startAt(long)
- */
- public static GetObjectOptions startAt(long start) {
- GetObjectOptions options = new GetObjectOptions();
- return options.startAt(start);
- }
-
- /**
- * @see GetObjectOptions#tail(long)
- */
- public static GetObjectOptions tail(long count) {
- GetObjectOptions options = new GetObjectOptions();
- return options.tail(count);
- }
-
- /**
- * @see GetObjectOptions#getIfModifiedSince()
- */
- public static GetObjectOptions ifModifiedSince(DateTime ifModifiedSince) {
- GetObjectOptions options = new GetObjectOptions();
- return options.ifModifiedSince(ifModifiedSince);
- }
-
- /**
- * @see GetObjectOptions#ifUnmodifiedSince(DateTime)
- */
- public static GetObjectOptions ifUnmodifiedSince(
- DateTime ifUnmodifiedSince) {
- GetObjectOptions options = new GetObjectOptions();
- return options.ifUnmodifiedSince(ifUnmodifiedSince);
- }
-
- /**
- * @see GetObjectOptions#ifMd5Matches(byte[])
- */
- public static GetObjectOptions ifMd5Matches(byte[] md5)
- throws UnsupportedEncodingException {
- GetObjectOptions options = new GetObjectOptions();
- return options.ifMd5Matches(md5);
- }
-
- /**
- * @see GetObjectOptions#ifMd5DoesntMatch(byte[])
- */
- public static GetObjectOptions ifMd5DoesntMatch(byte[] md5)
- throws UnsupportedEncodingException {
- GetObjectOptions options = new GetObjectOptions();
- return options.ifMd5DoesntMatch(md5);
- }
-
- }
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/options/ListBucketOptions.java b/s3/src/main/java/org/jclouds/aws/s3/commands/options/ListBucketOptions.java
deleted file mode 100644
index c4d1ee3399..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/options/ListBucketOptions.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands.options;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-/**
- * Contains options supported in the REST API for the GET bucket operation.
- * Usage
The recommended way to instantiate a GetBucketOptions object is to
- * statically import GetBucketOptions.Builder.* and invoke a static creation
- * method followed by an instance mutator (if needed):
- *
- *
- * import static org.jclouds.aws.s3.commands.options.GetBucketOptions.Builder.*
- *
- * S3Connection connection = // get connection
- * Future bucket = connection.listBucket("bucketName",withPrefix("home/users").maxKeys(1000));
- *
- *
- * @author Adrian Cole
- * @see
- */
-public class ListBucketOptions extends BaseHttpRequestOptions {
- public static final ListBucketOptions NONE = new ListBucketOptions();
-
- /**
- * Limits the response to keys which begin with the indicated prefix. You
- * can use prefixes to separate a bucket into different sets of keys in a
- * way similar to how a file system uses folders.
- *
- * @throws UnsupportedEncodingException
- */
- public ListBucketOptions withPrefix(String prefix)
- throws UnsupportedEncodingException {
- options.put("prefix", URLEncoder.encode(checkNotNull(prefix, "prefix"),
- "UTF-8"));
- return this;
- }
-
- /**
- * @see ListBucketOptions#withPrefix(String)
- */
- public String getPrefix() {
- return options.get("prefix");
- }
-
- /**
- * Indicates where in the bucket to begin listing. The list will only
- * include keys that occur lexicographically after marker. This is
- * convenient for pagination: To get the next page of results use the last
- * key of the current page as the marker.
- *
- * @throws UnsupportedEncodingException
- */
- public ListBucketOptions afterMarker(String marker)
- throws UnsupportedEncodingException {
- options.put("marker", URLEncoder.encode(checkNotNull(marker, "marker"),
- "UTF-8"));
- return this;
- }
-
- /**
- * @see ListBucketOptions#afterMarker(String)
- */
- public String getMarker() {
- return options.get("marker");
- }
-
- /**
- * The maximum number of keys you'd like to see in the response body. The
- * server might return fewer than this many keys, but will not return more.
- */
- public ListBucketOptions maxResults(long maxKeys) {
- checkState(maxKeys >= 0, "maxKeys must be >= 0");
- options.put("max-keys", Long.toString(maxKeys));
- return this;
- }
-
- /**
- * @see ListBucketOptions#maxResults(long)
- */
- public String getMaxKeys() {
- return options.get("max-keys");
- }
-
- /**
- * Causes keys that contain the same string between the prefix and the first
- * occurrence of the delimiter to be rolled up into a single result element
- * in the CommonPrefixes collection. These rolled-up keys are not returned
- * elsewhere in the response.
- *
- * @throws UnsupportedEncodingException
- */
- public ListBucketOptions delimiter(String delimiter)
- throws UnsupportedEncodingException {
- options.put("delimiter", URLEncoder.encode(checkNotNull(delimiter,
- "delimiter"), "UTF-8"));
- return this;
- }
-
- /**
- * @see ListBucketOptions#delimiter(String)
- */
- public String getDelimiter() {
- return options.get("delimiter");
- }
-
- public static class Builder {
-
- /**
- * @throws UnsupportedEncodingException
- * @see ListBucketOptions#withPrefix(String)
- */
- public static ListBucketOptions withPrefix(String prefix)
- throws UnsupportedEncodingException {
- ListBucketOptions options = new ListBucketOptions();
- return options.withPrefix(prefix);
- }
-
- /**
- * @throws UnsupportedEncodingException
- * @see ListBucketOptions#afterMarker(String)
- */
- public static ListBucketOptions afterMarker(String marker)
- throws UnsupportedEncodingException {
- ListBucketOptions options = new ListBucketOptions();
- return options.afterMarker(marker);
- }
-
- /**
- * @see ListBucketOptions#maxResults(long)
- */
- public static ListBucketOptions maxResults(long maxKeys) {
- ListBucketOptions options = new ListBucketOptions();
- return options.maxResults(maxKeys);
- }
-
- /**
- * @throws UnsupportedEncodingException
- * @see ListBucketOptions#delimiter(String)
- */
- public static ListBucketOptions delimiter(String delimiter)
- throws UnsupportedEncodingException {
- ListBucketOptions options = new ListBucketOptions();
- return options.delimiter(delimiter);
- }
-
- }
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/options/PutBucketOptions.java b/s3/src/main/java/org/jclouds/aws/s3/commands/options/PutBucketOptions.java
deleted file mode 100644
index 9b2c9bb22c..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/options/PutBucketOptions.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands.options;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import org.jclouds.aws.s3.domain.S3Bucket.Metadata.LocationConstraint;
-import org.jclouds.aws.s3.domain.acl.CannedAccessPolicy;
-import org.jclouds.aws.s3.reference.S3Headers;
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-/**
- * Contains options supported in the REST API for the PUT bucket operation.
- * Usage
The recommended way to instantiate a PutBucketOptions object is to
- * statically import PutBucketOptions.Builder.* and invoke a static creation
- * method followed by an instance mutator (if needed):
- *
- *
- * import static org.jclouds.aws.s3.commands.options.PutBucketOptions.Builder.*
- * import static org.jclouds.aws.s3.domain.S3Bucket.Metadata.LocationConstraint.*;
- * import org.jclouds.aws.s3.S3Connection;
- *
- * S3Connection connection = // get connection
- * Future createdInEu = connection.putBucketIfNotExists("bucketName",createIn(EU));
- *
- *
- * @author Adrian Cole
- * @see
- */
-public class PutBucketOptions extends BaseHttpRequestOptions {
- public static final PutBucketOptions NONE = new PutBucketOptions();
- private CannedAccessPolicy acl = CannedAccessPolicy.PRIVATE;
- private LocationConstraint constraint;
-
- /**
- * Depending on your latency and legal requirements, you can specify a
- * location constraint that will affect where your data physically resides.
- * You can currently specify a Europe (EU) location constraint.
- */
- public PutBucketOptions createIn(LocationConstraint constraint) {
- this.constraint = checkNotNull(constraint, "constraint");
- this.payload = String
- .format(
- "%1$s",
- constraint.toString());
- return this;
- }
-
- /**
- * Override the default ACL (private) with the specified one.
- *
- * @see CannedAccessPolicy
- */
- public PutBucketOptions withBucketAcl(CannedAccessPolicy acl) {
- this.acl = checkNotNull(acl, "acl");
- if (!acl.equals(CannedAccessPolicy.PRIVATE))
- this.replaceHeader(S3Headers.CANNED_ACL, acl.toString());
- return this;
- }
-
- /**
- * @see PutBucketOptions#withBucketAcl(CannedAccessPolicy)
- */
- public CannedAccessPolicy getAcl() {
- return acl;
- }
-
- /**
- * @see PutBucketOptions#createIn(org.jclouds.aws.s3.domain.S3Bucket.Metadata.LocationConstraint)
- */
- public LocationConstraint getLocationConstraint() {
- return constraint;
- }
-
- public static class Builder {
- /**
- * @see PutBucketOptions#createIn(org.jclouds.aws.s3.domain.S3Bucket.Metadata.LocationConstraint)
- */
- public static PutBucketOptions createIn(LocationConstraint constraint) {
- PutBucketOptions options = new PutBucketOptions();
- return options.createIn(constraint);
- }
-
- /**
- * @see PutBucketOptions#withBucketAcl(CannedAccessPolicy)
- */
- public static PutBucketOptions withBucketAcl(CannedAccessPolicy acl) {
- PutBucketOptions options = new PutBucketOptions();
- return options.withBucketAcl(acl);
- }
- }
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/options/PutObjectOptions.java b/s3/src/main/java/org/jclouds/aws/s3/commands/options/PutObjectOptions.java
deleted file mode 100644
index 74e68ad7be..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/options/PutObjectOptions.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.commands.options;
-
-import org.jclouds.aws.s3.domain.acl.CannedAccessPolicy;
-import org.jclouds.aws.s3.reference.S3Headers;
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-import static com.google.common.base.Preconditions.*;
-
-/**
- * Contains options supported in the REST API for the PUT object operation.
- *
- *
- * Usage
The recommended way to instantiate a PutObjectOptions object is to
- * statically import PutObjectOptions.Builder.* and invoke a static creation
- * method followed by an instance mutator (if needed):
- *
- *
- * import static org.jclouds.aws.s3.commands.options.PutObjectOptions.Builder.*
- * import org.jclouds.aws.s3.S3Connection;
- *
- * S3Connection connection = // get connection
- * Future publicly readable = connection.putObject("bucketName",new S3Object("key","value"), withAcl(CannedAccessPolicy.PUBLIC_READ));
- *
- *
- * @see
- *
- * @author Adrian Cole
- *
- */
-public class PutObjectOptions extends BaseHttpRequestOptions {
- public static final PutObjectOptions NONE = new PutObjectOptions();
-
- private CannedAccessPolicy acl = CannedAccessPolicy.PRIVATE;
-
- /**
- * Override the default ACL (private) with the specified one.
- *
- * @see CannedAccessPolicy
- */
- public PutObjectOptions withAcl(CannedAccessPolicy acl) {
- this.acl = checkNotNull(acl, "acl");
- if (!acl.equals(CannedAccessPolicy.PRIVATE))
- this.replaceHeader(S3Headers.CANNED_ACL, acl.toString());
- return this;
- }
-
- /**
- * @see PutObjectOptions#withAcl(CannedAccessPolicy)
- */
- public CannedAccessPolicy getAcl() {
- return acl;
- }
-
- public static class Builder {
-
- /**
- * @see PutObjectOptions#withAcl(CannedAccessPolicy)
- */
- public static PutObjectOptions withAcl(CannedAccessPolicy acl) {
- PutObjectOptions options = new PutObjectOptions();
- return options.withAcl(acl);
- }
- }
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/options/package-info.java b/s3/src/main/java/org/jclouds/aws/s3/commands/options/package-info.java
deleted file mode 100644
index 2af21b6c28..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/options/package-info.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.
- * ====================================================================
- */
-/**
- * This package contains request options for S3 REST commands.
- *
- * @see
- * @author Adrian Cole
- */
-package org.jclouds.aws.s3.commands.options;
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/commands/package-info.java b/s3/src/main/java/org/jclouds/aws/s3/commands/package-info.java
deleted file mode 100644
index 3ce8ee7fd2..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/commands/package-info.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.
- * ====================================================================
- */
-/**
- * This package contains all currently supported commands in the Amazon S3 REST Api.
- * @see
- * @author Adrian Cole
- */
-package org.jclouds.aws.s3.commands;
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/config/LiveS3ConnectionModule.java b/s3/src/main/java/org/jclouds/aws/s3/config/LiveS3ConnectionModule.java
deleted file mode 100644
index a8ea7adfe1..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/config/LiveS3ConnectionModule.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.config;
-
-import com.google.inject.*;
-import com.google.inject.assistedinject.FactoryProvider;
-import com.google.inject.name.Named;
-import org.jclouds.aws.s3.S3Connection;
-import org.jclouds.aws.s3.S3Context;
-import org.jclouds.aws.s3.commands.config.S3CommandsModule;
-import org.jclouds.aws.s3.filters.RequestAuthorizeSignature;
-import org.jclouds.aws.s3.handlers.ParseS3ErrorFromXmlContent;
-import org.jclouds.aws.s3.internal.GuiceS3Context;
-import org.jclouds.aws.s3.internal.LiveS3Connection;
-import org.jclouds.aws.s3.internal.LiveS3InputStreamMap;
-import org.jclouds.aws.s3.internal.LiveS3ObjectMap;
-import org.jclouds.http.HttpConstants;
-import org.jclouds.http.HttpRequestFilter;
-import org.jclouds.http.HttpResponseHandler;
-import org.jclouds.http.annotation.ClientErrorHandler;
-import org.jclouds.http.annotation.RedirectHandler;
-import org.jclouds.http.annotation.ServerErrorHandler;
-import org.jclouds.http.handlers.CloseContentAndSetExceptionHandler;
-import org.jclouds.logging.Logger;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Configures the S3 connection, including logging and http transport.
- *
- * @author Adrian Cole
- */
-@S3ConnectionModule
-public class LiveS3ConnectionModule extends AbstractModule {
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- @Named(HttpConstants.PROPERTY_HTTP_ADDRESS)
- String address;
- @Inject
- @Named(HttpConstants.PROPERTY_HTTP_PORT)
- int port;
- @Inject
- @Named(HttpConstants.PROPERTY_HTTP_SECURE)
- boolean isSecure;
-
- @Override
- protected void configure() {
- bind(S3Connection.class).to(LiveS3Connection.class)
- .in(Scopes.SINGLETON);
- bind(HttpResponseHandler.class).annotatedWith(RedirectHandler.class)
- .to(CloseContentAndSetExceptionHandler.class).in(
- Scopes.SINGLETON);
- bind(HttpResponseHandler.class).annotatedWith(ClientErrorHandler.class)
- .to(ParseS3ErrorFromXmlContent.class).in(Scopes.SINGLETON);
- bind(HttpResponseHandler.class).annotatedWith(ServerErrorHandler.class)
- .to(ParseS3ErrorFromXmlContent.class).in(Scopes.SINGLETON);
- requestInjection(this);
- logger.info("S3 Context = %1$s://%2$s:%3$s", (isSecure ? "https"
- : "http"), address, port);
- }
-
- @Provides
- @Singleton
- List provideRequestFilters(
- RequestAuthorizeSignature requestAuthorizeSignature) {
- List filters = new ArrayList();
- filters.add(requestAuthorizeSignature);
- return filters;
- }
-
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/config/S3ConnectionModule.java b/s3/src/main/java/org/jclouds/aws/s3/config/S3ConnectionModule.java
deleted file mode 100644
index 5cccf024d1..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/config/S3ConnectionModule.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.jclouds.aws.s3.config;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import org.jclouds.http.HttpFutureCommandClient;
-
-/**
- * designates the the module configures a {@link org.jclouds.aws.s3.S3Connection}
- *
- * @author Adrian Cole
- *
- */
-@Retention(RUNTIME)
-@Target(TYPE)
-public @interface S3ConnectionModule {
-
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/config/S3ContextModule.java b/s3/src/main/java/org/jclouds/aws/s3/config/S3ContextModule.java
deleted file mode 100644
index b158233e5b..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/config/S3ContextModule.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.config;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.assistedinject.FactoryProvider;
-import org.jclouds.aws.s3.S3Connection;
-import org.jclouds.aws.s3.S3Context;
-import org.jclouds.aws.s3.commands.config.S3CommandsModule;
-import org.jclouds.aws.s3.internal.GuiceS3Context;
-import org.jclouds.aws.s3.internal.LiveS3InputStreamMap;
-import org.jclouds.aws.s3.internal.LiveS3ObjectMap;
-
-/**
- * Configures the {@link S3Context}; requires {@link S3Connection} bound.
- *
- * @author Adrian Cole
- */
-public class S3ContextModule extends AbstractModule {
-
-
- @Override
- protected void configure() {
- this.requireBinding(S3Connection.class);
- install(new S3CommandsModule());
- bind(GuiceS3Context.S3ObjectMapFactory.class).toProvider(
- FactoryProvider.newFactory(
- GuiceS3Context.S3ObjectMapFactory.class,
- LiveS3ObjectMap.class));
- bind(GuiceS3Context.S3InputStreamMapFactory.class).toProvider(
- FactoryProvider.newFactory(
- GuiceS3Context.S3InputStreamMapFactory.class,
- LiveS3InputStreamMap.class));
- bind(S3Context.class).to(GuiceS3Context.class);
-
- }
-
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/config/package-info.java b/s3/src/main/java/org/jclouds/aws/s3/config/package-info.java
deleted file mode 100644
index 69fb6a5de0..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/config/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.
- * ====================================================================
- */
-/**
- * This package contains modules who manage the dependencies of the S3Context, S3Connection, and S3 Map views.
- * @author Adrian Cole
- */
-package org.jclouds.aws.s3.config;
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/domain/CanonicalUser.java b/s3/src/main/java/org/jclouds/aws/s3/domain/CanonicalUser.java
deleted file mode 100644
index 08a81d3622..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/domain/CanonicalUser.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.domain;
-
-/**
- * Every bucket and object in Amazon S3 has an owner, the user that created the
- * bucket or object. The owner of a bucket or object cannot be changed. However,
- * if the object is overwritten by another user (deleted and rewritten), the new
- * object will have a new owner.
- *
- *
- * @see
- * @author Adrian Cole
- */
-public class CanonicalUser {
- private final String id;
- private String displayName;
-
- public CanonicalUser(String id) {
- this.id = id;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("S3Owner");
- sb.append("{id='").append(id).append('\'');
- sb.append(", displayName='").append(displayName).append('\'');
- sb.append('}');
- return sb.toString();
- }
-
- /**
- * To locate the CanonicalUser ID for a user, the user must perform the
- * {@link org.jclouds.aws.s3.S3Connection#listBucket(String)} and retrieve
- * {@link S3Bucket.Metadata#getOwner()}
- */
- public String getId() {
- return id;
- }
-
- /**
- * read-only as is maintained by Amazon.
- */
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (!(o instanceof CanonicalUser))
- return false;
-
- CanonicalUser s3Owner = (CanonicalUser) o;
-
- if (displayName != null ? !displayName.equals(s3Owner.displayName)
- : s3Owner.displayName != null)
- return false;
- if (!id.equals(s3Owner.id))
- return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = id.hashCode();
- result = 31 * result
- + (displayName != null ? displayName.hashCode() : 0);
- return result;
- }
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/domain/S3Bucket.java b/s3/src/main/java/org/jclouds/aws/s3/domain/S3Bucket.java
deleted file mode 100644
index af8ddea48d..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/domain/S3Bucket.java
+++ /dev/null
@@ -1,336 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import org.joda.time.DateTime;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A container that provides namespace, access control and aggregation of
- * {@link S3Object}s
- *
- *
- * Every object stored in Amazon S3 is contained in a bucket. Buckets partition
- * the namespace of objects stored in Amazon S3 at the top level. Within a
- * bucket, you can use any names for your objects, but bucket names must be
- * unique across all of Amazon S3.
- *
- * Buckets are similar to Internet domain names. Just as Amazon is the only
- * owner of the domain name Amazon.com, only one person or organization can own
- * a bucket within Amazon S3. Once you create a uniquely named bucket in Amazon
- * S3, you can organize and name the objects within the bucket in any way you
- * like and the bucket will remain yours for as long as you like and as long as
- * you have the Amazon S3 account.
- *
- * The similarities between buckets and domain names is not a coincidenceÑthere
- * is a direct mapping between Amazon S3 buckets and subdomains of
- * s3.amazonaws.com. Objects stored in Amazon S3 are addressable using the REST
- * API under the domain bucketname.s3.amazonaws.com. For example, if the object
- * homepage.html?is stored in the Amazon S3 bucket mybucket its address would be
- * http://mybucket.s3.amazonaws.com/homepage.html?
- *
- * @author Adrian Cole
- * @see
- */
-public class S3Bucket {
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("S3Bucket");
- sb.append("{metadata=").append(metadata);
- sb.append(", isTruncated=").append(isTruncated);
- sb.append('}');
- return sb.toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (!(o instanceof S3Bucket))
- return false;
-
- S3Bucket s3Bucket = (S3Bucket) o;
-
- if (isTruncated != s3Bucket.isTruncated)
- return false;
- if (!metadata.equals(s3Bucket.metadata))
- return false;
- if (objects != null ? !objects.equals(s3Bucket.objects)
- : s3Bucket.objects != null)
- return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = objects != null ? objects.hashCode() : 0;
- result = 31 * result + metadata.hashCode();
- result = 31 * result + (isTruncated ? 1 : 0);
- return result;
- }
-
- /**
- * System metadata of the S3Bucket
- *
- * @author Adrian Cole
- */
- public static class Metadata {
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("Metadata");
- sb.append("{name='").append(name).append('\'');
- sb.append(", creationDate=").append(creationDate);
- sb.append(", canonicalUser=").append(canonicalUser);
- sb.append('}');
- return sb.toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (!(o instanceof Metadata))
- return false;
-
- Metadata metadata = (Metadata) o;
- if (canonicalUser != null ? !canonicalUser
- .equals(metadata.canonicalUser)
- : metadata.canonicalUser != null)
- return false;
- if (!name.equals(metadata.name))
- return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = name.hashCode();
- result = 31 * result
- + (canonicalUser != null ? canonicalUser.hashCode() : 0);
- return result;
- }
-
- /**
- * Location constraint of the bucket.
- *
- * @author Adrian Cole
- * @see
- */
- public static enum LocationConstraint {
- EU
- }
-
- private final String name;
- private DateTime creationDate;
- private CanonicalUser canonicalUser;
-
- /**
- * @see #getName()
- */
- public Metadata(String name) {
- this.name = checkNotNull(name, "name");
- }
-
- /**
- * To comply with Amazon S3 requirements, bucket names must:
- *
- * Contain lowercase letters, numbers, periods (.), underscores (_), and
- * dashes (-)
- *
- * Start with a number or letter
- *
- * Be between 3 and 255 characters long
- *
- * Not be in an IP address style (e.g., "192.168.5.4")
- */
- public String getName() {
- return name;
- }
-
- public DateTime getCreationDate() {
- return creationDate;
- }
-
- public void setCreationDate(DateTime creationDate) {
- this.creationDate = creationDate;
- }
-
- /**
- * Every bucket and object in Amazon S3 has an owner, the user that
- * created the bucket or object. The owner of a bucket or object cannot
- * be changed. However, if the object is overwritten by another user
- * (deleted and rewritten), the new object will have a new owner.
- */
- public CanonicalUser getOwner() {
- return canonicalUser;
- }
-
- public void setOwner(CanonicalUser canonicalUser) {
- this.canonicalUser = canonicalUser;
- }
-
- }
-
- public static final S3Bucket NOT_FOUND = new S3Bucket("NOT_FOUND");
-
- private Set objects = new HashSet();
- private Set commonPrefixes = new HashSet();
- private String prefix;
- private String marker;
- private String delimiter;
- private long maxKeys;
- private final Metadata metadata;
-
- private boolean isTruncated;
-
- public S3Bucket(String name) {
- this.metadata = new Metadata(name);
- }
-
- public String getName() {
- return this.metadata.getName();
- }
-
- public S3Bucket(Metadata metadata) {
- this.metadata = checkNotNull(metadata, "metadata");
- }
-
- /**
- * @see org.jclouds.aws.s3.S3Connection#listBucket(String)
- */
- public Set getContents() {
- return objects;
- }
-
- public void setContents(Set objects) {
- this.objects = objects;
- }
-
- /**
- * @return true, if the list contains all objects.
- */
- public boolean isTruncated() {
- return isTruncated;
- }
-
- public void setTruncated(boolean truncated) {
- isTruncated = truncated;
- }
-
- public Metadata getMetadata() {
- return metadata;
- }
-
- public void setCommonPrefixes(Set commonPrefixes) {
- this.commonPrefixes = commonPrefixes;
- }
-
- /**
- * Example:
- *
- * if the following keys are in the bucket
- *
- * a/1/a
- * a/1/b
- * a/2/a
- * a/2/b
- *
- * and prefix is set to a/
and delimiter is set to
- * /
then commonprefixes would return 1,2
- *
- * @see org.jclouds.aws.s3.commands.options.ListBucketOptions#getPrefix()
- */
- public Set getCommonPrefixes() {
- return commonPrefixes;
- }
-
- public void setPrefix(String prefix) {
- this.prefix = prefix;
- }
-
- /**
- * return keys that start with this.
- *
- * @see org.jclouds.aws.s3.commands.options.ListBucketOptions#getPrefix()
- */
- public String getPrefix() {
- return prefix;
- }
-
- public void setMaxKeys(long maxKeys) {
- this.maxKeys = maxKeys;
- }
-
- /**
- * @return maximum results of the bucket.
- * @see org.jclouds.aws.s3.commands.options.ListBucketOptions#getMaxKeys()
- */
- public long getMaxKeys() {
- return maxKeys;
- }
-
- public void setMarker(String marker) {
- this.marker = marker;
- }
-
- /**
- * when set, bucket contains results whose keys are lexigraphically after
- * marker.
- *
- * @see org.jclouds.aws.s3.commands.options.ListBucketOptions#getMarker()
- */
- public String getMarker() {
- return marker;
- }
-
- public void setDelimiter(String delimiter) {
- this.delimiter = delimiter;
- }
-
- /**
- * when set, bucket results will not contain keys that have text following
- * this delimiter.
- *
- * note that delimiter has no effect on prefix. prefix can contain the
- * delimiter many times, or not at all. delimiter only restricts after the
- * prefix.
- *
- * @see org.jclouds.aws.s3.commands.options.ListBucketOptions#getMarker()
- */
- public String getDelimiter() {
- return delimiter;
- }
-
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/domain/S3Error.java b/s3/src/main/java/org/jclouds/aws/s3/domain/S3Error.java
deleted file mode 100644
index bc201beae5..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/domain/S3Error.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.domain;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * When an Amazon S3 request is in error, the client receives an error response.
- *
- * @see
- * @author Adrian Cole
- *
- */
-public class S3Error {
- private String code;
- private String message;
- private String requestId;
- private String requestToken;
- private Map details = new HashMap();
- private String stringSigned;
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("S3Error");
- sb.append("{code='").append(code).append('\'');
- sb.append(", message='").append(message).append('\'');
- sb.append(", requestId='").append(requestId).append('\'');
- sb.append(", requestToken='").append(requestToken).append('\'');
- if (stringSigned != null)
- sb.append(", stringSigned='").append(stringSigned).append('\'');
- sb.append(", context='").append(details.toString()).append('\'')
- .append('}');
- return sb.toString();
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- /**
- * The error code is a string that uniquely identifies an error condition.
- * It is meant to be read and understood by programs that detect and handle
- * errors by type
- *
- * @see
- */
- public String getCode() {
- return code;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- /**
- * The error message contains a generic description of the error condition
- * in English.
- *
- * @see
- */
- public String getMessage() {
- return message;
- }
-
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
- /**
- * * A unique ID assigned to each request by the system. In the unlikely
- * event that you have problems with Amazon S3, Amazon can use this to help
- * troubleshoot the problem.
- *
- */
- public String getRequestId() {
- return requestId;
- }
-
- public void setStringSigned(String stringSigned) {
- this.stringSigned = stringSigned;
- }
-
- /**
- * @return what jclouds signed before sending the request.
- */
- public String getStringSigned() {
- return stringSigned;
- }
-
- public void setDetails(Map context) {
- this.details = context;
- }
-
- /**
- * @return additional details surrounding the error.
- */
- public Map getDetails() {
- return details;
- }
-
- public void setRequestToken(String requestToken) {
- this.requestToken = requestToken;
- }
-
- public String getRequestToken() {
- return requestToken;
- }
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/domain/S3Object.java b/s3/src/main/java/org/jclouds/aws/s3/domain/S3Object.java
deleted file mode 100644
index 2b0caf867e..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/domain/S3Object.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.domain;
-
-import static com.google.common.base.Preconditions.*;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import org.jclouds.aws.s3.commands.options.GetObjectOptions;
-import org.jclouds.aws.s3.util.S3Utils;
-import org.jclouds.aws.s3.util.S3Utils.Md5InputStreamResult;
-import org.jclouds.http.ContentTypes;
-import org.joda.time.DateTime;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-
-/**
- * Amazon S3 is designed to store objects. Objects are stored in
- * {@link S3Bucket buckets} and consist of a {@link org.jclouds.aws.s3.domain.S3Object#getData() value},
- * a {@link S3Object#getKey key}, {@link S3Object.Metadata#getUserMetadata()
- * metadata}, and an access control policy.
- *
- * @author Adrian Cole
- * @see
- */
-public class S3Object {
- public static final S3Object NOT_FOUND = new S3Object(Metadata.NOT_FOUND);
-
- private Object data;
- private Metadata metadata;
- private long contentLength = -1;
- private String contentRange;
-
- public S3Object(String key) {
- this(new Metadata(key));
- }
-
- public S3Object(Metadata metadata) {
- this.metadata = metadata;
- }
-
- public S3Object(Metadata metadata, Object data) {
- this(metadata);
- setData(data);
- }
-
- public S3Object(String key, Object data) {
- this(key);
- setData(data);
- }
-
- /**
- * System and user Metadata for the {@link S3Object}.
- *
- * @author Adrian Cole
- * @see
- */
- public static class Metadata implements Comparable {
- public static final Metadata NOT_FOUND = new Metadata("NOT_FOUND");
-
- // parsed during list, head, or get
- private final String key;
- private byte[] md5;
- private volatile long size = -1;
-
- // only parsed during head or get
- private Multimap allHeaders = HashMultimap.create();
- private Multimap userMetadata = HashMultimap.create();
- private DateTime lastModified;
- private String dataType = ContentTypes.BINARY;
- private String cacheControl;
- private String dataDisposition;
- private String dataEncoding;
-
- // only parsed on list
- private CanonicalUser owner = null;
- private String storageClass = null;
-
- /**
- * @param key
- * @see #getKey()
- */
- public Metadata(String key) {
- checkNotNull(key, "key");
- checkArgument(!key.startsWith("/"), "keys cannot start with /");
- this.key = key;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("Metadata");
- sb.append("{key='").append(key).append('\'');
- sb.append(", lastModified=").append(lastModified);
- sb.append(", md5=").append(
- getMd5() == null ? "null" : Arrays.asList(getMd5())
- .toString());
- sb.append(", size=").append(size);
- sb.append(", dataType='").append(dataType).append('\'');
- sb.append('}');
- return sb.toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (!(o instanceof Metadata))
- return false;
-
- Metadata metadata = (Metadata) o;
-
- if (size != metadata.size)
- return false;
- if (dataType != null ? !dataType.equals(metadata.dataType)
- : metadata.dataType != null)
- return false;
- if (!key.equals(metadata.key))
- return false;
- if (lastModified != null ? !lastModified
- .equals(metadata.lastModified)
- : metadata.lastModified != null)
- return false;
- if (!Arrays.equals(getMd5(), metadata.getMd5()))
- return false;
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = key.hashCode();
- result = 31 * result
- + (lastModified != null ? lastModified.hashCode() : 0);
- result = 31 * result
- + (getMd5() != null ? Arrays.hashCode(getMd5()) : 0);
- result = 31 * result + (int) (size ^ (size >>> 32));
- result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
- return result;
- }
-
- /**
- * The key is the handle that you assign to an object that allows you
- * retrieve it later. A key is a sequence of Unicode characters whose
- * UTF-8 encoding is at most 1024 bytes long. Each object in a bucket
- * must have a unique key.
- *
- * @see
- */
- public String getKey() {
- return key;
- }
-
- public DateTime getLastModified() {
- return lastModified;
- }
-
- public void setLastModified(DateTime lastModified) {
- this.lastModified = lastModified;
- }
-
- /**
- * The size of the object, in bytes.
- *
- * @see
- */
- public long getSize() {
- return size;
- }
-
- public void setSize(long size) {
- this.size = size;
- }
-
- /**
- * A standard MIME type describing the format of the contents. If none
- * is provided, the default is binary/octet-stream.
- * @see
- */
- public String getContentType() {
- return dataType;
- }
-
- public void setContentType(String dataType) {
- this.dataType = dataType;
- }
-
- public void setMd5(byte[] md5) {
- this.md5 = Arrays.copyOf(md5, md5.length);
- }
-
- /**
- * @return the md5 value stored in the Etag header returned by S3.
- */
- public byte[] getMd5() {
- return (md5 == null) ? null : Arrays.copyOf(md5, md5.length);
- }
-
- public void setUserMetadata(Multimap userMetadata) {
- this.userMetadata = userMetadata;
- }
-
- /**
- * Any header starting with x-amz-meta-
is considered user
- * metadata. It will be stored with the object and returned when you
- * retrieve the object. The total size of the HTTP request, not
- * including the body, must be less than 8 KB.
- */
- public Multimap getUserMetadata() {
- return userMetadata;
- }
-
- public void setOwner(CanonicalUser owner) {
- this.owner = owner;
- }
-
- /**
- * Every bucket and object in Amazon S3 has an owner, the user that
- * created the bucket or object. The owner of a bucket or object cannot
- * be changed. However, if the object is overwritten by another user
- * (deleted and rewritten), the new object will have a new owner.
- */
- public CanonicalUser getOwner() {
- return owner;
- }
-
- public void setStorageClass(String storageClass) {
- this.storageClass = storageClass;
- }
-
- /**
- * Currently defaults to 'STANDARD' and not used.
- */
- public String getStorageClass() {
- return storageClass;
- }
-
- public void setCacheControl(String cacheControl) {
- this.cacheControl = cacheControl;
- }
-
- /**
- * Can be used to specify caching behavior along the request/reply
- * chain.
- *
- * @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html?sec14.9.
- */
- public String getCacheControl() {
- return cacheControl;
- }
-
- public void setContentDisposition(String dataDisposition) {
- this.dataDisposition = dataDisposition;
- }
-
- /**
- * Specifies presentational information for the object.
- *
- * @see
- */
- public String getContentDisposition() {
- return dataDisposition;
- }
-
- public void setContentEncoding(String dataEncoding) {
- this.dataEncoding = dataEncoding;
- }
-
- /**
- * Specifies what content encodings have been applied to the object and
- * thus what decoding mechanisms must be applied in order to obtain the
- * media-type referenced by the Content-Type header field.
- *
- * @see
- */
- public String getContentEncoding() {
- return dataEncoding;
- }
-
- public void setAllHeaders(Multimap allHeaders) {
- this.allHeaders = allHeaders;
- }
-
- /**
- * @return all http response headers associated with this S3Object
- */
- public Multimap getAllHeaders() {
- return allHeaders;
- }
-
- public int compareTo(Metadata o) {
- return (this == o) ? 0 : getKey().compareTo(o.getKey());
- }
- }
-
- /**
- * @see Metadata#getKey()
- */
- public String getKey() {
- return metadata.getKey();
- }
-
- /**
- * Sets payload for the request or the content from the response. If size
- * isn't set, this will attempt to discover it.
- *
- * @param data typically InputStream for downloads, or File, byte [], String,
- * or InputStream for uploads.
- */
- public void setData(Object data) {
- this.data = checkNotNull(data, "data");
- if (getMetadata().getSize() == -1)
- this.getMetadata().setSize(S3Utils.calculateSize(data));
- }
-
- /**
- * generate an MD5 Hash for the current data.
- *
- * Note
- *
- * If this is an InputStream, it will be converted to a byte array first.
- *
- * @throws IOException if there is a problem generating the hash.
- */
- public void generateMd5() throws IOException {
- checkState(data != null, "data");
- if (data instanceof InputStream) {
- Md5InputStreamResult result = S3Utils
- .generateMd5Result((InputStream) data);
- getMetadata().setSize(result.length);
- getMetadata().setMd5(result.md5);
- setData(result.data);
- } else {
- getMetadata().setMd5(S3Utils.md5(data));
- }
- }
-
- /**
- * @return InputStream, if downloading, or whatever was set during
- * {@link #setData(Object)}
- */
- public Object getData() {
- return data;
- }
-
- public void setMetadata(Metadata metadata) {
- this.metadata = metadata;
- }
-
- /**
- * @return System and User metadata relevant to this object.
- */
- public Metadata getMetadata() {
- return metadata;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("S3Object");
- sb.append("{metadata=").append(metadata);
- sb.append('}');
- return sb.toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (!(o instanceof S3Object))
- return false;
-
- S3Object s3Object = (S3Object) o;
-
- if (data != null ? !data.equals(s3Object.data) : s3Object.data != null)
- return false;
- if (!metadata.equals(s3Object.metadata))
- return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = data != null ? data.hashCode() : 0;
- result = 31 * result + metadata.hashCode();
- return result;
- }
-
- public void setContentLength(long contentLength) {
- this.contentLength = contentLength;
- }
-
- /**
- * Returns the total size of the downloaded object, or the chunk that's
- * available.
- *
- * Chunking is only used when
- * {@link org.jclouds.aws.s3.S3Connection#getObject(String, String, org.jclouds.aws.s3.commands.options.GetObjectOptions) }
- * is called with options like tail, range, or startAt.
- *
- * @return the length in bytes that can be be obtained from
- * {@link #getData()}
- * @see org.jclouds.http.HttpHeaders#CONTENT_LENGTH
- * @see GetObjectOptions
- */
- public long getContentLength() {
- return contentLength;
- }
-
- public void setContentRange(String contentRange) {
- this.contentRange = contentRange;
- }
-
- /**
- * If this is not-null, {@link #getContentLength() } will the size of chunk
- * of the S3Object available via {@link #getData()}
- *
- * @see org.jclouds.http.HttpHeaders#CONTENT_RANGE
- * @see GetObjectOptions
- */
- public String getContentRange() {
- return contentRange;
- }
-
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/domain/acl/CannedAccessPolicy.java b/s3/src/main/java/org/jclouds/aws/s3/domain/acl/CannedAccessPolicy.java
deleted file mode 100644
index 49f097946f..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/domain/acl/CannedAccessPolicy.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.domain.acl;
-
-/**
- * Description from Amazon's documentation:
- *
- *
- * Because of restrictions in what can be sent via http headers, Amazon S3
- * supports the concept of canned access policies for REST. A canned access
- * policy can be included with the x-amz-acl header as part of a PUT operation
- * to provide shorthand representation of a full access policy. When Amazon S3
- * sees the x-amz-acl header as part of a PUT operation, it will assign the
- * respective access policy to the resource created as a result of the PUT. If
- * no x-amz-acl header is included with a PUT request, then the bucket or object
- * is written with the private access control policy (even if, in the case of an
- * object, the object already exists with some other pre-existing access control
- * policy).
- *
- * @see
- * @author Adrian Cole
- *
- */
-public enum CannedAccessPolicy {
-
- /**
- * Owner gets FULL_CONTROL. No one else has access rights (default).
- */
- PRIVATE("private"),
- /**
- * Owner gets FULL_CONTROL and the anonymous principal is granted READ
- * access. If this policy is used on an object, it can be read from a
- * browser with no authentication.
- */
- PUBLIC_READ("public-read"),
- /**
- * Owner gets FULL_CONTROL, the anonymous principal is granted READ and
- * WRITE access. This can be a useful policy to apply to a bucket, but is
- * generally not recommended.
- */
- PUBLIC_READ_WRITE("public-read-write"),
- /**
- * Owner gets FULL_CONTROL, and any principal authenticated as a registered
- * Amazon S3 user is granted READ access.
- */
- AUTHENTICATED_READ("authenticated-read");
-
- private String policyName;
-
- CannedAccessPolicy(String policyName) {
- this.policyName = policyName;
- }
-
- @Override
- public String toString() {
- return policyName;
- }
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/domain/acl/package-info.java b/s3/src/main/java/org/jclouds/aws/s3/domain/acl/package-info.java
deleted file mode 100644
index 0c3b684bce..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/domain/acl/package-info.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.
- * ====================================================================
- */
-/**
- * This package contains components that represent authorization state.
- * @see
- * @author Adrian Cole
- */
-package org.jclouds.aws.s3.domain.acl;
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/domain/package-info.java b/s3/src/main/java/org/jclouds/aws/s3/domain/package-info.java
deleted file mode 100644
index e5cd0c6deb..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/domain/package-info.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.
- * ====================================================================
- */
-/**
- * This package contains the core components of S3.
- * @see
- * @author Adrian Cole
- */
-package org.jclouds.aws.s3.domain;
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignature.java b/s3/src/main/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignature.java
deleted file mode 100644
index b1ddb1cbb1..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignature.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.filters;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.jclouds.aws.s3.reference.S3Constants;
-import org.jclouds.aws.s3.util.DateService;
-import org.jclouds.aws.s3.util.S3Utils;
-import org.jclouds.http.HttpException;
-import org.jclouds.http.HttpHeaders;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpRequestFilter;
-
-import com.google.inject.Inject;
-import com.google.inject.name.Named;
-
-/**
- * Signs the S3 request. This will update timestamps at most once per second.
- *
- * @see
- * @author Adrian Cole
- *
- */
-public class RequestAuthorizeSignature implements HttpRequestFilter {
- private static final String[] firstHeadersToSign = new String[] {
- HttpHeaders.CONTENT_MD5, HttpHeaders.CONTENT_TYPE, HttpHeaders.DATE };
-
- private final String accessKey;
- private final String secretKey;
- private final DateService dateService;
-
- public static final long BILLION = 1000000000;
- private final AtomicReference timeStamp;
- private final AtomicLong trigger = new AtomicLong(System.nanoTime() + 1
- * BILLION);
-
- /**
- * Start the time update service. Amazon clocks need to be within 900
- * seconds of the request time. This method updates the clock every second.
- * This is not performed per-request, as creation of the date object is a
- * slow, synchronized command.
- */
- synchronized void updateIfTimeOut() {
-
- if (trigger.get() - System.nanoTime() <= 0) {
- timeStamp.set(createNewStamp());
- trigger.set(System.nanoTime() + 1 * BILLION);
- }
-
- }
-
- // this is a hotspot when submitted concurrently, so be lazy.
- // amazon is ok with up to 15 minutes off their time, so let's
- // be as lazy as possible.
- String createNewStamp() {
- return dateService.timestampAsHeaderString();
- }
-
- public String timestampAsHeaderString() {
- updateIfTimeOut();
- return timeStamp.get();
- }
-
- @Inject
- public RequestAuthorizeSignature(
- @Named(S3Constants.PROPERTY_AWS_ACCESSKEYID) String accessKey,
- @Named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY) String secretKey,
- DateService dateService) {
- this.accessKey = accessKey;
- this.secretKey = secretKey;
- this.dateService = dateService;
- timeStamp = new AtomicReference(createNewStamp());
- }
-
- public void filter(HttpRequest request) throws HttpException {
- // re-sign the request
- removeOldHeaders(request);
-
- addDateHeader(request);
-
- String toSign = createStringToSign(request);
-
- addAuthHeader(request, toSign);
- }
-
- public static String createStringToSign(HttpRequest request) {
- StringBuilder buffer = new StringBuilder();
- appendMethod(request, buffer);
- appendHttpHeaders(request, buffer);
- appendAmzHeaders(request, buffer);
- appendBucketName(request, buffer);
- appendUriPath(request, buffer);
- return buffer.toString();
- }
-
- private void removeOldHeaders(HttpRequest request) {
- request.getHeaders().removeAll(S3Constants.AUTHORIZATION);
- request.getHeaders().removeAll(HttpHeaders.CONTENT_TYPE);
- request.getHeaders().removeAll(HttpHeaders.DATE);
- }
-
- private void addAuthHeader(HttpRequest request, String toSign)
- throws HttpException {
- String signature;
- try {
- signature = S3Utils.hmacSha1Base64(toSign, secretKey.getBytes());
- } catch (Exception e) {
- throw new HttpException("error signing request", e);
- }
- request.getHeaders().put(S3Constants.AUTHORIZATION,
- "AWS " + accessKey + ":" + signature);
- }
-
- private static void appendMethod(HttpRequest request, StringBuilder toSign) {
- toSign.append(request.getMethod()).append("\n");
- }
-
- private void addDateHeader(HttpRequest request) {
- request.getHeaders().put(HttpHeaders.DATE, timestampAsHeaderString());
- }
-
- private static void appendAmzHeaders(HttpRequest request,
- StringBuilder toSign) {
- Set headers = new TreeSet(request.getHeaders().keySet());
- for (String header : headers) {
- if (header.startsWith("x-amz-")) {
- toSign.append(header).append(":");
- for (String value : request.getHeaders().get(header))
- toSign.append(value.replaceAll("\r?\n", "")).append(",");
- toSign.deleteCharAt(toSign.lastIndexOf(","));
- toSign.append("\n");
- }
- }
- }
-
- private static void appendHttpHeaders(HttpRequest request,
- StringBuilder toSign) {
- for (String header : firstHeadersToSign)
- toSign.append(valueOrEmpty(request.getHeaders().get(header)))
- .append("\n");
- }
-
- private static void appendBucketName(HttpRequest request,
- StringBuilder toSign) {
- String hostHeader = request.getHeaders().get(HttpHeaders.HOST)
- .iterator().next();
- if (hostHeader.endsWith(".s3.amazonaws.com"))
- toSign.append("/").append(
- hostHeader.substring(0, hostHeader.length() - 17));
- }
-
- private static void appendUriPath(HttpRequest request, StringBuilder toSign) {
- int queryIndex = request.getUri().indexOf('?');
- if (queryIndex >= 0)
- toSign.append(request.getUri().substring(0, queryIndex));
- else
- toSign.append(request.getUri());
- }
-
- private static String valueOrEmpty(Collection collection) {
- return (collection != null && collection.size() >= 1) ? collection
- .iterator().next() : "";
- }
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/filters/package-info.java b/s3/src/main/java/org/jclouds/aws/s3/filters/package-info.java
deleted file mode 100644
index 327f2e9230..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/filters/package-info.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.
- * ====================================================================
- */
-/**
- * This package contains HttpRequestFilters needed to operate the REST api.
- * @see
- * @author Adrian Cole
- */
-package org.jclouds.aws.s3.filters;
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/handlers/ParseS3ErrorFromXmlContent.java b/s3/src/main/java/org/jclouds/aws/s3/handlers/ParseS3ErrorFromXmlContent.java
deleted file mode 100644
index c0a6a072b9..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/handlers/ParseS3ErrorFromXmlContent.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.handlers;
-
-import java.io.InputStream;
-
-import javax.annotation.Resource;
-
-import org.apache.commons.io.IOUtils;
-import org.jclouds.aws.s3.S3ResponseException;
-import org.jclouds.aws.s3.domain.S3Error;
-import org.jclouds.aws.s3.filters.RequestAuthorizeSignature;
-import org.jclouds.aws.s3.reference.S3Headers;
-import org.jclouds.aws.s3.xml.S3ParserFactory;
-import org.jclouds.http.HttpFutureCommand;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpResponseHandler;
-import org.jclouds.logging.Logger;
-
-
-import com.google.inject.Inject;
-
-/**
- * This will parse and set an appropriate exception on the command object.
- *
- * @see S3Error
- * @author Adrian Cole
- *
- */
-public class ParseS3ErrorFromXmlContent implements HttpResponseHandler {
- @Resource
- protected Logger logger = Logger.NULL;
-
- private final S3ParserFactory parserFactory;
-
- @Inject
- public ParseS3ErrorFromXmlContent(S3ParserFactory parserFactory) {
- this.parserFactory = parserFactory;
- }
-
- public void handle(HttpFutureCommand> command, HttpResponse response) {
- S3Error error = new S3Error();
- error.setRequestId(response.getFirstHeaderOrNull(S3Headers.REQUEST_ID));
- error.setRequestToken(response
- .getFirstHeaderOrNull(S3Headers.REQUEST_TOKEN));
- InputStream errorStream = response.getContent();
- try {
- if (errorStream != null) {
- error = parserFactory.createErrorParser().parse(errorStream);
- if ("SignatureDoesNotMatch".equals(error.getCode()))
- error.setStringSigned(RequestAuthorizeSignature
- .createStringToSign(command.getRequest()));
- error.setRequestToken(response
- .getFirstHeaderOrNull(S3Headers.REQUEST_TOKEN));
- }
- } catch (Exception e) {
- logger.warn(e, "error parsing XML reponse: %1$s", response);
- } finally {
- command.setException(new S3ResponseException(command, response,
- error));
- IOUtils.closeQuietly(errorStream);
- }
- }
-
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/handlers/package-info.java b/s3/src/main/java/org/jclouds/aws/s3/handlers/package-info.java
deleted file mode 100644
index 4a6d03a147..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/handlers/package-info.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.
- * ====================================================================
- */
-/**
- * This package contains HttpResponseHandlers needed to operate the REST api.
- * @see
- * @author Adrian Cole
- */
-package org.jclouds.aws.s3.handlers;
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/internal/BaseS3Map.java b/s3/src/main/java/org/jclouds/aws/s3/internal/BaseS3Map.java
deleted file mode 100644
index 84ea134b1d..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/internal/BaseS3Map.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.name.Named;
-import org.jclouds.aws.s3.S3Connection;
-import org.jclouds.aws.s3.S3Map;
-import org.jclouds.aws.s3.domain.S3Bucket;
-import org.jclouds.aws.s3.domain.S3Object;
-import org.jclouds.aws.s3.reference.S3Constants;
-import org.jclouds.util.Utils;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-/**
- * Implements core Map functionality with an {@link S3Connection}
- *
- * All commands will wait a maximum of ${jclouds.s3.map.timeout} milliseconds to
- * complete before throwing an exception.
- *
- * @author Adrian Cole
- * @param
- * value of the map
- */
-public abstract class BaseS3Map implements S3Map {
-
- protected final S3Connection connection;
- protected final String bucket;
-
- /**
- * maximum duration of an S3 Request
- */
- @Inject(optional = true)
- @Named(S3Constants.PROPERTY_S3_MAP_TIMEOUT)
- protected long requestTimeoutMilliseconds = 10000;
-
- @Inject
- public BaseS3Map(S3Connection connection, @Assisted String bucket) {
- this.connection = checkNotNull(connection, "connection");
- this.bucket = checkNotNull(bucket, "bucketName");
- }
-
- /**
- * {@inheritDoc}
- *
- * This returns the number of keys in the {@link S3Bucket}
- *
- * @see S3Bucket#getContents()
- */
- public int size() {
- try {
- S3Bucket bucket = refreshBucket();
- Set contents = bucket.getContents();
- return contents.size();
- } catch (Exception e) {
- Utils.rethrowIfRuntimeOrSameType(e);
- throw new S3RuntimeException("Error getting size of bucketName"
- + bucket, e);
- }
- }
-
- protected boolean containsMd5(byte[] md5) throws InterruptedException,
- ExecutionException, TimeoutException {
- for (S3Object.Metadata metadata : refreshBucket().getContents()) {
- if (Arrays.equals(md5, metadata.getMd5()))
- return true;
- }
- return false;
- }
-
- protected byte[] getMd5(Object value) throws IOException,
- FileNotFoundException, InterruptedException, ExecutionException,
- TimeoutException {
- S3Object object = null;
- if (value instanceof S3Object) {
- object = (S3Object) value;
- } else {
- object = new S3Object("dummy", value);
- }
- if (object.getMetadata().getMd5() == null)
- object.generateMd5();
- return object.getMetadata().getMd5();
- }
-
- /**
- * attempts asynchronous gets on all objects.
- *
- * @see S3Connection#getObject(String, String)
- */
- protected Set getAllObjects() {
- Set objects = new HashSet();
- Set> futureObjects = new HashSet>();
- for (String key : keySet()) {
- futureObjects.add(connection.getObject(bucket, key));
- }
- for (Future futureObject : futureObjects) {
- S3Object object = null;
- try {
- object = futureObject.get(requestTimeoutMilliseconds,
- TimeUnit.MILLISECONDS);
- } catch (Exception e) {
- Utils.rethrowIfRuntimeOrSameType(e);
- throw new S3RuntimeException(String.format(
- "Error getting value from bucket %1$s", bucket), e);
- }
- if (object != S3Object.NOT_FOUND)
- objects.add(object);
- }
- return objects;
- }
-
- /**
- * {@inheritDoc}
- *
- * Note that if value is an instance of InputStream, it will be read and
- * closed following this method. To reuse data from InputStreams, pass
- * {@link java.io.InputStream}s inside {@link S3Object}s
- */
- public boolean containsValue(Object value) {
- try {
- byte[] md5 = getMd5(value);
- return containsMd5(md5);
- } catch (Exception e) {
- Utils.rethrowIfRuntimeOrSameType(e);
- throw new S3RuntimeException(String.format(
- "Error searching for ETAG of value: [%2$s] in bucketName:%1$s",
- bucket, value), e);
- }
- }
-
- public static class S3RuntimeException extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- S3RuntimeException(String s) {
- super(s);
- }
-
- public S3RuntimeException(String s, Throwable throwable) {
- super(s, throwable);
- }
- }
-
- public void clear() {
- try {
- List> deletes = new ArrayList>();
- for (String key : keySet()) {
- deletes.add(connection.deleteObject(bucket, key));
- }
- for (Future isdeleted : deletes)
- if (!isdeleted.get(requestTimeoutMilliseconds,
- TimeUnit.MILLISECONDS)) {
- throw new S3RuntimeException("failed to delete entry");
- }
- } catch (Exception e) {
- Utils.rethrowIfRuntimeOrSameType(e);
- throw new S3RuntimeException("Error clearing bucketName" + bucket, e);
- }
- }
-
- protected S3Bucket refreshBucket() throws InterruptedException,
- ExecutionException, TimeoutException {
- S3Bucket currentBucket = connection.listBucket(bucket).get(
- requestTimeoutMilliseconds, TimeUnit.MILLISECONDS);
- if (currentBucket == S3Bucket.NOT_FOUND)
- throw new S3RuntimeException("bucketName not found: " + bucket);
- else
- return currentBucket;
- }
-
- public Set keySet() {
- try {
- Set keys = new HashSet();
- for (S3Object.Metadata object : refreshBucket().getContents())
- keys.add(object.getKey());
- return keys;
- } catch (Exception e) {
- Utils.rethrowIfRuntimeOrSameType(e);
- throw new S3RuntimeException("Error getting keys in bucketName: "
- + bucket, e);
- }
- }
-
- public boolean containsKey(Object key) {
- try {
- return connection.headObject(bucket, key.toString()).get(
- requestTimeoutMilliseconds, TimeUnit.MILLISECONDS) != S3Object.Metadata.NOT_FOUND;
- } catch (Exception e) {
- Utils.rethrowIfRuntimeOrSameType(e);
- throw new S3RuntimeException(String.format(
- "Error searching for %1$s:%2$s", bucket, key), e);
- }
- }
-
- public boolean isEmpty() {
- return keySet().size() == 0;
- }
-
- public S3Bucket getBucket() {
- try {
- return refreshBucket();
- } catch (Exception e) {
- Utils.rethrowIfRuntimeOrSameType(e);
- throw new S3RuntimeException("Error getting bucketName" + bucket, e);
- }
- }
-}
\ No newline at end of file
diff --git a/s3/src/main/java/org/jclouds/aws/s3/internal/GuiceS3Context.java b/s3/src/main/java/org/jclouds/aws/s3/internal/GuiceS3Context.java
deleted file mode 100644
index 8cf0e427b2..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/internal/GuiceS3Context.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.internal;
-
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import org.jclouds.aws.s3.S3Connection;
-import org.jclouds.aws.s3.S3Context;
-import org.jclouds.aws.s3.S3InputStreamMap;
-import org.jclouds.aws.s3.S3ObjectMap;
-import org.jclouds.lifecycle.Closer;
-import org.jclouds.logging.Logger;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-
-/**
- * Uses a Guice Injector to configure the objects served by S3Context methods.
- *
- * @author Adrian Cole
- * @see Injector
- */
-public class GuiceS3Context implements S3Context {
- public interface S3ObjectMapFactory {
- S3ObjectMap createMapView(String bucket);
- }
-
- public interface S3InputStreamMapFactory {
- S3InputStreamMap createMapView(String bucket);
- }
-
- @Resource
- private Logger logger = Logger.NULL;
- private final Injector injector;
- private final S3InputStreamMapFactory s3InputStreamMapFactory;
- private final S3ObjectMapFactory s3ObjectMapFactory;
- private final Closer closer;
-
- @Inject
- private GuiceS3Context(Injector injector, Closer closer,
- S3ObjectMapFactory s3ObjectMapFactory,
- S3InputStreamMapFactory s3InputStreamMapFactory) {
- this.injector = injector;
- this.s3InputStreamMapFactory = s3InputStreamMapFactory;
- this.s3ObjectMapFactory = s3ObjectMapFactory;
- this.closer = closer;
- }
-
- /**
- * {@inheritDoc}
- */
- public S3Connection getConnection() {
- return injector.getInstance(S3Connection.class);
- }
-
- /**
- * {@inheritDoc}
- */
- public S3InputStreamMap createInputStreamMap(String bucket) {
- getConnection().putBucketIfNotExists(bucket);
- return s3InputStreamMapFactory.createMapView(bucket);
- }
-
- /**
- * {@inheritDoc}
- */
- public S3ObjectMap createS3ObjectMap(String bucket) {
- getConnection().putBucketIfNotExists(bucket);
- return s3ObjectMapFactory.createMapView(bucket);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see Closer
- */
- public void close() {
- try {
- closer.close();
- } catch (IOException e) {
- logger.error(e, "error closing content");
- }
- }
-
-}
diff --git a/s3/src/main/java/org/jclouds/aws/s3/internal/LiveS3Connection.java b/s3/src/main/java/org/jclouds/aws/s3/internal/LiveS3Connection.java
deleted file mode 100644
index 8a28fb2ceb..0000000000
--- a/s3/src/main/java/org/jclouds/aws/s3/internal/LiveS3Connection.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/**
- *
- * Copyright (C) 2009 Adrian Cole
- *
- * ====================================================================
- * 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.internal;
-
-import java.util.List;
-import java.util.concurrent.Future;
-
-import org.jclouds.aws.s3.S3Connection;
-import org.jclouds.aws.s3.commands.BucketExists;
-import org.jclouds.aws.s3.commands.CopyObject;
-import org.jclouds.aws.s3.commands.DeleteBucket;
-import org.jclouds.aws.s3.commands.DeleteObject;
-import org.jclouds.aws.s3.commands.ListOwnedBuckets;
-import org.jclouds.aws.s3.commands.GetObject;
-import org.jclouds.aws.s3.commands.HeadObject;
-import org.jclouds.aws.s3.commands.ListBucket;
-import org.jclouds.aws.s3.commands.PutBucket;
-import org.jclouds.aws.s3.commands.PutObject;
-import org.jclouds.aws.s3.commands.S3CommandFactory;
-import org.jclouds.aws.s3.commands.options.CopyObjectOptions;
-import org.jclouds.aws.s3.commands.options.GetObjectOptions;
-import org.jclouds.aws.s3.commands.options.ListBucketOptions;
-import org.jclouds.aws.s3.commands.options.PutBucketOptions;
-import org.jclouds.aws.s3.commands.options.PutObjectOptions;
-import org.jclouds.aws.s3.domain.S3Bucket;
-import org.jclouds.aws.s3.domain.S3Object;
-import org.jclouds.aws.s3.domain.S3Bucket.Metadata;
-import org.jclouds.http.HttpFutureCommandClient;
-
-import com.google.inject.Inject;
-
-/**
- * Uses {@link HttpFutureCommandClient} to invoke the REST API of S3.
- *
- * @see
- * @author Adrian Cole
- */
-public class LiveS3Connection implements S3Connection {
-
- private final HttpFutureCommandClient client;
- /**
- * creates command objects that can be submitted to the client
- */
- private final S3CommandFactory factory;
-
- @Inject
- public LiveS3Connection(HttpFutureCommandClient client,
- S3CommandFactory factory) {
- this.client = client;
- this.factory = factory;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see GetObject
- */
- public Future getObject(String s3Bucket, String key) {
- return getObject(s3Bucket, key, GetObjectOptions.NONE);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see GetObject
- */
- public Future getObject(String s3Bucket, String key,
- GetObjectOptions options) {
- GetObject getObject = factory.createGetObject(s3Bucket, key, options);
- client.submit(getObject);
- return getObject;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see HeadObject
- */
- public Future headObject(String s3Bucket, String key) {
- HeadObject headMetadata = factory.createHeadMetadata(s3Bucket, key);
- client.submit(headMetadata);
- return headMetadata;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see DeleteObject
- */
- public Future