use URISupplier over references etc.

This commit is contained in:
danikov 2012-02-29 11:27:08 +00:00
parent 0047a0fb69
commit a74a79fe17
19 changed files with 172 additions and 120 deletions

View File

@ -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;
}
};
}
}
}

View File

@ -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<Catalog> getCatalog(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef);
ListenableFuture<Catalog> 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<CatalogItem> addCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef,
ListenableFuture<CatalogItem> 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<Metadata> getCatalogMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef);
ListenableFuture<Metadata> 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<MetadataValue> getCatalogMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef,
ListenableFuture<MetadataValue> getCatalogMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef,
@PathParam("key") String key);
/**
@ -102,7 +102,7 @@ public interface CatalogAsyncClient {
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<CatalogItem> getCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef);
ListenableFuture<CatalogItem> 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<CatalogItem> updateCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
ListenableFuture<CatalogItem> 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<Void> deleteCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef);
ListenableFuture<Void> 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<Metadata> getCatalogItemMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef);
ListenableFuture<Metadata> 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<Task> mergeCatalogItemMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
ListenableFuture<Task> 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<MetadataValue> getCatalogItemMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
ListenableFuture<MetadataValue> 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<Task> setCatalogItemMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
ListenableFuture<Task> 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<Task> deleteCatalogItemMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
ListenableFuture<Task> deleteCatalogItemMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef,
@PathParam("key") String key);
}

View File

@ -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);
}

View File

@ -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<Media> getMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef);
ListenableFuture<Media> 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<Task> updateMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef,
ListenableFuture<Task> 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<Task> deleteMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef);
ListenableFuture<Task> deleteMedia(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef);
/**
* @see MediaClient#getOwner(Reference)
* @see MediaClient#getOwner(URISupplier)
*/
@GET
@Path("/owner")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Owner> getOwner(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef);
ListenableFuture<Owner> getOwner(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef);
/**
* @see MediaClient#getMetadata(Reference))
* @see MediaClient#getMetadata(URISupplier))
*/
@GET
@Path("/metadata")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Metadata> getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef);
ListenableFuture<Metadata> 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<Task> mergeMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef,
ListenableFuture<Task> 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<MetadataValue> getMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef,
ListenableFuture<MetadataValue> 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<Task> setMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference metaDataRef,
ListenableFuture<Task> 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<Task> deleteMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) Reference metaDataRef,
ListenableFuture<Task> deleteMetadataEntry(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier metaDataRef,
@PathParam("key") String key);
}

View File

@ -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);
}

View File

@ -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<OrgNetwork> getNetwork(@EndpointParam(parser = ReferenceToEndpoint.class) Reference networkRef);
ListenableFuture<OrgNetwork> getNetwork(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier networkRef);
/**
* @see NeworkClient#getMetadata(Reference)
* @see NeworkClient#getMetadata(URISupplier)
*/
@GET
@Path("/metadata")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Metadata> getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference networkRef);
ListenableFuture<Metadata> 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<MetadataValue> getMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) Reference networkRef ,
ListenableFuture<MetadataValue> getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier networkRef ,
@PathParam("key") String key);
}

View File

@ -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);
}

View File

@ -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<Org> getOrg(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> orgRef);
ListenableFuture<Org> getOrg(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier orgRef);
/**
* @see OrgClient#getMetadata(ReferenceType)
@ -71,7 +72,7 @@ public interface OrgAsyncClient {
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Metadata> getOrgMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> orgRef);
ListenableFuture<Metadata> 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<MetadataValue> getOrgMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> orgRef,
ListenableFuture<MetadataValue> getOrgMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier orgRef,
@PathParam("key") String key);
}

View File

@ -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);
}

View File

@ -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<TasksList> getTaskList(@EndpointParam(parser = OrgReferenceToTaskListEndpoint.class) Reference orgRef);
ListenableFuture<TasksList> getTaskList(@EndpointParam(parser = OrgReferenceToTaskListEndpoint.class) URISupplier orgRef);
/**
* @see TaskClient#getTask(URI)
@ -61,7 +61,7 @@ public interface TaskAsyncClient {
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> getTask(@EndpointParam URI taskUri);
ListenableFuture<Task> getTask(@EndpointParam URISupplier taskRef);
/**
* @see TaskClient#cancelTask(URI)
@ -71,5 +71,5 @@ public interface TaskAsyncClient {
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Void> cancelTask(@EndpointParam URI taskUri);
ListenableFuture<Void> cancelTask(@EndpointParam URISupplier taskRef);
}

View File

@ -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
* </pre>
*/
void cancelTask(URI taskUri);
void cancelTask(URISupplier taskUri);
}

View File

@ -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);
}

View File

@ -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<Object, URI> {
@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)) {

View File

@ -29,6 +29,7 @@ import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
/**
* @author grkvlt@apache.org
*/
@Deprecated
public class ReferenceToEndpoint implements Function<Object, URI> {
@Override

View File

@ -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<Object, URI> {
@Override
public URI apply(Object input) {
Preconditions.checkNotNull(input);
Preconditions.checkArgument(input instanceof URISupplier);
URISupplier provider = (URISupplier) input;
return provider.getURI();
};
}

View File

@ -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<URI> {
public class TaskSuccess implements Predicate<URISupplier> {
private final TaskClient taskClient;
@ -51,10 +50,10 @@ public class TaskSuccess implements Predicate<URI> {
/** @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());

View File

@ -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"));
}
}

View File

@ -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);
}

View File

@ -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);
}
}