From 0047a0fb69d44e2b081d88fb66ff400a375bb4e3 Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:24:22 +0000 Subject: [PATCH 01/34] correct types, switch to using URISupplier --- .../v1_5/features/VdcAsyncClient.java | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java index 4fe5cda2ae..1089d68647 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java @@ -41,14 +41,14 @@ 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; import org.jclouds.vcloud.director.v1_5.domain.Vdc; 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,16 +61,16 @@ import com.google.common.util.concurrent.ListenableFuture; public interface VdcAsyncClient { /** - * @see VdcClient#getVdc(Reference) + * @see VdcClient#getVdc(URISupplier) */ @GET @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getVdc(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef); + ListenableFuture getVdc(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef); /** - * @see VdcClient#captureVApp(Reference, CaptureVAppParams) + * @see VdcClient#captureVApp(URISupplier, CaptureVAppParams) */ @POST @Path("/action/captureVApp") @@ -78,112 +78,112 @@ public interface VdcAsyncClient { @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture captureVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + ListenableFuture captureVApp(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef, @BinderParam(BindToXMLPayload.class) CaptureVAppParams params); /** - * @see VdcClient#cloneMedia(Reference, CloneMediaParams) + * @see VdcClient#cloneMedia(URISupplier, CloneMediaParams) */ @POST @Path("/action/cloneMedia") @Consumes(VCloudDirectorMediaType.MEDIA) - @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) + @Produces(VCloudDirectorMediaType.CLONE_MEDIA_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture cloneMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + ListenableFuture cloneMedia(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef, @BinderParam(BindToXMLPayload.class) CloneMediaParams params); /** - * @see VdcClient#cloneVApp(Reference, CloneVAppParams) + * @see VdcClient#cloneVApp(URISupplier, CloneVAppParams) */ @POST @Path("/action/cloneVApp") @Consumes(VCloudDirectorMediaType.V_APP) - @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) + @Produces(VCloudDirectorMediaType.CLONE_V_APP_PARAMS) //TODO fix these etc. @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture cloneVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + ListenableFuture cloneVApp(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef, @BinderParam(BindToXMLPayload.class) CloneVAppParams params); /** - * @see VdcClient#cloneVAppTemplate(Reference, CloneVAppTemplateParams) + * @see VdcClient#cloneVAppTemplate(URISupplier, CloneVAppTemplateParams) */ @POST @Path("/action/cloneVAppTemplate") @Consumes(VCloudDirectorMediaType.V_APP_TEMPLATE) - @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) + @Produces(VCloudDirectorMediaType.CLONE_V_APP_TEMPLATE_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture cloneVAppTemplate(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + ListenableFuture cloneVAppTemplate(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef, @BinderParam(BindToXMLPayload.class) CloneVAppTemplateParams params); /** - * @see VdcClient#composeVApp(Reference, ComposeVAppParams) + * @see VdcClient#composeVApp(URISupplier, ComposeVAppParams) */ @POST @Path("/action/composeVApp") @Consumes(VCloudDirectorMediaType.V_APP) - @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) + @Produces(VCloudDirectorMediaType.COMPOSE_VAPP_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture composeVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + ListenableFuture composeVApp(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef, @BinderParam(BindToXMLPayload.class) ComposeVAppParams params); /** - * @see VdcClient#instantiateVApp(Reference, InstantiateVAppParamsType) + * @see VdcClient#instantiateVApp(URISupplier, InstantiateVAppParamsType) */ @POST @Path("/action/instantiateVApp") @Consumes(VCloudDirectorMediaType.V_APP) - @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) + @Produces(VCloudDirectorMediaType.INSTANTIATE_VAPP_TEMPLATE_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture instantiateVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + ListenableFuture instantiateVApp(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef, @BinderParam(BindToXMLPayload.class) InstantiateVAppParamsType params); /** - * @see VdcClient#uploadVAppTemplate(Reference, UploadVAppTemplateParams) + * @see VdcClient#uploadVAppTemplate(URISupplier, UploadVAppTemplateParams) */ @POST @Path("/action/uploadVAppTemplate") @Consumes(VCloudDirectorMediaType.V_APP_TEMPLATE) - @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) + @Produces(VCloudDirectorMediaType.UPLOAD_VAPP_TEMPLATE_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture uploadVAppTemplate(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + ListenableFuture uploadVAppTemplate(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef, @BinderParam(BindToXMLPayload.class) UploadVAppTemplateParams params); /** - * @see VdcClient#createMedia(Reference, Media) + * @see VdcClient#createMedia(URISupplier, Media) */ @POST @Path("/media") @Consumes(VCloudDirectorMediaType.MEDIA) - @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) + @Produces(VCloudDirectorMediaType.MEDIA) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture createMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + ListenableFuture createMedia(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef, @BinderParam(BindToXMLPayload.class) Media media); /** - * @see VdcClient#getMetadata(Reference) + * @see VdcClient#getMetadata(URISupplier) */ @GET @Path("/metadata") @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef); + ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef); /** - * @see VdcClient#getMetadataEntry(Reference, String) + * @see VdcClient#getMetadataEntry(URISupplier, String) */ @GET @Path("/metadata/{key}") @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef , + ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef , @PathParam("key") String key); } \ No newline at end of file From a74a79fe175cdaa3fe015831fa4aeeda006807c0 Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:27:08 +0000 Subject: [PATCH 02/34] 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); } } From 8bca9430866250ec440f25559f639d07dfce4bab Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:27:49 +0000 Subject: [PATCH 03/34] switch to using URISupplier, remove un-needed vars --- .../BaseVCloudDirectorClientLiveTest.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java index 3f4ad4cf77..353e525046 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.vcloud.director.v1_5.internal; -import java.net.URI; import java.util.Properties; import org.jclouds.compute.BaseVersionedServiceLiveTest; @@ -29,6 +28,7 @@ import org.jclouds.rest.RestContextFactory; import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.vcloud.director.v1_5.VCloudDirectorAsyncClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.predicates.TaskSuccess; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -51,24 +51,21 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ } protected String catalogName; - protected String mediaId; protected String vAppTemplateId; protected String networkId; - protected String vDCId; + protected String vdcId; @Override protected Properties setupProperties() { Properties overrides= super.setupProperties(); if (catalogName != null) overrides.setProperty(provider + ".catalog-name", catalogName); - if (mediaId != null) - overrides.setProperty(provider + ".media-id", mediaId); if (vAppTemplateId != null) overrides.setProperty(provider + ".vapptemplate-id", vAppTemplateId); if (networkId != null) overrides.setProperty(provider + ".network-id", networkId); - if (vDCId != null) - overrides.setProperty(provider + ".vcd-id", vDCId); + if (vdcId != null) + overrides.setProperty(provider + ".vdc-id", vdcId); return overrides; } @@ -77,7 +74,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ public abstract void setupRequiredClients(); /** Injected by {@link #setupContext} */ - public Predicate retryTaskSuccess; + public Predicate retryTaskSuccess; @Override @BeforeClass(groups = { "live" }) @@ -85,10 +82,9 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ super.setupCredentials(); catalogName = System.getProperty("test." + provider + ".catalog-name"); - mediaId = System.getProperty("test." + provider + ".media-id"); vAppTemplateId = System.getProperty("test." + provider + ".vapptemplate-id"); networkId = System.getProperty("test." + provider + ".network-id"); - vDCId = System.getProperty("test." + provider + ".vdc-id"); + vdcId = System.getProperty("test." + provider + ".vdc-id"); } protected RestContext context; @@ -103,7 +99,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides); TaskSuccess taskSuccess = context.utils().injector().getInstance(TaskSuccess.class); - retryTaskSuccess = new RetryablePredicate(taskSuccess, 1000L); + retryTaskSuccess = new RetryablePredicate(taskSuccess, 1000L); } protected void tearDown() { From a307c44a22132e22f5fdb59b8b517558cab89b6a Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:28:32 +0000 Subject: [PATCH 04/34] extract out media methods, correct var name --- .../v1_5/features/VdcClientLiveTest.java | 43 ++----------------- 1 file changed, 4 insertions(+), 39 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index 4b049d4dd6..33ea099a1d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -73,8 +73,8 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { vdcRef = Reference.builder() .type("application/vnd.vmware.vcloud.vdc+xml") .name("") - .href(URI.create(endpoint+"/vdc/"+vDCId)) - .id(vDCId) + .href(URI.create(endpoint+"/vdc/"+vdcId)) + .id(vdcId) .build(); vdcClient = context.getApi().getVdcClient(); } @@ -143,23 +143,6 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { // TODO: make assertions that the task was successful } - @Test(testName = "POST /vdc/{id}/action/cloneMedia") - public void testCloneMedia() { - Reference mediaSource = null; // TODO: media reference - Media media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder() - .source(mediaSource) - // TODO: test optional params - //.name("") - //.description("") - //.isSourceDelete(true) - .build()); - - Checks.checkMediaFor(VDC, media); - - // TODO: await task to complete - // TODO: make assertions that the task was successful - } - @Test(testName = "POST /vdc/{id}/action/cloneVApp", enabled = false) public void testCloneVApp() { Reference vAppSource = null; // TODO: vApp reference @@ -260,25 +243,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { // TODO: make assertions that the task was successful } - @Test(testName = "POST /vdc/{id}/media") - public void testCreateMedia() { - Media media = vdcClient.createMedia(vdcRef, Media.builder() - .name("") - .imageType(Media.ImageType.ISO) - .size(0) - // TODO: test optional params - //.name("") - //.description("") - //.isSourceDelete(true) - .build()); - - Checks.checkMediaFor(VDC, media); - - // TODO: await task to complete - // TODO: make assertions that the task was successful - } - - @Test(testName = "GET /network/{id}/metadata") + @Test(testName = "GET /network/{id}/metadata", enabled = false) public void testGetMetadata() { Metadata metadata = vdcClient.getMetadata(vdcRef); // required for testing @@ -288,7 +253,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMetadataFor(VDC, metadata); } - @Test(testName = "GET /network/{id}/metadata/{key}") + @Test(testName = "GET /network/{id}/metadata/{key}", enabled = false) public void testGetMetadataValue() { MetadataValue metadataValue = vdcClient.getMetadataValue(vdcRef, "key"); From ed6cfca0a732756c2431facb1955d4b77a01e56b Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:29:50 +0000 Subject: [PATCH 05/34] add clone checks --- .../vcloud/director/v1_5/domain/EntityType.java | 12 ++++++++++++ .../jclouds/vcloud/director/v1_5/domain/Media.java | 11 +++++++++++ .../director/v1_5/domain/ResourceEntityType.java | 10 ++++++++++ .../vcloud/director/v1_5/domain/ResourceType.java | 9 +++++++++ 4 files changed, 42 insertions(+) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java index 077e4ad1e0..feb434aedf 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java @@ -198,6 +198,18 @@ public abstract class EntityType> extends ResourceType that = EntityType.class.cast(o); + return super.equals(that) && + equal(this.description, that.description) && + equal(this.name, that.name); + } @Override public int hashCode() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java index 8c794d3e54..c218c59efd 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java @@ -244,6 +244,17 @@ public class Media extends ResourceEntityType { return super.equals(that) && equal(this.owner, that.owner) && equal(this.imageType, that.imageType) && equal(this.size, that.size); } + + @Override + public boolean clone(Object o) { + if (this == o) + return false; + if (o == null || getClass() != o.getClass()) + return false; + Media that = Media.class.cast(o); + return super.clone(that) && + equal(this.owner, that.owner) && equal(this.imageType, that.imageType) && equal(this.size, that.size); + } @Override public int hashCode() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java index 78afcce32f..484272498f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java @@ -167,6 +167,16 @@ public abstract class ResourceEntityType> extend ResourceEntityType that = ResourceEntityType.class.cast(o); return super.equals(that) && equal(this.files, that.files) && equal(this.status, that.status); } + + @Override + public boolean clone(Object o) { + if (this == o) + return false; + if (o == null || getClass() != o.getClass()) + return false; + ResourceEntityType that = ResourceEntityType.class.cast(o); + return super.clone(that) && equal(this.files, that.files); + } @Override public int hashCode() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java index a4d5745ff2..b90944e3b4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java @@ -160,6 +160,15 @@ public abstract class ResourceType> implements URISupp ResourceType that = ResourceType.class.cast(o); return equal(this.href, that.href) && equal(this.links, that.links) && equal(this.type, that.type); } + + public boolean clone(Object o) { + if (this == o) + return false; + if (o == null || getClass() != o.getClass()) + return false; + ResourceType that = ResourceType.class.cast(o); + return equal(this.type, that.type); + } @Override public int hashCode() { From cdf2ddb0ac6c8dae755cbf9b015651382c026078 Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:30:08 +0000 Subject: [PATCH 06/34] add missing builder methods --- .../director/v1_5/domain/CloneMediaParams.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java index f55c034512..d195c2e1bf 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java @@ -90,8 +90,26 @@ public class CloneMediaParams public CloneMediaParams build() { return new CloneMediaParams(description, name, source, isSourceDelete); + cloneMediaParams.setDescription(description); + cloneMediaParams.setName(name); } + + /** + * @see ParamsType#getDescription() + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see ParamsType#getName() + */ + public Builder name(String name) { + this.name = name; + return this; + } @Override public Builder fromParamsType(ParamsType in) { return Builder.class.cast(super.fromParamsType(in)); From 5003f7adb3a7126aafc0ed80b46fbf852051a1e9 Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:30:51 +0000 Subject: [PATCH 07/34] fix toString, equals and hashcode, --- .../jclouds/vcloud/director/v1_5/domain/File.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java index b9e455dcb0..47b0015cdd 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java @@ -31,6 +31,7 @@ import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.Sets; @@ -228,24 +229,26 @@ public class File extends EntityType { if (o == null || getClass() != o.getClass()) return false; File that = File.class.cast(o); - return equal(size, that.size) && + return super.equals(that) && + equal(size, that.size) && equal(bytesTransferred, that.bytesTransferred) && equal(checksum, that.checksum); } @Override public int hashCode() { - return Objects.hashCode(size, + return Objects.hashCode(super.hashCode(), + size, bytesTransferred, checksum); } @Override - public String toString() { - return Objects.toStringHelper("") + public ToStringHelper string() { + return super.string() .add("size", size) .add("bytesTransferred", bytesTransferred) - .add("checksum", checksum).toString(); + .add("checksum", checksum); } } From 633dd489b17b2691b07af1659ca64d1a393b84c1 Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:31:11 +0000 Subject: [PATCH 08/34] add upload:default media type --- .../java/org/jclouds/vcloud/director/v1_5/domain/Link.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java index 9ccebe4d19..e7d95c666d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java @@ -58,6 +58,7 @@ public class Link extends ReferenceType { public static final String LAST_PAGE = "lastPage"; public static final String FIRST_PAGE = "firstPage"; public static final String CONTROL_ACCESS = "controlAccess"; + public static final String UPLOAD_DEFAULT = "upload:default"; /** * All acceptable {@link Link#getRel()} values. @@ -67,7 +68,7 @@ public class Link extends ReferenceType { public static final List ALL = Arrays.asList( UP, DOWN, EDIT, ADD, DELETE, REMOVE, CATALOG_ITEM, TASK_CANCEL, ALTERNATE, NEXT_PAGE, PREVIOUS_PAGE, LAST_PAGE, FIRST_PAGE, - CONTROL_ACCESS + CONTROL_ACCESS, UPLOAD_DEFAULT ); } From 6bed78b5a0763dd9e6b9f75a260f34b8acd05acd Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:31:53 +0000 Subject: [PATCH 09/34] add convenience constructor to make a reference to an entityType from the entityType --- .../org/jclouds/vcloud/director/v1_5/domain/Reference.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java index e055bb5264..c40d5911a6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java @@ -88,6 +88,10 @@ public class Reference extends ReferenceType { public Builder fromReference(Reference in) { return fromReferenceType(in); } + + public Builder fromEntity(EntityType in) { + return href(in.getHref()).id(in.getId()).name(in.getName()).type(in.getType()); + } } public Reference(URI href, String id, String name, String type) { From 8cb04758ce1b349998152a90cddf9a11696c5fb1 Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:32:39 +0000 Subject: [PATCH 10/34] add dummy file for testing media upload --- labs/vcloud-director/src/test/resources/media/test.iso | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 labs/vcloud-director/src/test/resources/media/test.iso diff --git a/labs/vcloud-director/src/test/resources/media/test.iso b/labs/vcloud-director/src/test/resources/media/test.iso new file mode 100644 index 0000000000..e69de29bb2 From 781c0b538c3f7fc2cae3019bfd5c47dcc1e58aba Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:33:28 +0000 Subject: [PATCH 11/34] extract out metadata + upload clients --- .../v1_5/VCloudDirectorAsyncClient.java | 14 +++ .../director/v1_5/VCloudDirectorClient.java | 14 +++ .../VCloudDirectorRestClientModule.java | 6 + .../v1_5/features/MetadataAsyncClient.java | 115 ++++++++++++++++++ .../v1_5/features/MetadataClient.java | 81 ++++++++++++ .../v1_5/features/UploadAsyncClient.java | 55 +++++++++ .../director/v1_5/features/UploadClient.java | 48 ++++++++ 7 files changed, 333 insertions(+) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataClient.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/UploadAsyncClient.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/UploadClient.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java index 1c0cfd16c9..94d1a9d70b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java @@ -21,17 +21,20 @@ package org.jclouds.vcloud.director.v1_5; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Catalog; 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.Org; import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.domain.ovf.Network; import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient; +import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient; import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient; import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; import org.jclouds.vcloud.director.v1_5.features.QueryAsyncClient; import org.jclouds.vcloud.director.v1_5.features.TaskAsyncClient; import org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncClient; +import org.jclouds.vcloud.director.v1_5.features.UploadAsyncClient; import org.jclouds.vcloud.director.v1_5.features.VdcAsyncClient; import com.google.inject.Provides; @@ -92,6 +95,17 @@ public interface VCloudDirectorAsyncClient { @Delegate VdcAsyncClient getVdcClient(); + /** + * @return asynchronous access to Upload features + */ + @Delegate + UploadAsyncClient getUploadClient(); + + /** + * @return asynchronous access to {@link Metadata} features + */ + @Delegate + MetadataAsyncClient getMetadataClient(); /** * @return asynchronous access to {@link org.jclouds.vcloud.director.v1_5.domain.VAppTemplate} features */ diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java index 0dade36531..75094928ad 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java @@ -24,6 +24,7 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Catalog; 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.Org; import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.Task; @@ -31,11 +32,13 @@ import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.domain.ovf.Network; import org.jclouds.vcloud.director.v1_5.features.CatalogClient; import org.jclouds.vcloud.director.v1_5.features.MediaClient; +import org.jclouds.vcloud.director.v1_5.features.MetadataClient; import org.jclouds.vcloud.director.v1_5.features.NetworkClient; import org.jclouds.vcloud.director.v1_5.features.OrgClient; import org.jclouds.vcloud.director.v1_5.features.QueryClient; import org.jclouds.vcloud.director.v1_5.features.TaskClient; import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient; +import org.jclouds.vcloud.director.v1_5.features.UploadClient; import org.jclouds.vcloud.director.v1_5.features.VdcClient; import com.google.inject.Provides; @@ -96,6 +99,17 @@ public interface VCloudDirectorClient { @Delegate VdcClient getVdcClient(); + /** + * @return synchronous access to {@link Upload} features + */ + @Delegate + UploadClient getUploadClient(); + + /** + * @return synchronous access to {@link Metadata} features + */ + @Delegate + MetadataClient getMetadataClient(); /* * @return synchronous access to {@link org.jclouds.vcloud.director.v1_5.domain.VAppTemplate} features */ diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java index 3aa3d05ea6..5c39b4a14a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java @@ -43,6 +43,10 @@ import org.jclouds.vcloud.director.v1_5.annotations.Login; import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; import org.jclouds.vcloud.director.v1_5.features.*; +import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient; +import org.jclouds.vcloud.director.v1_5.features.MetadataClient; +import org.jclouds.vcloud.director.v1_5.features.UploadAsyncClient; +import org.jclouds.vcloud.director.v1_5.features.UploadClient; import org.jclouds.vcloud.director.v1_5.functions.LoginUserInOrgWithPassword; import org.jclouds.vcloud.director.v1_5.handlers.InvalidateSessionAndRetryOn401AndLogoutOnClose; import org.jclouds.vcloud.director.v1_5.handlers.VCloudDirectorErrorHandler; @@ -78,6 +82,8 @@ public class VCloudDirectorRestClientModule extends RestClientModule getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parent); + + /** + * @see MetadataClient.Readable#getMetadataEntry(URISupplier, String) + */ + @GET + @Path("/metadata/{key}") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parent , + @PathParam("key") String key); + } + + public static interface Writable extends Readable { + /** + * @see MetadataClient.Writable#mergeMetadata(URISupplier, Metadata)) + */ + @POST + @Path("/metadata") + @Consumes(VCloudDirectorMediaType.TASK) + @Produces(VCloudDirectorMediaType.METADATA) + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture mergeMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef, + @BinderParam(BindToXMLPayload.class) Metadata metadata); + + + /** + * @see MetadataClient.Writable#setMetadata(URISupplier, String, MetadataEntry)) + */ + @PUT + @Path("/metadata/{key}") + @Consumes(VCloudDirectorMediaType.TASK) + @Produces(VCloudDirectorMediaType.METADATA_VALUE) + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture setMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier metaDataRef, + @PathParam("key") String key, + @BinderParam(BindToXMLPayload.class) MetadataValue metadataValue); + + /** + * @see MetadataClient.Writable#deleteMetadataEntry(URISupplier, String)) + */ + @DELETE + @Path("/metadata/{key}") + @Consumes(VCloudDirectorMediaType.TASK) + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + 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/MetadataClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataClient.java new file mode 100644 index 0000000000..90842c8ab3 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataClient.java @@ -0,0 +1,81 @@ +/** + * 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.features; + +import java.util.concurrent.TimeUnit; + +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.Task; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; + +/** + * Provides synchronous access to Upload. + *

+ * + * @see MetadataAsyncClient + * @see + * @author danikov + */ +@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) +public interface MetadataClient { + public static interface Readable extends MetadataClient { + /** + * Retrieves an list of metadata + * + * @return a list of metadata + */ + Metadata getMetadata(URISupplier vdcRef); + + /** + * Retrieves a metadata value + * + * @return the metadata value, or null if not found + */ + MetadataValue getMetadataValue(URISupplier vdcRef, String key); + } + + public static interface Writable extends Readable { + /** + * 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(URISupplier mediaRef, Metadata metadata); + + /** + * Sets the metadata for the particular key for the media to the value provided. + * Note: this will replace any existing metadata information + * + * @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(URISupplier mediaRef, String key, MetadataValue metadataValue); + + /** + * Deletes a metadata entry. + * + * @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(URISupplier mediaRef, String key); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/UploadAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/UploadAsyncClient.java new file mode 100644 index 0000000000..0f0062acb1 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/UploadAsyncClient.java @@ -0,0 +1,55 @@ +/** + * 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.features; + +import java.io.File; + +import javax.ws.rs.PUT; + +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.RequestFilters; +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.ThrowVCloudErrorOn4xx; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + + * @see UploadClient + * @author danikov + */ +@RequestFilters(AddVCloudAuthorizationToRequest.class) +public interface UploadAsyncClient { // TODO: implement these operations correctly + + /** + * @see UploadClient#uploadFile(URISupplier, File) + */ + @PUT + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture uploadFile(URISupplier target, File file); + + /** + * @see UploadClient#uploadBigFile(URISupplier, File) + */ + @PUT + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture uploadBigFile(URISupplier target, File file); + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/UploadClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/UploadClient.java new file mode 100644 index 0000000000..cc256c7123 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/UploadClient.java @@ -0,0 +1,48 @@ +/** + * 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.features; + +import java.io.File; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.director.v1_5.domain.URISupplier; + +/** + * Provides synchronous access to Upload. + *

+ * + * @see UploadAsyncClient + * @see + * @author danikov + */ +@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) +public interface UploadClient { + + /** + * Uploads a file. + */ + void uploadFile(URISupplier target, File file); + + /** + * Uploads a file using ranged PUTs. + */ + void uploadBigFile(URISupplier target, File file); + +} From 44fc620f67e9d46c64cf76faab6c75f047e9238b Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:38:41 +0000 Subject: [PATCH 12/34] outline some live testing for the upload client --- .../v1_5/features/UploadClientLiveTest.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java new file mode 100644 index 0000000000..cb6640e665 --- /dev/null +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java @@ -0,0 +1,66 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + *(Link.builder().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(Link.builder().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.features; + +import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests behavior of {@link NetworkClient} + * + * @author danikov + */ +@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "NetworkClientLiveTest") +public class UploadClientLiveTest extends BaseVCloudDirectorClientLiveTest { + + public static final String UPLOAD = "upload"; + + /* + * Convenience reference to API client. + */ + protected UploadClient uploadClient; + + @BeforeClass(inheritGroups = true) + @Override + public void setupRequiredClients() { +// uploadClient = context.getApi().getUploadClient(); + } + + @Test(testName = "PUT ???") + public void testUpload() { + ////TODO upload to target + // long sourceChecksum = 0;// = Files.getChecksum(sourceFile, new CRC32()) + // + // // TODO: await task to complete + // media = mediaClient.getMedia(media); + // TasksInProgress tasks = media.getTasksInProgress(); + // if (tasks.getTasks().size() > 0) { +// assertTrue(tasks.getTasks().size() == 1, ""); +// Task uploadTask = Iterables.getFirst(tasks.getTasks(), null); +// Checks.checkTask(uploadTask); +// assertTrue(retryTaskSuccess.apply(uploadTask), String.format(TASK_COMPLETE_TIMELY, "createMedia")); + // } + // + // // TODO: make assertions that the task was successful + // media = mediaClient.getMedia(media); + // assertTrue(equal(sourceFile.length(), uploadFile.getSize()), ""); + // assertTrue(equal(sourceChecksum, uploadFile.getChecksum()), ""); + } +} From 58744ab91c01e8c0534b27d2aa9d5c7050c52e51 Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:39:01 +0000 Subject: [PATCH 13/34] add missing media type --- .../jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java index a2f87e8062..ce8a01df2b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java @@ -142,8 +142,9 @@ public class VCloudDirectorMediaType { COMPOSE_VAPP_PARAMS, INSTANTIATE_VAPP_TEMPLATE_PARAMS, UPLOAD_VAPP_TEMPLATE_PARAMS, QUERY_RESULT_RECORDS, QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS, + CONTROL_ACCESS, VAPP_TEMPLATE, CUSTOMIZATION_SECTION, GUEST_CUSTOMIZATION_SECTION, NETWORK_SECTION, NETWORK_CONFIG_SECTION, NETWORK_CONNECTION_SECTION, - CONTROL_ACCESS + CLONE_MEDIA_PARAMS , LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE ); From f2f2233db0677471f6914579dacd323db3b3c4d6 Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 29 Feb 2012 11:39:26 +0000 Subject: [PATCH 14/34] update and inline vdc clone/create methods into media testing --- .../v1_5/features/MediaClientLiveTest.java | 169 +++++++++++++----- 1 file changed, 122 insertions(+), 47 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index edecf90da7..633fffc339 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -23,11 +23,16 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.* import static org.testng.Assert.*; import java.net.URI; +import java.net.URISyntaxException; import java.util.Set; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Checks; +import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.Error; +import org.jclouds.vcloud.director.v1_5.domain.File; +import org.jclouds.vcloud.director.v1_5.domain.Link; 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.MetadataEntry; @@ -35,9 +40,9 @@ 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.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -52,49 +57,77 @@ import com.google.common.collect.Iterables; public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String MEDIA = "media"; + public static final String VDC = "vdc"; /* * Convenience references to API clients. */ - private Reference mediaRef; + private URISupplier vdcRef; + protected VdcClient vdcClient; protected MediaClient mediaClient; @BeforeClass(inheritGroups = true) @Override public void setupRequiredClients() { - mediaRef = Reference.builder() - .type("application/vnd.vmware.vcloud.media+xml") + vdcRef = Reference.builder() + .type("application/vnd.vmware.vcloud.vdc+xml") .name("") - .href(URI.create(endpoint+"/media/" + mediaId)) - .id(mediaId) + .href(URI.create(endpoint+"/vdc/"+vdcId)) + .id(vdcId) .build(); + + vdcClient = context.getApi().getVdcClient(); mediaClient = context.getApi().getMediaClient(); } /* * Shared state between dependent tests. */ - private Media media; + private Media media, oldMedia; private Owner owner; private Metadata metadata; private MetadataValue metadataValue; private String metadataEntryValue = "value"; - @BeforeGroups(groups = { "live" }) - public void createReferenceData() { - // FIXME: don't want to be modifying anything here! - mediaClient.setMetadata(mediaRef, "key", MetadataValue.builder().value("value").build()); + @Test(testName = "POST /vdc/{id}/media") + public void testCreateMedia() throws URISyntaxException { + assertNotNull(vdcRef, String.format(REF_REQ_LIVE, VDC)); + assertNotNull(vdcClient.getVdc(vdcRef), String.format(OBJ_REQ_LIVE, VDC)); + + java.io.File sourceFile = new java.io.File(getClass().getResource("/media/test.iso").toURI()); + + Media sourceMedia = Media.builder() + .type(VCloudDirectorMediaType.MEDIA) + .name("Test media 1") + .size(sourceFile.length()) + .imageType(Media.ImageType.ISO) + .description("Test media generated by testCreateMedia()") + .build(); + media = vdcClient.createMedia(vdcRef, sourceMedia); + + Checks.checkMediaFor(MEDIA, media); + + assertNotNull(media.getFiles(), ""); + assertTrue(media.getFiles().getFiles().size() == 1, ""); + File uploadFile = Iterables.getFirst(media.getFiles().getFiles(), null); + assertNotNull(uploadFile, ""); + assertTrue(equal(uploadFile.getSize(), sourceMedia.getSize()), ""); + + Set links = uploadFile.getLinks(); + assertNotNull(links, ""); + assertTrue(links.size() == 1, ""); + Link uploadLink = Iterables.getFirst(links, null); + + //TODO upload file +// context.getApi().getUploadClient().uploadFile(uploadFile, sourceFile); + fail(); } - @Test(testName = "GET /media/{id}") + @Test(testName = "GET /media/{id}", dependsOnMethods = { "testCreateMedia" }) public void testGetMedia() { - // required for testing - assertNotNull(mediaRef, String.format(REF_REQ_LIVE, MEDIA)); - - media = mediaClient.getMedia(mediaRef); + media = mediaClient.getMedia(media); assertNotNull(media, String.format(OBJ_REQ_LIVE, MEDIA)); - assertTrue(!media.getDescription().equals("DO NOT USE"), "Media isn't to be used for testing"); owner = media.getOwner(); assertNotNull(owner, String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "owner")); @@ -106,7 +139,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /media/{id}/owner", dependsOnMethods = { "testGetMedia" }) public void testGetMediaOwner() { - Owner directOwner = mediaClient.getOwner(mediaRef); + Owner directOwner = mediaClient.getOwner(media); assertEquals(owner, directOwner, String.format(GETTER_RETURNS_SAME_OBJ, "getOwner()", "owner", "media.getOwner()", owner.toString(), directOwner.toString())); @@ -118,8 +151,50 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkReferenceType(directOwner.getUser()); } + @Test(testName = "POST /vdc/{id}/action/cloneMedia", + dependsOnMethods = { "testGetMediaOwner" }) + public void testCloneMedia() { + oldMedia = media; + media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder() + .source(Reference.builder().fromEntity(media).build()) + .build()); + + Checks.checkMediaFor(VDC, media); + + Task copyTask = Iterables.getFirst(media.getTasksInProgress().getTasks(), null); + if (copyTask != null) { + Checks.checkTask(copyTask); + assertTrue(retryTaskSuccess.apply(copyTask), String.format(TASK_COMPLETE_TIMELY, "copyTask")); + media = mediaClient.getMedia(media); + } + + Checks.checkMediaFor(MEDIA, media); + assertTrue(media.clone(oldMedia), ""); + + mediaClient.setMetadata(media, "key", MetadataValue.builder().value("value").build()); + + media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder() + .source(Reference.builder().fromEntity(media).build()) + .name("copied test media") + .description("copied by testCloneMedia()") + .isSourceDelete(true) + .build()); + + Checks.checkMediaFor(VDC, media); + + copyTask = Iterables.getFirst(media.getTasksInProgress().getTasks(), null); + if (copyTask != null) { + Checks.checkTask(copyTask); + assertTrue(retryTaskSuccess.apply(copyTask), String.format(TASK_COMPLETE_TIMELY, "copyTask")); + media = mediaClient.getMedia(media); + } + + Checks.checkMediaFor(MEDIA, media); + assertTrue(media.clone(oldMedia), ""); + } + @Test(testName = "PUT /media/{id}", - dependsOnMethods = { "testGetMedia" }) + dependsOnMethods = { "testCloneMedia" }) public void testSetMedia() { String oldName = media.getName(); String newName = "new "+oldName; @@ -127,10 +202,10 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { String newDescription = "new "+oldDescription; media = media.toBuilder().name(newName).description(newDescription).build(); - Task updateMedia = mediaClient.updateMedia(mediaRef, media); + Task updateMedia = mediaClient.updateMedia(media, media); Checks.checkTask(updateMedia); - assertTrue(retryTaskSuccess.apply(updateMedia.getHref()), String.format(TASK_COMPLETE_TIMELY, "updateMedia")); - media = mediaClient.getMedia(mediaRef); + assertTrue(retryTaskSuccess.apply(updateMedia), String.format(TASK_COMPLETE_TIMELY, "updateMedia")); + media = mediaClient.getMedia(media); assertTrue(equal(media.getName(), newName), String.format(OBJ_FIELD_UPDATABLE, MEDIA, "name")); assertTrue(equal(media.getDescription(), newDescription), @@ -142,16 +217,16 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { media = media.toBuilder().name(oldName).description(oldDescription).build(); - updateMedia = mediaClient.updateMedia(mediaRef, media); + updateMedia = mediaClient.updateMedia(media, media); Checks.checkTask(updateMedia); - assertTrue(retryTaskSuccess.apply(updateMedia.getHref()), String.format(TASK_COMPLETE_TIMELY, "updateMedia")); - media = mediaClient.getMedia(mediaRef); + assertTrue(retryTaskSuccess.apply(updateMedia), String.format(TASK_COMPLETE_TIMELY, "updateMedia")); + media = mediaClient.getMedia(media); } @Test(testName = "GET /media/{id}/metadata", dependsOnMethods = { "testGetMedia" }) public void testGetMetadata() { - metadata = mediaClient.getMetadata(mediaRef); + metadata = mediaClient.getMetadata(media); // required for testing assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "metadata.entries")); @@ -168,14 +243,14 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { .entries(inputEntries) .build(); - Task mergeMetadata = mediaClient.mergeMetadata(mediaRef, inputMetadata); + Task mergeMetadata = mediaClient.mergeMetadata(media, inputMetadata); Checks.checkTask(mergeMetadata); - assertTrue(retryTaskSuccess.apply(mergeMetadata.getHref()), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(new)")); - metadata = mediaClient.getMetadata(mediaRef); + assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(new)")); + metadata = mediaClient.getMetadata(media); Checks.checkMetadataFor(MEDIA, metadata); checkMetadataContainsEntries(metadata, inputEntries); - media = mediaClient.getMedia(mediaRef); + media = mediaClient.getMedia(media); Checks.checkMediaFor(MEDIA, media); // test modify @@ -184,14 +259,14 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { .entries(inputEntries) .build(); - mergeMetadata = mediaClient.mergeMetadata(mediaRef, inputMetadata); + mergeMetadata = mediaClient.mergeMetadata(media, inputMetadata); Checks.checkTask(mergeMetadata); - assertTrue(retryTaskSuccess.apply(mergeMetadata.getHref()), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(modify)")); - metadata = mediaClient.getMetadata(mediaRef); + assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(modify)")); + metadata = mediaClient.getMetadata(media); Checks.checkMetadataFor(MEDIA, metadata); checkMetadataContainsEntries(metadata, inputEntries); - media = mediaClient.getMedia(mediaRef); + media = mediaClient.getMedia(media); Checks.checkMediaFor(MEDIA, media); } @@ -215,7 +290,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /media/{id}/metadata/{key}", dependsOnMethods = { "testMergeMetadata" }) public void testGetMetadataValue() { - metadataValue = mediaClient.getMetadataValue(mediaRef, "key"); + metadataValue = mediaClient.getMetadataValue(media, "key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); } @@ -225,20 +300,20 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { metadataEntryValue = "newValue"; MetadataValue newValue = MetadataValue.builder().value(metadataEntryValue).build(); - Task setMetadataEntry = mediaClient.setMetadata(mediaRef, "key", newValue); + Task setMetadataEntry = mediaClient.setMetadata(media, "key", newValue); Checks.checkTask(setMetadataEntry); - assertTrue(retryTaskSuccess.apply(setMetadataEntry.getHref()), + assertTrue(retryTaskSuccess.apply(setMetadataEntry), String.format(TASK_COMPLETE_TIMELY, "setMetadataEntry")); - metadataValue = mediaClient.getMetadataValue(mediaRef, "key"); + metadataValue = mediaClient.getMetadataValue(media, "key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); } @Test(testName = "DELETE /media/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" } ) public void testDeleteMetadata() { - Task deleteMetadataEntry = mediaClient.deleteMetadataEntry(mediaRef, "testKey"); + Task deleteMetadataEntry = mediaClient.deleteMetadataEntry(media, "testKey"); Checks.checkTask(deleteMetadataEntry); - assertTrue(retryTaskSuccess.apply(deleteMetadataEntry.getHref()), + assertTrue(retryTaskSuccess.apply(deleteMetadataEntry), String.format(TASK_COMPLETE_TIMELY, "deleteMetadataEntry")); Error expected = Error.builder() @@ -248,7 +323,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { .build(); try { - metadataValue = mediaClient.getMetadataValue(mediaRef, "testKey"); + metadataValue = mediaClient.getMetadataValue(media, "testKey"); fail("Should give HTTP 403 error"); } catch (VCloudDirectorException vde) { assertEquals(vde.getError(), expected); @@ -263,31 +338,31 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { "metadataEntry", metadataValue.toString())); } - metadataValue = mediaClient.getMetadataValue(mediaRef, "key"); + metadataValue = mediaClient.getMetadataValue(media, "key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); - media = mediaClient.getMedia(mediaRef); + media = mediaClient.getMedia(media); Checks.checkMediaFor(MEDIA, media); } @Test(testName = "DELETE /media/{id}", dependsOnMethods = { "testDeleteMetadata" } ) public void testDeleteMedia() { - Task deleteMedia = mediaClient.deleteMedia(mediaRef); + Task deleteMedia = mediaClient.deleteMedia(media); Checks.checkTask(deleteMedia); - assertTrue(retryTaskSuccess.apply(deleteMedia.getHref()), + assertTrue(retryTaskSuccess.apply(deleteMedia), String.format(TASK_COMPLETE_TIMELY, "deleteMedia")); Error expected = Error.builder() .message(String.format( "No access to entity \"(com.vmware.vcloud.entity.media:%s)\".", - mediaRef.getId())) + media.getId())) .majorErrorCode(403) .minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN") .build(); try { - media = mediaClient.getMedia(mediaRef); + media = mediaClient.getMedia(media); fail("Should give HTTP 403 error"); } catch (VCloudDirectorException vde) { assertEquals(vde.getError(), expected); From 526dee9bf7955b8c3d5ca235dd4290a8eae655f4 Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 12:42:19 +0000 Subject: [PATCH 15/34] move and complete media tests --- .../v1_5/features/MediaClientExpectTest.java | 165 +++++++++++++++++- .../v1_5/features/VdcClientExpectTest.java | 23 +-- 2 files changed, 161 insertions(+), 27 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java index 097a1415fe..1faf162e63 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java @@ -26,7 +26,10 @@ import java.net.URI; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.Error; +import org.jclouds.vcloud.director.v1_5.domain.File; +import org.jclouds.vcloud.director.v1_5.domain.FilesList; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Metadata; @@ -35,6 +38,7 @@ 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.TasksInProgress; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.testng.annotations.Test; @@ -43,10 +47,70 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "NetworkClientExpectTest") +@Test(groups = { "unit", "media" }, singleThreaded = true, testName = "MediaClientExpectTest") public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { - @Test(enabled = false) + @Test + public void testCreateMedia() { + URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/media") + .acceptMedia(VCloudDirectorMediaType.MEDIA) + .xmlFilePayload("/media/createMediaSource.xml", VCloudDirectorMediaType.MEDIA) + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/media/createMedia.xml", VCloudDirectorMediaType.MEDIA) + .httpResponseBuilder().statusCode(201).build()); + + Media source = Media.builder() + .size(0) + .imageType("iso") + .name("Test media 1") + .type("application/vnd.vmware.vcloud.media+xml") + .description("Test media generated by testCreateMedia()") + .build(); + Media expected = createMedia(); + + Reference vdcRef = Reference.builder().href(vdcUri).build(); + + assertEquals(client.getVdcClient().createMedia(vdcRef, source), expected); + } + + @Test + public void testCloneMedia() { + URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneMedia") + .acceptMedia(VCloudDirectorMediaType.MEDIA) + .xmlFilePayload("/media/cloneMediaParams.xml", VCloudDirectorMediaType.CLONE_MEDIA_PARAMS) + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/media/cloneMedia.xml", VCloudDirectorMediaType.MEDIA) + .httpResponseBuilder().statusCode(201).build()); + + CloneMediaParams params = CloneMediaParams.builder() + .name("moved test media") + .description("moved by testCloneMedia()") + .source(Reference.builder() + .type("application/vnd.vmware.vcloud.media+xml") + .name("copied test media") + .id("urn:vcloud:media:da8361af-cccd-4103-a71c-493513c49094") + .href(URI.create("https://mycloud.greenhousedata.com/api/media/da8361af-cccd-4103-a71c-493513c49094")) + .build()) + .isSourceDelete(false) + .build(); + Media expected = cloneMedia(); + + Reference vdcRef = Reference.builder().href(vdcUri).build(); + + assertEquals(client.getVdcClient().cloneMedia(vdcRef, params), expected); + } + + @Test public void testGetMedia() { URI mediaUri = URI.create(endpoint + "/media/794eb334-754e-4917-b5a0-5df85cbd61d1"); @@ -59,13 +123,14 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes .xmlFilePayload("/media/media.xml", VCloudDirectorMediaType.MEDIA) .httpResponseBuilder().build()); - Media expected = media(); + Media expected = getMedia(); Reference mediaRef = Reference.builder().href(mediaUri).build(); assertEquals(client.getMediaClient().getMedia(mediaRef), expected); } + @Test public void testResponse400ForInvalidMedia() { URI mediaUri = URI.create(endpoint + "/media/NOTAUUID"); @@ -319,7 +384,96 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes assertEquals(client.getMediaClient().getOwner(mediaRef), expected); } - private static Media media() { + private static Media createMedia() { + return Media.builder() + .size(0) + .imageType("iso") + .status(0) + .name("Test media 1") + .id("urn:vcloud:media:d51b0b9d-099c-499f-97f8-4fbe40ba06d7") + .type("application/vnd.vmware.vcloud.media+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/media/d51b0b9d-099c-499f-97f8-4fbe40ba06d7")) + .link(Link.builder() + .rel("up") + .type("application/vnd.vmware.vcloud.vdc+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f")) + .build()) + .link(Link.builder() + .rel("remove") + .href(URI.create("https://mycloud.greenhousedata.com/api/media/d51b0b9d-099c-499f-97f8-4fbe40ba06d7")) + .build()) + .description("Test media generated by testCreateMedia()") + .files(FilesList.builder() + .file(File.builder() + .size(0l) + .bytesTransferred(0l) + .name("file") + .link(Link.builder() + .rel("upload:default") + .href(URI.create("https://mycloud.greenhousedata.com:443/transfer/b1fdf2d0-feff-4414-a8d1-3a8d86c4ccc5/file")) + .build()) + .build()) + .build()) + .owner(owner()) + .build(); + } + + private static Media cloneMedia() { + return Media.builder() + .size(175163392) + .imageType("iso") + .status(0) + .name("copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2") + .id("urn:vcloud:media:a6b023f2-7f90-4e89-a24d-56e0eba83a5a") + .type("application/vnd.vmware.vcloud.media+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/media/a6b023f2-7f90-4e89-a24d-56e0eba83a5a")) + .link(Link.builder() + .rel("up") + .type("application/vnd.vmware.vcloud.vdc+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f")) + .build()) + .link(Link.builder() + .rel("remove") + .href(URI.create("https://mycloud.greenhousedata.com/api/media/a6b023f2-7f90-4e89-a24d-56e0eba83a5a")) + .build()) + .description("copied by testCloneMedia()") + .tasksInProgress(TasksInProgress.builder() + .task(Task.builder() + .status("running") + .startTime(dateService.iso8601DateParse("2012-03-02T04:58:48.754-07:00")) + .operationName("vdcCopyMedia") + .operation("Copying Media File copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2(a6b023f2-7f90-4e89-a24d-56e0eba83a5a)") + .expiryTime(dateService.iso8601DateParse("2012-05-31T04:58:48.754-06:00")) + .name("task") + .id("urn:vcloud:task:7e4f6baf-7ef0-43ea-93cc-62cc329afb5d") + .type("application/vnd.vmware.vcloud.task+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/task/7e4f6baf-7ef0-43ea-93cc-62cc329afb5d")) + .link(Link.builder() + .rel("task:cancel") + .href(URI.create("https://mycloud.greenhousedata.com/api/task/7e4f6baf-7ef0-43ea-93cc-62cc329afb5d/action/cancel")) + .build()) + .owner(Reference.builder() + .type("application/vnd.vmware.vcloud.media+xml") + .name("copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2") + .href(URI.create("https://mycloud.greenhousedata.com/api/media/a6b023f2-7f90-4e89-a24d-56e0eba83a5a")) + .build()) + .user(Reference.builder() + .type("application/vnd.vmware.admin.user+xml") + .name("acole") + .href(URI.create("https://mycloud.greenhousedata.com/api/admin/user/c090335b-708c-4c1c-9e3d-89560d002120")) + .build()) + .org(Reference.builder() + .type("application/vnd.vmware.vcloud.org+xml") + .name("cloudsoft") + .href(URI.create("https://mycloud.greenhousedata.com/api/org/c076f90a-397a-49fa-89b8-b294c1599cd0")) + .build()) + .build()) + .build()) + .owner(owner()) + .build(); + } + + private static Media getMedia() { return Media.builder() .size(175163392) .imageType("iso") @@ -356,7 +510,8 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes .type("application/vnd.vmware.vcloud.metadata+xml") .href(URI.create("https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata")) .build()) - .description("Windows 2003 R2 Disk2 Standard 32bit & 64bit") + .type("application/vnd.vmware.vcloud.media+xml") + .description("Windows 2003 R2 Disk2 Standard 32bit & 64bit") .owner(owner()) .build(); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index b4ba9250d0..6d7e96e03f 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -193,28 +193,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest } } - @Test(enabled = false) - public void testCloneMedia() { - VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - new VcloudHttpRequestPrimer() - .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneMedia") - .xmlFilePayload("/vdc/params/cloneMedia.xml", VCloudDirectorMediaType.CLONE_MEDIA_PARAMS) - .acceptAnyMedia() - .httpRequestBuilder().build(), - new VcloudHttpResponsePrimer() - .xmlFilePayload("/vdc/cloneMedia.xml", VCloudDirectorMediaType.MEDIA) - .httpResponseBuilder().build()); - - Media expected = cloneMedia(); - - // TODO: configure params - CloneMediaParams params = CloneMediaParams.builder() - - .build(); - - assertEquals(client.getVdcClient().cloneMedia(vdcRef, params), expected); - } - + @Test @Test(enabled = false) public void testCloneVApp() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, From b9e0263aa16ae02f9a1478222b8159c40856f722 Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 12:43:00 +0000 Subject: [PATCH 16/34] remove comments and name correctly --- .../v1_5/features/UploadClientLiveTest.java | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java index cb6640e665..ca8c63fa23 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java @@ -27,7 +27,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "NetworkClientLiveTest") +@Test(groups = { "live", "api", "upload" }, singleThreaded = true, testName = "UploadClientLiveTest") public class UploadClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String UPLOAD = "upload"; @@ -40,27 +40,10 @@ public class UploadClientLiveTest extends BaseVCloudDirectorClientLiveTest { @BeforeClass(inheritGroups = true) @Override public void setupRequiredClients() { -// uploadClient = context.getApi().getUploadClient(); + uploadClient = context.getApi().getUploadClient(); } - @Test(testName = "PUT ???") + @Test(testName = "PUT ???", enabled = false) public void testUpload() { - ////TODO upload to target - // long sourceChecksum = 0;// = Files.getChecksum(sourceFile, new CRC32()) - // - // // TODO: await task to complete - // media = mediaClient.getMedia(media); - // TasksInProgress tasks = media.getTasksInProgress(); - // if (tasks.getTasks().size() > 0) { -// assertTrue(tasks.getTasks().size() == 1, ""); -// Task uploadTask = Iterables.getFirst(tasks.getTasks(), null); -// Checks.checkTask(uploadTask); -// assertTrue(retryTaskSuccess.apply(uploadTask), String.format(TASK_COMPLETE_TIMELY, "createMedia")); - // } - // - // // TODO: make assertions that the task was successful - // media = mediaClient.getMedia(media); - // assertTrue(equal(sourceFile.length(), uploadFile.getSize()), ""); - // assertTrue(equal(sourceChecksum, uploadFile.getChecksum()), ""); } } From 6a4ccc517860268d70ef192e4d37f4273eb3df38 Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 12:43:32 +0000 Subject: [PATCH 17/34] pass clone media --- .../v1_5/features/MediaClientLiveTest.java | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index 633fffc339..ba5bb48f0c 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -90,7 +90,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { private MetadataValue metadataValue; private String metadataEntryValue = "value"; - @Test(testName = "POST /vdc/{id}/media") + @Test(testName = "POST /vdc/{id}/media", enabled = false) public void testCreateMedia() throws URISyntaxException { assertNotNull(vdcRef, String.format(REF_REQ_LIVE, VDC)); assertNotNull(vdcClient.getVdc(vdcRef), String.format(OBJ_REQ_LIVE, VDC)); @@ -118,10 +118,10 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { assertNotNull(links, ""); assertTrue(links.size() == 1, ""); Link uploadLink = Iterables.getFirst(links, null); + assertTrue(equal(uploadLink.getRel(), Link.Rel.UPLOAD_DEFAULT), ""); - //TODO upload file -// context.getApi().getUploadClient().uploadFile(uploadFile, sourceFile); - fail(); + fail(); //TODO upload file and assert it succeeds + context.getApi().getUploadClient().uploadFile(uploadLink, sourceFile); } @Test(testName = "GET /media/{id}", dependsOnMethods = { "testCreateMedia" }) @@ -157,15 +157,19 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { oldMedia = media; media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder() .source(Reference.builder().fromEntity(media).build()) + .name("copied test media") + .description("copied by testCloneMedia()") .build()); Checks.checkMediaFor(VDC, media); - Task copyTask = Iterables.getFirst(media.getTasksInProgress().getTasks(), null); - if (copyTask != null) { - Checks.checkTask(copyTask); - assertTrue(retryTaskSuccess.apply(copyTask), String.format(TASK_COMPLETE_TIMELY, "copyTask")); - media = mediaClient.getMedia(media); + if (media.getTasksInProgress() != null) { + Task copyTask = Iterables.getFirst(media.getTasksInProgress().getTasks(), null); + if (copyTask != null) { + Checks.checkTask(copyTask); + assertTrue(retryTaskSuccess.apply(copyTask), String.format(TASK_COMPLETE_TIMELY, "copyTask")); + media = mediaClient.getMedia(media); + } } Checks.checkMediaFor(MEDIA, media); @@ -175,18 +179,20 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder() .source(Reference.builder().fromEntity(media).build()) - .name("copied test media") - .description("copied by testCloneMedia()") + .name("moved test media") + .description("moved by testCloneMedia()") .isSourceDelete(true) .build()); Checks.checkMediaFor(VDC, media); - copyTask = Iterables.getFirst(media.getTasksInProgress().getTasks(), null); - if (copyTask != null) { - Checks.checkTask(copyTask); - assertTrue(retryTaskSuccess.apply(copyTask), String.format(TASK_COMPLETE_TIMELY, "copyTask")); - media = mediaClient.getMedia(media); + if (media.getTasksInProgress() != null) { + Task copyTask = Iterables.getFirst(media.getTasksInProgress().getTasks(), null); + if (copyTask != null) { + Checks.checkTask(copyTask); + assertTrue(retryTaskSuccess.apply(copyTask), String.format(TASK_COMPLETE_TIMELY, "copyTask")); + media = mediaClient.getMedia(media); + } } Checks.checkMediaFor(MEDIA, media); @@ -374,5 +380,8 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { if (media != null) { // guard against NPE on the .toStrings assertNull(metadataValue, String.format(OBJ_DEL, MEDIA, media.toString())); } + + deleteMedia = mediaClient.deleteMedia(oldMedia); + Checks.checkTask(deleteMedia); } } From 1b2da14aabfb474a800e80503ba716a43093ee69 Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 12:45:18 +0000 Subject: [PATCH 18/34] add incremental builder method --- .../director/v1_5/domain/FilesList.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java index 050ecd1d86..642a6131ff 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java @@ -20,13 +20,14 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -66,23 +67,29 @@ public class FilesList { public static class Builder { - private Set files = Sets.newLinkedHashSet(); + private List files = Lists.newLinkedList(); + + /** + * @see FilesList#getFiles() + */ + public Builder files(List files) { + this.files = Lists.newLinkedList(checkNotNull(files, "files")); + return this; + } /** * @see FilesList#getFiles() */ - public Builder files(Set files) { - this.files = files; + public Builder file(File file) { + files.add(checkNotNull(file, "file")); return this; } - - + public FilesList build() { FilesList filesList = new FilesList(files); return filesList; } - public Builder fromFilesList(FilesList in) { return files(in.getFiles()); } From 9d2923e96cd7bb91eeaae4602f86845015dcd22a Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 12:45:39 +0000 Subject: [PATCH 19/34] fix builder --- .../vcloud/director/v1_5/domain/File.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java index 47b0015cdd..7679fc3390 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java @@ -100,14 +100,30 @@ public class File extends EntityType { public File build() { return new File(href, type, links, description, tasksInProgress, id, name, size, bytesTransferred, checksum); + } + /** + * @see EntityType#getName() + */ + public Builder name(String name) { + super.name(name); + return this; + } + + /** + * @see EntityType#getDescription() + */ + public Builder description(String description) { + super.description(description); + return this; + } /** * @see EntityType#getId() */ @Override public Builder id(String id) { - this.id = id; + super.id(id); return this; } @@ -116,7 +132,7 @@ public class File extends EntityType { */ @Override public Builder tasksInProgress(TasksInProgress tasksInProgress) { - this.tasksInProgress = tasksInProgress; + super.tasksInProgress (tasksInProgress); return this; } @@ -125,7 +141,7 @@ public class File extends EntityType { */ @Override public Builder href(URI href) { - this.href = href; + super.href(href); return this; } @@ -182,7 +198,9 @@ public class File extends EntityType { // For JAXB and builder use } - + private File(URI href, String name) { + super(href, name); + } @XmlAttribute protected Long size; @XmlAttribute From 24725cf88c33957e94f21ac034f34c30949c56e0 Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 12:45:58 +0000 Subject: [PATCH 20/34] fix clone method and xmlElement name --- .../org/jclouds/vcloud/director/v1_5/domain/EntityType.java | 6 ++---- .../java/org/jclouds/vcloud/director/v1_5/domain/Media.java | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java index feb434aedf..b866ccd307 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java @@ -137,7 +137,7 @@ public abstract class EntityType> extends ResourceType> extends ResourceType that = EntityType.class.cast(o); - return super.equals(that) && - equal(this.description, that.description) && - equal(this.name, that.name); + return super.clone(that); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java index c218c59efd..010a18ba3f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java @@ -253,7 +253,7 @@ public class Media extends ResourceEntityType { return false; Media that = Media.class.cast(o); return super.clone(that) && - equal(this.owner, that.owner) && equal(this.imageType, that.imageType) && equal(this.size, that.size); + equal(this.imageType, that.imageType) && equal(this.size, that.size); } @Override From 0c0dedee17406d8a6a045b2bd3cdb21957d40e35 Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 12:46:33 +0000 Subject: [PATCH 21/34] add XmlRootElement annotation --- .../vcloud/director/v1_5/domain/CloneMediaParams.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java index d195c2e1bf..982a0440be 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java @@ -22,6 +22,7 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; @@ -50,7 +51,8 @@ import com.google.common.base.Objects; * </complexType> * */ -@XmlType(name = "CloneMediaParams", propOrder = { +@XmlRootElement(name = "CloneMediaParams") +@XmlType(propOrder = { "source", "isSourceDelete" }) @@ -90,8 +92,8 @@ public class CloneMediaParams public CloneMediaParams build() { return new CloneMediaParams(description, name, source, isSourceDelete); - cloneMediaParams.setDescription(description); cloneMediaParams.setName(name); + cloneMediaParams.setDescription(description); } From e24b96e043cf85c96fc629abc56261dfd6d86910 Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 12:46:45 +0000 Subject: [PATCH 22/34] exemplar xml for expect tests --- .../src/test/resources/media/cloneMedia.xml | 17 +++++++++++++++++ .../test/resources/media/cloneMediaParams.xml | 6 ++++++ .../src/test/resources/media/createMedia.xml | 14 ++++++++++++++ .../test/resources/media/createMediaSource.xml | 4 ++++ 4 files changed, 41 insertions(+) create mode 100644 labs/vcloud-director/src/test/resources/media/cloneMedia.xml create mode 100644 labs/vcloud-director/src/test/resources/media/cloneMediaParams.xml create mode 100644 labs/vcloud-director/src/test/resources/media/createMedia.xml create mode 100644 labs/vcloud-director/src/test/resources/media/createMediaSource.xml diff --git a/labs/vcloud-director/src/test/resources/media/cloneMedia.xml b/labs/vcloud-director/src/test/resources/media/cloneMedia.xml new file mode 100644 index 0000000000..e7e64cbffa --- /dev/null +++ b/labs/vcloud-director/src/test/resources/media/cloneMedia.xml @@ -0,0 +1,17 @@ + + + + + copied by testCloneMedia() + + + + + + + + + + + + \ No newline at end of file diff --git a/labs/vcloud-director/src/test/resources/media/cloneMediaParams.xml b/labs/vcloud-director/src/test/resources/media/cloneMediaParams.xml new file mode 100644 index 0000000000..4081d718b4 --- /dev/null +++ b/labs/vcloud-director/src/test/resources/media/cloneMediaParams.xml @@ -0,0 +1,6 @@ + + + moved by testCloneMedia() + + false + diff --git a/labs/vcloud-director/src/test/resources/media/createMedia.xml b/labs/vcloud-director/src/test/resources/media/createMedia.xml new file mode 100644 index 0000000000..0fb95ac1b8 --- /dev/null +++ b/labs/vcloud-director/src/test/resources/media/createMedia.xml @@ -0,0 +1,14 @@ + + + + + Test media generated by testCreateMedia() + + + + + + + + + diff --git a/labs/vcloud-director/src/test/resources/media/createMediaSource.xml b/labs/vcloud-director/src/test/resources/media/createMediaSource.xml new file mode 100644 index 0000000000..6fe96c74e0 --- /dev/null +++ b/labs/vcloud-director/src/test/resources/media/createMediaSource.xml @@ -0,0 +1,4 @@ + + + Test media generated by testCreateMedia() + From 5518149db91035b12257edae63b4204ddfa43d52 Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 13:12:44 +0000 Subject: [PATCH 23/34] merge to master --- .../v1_5/domain/CloneMediaParams.java | 2 -- .../director/v1_5/domain/EntityType.java | 3 ++- .../vcloud/director/v1_5/domain/File.java | 7 ++---- .../director/v1_5/domain/FilesList.java | 13 ++++++----- .../vcloud/director/v1_5/domain/Media.java | 1 - .../v1_5/features/VdcClientExpectTest.java | 23 ------------------- 6 files changed, 11 insertions(+), 38 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java index 982a0440be..e96cc68b01 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java @@ -92,8 +92,6 @@ public class CloneMediaParams public CloneMediaParams build() { return new CloneMediaParams(description, name, source, isSourceDelete); - cloneMediaParams.setName(name); - cloneMediaParams.setDescription(description); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java index b866ccd307..3645f5e4d1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Set; + import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -137,7 +138,7 @@ public abstract class EntityType> extends ResourceType { - @SuppressWarnings("unchecked") public static Builder builder() { return new Builder(); } @@ -194,13 +193,11 @@ public class File extends EntityType { this.checksum = checksum; } + @SuppressWarnings("unused") private File() { - // For JAXB and builder use + // For JAXB } - private File(URI href, String name) { - super(href, name); - } @XmlAttribute protected Long size; @XmlAttribute diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java index 642a6131ff..233e132923 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java @@ -22,13 +22,14 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import java.util.Set; +import java.util.List; + import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import com.google.common.collect.Sets; /** @@ -99,18 +100,18 @@ public class FilesList { // For JAXB and builder use } - private FilesList(Set files) { - this.files = ImmutableSet.copyOf(files); + private FilesList(List files) { + this.files = ImmutableList.copyOf(files); } @XmlElement(name = "File", required = true) - protected Set files = Sets.newLinkedHashSet(); + protected List files = Lists.newLinkedList(); /** * Gets the value of the file property. */ - public Set getFiles() { + public List getFiles() { return this.files; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java index 010a18ba3f..1c42578cb0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java @@ -48,7 +48,6 @@ public class Media extends ResourceEntityType { public static final List ALL = Arrays.asList(ISO, FLOPPY); } - @SuppressWarnings("unchecked") public static Builder builder() { return new Builder(); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index 6d7e96e03f..1ccd0a2042 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -193,29 +193,6 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest } } - @Test - @Test(enabled = false) - public void testCloneVApp() { - VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - new VcloudHttpRequestPrimer() - .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneVApp") - .xmlFilePayload("/vdc/params/cloneVApp.xml", VCloudDirectorMediaType.CLONE_V_APP_PARAMS) - .acceptAnyMedia() - .httpRequestBuilder().build(), - new VcloudHttpResponsePrimer() - .xmlFilePayload("/vdc/cloneVApp.xml", VCloudDirectorMediaType.V_APP) - .httpResponseBuilder().build()); - - VApp expected = cloneVApp(); - - // TODO: configure params - CloneVAppParams params = CloneVAppParams.builder() - - .build(); - - assertEquals(client.getVdcClient().cloneVApp(vdcRef, params), expected); - } - @Test(enabled = false) public void testCloneVAppTemplate() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, From 15c2ac64206987b5a7ad44f094a390a70e822368 Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 13:47:17 +0000 Subject: [PATCH 24/34] rename to match field --- .../jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java index 32b9c72159..daeb321453 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java @@ -65,7 +65,7 @@ import com.google.common.collect.Sets; */ @XmlType(name = "CaptureVAppParams", propOrder = { "source", - "section" + "sections" }) public class CaptureVAppParams extends ParamsType From 136faf40ba2a1f9aaf8e8710b2d2bb66974ed76f Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 13:47:34 +0000 Subject: [PATCH 25/34] disable broken class --- .../org/jclouds/vcloud/director/v1_5/domain/ParamsType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java index 98aaea6fed..d2967ac6e8 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java @@ -55,7 +55,7 @@ import com.google.common.base.Objects; "description" }) @XmlSeeAlso({ - CaptureVAppParams.class, +// CaptureVAppParams.class, // FIXME! CloneVAppTemplateParams.class, CloneMediaParams.class, UploadVAppTemplateParams.class From fe31db7eeadb78b9026078b15aadd6b4f136dbd9 Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 13:47:51 +0000 Subject: [PATCH 26/34] add endpoint parsers --- .../vcloud/director/v1_5/features/TaskAsyncClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 e54c1d04d7..d73d066d85 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 @@ -35,6 +35,7 @@ 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; +import org.jclouds.vcloud.director.v1_5.functions.URISupplierToEndpoint; import com.google.common.util.concurrent.ListenableFuture; @@ -61,7 +62,7 @@ public interface TaskAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getTask(@EndpointParam URISupplier taskRef); + ListenableFuture getTask(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier taskRef); /** * @see TaskClient#cancelTask(URI) @@ -71,5 +72,5 @@ public interface TaskAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture cancelTask(@EndpointParam URISupplier taskRef); + ListenableFuture cancelTask(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier taskRef); } From 2433ec1d3fdbf6d46e52d3a783d3b252300a5cbd Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 14:13:03 +0000 Subject: [PATCH 27/34] tidy test, add missing test, remove leftovers --- .../v1_5/features/VdcClientExpectTest.java | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index 1ccd0a2042..bebbd34014 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -30,7 +30,6 @@ import org.jclouds.vcloud.director.v1_5.domain.AvailableNetworks; import org.jclouds.vcloud.director.v1_5.domain.Capabilities; import org.jclouds.vcloud.director.v1_5.domain.CapacityWithUsage; import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; @@ -57,14 +56,14 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "apitests", "user" }, singleThreaded = true, testName = "VdcClientExpectTest") +@Test(groups = { "unit", "user", "vdc" }, singleThreaded = true, testName = "VdcClientExpectTest") public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { private Reference vdcRef; @BeforeClass public void before() { - String vdcId = "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"; + String vdcId = "e9cd3387-ac57-4d27-a481-9bee75e0690f"; vdcRef = Reference.builder() .type("application/vnd.vmware.vcloud.vdc+xml") .name("") @@ -73,7 +72,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest .build(); } - @Test(enabled = false) + @Test public void testGetVdc() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer() @@ -89,8 +88,10 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest assertEquals(client.getVdcClient().getVdc(vdcRef), expected); } - @Test(enabled = false) + @Test public void testResponse400ForInvalidVdcId() { + URI vdcUri = URI.create(endpoint + "/vdc/NOTAUUID"); + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer() .apiCommand("GET", "/vdc/NOTAUUID") @@ -105,6 +106,8 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest .majorErrorCode(400) .minorErrorCode("BAD_REQUEST") .build(); + + Reference vdcRef = Reference.builder().href(vdcUri).build(); try { client.getVdcClient().getVdc(vdcRef); @@ -116,8 +119,10 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest } } - @Test(enabled = false) + @Test public void testResponse403ForFakeVdcId() { + URI vdcUri = URI.create(endpoint + "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer() .apiCommand("GET", "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") @@ -132,6 +137,8 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest .majorErrorCode(403) .minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN") .build(); + + Reference vdcRef = Reference.builder().href(vdcUri).build(); try { client.getVdcClient().getVdc(vdcRef); @@ -193,6 +200,28 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest } } + @Test(enabled = false) + public void testCloneVApp() { + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneVAppTemplate") + .xmlFilePayload("/vdc/params/cloneVApp.xml", VCloudDirectorMediaType.CLONE_V_APP_PARAMS) + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/cloneVApp.xml", VCloudDirectorMediaType.V_APP) + .httpResponseBuilder().build()); + + VApp expected = cloneVApp(); + + // TODO: configure params + CloneVAppParams params = CloneVAppParams.builder() + + .build(); + + assertEquals(client.getVdcClient().cloneVApp(vdcRef, params), expected); + } + @Test(enabled = false) public void testCloneVAppTemplate() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, @@ -478,11 +507,6 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest return null; } - private Media cloneMedia() { - // TODO Auto-generated method stub - return null; - } - private VApp cloneVApp() { // TODO Auto-generated method stub return null; From 61deb778d14f5e05988dd4118ec7193b5ead8f82 Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 14:13:42 +0000 Subject: [PATCH 28/34] disable UploadClient dependent tests --- .../v1_5/features/MediaClientLiveTest.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index ba5bb48f0c..e3a636b189 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -53,7 +53,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "MediaClientLiveTest") +@Test(groups = { "live", "user", "media" }, singleThreaded = true, testName = "MediaClientLiveTest") public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String MEDIA = "media"; @@ -124,7 +124,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { context.getApi().getUploadClient().uploadFile(uploadLink, sourceFile); } - @Test(testName = "GET /media/{id}", dependsOnMethods = { "testCreateMedia" }) + @Test(testName = "GET /media/{id}", dependsOnMethods = { "testCreateMedia" }, enabled = false) public void testGetMedia() { media = mediaClient.getMedia(media); assertNotNull(media, String.format(OBJ_REQ_LIVE, MEDIA)); @@ -137,7 +137,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } @Test(testName = "GET /media/{id}/owner", - dependsOnMethods = { "testGetMedia" }) + dependsOnMethods = { "testGetMedia" }, enabled = false) public void testGetMediaOwner() { Owner directOwner = mediaClient.getOwner(media); assertEquals(owner, directOwner, String.format(GETTER_RETURNS_SAME_OBJ, @@ -152,7 +152,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } @Test(testName = "POST /vdc/{id}/action/cloneMedia", - dependsOnMethods = { "testGetMediaOwner" }) + dependsOnMethods = { "testGetMediaOwner" }, enabled = false) public void testCloneMedia() { oldMedia = media; media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder() @@ -200,7 +200,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } @Test(testName = "PUT /media/{id}", - dependsOnMethods = { "testCloneMedia" }) + dependsOnMethods = { "testCloneMedia" }, enabled = false) public void testSetMedia() { String oldName = media.getName(); String newName = "new "+oldName; @@ -230,7 +230,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } @Test(testName = "GET /media/{id}/metadata", - dependsOnMethods = { "testGetMedia" }) + dependsOnMethods = { "testGetMedia" }, enabled = false) public void testGetMetadata() { metadata = mediaClient.getMetadata(media); // required for testing @@ -241,7 +241,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } @Test(testName = "POST /media/{id}/metadata", - dependsOnMethods = { "testGetMetadata" }) + dependsOnMethods = { "testGetMetadata" }, enabled = false) public void testMergeMetadata() { // test new Set inputEntries = ImmutableSet.of(MetadataEntry.builder().entry("testKey", "testValue").build()); @@ -294,14 +294,14 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } @Test(testName = "GET /media/{id}/metadata/{key}", - dependsOnMethods = { "testMergeMetadata" }) + dependsOnMethods = { "testMergeMetadata" }, enabled = false) public void testGetMetadataValue() { metadataValue = mediaClient.getMetadataValue(media, "key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); } @Test(testName = "PUT /media/{id}/metadata/{key}", - dependsOnMethods = { "testGetMetadataValue" }) + dependsOnMethods = { "testGetMetadataValue" }, enabled = false) public void testSetMetadataValue() { metadataEntryValue = "newValue"; MetadataValue newValue = MetadataValue.builder().value(metadataEntryValue).build(); @@ -315,7 +315,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } @Test(testName = "DELETE /media/{id}/metadata/{key}", - dependsOnMethods = { "testSetMetadataValue" } ) + dependsOnMethods = { "testSetMetadataValue" }, enabled = false ) public void testDeleteMetadata() { Task deleteMetadataEntry = mediaClient.deleteMetadataEntry(media, "testKey"); Checks.checkTask(deleteMetadataEntry); @@ -352,7 +352,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } @Test(testName = "DELETE /media/{id}", - dependsOnMethods = { "testDeleteMetadata" } ) + dependsOnMethods = { "testDeleteMetadata" }, enabled = false ) public void testDeleteMedia() { Task deleteMedia = mediaClient.deleteMedia(media); Checks.checkTask(deleteMedia); From f1945234037db1dbdb2f5985f275e0462cc577a4 Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 2 Mar 2012 14:14:04 +0000 Subject: [PATCH 29/34] tidy up test groupings --- .../director/v1_5/features/CatalogClientExpectTest.java | 2 +- .../vcloud/director/v1_5/features/CatalogClientLiveTest.java | 2 +- .../vcloud/director/v1_5/features/MediaClientExpectTest.java | 2 +- .../director/v1_5/features/NetworkClientExpectTest.java | 2 +- .../vcloud/director/v1_5/features/NetworkClientLiveTest.java | 2 +- .../vcloud/director/v1_5/features/OrgClientExpectTest.java | 2 +- .../vcloud/director/v1_5/features/OrgClientLiveTest.java | 2 +- .../vcloud/director/v1_5/features/QueryClientExpectTest.java | 2 +- .../vcloud/director/v1_5/features/QueryClientLiveTest.java | 2 +- .../vcloud/director/v1_5/features/TaskClientExpectTest.java | 2 +- .../vcloud/director/v1_5/features/TaskClientLiveTest.java | 2 +- .../vcloud/director/v1_5/features/UploadClientLiveTest.java | 2 +- .../vcloud/director/v1_5/features/VdcClientLiveTest.java | 4 +--- 13 files changed, 13 insertions(+), 15 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java index a41409f3ee..18cf10c3e4 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java @@ -46,7 +46,7 @@ import com.google.common.collect.ImmutableSet; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "CatalogClientExpectTest") +@Test(groups = { "unit", "user", "catalog" }, singleThreaded = true, testName = "CatalogClientExpectTest") public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { @Test 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 aef5ec0bfd..a01e021db6 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 @@ -55,7 +55,7 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "CatalogClientLiveTest") +@Test(groups = { "live", "user", "catalog" }, singleThreaded = true, testName = "CatalogClientLiveTest") public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java index 1faf162e63..f5700e6fad 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java @@ -47,7 +47,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "media" }, singleThreaded = true, testName = "MediaClientExpectTest") +@Test(groups = { "unit", "user", "media" }, singleThreaded = true, testName = "MediaClientExpectTest") public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java index 2cdfb95b08..f17857dc24 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java @@ -48,7 +48,7 @@ import com.google.common.collect.ImmutableSet; * * @author danikov */ -@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "NetworkClientExpectTest") +@Test(groups = { "unit", "user", "network" }, singleThreaded = true, testName = "NetworkClientExpectTest") public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java index d2ecac0bb3..12a7259850 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java @@ -50,7 +50,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "NetworkClientLiveTest") +@Test(groups = { "live", "user", "network" }, singleThreaded = true, testName = "NetworkClientLiveTest") public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String NETWORK = "network"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index 9ed89265d5..bb4773d53b 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -45,7 +45,7 @@ import com.google.common.collect.Iterables; * * @author Adrian Cole */ -@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "OrgClientExpectTest") +@Test(groups = { "unit", "user", "org" }, singleThreaded = true, testName = "OrgClientExpectTest") public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java index 7a4bee6afc..e4ccf4c56c 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java @@ -45,7 +45,7 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "OrgClientLiveTest") +@Test(groups = { "live", "user", "org" }, singleThreaded = true, testName = "OrgClientLiveTest") public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java index 967284c4aa..b87ff1b077 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java @@ -41,7 +41,7 @@ import com.google.common.collect.ImmutableMultimap; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "QueryClientExpectTest") +@Test(groups = { "unit", "user", "query" }, singleThreaded = true, testName = "QueryClientExpectTest") public class QueryClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java index fb3bcba3a5..a1ded707e8 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java @@ -32,7 +32,7 @@ import org.testng.annotations.Test; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "QueryClientLiveTest") +@Test(groups = { "live", "user", "query" }, singleThreaded = true, testName = "QueryClientLiveTest") public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* 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 d3c69107ae..dba061c25c 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 @@ -43,7 +43,7 @@ import com.google.common.collect.ImmutableMultimap; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "TaskClientExpectTest") +@Test(groups = { "unit", "user", "task" }, singleThreaded = true, testName = "TaskClientExpectTest") public class TaskClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { @Test 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 07cd62d220..95a412b1df 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 @@ -38,7 +38,7 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "TaskClientLiveTest") +@Test(groups = { "live", "user", "task" }, singleThreaded = true, testName = "TaskClientLiveTest") public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java index ca8c63fa23..6b4d25cd64 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java @@ -27,7 +27,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "live", "api", "upload" }, singleThreaded = true, testName = "UploadClientLiveTest") +@Test(groups = { "live", "user", "upload" }, singleThreaded = true, testName = "UploadClientLiveTest") public class UploadClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String UPLOAD = "upload"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index 33ea099a1d..c7a67f29ca 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -31,12 +31,10 @@ import java.net.URI; import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; import org.jclouds.vcloud.director.v1_5.domain.Checks; -import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParams; -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; @@ -55,7 +53,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "apitests", "user" }, testName = "VdcClientLiveTest") +@Test(groups = { "live", "user", "vdc" }, testName = "VdcClientLiveTest") public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String VDC = "vdc"; From 5789d1783ee7cfe99b15e1c45e8ab389170f3554 Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 5 Mar 2012 10:52:04 +0000 Subject: [PATCH 30/34] test groupings + metadataclient delegation --- .../v1_5/VCloudDirectorAsyncClient.java | 10 +- .../director/v1_5/VCloudDirectorClient.java | 9 +- .../VCloudDirectorRestClientModule.java | 3 +- .../v1_5/features/CatalogAsyncClient.java | 81 +--------------- .../director/v1_5/features/CatalogClient.java | 93 +------------------ .../v1_5/features/MediaAsyncClient.java | 64 +------------ .../director/v1_5/features/MediaClient.java | 41 +------- .../v1_5/features/MetadataAsyncClient.java | 6 +- .../v1_5/features/MetadataClient.java | 15 +-- .../v1_5/features/NetworkAsyncClient.java | 25 +---- .../director/v1_5/features/NetworkClient.java | 17 +--- .../v1_5/features/OrgAsyncClient.java | 24 +---- .../director/v1_5/features/OrgClient.java | 24 +---- .../v1_5/features/VdcAsyncClient.java | 24 +---- .../director/v1_5/features/VdcClient.java | 16 +--- .../features/CatalogClientExpectTest.java | 14 +-- .../v1_5/features/CatalogClientLiveTest.java | 32 +++---- .../v1_5/features/MediaClientExpectTest.java | 12 +-- .../v1_5/features/MediaClientLiveTest.java | 24 ++--- .../features/NetworkClientExpectTest.java | 4 +- .../v1_5/features/NetworkClientLiveTest.java | 4 +- .../v1_5/features/OrgClientExpectTest.java | 4 +- .../v1_5/features/OrgClientLiveTest.java | 4 +- .../v1_5/features/VdcClientExpectTest.java | 4 +- .../v1_5/features/VdcClientLiveTest.java | 4 +- 25 files changed, 110 insertions(+), 448 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java index 94d1a9d70b..40bbac8771 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java @@ -21,20 +21,18 @@ package org.jclouds.vcloud.director.v1_5; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Catalog; 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.Org; import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.domain.ovf.Network; import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient; import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient; import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; import org.jclouds.vcloud.director.v1_5.features.QueryAsyncClient; import org.jclouds.vcloud.director.v1_5.features.TaskAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncClient; import org.jclouds.vcloud.director.v1_5.features.UploadAsyncClient; +import org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncClient; import org.jclouds.vcloud.director.v1_5.features.VdcAsyncClient; import com.google.inject.Provides; @@ -101,11 +99,7 @@ public interface VCloudDirectorAsyncClient { @Delegate UploadAsyncClient getUploadClient(); - /** - * @return asynchronous access to {@link Metadata} features - */ - @Delegate - MetadataAsyncClient getMetadataClient(); + /** * @return asynchronous access to {@link org.jclouds.vcloud.director.v1_5.domain.VAppTemplate} features */ diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java index 75094928ad..15d4195af1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java @@ -24,7 +24,6 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Catalog; 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.Org; import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.Task; @@ -32,13 +31,12 @@ import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.domain.ovf.Network; import org.jclouds.vcloud.director.v1_5.features.CatalogClient; import org.jclouds.vcloud.director.v1_5.features.MediaClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataClient; import org.jclouds.vcloud.director.v1_5.features.NetworkClient; import org.jclouds.vcloud.director.v1_5.features.OrgClient; import org.jclouds.vcloud.director.v1_5.features.QueryClient; import org.jclouds.vcloud.director.v1_5.features.TaskClient; -import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient; import org.jclouds.vcloud.director.v1_5.features.UploadClient; +import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient; import org.jclouds.vcloud.director.v1_5.features.VdcClient; import com.google.inject.Provides; @@ -106,11 +104,6 @@ public interface VCloudDirectorClient { UploadClient getUploadClient(); /** - * @return synchronous access to {@link Metadata} features - */ - @Delegate - MetadataClient getMetadataClient(); - /* * @return synchronous access to {@link org.jclouds.vcloud.director.v1_5.domain.VAppTemplate} features */ @Delegate diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java index 5c39b4a14a..7163767131 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java @@ -83,7 +83,8 @@ public class VCloudDirectorRestClientModule extends RestClientModule addCatalogItem(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef, @BinderParam(BindToXMLPayload.class) CatalogItem catalogItem); - /** - * Returns the metadata associated with the catalog. - */ - @GET - @Path("/metadata") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef); - - /** - * Returns the metadata associated with the catalog for the specified key. - */ - @GET - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef, - @PathParam("key") String key); - /** * Retrieves a catalog item. */ @@ -125,58 +102,8 @@ public interface CatalogAsyncClient { ListenableFuture deleteCatalogItem(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef); /** - * Returns the metadata associated with the catalog item. + * @return asynchronous access to {@link Metadata.Writeable} features */ - @GET - @Path("/metadata") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogItemMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef); - - /** - * Merges the metadata for a catalog item with the information provided. - */ - @POST - @Path("/metadata") - @Consumes(VCloudDirectorMediaType.TASK) - @Produces(VCloudDirectorMediaType.METADATA) - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture mergeCatalogItemMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, - @BinderParam(BindToXMLPayload.class) Metadata catalogItemMetadata); - - /** - * Returns the metadata associated with the catalog item for the specified key. - */ - @GET - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogItemMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, - @PathParam("key") String key); - - /** - * Sets the metadata for the particular key for the catalog item to the value provided. - */ - @PUT - @Path("/metadata/{key}") - @Consumes(VCloudDirectorMediaType.TASK) - @Produces(VCloudDirectorMediaType.METADATA_VALUE) - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture setCatalogItemMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, - @PathParam("key") String key, @BinderParam(BindToXMLPayload.class) MetadataValue metadataValue); - - /** - * Deletes the metadata for the particular key for the catalog item. - */ - @DELETE - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture deleteCatalogItemMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, - @PathParam("key") String key); + @Delegate + MetadataAsyncClient.Writable getMetadataClient(); } 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 da583f3f45..9fc27f23de 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 @@ -21,11 +21,10 @@ package org.jclouds.vcloud.director.v1_5.features; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.Delegate; 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.Task; import org.jclouds.vcloud.director.v1_5.domain.URISupplier; /** @@ -62,31 +61,6 @@ public interface CatalogClient { */ CatalogItem addCatalogItem(URISupplier catalogRef, CatalogItem item); - /** - * Returns the metadata associated with the catalog. - * - *

-    * GET /catalog/{id}/metadata
-    * 
- * - * @param catalogRef the reference for the catalog - * @return the catalog metadata - */ - Metadata getCatalogMetadata(URISupplier catalogRef); - - /** - * Returns the metadata associated with the catalog for the specified key. - * - *
-    * GET /catalog/{id}/metadata/{key}
-    * 
- * - * @param catalogRef the reference for the catalog - * @param key the metadata entry key - * @return the catalog metadata value - */ - MetadataValue getCatalogMetadataValue(URISupplier catalogRef, String key); - /** * Retrieves a catalog item. * @@ -124,67 +98,8 @@ public interface CatalogClient { void deleteCatalogItem(URISupplier catalogItemRef); /** - * Returns the metadata associated with the catalog item. - * - *
-    * GET /catalogItem/{id}/metadata
-    * 
- * - * @param catalogItemRef the reference for the catalog item - * @return the catalog item metadata + * @return synchronous access to {@link Metadata.Writeable} features */ - Metadata getCatalogItemMetadata(URISupplier catalogItemRef); - - /** - * Merges the metadata for a catalog item with the information provided. - * - *
-    * POST /catalogItem/{id}/metadata
-    * 
- * - * @param catalogItemRef the reference for the catalog item - * @param catalogItemMetadata the metadata for the catalog item - * @return a task for the merge operation - */ - Task mergeCatalogItemMetadata(URISupplier catalogItemRef, Metadata catalogItemMetadata); - - /** - * Returns the metadata associated with the catalog item for the specified key. - * - *
-    * GET /catalog/{id}/metadata/{key}
-    * 
- * - * @param catalogItemRef the reference for the catalog item - * @param key the metadata entry key - * @return the catalog item metadata value - */ - MetadataValue getCatalogItemMetadataValue(URISupplier catalogItemRef, String key); - - /** - * Sets the metadata for the particular key for the catalog item to the value provided. - * - *
-    * PUT /catalog/{id}/metadata/{key}
-    * 
- * - * @param catalogItemRef the reference for the catalog item - * @param key the metadata entry key - * @param value the metadata value - * @return a task for the set operation - */ - Task setCatalogItemMetadataValue(URISupplier catalogItemRef, String key, MetadataValue value); - - /** - * Deletes the metadata for the particular key for the catalog item. - * - *
-    * DELETE /catalog/{id}/metadata/{key}
-    * 
- * - * @param catalogItemRef the reference for the catalog item - * @param key the metadata entry key - * @return a task for the delete operation - */ - Task deleteCatalogItemMetadataValue(URISupplier catalogItemRef, String key); + @Delegate + MetadataClient.Writeable getMetadataClient(); } 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 3bd49792ab..4c28188b6e 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 @@ -21,13 +21,12 @@ package org.jclouds.vcloud.director.v1_5.features; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; @@ -36,7 +35,6 @@ import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; 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.Task; import org.jclouds.vcloud.director.v1_5.domain.URISupplier; @@ -93,60 +91,8 @@ public interface MediaAsyncClient { ListenableFuture getOwner(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef); /** - * @see MediaClient#getMetadata(URISupplier)) - */ - @GET - @Path("/metadata") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef); - - /** - * @see MediaClient#mergeMetadata(URISupplier, Metadata)) - */ - @POST - @Path("/metadata") - @Consumes(VCloudDirectorMediaType.TASK) - @Produces(VCloudDirectorMediaType.METADATA) - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture mergeMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef, - @BinderParam(BindToXMLPayload.class) Metadata metadata); - - /** - * @see MediaClient#getMetadataEntry(URISupplier, String)) - */ - @GET - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef, - @PathParam("key") String key); - - /** - * @see MediaClient#setMetadata(URISupplier, String, MetadataEntry)) - */ - @PUT - @Path("/metadata/{key}") - @Consumes(VCloudDirectorMediaType.TASK) - @Produces(VCloudDirectorMediaType.METADATA_VALUE) - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture setMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier metaDataRef, - @PathParam("key") String key, - @BinderParam(BindToXMLPayload.class) MetadataValue metadataValue); - - /** - * @see MediaClient#deleteMetadataEntry(URISupplier, String)) - */ - @DELETE - @Path("/metadata/{key}") - @Consumes(VCloudDirectorMediaType.TASK) - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture deleteMetadataEntry(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier metaDataRef, - @PathParam("key") String key); - + * @return asynchronous access to {@link Metadata.Writeable} features + */ + @Delegate + MetadataAsyncClient.Writable getMetadataClient(); } 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 4a55b7bdd5..7f19e85b52 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 @@ -21,9 +21,9 @@ package org.jclouds.vcloud.director.v1_5.features; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.Delegate; 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.Task; import org.jclouds.vcloud.director.v1_5.domain.URISupplier; @@ -67,42 +67,9 @@ public interface MediaClient { Owner getOwner(URISupplier mediaRef); /** - * Retrieves an list of the media's metadata - * - * @return a list of metadata + * @return synchronous access to {@link Metadata.Writeable} features */ - 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(URISupplier mediaRef, Metadata metadata); - - /** - * Retrieves a metadata value - * - * @return the metadata value, or null if not found - */ - MetadataValue getMetadataValue(URISupplier mediaRef, String key); - - /** - * Sets the metadata for the particular key for the media to the value provided. - * Note: this will replace any existing metadata information - * - * @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(URISupplier mediaRef, String key, MetadataValue metadataValue); - - /** - * Deletes a metadata entry. - * - * @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(URISupplier mediaRef, String key); - + @Delegate + MetadataClient.Writeable getMetadataClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java index b1a4341288..1998a8bd2e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java @@ -60,7 +60,7 @@ public interface MetadataAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parent); + ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parentRef); /** * @see MetadataClient.Readable#getMetadataEntry(URISupplier, String) @@ -70,7 +70,7 @@ public interface MetadataAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parent , + ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parentRef , @PathParam("key") String key); } @@ -84,7 +84,7 @@ public interface MetadataAsyncClient { @Produces(VCloudDirectorMediaType.METADATA) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture mergeMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef, + ListenableFuture mergeMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parentRef, @BinderParam(BindToXMLPayload.class) Metadata metadata); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataClient.java index 90842c8ab3..5d31ff3b4e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataClient.java @@ -34,32 +34,33 @@ import org.jclouds.vcloud.director.v1_5.domain.URISupplier; * @see
* @author danikov */ -@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) public interface MetadataClient { + @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) public static interface Readable extends MetadataClient { /** * Retrieves an list of metadata * * @return a list of metadata */ - Metadata getMetadata(URISupplier vdcRef); + Metadata getMetadata(URISupplier parentRef); /** * Retrieves a metadata value * * @return the metadata value, or null if not found */ - MetadataValue getMetadataValue(URISupplier vdcRef, String key); + MetadataValue getMetadataValue(URISupplier parentRef, String key); } - public static interface Writable extends Readable { + @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) + public static interface Writeable extends Readable { /** * 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(URISupplier mediaRef, Metadata metadata); + Task mergeMetadata(URISupplier parentRef, Metadata metadata); /** * Sets the metadata for the particular key for the media to the value provided. @@ -68,7 +69,7 @@ public interface MetadataClient { * @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(URISupplier mediaRef, String key, MetadataValue metadataValue); + Task setMetadata(URISupplier parentRef, String key, MetadataValue metadataValue); /** * Deletes a metadata entry. @@ -76,6 +77,6 @@ public interface MetadataClient { * @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(URISupplier mediaRef, String key); + Task deleteMetadataEntry(URISupplier parentRef, 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 7681d80660..c1121c7c50 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 @@ -20,15 +20,13 @@ package org.jclouds.vcloud.director.v1_5.features; import javax.ws.rs.Consumes; import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; +import org.jclouds.rest.annotations.Delegate; 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.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.URISupplier; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; @@ -55,24 +53,9 @@ public interface NetworkAsyncClient { ListenableFuture getNetwork(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier networkRef); /** - * @see NeworkClient#getMetadata(URISupplier) + * @return asynchronous access to {@link Metadata.Readable} features */ - @GET - @Path("/metadata") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier networkRef); - - /** - * @see NeworkClient#getMetadataValue(URISupplier, String) - */ - @GET - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier networkRef , - @PathParam("key") String key); + @Delegate + MetadataAsyncClient.Readable getMetadataClient(); } 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 7fbb6859c2..2cf8e2239a 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 @@ -21,8 +21,8 @@ package org.jclouds.vcloud.director.v1_5.features; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.Delegate; 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.URISupplier; @@ -45,17 +45,8 @@ public interface NetworkClient { OrgNetwork getNetwork(URISupplier networkRef); /** - * Retrieves an list of the network's metadata - * - * @return a list of metadata + * @return synchronous access to {@link Metadata.Readable} features */ - Metadata getMetadata(URISupplier networkRef); - - /** - * Retrieves a metadata value - * - * @return the metadata value, or null if not found - */ - MetadataValue getMetadataValue(URISupplier networkRef, String key); - + @Delegate + MetadataClient.Readable getMetadataClient(); } 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 d3437511ef..57f647074c 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 @@ -21,14 +21,13 @@ package org.jclouds.vcloud.director.v1_5.features; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; +import org.jclouds.rest.annotations.Delegate; 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.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; @@ -65,23 +64,8 @@ public interface OrgAsyncClient { ListenableFuture getOrg(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier orgRef); /** - * @see OrgClient#getMetadata(ReferenceType) + * @return asynchronous access to {@link Metadata.Readable} features */ - @GET - @Path("/metadata") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getOrgMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier orgRef); - - /** - * @see OrgClient#getMetadataEntry(ReferenceType, String) - */ - @GET - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getOrgMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier orgRef, - @PathParam("key") String key); + @Delegate + MetadataAsyncClient.Readable getMetadataClient(); } 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 d297c21b17..1a954f3893 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 @@ -21,8 +21,8 @@ package org.jclouds.vcloud.director.v1_5.features; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.Delegate; 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.URISupplier; @@ -60,24 +60,8 @@ public interface OrgClient { Org getOrg(URISupplier orgRef); /** - * Retrieves an list of the organization's metadata - * - *
-    * GET /org/{id}/metadata
-    * 
- * - * @return a list of metadata + * @return synchronous access to {@link Metadata.Readable} features */ - Metadata getOrgMetadata(URISupplier orgRef); - - /** - * Retrieves a metadata entry. - * - *
-    * GET /org/{id}/metadata{key}
-    * 
- * - * @return the metadata entry or null if not found - */ - MetadataValue getOrgMetadataValue(URISupplier orgRef, String key); + @Delegate + MetadataClient.Readable getMetadataClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java index 1089d68647..100692c8cb 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java @@ -22,10 +22,10 @@ import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; @@ -40,7 +40,6 @@ import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; 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.URISupplier; import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; @@ -166,24 +165,9 @@ public interface VdcAsyncClient { @BinderParam(BindToXMLPayload.class) Media media); /** - * @see VdcClient#getMetadata(URISupplier) + * @return asynchronous access to {@link Metadata.Readable} features */ - @GET - @Path("/metadata") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef); - - /** - * @see VdcClient#getMetadataEntry(URISupplier, String) - */ - @GET - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef , - @PathParam("key") String key); + @Delegate + MetadataAsyncClient.Readable getMetadataClient(); } \ No newline at end of file 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 edc48e8108..7a20e21fe0 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 @@ -21,6 +21,7 @@ package org.jclouds.vcloud.director.v1_5.features; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; @@ -29,7 +30,6 @@ import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; 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.URISupplier; import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; @@ -144,17 +144,9 @@ public interface VdcClient { Media createMedia(URISupplier vdcRef, Media media); /** - * Retrieves an list of the vdc's metadata - * - * @return a list of metadata + * @return synchronous access to {@link Metadata.Readable} features */ - Metadata getMetadata(URISupplier vdcRef); - - /** - * Retrieves a metadata value - * - * @return the metadata value, or null if not found - */ - MetadataValue getMetadataValue(URISupplier vdcRef, String key); + @Delegate + MetadataClient.Readable getMetadataClient(); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java index 18cf10c3e4..e0e1cbe1ee 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java @@ -149,7 +149,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT .entries(ImmutableSet.of(metadataEntry())) .build(); - assertEquals(client.getCatalogClient().getCatalogMetadata(catalogRef), expected); + assertEquals(client.getCatalogClient().getMetadataClient().getMetadata(catalogRef), expected); } @Test @@ -178,7 +178,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT MetadataValue expected = metadataValue(); - assertEquals(client.getCatalogClient().getCatalogMetadataValue(catalogRef, "KEY"), expected); + assertEquals(client.getCatalogClient().getMetadataClient().getMetadataValue(catalogRef, "KEY"), expected); } @Test @@ -301,7 +301,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT .entries(ImmutableSet.of(itemMetadataEntry())) .build(); - assertEquals(client.getCatalogClient().getCatalogItemMetadata(catalogItemReference), expected); + assertEquals(client.getCatalogClient().getMetadataClient().getMetadata(catalogItemReference), expected); } @Test @@ -333,7 +333,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT Task expected = mergeMetadataTask(); - assertEquals(client.getCatalogClient().mergeCatalogItemMetadata(catalogItemReference, metadata), expected); + assertEquals(client.getCatalogClient().getMetadataClient().mergeMetadata(catalogItemReference, metadata), expected); } @Test @@ -362,7 +362,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT MetadataValue expected = itemMetadataValue(); - assertEquals(client.getCatalogClient().getCatalogItemMetadataValue(catalogItemReference, "KEY"), expected); + assertEquals(client.getCatalogClient().getMetadataClient().getMetadataValue(catalogItemReference, "KEY"), expected); } @Test @@ -394,7 +394,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT Task expected = setMetadataValueTask(); - assertEquals(client.getCatalogClient().setCatalogItemMetadataValue(catalogItemReference, "KEY", value), expected); + assertEquals(client.getCatalogClient().getMetadataClient().setMetadata(catalogItemReference, "KEY", value), expected); } @Test @@ -423,7 +423,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT Task expected = deleteMetadataEntryTask(); - assertEquals(client.getCatalogClient().deleteCatalogItemMetadataValue(catalogItemReference, "KEY"), expected); + assertEquals(client.getCatalogClient().getMetadataClient().deleteMetadataEntry(catalogItemReference, "KEY"), expected); } public static final Catalog catalog() { 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 a01e021db6..7cdf8e37f9 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 @@ -150,7 +150,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { // NOTE for this test to work, we need to be able to create metadata on a Catalog, specifically { "KEY", "VALUE" } @Test(testName = "GET /catalog/{id}/metadata", dependsOnMethods = { "testGetCatalog" }, enabled = false) public void testGetCatalogMetadata() { - catalogMetadata = catalogClient.getCatalogMetadata(catalogRef); + catalogMetadata = catalogClient.getMetadataClient().getMetadata(catalogRef); checkMetadata(catalogMetadata); } @@ -163,7 +163,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { return input.getKey().equals("KEY"); } }); - MetadataValue metadataValue = catalogClient.getCatalogMetadataValue(catalogRef, "KEY"); + MetadataValue metadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogRef, "KEY"); assertEquals(metadataValue.getValue(), existingMetadataEntry.getValue(), String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", existingMetadataEntry.getValue(), metadataValue.getValue())); checkMetadataValue(metadataValue); @@ -172,7 +172,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /catalogItem/{id}/metadata", dependsOnMethods = { "testGetCatalogItem" }) public void testGetCatalogItemMetadata() { resetCatalogItemMetadata(catalogItemRef); - catalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); + catalogItemMetadata = catalogClient.getMetadataClient().getMetadata(catalogItemRef); assertEquals(catalogItemMetadata.getMetadataEntries().size(), 1, String.format(MUST_EXIST_FMT, "MetadataEntry", "CatalogItem")); checkMetadata(catalogItemMetadata); } @@ -184,22 +184,22 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { .entry(MetadataEntry.builder().entry("VEGIMITE", "VALUE").build()) .build(); - Task mergeCatalogItemMetadata = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata); + Task mergeCatalogItemMetadata = catalogClient.getMetadataClient().mergeMetadata(catalogItemRef, newMetadata); checkTask(mergeCatalogItemMetadata); assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata")); - Metadata mergedCatalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); + Metadata mergedCatalogItemMetadata = catalogClient.getMetadataClient().getMetadata(catalogItemRef); // XXX assertEquals(mergedCatalogItemMetadata.getMetadataEntries().size(), catalogItemMetadata.getMetadataEntries().size() + 1, "Should have added another MetadataEntry to the CatalogItem"); - MetadataValue keyMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); + MetadataValue keyMetadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "KEY"); // XXX assertEquals(keyMetadataValue.getValue(), "MARMALADE", "The Value of the MetadataValue for KEY should have changed"); checkMetadataValue(keyMetadataValue); - MetadataValue newKeyMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "VEGIMITE"); + MetadataValue newKeyMetadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "VEGIMITE"); // XXX assertEquals(newKeyMetadataValue.getValue(), "VALUE", "The Value of the MetadataValue for NEW_KEY should have been set"); checkMetadataValue(newKeyMetadataValue); @@ -215,7 +215,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { return input.getKey().equals("KEY"); } }); - MetadataValue metadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); + MetadataValue metadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "KEY"); assertEquals(existingMetadataEntry.getValue(), metadataValue.getValue()); checkMetadataValue(metadataValue); } @@ -224,13 +224,13 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { public void testSetCatalogItemMetadataValue() { MetadataValue newMetadataValue = MetadataValue.builder().value("NEW").build(); - Task setCatalogItemMetadataValue = catalogClient.setCatalogItemMetadataValue(catalogItemRef, "KEY", newMetadataValue); + Task setCatalogItemMetadataValue = catalogClient.getMetadataClient().setMetadata(catalogItemRef, "KEY", newMetadataValue); checkTask(setCatalogItemMetadataValue); Checks.checkTask(setCatalogItemMetadataValue); assertTrue(retryTaskSuccess.apply(setCatalogItemMetadataValue), String.format(TASK_COMPLETE_TIMELY, "setCatalogItemMetadataValue")); - MetadataValue updatedMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); + MetadataValue updatedMetadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "KEY"); assertEquals(updatedMetadataValue.getValue(), newMetadataValue.getValue(), String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", newMetadataValue.getValue(), updatedMetadataValue.getValue())); checkMetadataValue(updatedMetadataValue); @@ -238,13 +238,13 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "DELETE /catalog/{id}/metadata/{key}", dependsOnMethods = { "testSetCatalogItemMetadataValue" }) public void testDeleteCatalogItemMetadataValue() { - Task deleteCatalogItemMetadataValue = catalogClient.deleteCatalogItemMetadataValue(catalogItemRef, "KEY"); + Task deleteCatalogItemMetadataValue = catalogClient.getMetadataClient().deleteMetadataEntry(catalogItemRef, "KEY"); checkTask(deleteCatalogItemMetadataValue); Checks.checkTask(deleteCatalogItemMetadataValue); assertTrue(retryTaskSuccess.apply(deleteCatalogItemMetadataValue), String.format(TASK_COMPLETE_TIMELY, "deleteCatalogItemMetadataValue")); try { - catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); + catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "KEY"); fail("The CatalogItem MetadataValue for KEY should have been deleted"); } catch (VCloudDirectorException vcde) { Error error = vcde.getError(); @@ -256,18 +256,18 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { } private void deleteAllCatalogItemMetadata(ReferenceType catalogItemRef) { - Metadata currentMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); + Metadata currentMetadata = catalogClient.getMetadataClient().getMetadata(catalogItemRef); for (MetadataEntry currentMetadataEntry : currentMetadata.getMetadataEntries()) { - catalogClient.deleteCatalogItemMetadataValue(catalogItemRef, currentMetadataEntry.getKey()); + catalogClient.getMetadataClient().deleteMetadataEntry(catalogItemRef, currentMetadataEntry.getKey()); } - Metadata emptyMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); + Metadata emptyMetadata = catalogClient.getMetadataClient().getMetadata(catalogItemRef); assertTrue(emptyMetadata.getMetadataEntries().isEmpty(), "The catalogItem Metadata should be empty"); } private void resetCatalogItemMetadata(ReferenceType catalogItemRef) { deleteAllCatalogItemMetadata(catalogItemRef); Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "VALUE").build()).build(); - Task mergeCatalogItemMetadata = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata); + Task mergeCatalogItemMetadata = catalogClient.getMetadataClient().mergeMetadata(catalogItemRef, newMetadata); Checks.checkTask(mergeCatalogItemMetadata); 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/MediaClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java index f5700e6fad..3a0be0a75d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java @@ -47,7 +47,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "user", "media" }, singleThreaded = true, testName = "MediaClientExpectTest") +@Test(groups = { "unit", "media" }, singleThreaded = true, testName = "MediaClientExpectTest") public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { @Test @@ -280,7 +280,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes Metadata expected = metadata(); - assertEquals(client.getMediaClient().getMetadata(mediaRef), expected); + assertEquals(client.getMediaClient().getMetadataClient().getMetadata(mediaRef), expected); } @Test @@ -301,7 +301,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes Metadata inputMetadata = metadata(); Task expectedTask = mergeMetadataTask(); - assertEquals(client.getMediaClient().mergeMetadata(mediaRef, inputMetadata), expectedTask); + assertEquals(client.getMediaClient().getMetadataClient().mergeMetadata(mediaRef, inputMetadata), expectedTask); } public void testGetMetadataValue() { @@ -320,7 +320,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes Reference mediaRef = Reference.builder().href(mediaUri).build(); - assertEquals(client.getMediaClient().getMetadataValue(mediaRef, "key"), expected); + assertEquals(client.getMediaClient().getMetadataClient().getMetadataValue(mediaRef, "key"), expected); } @Test @@ -342,7 +342,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes Task expectedTask = setMetadataEntryTask(); - assertEquals(client.getMediaClient().setMetadata(mediaRef, "key", inputMetadataValue), expectedTask); + assertEquals(client.getMediaClient().getMetadataClient().setMetadata(mediaRef, "key", inputMetadataValue), expectedTask); } @Test @@ -361,7 +361,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes Reference mediaRef = Reference.builder().href(mediaUri).build(); Task expectedTask = deleteMetadataEntryTask(); - assertEquals(client.getMediaClient().deleteMetadataEntry(mediaRef, "key"), expectedTask); + assertEquals(client.getMediaClient().getMetadataClient().deleteMetadataEntry(mediaRef, "key"), expectedTask); } @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index e3a636b189..c807aa80c1 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -175,7 +175,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMediaFor(MEDIA, media); assertTrue(media.clone(oldMedia), ""); - mediaClient.setMetadata(media, "key", MetadataValue.builder().value("value").build()); + mediaClient.getMetadataClient().setMetadata(media, "key", MetadataValue.builder().value("value").build()); media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder() .source(Reference.builder().fromEntity(media).build()) @@ -232,7 +232,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /media/{id}/metadata", dependsOnMethods = { "testGetMedia" }, enabled = false) public void testGetMetadata() { - metadata = mediaClient.getMetadata(media); + metadata = mediaClient.getMetadataClient().getMetadata(media); // required for testing assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "metadata.entries")); @@ -249,10 +249,10 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { .entries(inputEntries) .build(); - Task mergeMetadata = mediaClient.mergeMetadata(media, inputMetadata); + Task mergeMetadata = mediaClient.getMetadataClient().mergeMetadata(media, inputMetadata); Checks.checkTask(mergeMetadata); assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(new)")); - metadata = mediaClient.getMetadata(media); + metadata = mediaClient.getMetadataClient().getMetadata(media); Checks.checkMetadataFor(MEDIA, metadata); checkMetadataContainsEntries(metadata, inputEntries); @@ -265,10 +265,10 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { .entries(inputEntries) .build(); - mergeMetadata = mediaClient.mergeMetadata(media, inputMetadata); + mergeMetadata = mediaClient.getMetadataClient().mergeMetadata(media, inputMetadata); Checks.checkTask(mergeMetadata); assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(modify)")); - metadata = mediaClient.getMetadata(media); + metadata = mediaClient.getMetadataClient().getMetadata(media); Checks.checkMetadataFor(MEDIA, metadata); checkMetadataContainsEntries(metadata, inputEntries); @@ -296,7 +296,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /media/{id}/metadata/{key}", dependsOnMethods = { "testMergeMetadata" }, enabled = false) public void testGetMetadataValue() { - metadataValue = mediaClient.getMetadataValue(media, "key"); + metadataValue = mediaClient.getMetadataClient().getMetadataValue(media, "key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); } @@ -306,18 +306,18 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { metadataEntryValue = "newValue"; MetadataValue newValue = MetadataValue.builder().value(metadataEntryValue).build(); - Task setMetadataEntry = mediaClient.setMetadata(media, "key", newValue); + Task setMetadataEntry = mediaClient.getMetadataClient().setMetadata(media, "key", newValue); Checks.checkTask(setMetadataEntry); assertTrue(retryTaskSuccess.apply(setMetadataEntry), String.format(TASK_COMPLETE_TIMELY, "setMetadataEntry")); - metadataValue = mediaClient.getMetadataValue(media, "key"); + metadataValue = mediaClient.getMetadataClient().getMetadataValue(media, "key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); } @Test(testName = "DELETE /media/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }, enabled = false ) public void testDeleteMetadata() { - Task deleteMetadataEntry = mediaClient.deleteMetadataEntry(media, "testKey"); + Task deleteMetadataEntry = mediaClient.getMetadataClient().deleteMetadataEntry(media, "testKey"); Checks.checkTask(deleteMetadataEntry); assertTrue(retryTaskSuccess.apply(deleteMetadataEntry), String.format(TASK_COMPLETE_TIMELY, "deleteMetadataEntry")); @@ -329,7 +329,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { .build(); try { - metadataValue = mediaClient.getMetadataValue(media, "testKey"); + metadataValue = mediaClient.getMetadataClient().getMetadataValue(media, "testKey"); fail("Should give HTTP 403 error"); } catch (VCloudDirectorException vde) { assertEquals(vde.getError(), expected); @@ -344,7 +344,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { "metadataEntry", metadataValue.toString())); } - metadataValue = mediaClient.getMetadataValue(media, "key"); + metadataValue = mediaClient.getMetadataClient().getMetadataValue(media, "key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); media = mediaClient.getMedia(media); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java index f17857dc24..8f99fdd390 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java @@ -164,7 +164,7 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT Reference networkRef = Reference.builder().href(networkUri).build(); - assertEquals(client.getNetworkClient().getMetadata(networkRef), expected); + assertEquals(client.getNetworkClient().getMetadataClient().getMetadata(networkRef), expected); } @Test(enabled=false) // No metadata in exemplar xml... @@ -181,7 +181,7 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT Reference networkRef = Reference.builder().href(networkUri).build(); - assertEquals(client.getNetworkClient().getMetadataValue(networkRef, "KEY"), expected); + assertEquals(client.getNetworkClient().getMetadataClient().getMetadataValue(networkRef, "KEY"), expected); } public static OrgNetwork orgNetwork() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java index 12a7259850..bbed422499 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java @@ -100,7 +100,7 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /network/{id}/metadata") public void testGetMetadata() { - Metadata metadata = networkClient.getMetadata(networkRef); + Metadata metadata = networkClient.getMetadataClient().getMetadata(networkRef); // required for testing assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), String.format(OBJ_FIELD_REQ_LIVE, NETWORK, "metadata.entries")); @@ -122,7 +122,7 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /network/{id}/metadata/{key}") public void testGetMetadataValue() { - MetadataValue metadataValue = networkClient.getMetadataValue(networkRef, "key"); + MetadataValue metadataValue = networkClient.getMetadataClient().getMetadataValue(networkRef, "key"); // Check parent type checkResourceType(metadataValue); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index bb4773d53b..6489dacb3d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -195,7 +195,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest Reference orgRef = Reference.builder().href(orgUri).build(); - assertEquals(client.getOrgClient().getOrgMetadata(orgRef), expected); + assertEquals(client.getOrgClient().getMetadataClient().getMetadata(orgRef), expected); } @Test @@ -210,7 +210,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest Reference orgRef = Reference.builder().href(orgUri).build(); - assertEquals(client.getOrgClient().getOrgMetadataValue(orgRef, "KEY"), expected); + assertEquals(client.getOrgClient().getMetadataClient().getMetadataValue(orgRef, "KEY"), expected); } public static Org org() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java index e4ccf4c56c..bd03051da0 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java @@ -97,7 +97,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /org/{id}/metadata/", dependsOnMethods = { "testGetOrg" }) public void testGetOrgMetadata() { // Call the method being tested - Metadata metadata = orgClient.getOrgMetadata(orgRef); + Metadata metadata = orgClient.getMetadataClient().getMetadata(orgRef); // NOTE The environment MUST have at one metadata entry for the first organisation configured @@ -110,7 +110,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /org/{id}/metadata/{key}", dependsOnMethods = { "testGetOrgMetadata" }) public void testGetOrgMetadataValue() { // Call the method being tested - MetadataValue value = orgClient.getOrgMetadataValue(orgRef, "KEY"); + MetadataValue value = orgClient.getMetadataClient().getMetadataValue(orgRef, "KEY"); // NOTE The environment MUST have configured the metadata entry as '{ key="KEY", value="VALUE" )' diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index bebbd34014..2fd8602681 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -349,7 +349,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest Metadata expected = metadata(); - assertEquals(client.getMediaClient().getMetadata(mediaRef), expected); + assertEquals(client.getVdcClient().getMetadataClient().getMetadata(mediaRef), expected); } @Test(enabled = false) @@ -369,7 +369,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest Reference mediaRef = Reference.builder().href(vdcUri).build(); - assertEquals(client.getVdcClient().getMetadataValue(mediaRef, "key"), expected); + assertEquals(client.getVdcClient().getMetadataClient().getMetadataValue(mediaRef, "key"), expected); } public static Vdc getVdc() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index c7a67f29ca..a52922b44f 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -243,7 +243,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /network/{id}/metadata", enabled = false) public void testGetMetadata() { - Metadata metadata = vdcClient.getMetadata(vdcRef); + Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcRef); // required for testing assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), String.format(OBJ_FIELD_REQ_LIVE, VDC, "metadata.entries")); @@ -253,7 +253,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /network/{id}/metadata/{key}", enabled = false) public void testGetMetadataValue() { - MetadataValue metadataValue = vdcClient.getMetadataValue(vdcRef, "key"); + MetadataValue metadataValue = vdcClient.getMetadataClient().getMetadataValue(vdcRef, "key"); Checks.checkMetadataValueFor(VDC, metadataValue); } From fb625864ac02954514ffe12c229f4c0a03525397 Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 5 Mar 2012 11:05:28 +0000 Subject: [PATCH 31/34] fix accept type --- .../vcloud/director/v1_5/features/CatalogClientExpectTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java index e0e1cbe1ee..83213fa32f 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java @@ -403,7 +403,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT .method("DELETE") .endpoint(URI.create(endpoint + "/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df/metadata/KEY")) .headers(ImmutableMultimap. builder() - .put("Accept", "*/*") + .put("Accept", "application/vnd.vmware.vcloud.task+xml") .put("x-vcloud-authorization", token) .build()) .build(); From 8891dcf280b13fc9b386b32500ecb2289757cb60 Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 5 Mar 2012 12:19:33 +0000 Subject: [PATCH 32/34] fix headers using primer approach --- .../features/NetworkClientExpectTest.java | 9 +++++++-- .../v1_5/features/OrgClientExpectTest.java | 20 ++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java index 8f99fdd390..fecbe925b4 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java @@ -148,8 +148,13 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT URI networkUri = URI.create(endpoint + "/network/55a677cf-ab3f-48ae-b880-fab90421980c"); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - getStandardRequest("GET", "/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata"), - getStandardPayloadResponse("/network/metadata.xml", VCloudDirectorMediaType.METADATA)); + new VcloudHttpRequestPrimer() + .apiCommand("GET", "/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata") + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/network/metadata.xml", VCloudDirectorMediaType.METADATA) + .httpResponseBuilder().build()); Metadata expected = Metadata.builder() .type("application/vnd.vmware.vcloud.metadata+xml") diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index 6489dacb3d..67242bafc2 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -179,8 +179,13 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest URI orgUri = URI.create(endpoint + "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - getStandardRequest("GET", "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"), - getStandardPayloadResponse("/org/orgMetadata.xml", VCloudDirectorMediaType.METADATA)); + new VcloudHttpRequestPrimer() + .apiCommand("GET", "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata") + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/org/orgMetadata.xml", VCloudDirectorMediaType.METADATA) + .httpResponseBuilder().build()); Metadata expected = Metadata.builder() .type("application/vnd.vmware.vcloud.metadata+xml") @@ -202,9 +207,14 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest public void testGetOrgMetadataValue() { URI orgUri = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"); - VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - getStandardRequest("GET", "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY"), - getStandardPayloadResponse("/org/orgMetadataValue.xml", VCloudDirectorMediaType.METADATA_VALUE)); + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("GET", "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY") + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/org/orgMetadataValue.xml", VCloudDirectorMediaType.METADATA_VALUE) + .httpResponseBuilder().build()); MetadataValue expected = metadataValue(); From d7882bc1308640f3fffd8ce11db279cea591fc9c Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 5 Mar 2012 12:20:15 +0000 Subject: [PATCH 33/34] move annotation to classes --- .../vcloud/director/v1_5/features/MetadataAsyncClient.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java index 1998a8bd2e..9164c40164 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java @@ -49,8 +49,8 @@ import com.google.common.util.concurrent.ListenableFuture; * @see NetworkClient * @author danikov */ -@RequestFilters(AddVCloudAuthorizationToRequest.class) public interface MetadataAsyncClient { + @RequestFilters(AddVCloudAuthorizationToRequest.class) public static interface Readable extends MetadataAsyncClient { /** * @see MetadataClient.Readable#getMetadata(URISupplier) @@ -74,6 +74,7 @@ public interface MetadataAsyncClient { @PathParam("key") String key); } + @RequestFilters(AddVCloudAuthorizationToRequest.class) public static interface Writable extends Readable { /** * @see MetadataClient.Writable#mergeMetadata(URISupplier, Metadata)) From d069dce1e5cc18de64a41eda8938e0e5aca82fd5 Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 5 Mar 2012 15:15:50 +0000 Subject: [PATCH 34/34] add error strings to new tests --- .../v1_5/VCloudDirectorLiveTestConstants.java | 2 ++ .../v1_5/features/MediaClientLiveTest.java | 23 +++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java index 5420c9b670..aa83961055 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java @@ -70,5 +70,7 @@ public class VCloudDirectorLiveTestConstants { public static final String CONDITION_FMT = "ERR-121: The %s field must be %s: '%s'"; public static final String CORRECT_VALUE_OBJECT_FMT = "ERR-122: The %s field of the %s must be '%s': '%s'"; + + public static final String OBJ_FIELD_CLONE = "ERR-123: %s %s must be a clone of \"%s\" (%s)"; } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index c807aa80c1..84ace497cf 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -108,17 +108,20 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMediaFor(MEDIA, media); - assertNotNull(media.getFiles(), ""); - assertTrue(media.getFiles().getFiles().size() == 1, ""); + assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files")); + assertTrue(media.getFiles().getFiles().size() == 1, String.format(OBJ_FIELD_EQ, MEDIA, "files.size()", "1", + media.getFiles().getFiles().size())); File uploadFile = Iterables.getFirst(media.getFiles().getFiles(), null); - assertNotNull(uploadFile, ""); - assertTrue(equal(uploadFile.getSize(), sourceMedia.getSize()), ""); + assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first")); + assertTrue(equal(uploadFile.getSize(), sourceMedia.getSize()), String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()", + sourceMedia.getSize(), uploadFile.getSize())); Set links = uploadFile.getLinks(); - assertNotNull(links, ""); - assertTrue(links.size() == 1, ""); + assertNotNull(links, String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links")); + assertTrue(links.size() == 1, String.format(OBJ_FIELD_EQ, MEDIA, "uploadfile.links.size()", "1", + links.size())); Link uploadLink = Iterables.getFirst(links, null); - assertTrue(equal(uploadLink.getRel(), Link.Rel.UPLOAD_DEFAULT), ""); + assertTrue(equal(uploadLink.getRel(), Link.Rel.UPLOAD_DEFAULT), String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first")); fail(); //TODO upload file and assert it succeeds context.getApi().getUploadClient().uploadFile(uploadLink, sourceFile); @@ -173,7 +176,8 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } Checks.checkMediaFor(MEDIA, media); - assertTrue(media.clone(oldMedia), ""); + assertTrue(media.clone(oldMedia), String.format(OBJ_FIELD_CLONE, MEDIA, "copied media", + media.toString(), oldMedia.toString())); mediaClient.getMetadataClient().setMetadata(media, "key", MetadataValue.builder().value("value").build()); @@ -196,7 +200,8 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } Checks.checkMediaFor(MEDIA, media); - assertTrue(media.clone(oldMedia), ""); + assertTrue(media.clone(oldMedia), String.format(OBJ_FIELD_CLONE, MEDIA, "moved media", + media.toString(), oldMedia.toString())); } @Test(testName = "PUT /media/{id}",