Issue 112: moved NamedResource to vcloud as it is only used there. added id-based getVDC and getTasksList

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2471 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-12-19 08:30:53 +00:00
parent 410b5f76e3
commit 98371e6b37
55 changed files with 381 additions and 843 deletions

View File

@ -1,45 +0,0 @@
/**
*
* 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.rest.domain;
import java.net.URI;
import org.jclouds.rest.domain.internal.LinkImpl;
import com.google.inject.ImplementedBy;
/**
* Location of a Rest resource
*
* @author Adrian Cole
*
*/
@ImplementedBy(LinkImpl.class)
public interface Link {
String getType();
URI getLocation();
}

View File

@ -1,41 +0,0 @@
/**
*
* 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.rest.domain;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import com.google.inject.ImplementedBy;
/**
* Location of a Rest resource
*
* @author Adrian Cole
*
*/
@ImplementedBy(NamedLinkImpl.class)
public interface NamedLink extends Link {
String getName();
}

View File

@ -1,79 +0,0 @@
/**
*
* 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.rest.domain.internal;
import java.net.URI;
import org.jclouds.rest.domain.NamedLink;
/**
* Location of a Rest resource
*
* @author Adrian Cole
*
*/
public class NamedLinkImpl extends LinkImpl implements NamedLink {
private final String name;
public NamedLinkImpl(String name, String type, URI location) {
super(type, location);
this.name = name;
}
public String getName() {
return name;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((name == null) ? 0 : name.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;
NamedLinkImpl other = (NamedLinkImpl) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
@Override
public String toString() {
return "NamedLinkImpl [name=" + name + ", getLocation()=" + getLocation() + ", getType()="
+ getType() + "]";
}
}

View File

@ -1,83 +0,0 @@
/**
*
* 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.rest.internal;
import java.net.URI;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
/**
* Location of a Rest resource
*
* @author Adrian Cole
*
*/
public class NamedResourceImpl extends NamedLinkImpl implements NamedResource {
private final String id;
public NamedResourceImpl(String id, String name, String type, URI location) {
super(name, type, location);
this.id = id;
}
public String getId() {
return id;
}
public int compareTo(NamedResource that) {
return (this == that) ? 0 : this.id.compareTo(that.getId());
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((id == null) ? 0 : id.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;
NamedResourceImpl other = (NamedResourceImpl) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
@Override
public String toString() {
return "NamedResourceImpl [id=" + id + ", name=" + getName() + ", location="
+ getLocation() + ", type=" + getType() + "]";
}
}

View File

@ -85,12 +85,26 @@ public interface VCloudAsyncClient {
@XMLResponseParser(CatalogHandler.class)
Future<? extends Catalog> getCatalog();
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vdc/{vDCId}")
@XMLResponseParser(VDCHandler.class)
@Consumes(VDC_XML)
Future<? extends VDC> getVDC(@PathParam("vDCId") String vDCId);
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
@XMLResponseParser(VDCHandler.class)
@Consumes(VDC_XML)
Future<? extends VDC> getDefaultVDC();
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/tasksList/{tasksListId}")
@Consumes(TASKSLIST_XML)
@XMLResponseParser(TasksListHandler.class)
Future<? extends TasksList> getTasksList(@PathParam("tasksListId") String tasksListId);
@GET
@Endpoint(org.jclouds.vcloud.endpoints.TasksList.class)
@Consumes(TASKSLIST_XML)

View File

@ -51,8 +51,12 @@ public interface VCloudClient {
Catalog getCatalog();
VDC getVDC(String vDCId);
VDC getDefaultVDC();
TasksList getTasksList(String tasksListId);
TasksList getDefaultTasksList();
Task deployVApp(String vAppId);

View File

@ -23,10 +23,8 @@
*/
package org.jclouds.vcloud.domain;
import java.net.URI;
import java.util.Map;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.CatalogImpl;
import com.google.inject.ImplementedBy;
@ -36,10 +34,8 @@ import com.google.inject.ImplementedBy;
*/
@org.jclouds.vcloud.endpoints.Catalog
@ImplementedBy(CatalogImpl.class)
public interface Catalog extends Map<String, NamedResource> {
String getName();
public interface Catalog extends NamedResource, Map<String, NamedResource> {
String getDescription();
URI getLocation();
}

View File

@ -21,9 +21,11 @@
* under the License.
* ====================================================================
*/
package org.jclouds.rest.domain;
package org.jclouds.vcloud.domain;
import org.jclouds.rest.internal.NamedResourceImpl;
import java.net.URI;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import com.google.inject.ImplementedBy;
@ -34,6 +36,12 @@ import com.google.inject.ImplementedBy;
*
*/
@ImplementedBy(NamedResourceImpl.class)
public interface NamedResource extends NamedLink, Comparable<NamedResource> {
public interface NamedResource extends Comparable<NamedResource> {
String getId();
String getName();
String getType();
URI getLocation();
}

View File

@ -23,11 +23,8 @@
*/
package org.jclouds.vcloud.domain;
import java.net.URI;
import java.util.Map;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.vcloud.domain.internal.OrganizationImpl;
import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.Org;
@ -41,20 +38,15 @@ import com.google.inject.ImplementedBy;
*/
@Org
@ImplementedBy(OrganizationImpl.class)
public interface Organization {
String getName();
String getId();
URI getLocation();
public interface Organization extends NamedResource {
@Catalog
Link getCatalog();
NamedResource getCatalog();
@VDC
Map<String, NamedLink> getVDCs();
Map<String, NamedResource> getVDCs();
@TasksList
Map<String, NamedLink> getTasksLists();
Map<String, NamedResource> getTasksLists();
}

View File

@ -26,7 +26,6 @@ package org.jclouds.vcloud.domain;
import java.net.URI;
import java.util.Date;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.TaskImpl;
import com.google.inject.ImplementedBy;
@ -36,17 +35,23 @@ import com.google.inject.ImplementedBy;
*/
@ImplementedBy(TaskImpl.class)
public interface Task extends Comparable<Task> {
String getId();
String getId();
URI getLocation();
URI getLocation();
TaskStatus getStatus();
TaskStatus getStatus();
Date getStartTime();
Date getStartTime();
Date getEndTime();
Date getEndTime();
NamedResource getOwner();
/**
* A link to the vDC in which the task was started
*/
NamedResource getOwner();
NamedResource getResult();
/**
* A link to the result of the task
*/
NamedResource getResult();
}

View File

@ -37,6 +37,8 @@ import com.google.inject.ImplementedBy;
@org.jclouds.vcloud.endpoints.TasksList
@ImplementedBy(TasksListImpl.class)
public interface TasksList {
String getId();
URI getLocation();
SortedSet<Task> getTasks();

View File

@ -1,348 +0,0 @@
/**
*
* 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 static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Adrian Cole
*/
public class TerremarkResourceAllocation implements Comparable<TerremarkResourceAllocation> {
private final Integer address;
private final Integer addressOnParent;
private final String allocationUnits;
private final String automaticAllocation;
private final String automaticDeallocation;
private final String caption;
private final String consumerVisibility;
private final String description;
private final String elementName;
private final String hostResource;
private final int instanceID;
private final String limit;
private final String mappingBehavior;
private final String otherResourceType;
private final Integer parent;
private final String poolID;
private final String reservation;
private final String resourceSubType;
private final ResourceType resourceType;
private final long virtualQuantity;
private final String virtualQuantityUnits;
private final String weight;
public TerremarkResourceAllocation(Integer address, Integer addressOnParent, String allocationUnits,
String automaticAllocation, String automaticDeallocation, String caption,
String consumerVisibility, String description, String elementName, String hostResource,
int instanceID, String limit, String mappingBehavior, String otherResourceType,
Integer parent, String poolID, String reservation, String resourceSubType,
ResourceType resourceType, long virtualQuantity, String virtualQuantityUnits,
String weight) {
this.address = address;
this.addressOnParent = addressOnParent;
this.allocationUnits = allocationUnits;
this.automaticAllocation = automaticAllocation;
this.automaticDeallocation = automaticDeallocation;
this.caption = caption;
this.consumerVisibility = consumerVisibility;
this.description = description;
this.elementName = elementName;
this.hostResource = hostResource;
this.instanceID = checkNotNull(instanceID, "instanceID");
this.limit = limit;
this.mappingBehavior = mappingBehavior;
this.otherResourceType = otherResourceType;
this.parent = parent;
this.poolID = poolID;
this.reservation = reservation;
this.resourceSubType = resourceSubType;
this.resourceType = checkNotNull(resourceType, "resourceType");
this.virtualQuantity = virtualQuantity;
this.virtualQuantityUnits = virtualQuantityUnits;
this.weight = weight;
}
public Integer getAddress() {
return address;
}
public Integer getAddressOnParent() {
return addressOnParent;
}
public String getAllocationUnits() {
return allocationUnits;
}
public String getAutomaticAllocation() {
return automaticAllocation;
}
public String getAutomaticDeallocation() {
return automaticDeallocation;
}
public String getCaption() {
return caption;
}
public String getConsumerVisibility() {
return consumerVisibility;
}
public String getDescription() {
return description;
}
public String getElementName() {
return elementName;
}
public int getInstanceID() {
return instanceID;
}
public String getLimit() {
return limit;
}
public String getMappingBehavior() {
return mappingBehavior;
}
public String getOtherResourceType() {
return otherResourceType;
}
public Integer getParent() {
return parent;
}
public String getPoolID() {
return poolID;
}
public String getReservation() {
return reservation;
}
public String getResourceSubType() {
return resourceSubType;
}
public ResourceType getResourceType() {
return resourceType;
}
public long getVirtualQuantity() {
return virtualQuantity;
}
public String getVirtualQuantityUnits() {
return virtualQuantityUnits;
}
public String getWeight() {
return weight;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((address == null) ? 0 : address.hashCode());
result = prime * result + ((addressOnParent == null) ? 0 : addressOnParent.hashCode());
result = prime * result + ((allocationUnits == null) ? 0 : allocationUnits.hashCode());
result = prime * result
+ ((automaticAllocation == null) ? 0 : automaticAllocation.hashCode());
result = prime * result
+ ((automaticDeallocation == null) ? 0 : automaticDeallocation.hashCode());
result = prime * result + ((caption == null) ? 0 : caption.hashCode());
result = prime * result + ((consumerVisibility == null) ? 0 : consumerVisibility.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((elementName == null) ? 0 : elementName.hashCode());
result = prime * result + instanceID;
result = prime * result + ((limit == null) ? 0 : limit.hashCode());
result = prime * result + ((mappingBehavior == null) ? 0 : mappingBehavior.hashCode());
result = prime * result + ((otherResourceType == null) ? 0 : otherResourceType.hashCode());
result = prime * result + ((parent == null) ? 0 : parent.hashCode());
result = prime * result + ((poolID == null) ? 0 : poolID.hashCode());
result = prime * result + ((reservation == null) ? 0 : reservation.hashCode());
result = prime * result + ((resourceSubType == null) ? 0 : resourceSubType.hashCode());
result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode());
result = prime * result + (int) (virtualQuantity ^ (virtualQuantity >>> 32));
result = prime * result
+ ((virtualQuantityUnits == null) ? 0 : virtualQuantityUnits.hashCode());
result = prime * result + ((weight == null) ? 0 : weight.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TerremarkResourceAllocation other = (TerremarkResourceAllocation) obj;
if (address == null) {
if (other.address != null)
return false;
} else if (!address.equals(other.address))
return false;
if (addressOnParent == null) {
if (other.addressOnParent != null)
return false;
} else if (!addressOnParent.equals(other.addressOnParent))
return false;
if (allocationUnits == null) {
if (other.allocationUnits != null)
return false;
} else if (!allocationUnits.equals(other.allocationUnits))
return false;
if (automaticAllocation == null) {
if (other.automaticAllocation != null)
return false;
} else if (!automaticAllocation.equals(other.automaticAllocation))
return false;
if (automaticDeallocation == null) {
if (other.automaticDeallocation != null)
return false;
} else if (!automaticDeallocation.equals(other.automaticDeallocation))
return false;
if (caption == null) {
if (other.caption != null)
return false;
} else if (!caption.equals(other.caption))
return false;
if (consumerVisibility == null) {
if (other.consumerVisibility != null)
return false;
} else if (!consumerVisibility.equals(other.consumerVisibility))
return false;
if (description == null) {
if (other.description != null)
return false;
} else if (!description.equals(other.description))
return false;
if (elementName == null) {
if (other.elementName != null)
return false;
} else if (!elementName.equals(other.elementName))
return false;
if (instanceID != other.instanceID)
return false;
if (limit == null) {
if (other.limit != null)
return false;
} else if (!limit.equals(other.limit))
return false;
if (mappingBehavior == null) {
if (other.mappingBehavior != null)
return false;
} else if (!mappingBehavior.equals(other.mappingBehavior))
return false;
if (otherResourceType == null) {
if (other.otherResourceType != null)
return false;
} else if (!otherResourceType.equals(other.otherResourceType))
return false;
if (parent == null) {
if (other.parent != null)
return false;
} else if (!parent.equals(other.parent))
return false;
if (poolID == null) {
if (other.poolID != null)
return false;
} else if (!poolID.equals(other.poolID))
return false;
if (reservation == null) {
if (other.reservation != null)
return false;
} else if (!reservation.equals(other.reservation))
return false;
if (resourceSubType == null) {
if (other.resourceSubType != null)
return false;
} else if (!resourceSubType.equals(other.resourceSubType))
return false;
if (resourceType == null) {
if (other.resourceType != null)
return false;
} else if (!resourceType.equals(other.resourceType))
return false;
if (virtualQuantity != other.virtualQuantity)
return false;
if (virtualQuantityUnits == null) {
if (other.virtualQuantityUnits != null)
return false;
} else if (!virtualQuantityUnits.equals(other.virtualQuantityUnits))
return false;
if (weight == null) {
if (other.weight != null)
return false;
} else if (!weight.equals(other.weight))
return false;
return true;
}
@Override
public String toString() {
return "ResourceAllocation [address=" + address + ", addressOnParent=" + addressOnParent
+ ", allocationUnits=" + allocationUnits + ", automaticAllocation="
+ automaticAllocation + ", automaticDeallocation=" + automaticDeallocation
+ ", caption=" + caption + ", consumerVisibility=" + consumerVisibility
+ ", description=" + description + ", elementName=" + elementName + ", instanceID="
+ instanceID + ", limit=" + limit + ", mappingBehavior=" + mappingBehavior
+ ", otherResourceType=" + otherResourceType + ", parent=" + parent + ", poolID="
+ poolID + ", reservation=" + reservation + ", resourceSubType=" + resourceSubType
+ ", resourceType=" + resourceType + ", virtualQuantity=" + virtualQuantity
+ ", virtualQuantityUnits=" + virtualQuantityUnits + ", weight=" + weight + "]";
}
public int compareTo(TerremarkResourceAllocation that) {
final int BEFORE = -1;
final int EQUAL = 0;
final int AFTER = 1;
if (this == that)
return EQUAL;
int comparison = this.resourceType.compareTo(that.resourceType);
if (comparison != EQUAL)
return comparison;
if (this.instanceID < that.instanceID)
return BEFORE;
if (this.instanceID > that.instanceID)
return AFTER;
return EQUAL;
}
public String getHostResource() {
return hostResource;
}
}

View File

@ -24,18 +24,20 @@
package org.jclouds.vcloud.domain;
import java.net.InetAddress;
import java.net.URI;
import java.util.Map;
import java.util.SortedSet;
import com.google.common.collect.ListMultimap;
public interface VApp {
String getId();
URI getLocation();
String getName();
/**
* A virtual application (vApp) is a software solution, packaged in OVF containing one or more
* virtual machines. A vApp can be authored by Developers at ISVs and VARs or by IT Administrators
* in Enterprises and Service Providers.
*
* @author Adrian Cole
*/
public interface VApp extends NamedResource {
VAppStatus getStatus();

View File

@ -23,10 +23,8 @@
*/
package org.jclouds.vcloud.domain;
import java.net.URI;
import java.util.Map;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.VDCImpl;
import com.google.inject.ImplementedBy;
@ -36,13 +34,7 @@ import com.google.inject.ImplementedBy;
*/
@org.jclouds.vcloud.endpoints.VDC
@ImplementedBy(VDCImpl.class)
public interface VDC {
String getName();
String getId();
URI getLocation();
public interface VDC extends NamedResource {
String getDescription();

View File

@ -29,8 +29,9 @@ import java.net.URI;
import java.util.SortedMap;
import java.util.TreeMap;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.NamedResource;
import com.google.inject.internal.Nullable;
@ -44,13 +45,14 @@ public class CatalogImpl extends TreeMap<String, NamedResource> implements Catal
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
private final String id;
private final String name;
private final String description;
private final URI location;
public CatalogImpl(String name, URI location, @Nullable String description,
public CatalogImpl(String id, String name, URI location, @Nullable String description,
SortedMap<String, NamedResource> contents) {
super();
this.id = checkNotNull(id, "id");
this.name = checkNotNull(name, "name");
this.description = description;
this.location = checkNotNull(location, "location");
@ -61,6 +63,10 @@ public class CatalogImpl extends TreeMap<String, NamedResource> implements Catal
return location;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
@ -106,4 +112,14 @@ public class CatalogImpl extends TreeMap<String, NamedResource> implements Catal
return description;
}
@Override
public String getType() {
return VCloudMediaType.CATALOG_XML;
}
@Override
public int compareTo(NamedResource o) {
return (this == o) ? 0 : getId().compareTo(o.getId());
}
}

View File

@ -21,11 +21,11 @@
* under the License.
* ====================================================================
*/
package org.jclouds.rest.domain.internal;
package org.jclouds.vcloud.domain.internal;
import java.net.URI;
import org.jclouds.rest.domain.Link;
import org.jclouds.vcloud.domain.NamedResource;
/**
* Location of a Rest resource
@ -33,15 +33,27 @@ import org.jclouds.rest.domain.Link;
* @author Adrian Cole
*
*/
public class LinkImpl implements Link {
public class NamedResourceImpl implements NamedResource {
private final String id;
private final String name;
private final String type;
private final URI location;
public LinkImpl(String type, URI location) {
public NamedResourceImpl(String id, String name, String type, URI location) {
this.id = id;
this.name = name;
this.type = type;
this.location = location;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public String getType() {
return type;
}
@ -50,11 +62,17 @@ public class LinkImpl implements Link {
return location;
}
public int compareTo(NamedResource that) {
return (this == that) ? 0 : this.id.compareTo(that.getId());
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
@ -67,12 +85,22 @@ public class LinkImpl implements Link {
return false;
if (getClass() != obj.getClass())
return false;
LinkImpl other = (LinkImpl) obj;
NamedResourceImpl other = (NamedResourceImpl) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (location == null) {
if (other.location != null)
return false;
} else if (!location.equals(other.location))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (type == null) {
if (other.type != null)
return false;
@ -83,6 +111,7 @@ public class LinkImpl implements Link {
@Override
public String toString() {
return "LinkImpl [location=" + location + ", type=" + type + "]";
return "NamedResourceImpl [id=" + id + ", name=" + name + ", type=" + type + ", location="
+ location + "]";
}
}

View File

@ -26,7 +26,8 @@ package org.jclouds.vcloud.domain.internal;
import java.net.URI;
import java.util.Map;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.TasksList;
@ -42,12 +43,12 @@ public class OrganizationImpl implements Organization {
private final String id;
private final String name;
private final URI location;
private final NamedLink catalog;
private final Map<String, NamedLink> vdcs;
private final Map<String, NamedLink> tasksLists;
private final NamedResource catalog;
private final Map<String, NamedResource> vdcs;
private final Map<String, NamedResource> tasksLists;
public OrganizationImpl(String id, String name, URI location, NamedLink catalog,
Map<String, NamedLink> vdcs, Map<String, NamedLink> tasksLists) {
public OrganizationImpl(String id, String name, URI location, NamedResource catalog,
Map<String, NamedResource> vdcs, Map<String, NamedResource> tasksLists) {
this.id = id;
this.name = name;
this.location = location;
@ -67,19 +68,19 @@ public class OrganizationImpl implements Organization {
public URI getLocation() {
return location;
}
@Catalog
public NamedLink getCatalog() {
public NamedResource getCatalog() {
return catalog;
}
@VDC
public Map<String, NamedLink> getVDCs() {
public Map<String, NamedResource> getVDCs() {
return vdcs;
}
@TasksList
public Map<String, NamedLink> getTasksLists() {
public Map<String, NamedResource> getTasksLists() {
return tasksLists;
}
@ -138,5 +139,13 @@ public class OrganizationImpl implements Organization {
return true;
}
@Override
public String getType() {
return VCloudMediaType.ORG_XML;
}
public int compareTo(NamedResource o) {
return (this == o) ? 0 : getId().compareTo(o.getId());
}
}

View File

@ -28,7 +28,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Date;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;

View File

@ -42,7 +42,7 @@ import com.google.common.collect.Multimaps;
*
*/
public class TasksListImpl implements TasksList {
private final String id;
private final SortedSet<Task> tasks;
private final ListMultimap<URI, Task> tasksByResult;
private final ListMultimap<URI, Task> tasksByOwner;
@ -51,7 +51,8 @@ public class TasksListImpl implements TasksList {
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
public TasksListImpl(URI location, SortedSet<Task> tasks) {
public TasksListImpl(String id, URI location, SortedSet<Task> tasks) {
this.id = id;
this.location = location;
this.tasks = tasks;
this.tasksByResult = Multimaps.index(Iterables.filter(tasks, new Predicate<Task>() {
@ -94,8 +95,10 @@ public class TasksListImpl implements TasksList {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
result = prime * result + ((tasksByOwner == null) ? 0 : tasksByOwner.hashCode());
result = prime * result + ((tasksByResult == null) ? 0 : tasksByResult.hashCode());
return result;
}
@ -109,6 +112,11 @@ public class TasksListImpl implements TasksList {
if (getClass() != obj.getClass())
return false;
TasksListImpl other = (TasksListImpl) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (location == null) {
if (other.location != null)
return false;
@ -119,6 +127,11 @@ public class TasksListImpl implements TasksList {
return false;
} else if (!tasks.equals(other.tasks))
return false;
if (tasksByOwner == null) {
if (other.tasksByOwner != null)
return false;
} else if (!tasksByOwner.equals(other.tasksByOwner))
return false;
if (tasksByResult == null) {
if (other.tasksByResult != null)
return false;
@ -134,4 +147,9 @@ public class TasksListImpl implements TasksList {
public ListMultimap<URI, Task> getTasksByOwner() {
return tasksByOwner;
}
@Override
public String getId() {
return id;
}
}

View File

@ -28,6 +28,8 @@ import java.net.URI;
import java.util.Map;
import java.util.SortedSet;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VApp;
@ -39,7 +41,6 @@ import com.google.common.collect.ListMultimap;
import com.google.common.collect.Maps;
/**
* Locations of resources in vCloud
*
* @author Adrian Cole
*
@ -212,4 +213,13 @@ public class VAppImpl implements VApp {
+ ", size=" + size + ", status=" + status + ", system=" + system + "]";
}
@Override
public String getType() {
return VCloudMediaType.VAPP_XML;
}
@Override
public int compareTo(NamedResource o) {
return (this == o) ? 0 : getId().compareTo(o.getId());
}
}

View File

@ -28,8 +28,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Capacity;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Quota;
import org.jclouds.vcloud.domain.VDC;
@ -203,4 +204,14 @@ public class VDCImpl implements VDC {
public Quota getDeployedVmsQuota() {
return deployedVmsQuota;
}
@Override
public String getType() {
return VCloudMediaType.VDC_XML;
}
@Override
public int compareTo(NamedResource o) {
return (this == o) ? 0 : getId().compareTo(o.getId());
}
}

View File

@ -38,8 +38,8 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpResponseException;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.VCloudToken;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
import org.jclouds.vcloud.xml.OrgListHandler;

View File

@ -33,9 +33,9 @@ import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudToken;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;

View File

@ -21,17 +21,13 @@
* under the License.
* ====================================================================
*/
package org.jclouds.rest.util;
package org.jclouds.vcloud.util;
import java.net.URI;
import java.util.Map;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.xml.sax.Attributes;
/**
@ -40,20 +36,6 @@ import org.xml.sax.Attributes;
*/
public class Utils {
public static void putNamedLink(Map<String, NamedLink> map, Attributes attributes) {
map.put(attributes.getValue(attributes.getIndex("name")), newNamedLink(attributes));
}
public static Link newLink(Attributes attributes) {
return new LinkImpl(attributes.getValue(attributes.getIndex("type")), URI.create(attributes
.getValue(attributes.getIndex("href"))));
}
public static NamedLink newNamedLink(Attributes attributes) {
return new NamedLinkImpl(attributes.getValue(attributes.getIndex("name")), attributes
.getValue(attributes.getIndex("type")), URI.create(attributes.getValue(attributes
.getIndex("href"))));
}
public static NamedResource newNamedResource(Attributes attributes) {
String uri = attributes.getValue(attributes.getIndex("href"));

View File

@ -30,13 +30,12 @@ import java.util.SortedMap;
import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.CatalogImpl;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.internal.CatalogItemRoot;
import org.jclouds.vcloud.util.Utils;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@ -48,7 +47,7 @@ import com.google.common.collect.Maps;
public class CatalogHandler extends ParseSax.HandlerWithResult<Catalog> {
private StringBuilder currentText = new StringBuilder();
private NamedLink Catalog;
private NamedResource catalog;
private SortedMap<String, NamedResource> contents = Maps.newTreeMap();
@Inject
@CatalogItemRoot
@ -57,16 +56,15 @@ public class CatalogHandler extends ParseSax.HandlerWithResult<Catalog> {
private String description;
public Catalog getResult() {
return new CatalogImpl(Catalog.getName(), Catalog.getLocation(), description, contents);
return new CatalogImpl(catalog.getId(), catalog.getName(), catalog.getLocation(),
description, contents);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
if (qName.equals("Catalog")) {
Catalog = new NamedLinkImpl(attributes.getValue(attributes.getIndex("name")), attributes
.getValue(attributes.getIndex("type")), URI.create(attributes.getValue(attributes
.getIndex("href"))));
catalog = Utils.newNamedResource(attributes);
} else if (qName.equals("CatalogItem")) {
putNamedResource(contents, attributes);
}

View File

@ -23,24 +23,18 @@
*/
package org.jclouds.vcloud.xml;
import static org.jclouds.rest.util.Utils.newNamedLink;
import static org.jclouds.rest.util.Utils.putNamedLink;
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
import static org.jclouds.vcloud.util.Utils.newNamedResource;
import static org.jclouds.vcloud.util.Utils.putNamedResource;
import java.net.URI;
import java.util.Map;
import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.internal.OrganizationImpl;
import org.jclouds.vcloud.endpoints.VCloudApi;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@ -51,12 +45,9 @@ import com.google.common.collect.Maps;
*/
public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
private NamedResource org;
private Map<String, NamedLink> vdcs = Maps.newHashMap();
private Map<String, NamedLink> tasksLists = Maps.newHashMap();
private NamedLink catalog;
@Inject
@VCloudApi
URI vcloudUri;
private Map<String, NamedResource> vdcs = Maps.newHashMap();
private Map<String, NamedResource> tasksLists = Maps.newHashMap();
private NamedResource catalog;
public Organization getResult() {
return new OrganizationImpl(org.getId(), org.getName(), org.getLocation(), catalog, vdcs,
@ -72,21 +63,13 @@ public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
int typeIndex = attributes.getIndex("type");
if (typeIndex != -1) {
if (attributes.getValue(typeIndex).equals(VDC_XML)) {
putNamedLink(vdcs, attributes);
putNamedResource(vdcs, attributes);
} else if (attributes.getValue(typeIndex).equals(CATALOG_XML)) {
catalog = newNamedLink(attributes);
catalog = newNamedResource(attributes);
} else if (attributes.getValue(typeIndex).equals(TASKSLIST_XML)) {
putNamedLink(tasksLists, attributes);
putNamedResource(tasksLists, attributes);
}
}
}
}
public NamedResource newNamedResource(Attributes attributes) {
return new NamedResourceImpl(attributes.getValue(attributes.getIndex("href")).replace(
vcloudUri.toASCIIString() + "/org/", ""), attributes.getValue(attributes
.getIndex("name")), attributes.getValue(attributes.getIndex("type")), URI
.create(attributes.getValue(attributes.getIndex("href"))));
}
}

View File

@ -23,13 +23,13 @@
*/
package org.jclouds.vcloud.xml;
import static org.jclouds.rest.util.Utils.putNamedResource;
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
import static org.jclouds.vcloud.util.Utils.putNamedResource;
import java.util.Map;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.NamedResource;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

View File

@ -32,11 +32,11 @@ import javax.inject.Inject;
import org.jclouds.date.DateService;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.logging.Logger;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.rest.util.Utils;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.internal.TaskImpl;
import org.jclouds.vcloud.util.Utils;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

View File

@ -23,16 +23,16 @@
*/
package org.jclouds.vcloud.xml;
import java.net.URI;
import java.util.SortedSet;
import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.util.Utils;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TasksList;
import org.jclouds.vcloud.domain.internal.TasksListImpl;
import org.jclouds.vcloud.util.Utils;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@ -45,7 +45,7 @@ public class TasksListHandler extends ParseSax.HandlerWithResult<TasksList> {
private SortedSet<Task> tasks = Sets.newTreeSet();
private final TaskHandler taskHandler;
private URI location;
private NamedResource resource;
@Inject
public TasksListHandler(TaskHandler taskHandler) {
@ -53,17 +53,17 @@ public class TasksListHandler extends ParseSax.HandlerWithResult<TasksList> {
}
public TasksList getResult() {
return new TasksListImpl(location, tasks);
return new TasksListImpl(resource.getId(), resource.getLocation(), tasks);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
if (qName.equals("TasksList")) {
location = Utils.newLink(attributes).getLocation();
resource = Utils.newNamedResource(attributes);
} else if (qName.equals("Link") && attributes.getIndex("rel") != -1
&& attributes.getValue(attributes.getIndex("rel")).equals("self")) {
location = Utils.newLink(attributes).getLocation();
resource = Utils.newNamedResource(attributes);
} else {
taskHandler.startElement(uri, localName, qName, attributes);
}

View File

@ -23,14 +23,14 @@
*/
package org.jclouds.vcloud.xml;
import static org.jclouds.rest.util.Utils.newNamedResource;
import static org.jclouds.rest.util.Utils.putNamedResource;
import static org.jclouds.vcloud.util.Utils.newNamedResource;
import static org.jclouds.vcloud.util.Utils.putNamedResource;
import java.util.Map;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.Capacity;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Quota;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.domain.internal.VDCImpl;

View File

@ -110,6 +110,21 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
checkFilters(httpMethod);
}
public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getVDC", String.class);
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1");
assertRequestLineEquals(httpMethod, "GET http://vcloud/vdc/1 HTTP/1.1");
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
assertPayloadEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, VDCHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testGetDefaultTasksList() throws SecurityException, NoSuchMethodException,
IOException {
Method method = VCloudAsyncClient.class.getMethod("getDefaultTasksList");
@ -126,6 +141,21 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
checkFilters(httpMethod);
}
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getTasksList", String.class);
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1");
assertRequestLineEquals(httpMethod, "GET http://vcloud/tasksList/1 HTTP/1.1");
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
assertPayloadEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, TasksListHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("deployVApp", String.class);
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, 1);

View File

@ -30,8 +30,8 @@ import static org.testng.Assert.assertNotNull;
import java.net.URI;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp;
@ -54,6 +54,7 @@ public class VCloudClientLiveTest {
public void testOrganization() throws Exception {
Organization response = connection.getOrganization();
assertNotNull(response);
assertNotNull(response.getId());
assertNotNull(account);
assertNotNull(response.getCatalog());
assertEquals(response.getTasksLists().size(), 1);
@ -64,6 +65,7 @@ public class VCloudClientLiveTest {
public void testCatalog() throws Exception {
Catalog response = connection.getCatalog();
assertNotNull(response);
assertNotNull(response.getId());
assertNotNull(response.getName());
assertNotNull(response.getLocation());
assert response.size() > 0;
@ -73,18 +75,22 @@ public class VCloudClientLiveTest {
public void testDefaultVDC() throws Exception {
VDC response = connection.getDefaultVDC();
assertNotNull(response);
assertNotNull(response.getId());
assertNotNull(response.getName());
assertNotNull(response.getLocation());
assertNotNull(response.getResourceEntities());
assertNotNull(response.getAvailableNetworks());
assertEquals(connection.getVDC(response.getId()), response);
}
@Test
public void testDefaultTasksList() throws Exception {
org.jclouds.vcloud.domain.TasksList response = connection.getDefaultTasksList();
assertNotNull(response);
assertNotNull(response.getId());
assertNotNull(response.getLocation());
assertNotNull(response.getTasks());
assertEquals(connection.getTasksList(response.getId()), response);
}
@Test

View File

@ -44,9 +44,9 @@ import org.jclouds.http.handlers.CloseContentAndSetExceptionErrorHandler;
import org.jclouds.http.handlers.DelegatingErrorHandler;
import org.jclouds.http.handlers.DelegatingRetryHandler;
import org.jclouds.http.handlers.RedirectionRetryHandler;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.util.Jsr330;
import org.jclouds.util.Utils;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
import org.testng.annotations.Test;

View File

@ -31,8 +31,8 @@ import javax.ws.rs.core.HttpHeaders;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

View File

@ -32,8 +32,8 @@ import java.net.URI;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.internal.CatalogItemRoot;
import org.testng.annotations.Test;

View File

@ -35,9 +35,9 @@ import javax.inject.Singleton;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.VCloudApi;
import org.testng.annotations.Test;
@ -55,45 +55,46 @@ import com.google.inject.Provides;
@Test(groups = "unit", testName = "vcloud.OrgHandlerTest")
public class OrgHandlerTest {
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/org.xml");
Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule(){
Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule() {
@Override
protected void configure() {
}
@SuppressWarnings("unused")
@Provides
@Singleton
@VCloudApi
URI provide(){
URI provide() {
return URI.create("https://services.vcloudexpress.terremark.com/api/v0.8");
}
});
Factory factory = injector.getInstance(ParseSax.Factory.class);
Organization result = (Organization) factory.create(injector.getInstance(OrgHandler.class))
.parse(is);
assertEquals(result.getName(), "adrian@jclouds.org");
assertEquals(result.getId(), 48+"");
assertEquals(result.getId(), 48 + "");
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"));
assertEquals(result.getCatalog(), new NamedLinkImpl("Miami Environment 1 Catalog",
CATALOG_XML,
assertEquals(result.getCatalog(), new NamedResourceImpl("catalog",
"Miami Environment 1 Catalog", CATALOG_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")));
assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new NamedLinkImpl(
"Miami Environment 1", VCloudMediaType.VDC_XML, URI
assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new NamedResourceImpl(
"32", "Miami Environment 1", VCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))));
assertEquals(
result.getTasksLists(),
ImmutableMap
.of(
"Miami Environment 1 Tasks List",
new NamedLinkImpl(
new NamedResourceImpl(
"32",
"Miami Environment 1 Tasks List",
TASKSLIST_XML,
URI
@ -102,35 +103,37 @@ public class OrgHandlerTest {
public void testHosting() {
InputStream is = getClass().getResourceAsStream("/org-hosting.xml");
Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule(){
Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule() {
@Override
protected void configure() {
}
@SuppressWarnings("unused")
@Provides
@Singleton
@VCloudApi
URI provide(){
URI provide() {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8");
}
});
Factory factory = injector.getInstance(ParseSax.Factory.class);
Organization result = (Organization) factory.create(injector.getInstance(OrgHandler.class))
.parse(is);
assertEquals(result.getName(), "Customer 188849");
assertEquals(result.getId(), 188849+"");
assertEquals(result.getId(), 188849 + "");
assertEquals(result.getLocation(), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/org/188849"));
assertEquals(result.getCatalog(), new NamedLinkImpl("HMS Shared Catalog", CATALOG_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1")));
assertEquals(result.getCatalog(), new NamedResourceImpl("1", "HMS Shared Catalog",
CATALOG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1")));
assertEquals(result.getVDCs(), ImmutableMap.of("188849 Virtual DataCenter",
new NamedLinkImpl("188849 Virtual DataCenter", VCloudMediaType.VDC_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"))));
assertEquals(result.getTasksLists(), ImmutableMap.of("188849 Task List", new NamedLinkImpl(
"188849 Task List", TASKSLIST_XML, URI
new NamedResourceImpl("188849", "188849 Virtual DataCenter",
VCloudMediaType.VDC_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"))));
assertEquals(result.getTasksLists(), ImmutableMap.of("188849 Task List",
new NamedResourceImpl("188849", "188849 Task List", TASKSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849"))));
}
}

View File

@ -30,9 +30,9 @@ import java.net.URI;
import java.util.Map;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

View File

@ -30,10 +30,10 @@ import java.net.URI;
import org.jclouds.date.DateService;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.internal.TaskImpl;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

View File

@ -30,11 +30,11 @@ import java.net.URI;
import org.jclouds.date.DateService;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.TasksList;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.internal.TaskImpl;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

View File

@ -31,11 +31,11 @@ import java.net.URI;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.Capacity;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Quota;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.VCloudApi;
import org.testng.annotations.Test;
@ -80,7 +80,7 @@ public class VDCHandlerTest {
assertEquals(result.getMemoryCapacity(), null);
assertEquals(result.getInstantiatedVmsQuota(), null);
assertEquals(result.getDeployedVmsQuota(), null);
assertEquals(result.getResourceEntities(), ImmutableMap.<String, NamedLink> of());
assertEquals(result.getResourceEntities(), ImmutableMap.<String, NamedResource> of());
assertEquals(
result.getAvailableNetworks(),
ImmutableMap
@ -123,7 +123,7 @@ public class VDCHandlerTest {
assertEquals(result.getDeployedVmsQuota(), new Quota(0, 2));
assertEquals(
result.getResourceEntities(),
new ImmutableMap.Builder<String, NamedLink>()
new ImmutableMap.Builder<String, NamedResource>()
.put(
"Plesk (Linux) 64-bit Template",
new NamedResourceImpl(
@ -175,6 +175,6 @@ public class VDCHandlerTest {
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-2")))
.build());
assertEquals(result.getAvailableNetworks(), ImmutableMap.<String, NamedLink> of());
assertEquals(result.getAvailableNetworks(), ImmutableMap.<String, NamedResource> of());
}
}

View File

@ -43,8 +43,8 @@ import org.jclouds.compute.domain.internal.CreateServerResponseImpl;
import org.jclouds.compute.domain.internal.ServerMetadataImpl;
import org.jclouds.domain.Credentials;
import org.jclouds.logging.Logger;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudClient;

View File

@ -89,8 +89,20 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
@XMLResponseParser(TerremarkVDCHandler.class)
@Consumes(VDC_XML)
@Override
Future<? extends VDC> getDefaultVDC();
/**
* @see TerremarkVCloudClient#getVDC
*/
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vdc/{vDCId}")
@XMLResponseParser(TerremarkVDCHandler.class)
@Consumes(VDC_XML)
@Override
Future<? extends VDC> getVDC(@PathParam("vDCId") String vDCId);
/**
* @see TerremarkVCloudClient#instantiateVAppTemplate
*/

View File

@ -44,8 +44,8 @@ import org.jclouds.compute.domain.internal.CreateServerResponseImpl;
import org.jclouds.compute.domain.internal.ServerMetadataImpl;
import org.jclouds.domain.Credentials;
import org.jclouds.logging.Logger;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;

View File

@ -23,7 +23,7 @@
*/
package org.jclouds.vcloud.terremark.domain;
import org.jclouds.rest.domain.Link;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.terremark.domain.internal.TerremarkVAppImpl;
@ -35,10 +35,10 @@ import com.google.inject.ImplementedBy;
@ImplementedBy(TerremarkVAppImpl.class)
public interface TerremarkVApp extends VApp {
Link getVDC();
NamedResource getVDC();
Link getComputeOptions();
NamedResource getComputeOptions();
Link getCustomizationOptions();
NamedResource getCustomizationOptions();
}

View File

@ -23,7 +23,7 @@
*/
package org.jclouds.vcloud.terremark.domain;
import org.jclouds.rest.domain.Link;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.terremark.domain.internal.TerremarkVDCImpl;
@ -40,13 +40,13 @@ import com.google.inject.ImplementedBy;
public interface TerremarkVDC extends VDC {
@Catalog
Link getCatalog();
NamedResource getCatalog();
@PublicIPs
Link getPublicIps();
NamedResource getPublicIps();
@InternetServices
Link getInternetServices();
NamedResource getInternetServices();
// TODO getDescription() // what is the type?
}

View File

@ -21,10 +21,12 @@
* under the License.
* ====================================================================
*/
package org.jclouds.vcloud.domain;
package org.jclouds.vcloud.terremark.domain;
import java.util.Date;
import org.jclouds.vcloud.domain.VirtualSystem;
/**
* @author Adrian Cole
*/

View File

@ -27,12 +27,12 @@ import java.net.InetAddress;
import java.net.URI;
import java.util.SortedSet;
import org.jclouds.rest.domain.Link;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.TerremarkVirtualSystem;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.internal.VAppImpl;
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
import org.jclouds.vcloud.terremark.domain.TerremarkVirtualSystem;
import com.google.common.collect.ListMultimap;
@ -44,15 +44,15 @@ import com.google.common.collect.ListMultimap;
*/
public class TerremarkVAppImpl extends VAppImpl implements TerremarkVApp {
private final Link vDC;
private final Link computeOptions;
private final Link customizationOptions;
private final NamedResource vDC;
private final NamedResource computeOptions;
private final NamedResource customizationOptions;
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
public TerremarkVAppImpl(String id, String name, String type, URI location, VAppStatus status,
long size, Link vDC, Link computeOptions, Link customizationOptions,
long size, NamedResource vDC, NamedResource computeOptions, NamedResource customizationOptions,
ListMultimap<String, InetAddress> networkToAddresses,
String operatingSystemDescription, TerremarkVirtualSystem system,
SortedSet<ResourceAllocation> resourceAllocations) {
@ -63,15 +63,15 @@ public class TerremarkVAppImpl extends VAppImpl implements TerremarkVApp {
this.customizationOptions = customizationOptions;
}
public Link getVDC() {
public NamedResource getVDC() {
return vDC;
}
public Link getComputeOptions() {
public NamedResource getComputeOptions() {
return computeOptions;
}
public Link getCustomizationOptions() {
public NamedResource getCustomizationOptions() {
return customizationOptions;
}

View File

@ -28,9 +28,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.Capacity;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Quota;
import org.jclouds.vcloud.domain.internal.VDCImpl;
import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
@ -43,9 +42,9 @@ import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
*/
public class TerremarkVDCImpl extends VDCImpl implements TerremarkVDC {
private final NamedLink catalog;
private final NamedLink publicIps;
private final NamedLink internetServices;
private final NamedResource catalog;
private final NamedResource publicIps;
private final NamedResource internetServices;
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
@ -54,8 +53,8 @@ public class TerremarkVDCImpl extends VDCImpl implements TerremarkVDC {
Capacity storageCapacity, Capacity cpuCapacity, Capacity memoryCapacity,
Quota instantiatedVmsQuota, Quota deployedVmsQuota,
Map<String, NamedResource> availableNetworks,
Map<String, NamedResource> resourceEntities, NamedLink catalog, NamedLink publicIps,
NamedLink internetServices) {
Map<String, NamedResource> resourceEntities, NamedResource catalog, NamedResource publicIps,
NamedResource internetServices) {
super(id, name, location, description, storageCapacity, cpuCapacity, memoryCapacity,
instantiatedVmsQuota, deployedVmsQuota, availableNetworks, resourceEntities);
this.catalog = checkNotNull(catalog, "catalog");
@ -63,15 +62,15 @@ public class TerremarkVDCImpl extends VDCImpl implements TerremarkVDC {
this.internetServices = checkNotNull(internetServices, "internetServices");
}
public NamedLink getCatalog() {
public NamedResource getCatalog() {
return catalog;
}
public NamedLink getPublicIps() {
public NamedResource getPublicIps() {
return publicIps;
}
public NamedLink getInternetServices() {
public NamedResource getInternetServices() {
return internetServices;
}

View File

@ -34,17 +34,16 @@ import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.logging.Logger;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.rest.util.Utils;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.TerremarkVirtualSystem;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.internal.VAppRoot;
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
import org.jclouds.vcloud.terremark.domain.TerremarkVirtualSystem;
import org.jclouds.vcloud.terremark.domain.internal.TerremarkVAppImpl;
import org.jclouds.vcloud.util.Utils;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@ -72,12 +71,12 @@ public class TerremarkVAppHandler extends ParseSax.HandlerWithResult<TerremarkVA
private TerremarkVirtualSystem system;
private SortedSet<ResourceAllocation> allocations = Sets.newTreeSet();
private NamedResource vApp;
private Link vDC;
private NamedResource vDC;
private VAppStatus status;
private int size;
private boolean skip;
private Link computeOptions;
private Link customizationOptions;
private NamedResource computeOptions;
private NamedResource customizationOptions;
private final ListMultimap<String, InetAddress> networkToAddresses = ArrayListMultimap.create();
private StringBuilder currentText = new StringBuilder();
private String operatingSystemDescription;
@ -103,12 +102,12 @@ public class TerremarkVAppHandler extends ParseSax.HandlerWithResult<TerremarkVA
}
if (qName.equals("Link")) {
if (attributes.getValue(attributes.getIndex("type")).equals(VCloudMediaType.VDC_XML)) {
vDC = Utils.newLink(attributes);
vDC = Utils.newNamedResource(attributes);
} else if (attributes.getValue(attributes.getIndex("name")).equals("Compute Options")) {
this.computeOptions = Utils.newLink(attributes);
this.computeOptions = Utils.newNamedResource(attributes);
} else if (attributes.getValue(attributes.getIndex("name"))
.equals("Customization Options")) {
this.customizationOptions = Utils.newLink(attributes);
this.customizationOptions = Utils.newNamedResource(attributes);
}
} else if (qName.equals("VApp")) {
vApp = newNamedResource(attributes);

View File

@ -23,12 +23,12 @@
*/
package org.jclouds.vcloud.terremark.xml;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.util.Utils;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
import org.jclouds.vcloud.terremark.domain.internal.TerremarkVDCImpl;
import org.jclouds.vcloud.util.Utils;
import org.jclouds.vcloud.xml.VDCHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@ -38,9 +38,9 @@ import org.xml.sax.SAXException;
*/
public class TerremarkVDCHandler extends VDCHandler {
private NamedLink catalog;
private NamedLink publicIps;
private NamedLink internetServices;
private NamedResource catalog;
private NamedResource publicIps;
private NamedResource internetServices;
public TerremarkVDC getResult() {
VDC vDC = super.getResult();
@ -58,13 +58,13 @@ public class TerremarkVDCHandler extends VDCHandler {
if (qName.equals("Link")) {
String name = attributes.getValue(attributes.getIndex("name"));
if (name.equals("Internet Services")) {
internetServices = Utils.newNamedLink(attributes);
internetServices = Utils.newNamedResource(attributes);
} else if (name.equals("Public IPs")) {
publicIps = Utils.newNamedLink(attributes);
publicIps = Utils.newNamedResource(attributes);
} else {
String type = attributes.getValue(attributes.getIndex("type"));
if (type.equals(VCloudMediaType.CATALOG_XML)) {
catalog = Utils.newNamedLink(attributes);
catalog = Utils.newNamedResource(attributes);
}
}
}

View File

@ -36,7 +36,7 @@ import org.xml.sax.SAXException;
* @author Adrian Cole
*/
public class VirtualSystemHandler extends
ParseSax.HandlerWithResult<org.jclouds.vcloud.domain.TerremarkVirtualSystem> {
ParseSax.HandlerWithResult<org.jclouds.vcloud.terremark.domain.TerremarkVirtualSystem> {
private StringBuilder currentText = new StringBuilder();
protected DateService dateService;
@ -62,7 +62,7 @@ public class VirtualSystemHandler extends
private String virtualSystemIdentifier;
private String virtualSystemType;
private org.jclouds.vcloud.domain.TerremarkVirtualSystem system;
private org.jclouds.vcloud.terremark.domain.TerremarkVirtualSystem system;
private boolean skip;
@ -71,7 +71,7 @@ public class VirtualSystemHandler extends
this.dateService = dateService;
}
public org.jclouds.vcloud.domain.TerremarkVirtualSystem getResult() {
public org.jclouds.vcloud.terremark.domain.TerremarkVirtualSystem getResult() {
return system;
}
@ -134,7 +134,7 @@ public class VirtualSystemHandler extends
} else if (qName.equals("VirtualSystemType")) {
this.virtualSystemType = currentText.toString().trim();
} else if (qName.equals("q2:System")) {
this.system = new org.jclouds.vcloud.domain.TerremarkVirtualSystem(
this.system = new org.jclouds.vcloud.terremark.domain.TerremarkVirtualSystem(
automaticRecoveryAction, automaticShutdownAction, automaticStartupAction,
automaticStartupActionDelay, automaticStartupActionSequenceNumber, caption,
configurationDataRoot, configurationFile, configurationID, creationTime,

View File

@ -39,12 +39,12 @@ import org.jclouds.http.HttpResponseException;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshClient.Factory;
import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.jclouds.util.Utils;
import org.jclouds.vcloud.VCloudClientLiveTest;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VAppStatus;

View File

@ -35,14 +35,14 @@ import javax.ws.rs.core.MediaType;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.TerremarkVirtualSystem;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.internal.VAppRoot;
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
import org.jclouds.vcloud.terremark.domain.TerremarkVirtualSystem;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@ -94,8 +94,9 @@ public class TerremarkVAppHandlerTest extends BaseHandlerTest {
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13775"));
assertEquals(result.getVDC(), new LinkImpl("application/vnd.vmware.vcloud.vdc+xml", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")));
assertEquals(result.getVDC(), new NamedResourceImpl("32", null,
"application/vnd.vmware.vcloud.vdc+xml", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")));
}
@ -114,17 +115,21 @@ public class TerremarkVAppHandlerTest extends BaseHandlerTest {
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13850"));
assertEquals(result.getVDC(), new LinkImpl(VCloudMediaType.VDC_XML, URI
assertEquals(result.getVDC(), new NamedResourceImpl("32", null, VCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")));
assertEquals(
result.getComputeOptions(),
new LinkImpl(
new NamedResourceImpl(
"compute",
"Compute Options",
MediaType.APPLICATION_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13850/options/compute")));
assertEquals(
result.getCustomizationOptions(),
new LinkImpl(
new NamedResourceImpl(
"customization",
"Customization Options",
MediaType.APPLICATION_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13850/options/customization")));

View File

@ -32,10 +32,9 @@ import java.net.URI;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.VCloudApi;
import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
import org.testng.annotations.Test;
@ -107,13 +106,21 @@ public class TerremarkVDCHandlerTest {
"application/vnd.vmware.vcloud.network+xml",
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"))));
assertEquals(result.getCatalog(), new NamedLinkImpl("Miami Environment 1", CATALOG_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")));
assertEquals(result.getPublicIps(), new NamedLinkImpl("Public IPs", "application/xml", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps")));
assertEquals(result.getCatalog(), new NamedResourceImpl("catalog", "Miami Environment 1",
CATALOG_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")));
assertEquals(
result.getPublicIps(),
new NamedResourceImpl(
"publicIps",
"Public IPs",
"application/xml",
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps")));
assertEquals(
result.getInternetServices(),
new NamedLinkImpl(
new NamedResourceImpl(
"internetServices",
"Internet Services",
"application/xml",
URI

View File

@ -28,7 +28,7 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.domain.TerremarkVirtualSystem;
import org.jclouds.vcloud.terremark.domain.TerremarkVirtualSystem;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;