From d4422e1ff5abceec6b225a2ab998a3d8c825bcf1 Mon Sep 17 00:00:00 2001 From: adriancole Date: Mon, 25 Mar 2013 09:17:24 -0700 Subject: [PATCH 1/2] corrected map binder for terremark so that it is compatible w/ jclouds 1.6 --- .../TerremarkVCloudAsyncClient.java | 8 +++---- .../OrgNameAndTasksListNameToEndpoint.java | 24 ++++++++++++------- 2 files changed, 19 insertions(+), 13 deletions(-) rename common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/{functions => binders}/OrgNameAndTasksListNameToEndpoint.java (72%) diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudAsyncClient.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudAsyncClient.java index 305d5031a2..b9ecf9b0cc 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudAsyncClient.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudAsyncClient.java @@ -65,6 +65,7 @@ import org.jclouds.trmk.vcloud_0_8.binders.BindInstantiateVAppTemplateParamsToXm import org.jclouds.trmk.vcloud_0_8.binders.BindNodeConfigurationToXmlPayload; import org.jclouds.trmk.vcloud_0_8.binders.BindVAppConfigurationToXmlPayload; import org.jclouds.trmk.vcloud_0_8.binders.OrgNameAndCatalogNameToEndpoint; +import org.jclouds.trmk.vcloud_0_8.binders.OrgNameAndTasksListNameToEndpoint; import org.jclouds.trmk.vcloud_0_8.binders.OrgNameAndVDCNameToEndpoint; import org.jclouds.trmk.vcloud_0_8.binders.OrgNameCatalogNameItemNameToEndpoint; import org.jclouds.trmk.vcloud_0_8.binders.OrgNameCatalogNameVAppTemplateNameToEndpoint; @@ -86,7 +87,6 @@ import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate; import org.jclouds.trmk.vcloud_0_8.domain.VDC; import org.jclouds.trmk.vcloud_0_8.endpoints.Org; import org.jclouds.trmk.vcloud_0_8.filters.SetVCloudTokenCookie; -import org.jclouds.trmk.vcloud_0_8.functions.OrgNameAndTasksListNameToEndpoint; import org.jclouds.trmk.vcloud_0_8.functions.OrgNameToEndpoint; import org.jclouds.trmk.vcloud_0_8.functions.ParseTaskFromLocationHeader; import org.jclouds.trmk.vcloud_0_8.functions.VDCURIToInternetServicesEndpoint; @@ -162,9 +162,9 @@ public interface TerremarkVCloudAsyncClient { @XMLResponseParser(TasksListHandler.class) @Fallback(NullOnNotFoundOr404.class) @Consumes(TASKSLIST_XML) - ListenableFuture findTasksListInOrgNamed( - @Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String tasksListName); + @MapBinder(OrgNameAndTasksListNameToEndpoint.class) + ListenableFuture findTasksListInOrgNamed(@Nullable @PayloadParam("orgName") String orgName, + @Nullable @PayloadParam("tasksListName") String tasksListName); /** * @see TerremarkVCloudClient#getTask diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndTasksListNameToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/OrgNameAndTasksListNameToEndpoint.java similarity index 72% rename from common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndTasksListNameToEndpoint.java rename to common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/OrgNameAndTasksListNameToEndpoint.java index c0d91da433..6b9c6ab7d3 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndTasksListNameToEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/OrgNameAndTasksListNameToEndpoint.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.trmk.vcloud_0_8.functions; +package org.jclouds.trmk.vcloud_0_8.binders; import static com.google.common.base.Preconditions.checkNotNull; @@ -27,11 +27,12 @@ import java.util.NoSuchElementException; import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.MapBinder; import org.jclouds.trmk.vcloud_0_8.domain.Org; import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType; import org.jclouds.trmk.vcloud_0_8.endpoints.TasksList; -import com.google.common.base.Function; import com.google.common.base.Supplier; import com.google.common.collect.Iterables; @@ -40,7 +41,7 @@ import com.google.common.collect.Iterables; * @author Adrian Cole */ @Singleton -public class OrgNameAndTasksListNameToEndpoint implements Function { +public class OrgNameAndTasksListNameToEndpoint implements MapBinder { private final Supplier> orgMap; private final Supplier defaultOrg; private final Supplier defaultTasksList; @@ -54,21 +55,26 @@ public class OrgNameAndTasksListNameToEndpoint implements Function } @SuppressWarnings("unchecked") - public URI apply(Object from) { - Iterable orgTasksList = (Iterable) checkNotNull(from, "args"); - Object org = Iterables.get(orgTasksList, 0); - Object tasksList = Iterables.get(orgTasksList, 1); + @Override + public R bindToRequest(R request, Map postParams) { + Object org = postParams.get("orgName"); + Object tasksList = postParams.get("tasksListName"); if (org == null && tasksList == null) - return defaultTasksList.get().getHref(); + return (R) request.toBuilder().endpoint(defaultTasksList.get().getHref()).build(); else if (org == null) org = defaultOrg.get().getName(); try { Map tasksLists = checkNotNull(orgMap.get().get(org)).getTasksLists(); - return tasksList == null ? Iterables.getLast(tasksLists.values()).getHref() : tasksLists.get(tasksList).getHref(); + URI endpoint = tasksList == null ? Iterables.getLast(tasksLists.values()).getHref() : tasksLists.get(tasksList).getHref(); + return (R) request.toBuilder().endpoint(endpoint).build(); } catch (NullPointerException e) { throw new NoSuchElementException(org + "/" + tasksList + " not found in " + orgMap.get()); } } + @Override + public R bindToRequest(R request, Object input) { + throw new IllegalStateException(getClass() + " needs parameters"); + } } From 29d5eb37db2363d978a7296b209335e9a6b87758 Mon Sep 17 00:00:00 2001 From: adriancole Date: Mon, 25 Mar 2013 10:45:53 -0700 Subject: [PATCH 2/2] added nullable to nullable parameter --- .../compute/functions/ImageForVCloudExpressVAppTemplate.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/ImageForVCloudExpressVAppTemplate.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/ImageForVCloudExpressVAppTemplate.java index dfd68d660d..8ff17b8b16 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/ImageForVCloudExpressVAppTemplate.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/ImageForVCloudExpressVAppTemplate.java @@ -28,6 +28,7 @@ import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType; import org.jclouds.trmk.vcloud_0_8.domain.Status; import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate; @@ -60,7 +61,7 @@ public class ImageForVCloudExpressVAppTemplate implements Function