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) @XMLResponseParser(CatalogHandler.class)
Future<? extends Catalog> getCatalog(); 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 @GET
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class) @Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
@XMLResponseParser(VDCHandler.class) @XMLResponseParser(VDCHandler.class)
@Consumes(VDC_XML) @Consumes(VDC_XML)
Future<? extends VDC> getDefaultVDC(); 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 @GET
@Endpoint(org.jclouds.vcloud.endpoints.TasksList.class) @Endpoint(org.jclouds.vcloud.endpoints.TasksList.class)
@Consumes(TASKSLIST_XML) @Consumes(TASKSLIST_XML)

View File

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

View File

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

View File

@ -21,9 +21,11 @@
* under the License. * 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; import com.google.inject.ImplementedBy;
@ -34,6 +36,12 @@ import com.google.inject.ImplementedBy;
* *
*/ */
@ImplementedBy(NamedResourceImpl.class) @ImplementedBy(NamedResourceImpl.class)
public interface NamedResource extends NamedLink, Comparable<NamedResource> { public interface NamedResource extends Comparable<NamedResource> {
String getId(); String getId();
String getName();
String getType();
URI getLocation();
} }

View File

@ -23,11 +23,8 @@
*/ */
package org.jclouds.vcloud.domain; package org.jclouds.vcloud.domain;
import java.net.URI;
import java.util.Map; 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.domain.internal.OrganizationImpl;
import org.jclouds.vcloud.endpoints.Catalog; import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.endpoints.Org;
@ -41,20 +38,15 @@ import com.google.inject.ImplementedBy;
*/ */
@Org @Org
@ImplementedBy(OrganizationImpl.class) @ImplementedBy(OrganizationImpl.class)
public interface Organization { public interface Organization extends NamedResource {
String getName();
String getId();
URI getLocation();
@Catalog @Catalog
Link getCatalog(); NamedResource getCatalog();
@VDC @VDC
Map<String, NamedLink> getVDCs(); Map<String, NamedResource> getVDCs();
@TasksList @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.net.URI;
import java.util.Date; import java.util.Date;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.TaskImpl; import org.jclouds.vcloud.domain.internal.TaskImpl;
import com.google.inject.ImplementedBy; import com.google.inject.ImplementedBy;
@ -46,7 +45,13 @@ public interface Task extends Comparable<Task> {
Date getEndTime(); Date getEndTime();
/**
* A link to the vDC in which the task was started
*/
NamedResource getOwner(); NamedResource getOwner();
/**
* A link to the result of the task
*/
NamedResource getResult(); NamedResource getResult();
} }

View File

@ -37,6 +37,8 @@ import com.google.inject.ImplementedBy;
@org.jclouds.vcloud.endpoints.TasksList @org.jclouds.vcloud.endpoints.TasksList
@ImplementedBy(TasksListImpl.class) @ImplementedBy(TasksListImpl.class)
public interface TasksList { public interface TasksList {
String getId();
URI getLocation(); URI getLocation();
SortedSet<Task> getTasks(); 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; package org.jclouds.vcloud.domain;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.URI;
import java.util.Map; import java.util.Map;
import java.util.SortedSet; import java.util.SortedSet;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
public interface VApp { /**
String getId(); * 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
URI getLocation(); * in Enterprises and Service Providers.
*
String getName(); * @author Adrian Cole
*/
public interface VApp extends NamedResource {
VAppStatus getStatus(); VAppStatus getStatus();

View File

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

View File

@ -29,8 +29,9 @@ import java.net.URI;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.TreeMap; 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.Catalog;
import org.jclouds.vcloud.domain.NamedResource;
import com.google.inject.internal.Nullable; import com.google.inject.internal.Nullable;
@ -44,13 +45,14 @@ public class CatalogImpl extends TreeMap<String, NamedResource> implements Catal
/** The serialVersionUID */ /** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L; private static final long serialVersionUID = 8464716396538298809L;
private final String id;
private final String name; private final String name;
private final String description; private final String description;
private final URI location; 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) { SortedMap<String, NamedResource> contents) {
super(); this.id = checkNotNull(id, "id");
this.name = checkNotNull(name, "name"); this.name = checkNotNull(name, "name");
this.description = description; this.description = description;
this.location = checkNotNull(location, "location"); this.location = checkNotNull(location, "location");
@ -61,6 +63,10 @@ public class CatalogImpl extends TreeMap<String, NamedResource> implements Catal
return location; return location;
} }
public String getId() {
return id;
}
public String getName() { public String getName() {
return name; return name;
} }
@ -106,4 +112,14 @@ public class CatalogImpl extends TreeMap<String, NamedResource> implements Catal
return description; 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. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.rest.domain.internal; package org.jclouds.vcloud.domain.internal;
import java.net.URI; import java.net.URI;
import org.jclouds.rest.domain.Link; import org.jclouds.vcloud.domain.NamedResource;
/** /**
* Location of a Rest resource * Location of a Rest resource
@ -33,15 +33,27 @@ import org.jclouds.rest.domain.Link;
* @author Adrian Cole * @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 String type;
private final URI location; 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.type = type;
this.location = location; this.location = location;
} }
public String getId() {
return id;
}
public String getName() {
return name;
}
public String getType() { public String getType() {
return type; return type;
} }
@ -50,11 +62,17 @@ public class LinkImpl implements Link {
return location; return location;
} }
public int compareTo(NamedResource that) {
return (this == that) ? 0 : this.id.compareTo(that.getId());
}
@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 + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((location == null) ? 0 : location.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()); result = prime * result + ((type == null) ? 0 : type.hashCode());
return result; return result;
} }
@ -67,12 +85,22 @@ public class LinkImpl implements Link {
return false; return false;
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; 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 (location == null) {
if (other.location != null) if (other.location != null)
return false; return false;
} else if (!location.equals(other.location)) } else if (!location.equals(other.location))
return false; return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (type == null) { if (type == null) {
if (other.type != null) if (other.type != null)
return false; return false;
@ -83,6 +111,7 @@ public class LinkImpl implements Link {
@Override @Override
public String toString() { 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.net.URI;
import java.util.Map; 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.domain.Organization;
import org.jclouds.vcloud.endpoints.Catalog; import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.TasksList; import org.jclouds.vcloud.endpoints.TasksList;
@ -42,12 +43,12 @@ public class OrganizationImpl implements Organization {
private final String id; private final String id;
private final String name; private final String name;
private final URI location; private final URI location;
private final NamedLink catalog; private final NamedResource catalog;
private final Map<String, NamedLink> vdcs; private final Map<String, NamedResource> vdcs;
private final Map<String, NamedLink> tasksLists; private final Map<String, NamedResource> tasksLists;
public OrganizationImpl(String id, String name, URI location, NamedLink catalog, public OrganizationImpl(String id, String name, URI location, NamedResource catalog,
Map<String, NamedLink> vdcs, Map<String, NamedLink> tasksLists) { Map<String, NamedResource> vdcs, Map<String, NamedResource> tasksLists) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.location = location; this.location = location;
@ -69,17 +70,17 @@ public class OrganizationImpl implements Organization {
} }
@Catalog @Catalog
public NamedLink getCatalog() { public NamedResource getCatalog() {
return catalog; return catalog;
} }
@VDC @VDC
public Map<String, NamedLink> getVDCs() { public Map<String, NamedResource> getVDCs() {
return vdcs; return vdcs;
} }
@TasksList @TasksList
public Map<String, NamedLink> getTasksLists() { public Map<String, NamedResource> getTasksLists() {
return tasksLists; return tasksLists;
} }
@ -138,5 +139,13 @@ public class OrganizationImpl implements Organization {
return true; 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.net.URI;
import java.util.Date; 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.Task;
import org.jclouds.vcloud.domain.TaskStatus; import org.jclouds.vcloud.domain.TaskStatus;

View File

@ -42,7 +42,7 @@ import com.google.common.collect.Multimaps;
* *
*/ */
public class TasksListImpl implements TasksList { public class TasksListImpl implements TasksList {
private final String id;
private final SortedSet<Task> tasks; private final SortedSet<Task> tasks;
private final ListMultimap<URI, Task> tasksByResult; private final ListMultimap<URI, Task> tasksByResult;
private final ListMultimap<URI, Task> tasksByOwner; private final ListMultimap<URI, Task> tasksByOwner;
@ -51,7 +51,8 @@ public class TasksListImpl implements TasksList {
/** The serialVersionUID */ /** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L; 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.location = location;
this.tasks = tasks; this.tasks = tasks;
this.tasksByResult = Multimaps.index(Iterables.filter(tasks, new Predicate<Task>() { this.tasksByResult = Multimaps.index(Iterables.filter(tasks, new Predicate<Task>() {
@ -94,8 +95,10 @@ public class TasksListImpl implements TasksList {
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode()); result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((tasks == null) ? 0 : tasks.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()); result = prime * result + ((tasksByResult == null) ? 0 : tasksByResult.hashCode());
return result; return result;
} }
@ -109,6 +112,11 @@ public class TasksListImpl implements TasksList {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
TasksListImpl other = (TasksListImpl) obj; 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 (location == null) {
if (other.location != null) if (other.location != null)
return false; return false;
@ -119,6 +127,11 @@ public class TasksListImpl implements TasksList {
return false; return false;
} else if (!tasks.equals(other.tasks)) } else if (!tasks.equals(other.tasks))
return false; return false;
if (tasksByOwner == null) {
if (other.tasksByOwner != null)
return false;
} else if (!tasksByOwner.equals(other.tasksByOwner))
return false;
if (tasksByResult == null) { if (tasksByResult == null) {
if (other.tasksByResult != null) if (other.tasksByResult != null)
return false; return false;
@ -134,4 +147,9 @@ public class TasksListImpl implements TasksList {
public ListMultimap<URI, Task> getTasksByOwner() { public ListMultimap<URI, Task> getTasksByOwner() {
return tasksByOwner; 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.Map;
import java.util.SortedSet; 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.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VApp;
@ -39,7 +41,6 @@ import com.google.common.collect.ListMultimap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
/** /**
* Locations of resources in vCloud
* *
* @author Adrian Cole * @author Adrian Cole
* *
@ -212,4 +213,13 @@ public class VAppImpl implements VApp {
+ ", size=" + size + ", status=" + status + ", system=" + system + "]"; + ", 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.net.URI;
import java.util.Map; 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.Capacity;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Quota; import org.jclouds.vcloud.domain.Quota;
import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.VDC;
@ -203,4 +204,14 @@ public class VDCImpl implements VDC {
public Quota getDeployedVmsQuota() { public Quota getDeployedVmsQuota() {
return deployedVmsQuota; 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.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.rest.domain.NamedResource;
import org.jclouds.vcloud.VCloudToken; import org.jclouds.vcloud.VCloudToken;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession; import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
import org.jclouds.vcloud.xml.OrgListHandler; 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.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.rest.domain.NamedResource;
import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudToken; import org.jclouds.vcloud.VCloudToken;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders; import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;

View File

@ -21,17 +21,13 @@
* under the License. * under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.rest.util; package org.jclouds.vcloud.util;
import java.net.URI; import java.net.URI;
import java.util.Map; import java.util.Map;
import org.jclouds.rest.domain.Link; import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.rest.domain.NamedLink; import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
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.xml.sax.Attributes; import org.xml.sax.Attributes;
/** /**
@ -40,20 +36,6 @@ import org.xml.sax.Attributes;
*/ */
public class Utils { 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) { public static NamedResource newNamedResource(Attributes attributes) {
String uri = attributes.getValue(attributes.getIndex("href")); String uri = attributes.getValue(attributes.getIndex("href"));

View File

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

View File

@ -23,24 +23,18 @@
*/ */
package org.jclouds.vcloud.xml; 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.CATALOG_XML;
import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML; import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
import static org.jclouds.vcloud.VCloudMediaType.VDC_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 java.util.Map;
import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.domain.NamedLink; import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.Organization; import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.internal.OrganizationImpl; import org.jclouds.vcloud.domain.internal.OrganizationImpl;
import org.jclouds.vcloud.endpoints.VCloudApi;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -51,12 +45,9 @@ import com.google.common.collect.Maps;
*/ */
public class OrgHandler extends ParseSax.HandlerWithResult<Organization> { public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
private NamedResource org; private NamedResource org;
private Map<String, NamedLink> vdcs = Maps.newHashMap(); private Map<String, NamedResource> vdcs = Maps.newHashMap();
private Map<String, NamedLink> tasksLists = Maps.newHashMap(); private Map<String, NamedResource> tasksLists = Maps.newHashMap();
private NamedLink catalog; private NamedResource catalog;
@Inject
@VCloudApi
URI vcloudUri;
public Organization getResult() { public Organization getResult() {
return new OrganizationImpl(org.getId(), org.getName(), org.getLocation(), catalog, vdcs, 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"); 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)) {
putNamedLink(vdcs, attributes); putNamedResource(vdcs, attributes);
} else if (attributes.getValue(typeIndex).equals(CATALOG_XML)) { } else if (attributes.getValue(typeIndex).equals(CATALOG_XML)) {
catalog = newNamedLink(attributes); catalog = newNamedResource(attributes);
} else if (attributes.getValue(typeIndex).equals(TASKSLIST_XML)) { } 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; 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.VCloudMediaType.ORG_XML;
import static org.jclouds.vcloud.util.Utils.putNamedResource;
import java.util.Map; import java.util.Map;
import org.jclouds.http.functions.ParseSax; 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.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;

View File

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

View File

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

View File

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

View File

@ -110,6 +110,21 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
checkFilters(httpMethod); 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, public void testGetDefaultTasksList() throws SecurityException, NoSuchMethodException,
IOException { IOException {
Method method = VCloudAsyncClient.class.getMethod("getDefaultTasksList"); Method method = VCloudAsyncClient.class.getMethod("getDefaultTasksList");
@ -126,6 +141,21 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
checkFilters(httpMethod); 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 { public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("deployVApp", String.class); Method method = VCloudAsyncClient.class.getMethod("deployVApp", String.class);
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, 1); GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, 1);

View File

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

View File

@ -44,9 +44,9 @@ import org.jclouds.http.handlers.CloseContentAndSetExceptionErrorHandler;
import org.jclouds.http.handlers.DelegatingErrorHandler; 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.rest.domain.NamedResource;
import org.jclouds.util.Jsr330; import org.jclouds.util.Jsr330;
import org.jclouds.util.Utils; import org.jclouds.util.Utils;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient; import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession; import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
import org.testng.annotations.Test; 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.HttpResponse;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession; import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; 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;
import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.internal.CatalogItemRoot; import org.jclouds.vcloud.endpoints.internal.CatalogItemRoot;
import org.testng.annotations.Test; 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;
import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Organization; import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.VCloudApi; import org.jclouds.vcloud.endpoints.VCloudApi;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -55,21 +55,21 @@ import com.google.inject.Provides;
@Test(groups = "unit", testName = "vcloud.OrgHandlerTest") @Test(groups = "unit", testName = "vcloud.OrgHandlerTest")
public class OrgHandlerTest { public class OrgHandlerTest {
public void testApplyInputStream() { public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/org.xml"); InputStream is = getClass().getResourceAsStream("/org.xml");
Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule(){ Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Provides @Provides
@Singleton @Singleton
@VCloudApi @VCloudApi
URI provide(){ URI provide() {
return URI.create("https://services.vcloudexpress.terremark.com/api/v0.8"); return URI.create("https://services.vcloudexpress.terremark.com/api/v0.8");
} }
@ -79,21 +79,22 @@ public class OrgHandlerTest {
Organization result = (Organization) factory.create(injector.getInstance(OrgHandler.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.getId(), 48+""); assertEquals(result.getId(), 48 + "");
assertEquals(result.getLocation(), 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(), new NamedLinkImpl("Miami Environment 1 Catalog", assertEquals(result.getCatalog(), new NamedResourceImpl("catalog",
CATALOG_XML, "Miami Environment 1 Catalog", CATALOG_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"))); URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")));
assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new NamedLinkImpl( assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new NamedResourceImpl(
"Miami Environment 1", VCloudMediaType.VDC_XML, URI "32", "Miami Environment 1", VCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")))); .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))));
assertEquals( assertEquals(
result.getTasksLists(), result.getTasksLists(),
ImmutableMap ImmutableMap
.of( .of(
"Miami Environment 1 Tasks List", "Miami Environment 1 Tasks List",
new NamedLinkImpl( new NamedResourceImpl(
"32",
"Miami Environment 1 Tasks List", "Miami Environment 1 Tasks List",
TASKSLIST_XML, TASKSLIST_XML,
URI URI
@ -102,17 +103,18 @@ public class OrgHandlerTest {
public void testHosting() { public void testHosting() {
InputStream is = getClass().getResourceAsStream("/org-hosting.xml"); InputStream is = getClass().getResourceAsStream("/org-hosting.xml");
Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule(){ Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Provides @Provides
@Singleton @Singleton
@VCloudApi @VCloudApi
URI provide(){ URI provide() {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8"); return URI.create("https://vcloud.safesecureweb.com/api/v0.8");
} }
@ -121,16 +123,17 @@ public class OrgHandlerTest {
Organization result = (Organization) factory.create(injector.getInstance(OrgHandler.class)) Organization result = (Organization) factory.create(injector.getInstance(OrgHandler.class))
.parse(is); .parse(is);
assertEquals(result.getName(), "Customer 188849"); assertEquals(result.getName(), "Customer 188849");
assertEquals(result.getId(), 188849+""); assertEquals(result.getId(), 188849 + "");
assertEquals(result.getLocation(), URI assertEquals(result.getLocation(), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/org/188849")); .create("https://vcloud.safesecureweb.com/api/v0.8/org/188849"));
assertEquals(result.getCatalog(), new NamedLinkImpl("HMS Shared Catalog", CATALOG_XML, URI assertEquals(result.getCatalog(), new NamedResourceImpl("1", "HMS Shared Catalog",
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))); CATALOG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1")));
assertEquals(result.getVDCs(), ImmutableMap.of("188849 Virtual DataCenter", assertEquals(result.getVDCs(), ImmutableMap.of("188849 Virtual DataCenter",
new NamedLinkImpl("188849 Virtual DataCenter", VCloudMediaType.VDC_XML, URI new NamedResourceImpl("188849", "188849 Virtual DataCenter",
VCloudMediaType.VDC_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849")))); .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"))));
assertEquals(result.getTasksLists(), ImmutableMap.of("188849 Task List", new NamedLinkImpl( assertEquals(result.getTasksLists(), ImmutableMap.of("188849 Task List",
"188849 Task List", TASKSLIST_XML, URI new NamedResourceImpl("188849", "188849 Task List", TASKSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849")))); .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 java.util.Map;
import org.jclouds.http.functions.BaseHandlerTest; 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.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;

View File

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

View File

@ -30,11 +30,11 @@ import java.net.URI;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus; import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.TasksList; import org.jclouds.vcloud.domain.TasksList;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.internal.TaskImpl; import org.jclouds.vcloud.domain.internal.TaskImpl;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; 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;
import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.ParserModule; 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.Capacity;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Quota; import org.jclouds.vcloud.domain.Quota;
import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.VCloudApi; import org.jclouds.vcloud.endpoints.VCloudApi;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -80,7 +80,7 @@ public class VDCHandlerTest {
assertEquals(result.getMemoryCapacity(), null); assertEquals(result.getMemoryCapacity(), null);
assertEquals(result.getInstantiatedVmsQuota(), null); assertEquals(result.getInstantiatedVmsQuota(), null);
assertEquals(result.getDeployedVmsQuota(), null); assertEquals(result.getDeployedVmsQuota(), null);
assertEquals(result.getResourceEntities(), ImmutableMap.<String, NamedLink> of()); assertEquals(result.getResourceEntities(), ImmutableMap.<String, NamedResource> of());
assertEquals( assertEquals(
result.getAvailableNetworks(), result.getAvailableNetworks(),
ImmutableMap ImmutableMap
@ -123,7 +123,7 @@ public class VDCHandlerTest {
assertEquals(result.getDeployedVmsQuota(), new Quota(0, 2)); assertEquals(result.getDeployedVmsQuota(), new Quota(0, 2));
assertEquals( assertEquals(
result.getResourceEntities(), result.getResourceEntities(),
new ImmutableMap.Builder<String, NamedLink>() new ImmutableMap.Builder<String, NamedResource>()
.put( .put(
"Plesk (Linux) 64-bit Template", "Plesk (Linux) 64-bit Template",
new NamedResourceImpl( new NamedResourceImpl(
@ -175,6 +175,6 @@ public class VDCHandlerTest {
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-2"))) .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-2")))
.build()); .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.compute.domain.internal.ServerMetadataImpl;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus; import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudClient; import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudClient;

View File

@ -89,8 +89,20 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class) @Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
@XMLResponseParser(TerremarkVDCHandler.class) @XMLResponseParser(TerremarkVDCHandler.class)
@Consumes(VDC_XML) @Consumes(VDC_XML)
@Override
Future<? extends VDC> getDefaultVDC(); 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 * @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.compute.domain.internal.ServerMetadataImpl;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus; import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.terremark.TerremarkVCloudClient; import org.jclouds.vcloud.terremark.TerremarkVCloudClient;

View File

@ -23,7 +23,7 @@
*/ */
package org.jclouds.vcloud.terremark.domain; 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.domain.VApp;
import org.jclouds.vcloud.terremark.domain.internal.TerremarkVAppImpl; import org.jclouds.vcloud.terremark.domain.internal.TerremarkVAppImpl;
@ -35,10 +35,10 @@ import com.google.inject.ImplementedBy;
@ImplementedBy(TerremarkVAppImpl.class) @ImplementedBy(TerremarkVAppImpl.class)
public interface TerremarkVApp extends VApp { 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; 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.domain.VDC;
import org.jclouds.vcloud.endpoints.Catalog; import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.terremark.domain.internal.TerremarkVDCImpl; import org.jclouds.vcloud.terremark.domain.internal.TerremarkVDCImpl;
@ -40,13 +40,13 @@ import com.google.inject.ImplementedBy;
public interface TerremarkVDC extends VDC { public interface TerremarkVDC extends VDC {
@Catalog @Catalog
Link getCatalog(); NamedResource getCatalog();
@PublicIPs @PublicIPs
Link getPublicIps(); NamedResource getPublicIps();
@InternetServices @InternetServices
Link getInternetServices(); NamedResource getInternetServices();
// TODO getDescription() // what is the type? // TODO getDescription() // what is the type?
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -23,12 +23,12 @@
*/ */
package org.jclouds.vcloud.terremark.xml; 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.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.terremark.domain.TerremarkVDC; import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
import org.jclouds.vcloud.terremark.domain.internal.TerremarkVDCImpl; import org.jclouds.vcloud.terremark.domain.internal.TerremarkVDCImpl;
import org.jclouds.vcloud.util.Utils;
import org.jclouds.vcloud.xml.VDCHandler; import org.jclouds.vcloud.xml.VDCHandler;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -38,9 +38,9 @@ import org.xml.sax.SAXException;
*/ */
public class TerremarkVDCHandler extends VDCHandler { public class TerremarkVDCHandler extends VDCHandler {
private NamedLink catalog; private NamedResource catalog;
private NamedLink publicIps; private NamedResource publicIps;
private NamedLink internetServices; private NamedResource internetServices;
public TerremarkVDC getResult() { public TerremarkVDC getResult() {
VDC vDC = super.getResult(); VDC vDC = super.getResult();
@ -58,13 +58,13 @@ public class TerremarkVDCHandler extends VDCHandler {
if (qName.equals("Link")) { if (qName.equals("Link")) {
String name = attributes.getValue(attributes.getIndex("name")); String name = attributes.getValue(attributes.getIndex("name"));
if (name.equals("Internet Services")) { if (name.equals("Internet Services")) {
internetServices = Utils.newNamedLink(attributes); internetServices = Utils.newNamedResource(attributes);
} else if (name.equals("Public IPs")) { } else if (name.equals("Public IPs")) {
publicIps = Utils.newNamedLink(attributes); publicIps = Utils.newNamedResource(attributes);
} else { } else {
String type = attributes.getValue(attributes.getIndex("type")); String type = attributes.getValue(attributes.getIndex("type"));
if (type.equals(VCloudMediaType.CATALOG_XML)) { 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 * @author Adrian Cole
*/ */
public class VirtualSystemHandler extends public class VirtualSystemHandler extends
ParseSax.HandlerWithResult<org.jclouds.vcloud.domain.TerremarkVirtualSystem> { ParseSax.HandlerWithResult<org.jclouds.vcloud.terremark.domain.TerremarkVirtualSystem> {
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
protected DateService dateService; protected DateService dateService;
@ -62,7 +62,7 @@ public class VirtualSystemHandler extends
private String virtualSystemIdentifier; private String virtualSystemIdentifier;
private String virtualSystemType; private String virtualSystemType;
private org.jclouds.vcloud.domain.TerremarkVirtualSystem system; private org.jclouds.vcloud.terremark.domain.TerremarkVirtualSystem system;
private boolean skip; private boolean skip;
@ -71,7 +71,7 @@ public class VirtualSystemHandler extends
this.dateService = dateService; this.dateService = dateService;
} }
public org.jclouds.vcloud.domain.TerremarkVirtualSystem getResult() { public org.jclouds.vcloud.terremark.domain.TerremarkVirtualSystem getResult() {
return system; return system;
} }
@ -134,7 +134,7 @@ public class VirtualSystemHandler extends
} else if (qName.equals("VirtualSystemType")) { } else if (qName.equals("VirtualSystemType")) {
this.virtualSystemType = currentText.toString().trim(); this.virtualSystemType = currentText.toString().trim();
} else if (qName.equals("q2:System")) { } 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, automaticRecoveryAction, automaticShutdownAction, automaticStartupAction,
automaticStartupActionDelay, automaticStartupActionSequenceNumber, caption, automaticStartupActionDelay, automaticStartupActionSequenceNumber, caption,
configurationDataRoot, configurationFile, configurationID, creationTime, 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.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen; import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.domain.NamedResource;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshClient.Factory; import org.jclouds.ssh.SshClient.Factory;
import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.jclouds.util.Utils; import org.jclouds.util.Utils;
import org.jclouds.vcloud.VCloudClientLiveTest; import org.jclouds.vcloud.VCloudClientLiveTest;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VAppStatus; 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.BaseHandlerTest;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.TerremarkVirtualSystem;
import org.jclouds.vcloud.domain.VAppStatus; import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.internal.VAppRoot; import org.jclouds.vcloud.endpoints.internal.VAppRoot;
import org.jclouds.vcloud.terremark.domain.TerremarkVApp; import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
import org.jclouds.vcloud.terremark.domain.TerremarkVirtualSystem;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -94,7 +94,8 @@ public class TerremarkVAppHandlerTest extends BaseHandlerTest {
assertEquals(result.getLocation(), URI assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13775")); .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13775"));
assertEquals(result.getVDC(), new LinkImpl("application/vnd.vmware.vcloud.vdc+xml", URI 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"))); .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")));
} }
@ -114,17 +115,21 @@ public class TerremarkVAppHandlerTest extends BaseHandlerTest {
assertEquals(result.getLocation(), URI assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13850")); .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"))); .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")));
assertEquals( assertEquals(
result.getComputeOptions(), result.getComputeOptions(),
new LinkImpl( new NamedResourceImpl(
"compute",
"Compute Options",
MediaType.APPLICATION_XML, MediaType.APPLICATION_XML,
URI URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13850/options/compute"))); .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13850/options/compute")));
assertEquals( assertEquals(
result.getCustomizationOptions(), result.getCustomizationOptions(),
new LinkImpl( new NamedResourceImpl(
"customization",
"Customization Options",
MediaType.APPLICATION_XML, MediaType.APPLICATION_XML,
URI URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13850/options/customization"))); .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;
import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.ParserModule; 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.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.VCloudApi; import org.jclouds.vcloud.endpoints.VCloudApi;
import org.jclouds.vcloud.terremark.domain.TerremarkVDC; import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -107,13 +106,21 @@ public class TerremarkVDCHandlerTest {
"application/vnd.vmware.vcloud.network+xml", "application/vnd.vmware.vcloud.network+xml",
URI URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708")))); .create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"))));
assertEquals(result.getCatalog(), new NamedLinkImpl("Miami Environment 1", CATALOG_XML, URI assertEquals(result.getCatalog(), new NamedResourceImpl("catalog", "Miami Environment 1",
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"))); CATALOG_XML,
assertEquals(result.getPublicIps(), new NamedLinkImpl("Public IPs", "application/xml", URI 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"))); .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps")));
assertEquals( assertEquals(
result.getInternetServices(), result.getInternetServices(),
new NamedLinkImpl( new NamedResourceImpl(
"internetServices",
"Internet Services", "Internet Services",
"application/xml", "application/xml",
URI URI

View File

@ -28,7 +28,7 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import org.jclouds.http.functions.BaseHandlerTest; 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.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;