diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java index 114e13590e..9056ce7704 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java @@ -28,8 +28,6 @@ import static org.jclouds.vcloud.VCloudMediaType.VAPPTEMPLATE_XML; import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML; import static org.jclouds.vcloud.VCloudMediaType.VDC_XML; -import java.net.URI; - import javax.annotation.Nullable; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -64,6 +62,8 @@ import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.functions.OrgNameAndCatalogNameToEndpoint; +import org.jclouds.vcloud.functions.OrgNameAndTasksListNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameToEndpoint; import org.jclouds.vcloud.functions.VAppIdToUri; @@ -127,6 +127,7 @@ public interface VCloudAsyncClient { /** * @see VCloudClient#getDefaultCatalog */ + @Deprecated @GET @Endpoint(org.jclouds.vcloud.endpoints.Catalog.class) @Consumes(CATALOG_XML) @@ -136,6 +137,7 @@ public interface VCloudAsyncClient { /** * @see VCloudClient#getCatalog */ + @Deprecated @GET @Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class) @Path("/catalog/{catalogId}") @@ -144,6 +146,17 @@ public interface VCloudAsyncClient { @Consumes(CATALOG_XML) ListenableFuture getCatalog(@PathParam("catalogId") String catalogId); + /** + * @see VCloudClient#getCatalogInOrg + */ + @GET + @XMLResponseParser(CatalogHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(CATALOG_XML) + ListenableFuture getCatalogInOrg( + @Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName); + /** * @see VCloudClient#getVAppTemplate */ @@ -180,6 +193,7 @@ public interface VCloudAsyncClient { /** * @see VCloudClient#getDefaultVDC */ + @Deprecated @GET @Endpoint(org.jclouds.vcloud.endpoints.VDC.class) @XMLResponseParser(VDCHandler.class) @@ -209,18 +223,10 @@ public interface VCloudAsyncClient { @Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName, @Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName); - /** - * @see VCloudClient#getVDC(URI) - */ - @GET - @XMLResponseParser(VDCHandler.class) - @Consumes(VDC_XML) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVDC(@EndpointParam URI vDCId); - /** * @see VCloudClient#getTasksList */ + @Deprecated @GET @Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class) @Path("/tasksList/{tasksListId}") @@ -229,9 +235,21 @@ public interface VCloudAsyncClient { @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture getTasksList(@PathParam("tasksListId") String tasksListId); + /** + * @see VCloudClient#getTasksListInOrg + */ + @GET + @Consumes(TASKSLIST_XML) + @XMLResponseParser(TasksListHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getTasksListInOrg( + @Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String tasksListName); + /** * @see VCloudClient#getDefaultTasksList */ + @Deprecated @GET @Endpoint(org.jclouds.vcloud.endpoints.TasksList.class) @Consumes(TASKSLIST_XML) diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java index 1c4606ca7f..46eb01ce1a 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java @@ -18,7 +18,6 @@ */ package org.jclouds.vcloud; -import java.net.URI; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; @@ -51,7 +50,7 @@ public interface VCloudClient { Organization getDefaultOrganization(); /** - * Please use #getOrganizationByName + * Please use #getOrganizationNamed */ @Deprecated Organization getOrganization(String orgId); @@ -65,10 +64,20 @@ public interface VCloudClient { */ Organization getOrganizationNamed(String name); + /** + * Please use #getCatalogInOrg(null, null) + */ + @Deprecated Catalog getDefaultCatalog(); + /** + * Please use #getCatalogInOrg + */ + @Deprecated Catalog getCatalog(String catalogId); + Catalog getCatalogInOrg(String orgName, String catalogName); + CatalogItem getCatalogItem(String catalogItemId); VAppTemplate getVAppTemplate(String vAppTemplateId); @@ -76,19 +85,31 @@ public interface VCloudClient { Network getNetwork(String networkId); /** - * please use {@link #getVDC(URI)} + * please use {@link #getVDCInOrg} */ @Deprecated VDC getVDC(String vDCId); VDC getVDCInOrg(String orgName, String vdcName); - VDC getVDC(URI vdc); - + /** + * Please use #getVDCInOrg(null, null) + */ + @Deprecated VDC getDefaultVDC(); + /** + * Please use #getTasksListInOrg + */ + @Deprecated TasksList getTasksList(String tasksListId); + TasksList getTasksListInOrg(String orgName, String tasksListName); + + /** + * Please use #getTasksListInOrg(null, null) + */ + @Deprecated TasksList getDefaultTasksList(); Task deployVApp(String vAppId); diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/providers/OrgAndVDCToLocationProvider.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/providers/OrgAndVDCToLocationProvider.java index 54bd414cdb..68b2eaa4d5 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/providers/OrgAndVDCToLocationProvider.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/providers/OrgAndVDCToLocationProvider.java @@ -30,8 +30,8 @@ import org.jclouds.domain.LocationScope; import org.jclouds.domain.internal.LocationImpl; import org.jclouds.vcloud.compute.domain.VCloudLocation; import org.jclouds.vcloud.domain.NamedResource; +import org.jclouds.vcloud.domain.Organization; import org.jclouds.vcloud.endpoints.Org; -import org.jclouds.vcloud.endpoints.VDC; import com.google.common.base.Supplier; import com.google.common.collect.Sets; @@ -43,12 +43,12 @@ import com.google.common.collect.Sets; public class OrgAndVDCToLocationProvider implements Provider> { private final String providerName; private final Supplier> orgNameToResource; - private final Supplier>> orgNameToVDCResource; + private final Supplier> orgNameToVDCResource; @Inject OrgAndVDCToLocationProvider(@org.jclouds.rest.annotations.Provider String providerName, @Org Supplier> orgNameToResource, - @VDC Supplier>> orgNameToVDCResource) { + Supplier> orgNameToVDCResource) { this.providerName = providerName; this.orgNameToResource = orgNameToResource; this.orgNameToVDCResource = orgNameToVDCResource; @@ -61,7 +61,7 @@ public class OrgAndVDCToLocationProvider implements Provider extends - RestClientModule { + RestClientModule { public BaseVCloudRestClientModule(Class syncClientType, Class asyncClientType) { super(syncClientType, asyncClientType); @@ -110,7 +111,7 @@ public abstract class BaseVCloudRestClientModule successTester(TaskSuccess success, - @Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) { + @Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) { return new RetryablePredicate(success, completed); } @@ -138,20 +139,20 @@ public abstract class BaseVCloudRestClientModule> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final @VDC Supplier>> orgToVDCSupplier) { + final Supplier> orgToVDCSupplier) { return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, seconds, - new Supplier>() { - @Override - public Map get() { - Map returnVal = Maps.newLinkedHashMap(); - for (Entry> orgr : orgToVDCSupplier.get().entrySet()) { - for (String vdc : orgr.getValue().keySet()) { - returnVal.put(vdc, orgr.getKey()); - } + new Supplier>() { + @Override + public Map get() { + Map returnVal = Maps.newLinkedHashMap(); + for (Entry orgr : orgToVDCSupplier.get().entrySet()) { + for (String vdc : orgr.getValue().getVDCs().keySet()) { + returnVal.put(vdc, orgr.getKey()); } - return returnVal; } - }); + return returnVal; + } + }); } @@ -176,55 +177,54 @@ public abstract class BaseVCloudRestClientModule provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final VCloudLoginAsyncClient login) { + final VCloudLoginAsyncClient login) { return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier(authException, seconds, - new Supplier() { + new Supplier() { - @Override - public VCloudSession get() { - try { - return login.login().get(10, TimeUnit.SECONDS); - } catch (Exception e) { - Throwables.propagate(e); - assert false : e; - return null; - } + @Override + public VCloudSession get() { + try { + return login.login().get(10, TimeUnit.SECONDS); + } catch (Exception e) { + Throwables.propagate(e); + assert false : e; + return null; } + } - }); + }); } @Provides @Singleton - @VDC - protected Supplier>> provideOrgToVDCCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgNameToVDCSupplier supplier) { - return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier>>( - authException, seconds, new Supplier>>() { - @Override - public Map> get() { - return supplier.get(); - } + protected Supplier> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, + final OrganizationMapSupplier supplier) { + return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, + seconds, new Supplier>() { + @Override + public Map get() { + return supplier.get(); + } - }); + }); } @Singleton - public static class OrgNameToVDCSupplier implements Supplier>> { + public static class OrganizationMapSupplier implements Supplier> { protected final Supplier sessionSupplier; private final VCloudClient client; @Inject - protected OrgNameToVDCSupplier(Supplier sessionSupplier, VCloudClient client) { + protected OrganizationMapSupplier(Supplier sessionSupplier, VCloudClient client) { this.sessionSupplier = sessionSupplier; this.client = client; } @Override - public Map> get() { - Map> returnVal = Maps.newLinkedHashMap(); + public Map get() { + Map returnVal = Maps.newLinkedHashMap(); for (String orgName : sessionSupplier.get().getOrgs().keySet()) { - returnVal.put(orgName, client.getOrganizationNamed(orgName).getVDCs()); + returnVal.put(orgName, client.getOrganizationNamed(orgName)); } return returnVal; } @@ -235,8 +235,7 @@ public abstract class BaseVCloudRestClientModule versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS); checkState(versions.size() > 0, "No versions present"); checkState(versions.containsKey(version), "version " + version + " not present in: " + versions); @@ -296,7 +295,7 @@ public abstract class BaseVCloudRestClientModule + * + * ==================================================================== + * Licensed 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.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Map; +import java.util.NoSuchElementException; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.vcloud.domain.NamedResource; +import org.jclouds.vcloud.domain.Organization; +import org.jclouds.vcloud.endpoints.Catalog; +import org.jclouds.vcloud.endpoints.Org; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.collect.Iterables; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class OrgNameAndCatalogNameToEndpoint implements Function { + private final Supplier> orgMap; + private final String defaultOrg; + private final URI defaultUri; + + @Inject + public OrgNameAndCatalogNameToEndpoint(Supplier> orgMap, @Org String defaultOrg, + @Catalog URI defaultUri) { + this.orgMap = orgMap; + this.defaultOrg = defaultOrg; + this.defaultUri = defaultUri; + } + + @SuppressWarnings("unchecked") + public URI apply(Object from) { + Iterable orgCatalog = (Iterable) checkNotNull(from, "args"); + Object org = Iterables.get(orgCatalog, 0); + Object catalog = Iterables.get(orgCatalog, 1); + if (org == null && catalog == null) + return defaultUri; + else if (org == null) + org = defaultOrg; + + try { + Map catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs(); + + return catalog == null ? Iterables.getLast(catalogs.values()).getLocation() : catalogs.get(catalog) + .getLocation(); + } catch (NullPointerException e) { + throw new NoSuchElementException(org + "/" + catalog + " not found in " + orgMap.get()); + } + } + +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/functions/OrgNameAndTasksListNameToEndpoint.java b/vcloud/core/src/main/java/org/jclouds/vcloud/functions/OrgNameAndTasksListNameToEndpoint.java new file mode 100644 index 0000000000..7ca87075a2 --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/functions/OrgNameAndTasksListNameToEndpoint.java @@ -0,0 +1,76 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Map; +import java.util.NoSuchElementException; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.vcloud.domain.NamedResource; +import org.jclouds.vcloud.domain.Organization; +import org.jclouds.vcloud.endpoints.Org; +import org.jclouds.vcloud.endpoints.TasksList; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.collect.Iterables; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class OrgNameAndTasksListNameToEndpoint implements Function { + private final Supplier> orgMap; + private final String defaultOrg; + private final URI defaultUri; + + @Inject + public OrgNameAndTasksListNameToEndpoint(Supplier> orgMap, @Org String defaultOrg, + @TasksList URI defaultUri) { + this.orgMap = orgMap; + this.defaultOrg = defaultOrg; + this.defaultUri = defaultUri; + } + + @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); + if (org == null && tasksList == null) + return defaultUri; + else if (org == null) + org = defaultOrg; + + try { + Map tasksLists = checkNotNull(orgMap.get().get(org)).getTasksLists(); + return tasksList == null ? Iterables.getLast(tasksLists.values()).getLocation() : tasksLists.get(tasksList) + .getLocation(); + } catch (NullPointerException e) { + throw new NoSuchElementException(org + "/" + tasksList + " not found in " + orgMap.get()); + } + } + +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/functions/OrgNameAndVDCNameToEndpoint.java b/vcloud/core/src/main/java/org/jclouds/vcloud/functions/OrgNameAndVDCNameToEndpoint.java index 973277c861..4f34aaa3fa 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/functions/OrgNameAndVDCNameToEndpoint.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/functions/OrgNameAndVDCNameToEndpoint.java @@ -28,6 +28,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.vcloud.domain.NamedResource; +import org.jclouds.vcloud.domain.Organization; import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.endpoints.VDC; @@ -41,13 +42,13 @@ import com.google.common.collect.Iterables; */ @Singleton public class OrgNameAndVDCNameToEndpoint implements Function { - private final Supplier>> orgNameToVDCEndpoint; + private final Supplier> orgNameToVDCEndpoint; private final String defaultOrg; private final URI defaultUri; @Inject - public OrgNameAndVDCNameToEndpoint(@VDC Supplier>> orgNameToVDCEndpoint, - @Org String defaultOrg, @VDC URI defaultUri) { + public OrgNameAndVDCNameToEndpoint(Supplier> orgNameToVDCEndpoint, @Org String defaultOrg, + @VDC URI defaultUri) { this.orgNameToVDCEndpoint = orgNameToVDCEndpoint; this.defaultOrg = defaultOrg; this.defaultUri = defaultUri; @@ -64,7 +65,7 @@ public class OrgNameAndVDCNameToEndpoint implements Function { org = defaultOrg; try { - Map vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)); + Map vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs(); return vdc == null ? Iterables.getLast(vdcs.values()).getLocation() : vdcs.get(vdc).getLocation(); } catch (NullPointerException e) { diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java index 709b43cac7..bd24030f5f 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java @@ -52,6 +52,7 @@ import org.jclouds.vcloud.config.VCloudRestClientModule; import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.Organization; import org.jclouds.vcloud.domain.internal.NamedResourceImpl; +import org.jclouds.vcloud.domain.internal.OrganizationImpl; import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.internal.VCloudLoginAsyncClient; @@ -331,6 +332,21 @@ public class VCloudAsyncClientTest extends RestClientTest { checkFilters(request); } + public void testCatalogInOrg() throws SecurityException, NoSuchMethodException, IOException { + Method method = VCloudAsyncClient.class.getMethod("getCatalogInOrg", String.class, String.class); + HttpRequest request = processor.createRequest(method, "org", "catalog"); + + assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalog/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, CatalogHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getNetwork", String.class); HttpRequest request = processor.createRequest(method, "2"); @@ -463,22 +479,6 @@ public class VCloudAsyncClientTest extends RestClientTest { checkFilters(request); } - public void testGetVDCURI() throws SecurityException, NoSuchMethodException, IOException { - Method method = VCloudAsyncClient.class.getMethod("getVDC", URI.class); - HttpRequest request = processor.createRequest(method, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1")); - - assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VDCHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - public void testGetDefaultTasksList() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getDefaultTasksList"); HttpRequest request = processor.createRequest(method); @@ -509,6 +509,21 @@ public class VCloudAsyncClientTest extends RestClientTest { checkFilters(request); } + public void testGetTasksListInOrg() throws SecurityException, NoSuchMethodException, IOException { + Method method = VCloudAsyncClient.class.getMethod("getTasksListInOrg", String.class, String.class); + HttpRequest request = processor.createRequest(method, "org", "tasksList"); + + assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/tasksList/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TasksListHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("deployVApp", String.class); HttpRequest request = processor.createRequest(method, 1); @@ -715,7 +730,7 @@ public class VCloudAsyncClientTest extends RestClientTest { @Override protected void configure() { super.configure(); - bind(OrgNameToVDCSupplier.class).to(TestOrgNameToVDCSupplier.class); + bind(OrganizationMapSupplier.class).to(TestOrganizationMapSupplier.class); } @Override @@ -781,17 +796,23 @@ public class VCloudAsyncClientTest extends RestClientTest { } @Singleton - public static class TestOrgNameToVDCSupplier extends OrgNameToVDCSupplier { + public static class TestOrganizationMapSupplier extends OrganizationMapSupplier { @Inject - protected TestOrgNameToVDCSupplier() { + protected TestOrganizationMapSupplier() { super(null, null); } @Override - public Map> get() { - return ImmutableMap.> of("org", ImmutableMap. of( - "vdc", new NamedResourceImpl("1", "vdc", VCloudMediaType.VDC_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1")))); + public Map get() { + return ImmutableMap. of("org", new OrganizationImpl("1", "org", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), ImmutableMap. of( + "catalog", new NamedResourceImpl("1", "catalog", VCloudMediaType.CATALOG_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap + . of("vdc", new NamedResourceImpl("1", "vdc", VCloudMediaType.VDC_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap + . of("tasksList", new NamedResourceImpl("1", "tasksList", + VCloudMediaType.TASKSLIST_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1"))))); } } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java index 99a7249882..c485e5fc89 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java @@ -55,7 +55,7 @@ public class VCloudClientLiveTest { @Test public void testOrganization() throws Exception { - Organization response = connection.getDefaultOrganization(); + Organization response = connection.getOrganizationNamed(null); assertNotNull(response); assertNotNull(response.getName()); assert response.getCatalogs().size() >= 1; @@ -66,17 +66,17 @@ public class VCloudClientLiveTest { @Test public void testCatalog() throws Exception { - Catalog response = connection.getDefaultCatalog(); + Catalog response = connection.getCatalogInOrg(null, null); assertNotNull(response); assertNotNull(response.getId()); assertNotNull(response.getName()); assertNotNull(response.getLocation()); - assertEquals(connection.getCatalog(response.getId()), response); + assertEquals(connection.getCatalogInOrg(null, response.getName()), response); } @Test public void testGetNetwork() throws Exception { - VDC response = connection.getDefaultVDC(); + VDC response = connection.getVDCInOrg(null, null); for (NamedResource resource : response.getAvailableNetworks().values()) { if (resource.getType().equals(VCloudMediaType.NETWORK_XML)) { Network item = connection.getNetwork(resource.getId()); @@ -87,7 +87,7 @@ public class VCloudClientLiveTest { @Test public void testGetCatalogItem() throws Exception { - Catalog response = connection.getDefaultCatalog(); + Catalog response = connection.getCatalogInOrg(null, null); for (NamedResource resource : response.values()) { if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { CatalogItem item = connection.getCatalogItem(resource.getId()); @@ -103,7 +103,7 @@ public class VCloudClientLiveTest { @Test public void testGetVAppTemplate() throws Exception { - Catalog response = connection.getDefaultCatalog(); + Catalog response = connection.getCatalogInOrg(null, null); for (NamedResource resource : response.values()) { if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { CatalogItem item = connection.getCatalogItem(resource.getId()); @@ -116,7 +116,7 @@ public class VCloudClientLiveTest { @Test public void testDefaultVDC() throws Exception { - VDC response = connection.getDefaultVDC(); + VDC response = connection.getVDCInOrg(null, null); assertNotNull(response); assertNotNull(response.getId()); assertNotNull(response.getName()); @@ -128,7 +128,7 @@ public class VCloudClientLiveTest { @Test public void testDefaultTasksList() throws Exception { - org.jclouds.vcloud.domain.TasksList response = connection.getDefaultTasksList(); + org.jclouds.vcloud.domain.TasksList response = connection.getTasksListInOrg(null, null); assertNotNull(response); assertNotNull(response.getId()); assertNotNull(response.getLocation()); @@ -138,7 +138,7 @@ public class VCloudClientLiveTest { @Test public void testGetTask() throws Exception { - org.jclouds.vcloud.domain.TasksList response = connection.getDefaultTasksList(); + org.jclouds.vcloud.domain.TasksList response = connection.getTasksListInOrg(null, null); assertNotNull(response); assertNotNull(response.getLocation()); assertNotNull(response.getTasks()); @@ -150,7 +150,7 @@ public class VCloudClientLiveTest { @Test public void testGetVApp() throws Exception { - VDC response = connection.getDefaultVDC(); + VDC response = connection.getVDCInOrg(null, null); for (NamedResource item : response.getResourceEntities().values()) { if (item.getType().equals(VCloudMediaType.VAPP_XML)) { VApp app = connection.getVApp(item.getId()); diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java index 2c5a848a82..0337357289 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java @@ -109,12 +109,14 @@ import com.google.common.util.concurrent.ListenableFuture; public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient { @GET + @Deprecated @Endpoint(Org.class) @Consumes(ORG_XML) @XMLResponseParser(TerremarkOrgHandler.class) ListenableFuture getDefaultOrganization(); @GET + @Deprecated @Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class) @Path("/org/{orgId}") @XMLResponseParser(TerremarkOrgHandler.class) diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java index ff27577fde..5b3771cb5c 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java @@ -46,9 +46,11 @@ import org.jclouds.vcloud.terremark.options.AddNodeOptions; */ @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) public interface TerremarkVCloudClient extends VCloudClient { + @Deprecated @Override TerremarkOrganization getDefaultOrganization(); + @Deprecated @Override TerremarkOrganization getOrganization(String orgId); diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java index 635f8cb153..05b7b0a151 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java @@ -54,6 +54,7 @@ import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.Organization; import org.jclouds.vcloud.domain.internal.NamedResourceImpl; +import org.jclouds.vcloud.domain.internal.OrganizationImpl; import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.internal.VCloudLoginAsyncClient; @@ -571,7 +572,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest> get() { - return ImmutableMap.> of("org", ImmutableMap. of( - "vdc", new NamedResourceImpl("1", "vdc", VCloudMediaType.VDC_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1")))); + public Map get() { + return ImmutableMap. of("org", new OrganizationImpl("1", "org", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), ImmutableMap. of( + "catalog", new NamedResourceImpl("1", "catalog", VCloudMediaType.CATALOG_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap + . of("vdc", new NamedResourceImpl("1", "vdc", VCloudMediaType.VDC_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap + . of("tasksList", new NamedResourceImpl("1", "tasksList", + VCloudMediaType.TASKSLIST_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1"))))); } }