From a74a79fe175cdaa3fe015831fa4aeeda006807c0 Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:27:08 +0000 Subject: [PATCH] use URISupplier over references etc. --- .../director/v1_5/domain/URISupplier.java | 12 ++++++ .../v1_5/features/CatalogAsyncClient.java | 28 ++++++------- .../director/v1_5/features/CatalogClient.java | 26 ++++++------ .../v1_5/features/MediaAsyncClient.java | 40 +++++++++---------- .../director/v1_5/features/MediaClient.java | 20 +++++----- .../v1_5/features/NetworkAsyncClient.java | 16 ++++---- .../director/v1_5/features/NetworkClient.java | 8 ++-- .../v1_5/features/OrgAsyncClient.java | 9 +++-- .../director/v1_5/features/OrgClient.java | 8 ++-- .../v1_5/features/TaskAsyncClient.java | 10 ++--- .../director/v1_5/features/TaskClient.java | 9 ++--- .../director/v1_5/features/VdcClient.java | 24 +++++------ .../OrgReferenceToTaskListEndpoint.java | 6 +-- .../v1_5/functions/ReferenceToEndpoint.java | 1 + .../v1_5/functions/URISupplierToEndpoint.java | 40 +++++++++++++++++++ .../director/v1_5/predicates/TaskSuccess.java | 11 +++-- .../v1_5/features/CatalogClientLiveTest.java | 8 ++-- .../v1_5/features/TaskClientExpectTest.java | 5 ++- .../v1_5/features/TaskClientLiveTest.java | 11 +++-- 19 files changed, 172 insertions(+), 120 deletions(-) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/URISupplierToEndpoint.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/URISupplier.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/URISupplier.java index 4cd978d6f8..3f5066b81d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/URISupplier.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/URISupplier.java @@ -32,4 +32,16 @@ public interface URISupplier { * @see ReferenceType#getHref() */ public URI getURI(); + + public static class SingleURI { + public static URISupplier fromURI(final URI uri) { + return new URISupplier(){ + @Override + public URI getURI() { + return uri; + } + }; + } + } + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogAsyncClient.java index 62675b5064..f63cfef5ba 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogAsyncClient.java @@ -38,11 +38,11 @@ import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; -import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; -import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; +import org.jclouds.vcloud.director.v1_5.functions.URISupplierToEndpoint; import com.google.common.util.concurrent.ListenableFuture; @@ -60,7 +60,7 @@ public interface CatalogAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalog(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType catalogRef); + ListenableFuture getCatalog(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef); /** * Creates a catalog item in a catalog. @@ -71,7 +71,7 @@ public interface CatalogAsyncClient { @Produces(VCloudDirectorMediaType.CATALOG_ITEM) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture addCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType catalogRef, + ListenableFuture addCatalogItem(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef, @BinderParam(BindToXMLPayload.class) CatalogItem catalogItem); /** @@ -82,7 +82,7 @@ public interface CatalogAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType catalogRef); + ListenableFuture getCatalogMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef); /** * Returns the metadata associated with the catalog for the specified key. @@ -92,7 +92,7 @@ public interface CatalogAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType catalogRef, + ListenableFuture getCatalogMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef, @PathParam("key") String key); /** @@ -102,7 +102,7 @@ public interface CatalogAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType catalogItemRef); + ListenableFuture getCatalogItem(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef); /** * Modifies a catalog item. @@ -112,7 +112,7 @@ public interface CatalogAsyncClient { @Produces(VCloudDirectorMediaType.CATALOG_ITEM) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture updateCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType catalogItemRef, + ListenableFuture updateCatalogItem(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, @BinderParam(BindToXMLPayload.class) CatalogItem catalogItem); /** @@ -122,7 +122,7 @@ public interface CatalogAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture deleteCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType catalogItemRef); + ListenableFuture deleteCatalogItem(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef); /** * Returns the metadata associated with the catalog item. @@ -132,7 +132,7 @@ public interface CatalogAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogItemMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType catalogItemRef); + ListenableFuture getCatalogItemMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef); /** * Merges the metadata for a catalog item with the information provided. @@ -143,7 +143,7 @@ public interface CatalogAsyncClient { @Produces(VCloudDirectorMediaType.METADATA) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture mergeCatalogItemMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType catalogItemRef, + ListenableFuture mergeCatalogItemMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, @BinderParam(BindToXMLPayload.class) Metadata catalogItemMetadata); /** @@ -154,7 +154,7 @@ public interface CatalogAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogItemMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType catalogItemRef, + ListenableFuture getCatalogItemMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, @PathParam("key") String key); /** @@ -166,7 +166,7 @@ public interface CatalogAsyncClient { @Produces(VCloudDirectorMediaType.METADATA_VALUE) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture setCatalogItemMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType catalogItemRef, + ListenableFuture setCatalogItemMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, @PathParam("key") String key, @BinderParam(BindToXMLPayload.class) MetadataValue metadataValue); /** @@ -177,6 +177,6 @@ public interface CatalogAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture deleteCatalogItemMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType catalogItemRef, + ListenableFuture deleteCatalogItemMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, @PathParam("key") String key); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogClient.java index 81e64e4dd5..da583f3f45 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogClient.java @@ -25,8 +25,8 @@ import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; -import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; /** * Provides synchronous access to {@link Catalog} objects. @@ -47,7 +47,7 @@ public interface CatalogClient { * @param catalogRef the reference for the catalog * @return a catalog */ - Catalog getCatalog(ReferenceType catalogRef); + Catalog getCatalog(URISupplier catalogRef); /** * Creates a catalog item in a catalog. @@ -60,7 +60,7 @@ public interface CatalogClient { * @param item the catalog item to create * @return the created catalog item */ - CatalogItem addCatalogItem(ReferenceType catalogRef, CatalogItem item); + CatalogItem addCatalogItem(URISupplier catalogRef, CatalogItem item); /** * Returns the metadata associated with the catalog. @@ -72,7 +72,7 @@ public interface CatalogClient { * @param catalogRef the reference for the catalog * @return the catalog metadata */ - Metadata getCatalogMetadata(ReferenceType catalogRef); + Metadata getCatalogMetadata(URISupplier catalogRef); /** * Returns the metadata associated with the catalog for the specified key. @@ -85,7 +85,7 @@ public interface CatalogClient { * @param key the metadata entry key * @return the catalog metadata value */ - MetadataValue getCatalogMetadataValue(ReferenceType catalogRef, String key); + MetadataValue getCatalogMetadataValue(URISupplier catalogRef, String key); /** * Retrieves a catalog item. @@ -97,7 +97,7 @@ public interface CatalogClient { * @param catalogItemRef the reference for the catalog item * @return the catalog item */ - CatalogItem getCatalogItem(ReferenceType catalogItemRef); + CatalogItem getCatalogItem(URISupplier catalogItemRef); /** * Modifies a catalog item. @@ -110,7 +110,7 @@ public interface CatalogClient { * @param catalogItem the catalog item * @return the updated catalog item */ - CatalogItem updateCatalogItem(ReferenceType catalogItemRef, CatalogItem catalogItem); + CatalogItem updateCatalogItem(URISupplier catalogItemRef, CatalogItem catalogItem); /** * Deletes a catalog item. @@ -121,7 +121,7 @@ public interface CatalogClient { * * @param catalogItemRef the reference for the catalog item */ - void deleteCatalogItem(ReferenceType catalogItemRef); + void deleteCatalogItem(URISupplier catalogItemRef); /** * Returns the metadata associated with the catalog item. @@ -133,7 +133,7 @@ public interface CatalogClient { * @param catalogItemRef the reference for the catalog item * @return the catalog item metadata */ - Metadata getCatalogItemMetadata(ReferenceType catalogItemRef); + Metadata getCatalogItemMetadata(URISupplier catalogItemRef); /** * Merges the metadata for a catalog item with the information provided. @@ -146,7 +146,7 @@ public interface CatalogClient { * @param catalogItemMetadata the metadata for the catalog item * @return a task for the merge operation */ - Task mergeCatalogItemMetadata(ReferenceType catalogItemRef, Metadata catalogItemMetadata); + Task mergeCatalogItemMetadata(URISupplier catalogItemRef, Metadata catalogItemMetadata); /** * Returns the metadata associated with the catalog item for the specified key. @@ -159,7 +159,7 @@ public interface CatalogClient { * @param key the metadata entry key * @return the catalog item metadata value */ - MetadataValue getCatalogItemMetadataValue(ReferenceType catalogItemRef, String key); + MetadataValue getCatalogItemMetadataValue(URISupplier catalogItemRef, String key); /** * Sets the metadata for the particular key for the catalog item to the value provided. @@ -173,7 +173,7 @@ public interface CatalogClient { * @param value the metadata value * @return a task for the set operation */ - Task setCatalogItemMetadataValue(ReferenceType catalogItemRef, String key, MetadataValue value); + Task setCatalogItemMetadataValue(URISupplier catalogItemRef, String key, MetadataValue value); /** * Deletes the metadata for the particular key for the catalog item. @@ -186,5 +186,5 @@ public interface CatalogClient { * @param key the metadata entry key * @return a task for the delete operation */ - Task deleteCatalogItemMetadataValue(ReferenceType catalogItemRef, String key); + Task deleteCatalogItemMetadataValue(URISupplier catalogItemRef, String key); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncClient.java index 3a1a0420f8..3bd49792ab 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncClient.java @@ -38,11 +38,11 @@ import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Owner; -import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; -import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; +import org.jclouds.vcloud.director.v1_5.functions.URISupplierToEndpoint; import com.google.common.util.concurrent.ListenableFuture; @@ -54,56 +54,56 @@ import com.google.common.util.concurrent.ListenableFuture; public interface MediaAsyncClient { /** - * @see MediaClient#getMedia(Reference) + * @see MediaClient#getMedia(URISupplier) */ @GET @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef); + ListenableFuture getMedia(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef); /** - * @see MediaClient#updateMedia(Reference, Media)) + * @see MediaClient#updateMedia(URISupplier, Media)) */ @PUT @Consumes(VCloudDirectorMediaType.TASK) @Produces(VCloudDirectorMediaType.MEDIA) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture updateMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef, + ListenableFuture updateMedia(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef, @BinderParam(BindToXMLPayload.class) Media media); /** - * @see MediaClient#deleteMedia(Reference)) + * @see MediaClient#deleteMedia(URISupplier)) */ @DELETE @Consumes(VCloudDirectorMediaType.TASK) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture deleteMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef); + ListenableFuture deleteMedia(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef); /** - * @see MediaClient#getOwner(Reference) + * @see MediaClient#getOwner(URISupplier) */ @GET @Path("/owner") @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getOwner(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef); + ListenableFuture getOwner(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef); /** - * @see MediaClient#getMetadata(Reference)) + * @see MediaClient#getMetadata(URISupplier)) */ @GET @Path("/metadata") @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef); + ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef); /** - * @see MediaClient#mergeMetadata(Reference, Metadata)) + * @see MediaClient#mergeMetadata(URISupplier, Metadata)) */ @POST @Path("/metadata") @@ -111,22 +111,22 @@ public interface MediaAsyncClient { @Produces(VCloudDirectorMediaType.METADATA) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture mergeMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef, + ListenableFuture mergeMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef, @BinderParam(BindToXMLPayload.class) Metadata metadata); /** - * @see MediaClient#getMetadataEntry(Reference, String)) + * @see MediaClient#getMetadataEntry(URISupplier, String)) */ @GET @Path("/metadata/{key}") @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef, + ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef, @PathParam("key") String key); /** - * @see MediaClient#setMetadata(Reference, String, MetadataEntry)) + * @see MediaClient#setMetadata(URISupplier, String, MetadataEntry)) */ @PUT @Path("/metadata/{key}") @@ -134,19 +134,19 @@ public interface MediaAsyncClient { @Produces(VCloudDirectorMediaType.METADATA_VALUE) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture setMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference metaDataRef, + ListenableFuture setMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier metaDataRef, @PathParam("key") String key, @BinderParam(BindToXMLPayload.class) MetadataValue metadataValue); /** - * @see MediaClient#deleteMetadataEntry(Reference, String)) + * @see MediaClient#deleteMetadataEntry(URISupplier, String)) */ @DELETE @Path("/metadata/{key}") @Consumes(VCloudDirectorMediaType.TASK) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture deleteMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) Reference metaDataRef, + ListenableFuture deleteMetadataEntry(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier metaDataRef, @PathParam("key") String key); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaClient.java index 70efcab0d5..4a55b7bdd5 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaClient.java @@ -25,8 +25,8 @@ import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Owner; -import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; /** * Provides synchronous access to Media. @@ -44,7 +44,7 @@ public interface MediaClient { * * @return the media or null if not found */ - Media getMedia(Reference mediaRef); + Media getMedia(URISupplier mediaRef); /** * Updates the name/description of a media. @@ -52,40 +52,40 @@ public interface MediaClient { * @return a task. This operation is asynchronous and the user should monitor the returned * task status in order to check when it is completed. */ - Task updateMedia(Reference mediaRef, Media media); + Task updateMedia(URISupplier mediaRef, Media media); /** * Deletes a media. */ - Task deleteMedia(Reference mediaRef); + Task deleteMedia(URISupplier mediaRef); /** * Retrieves an owner. * * @return the owner or null if not found */ - Owner getOwner(Reference mediaRef); + Owner getOwner(URISupplier mediaRef); /** * Retrieves an list of the media's metadata * * @return a list of metadata */ - Metadata getMetadata(Reference mediaRef); + Metadata getMetadata(URISupplier mediaRef); /** * Merges the metadata for a media with the information provided. * * @return a task. This operation is asynchronous and the user should monitor the returned * task status in order to check when it is completed. */ - Task mergeMetadata(Reference mediaRef, Metadata metadata); + Task mergeMetadata(URISupplier mediaRef, Metadata metadata); /** * Retrieves a metadata value * * @return the metadata value, or null if not found */ - MetadataValue getMetadataValue(Reference mediaRef, String key); + MetadataValue getMetadataValue(URISupplier mediaRef, String key); /** * Sets the metadata for the particular key for the media to the value provided. @@ -94,7 +94,7 @@ public interface MediaClient { * @return a task. This operation is asynchronous and the user should monitor the returned * task status in order to check when it is completed. */ - Task setMetadata(Reference mediaRef, String key, MetadataValue metadataValue); + Task setMetadata(URISupplier mediaRef, String key, MetadataValue metadataValue); /** * Deletes a metadata entry. @@ -102,7 +102,7 @@ public interface MediaClient { * @return a task. This operation is asynchronous and the user should monitor the returned * task status in order to check when it is completed. */ - Task deleteMetadataEntry(Reference mediaRef, String key); + Task deleteMetadataEntry(URISupplier mediaRef, String key); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java index 34fa61183d..7681d80660 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java @@ -30,10 +30,10 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; -import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; -import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; +import org.jclouds.vcloud.director.v1_5.functions.URISupplierToEndpoint; import com.google.common.util.concurrent.ListenableFuture; @@ -46,33 +46,33 @@ import com.google.common.util.concurrent.ListenableFuture; public interface NetworkAsyncClient { /** - * @see NeworkClient#getNetwork(Reference) + * @see NeworkClient#getNetwork(URISupplier) */ @GET @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getNetwork(@EndpointParam(parser = ReferenceToEndpoint.class) Reference networkRef); + ListenableFuture getNetwork(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier networkRef); /** - * @see NeworkClient#getMetadata(Reference) + * @see NeworkClient#getMetadata(URISupplier) */ @GET @Path("/metadata") @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference networkRef); + ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier networkRef); /** - * @see NeworkClient#getMetadataValue(Reference, String) + * @see NeworkClient#getMetadataValue(URISupplier, String) */ @GET @Path("/metadata/{key}") @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) Reference networkRef , + ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier networkRef , @PathParam("key") String key); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java index 88cb290aea..7fbb6859c2 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java @@ -24,7 +24,7 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; -import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; /** * Provides synchronous access to Network. @@ -42,20 +42,20 @@ public interface NetworkClient { * * @return the network or null if not found */ - OrgNetwork getNetwork(Reference networkRef); + OrgNetwork getNetwork(URISupplier networkRef); /** * Retrieves an list of the network's metadata * * @return a list of metadata */ - Metadata getMetadata(Reference networkRef); + Metadata getMetadata(URISupplier networkRef); /** * Retrieves a metadata value * * @return the metadata value, or null if not found */ - MetadataValue getMetadataValue(Reference networkRef, String key); + MetadataValue getMetadataValue(URISupplier networkRef, String key); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java index 4f608da006..d3437511ef 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java @@ -32,9 +32,10 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; -import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; +import org.jclouds.vcloud.director.v1_5.functions.URISupplierToEndpoint; import com.google.common.util.concurrent.ListenableFuture; @@ -61,7 +62,7 @@ public interface OrgAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getOrg(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType orgRef); + ListenableFuture getOrg(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier orgRef); /** * @see OrgClient#getMetadata(ReferenceType) @@ -71,7 +72,7 @@ public interface OrgAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getOrgMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType orgRef); + ListenableFuture getOrgMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier orgRef); /** * @see OrgClient#getMetadataEntry(ReferenceType, String) @@ -81,6 +82,6 @@ public interface OrgAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getOrgMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType orgRef, + ListenableFuture getOrgMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier orgRef, @PathParam("key") String key); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java index 63fa69d4b9..d297c21b17 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java @@ -25,7 +25,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.OrgList; -import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; /** * Provides synchronous access to Org. @@ -57,7 +57,7 @@ public interface OrgClient { * * @return the org or null if not found */ - Org getOrg(ReferenceType orgRef); + Org getOrg(URISupplier orgRef); /** * Retrieves an list of the organization's metadata @@ -68,7 +68,7 @@ public interface OrgClient { * * @return a list of metadata */ - Metadata getOrgMetadata(ReferenceType orgRef); + Metadata getOrgMetadata(URISupplier orgRef); /** * Retrieves a metadata entry. @@ -79,5 +79,5 @@ public interface OrgClient { * * @return the metadata entry or null if not found */ - MetadataValue getOrgMetadataValue(ReferenceType orgRef, String key); + MetadataValue getOrgMetadataValue(URISupplier orgRef, String key); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/TaskAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/TaskAsyncClient.java index 1c39d7f7ef..e54c1d04d7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/TaskAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/TaskAsyncClient.java @@ -29,9 +29,9 @@ import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.TasksList; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.functions.OrgReferenceToTaskListEndpoint; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; @@ -46,13 +46,13 @@ import com.google.common.util.concurrent.ListenableFuture; public interface TaskAsyncClient { /** - * @see TaskClient#getTaskList(ReferenceType) + * @see TaskClient#getTaskList(URISupplier) */ @GET @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getTaskList(@EndpointParam(parser = OrgReferenceToTaskListEndpoint.class) Reference orgRef); + ListenableFuture getTaskList(@EndpointParam(parser = OrgReferenceToTaskListEndpoint.class) URISupplier orgRef); /** * @see TaskClient#getTask(URI) @@ -61,7 +61,7 @@ public interface TaskAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getTask(@EndpointParam URI taskUri); + ListenableFuture getTask(@EndpointParam URISupplier taskRef); /** * @see TaskClient#cancelTask(URI) @@ -71,5 +71,5 @@ public interface TaskAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture cancelTask(@EndpointParam URI taskUri); + ListenableFuture cancelTask(@EndpointParam URISupplier taskRef); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/TaskClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/TaskClient.java index c3790eb412..58a6a05671 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/TaskClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/TaskClient.java @@ -18,13 +18,12 @@ */ package org.jclouds.vcloud.director.v1_5.features; -import java.net.URI; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.TasksList; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; /** * Provides synchronous access to {@link Task} objects. @@ -45,7 +44,7 @@ public interface TaskClient { * @param orgId the unique id for the organization * @return a list of tasks */ - TasksList getTaskList(Reference orgRef); + TasksList getTaskList(URISupplier orgRef); /** * Retrieves a task. @@ -56,7 +55,7 @@ public interface TaskClient { * * @return the task or null if not found */ - Task getTask(URI taskUri); + Task getTask(URISupplier taskUri); /** * Cancels a task. @@ -65,5 +64,5 @@ public interface TaskClient { * POST /task/{id}/action/cancel * */ - void cancelTask(URI taskUri); + void cancelTask(URISupplier taskUri); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java index 0b72a139c4..edc48e8108 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java @@ -30,7 +30,7 @@ import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParamsType; import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; -import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; @@ -52,7 +52,7 @@ public interface VdcClient { * * @return the vdc or null if not found */ - Vdc getVdc(Reference vdcRef); + Vdc getVdc(URISupplier vdcRef); /** * Captures a vApp into vApp template. @@ -61,7 +61,7 @@ public interface VdcClient { * @return a VApp resource which will contain a task. * The user should should wait for this task to finish to be able to use the vApp. */ - VAppTemplate captureVApp(Reference vdcRef, CaptureVAppParams params); + VAppTemplate captureVApp(URISupplier vdcRef, CaptureVAppParams params); /** * Clones a media into new one. @@ -70,7 +70,7 @@ public interface VdcClient { * @return a Media resource which will contain a task. * The user should monitor the contained task status in order to check when it is completed. */ - Media cloneMedia(Reference vdcRef, CloneMediaParams params); + Media cloneMedia(URISupplier vdcRef, CloneMediaParams params); /** * Clones a vApp into new one. The status of vApp will be in UNRESOLVED(0) until the clone task is finished. @@ -78,7 +78,7 @@ public interface VdcClient { * @return a VApp resource which will contain a task. * The user should should wait for this task to finish to be able to use the vApp. */ - VApp cloneVApp(Reference vdcRef, CloneVAppParams params); + VApp cloneVApp(URISupplier vdcRef, CloneVAppParams params); /** * Clones a vApp template into new one. @@ -87,7 +87,7 @@ public interface VdcClient { * @return a VAppTemplate resource which will contain a task. * The user should should wait for this task to finish to be able to use the VAppTemplate. */ - VAppTemplate cloneVAppTemplate(Reference vdcRef, CloneVAppTemplateParams params); + VAppTemplate cloneVAppTemplate(URISupplier vdcRef, CloneVAppTemplateParams params); /** * Composes a new vApp using VMs from other vApps or vApp templates. The vCloud API supports @@ -111,7 +111,7 @@ public interface VdcClient { * @return a VApp resource which will contain a task. * The user should should wait for this task to finish to be able to use the vApp. */ - VApp composeVApp(Reference vdcRef, ComposeVAppParams params); + VApp composeVApp(URISupplier vdcRef, ComposeVAppParams params); /** * Instantiate a vApp template into a new vApp. @@ -120,7 +120,7 @@ public interface VdcClient { * @return a VApp resource which will contain a task. * The user should should wait for this task to finish to be able to use the vApp. */ - VApp instantiateVApp(Reference vdcRef, InstantiateVAppParamsType params); + VApp instantiateVApp(URISupplier vdcRef, InstantiateVAppParamsType params); /** * Uploading vApp template to a vDC. The operation is separate on several steps: @@ -134,27 +134,27 @@ public interface VdcClient { * @return a VAppTemplate resource which will contain a task. * The user should should wait for this task to finish to be able to use the VAppTemplate. */ - VAppTemplate uploadVAppTemplate(Reference vdcRef, UploadVAppTemplateParams params); + VAppTemplate uploadVAppTemplate(URISupplier vdcRef, UploadVAppTemplateParams params); /** * Creates a media (and present upload link for the floppy/iso file). * * @return The response will return a link to transfer site to be able to continue with uploading the media. */ - Media createMedia(Reference vdcRef, Media media); + Media createMedia(URISupplier vdcRef, Media media); /** * Retrieves an list of the vdc's metadata * * @return a list of metadata */ - Metadata getMetadata(Reference vdcRef); + Metadata getMetadata(URISupplier vdcRef); /** * Retrieves a metadata value * * @return the metadata value, or null if not found */ - MetadataValue getMetadataValue(Reference vdcRef, String key); + MetadataValue getMetadataValue(URISupplier vdcRef, String key); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/OrgReferenceToTaskListEndpoint.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/OrgReferenceToTaskListEndpoint.java index 42b7e07dee..7dceb1dc56 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/OrgReferenceToTaskListEndpoint.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/OrgReferenceToTaskListEndpoint.java @@ -26,7 +26,7 @@ import javax.inject.Singleton; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Org; -import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.features.OrgClient; import com.google.common.base.Function; @@ -47,8 +47,8 @@ public class OrgReferenceToTaskListEndpoint implements Function { @Override public URI apply(Object input) { Preconditions.checkNotNull(input); - Preconditions.checkArgument(input instanceof ReferenceType); - ReferenceType reference = (ReferenceType) input; + Preconditions.checkArgument(input instanceof URISupplier); + URISupplier reference = (URISupplier) input; Org org = client.getOrg(reference); for (Link link : org.getLinks()) { if (link.getType().equals(VCloudDirectorMediaType.TASKS_LIST)) { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/ReferenceToEndpoint.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/ReferenceToEndpoint.java index 14fcce00d3..947b848455 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/ReferenceToEndpoint.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/ReferenceToEndpoint.java @@ -29,6 +29,7 @@ import org.jclouds.vcloud.director.v1_5.domain.URISupplier; /** * @author grkvlt@apache.org */ +@Deprecated public class ReferenceToEndpoint implements Function { @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/URISupplierToEndpoint.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/URISupplierToEndpoint.java new file mode 100644 index 0000000000..750b007f7a --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/URISupplierToEndpoint.java @@ -0,0 +1,40 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.vcloud.director.v1_5.functions; + +import java.net.URI; + +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; + +import com.google.common.base.Function; +import com.google.common.base.Preconditions; + +/** + * @author danikov + */ +public class URISupplierToEndpoint implements Function { + + @Override + public URI apply(Object input) { + Preconditions.checkNotNull(input); + Preconditions.checkArgument(input instanceof URISupplier); + URISupplier provider = (URISupplier) input; + return provider.getURI(); + }; +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java index 497f0f27be..0a344ca8f2 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java @@ -18,8 +18,6 @@ */ package org.jclouds.vcloud.director.v1_5.predicates; -import java.net.URI; - import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Singleton; @@ -27,6 +25,7 @@ import javax.inject.Singleton; import org.jclouds.logging.Logger; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.features.TaskClient; import com.google.common.base.Predicate; @@ -37,7 +36,7 @@ import com.google.common.base.Predicate; * @author grkvlt@apache.org */ @Singleton -public class TaskSuccess implements Predicate { +public class TaskSuccess implements Predicate { private final TaskClient taskClient; @@ -51,10 +50,10 @@ public class TaskSuccess implements Predicate { /** @see Predicate#apply(Object) */ @Override - public boolean apply(URI taskUri) { - logger.trace("looking for status on task %s", taskUri); + public boolean apply(URISupplier taskRef) { + logger.trace("looking for status on task %s", taskRef); - Task task = taskClient.getTask(taskUri); + Task task = taskClient.getTask(taskRef); // perhaps task isn't available, yet if (task == null) return false; logger.trace("%s: looking for status %s: currently: %s", task, Task.Status.SUCCESS, task.getStatus()); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java index 20e027b519..aef5ec0bfd 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java @@ -186,7 +186,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { Task mergeCatalogItemMetadata = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata); checkTask(mergeCatalogItemMetadata); - assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata.getHref()), + assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata")); Metadata mergedCatalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); @@ -227,7 +227,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { Task setCatalogItemMetadataValue = catalogClient.setCatalogItemMetadataValue(catalogItemRef, "KEY", newMetadataValue); checkTask(setCatalogItemMetadataValue); Checks.checkTask(setCatalogItemMetadataValue); - assertTrue(retryTaskSuccess.apply(setCatalogItemMetadataValue.getHref()), + assertTrue(retryTaskSuccess.apply(setCatalogItemMetadataValue), String.format(TASK_COMPLETE_TIMELY, "setCatalogItemMetadataValue")); MetadataValue updatedMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); @@ -241,7 +241,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { Task deleteCatalogItemMetadataValue = catalogClient.deleteCatalogItemMetadataValue(catalogItemRef, "KEY"); checkTask(deleteCatalogItemMetadataValue); Checks.checkTask(deleteCatalogItemMetadataValue); - assertTrue(retryTaskSuccess.apply(deleteCatalogItemMetadataValue.getHref()), + assertTrue(retryTaskSuccess.apply(deleteCatalogItemMetadataValue), String.format(TASK_COMPLETE_TIMELY, "deleteCatalogItemMetadataValue")); try { catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); @@ -269,7 +269,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "VALUE").build()).build(); Task mergeCatalogItemMetadata = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata); Checks.checkTask(mergeCatalogItemMetadata); - assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata.getHref()), + assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata")); } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java index ad3806a807..d3c69107ae 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java @@ -32,6 +32,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.TasksList; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.testng.annotations.Test; @@ -202,7 +203,7 @@ public class TaskClientExpectTest extends BaseVCloudDirectorRestClientExpectTest VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, taskRequest, taskResponse); - URI taskUri = URI.create(endpoint + "/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"); + URISupplier taskUri = URISupplier.SingleURI.fromURI(URI.create(endpoint + "/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b")); Task expected = taskOne(); @@ -226,7 +227,7 @@ public class TaskClientExpectTest extends BaseVCloudDirectorRestClientExpectTest VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, taskRequest, taskResponse); - URI taskUri = URI.create(endpoint + "/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"); + URISupplier taskUri = URISupplier.SingleURI.fromURI(URI.create(endpoint + "/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b")); client.getTaskClient().cancelTask(taskUri); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java index 6988b2fbd7..07cd62d220 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java @@ -22,12 +22,11 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.N import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkTask; import static org.testng.Assert.assertFalse; -import java.net.URI; - import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.TasksList; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -64,7 +63,7 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest { private Reference orgRef; private TasksList taskList; private Task task; - private URI taskUri; + private URISupplier taskRef; @Test(testName = "GET /tasksList/{id}") public void testGetTaskList() { @@ -86,10 +85,10 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /task/{id}", dependsOnMethods = { "testGetTaskList" }) public void testGetTask() { - taskUri = Iterables.getFirst(taskList.getTasks(), null).getHref(); + taskRef = Iterables.getFirst(taskList.getTasks(), null); // Call the method being tested - task = taskClient.getTask(taskUri); + task = taskClient.getTask(taskRef); // Check required elements and attributes checkTask(task); @@ -98,6 +97,6 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /task/{id}/metadata/", dependsOnMethods = { "testGetTask" }) public void testCancelTask() { // Call the method being tested - taskClient.cancelTask(taskUri); + taskClient.cancelTask(taskRef); } }