diff --git a/assemblies/src/main/resources/assemblies/jar-with-dependencies-descriptor.xml b/assemblies/src/main/resources/assemblies/jar-with-dependencies-descriptor.xml index b8981b4f39..e55eb314bb 100644 --- a/assemblies/src/main/resources/assemblies/jar-with-dependencies-descriptor.xml +++ b/assemblies/src/main/resources/assemblies/jar-with-dependencies-descriptor.xml @@ -31,6 +31,8 @@ runtime org.jclouds:jclouds-core + org.jclouds:jclouds-blobstore + org.jclouds:jclouds-compute true @@ -50,4 +52,4 @@ META-INF/maven/${project.groupId}/${project.artifactId} - \ No newline at end of file + diff --git a/assemblies/src/main/resources/assemblies/package-descriptor.xml b/assemblies/src/main/resources/assemblies/package-descriptor.xml index 85ad20c68d..9c26690fae 100644 --- a/assemblies/src/main/resources/assemblies/package-descriptor.xml +++ b/assemblies/src/main/resources/assemblies/package-descriptor.xml @@ -28,9 +28,15 @@ LICENSE.txt README.txt core - + docs <- javadoc for core - + lib <- core jar and dependencies for core - + src <- expanded or source jar for core + + docs <- javadoc for core, blobstore, and compute + + lib <- core, blobstore, and compute jars and dependencies for core + + src <- expanded or source jar for core, blobstore, and compute + profiles + + enterprise + + README.txt <- how to use the profile + + lib <- not core + + docs <- not core + + src <- not core extensions + log4j + README.txt <- how to use the extension @@ -43,6 +49,12 @@ + lib <- not core + docs <- not core + src <- not core + tools <- integrations with other tools + + antcontrib + + README.txt <- how to use the tool + + lib <- not core + + docs <- not core + + src <- not core samples <- includes samples and demos + tweetstore + README.txt <- how to build and run the sample @@ -75,6 +87,20 @@ core/lib + + blobstore/target + + jclouds-blobstore-${project.version}.jar + + core/lib + + + compute/target + + jclouds-compute-${project.version}.jar + + core/lib + core/target @@ -82,16 +108,38 @@ core/src + + blobstore/target + + jclouds-blobstore-${project.version}-sources.jar + + core/src + + + compute/target + + jclouds-compute-${project.version}-sources.jar + + core/src + core/target/apidocs core/docs + + blobstore/target/apidocs + core/docs + + + compute/target/apidocs + core/docs + atmos/target - jclouds-atmos-${project.version}-jar-with-dependencies.jar + jclouds-atmos-${project.version}.jar providers/atmos/lib @@ -118,7 +166,7 @@ aws/core/target - jclouds-aws-${project.version}-jar-with-dependencies.jar + jclouds-aws-${project.version}.jar providers/aws/lib @@ -172,7 +220,7 @@ azure/target - jclouds-azure-${project.version}-jar-with-dependencies.jar + jclouds-azure-${project.version}.jar providers/azure/lib @@ -199,7 +247,7 @@ vcloud/hostingdotcom/target - jclouds-hostingdotcom-${project.version}-jar-with-dependencies.jar + jclouds-hostingdotcom-${project.version}.jar providers/hostingdotcom/lib @@ -226,7 +274,7 @@ mezeo/pcs2/target - jclouds-pcs2-${project.version}-jar-with-dependencies.jar + jclouds-pcs2-${project.version}.jar providers/mezeo/lib @@ -253,7 +301,7 @@ nirvanix/sdn/target - jclouds-sdn-${project.version}-jar-with-dependencies.jar + jclouds-sdn-${project.version}.jar providers/nirvanix/lib @@ -280,7 +328,7 @@ rackspace/target - jclouds-rackspace-${project.version}-jar-with-dependencies.jar + jclouds-rackspace-${project.version}.jar providers/rackspace/lib @@ -334,7 +382,7 @@ vcloud/terremark/target - jclouds-terremark-${project.version}-jar-with-dependencies.jar + jclouds-terremark-${project.version}.jar providers/terremark/lib @@ -411,6 +459,33 @@ extensions/bouncycastle + + + extensions/enterprise/target + + jclouds-enterprise-${project.version}-jar-with-dependencies.jar + + profiles/enterprise/lib + + + extensions/enterprise/target + + jclouds-enterprise-${project.version}-sources.jar + + profiles/enterprise/src + + + extensions/enterprise/target/apidocs + profiles/enterprise/docs + + + extensions/enterprise + + README.txt + + profiles/enterprise + + extensions/gae/target @@ -469,7 +544,7 @@ extensions/httpnio/target - jclouds-httpnio-${project.version}-jar-with-dependencies.jar + jclouds-httpnio-${project.version}.jar extensions/httpnio/lib @@ -496,7 +571,7 @@ extensions/jsch/target - jclouds-jsch-${project.version}-jar-with-dependencies.jar + jclouds-jsch-${project.version}.jar extensions/ssh/jsch/lib @@ -545,7 +620,61 @@ extensions/log4j + + + + tools/antcontrib/target + + jclouds-antcontrib-${project.version}-jar-with-dependencies.jar + + tools/antcontrib/lib + + + tools/antcontrib/target + + jclouds-antcontrib-${project.version}-sources.jar + + tools/antcontrib/src + + + tools/antcontrib/target/apidocs + tools/antcontrib/docs + + + tools/antcontrib + + README.txt + + tools/antcontrib + + + + tools/vfs/target + + jclouds-vfs-${project.version}-jar-with-dependencies.jar + + tools/vfs/lib + + + tools/vfs/target + + jclouds-vfs-${project.version}-sources.jar + + tools/vfs/src + + + tools/vfs/target/apidocs + tools/vfs/docs + + + tools/vfs + + README.txt + + tools/vfs + + demos/gae-tweetstore/target/jclouds-demo-gae-tweetstore diff --git a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java index 8c93c173b6..cacb576490 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java @@ -71,7 +71,7 @@ public interface AsyncBlobStore { ListenableFuture clearContainer(String container); /** - * @see BlobStore#clearDirectory(String, ListContainerOptions) + * @see BlobStore#clearContainer(String, ListContainerOptions) */ ListenableFuture clearContainer(String container, ListContainerOptions options); @@ -111,7 +111,7 @@ public interface AsyncBlobStore { ListenableFuture blobMetadata(String container, String key); /** - * @see BlobStore#newBlob(String, String) + * @see BlobStore#getBlob(String, String) */ ListenableFuture getBlob(String container, String key); diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java index 4a4fcf5da6..2ba9898cee 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java @@ -26,12 +26,18 @@ import org.jclouds.blobstore.options.GetOptions; import org.jclouds.blobstore.options.ListContainerOptions; /** - * Provides hooks needed to run a blob store + * Synchronous access to a BlobStore such as Amazon S3 * + * @author Adrian Cole * @see AsyncBlobStore + * + * @see BlobStoreContextFactory */ public interface BlobStore { + /** + * creates a new blob with the specified name. + */ Blob newBlob(String name); /** @@ -39,42 +45,117 @@ public interface BlobStore { */ PageSet list(); + /** + * determines if a service-level container exists + */ boolean containerExists(String container); + /** + * Creates a namespace for your blobs + *

+ * + * A container is a namespace for your objects. Depending on the service, the scope can be + * global, account, or sub-account scoped. For example, in Amazon S3, containers are called + * buckets, and they must be uniquely named such that no-one else in the world conflicts. In + * other blobstores, the naming convention of the container is less strict. All blobstores allow + * you to list your containers and also the contents within them. These contents can either be + * blobs, folders, or virtual paths. + * + * @param location + * some blobstores allow you to specify a location, such as US-EAST, for where this + * container will exist. + * @param container + * namespace. Typically constrained to lowercase alpha-numeric and hyphens. + * @return true if the container was created, false if it already existed. + */ boolean createContainerInLocation(String location, String container); /** - * Lists all resources available at the specified path. Note that path may be a container, or a - * path within it delimited by {@code /} characters. + * Lists all resources in a container non-recursive. * - * @param parent - * - base path to list; non-recursive + * @param container + * what to list + * @return a list that may be incomplete, depending on whether PageSet#getNextMarker is set */ PageSet list(String container); + /** + * Like {@link #list(String)} except you can control the size, recursion, and context of the list + * using {@link ListContainerOptions options} + * + * @param container + * what to list + * @param options + * size, recursion, and context of the list + * @return a list that may be incomplete, depending on whether PageSet#getNextMarker is set + */ PageSet list(String container, ListContainerOptions options); /** - * This will delete the contents of a container without removing it + * This will delete the contents of a container at its root path without deleting the container * * @param container + * what to clear */ void clearContainer(String container); + + /** + * Like {@link #clearContainer(String)} except you can use options to do things like recursive + * deletes, or clear at a different path than root. + * + * @param container + * what to clear + * @param options + * recursion and path to clear + */ void clearContainer(String container, ListContainerOptions options); /** - * This will delete a container recursively. + * This will delete everything inside a container recursively. * * @param container + * what to delete */ void deleteContainer(String container); + /** + * Determines if a directory exists + * + * @param container + * container where the directory resides + * @param directory + * full path to the directory + */ boolean directoryExists(String container, String directory); + /** + * Creates a folder or a directory marker depending on the service + * + * @param container + * container to create the directory in + * @param directory + * full path to the directory + */ void createDirectory(String container, String directory); + /** + * Deletes a folder or a directory marker depending on the service + * + * @param container + * container to delete the directory from + * @param directory + * full path to the directory to delete + */ void deleteDirectory(String containerName, String name); + /** + * Determines if a blob exists + * + * @param container + * container where the blob resides + * @param directory + * full path to the blob + */ boolean blobExists(String container, String name); /** @@ -112,14 +193,25 @@ public interface BlobStore { * container where this exists. * @param name * fully qualified name relative to the container. - * @param options - * byte range or condition options * @return the blob you intended to receive or null, if it doesn't exist. * @throws ContainerNotFoundException * if the container doesn't exist */ Blob getBlob(String container, String name); + /** + * Retrieves a {@code Blob} representing the data at location {@code container/name} + * + * @param container + * container where this exists. + * @param name + * fully qualified name relative to the container. + * @param options + * byte range or condition options + * @return the blob you intended to receive or null, if it doesn't exist. + * @throws ContainerNotFoundException + * if the container doesn't exist + */ Blob getBlob(String container, String name, GetOptions options); /** @@ -134,8 +226,15 @@ public interface BlobStore { */ void removeBlob(String container, String name); + /** + * @return a count of all blobs in the container, excluding directory markers + */ long countBlobs(String container); + /** + * @return a count of all blobs that are in a listing constrained by the options specified, + * excluding directory markers + */ long countBlobs(String container, ListContainerOptions options); } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java index 70f8b425d2..6e9d0ac20d 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java @@ -26,8 +26,8 @@ import org.jclouds.rest.RestContext; import com.google.inject.ImplementedBy; /** - * Represents a cloud that has key-value storage functionality. - * + * Represents a cloud that has key-value storage functionality. This object is scoped to a service + * and an account. * * @author Adrian Cole * @@ -36,30 +36,78 @@ import com.google.inject.ImplementedBy; public interface BlobStoreContext { /** - * Creates a Map view of the specified container. + * Creates a Map view of the specified container. Use this for + * simplest access to blobstore, knowing that MD5s will be calculated for every object. * * @param container + * existing container you wish to read or modify + * @param options + * allow you to specify a directory within the container, or whether to list + * recursively. */ InputStreamMap createInputStreamMap(String container, ListContainerOptions options); + /** + * Creates a Map view of the specified container. Use this for + * simplest access to blobstore, knowing that MD5s will be calculated for every object. + * + * Only root-level blobs will be visible. + * + * @param container + * existing container you wish to read or modify + */ InputStreamMap createInputStreamMap(String container); /** - * Creates a Map view of the specified container. + * Creates a Map view of the specified container. Use this when you wan + * to control the content type, or manually specify length or size of blobs. * * @param container + * existing container you wish to read or modify + * @param options + * allow you to specify a directory within the container, or whether to list + * recursively. */ BlobMap createBlobMap(String container, ListContainerOptions options); + /** + * Creates a Map view of the specified container. Use this when you wan + * to control the content type, or manually specify length or size of blobs. + * + * Only root-level blobs will be visible. + * + * @param container + * existing container you wish to read or modify + */ BlobMap createBlobMap(String container); + /** + * @return a portable asynchronous interface for the BlobStore, which returns {@code Future}s for + * each call. + */ AsyncBlobStore getAsyncBlobStore(); + /** + * @return a portable interface for the BlobStore. + */ BlobStore getBlobStore(); + /** + * + * @return best guess at the consistency model used in this BlobStore. + */ ConsistencyModels getConsistencyModel(); + /** + * + * @return a context you can use to the access provider or vendor specific api underlying this + * context. + */ RestContext getProviderSpecificContext(); + /** + * closes threads and resources related to this connection. + * + */ void close(); } \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java index 4d497defa6..e7c71917f4 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java @@ -28,6 +28,13 @@ import org.jclouds.rest.RestContextFactory; /** * Helper class to instantiate {@code BlobStoreContext} instances. * + *

Example usage

+ * + *
+ * BlobStoreContext context = new BlobStoreContextFactory()
+ *          .createContext("s3", accesskeyid, secretkey);
+ * 
+ * * @author Adrian Cole */ public class BlobStoreContextFactory extends @@ -54,6 +61,9 @@ public class BlobStoreContextFactory extends super(properties); } + /** + * {@inheritDoc} + */ @Override protected BlobStoreContext build(BlobStoreContextBuilder contextBuilder) { return contextBuilder.buildBlobStoreContext(); diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/Blob.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/Blob.java index 600916970e..3a00c6ddbf 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/Blob.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/Blob.java @@ -24,15 +24,21 @@ import com.google.common.collect.Multimap; import com.google.inject.internal.Nullable; /** - * Value type for an HTTP Blob service. Blobs are stored in containers and consist - * of a {@link org.jclouds.blobstore.domain.Value#getContent() value}, a {@link Blob#getKey key and - * - * @link Blob.Metadata#getUserMetadata() metadata} + * Value type for an HTTP Blob service. Blobs are stored in containers and consist of a + * {@link MutableBlobMetadata#getName name}, {@link Payload payload}, and + * {@link MutableBlobMetadata metadata}. * * @author Adrian Cole */ public interface Blob extends PayloadEnclosing, Comparable { + /** + * Allows you to construct blobs without knowing the implementation type + */ public interface Factory { + /** + * Creates a blob, optionally setting its metadata to a known value. This is useful in making + * copies of blobs. + */ Blob create(@Nullable MutableBlobMetadata metadata); } @@ -41,8 +47,15 @@ public interface Blob extends PayloadEnclosing, Comparable { */ MutableBlobMetadata getMetadata(); + /** + * @return headers returned from the services + */ Multimap getAllHeaders(); + /** + * + * @see #getAllHeaders + */ void setAllHeaders(Multimap allHeaders); } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/ComputeService.java b/compute/src/main/java/org/jclouds/compute/ComputeService.java index 6ff1ea1ddf..af12115513 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeService.java @@ -47,7 +47,7 @@ public interface ComputeService { * it is a good indicator of relative speed within a cloud. memory is measured in megabytes and * disks in gigabytes. * - * @retun a map of sizes by ID, conceding that in some clouds the "id" is not used. + * @return a map of sizes by ID, conceding that in some clouds the "id" is not used. */ Map getSizes(); diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java index f19acc97b1..546de22e07 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java @@ -39,7 +39,7 @@ public class ComputeServiceContextFactory extends * * @throws IOException * if the default properties file cannot be loaded - * @see RestContextFactory#getProperties + * @see RestContextFactory#getPropertiesFromResource */ public ComputeServiceContextFactory() throws IOException { super("compute.properties"); diff --git a/core/src/main/java/org/jclouds/PropertiesBuilder.java b/core/src/main/java/org/jclouds/PropertiesBuilder.java index 1239f38427..5979eb0f81 100755 --- a/core/src/main/java/org/jclouds/PropertiesBuilder.java +++ b/core/src/main/java/org/jclouds/PropertiesBuilder.java @@ -42,7 +42,7 @@ import com.google.common.annotations.VisibleForTesting; public abstract class PropertiesBuilder { /** - * @see org.jclouds.http.Constants.PROPERTY_RELAX_HOSTNAME + * @see org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME */ public PropertiesBuilder relaxSSLHostname(boolean relax) { properties.setProperty(PROPERTY_RELAX_HOSTNAME, relax + ""); @@ -50,7 +50,7 @@ public abstract class PropertiesBuilder { } /** - * @see org.jclouds.http.Constants.PROPERTY_PROXY_SYSTEM + * @see org.jclouds.Constants.PROPERTY_PROXY_SYSTEM */ public PropertiesBuilder useSystemProxies(boolean useSystemProxies) { properties.setProperty(PROPERTY_PROXY_SYSTEM, useSystemProxies + ""); @@ -58,7 +58,7 @@ public abstract class PropertiesBuilder { } /** - * @see org.jclouds.http.Constants.PROPERTY_MAX_RETRIES + * @see org.jclouds.Constants.PROPERTY_MAX_RETRIES */ public PropertiesBuilder withHttpMaxRetries(int httpMaxRetries) { properties.setProperty(PROPERTY_MAX_RETRIES, Integer.toString(httpMaxRetries)); @@ -66,7 +66,7 @@ public abstract class PropertiesBuilder { } /** - * @see org.jclouds.http.Constants.PROPERTY_MAX_REDIRECTS + * @see org.jclouds.Constants.PROPERTY_MAX_REDIRECTS */ public PropertiesBuilder withHttpMaxRedirects(int httpMaxRedirects) { properties.setProperty(PROPERTY_MAX_REDIRECTS, Integer.toString(httpMaxRedirects)); @@ -74,7 +74,7 @@ public abstract class PropertiesBuilder { } /** - * @see org.jclouds.http.Constants.PROPERTY_MAX_CONNECTION_REUSE + * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTION_REUSE */ public PropertiesBuilder withMaxClientReuse(int poolMaxClientReuse) { properties.setProperty(PROPERTY_MAX_CONNECTION_REUSE, Integer.toString(poolMaxClientReuse)); @@ -82,7 +82,7 @@ public abstract class PropertiesBuilder { } /** - * @see org.jclouds.http.Constants.PROPERTY_MAX_SESSION_FAILURES + * @see org.jclouds.Constants.PROPERTY_MAX_SESSION_FAILURES */ public PropertiesBuilder withMaxSessionFailures(int poolMaxSessionFailures) { properties.setProperty(PROPERTY_MAX_SESSION_FAILURES, Integer @@ -92,7 +92,7 @@ public abstract class PropertiesBuilder { } /** - * @see org.jclouds.http.Constants.PROPERTY_IO_WORKER_THREADS + * @see org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS */ public PropertiesBuilder limitIoWorkerThreadsTo(int poolIoWorkerThreads) { properties.setProperty(PROPERTY_IO_WORKER_THREADS, Integer.toString(poolIoWorkerThreads)); @@ -100,7 +100,7 @@ public abstract class PropertiesBuilder { } /** - * @see org.jclouds.http.Constants.PROPERTY_IO_WORKER_THREADS + * @see org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS */ public PropertiesBuilder limitUserThreadsTo(int poolIoWorkerThreads) { properties.setProperty(PROPERTY_USER_THREADS, Integer.toString(poolIoWorkerThreads)); @@ -108,7 +108,7 @@ public abstract class PropertiesBuilder { } /** - * @see org.jclouds.http.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT + * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT */ public PropertiesBuilder limitConnectionsTo(int connectionLimit) { properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, Integer @@ -117,7 +117,7 @@ public abstract class PropertiesBuilder { } /** - * @see org.jclouds.http.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST + * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST */ public PropertiesBuilder limitConnectionsPerHostTo(int connectionLimit) { properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, Integer.toString(connectionLimit)); diff --git a/core/src/main/java/org/jclouds/domain/MutableResourceMetadata.java b/core/src/main/java/org/jclouds/domain/MutableResourceMetadata.java index 928d63bcf0..0359944a14 100644 --- a/core/src/main/java/org/jclouds/domain/MutableResourceMetadata.java +++ b/core/src/main/java/org/jclouds/domain/MutableResourceMetadata.java @@ -49,7 +49,7 @@ public interface MutableResourceMetadata> extends ResourceMeta void setName(String name); /** - * @see #getLocation + * @see #getLocationId */ void setLocationId(String location); diff --git a/core/src/main/java/org/jclouds/http/HttpCommand.java b/core/src/main/java/org/jclouds/http/HttpCommand.java index e4ffb87883..3ce547d4fd 100644 --- a/core/src/main/java/org/jclouds/http/HttpCommand.java +++ b/core/src/main/java/org/jclouds/http/HttpCommand.java @@ -29,14 +29,14 @@ public interface HttpCommand { /** * increments the current number of redirect attempts for this command. * - * @see getRedirectCount + * @see #getRedirectCount */ int incrementRedirectCount(); /** * This displays the current number of redirect attempts for this command. * - * @see org.jclouds.http.Constants.PROPERTY_HTTP_MAX_REDIRECTS + * @see org.jclouds.Constants.PROPERTY_MAX_REDIRECTS */ int getRedirectCount(); @@ -64,14 +64,14 @@ public interface HttpCommand { /** * increment the current failure count. * - * @see getFailureCount + * @see #getFailureCount */ int incrementFailureCount(); /** * This displays the current number of error retries for this command. * - * @see org.jclouds.http.Constants.PROPERTY_HTTP_MAX_RETRIES + * @see org.jclouds.Constants.PROPERTY_MAX_RETRIES */ int getFailureCount(); @@ -86,7 +86,7 @@ public interface HttpCommand { void setException(Exception exception); /** - * @see setException + * @see #setException */ Exception getException(); diff --git a/core/src/main/java/org/jclouds/http/HttpCommandExecutorService.java b/core/src/main/java/org/jclouds/http/HttpCommandExecutorService.java index 54e620d2c3..cf66d1293d 100644 --- a/core/src/main/java/org/jclouds/http/HttpCommandExecutorService.java +++ b/core/src/main/java/org/jclouds/http/HttpCommandExecutorService.java @@ -31,8 +31,6 @@ public interface HttpCommandExecutorService { * Asks the command to build a request relevant for an endpoint that produces responses of * generic type {@code HttpResponse}. and invokes it on the endpoint, returning a future * - * @param - * type of result the command extracts from the return value * @param command * that generates requests * @return {@link ListenableFuture} containing the response from the {@code endpoint} diff --git a/core/src/main/java/org/jclouds/http/HttpRequest.java b/core/src/main/java/org/jclouds/http/HttpRequest.java index b0f557888d..aed8bb769f 100644 --- a/core/src/main/java/org/jclouds/http/HttpRequest.java +++ b/core/src/main/java/org/jclouds/http/HttpRequest.java @@ -93,7 +93,7 @@ public class HttpRequest extends HttpMessage { * We cannot return an enum, as per specification custom methods are allowed. Enums are not * extensible. * - * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.1 + * @see rfc2616 */ public String getMethod() { return method; diff --git a/core/src/main/java/org/jclouds/http/HttpUtils.java b/core/src/main/java/org/jclouds/http/HttpUtils.java index 7ed1375df7..6b7dea7e8c 100644 --- a/core/src/main/java/org/jclouds/http/HttpUtils.java +++ b/core/src/main/java/org/jclouds/http/HttpUtils.java @@ -131,7 +131,6 @@ public class HttpUtils { * breaks, if there are special characters like '/' present. Otherwise, we wouldn't need this * class, and we could simply use URI.create("uri").getUserData(); * - * @author Adrian Cole */ public static URI createUri(String uriPath) { if (uriPath.indexOf('@') != 1) { diff --git a/core/src/main/java/org/jclouds/http/PayloadEnclosing.java b/core/src/main/java/org/jclouds/http/PayloadEnclosing.java index 1bcd86c35f..73dc545c8e 100644 --- a/core/src/main/java/org/jclouds/http/PayloadEnclosing.java +++ b/core/src/main/java/org/jclouds/http/PayloadEnclosing.java @@ -48,7 +48,7 @@ public interface PayloadEnclosing { Payload getPayload(); /** - * @return InputStream, if downloading, or whatever was set during {@link #setPayload(Object)} + * @return InputStream, if downloading, or whatever was set during {@link #setPayload(Payload)} */ InputStream getContent(); @@ -61,8 +61,8 @@ public interface PayloadEnclosing { * range, or startAt. * * @return the length in bytes that can be be obtained from {@link #getContent()} - * @see org.jclouds.http.HttpHeaders#CONTENT_LENGTH - * @see GetObjectOptions + * @see javax.ws.rs.core.HttpHeaders#CONTENT_LENGTH + * @see org.jclouds.http.options.GetOptions */ Long getContentLength(); diff --git a/core/src/main/java/org/jclouds/http/TransformingHttpCommandImpl.java b/core/src/main/java/org/jclouds/http/TransformingHttpCommandImpl.java index 17c693f51a..19d4fc93d7 100644 --- a/core/src/main/java/org/jclouds/http/TransformingHttpCommandImpl.java +++ b/core/src/main/java/org/jclouds/http/TransformingHttpCommandImpl.java @@ -37,7 +37,7 @@ import com.google.common.util.concurrent.ListenableFuture; * Executor which will invoke and transform the response of an {@code EndpointCommand} into generic * type . * - * @see TransformingEndpointCommand + * @see TransformingHttpCommand * * @author Adrian Cole */ @@ -83,6 +83,7 @@ public class TransformingHttpCommandImpl implements TransformingHttpCommand * This also removes the Host header in order to avoid ssl problems. */ + @Override public void changeHostAndPortTo(String host, int port) { UriBuilder builder = UriBuilder.fromUri(request.getEndpoint()); builder.host(host); @@ -92,9 +93,9 @@ public class TransformingHttpCommandImpl implements TransformingHttpCommand implements TransformingHttpCommand= 300) { - * Closeables.closeQuietly(getResponse().getContent()); throw new - * IllegalStateException("incorrect code for this operation: " + getResponse()); } } - **/ public HttpRequest getRequest() { return request; } @@ -136,7 +132,7 @@ public class TransformingHttpCommandImpl implements TransformingHttpCommand implements HttpCommandExecutorService { private final DelegatingRetryHandler retryHandler; @@ -123,16 +127,6 @@ public abstract class BaseHttpCommandExecutorService implements HttpCommandEx protected abstract Q convert(HttpRequest request) throws IOException, InterruptedException; - /** - * - * FIXME Comment this - * - * @param nativeRequest - * @return - * @throws IOException - * @throws InterruptedException - * if interrupted waiting for a connection. - */ protected abstract HttpResponse invoke(Q nativeRequest) throws IOException, InterruptedException; protected abstract void cleanup(Q nativeResponse); diff --git a/core/src/main/java/org/jclouds/http/internal/HttpWire.java b/core/src/main/java/org/jclouds/http/internal/HttpWire.java index 247faceebc..ba5e00caab 100644 --- a/core/src/main/java/org/jclouds/http/internal/HttpWire.java +++ b/core/src/main/java/org/jclouds/http/internal/HttpWire.java @@ -26,10 +26,8 @@ import org.jclouds.logging.Logger; import org.jclouds.logging.internal.Wire; /** - * Logs data to the wire LOG. * * @author Adrian Cole - * @see org.apache.HttpWire.impl.conn.Wire */ public class HttpWire extends Wire { diff --git a/core/src/main/java/org/jclouds/http/internal/SignatureWire.java b/core/src/main/java/org/jclouds/http/internal/SignatureWire.java index dc105eb443..57af2f748c 100644 --- a/core/src/main/java/org/jclouds/http/internal/SignatureWire.java +++ b/core/src/main/java/org/jclouds/http/internal/SignatureWire.java @@ -26,10 +26,7 @@ import org.jclouds.logging.Logger; import org.jclouds.logging.internal.Wire; /** - * Logs data to the wire LOG. - * * @author Adrian Cole - * @see org.apache.HttpWire.impl.conn.Wire */ public class SignatureWire extends Wire { diff --git a/core/src/main/java/org/jclouds/http/options/GetOptions.java b/core/src/main/java/org/jclouds/http/options/GetOptions.java index 7542c62d81..e6472b0c92 100644 --- a/core/src/main/java/org/jclouds/http/options/GetOptions.java +++ b/core/src/main/java/org/jclouds/http/options/GetOptions.java @@ -44,8 +44,8 @@ import com.google.common.collect.Multimap; * import static org.jclouds.http.options.GetOptions.Builder.* * * - * // this will get the first megabyte of an object, provided it wasn't modified since yesterday - * ListenableFuture object = client.get("objectName",range(0,1024).ifUnmodifiedSince(new Date().minusDays(1))); + * // this will get the first megabyte of an object. + * blob = client.get("objectName",range(0,1024)); * * * @author Adrian Cole @@ -106,7 +106,7 @@ public class GetOptions extends BaseHttpRequestOptions { /** * Only return the object if it has changed since this time. *

- * Not compatible with {@link #ifETagMatches(byte[])} or {@link #ifUnmodifiedSince(Date)} + * Not compatible with {@link #ifETagMatches(String)} or {@link #ifUnmodifiedSince(Date)} */ public GetOptions ifModifiedSince(Date ifModifiedSince) { checkArgument(getIfMatch() == null, @@ -124,7 +124,7 @@ public class GetOptions extends BaseHttpRequestOptions { * Return the object only if it has been modified since the specified time, otherwise return a * 304 (not modified). * - * @see GetOptions#ifModifiedSince(Date) + * @see #ifModifiedSince(Date) */ public String getIfModifiedSince() { return this.getFirstHeaderOrNull(HttpHeaders.IF_MODIFIED_SINCE); @@ -133,7 +133,7 @@ public class GetOptions extends BaseHttpRequestOptions { /** * Only return the object if it hasn't changed since this time. *

- * Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(Date)} + * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(Date)} */ public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { checkArgument(getIfNoneMatch() == null, @@ -151,7 +151,7 @@ public class GetOptions extends BaseHttpRequestOptions { * Return the object only if it has not been modified since the specified time, otherwise return * a 412 (precondition failed). * - * @see GetOptions#ifUnmodifiedSince(Date) + * @see #ifUnmodifiedSince(Date) */ public String getIfUnmodifiedSince() { return this.getFirstHeaderOrNull(HttpHeaders.IF_UNMODIFIED_SINCE); @@ -183,7 +183,7 @@ public class GetOptions extends BaseHttpRequestOptions { * Return the object only if its payload tag (ETag) is the same as the eTag specified, otherwise * return a 412 (precondition failed). * - * @see GetOptions#ifETagMatches(byte[]) + * @see #ifETagMatches(String) */ public String getIfMatch() { return this.getFirstHeaderOrNull(HttpHeaders.IF_MATCH); @@ -215,7 +215,7 @@ public class GetOptions extends BaseHttpRequestOptions { * Return the object only if its payload tag (ETag) is different from the one specified, otherwise * return a 304 (not modified). * - * @see GetOptions#ifETagDoesntMatch(byte[]) + * @see #ifETagDoesntMatch(String) */ public String getIfNoneMatch() { return this.getFirstHeaderOrNull(HttpHeaders.IF_NONE_MATCH); diff --git a/core/src/main/java/org/jclouds/io/TeeInputStream.java b/core/src/main/java/org/jclouds/io/TeeInputStream.java deleted file mode 100644 index b2cc3de010..0000000000 --- a/core/src/main/java/org/jclouds/io/TeeInputStream.java +++ /dev/null @@ -1,204 +0,0 @@ -/** - * - * Copyright (C) 2009 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed 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.io; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * Ported from org.apache.commons.io.input.TeeInputStream - * - * InputStream proxy that transparently writes a copy of all bytes read from the delegate stream to - * a given OutputStream. Using {@link #skip(long)} or {@link #mark(int)}/{@link #reset()} on the - * stream will result on some bytes from the input stream being skipped or duplicated in the output - * stream. - *

- * The delegate input stream is closed when the {@link #close()} method is called on this proxy. It - * is configurable whether the associated output stream will also closed. - * - * @see Commons IO 1.4 - * @see org.apache.commons.io.input.TeeInputStream - */ -public class TeeInputStream extends InputStream { - - /** - * The input stream to delegate to. - */ - private final InputStream delegate; - - /** - * The output stream that will receive a copy of all bytes read from the delegate input stream. - */ - private final OutputStream branch; - - /** - * Flag for closing also the associated output stream when this stream is closed. - */ - private final boolean closeBranch; - - /** - * Creates a TeeInputStream that delegates to the given {@link InputStream} and copies all read - * bytes to the given {@link OutputStream}. The given output stream will not be closed when this - * stream gets closed. - * - * @param input - * input stream to be delegate - * @param branch - * output stream that will receive a copy of all bytes read - */ - public TeeInputStream(InputStream delegate, OutputStream branch) { - this(delegate, branch, false); - } - - /** - * Creates a TeeInputStream that proxies the given {@link InputStream} and copies all read bytes - * to the given {@link OutputStream}. The given output stream will be closed when this stream - * gets closed if the closeBranch parameter is true. - * - * @param input - * input stream to be delegate - * @param branch - * output stream that will receive a copy of all bytes read - * @param closeBranch - * flag for closing also the output stream when this stream is closed - */ - public TeeInputStream(InputStream delegate, OutputStream branch, boolean closeBranch) { - this.delegate = delegate; - this.branch = branch; - this.closeBranch = closeBranch; - } - - /** - * Closes the delegate input stream and, if so configured, the associated output stream. An - * exception thrown from one stream will not prevent closing of the other stream. - * - * @throws IOException - * if either of the streams could not be closed - */ - @Override - public void close() throws IOException { - try { - delegate.close(); - } finally { - if (closeBranch) { - branch.close(); - } - } - } - - /** - * Reads a single byte from the delegate input stream and writes it to the associated output - * stream. - * - * @return next byte from the stream, or -1 if the stream has ended - * @throws IOException - * if the stream could not be read (or written) - */ - public int read() throws IOException { - int ch = delegate.read(); - if (ch != -1) { - branch.write(ch); - } - return ch; - } - - /** - * Reads bytes from the delegate input stream and writes the read bytes to the associated output - * stream. - * - * @param bts - * byte buffer - * @param st - * start offset within the buffer - * @param end - * maximum number of bytes to read - * @return number of bytes read, or -1 if the stream has ended - * @throws IOException - * if the stream could not be read (or written) - */ - @Override - public int read(byte[] bts, int st, int end) throws IOException { - int n = delegate.read(bts, st, end); - if (n != -1) { - branch.write(bts, st, n); - } - return n; - } - - /** - * Reads bytes from the delegate input stream and writes the read bytes to the associated output - * stream. - * - * @param bts - * byte buffer - * @return number of bytes read, or -1 if the stream has ended - * @throws IOException - * if the stream could not be read (or written) - */ - @Override - public int read(byte[] bts) throws IOException { - int n = delegate.read(bts); - if (n != -1) { - branch.write(bts, 0, n); - } - return n; - } - - /** - * {@inheritDoc} - */ - @Override - public int available() throws IOException { - return delegate.available(); - } - - /** - * {@inheritDoc} - */ - @Override - public synchronized void mark(int readlimit) { - delegate.mark(readlimit); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean markSupported() { - return delegate.markSupported(); - } - - /** - * {@inheritDoc} - */ - @Override - public synchronized void reset() throws IOException { - delegate.reset(); - } - - /** - * {@inheritDoc} - */ - @Override - public long skip(long n) throws IOException { - return delegate.skip(n); - } - -} diff --git a/core/src/main/java/org/jclouds/lifecycle/config/LifeCycleModule.java b/core/src/main/java/org/jclouds/lifecycle/config/LifeCycleModule.java index 23bf9bab0b..a368fee5cf 100644 --- a/core/src/main/java/org/jclouds/lifecycle/config/LifeCycleModule.java +++ b/core/src/main/java/org/jclouds/lifecycle/config/LifeCycleModule.java @@ -46,7 +46,7 @@ import com.google.inject.spi.TypeListener; /** * This associates java lifecycle annotations with guice hooks. For example, we invoke - * {@link PostConstruct} after injection, and Associate {@link PostDestroy} with a global + * {@link PostConstruct} after injection, and Associate {@link PreDestroy} with a global * {@link Closer} object. * * @author Adrian Cole diff --git a/core/src/main/java/org/jclouds/logging/internal/Wire.java b/core/src/main/java/org/jclouds/logging/internal/Wire.java index 6c5ade98a8..6a291f9071 100644 --- a/core/src/main/java/org/jclouds/logging/internal/Wire.java +++ b/core/src/main/java/org/jclouds/logging/internal/Wire.java @@ -36,10 +36,9 @@ import com.google.common.io.Closeables; import com.google.common.io.FileBackedOutputStream; /** - * Logs data to the wire LOG. + * Logs data to the wire LOG, similar to {@code org.apache.HttpWire.impl.conn.Wire} * * @author Adrian Cole - * @see org.apache.HttpWire.impl.conn.Wire */ public abstract class Wire { diff --git a/core/src/main/java/org/jclouds/rest/RestContextFactory.java b/core/src/main/java/org/jclouds/rest/RestContextFactory.java index cc5e575d75..761b64de41 100644 --- a/core/src/main/java/org/jclouds/rest/RestContextFactory.java +++ b/core/src/main/java/org/jclouds/rest/RestContextFactory.java @@ -180,5 +180,9 @@ public abstract class RestContextFactory> } } + /** + * Hook so that you can specify how to create an object using the contextBuilder produced with + * this factory. + */ protected abstract T build(B contextBuilder); } diff --git a/core/src/main/java/org/jclouds/rest/annotations/Headers.java b/core/src/main/java/org/jclouds/rest/annotations/Headers.java index fe6710fd74..fe50697174 100755 --- a/core/src/main/java/org/jclouds/rest/annotations/Headers.java +++ b/core/src/main/java/org/jclouds/rest/annotations/Headers.java @@ -42,7 +42,7 @@ public @interface Headers { /** * @see HttpHeaders */ - String [] keys(); + String[] keys(); /** * can be defined literally, or with enclosed variables (ex. {variable}) @@ -50,9 +50,8 @@ public @interface Headers { * The inputs to these variables are taken from method parameters annotated with {@code * @PathParam}. * - * @see PathParam + * @see javax.ws.rs.PathParam * - * @return */ - String [] values(); + String[] values(); } diff --git a/extensions/enterprise/pom.xml b/extensions/enterprise/pom.xml index 78ce4ca8d8..afee129bae 100644 --- a/extensions/enterprise/pom.xml +++ b/extensions/enterprise/pom.xml @@ -51,4 +51,26 @@ --> + + ${project.artifactId} + + + maven-assembly-plugin + + + package + + single + + + + jar-with-dependencies + + + + + + + + diff --git a/extensions/httpnio/src/main/java/org/jclouds/http/pool/ConnectionPoolTransformingHttpCommandExecutorService.java b/extensions/httpnio/src/main/java/org/jclouds/http/pool/ConnectionPoolTransformingHttpCommandExecutorService.java index a577e42f0f..d81e097bea 100755 --- a/extensions/httpnio/src/main/java/org/jclouds/http/pool/ConnectionPoolTransformingHttpCommandExecutorService.java +++ b/extensions/httpnio/src/main/java/org/jclouds/http/pool/ConnectionPoolTransformingHttpCommandExecutorService.java @@ -45,7 +45,6 @@ import com.google.common.collect.MapMaker; import com.google.common.util.concurrent.ListenableFuture; /** - * // TODO: Adrian: Document this! * * @author Adrian Cole */ @@ -123,7 +122,7 @@ public class ConnectionPoolTransformingHttpCommandExecutorService extends Bas /** * This is an asynchronous operation that puts the command onto a queue. Later, it - * will be processed via the {@link #invoke(TransformingHttpCommandExecutorService) invoke} + * will be processed via the {@link #invoke(HttpCommandRendezvous) invoke} * method. */ public ListenableFuture submit(HttpCommand command, diff --git a/project/pom.xml b/project/pom.xml index a7f40731b9..70d024d051 100644 --- a/project/pom.xml +++ b/project/pom.xml @@ -536,41 +536,6 @@ pageTracker._trackPageview(); - - maven-antrun-plugin - - - repackage-jar-with-dependencies - package - - run - - - - - - - - - - - - - - - - - - - - - com.tonicsystems.jarjar - jarjar - 1.0-rc8 - - - diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/Statements.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/Statements.java index e5d15960ca..eec3de8803 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/Statements.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/Statements.java @@ -61,7 +61,7 @@ public class Statements { /** * - * Runs the script in a way that it can be matched later with {@link findPid} + * Runs the script in a way that it can be matched later with {@link #findPid} * * @param instanceName * - what to match the process on diff --git a/tools/antcontrib/samples/compute/build.xml b/tools/antcontrib/samples/compute/build.xml index c5786769d7..d2c8f1b164 100644 --- a/tools/antcontrib/samples/compute/build.xml +++ b/tools/antcontrib/samples/compute/build.xml @@ -114,20 +114,18 @@ + + + - - - + diff --git a/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java b/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java index 293227a8a5..3f3e1ba16a 100644 --- a/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java +++ b/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java @@ -23,10 +23,8 @@ import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.buildCompu import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.createTemplateFromElement; import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.ipOrEmptyString; -import java.io.File; import java.io.IOException; import java.net.URI; -import java.nio.charset.Charset; import java.util.Map; import javax.annotation.Nullable; @@ -46,7 +44,6 @@ import org.jclouds.http.HttpUtils; import com.google.common.base.CaseFormat; import com.google.common.base.Splitter; -import com.google.common.io.Files; import com.google.inject.Provider; /** @@ -193,31 +190,17 @@ public class ComputeTask extends Task { for (NodeMetadata createdNode : computeService.runNodesWithTag(tag, nodeElement.getCount(), template)) { - logNodeDetails(createdNode); + logDetails(computeService, createdNode); addNodeDetailsAsProjectProperties(createdNode); } } - private void logNodeDetails(NodeMetadata createdNode) { - log(String.format(" id=%s, tag=%s, location=%s, tag=%s, connection=%s:%s@%s", createdNode - .getId(), createdNode.getTag(), createdNode.getLocationId(), createdNode.getName(), - createdNode.getCredentials().account, createdNode.getCredentials().key, - ipOrEmptyString(createdNode.getPublicAddresses()))); - } - private void addNodeDetailsAsProjectProperties(NodeMetadata createdNode) { if (nodeElement.getIdproperty() != null) getProject().setProperty(nodeElement.getIdproperty(), createdNode.getId()); if (nodeElement.getHostproperty() != null) getProject().setProperty(nodeElement.getHostproperty(), ipOrEmptyString(createdNode.getPublicAddresses())); - if (nodeElement.getKeyfile() != null && isKeyAuth(createdNode)) - try { - Files.write(createdNode.getCredentials().key, new File(nodeElement.getKeyfile()), - Charset.defaultCharset()); - } catch (IOException e) { - throw new BuildException(e); - } if (nodeElement.getPasswordproperty() != null && !isKeyAuth(createdNode)) getProject().setProperty(nodeElement.getPasswordproperty(), createdNode.getCredentials().key); diff --git a/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java b/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java index c3a6acae82..30c9d3dca7 100644 --- a/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java +++ b/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java @@ -46,6 +46,7 @@ import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.tools.ant.logging.config.AntLoggingModule; +import com.google.common.base.Charsets; import com.google.common.base.Function; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; @@ -131,6 +132,8 @@ public class ComputeTaskUtils { TemplateOptions options = new TemplateOptions() .inboundPorts(getPortsToOpenFromElement(nodeElement)); addRunScriptToOptionsIfPresentInNodeElement(nodeElement, options); + addPrivateKeyToOptionsIfPresentInNodeElement(nodeElement, options); + addPublicKeyToOptionsIfPresentInNodeElement(nodeElement, options); return options; } @@ -144,6 +147,28 @@ public class ComputeTaskUtils { } } + static void addPrivateKeyToOptionsIfPresentInNodeElement(NodeElement nodeElement, + TemplateOptions options) { + if (nodeElement.getPrivatekeyfile() != null) + try { + options.installPrivateKey(Files.toString(nodeElement.getPrivatekeyfile(), + Charsets.UTF_8)); + } catch (IOException e) { + throw new BuildException(e); + } + } + + static void addPublicKeyToOptionsIfPresentInNodeElement(NodeElement nodeElement, + TemplateOptions options) { + if (nodeElement.getPrivatekeyfile() != null) + try { + options.authorizePublicKey(Files.toString(nodeElement.getPublickeyfile(), + Charsets.UTF_8)); + } catch (IOException e) { + throw new BuildException(e); + } + } + static String ipOrEmptyString(Set set) { if (set.size() > 0) { return Iterables.get(set, 0).getHostAddress(); diff --git a/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/NodeElement.java b/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/NodeElement.java index d9880a2ddd..7b275b0436 100644 --- a/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/NodeElement.java +++ b/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/NodeElement.java @@ -32,7 +32,8 @@ public class NodeElement { private int count = 1; private String openports = "22"; private String passwordproperty; - private String keyfile; + private File privatekeyfile; + private File publickeyfile; private String hostproperty; private String idproperty; private String usernameproperty; @@ -95,16 +96,6 @@ public class NodeElement { return idproperty; } - /** - * The name of a file under which to store the DSA key of the user (if supported) - */ - public void setKeyfile(String keyfile) { - this.keyfile = keyfile; - } - - String getKeyfile() { - return keyfile; - } public void setSize(String size) { this.size = size; @@ -162,4 +153,20 @@ public class NodeElement { return tag; } + public void setPrivatekeyfile(File privatekeyfile) { + this.privatekeyfile = privatekeyfile; + } + + public File getPrivatekeyfile() { + return privatekeyfile; + } + + public void setPublickeyfile(File publickeyfile) { + this.publickeyfile = publickeyfile; + } + + public File getPublickeyfile() { + return publickeyfile; + } + }