Issue 112: added more support and changed classnames to match docs

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2045 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-11-06 16:31:55 +00:00
parent 94ce40015c
commit 1f92756a97
50 changed files with 1424 additions and 428 deletions

View File

@ -47,7 +47,7 @@
<module>rackspace</module> <module>rackspace</module>
<module>mezeo</module> <module>mezeo</module>
<module>nirvanix</module> <module>nirvanix</module>
<module>vcloudx</module> <module>vcloud</module>
<module>atmosonline</module> <module>atmosonline</module>
<module>twitter</module> <module>twitter</module>
</modules> </modules>

View File

@ -28,26 +28,26 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent> <parent>
<groupId>org.jclouds</groupId> <groupId>org.jclouds</groupId>
<artifactId>jclouds-vcloudx-project</artifactId> <artifactId>jclouds-vcloud-project</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.jclouds</groupId> <groupId>org.jclouds</groupId>
<artifactId>jclouds-vcloudx-core</artifactId> <artifactId>jclouds-vcloud-core</artifactId>
<name>jclouds vcloudx Components Core</name> <name>jclouds vcloud Components Core</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<description>jclouds Core components to access vcloudx</description> <description>jclouds Core components to access vcloud</description>
<properties> <properties>
<jclouds.test.user>${jclouds.vcloudx.user}</jclouds.test.user> <jclouds.test.user>${jclouds.vcloud.user}</jclouds.test.user>
<jclouds.test.key>${jclouds.vcloudx.password}</jclouds.test.key> <jclouds.test.key>${jclouds.vcloud.password}</jclouds.test.key>
<jclouds.test.endpoint>${jclouds.vcloudx.endpoint}</jclouds.test.endpoint> <jclouds.test.endpoint>${jclouds.vcloud.endpoint}</jclouds.test.endpoint>
</properties> </properties>
<scm> <scm>
<connection>scm:svn:http://jclouds.googlecode.com/svn/trunk/vcloudx/core</connection> <connection>scm:svn:http://jclouds.googlecode.com/svn/trunk/vcloud/core</connection>
<developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk/vcloudx/core</developerConnection> <developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk/vcloud/core</developerConnection>
<url>http://jclouds.googlecode.com/svn/trunk/vcloudx/core</url> <url>http://jclouds.googlecode.com/svn/trunk/vcloud/core</url>
</scm> </scm>
</project> </project>

View File

@ -21,7 +21,7 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx; package org.jclouds.vcloud;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -30,16 +30,16 @@ import java.util.concurrent.ExecutorService;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.rest.RestContextBuilder; import org.jclouds.rest.RestContextBuilder;
import org.jclouds.vcloudx.config.BaseVCloudXRestClientModule; import org.jclouds.vcloud.config.BaseVCloudContextModule;
import org.jclouds.vcloudx.config.BaseVCloudXContextModule; import org.jclouds.vcloud.config.BaseVCloudRestClientModule;
import org.jclouds.vcloudx.config.RestVCloudXAuthenticationModule; import org.jclouds.vcloud.config.VCloudDiscoveryRestClientModule;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
/** /**
* Creates {@link VCloudXContext} or {@link Injector} instances based on the most commonly requested * Creates {@link VCloudContext} or {@link Injector} instances based on the most commonly requested
* arguments. * arguments.
* <p/> * <p/>
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
@ -51,32 +51,32 @@ import com.google.inject.TypeLiteral;
* @author Adrian Cole * @author Adrian Cole
* @see CloudFilesContext * @see CloudFilesContext
*/ */
public class BaseVCloudXContextBuilder extends RestContextBuilder<VCloudXClient> { public class BaseVCloudContextBuilder extends RestContextBuilder<VCloudClient> {
public BaseVCloudXContextBuilder(Properties props) { public BaseVCloudContextBuilder(Properties props) {
super(new TypeLiteral<VCloudXClient>() { super(new TypeLiteral<VCloudClient>() {
}, props); }, props);
} }
@Override @Override
protected void addClientModule(List<Module> modules) { protected void addClientModule(List<Module> modules) {
modules.add(new RestVCloudXAuthenticationModule()); modules.add(new VCloudDiscoveryRestClientModule());
modules.add(new BaseVCloudXRestClientModule()); modules.add(new BaseVCloudRestClientModule());
} }
@Override @Override
protected void addContextModule(List<Module> modules) { protected void addContextModule(List<Module> modules) {
modules.add(new BaseVCloudXContextModule()); modules.add(new BaseVCloudContextModule());
} }
@Override @Override
public BaseVCloudXContextBuilder withExecutorService(ExecutorService service) { public BaseVCloudContextBuilder withExecutorService(ExecutorService service) {
return (BaseVCloudXContextBuilder) super.withExecutorService(service); return (BaseVCloudContextBuilder) super.withExecutorService(service);
} }
@Override @Override
public BaseVCloudXContextBuilder withModules(Module... modules) { public BaseVCloudContextBuilder withModules(Module... modules) {
return (BaseVCloudXContextBuilder) super.withModules(modules); return (BaseVCloudContextBuilder) super.withModules(modules);
} }
} }

View File

@ -0,0 +1,69 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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;
import java.util.concurrent.Future;
import static org.jclouds.vcloud.VCloudMediaType.*;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.xml.CatalogHandler;
/**
* Provides access to VCloud resources via their REST API.
* <p/>
*
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
* @author Adrian Cole
*/
@RequestFilters(SetVCloudTokenCookie.class)
public interface VCloudClient {
@GET
@Endpoint(org.jclouds.vcloud.endpoints.Catalog.class)
@Consumes(CATALOG_XML)
@XMLResponseParser(CatalogHandler.class)
Future<Catalog> getCatalog();
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
@Consumes(VDC_XML)
String getDefaultVDC();
//
// @GET
// @Endpoint(vDC.class)
// public Set<String> getvDCs();
//
// @GET
// @Endpoint(TasksList.class)
// public Set<String> getTasksLists();
}

View File

@ -21,37 +21,36 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx; package org.jclouds.vcloud;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.core.MediaType;
import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.vcloudx.domain.OrgLinks; import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloudx.endpoints.Org; import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloudx.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloudx.xml.OrgLinksHandler; import org.jclouds.vcloud.xml.OrgHandler;
/** /**
* Provides access to VCloudX resources via their REST API. * Provides access to VCloud resources via their REST API.
* <p/> * <p/>
* *
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" /> * @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
* @author Adrian Cole * @author Adrian Cole
*/ */
@RequestFilters(SetVCloudTokenCookie.class) @RequestFilters(SetVCloudTokenCookie.class)
public interface VCloudXClient { public interface VCloudDiscovery {
/** /**
* This call returns a list of all vCloud Data Centers (vDCs), catalogs, and task lists within * This call returns a list of all vCloud Data Centers (vdcs), catalogs, and task lists within
* the organization. * the organization.
*/ */
@GET @GET
@Endpoint(Org.class) @Endpoint(Org.class)
@Consumes(MediaType.APPLICATION_XML) @Consumes(VCloudMediaType.ORG_XML)
@XMLResponseParser(OrgLinksHandler.class) @XMLResponseParser(OrgHandler.class)
OrgLinks getOrganization(); Organization getOrganization();
} }

View File

@ -21,9 +21,9 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx; package org.jclouds.vcloud;
import java.net.URI; import java.util.Map;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.POST; import javax.ws.rs.POST;
@ -34,27 +34,28 @@ import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.vcloudx.endpoints.Org; import org.jclouds.vcloud.domain.Link;
import org.jclouds.vcloudx.endpoints.VCloudX; import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloudx.functions.ParseLoginResponseFromHeaders; import org.jclouds.vcloud.endpoints.VCloud;
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
/** /**
* Establishes a context with a VCloudX endpoint. * Establishes a context with a VCloud endpoint.
* <p/> * <p/>
* *
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" /> * @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
* @author Adrian Cole * @author Adrian Cole
*/ */
@Endpoint(VCloudX.class) @Endpoint(VCloud.class)
@RequestFilters(BasicAuthentication.class) @RequestFilters(BasicAuthentication.class)
public interface VCloudXLogin { public interface VCloudLogin {
public interface VCloudXSession { public interface VCloudSession {
@VCloudToken @VCloudToken
String getVCloudToken(); String getVCloudToken();
@Org @Org
URI getOrg(); Map<String, Link> getOrgs();
} }
/** /**
@ -65,5 +66,5 @@ public interface VCloudXLogin {
@ResponseParser(ParseLoginResponseFromHeaders.class) @ResponseParser(ParseLoginResponseFromHeaders.class)
@Path("/login") @Path("/login")
@Consumes(MediaType.APPLICATION_XML) @Consumes(MediaType.APPLICATION_XML)
VCloudXSession login(); VCloudSession login();
} }

View File

@ -21,7 +21,7 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx; package org.jclouds.vcloud;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -30,7 +30,7 @@ import javax.ws.rs.core.MediaType;
* *
* @see MediaType * @see MediaType
*/ */
public class VCloudXMediaType { public class VCloudMediaType {
/** /**
* "application/vnd.vmware.vcloud.org+xml" * "application/vnd.vmware.vcloud.org+xml"
@ -72,4 +72,14 @@ public class VCloudXMediaType {
public final static MediaType TASKSLIST_XML_TYPE = new MediaType("application", public final static MediaType TASKSLIST_XML_TYPE = new MediaType("application",
"vnd.vmware.vcloud.tasksList+xml"); "vnd.vmware.vcloud.tasksList+xml");
/**
* "application/vnd.vmware.vcloud.catalogItem+xml"
*/
public final static String CATALOGITEM_XML = "application/vnd.vmware.vcloud.catalogItem+xml";
/**
* "application/vnd.vmware.vcloud.catalogItem+xml"
*/
public final static MediaType CATALOGITEM_XML_TYPE = new MediaType("application",
"vnd.vmware.vcloud.catalogItem+xml");
} }

View File

@ -21,13 +21,13 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx; package org.jclouds.vcloud;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_ENDPOINT; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_KEY; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_KEY;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_SESSIONINTERVAL; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_SESSIONINTERVAL;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_USER; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER;
import java.net.URI; import java.net.URI;
import java.util.Properties; import java.util.Properties;
@ -35,41 +35,41 @@ import java.util.Properties;
import org.jclouds.http.HttpPropertiesBuilder; import org.jclouds.http.HttpPropertiesBuilder;
/** /**
* Builds properties used in VCloudX Clients * Builds properties used in VCloud Clients
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class VCloudXPropertiesBuilder extends HttpPropertiesBuilder { public class VCloudPropertiesBuilder extends HttpPropertiesBuilder {
@Override @Override
protected Properties defaultProperties() { protected Properties defaultProperties() {
Properties properties = super.defaultProperties(); Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_VCLOUDX_SESSIONINTERVAL, 9 * 60 + ""); properties.setProperty(PROPERTY_VCLOUD_SESSIONINTERVAL, 9 * 60 + "");
return properties; return properties;
} }
public VCloudXPropertiesBuilder(Properties properties) { public VCloudPropertiesBuilder(Properties properties) {
super(properties); super(properties);
} }
public VCloudXPropertiesBuilder(URI endpoint, String id, String secret) { public VCloudPropertiesBuilder(URI endpoint, String id, String secret) {
super(); super();
withCredentials(id, secret); withCredentials(id, secret);
withEndpoint(endpoint); withEndpoint(endpoint);
} }
public VCloudXPropertiesBuilder withTokenExpiration(long seconds) { public VCloudPropertiesBuilder withTokenExpiration(long seconds) {
properties.setProperty(PROPERTY_VCLOUDX_SESSIONINTERVAL, seconds + ""); properties.setProperty(PROPERTY_VCLOUD_SESSIONINTERVAL, seconds + "");
return this; return this;
} }
public VCloudXPropertiesBuilder withCredentials(String id, String secret) { public VCloudPropertiesBuilder withCredentials(String id, String secret) {
properties.setProperty(PROPERTY_VCLOUDX_USER, checkNotNull(id, "user")); properties.setProperty(PROPERTY_VCLOUD_USER, checkNotNull(id, "user"));
properties.setProperty(PROPERTY_VCLOUDX_KEY, checkNotNull(secret, "key")); properties.setProperty(PROPERTY_VCLOUD_KEY, checkNotNull(secret, "key"));
return this; return this;
} }
public VCloudXPropertiesBuilder withEndpoint(URI endpoint) { public VCloudPropertiesBuilder withEndpoint(URI endpoint) {
properties.setProperty(PROPERTY_VCLOUDX_ENDPOINT, checkNotNull(endpoint, "endpoint") properties.setProperty(PROPERTY_VCLOUD_ENDPOINT, checkNotNull(endpoint, "endpoint")
.toString()); .toString());
return this; return this;
} }

View File

@ -21,7 +21,7 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx; package org.jclouds.vcloud;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;

View File

@ -21,7 +21,7 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.config; package org.jclouds.vcloud.config;
import java.net.URI; import java.net.URI;
@ -31,9 +31,9 @@ import javax.inject.Singleton;
import org.jclouds.lifecycle.Closer; import org.jclouds.lifecycle.Closer;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.RestContextImpl; import org.jclouds.rest.internal.RestContextImpl;
import org.jclouds.vcloudx.VCloudXClient; import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloudx.endpoints.Org; import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloudx.reference.VCloudXConstants; import org.jclouds.vcloud.reference.VCloudConstants;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Provides; import com.google.inject.Provides;
@ -41,16 +41,16 @@ import com.google.inject.Provides;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
public class BaseVCloudXContextModule extends AbstractModule { public class BaseVCloudContextModule extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
} }
@Provides @Provides
@Singleton @Singleton
RestContext<VCloudXClient> provideContext(Closer closer, VCloudXClient defaultApi, RestContext<VCloudClient> provideContext(Closer closer, VCloudClient defaultApi,
@Org URI endPoint, @Named(VCloudXConstants.PROPERTY_VCLOUDX_USER) String account) { @Org URI endPoint, @Named(VCloudConstants.PROPERTY_VCLOUD_USER) String account) {
return new RestContextImpl<VCloudXClient>(closer, defaultApi, endPoint, account); return new RestContextImpl<VCloudClient>(closer, defaultApi, endPoint, account);
} }
} }

View File

@ -21,37 +21,53 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.config; package org.jclouds.vcloud.config;
import java.net.URI;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientFactory; import org.jclouds.rest.RestClientFactory;
import org.jclouds.vcloudx.VCloudXClient; import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.VCloudDiscovery;
import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.VDC;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Provides; import com.google.inject.Provides;
/** /**
* Configures the VCloudX authentication service connection, including logging and http * Configures the VCloud authentication service connection, including logging and http transport.
* transport.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@RequiresHttp @RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
public class BaseVCloudXRestClientModule extends AbstractModule { public class BaseVCloudRestClientModule extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
} }
@Provides @Provides
@Singleton @Singleton
protected VCloudXClient provideVCloudXClient(RestClientFactory factory) { protected VCloudClient provideVCloudClient(RestClientFactory factory) {
return factory.create(VCloudXClient.class); return factory.create(VCloudClient.class);
} }
@Provides
@Catalog
@Singleton
protected URI provideCatalog(VCloudDiscovery discovery) {
return discovery.getOrganization().getCatalog().getLocation();
}
@Provides
@VDC
@Singleton
protected URI provideDefaultVDC(VCloudDiscovery discovery) {
return discovery.getOrganization().getVDCs().values().iterator().next().getLocation();
}
} }

View File

@ -21,12 +21,12 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.config; package org.jclouds.vcloud.config;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_ENDPOINT; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_KEY; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_KEY;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_SESSIONINTERVAL; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_SESSIONINTERVAL;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_USER; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URI; import java.net.URI;
@ -39,23 +39,24 @@ import org.jclouds.concurrent.ExpirableSupplier;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.RestClientFactory; import org.jclouds.rest.RestClientFactory;
import org.jclouds.vcloudx.VCloudToken; import org.jclouds.vcloud.VCloudDiscovery;
import org.jclouds.vcloudx.VCloudXLogin; import org.jclouds.vcloud.VCloudLogin;
import org.jclouds.vcloudx.VCloudXLogin.VCloudXSession; import org.jclouds.vcloud.VCloudToken;
import org.jclouds.vcloudx.endpoints.Org; import org.jclouds.vcloud.VCloudLogin.VCloudSession;
import org.jclouds.vcloudx.endpoints.VCloudX; import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.endpoints.VCloud;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Provides; import com.google.inject.Provides;
/** /**
* Configures the VCloudX authentication service connection, including logging and http transport. * Configures the VCloud authentication service connection, including logging and http transport.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@RequiresHttp @RequiresHttp
public class RestVCloudXAuthenticationModule extends AbstractModule { public class VCloudDiscoveryRestClientModule extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
@ -63,14 +64,15 @@ public class RestVCloudXAuthenticationModule extends AbstractModule {
@VCloudToken @VCloudToken
@Provides @Provides
String provideVCloudToken(Supplier<VCloudXSession> cache) { String provideVCloudToken(Supplier<VCloudSession> cache) {
return cache.get().getVCloudToken(); return cache.get().getVCloudToken();
} }
@Provides @Provides
@Org @Org
protected URI provideOrg(VCloudXLogin login) { @Singleton
return login.login().getOrg(); protected URI provideOrg(Supplier<VCloudSession> cache, @Named(PROPERTY_VCLOUD_USER) String user) {
return cache.get().getOrgs().get(user).getLocation();
} }
/** /**
@ -78,10 +80,10 @@ public class RestVCloudXAuthenticationModule extends AbstractModule {
*/ */
@Provides @Provides
@Singleton @Singleton
Supplier<VCloudXSession> provideVCloudTokenCache( Supplier<VCloudSession> provideVCloudTokenCache(
@Named(PROPERTY_VCLOUDX_SESSIONINTERVAL) long seconds, final VCloudXLogin login) { @Named(PROPERTY_VCLOUD_SESSIONINTERVAL) long seconds, final VCloudLogin login) {
return new ExpirableSupplier<VCloudXSession>(new Supplier<VCloudXSession>() { return new ExpirableSupplier<VCloudSession>(new Supplier<VCloudSession>() {
public VCloudXSession get() { public VCloudSession get() {
return login.login(); return login.login();
} }
}, seconds, TimeUnit.SECONDS); }, seconds, TimeUnit.SECONDS);
@ -89,21 +91,27 @@ public class RestVCloudXAuthenticationModule extends AbstractModule {
@Provides @Provides
@Singleton @Singleton
@VCloudX @VCloud
protected URI provideAuthenticationURI(@Named(PROPERTY_VCLOUDX_ENDPOINT) String endpoint) { protected URI provideAuthenticationURI(@Named(PROPERTY_VCLOUD_ENDPOINT) String endpoint) {
return URI.create(endpoint); return URI.create(endpoint);
} }
@Provides @Provides
@Singleton @Singleton
protected VCloudXLogin provideVCloudXLogin(RestClientFactory factory) { protected VCloudLogin provideVCloudLogin(RestClientFactory factory) {
return factory.create(VCloudXLogin.class); return factory.create(VCloudLogin.class);
} }
@Provides @Provides
@Singleton @Singleton
public BasicAuthentication provideBasicAuthentication(@Named(PROPERTY_VCLOUDX_USER) String user, protected VCloudDiscovery provideVCloudDiscovery(RestClientFactory factory) {
@Named(PROPERTY_VCLOUDX_KEY) String key) throws UnsupportedEncodingException { return factory.create(VCloudDiscovery.class);
}
@Provides
@Singleton
public BasicAuthentication provideBasicAuthentication(@Named(PROPERTY_VCLOUD_USER) String user,
@Named(PROPERTY_VCLOUD_KEY) String key) throws UnsupportedEncodingException {
return new BasicAuthentication(user, key); return new BasicAuthentication(user, key);
} }

View File

@ -0,0 +1,39 @@
/**
*
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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.domain;
import java.util.Map;
import org.jclouds.vcloud.domain.internal.CatalogImpl;
import com.google.inject.ImplementedBy;
/**
* @author Adrian Cole
*/
@org.jclouds.vcloud.endpoints.Catalog
@ImplementedBy(CatalogImpl.class)
public interface Catalog extends Link, Map<String, Link> {
}

View File

@ -0,0 +1,47 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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.domain;
import java.net.URI;
import org.jclouds.vcloud.domain.internal.LinkImpl;
import com.google.inject.ImplementedBy;
/**
* Location of a vCloud resource
*
* @author Adrian Cole
*
*/
@ImplementedBy(LinkImpl.class)
public interface Link {
String getName();
String getType();
URI getLocation();
}

View File

@ -0,0 +1,52 @@
/**
*
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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.domain;
import java.util.Map;
import org.jclouds.vcloud.domain.internal.OrganizationImpl;
import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.endpoints.TasksList;
import org.jclouds.vcloud.endpoints.VDC;
import com.google.inject.ImplementedBy;
/**
* @author Adrian Cole
*/
@Org
@ImplementedBy(OrganizationImpl.class)
public interface Organization extends Link {
@Catalog
Link getCatalog();
@VDC
Map<String, Link> getVDCs();
@TasksList
Map<String, Link> getTasksLists();
}

View File

@ -0,0 +1,91 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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.domain.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.Link;
/**
* Locations of resources in vCloud
*
* @author Adrian Cole
*
*/
public class CatalogImpl extends HashMap<String, Link> implements Catalog {
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
private final Link catalog;
public CatalogImpl(String name, String type, URI location, Map<String, Link> contents) {
super(contents.size());
this.catalog = new LinkImpl(checkNotNull(name, "name"), checkNotNull(type, "type"),
checkNotNull(location, "location"));
putAll(checkNotNull(contents, "contents"));
}
public URI getLocation() {
return catalog.getLocation();
}
public String getName() {
return catalog.getName();
}
public String getType() {
return catalog.getType();
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((catalog == null) ? 0 : catalog.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
CatalogImpl other = (CatalogImpl) obj;
if (catalog == null) {
if (other.catalog != null)
return false;
} else if (!catalog.equals(other.catalog))
return false;
return true;
}
}

View File

@ -21,65 +21,53 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.domain; package org.jclouds.vcloud.domain.internal;
import java.net.URI; import java.net.URI;
import java.util.Set;
import javax.inject.Singleton; import org.jclouds.vcloud.domain.Link;
/** /**
* Locations of resources in VCloud Express * Location of a vCloud resource
* *
* @author Adrian Cole * @author Adrian Cole
* *
*/ */
@Singleton public class LinkImpl implements Link {
public class OrgLinks {
private final String name; private final String name;
private final URI org; private final String type;
private final URI catalog; private final URI location;
private final Set<URI> vDCs;
private final Set<URI> taskLists;
public OrgLinks(String name, URI org, URI catalog, Set<URI> vDCs, Set<URI> tasksLists) { public LinkImpl(String name, String type, URI location) {
this.name = name; this.name = name;
this.org = org; this.type = type;
this.catalog = catalog; this.location = location;
this.vDCs = vDCs;
this.taskLists = tasksLists;
} }
public String getName() { public String getName() {
return name; return name;
} }
public URI getOrg() { public String getType() {
return org; return type;
} }
public URI getCatalog() { public URI getLocation() {
return catalog; return location;
} }
public Set<URI> getVDCs() { @Override
return vDCs; public String toString() {
} return "Link [name=" + name + ", type=" + type + ", location=" + location + "]";
public Set<URI> getTaskLists() {
return taskLists;
} }
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((catalog == null) ? 0 : catalog.hashCode()); result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((org == null) ? 0 : org.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((taskLists == null) ? 0 : taskLists.hashCode());
result = prime * result + ((vDCs == null) ? 0 : vDCs.hashCode());
return result; return result;
} }
@ -91,33 +79,22 @@ public class OrgLinks {
return false; return false;
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
OrgLinks other = (OrgLinks) obj; LinkImpl other = (LinkImpl) obj;
if (catalog == null) { if (location == null) {
if (other.catalog != null) if (other.location != null)
return false; return false;
} else if (!catalog.equals(other.catalog)) } else if (!location.equals(other.location))
return false; return false;
if (name == null) { if (name == null) {
if (other.name != null) if (other.name != null)
return false; return false;
} else if (!name.equals(other.name)) } else if (!name.equals(other.name))
return false; return false;
if (org == null) { if (type == null) {
if (other.org != null) if (other.type != null)
return false; return false;
} else if (!org.equals(other.org)) } else if (!type.equals(other.type))
return false;
if (taskLists == null) {
if (other.taskLists != null)
return false;
} else if (!taskLists.equals(other.taskLists))
return false;
if (vDCs == null) {
if (other.vDCs != null)
return false;
} else if (!vDCs.equals(other.vDCs))
return false; return false;
return true; return true;
} }
} }

View File

@ -0,0 +1,107 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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.domain.internal;
import java.net.URI;
import java.util.Map;
import org.jclouds.vcloud.domain.Link;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.TasksList;
import org.jclouds.vcloud.endpoints.VDC;
/**
* Locations of resources in vCloud
*
* @author Adrian Cole
*
*/
public class OrganizationImpl extends LinkImpl implements Organization {
private final Link catalog;
private final Map<String, Link> vdcs;
private final Map<String, Link> tasksLists;
public OrganizationImpl(String name, String type, URI location, Link catalog,
Map<String, Link> vdcs, Map<String, Link> tasksLists) {
super(name, type, location);
this.catalog = catalog;
this.vdcs = vdcs;
this.tasksLists = tasksLists;
}
@Catalog
public Link getCatalog() {
return catalog;
}
@VDC
public Map<String, Link> getVDCs() {
return vdcs;
}
@TasksList
public Map<String, Link> getTasksLists() {
return tasksLists;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((catalog == null) ? 0 : catalog.hashCode());
result = prime * result + ((tasksLists == null) ? 0 : tasksLists.hashCode());
result = prime * result + ((vdcs == null) ? 0 : vdcs.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
OrganizationImpl other = (OrganizationImpl) obj;
if (catalog == null) {
if (other.catalog != null)
return false;
} else if (!catalog.equals(other.catalog))
return false;
if (tasksLists == null) {
if (other.tasksLists != null)
return false;
} else if (!tasksLists.equals(other.tasksLists))
return false;
if (vdcs == null) {
if (other.vdcs != null)
return false;
} else if (!vdcs.equals(other.vdcs))
return false;
return true;
}
}

View File

@ -21,7 +21,7 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.endpoints; package org.jclouds.vcloud.endpoints;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
@ -31,13 +31,13 @@ import java.lang.annotation.Target;
import javax.inject.Qualifier; import javax.inject.Qualifier;
/** /**
* Related to a VCloud express vDC. * Related to a VCloud Catalog.
* *
* @author Adrian Cole * @author Adrian Cole
* *
*/ */
@Retention(value = RetentionPolicy.RUNTIME) @Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier @Qualifier
public @interface Catalog { public @interface Catalog {

View File

@ -21,7 +21,7 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.endpoints; package org.jclouds.vcloud.endpoints;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
@ -37,7 +37,7 @@ import javax.inject.Qualifier;
* *
*/ */
@Retention(value = RetentionPolicy.RUNTIME) @Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier @Qualifier
public @interface Org { public @interface Org {

View File

@ -21,7 +21,7 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.endpoints; package org.jclouds.vcloud.endpoints;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
@ -39,6 +39,6 @@ import javax.inject.Qualifier;
@Retention(value = RetentionPolicy.RUNTIME) @Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier @Qualifier
public @interface TaskList { public @interface TasksList {
} }

View File

@ -21,7 +21,7 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.endpoints; package org.jclouds.vcloud.endpoints;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
@ -31,7 +31,7 @@ import java.lang.annotation.Target;
import javax.inject.Qualifier; import javax.inject.Qualifier;
/** /**
* Represents a component related to VCloud Express. * Represents a component related to vCloud.
* *
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" /> * @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
* @author Adrian Cole * @author Adrian Cole
@ -40,6 +40,6 @@ import javax.inject.Qualifier;
@Retention(value = RetentionPolicy.RUNTIME) @Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier @Qualifier
public @interface VCloudX { public @interface VCloud {
} }

View File

@ -21,7 +21,7 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.endpoints; package org.jclouds.vcloud.endpoints;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;

View File

@ -21,7 +21,7 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.filters; package org.jclouds.vcloud.filters;
import java.util.Collections; import java.util.Collections;
@ -32,7 +32,7 @@ import javax.inject.Singleton;
import org.jclouds.http.HttpException; import org.jclouds.http.HttpException;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.HttpRequestFilter;
import org.jclouds.vcloudx.VCloudToken; import org.jclouds.vcloud.VCloudToken;
/** /**
* Adds the VCloud Token to the request as a cookie * Adds the VCloud Token to the request as a cookie

View File

@ -21,11 +21,11 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.functions; package org.jclouds.vcloud.functions;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -38,36 +38,37 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpResponseException; import org.jclouds.http.HttpResponseException;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.vcloudx.VCloudToken; import org.jclouds.vcloud.VCloudToken;
import org.jclouds.vcloudx.VCloudXLogin.VCloudXSession; import org.jclouds.vcloud.VCloudLogin.VCloudSession;
import org.jclouds.vcloudx.endpoints.Org; import org.jclouds.vcloud.domain.Link;
import org.jclouds.vcloudx.xml.OrgListToOrgUriHandler; import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.xml.OrgListHandler;
import com.google.common.base.Function; import com.google.common.base.Function;
/** /**
* This parses {@link VCloudXSession} from HTTP headers. * This parses {@link VCloudSession} from HTTP headers.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Singleton @Singleton
public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCloudXSession> { public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCloudSession> {
static final Pattern pattern = Pattern.compile("vcloud-token=(.*); path=.*"); static final Pattern pattern = Pattern.compile("vcloud-token=(.*); path=.*");
private final ParseSax.Factory factory; private final ParseSax.Factory factory;
private final Provider<OrgListToOrgUriHandler> orgHandlerProvider; private final Provider<OrgListHandler> orgHandlerProvider;
@Inject @Inject
private ParseLoginResponseFromHeaders(Factory factory, private ParseLoginResponseFromHeaders(Factory factory,
Provider<OrgListToOrgUriHandler> orgHandlerProvider) { Provider<OrgListHandler> orgHandlerProvider) {
this.factory = factory; this.factory = factory;
this.orgHandlerProvider = orgHandlerProvider; this.orgHandlerProvider = orgHandlerProvider;
} }
/** /**
* parses the http response headers to create a new {@link VCloudXSession} object. * parses the http response headers to create a new {@link VCloudSession} object.
*/ */
public VCloudXSession apply(HttpResponse from) { public VCloudSession apply(HttpResponse from) {
String cookieHeader = checkNotNull(from.getFirstHeaderOrNull(HttpHeaders.SET_COOKIE), String cookieHeader = checkNotNull(from.getFirstHeaderOrNull(HttpHeaders.SET_COOKIE),
HttpHeaders.SET_COOKIE); HttpHeaders.SET_COOKIE);
@ -75,16 +76,17 @@ public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCl
boolean matchFound = matcher.find(); boolean matchFound = matcher.find();
if (matchFound) { if (matchFound) {
final URI org = (URI) factory.create(orgHandlerProvider.get()).parse(from.getContent()); final Map<String, Link> org = factory.create(orgHandlerProvider.get()).parse(
from.getContent());
return new VCloudXSession() { return new VCloudSession() {
@VCloudToken @VCloudToken
public String getVCloudToken() { public String getVCloudToken() {
return matcher.group(1); return matcher.group(1);
} }
@Org @Org
public URI getOrg() { public Map<String, Link> getOrgs() {
return org; return org;
} }
}; };

View File

@ -21,19 +21,19 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.reference; package org.jclouds.vcloud.reference;
/** /**
* Configuration properties and constants used in VCloudX connections. * Configuration properties and constants used in VCloud connections.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public interface VCloudXConstants { public interface VCloudConstants {
public static final String PROPERTY_VCLOUDX_ENDPOINT = "jclouds.vcloudx.endpoint"; public static final String PROPERTY_VCLOUD_ENDPOINT = "jclouds.vcloud.endpoint";
public static final String PROPERTY_VCLOUDX_USER = "jclouds.vcloudx.user"; public static final String PROPERTY_VCLOUD_USER = "jclouds.vcloud.user";
public static final String PROPERTY_VCLOUDX_KEY = "jclouds.vcloudx.key"; public static final String PROPERTY_VCLOUD_KEY = "jclouds.vcloud.key";
/** /**
* automatically renew vcloud token before this interval expires. * automatically renew vcloud token before this interval expires.
*/ */
public static final String PROPERTY_VCLOUDX_SESSIONINTERVAL = "jclouds.vcloudx.sessioninterval"; public static final String PROPERTY_VCLOUD_SESSIONINTERVAL = "jclouds.vcloud.sessioninterval";
} }

View File

@ -22,7 +22,7 @@
* ==================================================================== * ====================================================================
*/ */
/** /**
* This package contains properties and reference data used in VCloud Express. * This package contains properties and reference data used in vCloud.
* @author Adrian Cole * @author Adrian Cole
*/ */
package org.jclouds.vcloudx.reference; package org.jclouds.vcloud.reference;

View File

@ -0,0 +1,48 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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.util;
import java.net.URI;
import java.util.Map;
import org.jclouds.vcloud.domain.Link;
import org.jclouds.vcloud.domain.internal.LinkImpl;
import org.xml.sax.Attributes;
/**
*
* @author Adrian Cole
*/
public class Utils {
public static void putLink(Map<String, Link> map, Attributes attributes) {
map.put(attributes.getValue(attributes.getIndex("name")), newLink(attributes));
}
public static Link newLink(Attributes attributes) {
return new LinkImpl(attributes.getValue(attributes.getIndex("name")), attributes
.getValue(attributes.getIndex("type")), URI.create(attributes.getValue(attributes
.getIndex("href"))));
}
}

View File

@ -0,0 +1,64 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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.xml;
import static org.jclouds.vcloud.util.Utils.putLink;
import java.net.URI;
import java.util.Map;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.Link;
import org.jclouds.vcloud.domain.internal.CatalogImpl;
import org.jclouds.vcloud.domain.internal.LinkImpl;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import com.google.common.collect.Maps;
/**
* @author Adrian Cole
*/
public class CatalogHandler extends ParseSax.HandlerWithResult<Catalog> {
private Link Catalog;
private Map<String, Link> contents = Maps.newHashMap();
public Catalog getResult() {
return new CatalogImpl(Catalog.getName(), Catalog.getType(), Catalog.getLocation(), contents);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
if (qName.equals("Catalog")) {
Catalog = new LinkImpl(attributes.getValue(attributes.getIndex("name")), attributes
.getValue(attributes.getIndex("type")), URI.create(attributes.getValue(attributes
.getIndex("href"))));
} else if (qName.equals("CatalogItem")) {
putLink(contents, attributes);
}
}
}

View File

@ -21,68 +21,60 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.xml; package org.jclouds.vcloud.xml;
import static org.jclouds.vcloudx.VCloudXMediaType.CATALOG_XML; import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
import static org.jclouds.vcloudx.VCloudXMediaType.TASKSLIST_XML; import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
import static org.jclouds.vcloudx.VCloudXMediaType.VDC_XML; import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
import static org.jclouds.vcloud.util.Utils.newLink;
import static org.jclouds.vcloud.util.Utils.putLink;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Map;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.vcloudx.domain.OrgLinks; import org.jclouds.vcloud.domain.Link;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.internal.LinkImpl;
import org.jclouds.vcloud.domain.internal.OrganizationImpl;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import com.google.common.collect.Sets; import com.google.common.collect.Maps;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
public class OrgLinksHandler extends ParseSax.HandlerWithResult<OrgLinks> { public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
private String name; private Link org;
private URI org; private Map<String, Link> vdcs = Maps.newHashMap();
private Set<URI> vdcs = Sets.newHashSet(); private Map<String, Link> tasksLists = Maps.newHashMap();
private Set<URI> tasksLists = Sets.newHashSet(); private Link catalog;
private URI catalog;
public OrgLinks getResult() { public Organization getResult() {
return new OrgLinks(name, org, catalog, vdcs, tasksLists); return new OrganizationImpl(org.getName(), org.getType(), org.getLocation(), catalog, vdcs,
tasksLists);
} }
@Override @Override
public void startElement(String uri, String localName, String qName, Attributes attributes) public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException { throws SAXException {
if (qName.equals("Org")) { if (qName.equals("Org")) {
int index = attributes.getIndex("href"); org = new LinkImpl(attributes.getValue(attributes.getIndex("name")), ORG_XML, URI
if (index != -1) { .create(attributes.getValue(attributes.getIndex("href"))));
org = URI.create(attributes.getValue(index));
}
index = attributes.getIndex("name");
if (index != -1) {
name = attributes.getValue(index);
}
} else if (qName.equals("Link")) { } else if (qName.equals("Link")) {
int typeIndex = attributes.getIndex("type"); int typeIndex = attributes.getIndex("type");
if (typeIndex != -1) { if (typeIndex != -1) {
if (attributes.getValue(typeIndex).equals(VDC_XML)) { if (attributes.getValue(typeIndex).equals(VDC_XML)) {
int index = attributes.getIndex("href"); putLink(vdcs, attributes);
if (index != -1) {
vdcs.add(URI.create(attributes.getValue(index)));
}
} else if (attributes.getValue(typeIndex).equals(CATALOG_XML)) { } else if (attributes.getValue(typeIndex).equals(CATALOG_XML)) {
int index = attributes.getIndex("href"); catalog = newLink(attributes);
if (index != -1) {
catalog = URI.create(attributes.getValue(index));
}
} else if (attributes.getValue(typeIndex).equals(TASKSLIST_XML)) { } else if (attributes.getValue(typeIndex).equals(TASKSLIST_XML)) {
int index = attributes.getIndex("href"); putLink(tasksLists, attributes);
if (index != -1) {
tasksLists.add(URI.create(attributes.getValue(index)));
}
} }
} }
} }
} }
} }

View File

@ -21,22 +21,28 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.xml; package org.jclouds.vcloud.xml;
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
import static org.jclouds.vcloud.util.Utils.putLink;
import java.util.Map;
import java.net.URI;
import static org.jclouds.vcloudx.VCloudXMediaType.*;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.vcloud.domain.Link;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import com.google.common.collect.Maps;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
public class OrgListToOrgUriHandler extends ParseSax.HandlerWithResult<URI> { public class OrgListHandler extends ParseSax.HandlerWithResult<Map<String, Link>> {
private URI org; private Map<String, Link> org = Maps.newHashMap();
public URI getResult() { public Map<String, Link> getResult() {
return org; return org;
} }
@ -47,10 +53,7 @@ public class OrgListToOrgUriHandler extends ParseSax.HandlerWithResult<URI> {
int typeIndex = attributes.getIndex("type"); int typeIndex = attributes.getIndex("type");
if (typeIndex != -1) { if (typeIndex != -1) {
if (attributes.getValue(typeIndex).equals(ORG_XML)) { if (attributes.getValue(typeIndex).equals(ORG_XML)) {
int index = attributes.getIndex("href"); putLink(org, attributes);
if (index != -1) {
org = URI.create(attributes.getValue(index));
}
} }
} }
} }

View File

@ -21,9 +21,13 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx; package org.jclouds.vcloud;
import static org.easymock.classextension.EasyMock.createMock; import static org.easymock.classextension.EasyMock.createMock;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_KEY;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_SESSIONINTERVAL;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.net.URI; import java.net.URI;
@ -34,10 +38,9 @@ import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextBuilder; import org.jclouds.rest.RestContextBuilder;
import org.jclouds.rest.internal.RestContextImpl; import org.jclouds.rest.internal.RestContextImpl;
import org.jclouds.vcloudx.config.BaseVCloudXContextModule; import org.jclouds.vcloud.config.BaseVCloudContextModule;
import org.jclouds.vcloudx.config.BaseVCloudXRestClientModule; import org.jclouds.vcloud.config.BaseVCloudRestClientModule;
import org.jclouds.vcloudx.endpoints.Org; import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloudx.reference.VCloudXConstants;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
@ -47,72 +50,70 @@ import com.google.inject.Module;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
/** /**
* Tests behavior of modules configured in BaseVCloudXContextBuilder * Tests behavior of modules configured in BaseVCloudContextBuilder
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "vcloudx.BaseVCloudXContextBuilderTest") @Test(groups = "unit", testName = "vcloud.BaseVCloudContextBuilderTest")
public class BaseVCloudXContextBuilderTest { public class BaseVCloudContextBuilderTest {
VCloudXClient connection = createMock(VCloudXClient.class); VCloudClient connection = createMock(VCloudClient.class);
@ConfiguresRestClient @ConfiguresRestClient
private final class StubClientModule extends AbstractModule { private final class StubClientModule extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
bind(URI.class).annotatedWith(Org.class).toInstance(URI.create("http://org")); bind(URI.class).annotatedWith(Org.class).toInstance(URI.create("http://org"));
bind(VCloudXClient.class).toInstance(connection); bind(VCloudClient.class).toInstance(connection);
} }
} }
public void testNewBuilder() { public void testNewBuilder() {
RestContextBuilder<VCloudXClient> builder = builder(); RestContextBuilder<VCloudClient> builder = builder();
assertEquals(builder.getProperties().getProperty(VCloudXConstants.PROPERTY_VCLOUDX_ENDPOINT), assertEquals(builder.getProperties().getProperty(PROPERTY_VCLOUD_ENDPOINT),
"http://localhost"); "http://localhost");
assertEquals(builder.getProperties().getProperty(VCloudXConstants.PROPERTY_VCLOUDX_USER), assertEquals(builder.getProperties().getProperty(PROPERTY_VCLOUD_USER), "id");
"id"); assertEquals(builder.getProperties().getProperty(PROPERTY_VCLOUD_KEY), "secret");
assertEquals(builder.getProperties().getProperty(VCloudXConstants.PROPERTY_VCLOUDX_KEY), assertEquals(builder.getProperties().getProperty(PROPERTY_VCLOUD_SESSIONINTERVAL), "540");
"secret");
assertEquals(builder.getProperties().getProperty(
VCloudXConstants.PROPERTY_VCLOUDX_SESSIONINTERVAL), "540");
} }
public void testBuildContext() { public void testBuildContext() {
RestContextBuilder<VCloudXClient> builder = builder(); RestContextBuilder<VCloudClient> builder = builder();
RestContext<VCloudXClient> context = builder.buildContext(); RestContext<VCloudClient> context = builder.buildContext();
assertEquals(context.getClass(), RestContextImpl.class); assertEquals(context.getClass(), RestContextImpl.class);
assertEquals(context.getApi(), connection); assertEquals(context.getApi(), connection);
assertEquals(context.getAccount(), "id"); assertEquals(context.getAccount(), "id");
assertEquals(context.getEndPoint(), URI.create("http://org")); assertEquals(context.getEndPoint(), URI.create("http://org"));
} }
public BaseVCloudXContextBuilder builder() { public BaseVCloudContextBuilder builder() {
return new BaseVCloudXContextBuilder(new VCloudXPropertiesBuilder(URI return new BaseVCloudContextBuilder(new VCloudPropertiesBuilder(URI
.create("http://localhost"), "id", "secret").build()) .create("http://localhost"), "id", "secret").build())
.withModules(new StubClientModule()); .withModules(new StubClientModule());
} }
public void testBuildInjector() { public void testBuildInjector() {
RestContextBuilder<VCloudXClient> builder = builder(); RestContextBuilder<VCloudClient> builder = builder();
Injector i = builder.buildInjector(); Injector i = builder.buildInjector();
assert i.getInstance(Key.get(new TypeLiteral<RestContext<VCloudXClient>>() { assert i.getInstance(Key.get(URI.class, Org.class)) != null;
assert i.getInstance(Key.get(new TypeLiteral<RestContext<VCloudClient>>() {
})) != null; })) != null;
} }
protected void testAddContextModule() { protected void testAddContextModule() {
List<Module> modules = new ArrayList<Module>(); List<Module> modules = new ArrayList<Module>();
BaseVCloudXContextBuilder builder = builder(); BaseVCloudContextBuilder builder = builder();
builder.addContextModule(modules); builder.addContextModule(modules);
assertEquals(modules.size(), 1); assertEquals(modules.size(), 1);
assertEquals(modules.get(0).getClass(), BaseVCloudXContextModule.class); assertEquals(modules.get(0).getClass(), BaseVCloudContextModule.class);
} }
protected void addClientModule() { protected void addClientModule() {
List<Module> modules = new ArrayList<Module>(); List<Module> modules = new ArrayList<Module>();
BaseVCloudXContextBuilder builder = builder(); BaseVCloudContextBuilder builder = builder();
builder.addClientModule(modules); builder.addClientModule(modules);
assertEquals(modules.size(), 1); assertEquals(modules.size(), 1);
assertEquals(modules.get(0).getClass(), BaseVCloudXRestClientModule.class); assertEquals(modules.get(0).getClass(), BaseVCloudRestClientModule.class);
} }
} }

View File

@ -21,39 +21,46 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx; package org.jclouds.vcloud;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.net.URI; import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.vcloudx.domain.OrgLinks; import org.jclouds.vcloud.domain.Catalog;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Tests behavior of {@code VCloudXClient} * Tests behavior of {@code VCloudClient}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", sequential = true, testName = "vcloudx.VCloudXClientLiveTest") @Test(groups = "live", sequential = true, testName = "vcloud.VCloudClientLiveTest")
public class VCloudXClientLiveTest { public class VCloudClientLiveTest {
private VCloudXClient connection; private VCloudClient connection;
private String account; private String account;
@Test @Test
public void testOrganization() throws Exception { public void testOrganization() throws Exception {
OrgLinks response = connection.getOrganization(); Catalog response = connection.getCatalog().get(10, TimeUnit.SECONDS);
assertNotNull(response); assertNotNull(response);
assertEquals(response.getName(), account); assertNotNull(response.getName());
assertNotNull(response.getOrg()); assertNotNull(response.getLocation());
assertNotNull(response.getCatalog()); assertEquals(response.getType(), "application/vnd.vmware.vcloud.catalog+xml");
assertEquals(response.getTaskLists().size(), 1); assert response.size() > 0;
assertEquals(response.getVDCs().size(), 1); }
@Test
public void testDefaultVDC() throws Exception {
String response = connection.getDefaultVDC();
assertNotNull(response);
System.err.println(response);
} }
@BeforeGroups(groups = { "live" }) @BeforeGroups(groups = { "live" })
@ -62,7 +69,7 @@ public class VCloudXClientLiveTest {
"jclouds.test.endpoint"); "jclouds.test.endpoint");
account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
connection = new BaseVCloudXContextBuilder(new VCloudXPropertiesBuilder(URI.create(endpoint), connection = new BaseVCloudContextBuilder(new VCloudPropertiesBuilder(URI.create(endpoint),
account, key).build()).withModules(new Log4JLoggingModule()).buildContext().getApi(); account, key).build()).withModules(new Log4JLoggingModule()).buildContext().getApi();
} }

View File

@ -0,0 +1,127 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URI;
import javax.inject.Provider;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReturnStringIf200;
import org.jclouds.logging.Logger;
import org.jclouds.logging.Logger.LoggerFactory;
import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.VDC;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.xml.CatalogHandler;
import org.testng.annotations.Test;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
/**
* Tests behavior of {@code VCloudClient}
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "vcloud.VCloudClientTest")
public class VCloudClientTest extends RestClientTest<VCloudClient> {
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudClient.class.getMethod("getCatalog");
GeneratedHttpRequest<VCloudClient> httpMethod = processor.createRequest(method);
assertRequestLineEquals(httpMethod, "GET http://catalog HTTP/1.1");
assertHeadersEqual(httpMethod,"Accept: application/vnd.vmware.vcloud.catalog+xml\n");
assertEntityEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, CatalogHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testGetDefaultVDC() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudClient.class.getMethod("getDefaultVDC");
GeneratedHttpRequest<VCloudClient> httpMethod = processor.createRequest(method);
assertRequestLineEquals(httpMethod, "GET http://vdc HTTP/1.1");
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
assertEntityEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ReturnStringIf200.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
@Override
protected void checkFilters(GeneratedHttpRequest<VCloudClient> httpMethod) {
assertEquals(httpMethod.getFilters().size(), 1);
assertEquals(httpMethod.getFilters().get(0).getClass(), SetVCloudTokenCookie.class);
}
@Override
protected TypeLiteral<RestAnnotationProcessor<VCloudClient>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<VCloudClient>>() {
};
}
@Override
protected Module createModule() {
return new AbstractModule() {
@Override
protected void configure() {
bind(URI.class).annotatedWith(Catalog.class).toInstance(URI.create("http://catalog"));
bind(URI.class).annotatedWith(VDC.class).toInstance(URI.create("http://vdc"));
bind(SetVCloudTokenCookie.class).toInstance(
new SetVCloudTokenCookie(new Provider<String>() {
public String get() {
return "token";
}
}));
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
public Logger getLogger(String category) {
return Logger.NULL;
}
});
}
};
}
}

View File

@ -0,0 +1,123 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_KEY;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_SESSIONINTERVAL;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.net.URI;
import java.util.List;
import java.util.Properties;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.lifecycle.Closer;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextBuilder;
import org.jclouds.rest.internal.RestContextImpl;
import org.jclouds.vcloud.config.VCloudDiscoveryRestClientModule;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.endpoints.VCloud;
import org.jclouds.vcloud.reference.VCloudConstants;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral;
/**
* Tests behavior of {@code VCloudDiscovery}
*
* @author Adrian Cole
*/
@Test(groups = "live", sequential = true, testName = "vcloud.VCloudDiscoveryLiveTest")
public class VCloudDiscoveryLiveTest {
String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"),
"jclouds.test.endpoint");
String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
private final class VCloudDiscoveryContextModule extends AbstractModule {
@SuppressWarnings( { "unused" })
@Provides
@Singleton
RestContext<VCloudDiscovery> provideContext(Closer closer, VCloudDiscovery api,
@VCloud URI endPoint, @Named(VCloudConstants.PROPERTY_VCLOUD_USER) String account) {
return new RestContextImpl<VCloudDiscovery>(closer, api, endPoint, account);
}
@Override
protected void configure() {
}
}
private RestContext<VCloudDiscovery> context;
@Test
public void testOrganization() throws Exception {
Organization response = context.getApi().getOrganization();
assertNotNull(response);
assertEquals(response.getName(), account);
assertEquals(response.getType(), VCloudMediaType.ORG_XML);
assertNotNull(response.getCatalog());
assertEquals(response.getTasksLists().size(), 1);
assertEquals(response.getVDCs().size(), 1);
}
@BeforeClass
void setupFactory() {
context = new RestContextBuilder<VCloudDiscovery>(new TypeLiteral<VCloudDiscovery>() {
}, new Properties()) {
public void addContextModule(List<Module> modules) {
modules.add(new VCloudDiscoveryContextModule());
}
@Override
protected void addClientModule(List<Module> modules) {
properties.setProperty(VCloudConstants.PROPERTY_VCLOUD_ENDPOINT, checkNotNull(endpoint,
"endpoint").toString());
properties.setProperty(PROPERTY_VCLOUD_USER, checkNotNull(account, "user"));
properties.setProperty(PROPERTY_VCLOUD_KEY, checkNotNull(key, "key"));
properties.setProperty(PROPERTY_VCLOUD_SESSIONINTERVAL, "4");
modules.add(new VCloudDiscoveryRestClientModule());
}
}.withModules(new Log4JLoggingModule(),
new ExecutorServiceModule(new WithinThreadExecutorService())).buildContext();
}
}

View File

@ -21,62 +21,69 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx; package org.jclouds.vcloud;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.URI; import java.net.URI;
import javax.inject.Provider; import javax.inject.Provider;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import org.jclouds.concurrent.WithinThreadExecutorService; import org.jclouds.http.functions.ParseSax;
import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.logging.Logger.LoggerFactory;
import org.jclouds.rest.config.RestModule; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.vcloudx.endpoints.Org; import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloudx.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloudx.xml.OrgLinksHandler; import org.jclouds.vcloud.xml.OrgHandler;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Guice; import com.google.inject.Module;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
/** /**
* Tests behavior of {@code VCloudXClient} * Tests behavior of {@code VCloudDiscovery}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "vcloudx.VCloudXClient") @Test(groups = "unit", testName = "vcloud.VCloudDiscoveryTest")
public class VCloudXClientTest { public class VCloudDiscoveryTest extends RestClientTest<VCloudDiscovery> {
private RestAnnotationProcessor<VCloudXClient> processor; public void testOrganization() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudDiscovery.class.getMethod("getOrganization");
GeneratedHttpRequest<VCloudDiscovery> httpMethod = processor.createRequest(method);
public void testOrganization() throws SecurityException, NoSuchMethodException { assertRequestLineEquals(httpMethod, "GET http://org HTTP/1.1");
Method method = VCloudXClient.class.getMethod("getOrganization"); assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.org+xml\n");
HttpRequest httpMethod = processor.createRequest(method); assertEntityEquals(httpMethod, null);
assertEquals(httpMethod.getRequestLine(), "GET http://org HTTP/1.1");
assertEquals(httpMethod.getHeaders().size(), 1); assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertEquals(httpMethod.getFirstHeaderOrNull(HttpHeaders.ACCEPT), MediaType.APPLICATION_XML); assertSaxResponseParserClassEquals(method, OrgHandler.class);
assertEquals(RestAnnotationProcessor.getSaxResponseParserClassOrNull(method),OrgLinksHandler.class); assertExceptionParserClassEquals(method, null);
assertEquals(httpMethod.getFilters().size(), 1);
assertEquals(httpMethod.getFilters().get(0).getClass(), SetVCloudTokenCookie.class); checkFilters(httpMethod);
assertEquals(processor.createExceptionParserOrNullIfNotFound(method), null);
} }
@BeforeClass @Override
void setupFactory() { protected void checkFilters(GeneratedHttpRequest<VCloudDiscovery> httpMethod) {
Injector injector = Guice.createInjector(new AbstractModule() { assertEquals(httpMethod.getFilters().size(), 1);
assertEquals(httpMethod.getFilters().get(0).getClass(), SetVCloudTokenCookie.class);
}
@Override
protected TypeLiteral<RestAnnotationProcessor<VCloudDiscovery>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<VCloudDiscovery>>() {
};
}
@Override
protected Module createModule() {
return new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
bind(URI.class).annotatedWith(Org.class).toInstance(URI.create("http://org")); bind(URI.class).annotatedWith(Org.class).toInstance(URI.create("http://org"));
@ -95,11 +102,8 @@ public class VCloudXClientTest {
} }
}); });
} }
}, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()),
new JavaUrlHttpCommandExecutorServiceModule()); };
processor = injector.getInstance(Key
.get(new TypeLiteral<RestAnnotationProcessor<VCloudXClient>>() {
}));
} }
} }

View File

@ -21,12 +21,12 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx; package org.jclouds.vcloud;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_KEY; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_KEY;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_SESSIONINTERVAL; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_SESSIONINTERVAL;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_USER; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.net.URI; import java.net.URI;
@ -43,10 +43,11 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextBuilder; import org.jclouds.rest.RestContextBuilder;
import org.jclouds.rest.internal.RestContextImpl; import org.jclouds.rest.internal.RestContextImpl;
import org.jclouds.vcloudx.VCloudXLogin.VCloudXSession; import org.jclouds.vcloud.VCloudLogin;
import org.jclouds.vcloudx.config.RestVCloudXAuthenticationModule; import org.jclouds.vcloud.VCloudLogin.VCloudSession;
import org.jclouds.vcloudx.endpoints.VCloudX; import org.jclouds.vcloud.config.VCloudDiscoveryRestClientModule;
import org.jclouds.vcloudx.reference.VCloudXConstants; import org.jclouds.vcloud.endpoints.VCloud;
import org.jclouds.vcloud.reference.VCloudConstants;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -56,21 +57,21 @@ import com.google.inject.Provides;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
/** /**
* Tests behavior of {@code VCloudXLogin} * Tests behavior of {@code VCloudLogin}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", testName = "vcloudx.VCloudXLoginLiveTest") @Test(groups = "live", testName = "vcloud.VCloudLoginLiveTest")
public class VCloudXLoginLiveTest { public class VCloudLoginLiveTest {
private final class VCloudXLoginContextModule extends AbstractModule { private final class VCloudLoginContextModule extends AbstractModule {
@SuppressWarnings( { "unused" }) @SuppressWarnings( { "unused" })
@Provides @Provides
@Singleton @Singleton
RestContext<VCloudXLogin> provideContext(Closer closer, VCloudXLogin api, RestContext<VCloudLogin> provideContext(Closer closer, VCloudLogin api,
@VCloudX URI endPoint, @Named(VCloudXConstants.PROPERTY_VCLOUDX_USER) String account) { @VCloud URI endPoint, @Named(VCloudConstants.PROPERTY_VCLOUD_USER) String account) {
return new RestContextImpl<VCloudXLogin>(closer, api, endPoint, account); return new RestContextImpl<VCloudLogin>(closer, api, endPoint, account);
} }
@Override @Override
@ -84,37 +85,37 @@ public class VCloudXLoginLiveTest {
String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
private RestContext<VCloudXLogin> context; private RestContext<VCloudLogin> context;
@Test @Test
public void testLogin() throws Exception { public void testLogin() throws Exception {
VCloudXLogin authentication = context.getApi(); VCloudLogin authentication = context.getApi();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
VCloudXSession response = authentication.login(); VCloudSession response = authentication.login();
assertNotNull(response); assertNotNull(response);
assertNotNull(response.getVCloudToken()); assertNotNull(response.getVCloudToken());
assertNotNull(response.getOrg()); assertNotNull(response.getOrgs());
} }
} }
@BeforeClass @BeforeClass
void setupFactory() { void setupFactory() {
context = new RestContextBuilder<VCloudXLogin>(new TypeLiteral<VCloudXLogin>() { context = new RestContextBuilder<VCloudLogin>(new TypeLiteral<VCloudLogin>() {
}, new Properties()) { }, new Properties()) {
public void addContextModule(List<Module> modules) { public void addContextModule(List<Module> modules) {
modules.add(new VCloudXLoginContextModule()); modules.add(new VCloudLoginContextModule());
} }
@Override @Override
protected void addClientModule(List<Module> modules) { protected void addClientModule(List<Module> modules) {
properties.setProperty(VCloudXConstants.PROPERTY_VCLOUDX_ENDPOINT, checkNotNull( properties.setProperty(VCloudConstants.PROPERTY_VCLOUD_ENDPOINT, checkNotNull(
endpoint, "endpoint").toString()); endpoint, "endpoint").toString());
properties.setProperty(PROPERTY_VCLOUDX_USER, checkNotNull(account, "user")); properties.setProperty(PROPERTY_VCLOUD_USER, checkNotNull(account, "user"));
properties.setProperty(PROPERTY_VCLOUDX_KEY, checkNotNull(key, "key")); properties.setProperty(PROPERTY_VCLOUD_KEY, checkNotNull(key, "key"));
properties.setProperty(PROPERTY_VCLOUDX_SESSIONINTERVAL, "4"); properties.setProperty(PROPERTY_VCLOUD_SESSIONINTERVAL, "4");
modules.add(new RestVCloudXAuthenticationModule()); modules.add(new VCloudDiscoveryRestClientModule());
} }
}.withModules(new Log4JLoggingModule(), }.withModules(new Log4JLoggingModule(),

View File

@ -21,10 +21,11 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx; package org.jclouds.vcloud;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.URI; import java.net.URI;
@ -32,54 +33,61 @@ import java.net.URI;
import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.logging.Logger.LoggerFactory;
import org.jclouds.rest.config.RestModule; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.vcloudx.endpoints.VCloudX; import org.jclouds.vcloud.endpoints.VCloud;
import org.jclouds.vcloudx.functions.ParseLoginResponseFromHeaders; import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Guice; import com.google.inject.Module;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
/** /**
* Tests behavior of {@code VCloudXLogin} * Tests behavior of {@code VCloudLogin}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "vcloudx.VCloudXLogin") @Test(groups = "unit", testName = "vcloud.VCloudLoginTest")
public class VCloudXLoginTest { public class VCloudLoginTest extends RestClientTest<VCloudLogin> {
private RestAnnotationProcessor<VCloudXLogin> processor; public void testLogin() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudLogin.class.getMethod("login");
GeneratedHttpRequest<VCloudLogin> httpMethod = processor.createRequest(method);
public void testAuthenticate() throws SecurityException, NoSuchMethodException {
Method method = VCloudXLogin.class.getMethod("login");
HttpRequest httpMethod = processor.createRequest(method);
assertEquals(httpMethod.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1"); assertEquals(httpMethod.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1");
assertEquals(httpMethod.getHeaders().size(), 1); assertHeadersEqual(httpMethod, HttpHeaders.ACCEPT + ": " + MediaType.APPLICATION_XML + "\n");
assertEquals(httpMethod.getFirstHeaderOrNull(HttpHeaders.ACCEPT), MediaType.APPLICATION_XML); assertEntityEquals(httpMethod, null);
assertEquals(RestAnnotationProcessor.getParserOrThrowException(method),
ParseLoginResponseFromHeaders.class); assertResponseParserClassEquals(method, httpMethod, ParseLoginResponseFromHeaders.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
@Override
protected void checkFilters(GeneratedHttpRequest<VCloudLogin> httpMethod) {
assertEquals(httpMethod.getFilters().size(), 1); assertEquals(httpMethod.getFilters().size(), 1);
assertEquals(httpMethod.getFilters().get(0).getClass(), BasicAuthentication.class); assertEquals(httpMethod.getFilters().get(0).getClass(), BasicAuthentication.class);
} }
@BeforeClass @Override
void setupFactory() { protected TypeLiteral<RestAnnotationProcessor<VCloudLogin>> createTypeLiteral() {
Injector injector = Guice.createInjector(new AbstractModule() { return new TypeLiteral<RestAnnotationProcessor<VCloudLogin>>() {
};
}
@Override
protected Module createModule() {
return new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
bind(URI.class).annotatedWith(VCloudX.class).toInstance( bind(URI.class).annotatedWith(VCloud.class).toInstance(
URI.create("http://localhost:8080")); URI.create("http://localhost:8080"));
try { try {
bind(BasicAuthentication.class).toInstance(new BasicAuthentication("user", "pass")); bind(BasicAuthentication.class).toInstance(new BasicAuthentication("user", "pass"));
@ -92,11 +100,8 @@ public class VCloudXLoginTest {
} }
}); });
} }
}, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()),
new JavaUrlHttpCommandExecutorServiceModule()); };
processor = injector.getInstance(Key
.get(new TypeLiteral<RestAnnotationProcessor<VCloudXLogin>>() {
}));
} }
} }

View File

@ -21,15 +21,15 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.config; package org.jclouds.vcloud.config;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_ENDPOINT; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_KEY; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_KEY;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_SESSIONINTERVAL; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_SESSIONINTERVAL;
import static org.jclouds.vcloudx.reference.VCloudXConstants.PROPERTY_VCLOUDX_USER; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.net.URI; import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.HttpRetryHandler;
@ -39,8 +39,9 @@ import org.jclouds.http.handlers.DelegatingErrorHandler;
import org.jclouds.http.handlers.DelegatingRetryHandler; import org.jclouds.http.handlers.DelegatingRetryHandler;
import org.jclouds.http.handlers.RedirectionRetryHandler; import org.jclouds.http.handlers.RedirectionRetryHandler;
import org.jclouds.util.Jsr330; import org.jclouds.util.Jsr330;
import org.jclouds.vcloudx.VCloudXLogin; import org.jclouds.vcloud.VCloudLogin;
import org.jclouds.vcloudx.VCloudXLogin.VCloudXSession; import org.jclouds.vcloud.VCloudLogin.VCloudSession;
import org.jclouds.vcloud.domain.Link;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
@ -51,19 +52,19 @@ import com.google.inject.Injector;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "vcloudx.RestVCloudXAuthenticationModuleTest") @Test(groups = "unit", testName = "vcloud.RestVCloudAuthenticationModuleTest")
public class RestVCloudXAuthenticationModuleTest { public class RestVCloudAuthenticationModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new RestVCloudXAuthenticationModule(), new ParserModule(), return Guice.createInjector(new VCloudDiscoveryRestClientModule(), new ParserModule(),
new AbstractModule() { new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
bindConstant().annotatedWith(Jsr330.named(PROPERTY_VCLOUDX_USER)).to("user"); bindConstant().annotatedWith(Jsr330.named(PROPERTY_VCLOUD_USER)).to("user");
bindConstant().annotatedWith(Jsr330.named(PROPERTY_VCLOUDX_KEY)).to("secret"); bindConstant().annotatedWith(Jsr330.named(PROPERTY_VCLOUD_KEY)).to("secret");
bindConstant().annotatedWith(Jsr330.named(PROPERTY_VCLOUDX_ENDPOINT)).to( bindConstant().annotatedWith(Jsr330.named(PROPERTY_VCLOUD_ENDPOINT)).to(
"http://localhost"); "http://localhost");
bindConstant().annotatedWith(Jsr330.named(PROPERTY_VCLOUDX_SESSIONINTERVAL)) bindConstant().annotatedWith(Jsr330.named(PROPERTY_VCLOUD_SESSIONINTERVAL))
.to("2"); .to("2");
} }
}); });
@ -71,15 +72,15 @@ public class RestVCloudXAuthenticationModuleTest {
@Test @Test
void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException { void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException {
RestVCloudXAuthenticationModule module = new RestVCloudXAuthenticationModule(); VCloudDiscoveryRestClientModule module = new VCloudDiscoveryRestClientModule();
VCloudXLogin login = new VCloudXLogin() { VCloudLogin login = new VCloudLogin() {
private final AtomicInteger token = new AtomicInteger(); private final AtomicInteger token = new AtomicInteger();
public VCloudXSession login() { public VCloudSession login() {
return new VCloudXSession() { return new VCloudSession() {
public URI getOrg() { public Map<String, Link> getOrgs() {
return null; return null;
} }
@ -91,7 +92,7 @@ public class RestVCloudXAuthenticationModuleTest {
} }
}; };
Supplier<VCloudXSession> map = module.provideVCloudTokenCache(1, login); Supplier<VCloudSession> map = module.provideVCloudTokenCache(1, login);
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
map.get(); map.get();
assert "1".equals(map.get().getVCloudToken()); assert "1".equals(map.get().getVCloudToken());

View File

@ -21,7 +21,7 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.filters; package org.jclouds.vcloud.filters;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
@ -31,6 +31,7 @@ import javax.inject.Provider;
import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.HttpHeaders;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;

View File

@ -21,7 +21,7 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.functions; package org.jclouds.vcloud.functions;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
@ -31,9 +31,14 @@ import javax.ws.rs.core.HttpHeaders;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloudx.VCloudXLogin.VCloudXSession; import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudLogin.VCloudSession;
import org.jclouds.vcloud.domain.internal.LinkImpl;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@ -57,10 +62,11 @@ public class ParseLoginResponseFromHeadersTest extends BaseHandlerTest {
response.getHeaders().put(HttpHeaders.CONTENT_LENGTH, "307"); response.getHeaders().put(HttpHeaders.CONTENT_LENGTH, "307");
response.getHeaders().put(HttpHeaders.CONTENT_TYPE, response.getHeaders().put(HttpHeaders.CONTENT_TYPE,
"Content-Type: application/xml; charset=utf-8"); "Content-Type: application/xml; charset=utf-8");
VCloudXSession reply = parser.apply(response); VCloudSession reply = parser.apply(response);
assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2"); assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2");
assertEquals(reply.getOrg(), URI assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new LinkImpl(
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")); "adrian@jclouds.org", VCloudMediaType.ORG_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
} }

View File

@ -0,0 +1,137 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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.xml;
import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML;
import static org.testng.Assert.assertEquals;
import java.io.InputStream;
import java.net.URI;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.internal.LinkImpl;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
/**
* Tests behavior of {@code CatalogHandler}
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "vcloud.CatalogHandlerTest")
public class CatalogHandlerTest extends BaseHandlerTest {
@BeforeTest
@Override
protected void setUpInjector() {
super.setUpInjector();
}
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/catalog.xml");
Catalog result = (Catalog) factory.create(injector.getInstance(CatalogHandler.class)).parse(
is);
assertEquals(result.getName(), "Miami Environment 1");
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"));
assertEquals(result.getType(), "application/vnd.vmware.vcloud.catalog+xml");
assertEquals(result.get("CentOS 5.3 (32-bit)"), new LinkImpl("CentOS 5.3 (32-bit)",
CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/5")));
assertEquals(result.get("CentOS 5.3 (64-bit)"), new LinkImpl("CentOS 5.3 (64-bit)",
CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/6")));
assertEquals(result.get("RHEL 5.3 (32-bit)"), new LinkImpl("RHEL 5.3 (32-bit)",
CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/7")));
assertEquals(result.get("RHEL 5.3 (64-bit)"), new LinkImpl("RHEL 5.3 (64-bit)",
CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/8")));
assertEquals(result.get("Ubuntu JeOS 9.04 (32-bit)"), new LinkImpl(
"Ubuntu JeOS 9.04 (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/11")));
assertEquals(result.get("Ubuntu JeOS 9.04 (64-bit)"), new LinkImpl(
"Ubuntu JeOS 9.04 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/12")));
assertEquals(result.get("Ubuntu Server 9.04 (32-bit)"), new LinkImpl(
"Ubuntu Server 9.04 (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/9")));
assertEquals(result.get("Ubuntu Server 9.04 (64-bit)"), new LinkImpl(
"Ubuntu Server 9.04 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/10")));
assertEquals(result.get("Windows 2003 Enterprise R2 (32-bit)"), new LinkImpl(
"Windows 2003 Enterprise R2 (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/1")));
assertEquals(result.get("Windows 2003 Enterprise R2 (64-bit)"), new LinkImpl(
"Windows 2003 Enterprise R2 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/2")));
assertEquals(result.get("Windows 2003 Standard R2 (32-bit)"), new LinkImpl(
"Windows 2003 Standard R2 (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/3")));
assertEquals(result.get("Windows 2003 Standard R2 (64-bit)"), new LinkImpl(
"Windows 2003 Standard R2 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/4")));
assertEquals(result.get("Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"), new LinkImpl(
"Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/23")));
assertEquals(result.get("Windows Server 2008 Enterprise (32-bit)"), new LinkImpl(
"Windows Server 2008 Enterprise (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13")));
assertEquals(result.get("Windows Server 2008 Enterprise (64-bit)"), new LinkImpl(
"Windows Server 2008 Enterprise (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15")));
assertEquals(result.get("Windows Server 2008 Enterprise R2 (64-bit)"), new LinkImpl(
"Windows Server 2008 Enterprise R2 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16")));
assertEquals(result.get("Windows Server 2008 Standard (32-bit)"), new LinkImpl(
"Windows Server 2008 Standard (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17")));
assertEquals(result.get("Windows Server 2008 Standard (64-bit)"), new LinkImpl(
"Windows Server 2008 Standard (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18")));
assertEquals(result.get("Windows Server 2008 Standard R2 (64-bit)"), new LinkImpl(
"Windows Server 2008 Standard R2 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/19")));
assertEquals(
result.get("Windows Server 2008 Standard w.SQL 2008 Web (64-bit)"),
new LinkImpl(
"Windows Server 2008 Standard w.SQL 2008 Web (64-bit)",
CATALOGITEM_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/14")));
assertEquals(result.get("Windows Web Server 2008 (32-bit)"), new LinkImpl(
"Windows Web Server 2008 (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/20")));
assertEquals(result.get("Windows Web Server 2008 (64-bit)"), new LinkImpl(
"Windows Web Server 2008 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21")));
assertEquals(result.get("Windows Web Server 2008 R2 (64-bit)"), new LinkImpl(
"Windows Web Server 2008 R2 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22")));
}
}

View File

@ -21,27 +21,32 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.xml; package org.jclouds.vcloud.xml;
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI; import java.net.URI;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloudx.domain.OrgLinks; import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.internal.LinkImpl;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.Sets; import com.google.common.collect.ImmutableMap;
/** /**
* Tests behavior of {@code OrgLinksHandler} * Tests behavior of {@code OrgHandler}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "vcloudx.OrgLinksHandlerTest") @Test(groups = "unit", testName = "vcloud.OrgHandlerTest")
public class OrgLinksHandlerTest extends BaseHandlerTest { public class OrgHandlerTest extends BaseHandlerTest {
@BeforeTest @BeforeTest
@Override @Override
@ -52,16 +57,26 @@ public class OrgLinksHandlerTest extends BaseHandlerTest {
public void testApplyInputStream() { public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/org.xml"); InputStream is = getClass().getResourceAsStream("/org.xml");
OrgLinks result = (OrgLinks) factory.create(injector.getInstance(OrgLinksHandler.class)) Organization result = (Organization) factory.create(injector.getInstance(OrgHandler.class))
.parse(is); .parse(is);
assertEquals(result.getName(), "adrian@jclouds.org"); assertEquals(result.getName(), "adrian@jclouds.org");
assertEquals(result.getOrg(), URI assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")); .create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"));
assertEquals(result.getCatalog(), URI assertEquals(result.getType(), ORG_XML);
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")); assertEquals(result.getCatalog(), new LinkImpl("Miami Environment 1 Catalog", CATALOG_XML, URI
assertEquals(result.getVDCs(), Sets.newHashSet(URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")));
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))); assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new LinkImpl(
assertEquals(result.getTaskLists(), Sets.newHashSet(URI "Miami Environment 1", VCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/32"))); .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))));
assertEquals(
result.getTasksLists(),
ImmutableMap
.of(
"Miami Environment 1 Tasks List",
new LinkImpl(
"Miami Environment 1 Tasks List",
TASKSLIST_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/32"))));
} }
} }

View File

@ -21,24 +21,30 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloudx.xml; package org.jclouds.vcloud.xml;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI; import java.net.URI;
import java.util.Map;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Link;
import org.jclouds.vcloud.domain.internal.LinkImpl;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
/** /**
* Tests behavior of {@code OrgListToOrgUriHandler} * Tests behavior of {@code OrgListHandler}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "vcloudx.OrgListToOrgUriHandlerTest") @Test(groups = "unit", testName = "vcloud.OrgListHandlerTest")
public class OrgListToOrgUriHandlerTest extends BaseHandlerTest { public class OrgListHandlerTest extends BaseHandlerTest {
@BeforeTest @BeforeTest
@Override @Override
@ -49,9 +55,10 @@ public class OrgListToOrgUriHandlerTest extends BaseHandlerTest {
public void testApplyInputStream() { public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/orglist.xml"); InputStream is = getClass().getResourceAsStream("/orglist.xml");
URI result = (URI) factory.create(injector.getInstance(OrgListToOrgUriHandler.class)).parse( Map<String, Link> result = factory.create(injector.getInstance(OrgListHandler.class)).parse(
is); is);
assertEquals(result, URI assertEquals(result, ImmutableMap.of("adrian@jclouds.org", new LinkImpl("adrian@jclouds.org",
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")); VCloudMediaType.ORG_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
} }
} }

View File

@ -0,0 +1,27 @@
<Catalog href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog" type="application/vnd.vmware.vcloud.catalog+xml" name="Miami Environment 1" xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CatalogItems>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/5" type="application/vnd.vmware.vcloud.catalogItem+xml" name="CentOS 5.3 (32-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/6" type="application/vnd.vmware.vcloud.catalogItem+xml" name="CentOS 5.3 (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/7" type="application/vnd.vmware.vcloud.catalogItem+xml" name="RHEL 5.3 (32-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/8" type="application/vnd.vmware.vcloud.catalogItem+xml" name="RHEL 5.3 (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/11" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Ubuntu JeOS 9.04 (32-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/12" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Ubuntu JeOS 9.04 (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/9" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Ubuntu Server 9.04 (32-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/10" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Ubuntu Server 9.04 (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/1" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Enterprise R2 (32-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/2" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Enterprise R2 (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/3" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Standard R2 (32-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/4" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Standard R2 (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/23" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Enterprise (32-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Enterprise (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Enterprise R2 (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Standard (32-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Standard (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/19" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Standard R2 (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/14" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Standard w.SQL 2008 Web (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/20" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Web Server 2008 (32-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Web Server 2008 (64-bit)"/>
<CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Web Server 2008 R2 (64-bit)"/>
</CatalogItems>
</Catalog>

View File

@ -98,13 +98,12 @@
<priority value="DEBUG" /> <priority value="DEBUG" />
<appender-ref ref="ASYNCWIRE" /> <appender-ref ref="ASYNCWIRE" />
</category> </category>
<!--
<category name="jclouds.http.wire"> <category name="jclouds.http.wire">
<priority value="DEBUG" /> <priority value="DEBUG" />
<appender-ref ref="ASYNCWIRE" /> <appender-ref ref="ASYNCWIRE" />
</category> </category>
--><!-- ======================= --> <!-- ======================= -->
<!-- Setup the Root category --> <!-- Setup the Root category -->
<!-- ======================= --> <!-- ======================= -->

View File

@ -0,0 +1,10 @@
<Vdc href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32" type="application/vnd.vmware.vcloud.vdc+xml" name="Miami Environment 1" xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog" type="application/vnd.vmware.vcloud.catalog+xml" name="Miami Environment 1"/>
<Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps" type="application/xml" name="Public IPs"/>
<Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/internetServices" type="application/xml" name="Internet Services"/>
<Description/>
<ResourceEntities/>
<AvailableNetworks>
<Network href="https://services.vcloudexpress.terremark.com/api/v0.8/network/1708" type="application/vnd.vmware.vcloud.network+xml" name="10.114.34.128/26"/>
</AvailableNetworks>
</Vdc>

View File

@ -33,9 +33,9 @@
<relativePath>../project/pom.xml</relativePath> <relativePath>../project/pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>jclouds-vcloudx-project</artifactId> <artifactId>jclouds-vcloud-project</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>jclouds vcloudx project</name> <name>jclouds vcloud project</name>
<modules> <modules>
<module>core</module> <module>core</module>
</modules> </modules>