From 336c780713bc8cdbf025a17625be5a7063e61d39 Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 13 Feb 2012 16:44:26 +0000 Subject: [PATCH] update client to use references, pathparams, etc. --- .../v1_5/features/MediaAsyncClient.java | 48 ++++++++++--------- .../director/v1_5/features/MediaClient.java | 20 ++++---- 2 files changed, 36 insertions(+), 32 deletions(-) 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 112e5c7f15..df53a62d2b 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 @@ -18,27 +18,28 @@ */ package org.jclouds.vcloud.director.v1_5.features; -import java.net.URI; - 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 org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; 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; import org.jclouds.vcloud.director.v1_5.domain.Owner; +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.filters.AddVCloudAuthorizationToRequest; +import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint; +import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import com.google.common.util.concurrent.ListenableFuture; @@ -50,50 +51,50 @@ import com.google.common.util.concurrent.ListenableFuture; public interface MediaAsyncClient { /** - * @see MediaClient#getMedia() + * @see MediaClient#getMedia(ReferenceType) */ @GET @Consumes @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getMedia(@EndpointParam URI mediaRef); + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture getMedia(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType mediaRef); /** - * @see MediaClient#updateMedia() + * @see MediaClient#updateMedia(ReferenceType, Media)) */ @PUT @Consumes @JAXBResponseParser - ListenableFuture updateMedia(@EndpointParam URI mediaRef, + ListenableFuture updateMedia(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType mediaRef, @PayloadParam("Media") Media media); /** - * @see MediaClient#deleteMedia() + * @see MediaClient#deleteMedia(ReferenceType)) */ @DELETE @Consumes @JAXBResponseParser - ListenableFuture deleteMedia(@EndpointParam URI mediaRef); + ListenableFuture deleteMedia(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType mediaRef); /** - * @see MediaClient#getMedia() + * @see MediaClient#getOwner(ReferenceType) */ @GET - @Path("/owner/") + @Path("/owner") @Consumes @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getOwner(@EndpointParam URI mediaRef); + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture getOwner(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType mediaRef); /** * @see MediaClient#getMetadata() */ @GET - @Path("/metadata/") + @Path("/metadata") @Consumes @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getMetadata(@EndpointParam URI mediaRef); + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType mediaRef); /** * @see MediaClient#updateMetadata() @@ -101,7 +102,7 @@ public interface MediaAsyncClient { @POST @Consumes @JAXBResponseParser - ListenableFuture updateMetadata(@EndpointParam URI mediaRef, + ListenableFuture updateMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType mediaRef, @PayloadParam("Metadata") Metadata metadata); /** @@ -110,8 +111,9 @@ public interface MediaAsyncClient { @GET @Consumes @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getMetadataEntry(@EndpointParam URI metaDataRef); + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture getMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType mediaRef, + @PathParam("key") String key); /** * @see MediaClient#updateMedia() @@ -119,7 +121,8 @@ public interface MediaAsyncClient { @PUT @Consumes @JAXBResponseParser - ListenableFuture updateMetadataEntry(@EndpointParam URI metaDataRef, + ListenableFuture updateMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType metaDataRef, + @PathParam("key") String key, @PayloadParam("MetadataEntry") MetadataEntry metadataEntry); /** @@ -128,6 +131,7 @@ public interface MediaAsyncClient { @DELETE @Consumes @JAXBResponseParser - ListenableFuture deleteMetadataEntry(@EndpointParam URI metaDataRef); + ListenableFuture deleteMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType 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 f666d4244a..7b5511521d 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 @@ -18,7 +18,6 @@ */ package org.jclouds.vcloud.director.v1_5.features; -import java.net.URI; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; @@ -26,6 +25,7 @@ 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; import org.jclouds.vcloud.director.v1_5.domain.Owner; +import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; import org.jclouds.vcloud.director.v1_5.domain.Task; /** @@ -44,7 +44,7 @@ public interface MediaClient { * * @return the media or null if not found */ - Media getMedia(URI mediaRef); + Media getMedia(ReferenceType 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(URI mediaRef, Media media); + Task updateMedia(ReferenceType mediaRef, Media media); /** * Deletes a media. */ - void deleteMedia(URI mediaRef); + void deleteMedia(ReferenceType mediaRef); /** * Retrieves an owner. * * @return the owner or null if not found */ - Owner getOwner(URI mediaRef); + Owner getOwner(ReferenceType mediaRef); /** * Retrieves an list of the media's metadata * * @return a list of metadata */ - Metadata getMetadata(URI mediaRef); + Metadata getMetadata(ReferenceType 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 updateMetadata(URI mediaRef, Metadata metadata); + Task updateMetadata(ReferenceType mediaRef, Metadata metadata); /** * Retrieves a metadata entry * * @return the metadata entry, or null if not found */ - MetadataEntry getMetadataEntry(URI metaDataRef); + MetadataEntry getMetadataEntry(ReferenceType mediaRef, String key); /** * Sets the metadata for the particular key for the media to the value provided @@ -93,12 +93,12 @@ 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 updateMetadataEntry(URI metaDataRef, MetadataEntry metadataEntry); + Task updateMetadataEntry(ReferenceType mediaRef, String key, MetadataEntry metadataEntry); /** * Deletes a metadata entry. */ - void deleteMetadataEntry(URI metaDataRef); + void deleteMetadataEntry(ReferenceType mediaRef, String key); }