From 4e01fa336953b6a6301619f3f3e03c4e30f547f5 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Tue, 7 Feb 2012 11:04:24 +0000 Subject: [PATCH 01/14] Fix initial entity domain object heirarchy, particularly Builders and correct JAXB XML parsing --- .../vcloud/director/v1_5/domain/Entity.java | 220 +++++++--------- .../director/v1_5/domain/EntityType.java | 239 ++++++++++++++++++ .../vcloud/director/v1_5/domain/Error.java | 15 +- .../vcloud/director/v1_5/domain/Link.java | 52 +++- .../vcloud/director/v1_5/domain/Org.java | 88 ++++++- .../vcloud/director/v1_5/domain/OrgList.java | 20 +- .../director/v1_5/domain/Reference.java | 215 ++++------------ .../director/v1_5/domain/ReferenceType.java | 221 ++++++++++++++++ .../vcloud/director/v1_5/domain/Resource.java | 199 +++++---------- .../director/v1_5/domain/ResourceType.java | 202 +++++++++++++++ .../vcloud/director/v1_5/domain/Session.java | 9 +- .../v1_5/domain/SessionWithToken.java | 6 +- .../v1_5/features/OrgClientExpectTest.java | 20 +- 13 files changed, 1033 insertions(+), 473 deletions(-) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ReferenceType.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java index affc2c05eb..c31c203205 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java @@ -19,80 +19,41 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; import java.net.URI; +import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.Sets; /** - * Basic entity type in the vCloud object model. + * An entity. * - * Includes a name, an optional description, and an optional list of links - * - *
- * <xs:complexType name="EntityType">
- * 
- * - * @author Adrian Cole + * @author grkvlt@apache.org */ -public class Entity> extends Resource { +public class Entity extends EntityType { - public static > Builder builder() { - return new Builder(); + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); } @Override - public Builder toBuilder() { - return new Builder().fromEntity(this); + public Builder toBuilder() { + return new Builder(); } - public static class Builder> extends Resource.Builder { - - protected String description; - protected TaskList tasks; - protected String name; - protected String id; - - /** - * @see Entity#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see Entity#getDescription() - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * @see Entity#getId() - */ - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * @see Entity#getTasks() - */ - public Builder tasks(TaskList tasks) { - this.tasks = tasks; - return this; - } + public static class Builder extends EntityType.Builder { @Override - public Entity build() { - Entity entity = new Entity(href, name); + public Entity build() { + Entity entity = new Entity(href, name); entity.setDescription(description); entity.setTasks(tasks); entity.setId(id); @@ -102,99 +63,100 @@ public class Entity> extends Resource { } /** - * {@inheritDoc} + * @see EntityType#getName() */ @Override - public Builder fromResource(Resource in) { - return Builder.class.cast(super.fromResource(in)); + public Builder name(String name) { + this.name = name; + return this; } - public Builder fromEntity(Entity in) { - return fromResource(in).description(in.getDescription()).tasks(in.getTasks()).id(in.getId()).name(in.getName()); + /** + * @see EntityType#getDescription() + */ + @Override + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see EntityType#getId() + */ + @Override + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see EntityType#getTasks() + */ + @Override + public Builder tasks(TaskList tasks) { + this.tasks = tasks; + return this; + } + + /** + * @see ReferenceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ReferenceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder link(Link link) { + this.links.add(checkNotNull(link, "link")); + return this; + } + + @Override + public Builder fromEntityType(EntityType in) { + return Builder.class.cast(super.fromEntityType(in)); + } + + public Builder fromEntity(Entity in) { + return fromEntityType(in); } } - @XmlElement(namespace = NS, name = "Description") - protected String description; - @XmlElement(namespace = NS, name = "TasksInProgress") - protected TaskList tasks; - @XmlAttribute - protected String id; - @XmlAttribute - protected String name; - protected Entity(URI href, String name) { - super(href); - this.name = name; + super(href, name); } protected Entity() { // For JAXB } - /** - * Optional description. - */ - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - /** - * A list of queued, running, or recently completed tasks associated with this entity. - */ - public TaskList getTasks() { - return tasks; - } - - public void setTasks(TaskList tasks) { - this.tasks = tasks; - } - - /** - * The resource identifier, expressed in URN format. - * - * The value of this attribute uniquely identifies the resource, persists for the life of the - * resource, and is never reused. - */ - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - /** - * Contains the name of the the entity. - * - * The object type, specified as a MIME content type, of the object that the link references. - * This attribute is present only for links to objects. It is not present for links to actions. - * - * @return type definition, type, expressed as an HTTP Content-Type - */ - public String getName() { - return name; - } - @Override public boolean equals(Object o) { if (!super.equals(o)) return false; - Entity that = Entity.class.cast(o); - return super.equals(that) && equal(this.id, that.id) && equal(this.description, that.description) && equal(this.tasks, that.tasks); - } - - @Override - public int hashCode() { - return super.hashCode() + Objects.hashCode(description, tasks, id, name); - } - - @Override - public ToStringHelper string() { - return super.string().add("description", description).add("tasks", tasks).add("id", id).add("name", name); + Entity that = Entity.class.cast(o); + return super.equals(that); } } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java new file mode 100644 index 0000000000..c38e8d5886 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java @@ -0,0 +1,239 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.director.v1_5.domain; + +import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; + +import java.net.URI; +import java.util.Set; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.Sets; + +/** + * Basic entity type in the vCloud object model. + * + * Includes a name, an optional description, and an optional list of links + * + *
+ * <xs:complexType name="EntityType">
+ * 
+ * + * @author grkvlt@apache.org + */ +public class EntityType> extends ResourceType { + + public static > Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder().fromEntity(this); + } + + public static class Builder> extends ResourceType.Builder { + + protected String description; + protected TaskList tasks; + protected String name; + protected String id; + + /** + * @see EntityType#getName() + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see EntityType#getDescription() + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see EntityType#getId() + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see EntityType#getTasks() + */ + public Builder tasks(TaskList tasks) { + this.tasks = tasks; + return this; + } + + @Override + public EntityType build() { + EntityType entity = new EntityType(href, name); + entity.setDescription(description); + entity.setTasks(tasks); + entity.setId(id); + entity.setType(type); + entity.setLinks(links); + return entity; + } + + /** + * @see ReferenceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ReferenceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder link(Link link) { + this.links.add(checkNotNull(link, "link")); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder fromResourceType(ResourceType in) { + return Builder.class.cast(super.fromResourceType(in)); + } + + public Builder fromEntityType(EntityType in) { + return fromResourceType(in).description(in.getDescription()).tasks(in.getTasks()).id(in.getId()).name(in.getName()); + } + } + + @XmlElement(namespace = NS, name = "Description") + private String description; + @XmlElement(namespace = NS, name = "TasksInProgress") + private TaskList tasks; + @XmlAttribute + private String id; + @XmlAttribute + private String name; + + protected EntityType(URI href, String name) { + super(href); + this.name = name; + } + + protected EntityType() { + // For JAXB + } + + /** + * Optional description. + */ + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + /** + * A list of queued, running, or recently completed tasks associated with this entity. + */ + public TaskList getTasks() { + return tasks; + } + + public void setTasks(TaskList tasks) { + this.tasks = tasks; + } + + /** + * The resource identifier, expressed in URN format. + * + * The value of this attribute uniquely identifies the resource, persists for the life of the + * resource, and is never reused. + */ + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + /** + * Contains the name of the the entity. + * + * The object type, specified as a MIME content type, of the object that the link references. + * This attribute is present only for links to objects. It is not present for links to actions. + * + * @return type definition, type, expressed as an HTTP Content-Type + */ + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (!super.equals(o)) + return false; + EntityType that = EntityType.class.cast(o); + return super.equals(that) && equal(this.id, that.id) && equal(this.description, that.description) && equal(this.tasks, that.tasks); + } + + @Override + public int hashCode() { + return super.hashCode() + Objects.hashCode(description, tasks, id, name); + } + + @Override + public ToStringHelper string() { + return super.string().add("description", description).add("tasks", tasks).add("id", id).add("name", name); + } +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java index de87f8e493..3032a03d0e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java @@ -4,6 +4,8 @@ import static com.google.common.base.Objects.*; import static com.google.common.base.Preconditions.*; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; @@ -16,9 +18,10 @@ import com.google.common.base.Objects; * <xs:complexType name="ErrorType"> * * - * @author Adrian Cole + * @author grkvlt@apache.org */ @XmlRootElement(namespace = NS, name = "Error") +@XmlAccessorType(XmlAccessType.FIELD) public class Error { public static Builder builder() { @@ -94,15 +97,15 @@ public class Error { } @XmlAttribute - protected String message; + private String message; @XmlAttribute - protected int majorErrorCode; + private int majorErrorCode; @XmlAttribute - protected String minorErrorCode; + private String minorErrorCode; @XmlAttribute - protected String vendorSpecificErrorCode; + private String vendorSpecificErrorCode; @XmlAttribute - protected String stackTrace; + private String stackTrace; private Error(String message, int majorErrorCode, String minorErrorCode) { this.message = checkNotNull(message, "message"); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java index 921e217fc4..283ac6048e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java @@ -1,7 +1,7 @@ package org.jclouds.vcloud.director.v1_5.domain; -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; import java.net.URI; import java.util.Map; @@ -20,7 +20,7 @@ import com.google.common.base.Objects.ToStringHelper; * * @author Adrian Cole */ -public class Link extends Reference { +public class Link extends ReferenceType { @SuppressWarnings("unchecked") public static Builder builder() { @@ -35,7 +35,7 @@ public class Link extends Reference { return new Builder().fromLink(this); } - public static class Builder extends Reference.Builder { + public static class Builder extends ReferenceType.Builder { protected String rel; @@ -47,11 +47,49 @@ public class Link extends Reference { return this; } + @Override public Link build() { Link link = new Link(href, rel); link.setId(id); link.setName(name); link.setType(type); + return link; + } + + /** + * @see ReferenceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ReferenceType#getId() + */ + @Override + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see ReferenceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getName() + */ + @Override + public Builder name(String name) { + this.name = name; + return this; } public Builder fromLink(Link in) { @@ -61,13 +99,15 @@ public class Link extends Reference { /** * {@inheritDoc} */ - public Builder fromReference(Reference in) { + @Override + public Builder fromReference(ReferenceType in) { return Builder.class.cast(super.fromReference(in)); } /** * {@inheritDoc} */ + @Override public Builder fromAttributes(Map attributes) { super.fromAttributes(attributes); rel(attributes.get("rel")); @@ -76,7 +116,7 @@ public class Link extends Reference { } @XmlAttribute - protected String rel; + private String rel; private Link(URI href, String rel) { super(href); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java index 3f03aaeae5..36ed8383fa 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java @@ -18,22 +18,18 @@ */ package org.jclouds.vcloud.director.v1_5.domain; -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; +import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; import java.net.URI; import java.util.Set; -import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.jclouds.vcloud.director.v1_5.domain.Entity.Builder; - import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; /** @@ -48,7 +44,7 @@ import com.google.common.collect.Sets; * @author Adrian Cole */ @XmlRootElement(namespace = NS, name = "Org") -public class Org extends Entity { +public class Org extends EntityType { @SuppressWarnings("unchecked") public static Builder builder() { @@ -60,7 +56,7 @@ public class Org extends Entity { return new Builder().fromOrg(this); } - public static class Builder extends Entity.Builder { + public static class Builder extends EntityType.Builder { private String fullName; @@ -83,8 +79,80 @@ public class Org extends Entity { return org; } + /** + * @see EntityType#getName() + */ @Override - public Builder fromEntity(Entity in) { + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see EntityType#getDescription() + */ + @Override + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see EntityType#getId() + */ + @Override + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see EntityType#getTasks() + */ + @Override + public Builder tasks(TaskList tasks) { + this.tasks = tasks; + return this; + } + + /** + * @see ReferenceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ReferenceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder link(Link link) { + this.links.add(checkNotNull(link, "link")); + return this; + } + + @Override + public Builder fromEntity(EntityType in) { return Builder.class.cast(super.fromEntity(in)); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java index 4f480e94c3..44c98f159e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java @@ -18,9 +18,9 @@ */ package org.jclouds.vcloud.director.v1_5.domain; -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; +import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; import java.util.Set; @@ -49,12 +49,12 @@ public class OrgList { public static class Builder { - private Set orgs = Sets.newLinkedHashSet(); + private Set orgs = Sets.newLinkedHashSet(); /** * @see OrgList#getOrgs */ - public Builder orgs(Set orgs) { + public Builder orgs(Set orgs) { this.orgs = Sets.newLinkedHashSet(checkNotNull(orgs, "orgs")); return this; } @@ -62,7 +62,7 @@ public class OrgList { /** * @see OrgList#getOrgs */ - public Builder addOrg(OrgLink org) { + public Builder org(Reference org) { orgs.add(checkNotNull(org, "org")); return this; } @@ -80,14 +80,14 @@ public class OrgList { // For JAXB and builder use } - private OrgList(Set orgs) { + private OrgList(Set orgs) { this.orgs = ImmutableSet.copyOf(orgs); } @XmlElement(namespace = NS, name = "Org") - private Set orgs = Sets.newLinkedHashSet(); + private Set orgs = Sets.newLinkedHashSet(); - public Set getOrgs() { + public Set getOrgs() { return ImmutableSet.copyOf(orgs); } @@ -98,7 +98,7 @@ public class OrgList { if (o == null || getClass() != o.getClass()) return false; OrgList that = OrgList.class.cast(o); - return equal(orgs, that.orgs); + return equal(this.orgs, that.orgs); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java index 49aac7ad0b..33ecf0c234 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java @@ -18,202 +18,97 @@ */ package org.jclouds.vcloud.director.v1_5.domain; -import static com.google.common.base.Objects.equal; - import java.net.URI; -import java.util.Map; - -import javax.xml.bind.annotation.XmlAttribute; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; /** * A reference to a resource. - * - * Contains an href attribute and optional name and type attributes. - * - *
- * <xs:complexType name="ReferenceType">
- * 
* - * @author Adrian Cole + * @author grkvlt@apache.org */ -public class Reference> { +public class Reference extends ReferenceType { - public static > Builder builder() { - return new Builder(); + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); } - public Builder toBuilder() { - return new Builder().fromReference(this); + @Override + public Builder toBuilder() { + return new Builder().fromReference(this); } - public static class Builder> { + public static class Builder extends ReferenceType.Builder { - protected URI href; - protected String id; - protected String name; - protected String type; - - /** - * @see Reference#getHref() - */ - public Builder href(URI href) { - this.href = href; - return this; - } - - /** - * @see Reference#getId() - */ - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * @see Reference#getType() - */ - public Builder type(String type) { - this.type = type; - return this; - } - - /** - * @see Reference#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - public Reference build() { - Reference reference = new Reference(href); + @Override + public Reference build() { + Reference reference = new Reference(href); reference.setId(id); reference.setName(name); reference.setType(type); return reference; } - protected Builder fromReference(Reference in) { - return href(in.getHref()).id(in.getId()).name(in.getName()).type(in.getType()); + /** + * @see ReferenceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; } - protected Builder fromAttributes(Map attributes) { - return href(URI.create(attributes.get("href"))).id(attributes.get("id")).name(attributes.get("name")).type(attributes.get("type")); + /** + * @see ReferenceType#getId() + */ + @Override + public Builder id(String id) { + this.id = id; + return this; } + /** + * @see ReferenceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getName() + */ + @Override + public Builder name(String name) { + this.name = name; + return this; + } + + @Override + protected Builder fromReferenceType(ReferenceType in) { + return Builder.class.cast(super.fromReferenceType(in)); + } + + protected Builder fromReference(Reference in) { + return fromReferenceType(in); + } } - @XmlAttribute - protected URI href; - @XmlAttribute - protected String id; - @XmlAttribute - protected String name; - @XmlAttribute - protected String type; - protected Reference(URI href) { - this.href = href; + super(href); } protected Reference() { // For JAXB } - /** - * Contains the URI to the entity. - * - * An object reference, expressed in URL format. Because this URL includes the object identifier - * portion of the id attribute value, it uniquely identifies the object, persists for the life of - * the object, and is never reused. The value of the href attribute is a reference to a view of - * the object, and can be used to access a representation of the object that is valid in a - * particular context. Although URLs have a well-known syntax and a well-understood - * interpretation, a client should treat each href as an opaque string. The rules that govern how - * the server constructs href strings might change in future releases. - * - * @return an opaque reference and should never be parsed - */ - public URI getHref() { - return href; - } - - /** - * The resource identifier, expressed in URN format. - * - * The value of this attribute uniquely identifies the resource, persists for the life of the - * resource, and is never reused. - */ - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - /** - * Contains the name of the the entity. - * - * The object type, specified as a MIME content type, of the object that the link references. - * This attribute is present only for links to objects. It is not present for links to actions. - * - * @return type definition, type, expressed as an HTTP Content-Type - */ - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - /** - * Contains the type of the the entity. - * - * The object type, specified as a MIME content type, of the object that the link references. - * This attribute is present only for links to objects. It is not present for links to actions. - * - * @return type definition, type, expressed as an HTTP Content-Type - */ - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - /** - * @see #getHref() - */ - public URI getURI() { - return getHref(); - } - @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Reference that = Reference.class.cast(o); - return equal(this.href, that.href) && equal(this.id, that.id) && equal(this.name, that.name) && equal(this.type, that.type); - } - - @Override - public int hashCode() { - return Objects.hashCode(href, id, name, type); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper("").add("href", href).add("id", id).add("name", name).add("type", type); + Reference that = Reference.class.cast(o); + return super.equals(that); } } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ReferenceType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ReferenceType.java new file mode 100644 index 0000000000..4804bcac59 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ReferenceType.java @@ -0,0 +1,221 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.director.v1_5.domain; + +import static com.google.common.base.Objects.*; + +import java.net.URI; +import java.util.Map; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; + +/** + * A reference to a resource. + * + * Contains an href attribute and optional name and type attributes. + * + *
+ * <xs:complexType name="ReferenceType">
+ * 
+ * + * @author grkvlt@apache.org + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class ReferenceType> { + + public static > Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromReference(this); + } + + public static class Builder> { + + protected URI href; + protected String id; + protected String name; + protected String type; + + /** + * @see ReferenceType#getHref() + */ + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ReferenceType#getId() + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see ReferenceType#getType() + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getName() + */ + public Builder name(String name) { + this.name = name; + return this; + } + + public ReferenceType build() { + ReferenceType reference = new ReferenceType(href); + reference.setId(id); + reference.setName(name); + reference.setType(type); + return reference; + } + + protected Builder fromReferenceType(ReferenceType in) { + return href(in.getHref()).id(in.getId()).name(in.getName()).type(in.getType()); + } + + protected Builder fromAttributes(Map attributes) { + return href(URI.create(attributes.get("href"))).id(attributes.get("id")).name(attributes.get("name")).type(attributes.get("type")); + } + } + + @XmlAttribute + private URI href; + @XmlAttribute + private String id; + @XmlAttribute + private String name; + @XmlAttribute + private String type; + + protected ReferenceType(URI href) { + this.href = href; + } + + protected ReferenceType() { + // For JAXB + } + + /** + * Contains the URI to the entity. + * + * An object reference, expressed in URL format. Because this URL includes the object identifier + * portion of the id attribute value, it uniquely identifies the object, persists for the life of + * the object, and is never reused. The value of the href attribute is a reference to a view of + * the object, and can be used to access a representation of the object that is valid in a + * particular context. Although URLs have a well-known syntax and a well-understood + * interpretation, a client should treat each href as an opaque string. The rules that govern how + * the server constructs href strings might change in future releases. + * + * @return an opaque reference and should never be parsed + */ + public URI getHref() { + return href; + } + + /** + * The resource identifier, expressed in URN format. + * + * The value of this attribute uniquely identifies the resource, persists for the life of the + * resource, and is never reused. + */ + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + /** + * Contains the name of the the entity. + * + * The object type, specified as a MIME content type, of the object that the link references. + * This attribute is present only for links to objects. It is not present for links to actions. + * + * @return type definition, type, expressed as an HTTP Content-Type + */ + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Contains the type of the the entity. + * + * The object type, specified as a MIME content type, of the object that the link references. + * This attribute is present only for links to objects. It is not present for links to actions. + * + * @return type definition, type, expressed as an HTTP Content-Type + */ + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + /** + * @see #getHref() + */ + public URI getURI() { + return getHref(); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ReferenceType that = ReferenceType.class.cast(o); + return equal(this.href, that.href) && equal(this.id, that.id) && equal(this.name, that.name) && equal(this.type, that.type); + } + + @Override + public int hashCode() { + return Objects.hashCode(href, id, name, type); + } + + @Override + public String toString() { + return string().toString(); + } + + protected ToStringHelper string() { + return Objects.toStringHelper("").add("href", href).add("id", id).add("name", name).add("type", type); + } +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java index 2d5fb93515..0778dd35ea 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java @@ -18,185 +18,112 @@ */ package org.jclouds.vcloud.director.v1_5.domain; -import static com.google.common.base.Objects.equal; +import static com.google.common.base.Objects.*; import static com.google.common.base.Preconditions.*; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; import java.net.URI; -import java.util.Map; import java.util.Set; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; -import org.jclouds.vcloud.director.v1_5.domain.Task.Builder; +import org.jclouds.vcloud.director.v1_5.domain.Resource.Builder; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.Sets; /** - * The base type for all objects in the vCloud model. - * - * Has an optional list of links and href and type attributes. - * - *
- * <xs:complexType name="ResourceType">
- * 
+ * A resource. * - * @author Adrian Cole + * @author grkvlt@apache.org */ -public class Resource> { +public class Resource extends ResourceType { - public static > Builder builder() { - return new Builder(); + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); } - public Builder toBuilder() { - return new Builder().fromResource(this); + @Override + public Builder toBuilder() { + return new Builder().fromResource(this); } - public static class Builder> { + public static class Builder extends ResourceType.Builder { - protected URI href; - protected String type; - protected Set links = Sets.newLinkedHashSet(); - - /** - * @see Reference#getHref() - */ - public Builder href(URI href) { - this.href = href; - return this; - } - - /** - * @see Reference#getType() - */ - public Builder type(String type) { - this.type = type; - return this; - } - - /** - * @see Reference#getLinks() - */ - public Builder links(Set links) { - this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); - return this; - } - - /** - * @see Reference#getLinks() - */ - public Builder link(Link link) { - this.links.add(checkNotNull(link, "link")); - return this; - } - - public Resource build() { - Resource reference = new Resource(href); + @Override + public Resource build() { + Resource reference = new Resource(href); reference.setType(type); reference.setLinks(links); return reference; } - protected Builder fromResource(Resource in) { - return href(in.getHref()).type(in.getType()).links(in.getLinks()); + /** + * @see ResourceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ResourceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ResourceType#getLinks() + */ + @Override + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } + + /** + * @see ResourceType#getLinks() + */ + @Override + public Builder link(Link link) { + this.links.add(checkNotNull(link, "link")); + return this; + } + + @Override + protected Builder fromResourceType(ResourceType in) { + return Builder.class.cast(super.fromResourceType(in)); + } + + protected Builder fromResource(Resource in) { + return fromResourceType(in); } } - @XmlAttribute - protected URI href; - @XmlAttribute - protected String type; - @XmlElement(namespace = NS, name = "Link") - protected Set links = Sets.newLinkedHashSet(); - protected Resource(URI href) { - this.href = href; + super(href); } protected Resource() { // For JAXB } - /** - * Contains the URI to the entity. - * - * An object reference, expressed in URL format. Because this URL includes the object identifier - * portion of the id attribute value, it uniquely identifies the object, persists for the life of - * the object, and is never reused. The value of the href attribute is a reference to a view of - * the object, and can be used to access a representation of the object that is valid in a - * particular context. Although URLs have a well-known syntax and a well-understood - * interpretation, a client should treat each href as an opaque string. The rules that govern how - * the server constructs href strings might change in future releases. - * - * @return an opaque reference and should never be parsed - */ - public URI getHref() { - return href; - } - - /** - * Contains the type of the the entity. - * - * The object type, specified as a MIME content type, of the object that the link references. - * This attribute is present only for links to objects. It is not present for links to actions. - * - * @return type definition, type, expressed as an HTTP Content-Type - */ - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - /** - * Set of optional links to an entity or operation associated with this object. - */ - public SetgetLinks() { - return links; - } - - public void setLinks(Set links) { - this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); - } - - public void addLink(Link link) { - this.links.add(checkNotNull(link, "link")); - } - - /** - * @see #getHref() - */ - public URI getURI() { - return getHref(); - } - @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Resource that = Resource.class.cast(o); - return equal(this.href, that.href) && equal(this.links, that.links) && equal(this.type, that.type); - } - - @Override - public int hashCode() { - return Objects.hashCode(href, links, type); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper("").add("href", href).add("links", links).add("type", type); + Resource that = Resource.class.cast(o); + return super.equals(that); } } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java new file mode 100644 index 0000000000..b04fcdccf2 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java @@ -0,0 +1,202 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.director.v1_5.domain; + +import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; + +import java.net.URI; +import java.util.Set; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.Sets; + +/** + * The base type for all objects in the vCloud model. + * + * Has an optional list of links and href and type attributes. + * + *
+ * <xs:complexType name="ResourceType">
+ * 
+ * + * @author Adrian Cole + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class ResourceType> { + + public static > Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromResource(this); + } + + public static class Builder> { + + protected URI href; + protected String type; + protected Set links = Sets.newLinkedHashSet(); + + /** + * @see ResourceType#getHref() + */ + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ResourceType#getType() + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ResourceType#getLinks() + */ + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } + + /** + * @see ResourceType#getLinks() + */ + public Builder link(Link link) { + this.links.add(checkNotNull(link, "link")); + return this; + } + + public ResourceType build() { + ResourceType reference = new ResourceType(href); + reference.setType(type); + reference.setLinks(links); + return reference; + } + + protected Builder fromResourceType(ResourceType in) { + return href(in.getHref()).type(in.getType()).links(in.getLinks()); + } + } + + @XmlAttribute + private URI href; + @XmlAttribute + private String type; + @XmlElement(namespace = NS, name = "Link") + private Set links = Sets.newLinkedHashSet(); + + protected ResourceType(URI href) { + this.href = href; + } + + protected ResourceType() { + // For JAXB + } + + /** + * Contains the URI to the entity. + * + * An object reference, expressed in URL format. Because this URL includes the object identifier + * portion of the id attribute value, it uniquely identifies the object, persists for the life of + * the object, and is never reused. The value of the href attribute is a reference to a view of + * the object, and can be used to access a representation of the object that is valid in a + * particular context. Although URLs have a well-known syntax and a well-understood + * interpretation, a client should treat each href as an opaque string. The rules that govern how + * the server constructs href strings might change in future releases. + * + * @return an opaque reference and should never be parsed + */ + public URI getHref() { + return href; + } + + /** + * Contains the type of the the entity. + * + * The object type, specified as a MIME content type, of the object that the link references. + * This attribute is present only for links to objects. It is not present for links to actions. + * + * @return type definition, type, expressed as an HTTP Content-Type + */ + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + /** + * Set of optional links to an entity or operation associated with this object. + */ + public SetgetLinks() { + return links; + } + + public void setLinks(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + } + + public void addLink(Link link) { + this.links.add(checkNotNull(link, "link")); + } + + /** + * @see #getHref() + */ + public URI getURI() { + return getHref(); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ResourceType that = ResourceType.class.cast(o); + return equal(this.href, that.href) && equal(this.links, that.links) && equal(this.type, that.type); + } + + @Override + public int hashCode() { + return Objects.hashCode(href, links, type); + } + + @Override + public String toString() { + return string().toString(); + } + + protected ToStringHelper string() { + return Objects.toStringHelper("").add("href", href).add("links", links).add("type", type); + } +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Session.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Session.java index c374db31c8..8778581e99 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Session.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Session.java @@ -18,13 +18,15 @@ */ package org.jclouds.vcloud.director.v1_5.domain; -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; +import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; import java.net.URI; import java.util.Set; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -41,6 +43,7 @@ import com.google.common.collect.Sets; * @author Adrian Cole */ @XmlRootElement(namespace = NS, name = "Session") +@XmlAccessorType(XmlAccessType.FIELD) public class Session { public static Builder builder() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SessionWithToken.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SessionWithToken.java index faadb84958..a9575e50ca 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SessionWithToken.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SessionWithToken.java @@ -18,7 +18,7 @@ */ package org.jclouds.vcloud.director.v1_5.domain; -import static com.google.common.base.Objects.equal; +import static com.google.common.base.Objects.*; import com.google.common.base.Objects; @@ -68,8 +68,8 @@ public class SessionWithToken { } - protected Session session; - protected String token; + private Session session; + private String token; protected SessionWithToken(String token, Session session) { this.session = session; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index 3efcae7a0a..f059be2193 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.vcloud.director.v1_5.features; -import static org.testng.Assert.assertEquals; +import static org.testng.Assert.*; import java.net.URI; @@ -28,8 +28,8 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Org; -import org.jclouds.vcloud.director.v1_5.domain.OrgLink; import org.jclouds.vcloud.director.v1_5.domain.OrgList; +import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.testng.annotations.Test; @@ -61,7 +61,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgListRequest, orgListResponse); assertEquals(client.getOrgClient().getOrgList(), OrgList.builder() - .addOrg(OrgLink.builder() + .org(Reference.builder() .type("application/vnd.vmware.vcloud.org+xml") .name("JClouds") .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) @@ -95,41 +95,41 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest .id("urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0") .type(VCloudDirectorMediaType.ORG_XML) .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) - .addLink(Link.builder() + .link(Link.builder() .rel("down") .type("application/vnd.vmware.vcloud.vdc+xml") .name("Cluster01-JClouds") .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07")) .build()) - .addLink(Link.builder() + .link(Link.builder() .rel("down") .type("application/vnd.vmware.vcloud.tasksList+xml") .href(URI.create("https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) .build()) - .addLink(Link.builder() + .link(Link.builder() .rel("down") .type("application/vnd.vmware.vcloud.catalog+xml") .name("Public") .href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c")) .build()) - .addLink(Link.builder() + .link(Link.builder() .rel("down") .type("application/vnd.vmware.vcloud.controlAccess+xml") .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c/controlAccess/")) .build()) - .addLink(Link.builder() + .link(Link.builder() .rel("down") .type("application/vnd.vmware.vcloud.orgNetwork+xml") .name("ilsolation01-Jclouds") .href(URI.create("https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38")) .build()) - .addLink(Link.builder() + .link(Link.builder() .rel("down") .type("application/vnd.vmware.vcloud.orgNetwork+xml") .name("internet01-Jclouds") .href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c")) .build()) - .addLink(Link.builder() + .link(Link.builder() .rel("down") .type("application/vnd.vmware.vcloud.metadata+xml") .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata")) From 8828daf89b7c31ed623911f087d7a31d9eb28253 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Tue, 7 Feb 2012 11:08:04 +0000 Subject: [PATCH 02/14] Added initial Task and associated domain objects --- .../vcloud/director/v1_5/domain/Task.java | 370 ++++++++++++++++++ .../vcloud/director/v1_5/domain/TaskList.java | 117 ++++++ .../director/v1_5/domain/TasksInProgress.java | 116 ++++++ 3 files changed, 603 insertions(+) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TaskList.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksInProgress.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java new file mode 100644 index 0000000000..7a0a269897 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java @@ -0,0 +1,370 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.director.v1_5.domain; + +import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; + +import java.net.URI; +import java.util.Date; +import java.util.Set; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.Sets; + +/** + * Represents an asynchronous or long-running task in the vCloud environment. + * + *
+ * <xs:complexType name="TaskType">
+ * 
+ * + * @author grkvlt@apache.org + */ +@XmlRootElement(namespace = NS, name = "Task") +public class Task extends EntityType { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder().fromTask(this); + } + + public static class Builder extends EntityType.Builder { + + private Error error; + private Org org; + private Integer progress; + private String status; + private String operation; + private String operationName; + private Date startTime; + private Date endTime; + private Date expiryTime; + + /** + * @see Task#getError() + */ + public Builder error(Error error) { + this.error = error; + return this; + } + + /** + * @see Task#getOrg() + */ + public Builder org(Org org) { + this.org = org; + return this; + } + + /** + * @see Task#getProgress() + */ + public Builder progress(Integer progress) { + this.progress = progress; + return this; + } + + /** + * @see Task#getStatus() + */ + public Builder status(String status) { + this.status = status; + return this; + } + + /** + * @see Task#getOperation() + */ + public Builder operation(String operation) { + this.operation = operation; + return this; + } + + /** + * @see Task#getOperationName() + */ + public Builder operationName(String operationName) { + this.operationName = operationName; + return this; + } + + /** + * @see Task#getStartTime() + */ + public Builder startTime(Date startTime) { + this.startTime = startTime; + return this; + } + + /** + * @see Task#getEndTime() + */ + public Builder endTime(Date endTime) { + this.endTime = endTime; + return this; + } + + /** + * @see Task#getExpiryTime() + */ + public Builder expiryTime(Date expiryTime) { + this.expiryTime = expiryTime; + return this; + } + + @Override + public Task build() { + Task task = new Task(href, name); + task.setError(error); + task.setOrg(org); + task.setProgress(progress); + task.setStatus(status); + task.setOperation(operation); + task.setOperationName(operationName); + task.setStartTime(startTime); + task.setEndTime(endTime); + task.setExpiryTime(expiryTime); + return task; + } + + /** + * @see EntityType#getName() + */ + @Override + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see EntityType#getDescription() + */ + @Override + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see EntityType#getId() + */ + @Override + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see EntityType#getTasks() + */ + @Override + public Builder tasks(TaskList tasks) { + this.tasks = tasks; + return this; + } + + /** + * @see ReferenceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ReferenceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder link(Link link) { + this.links.add(checkNotNull(link, "link")); + return this; + } + + @Override + public Builder fromEntity(EntityType in) { + return Builder.class.cast(super.fromEntity(in)); + } + + public Builder fromTask(Task in) { + return fromEntity(in).error(in.getError()).org(in.getOrg()).progress(in.getProgress()).status(in.getStatus()) + .operation(in.getOperation()).operationName(in.getOperationName()); + } + } + + private Task() { + // For JAXB and builder use + } + + private Task(URI href, String name) { + super(href, name); + } + + @XmlElement(namespace = NS, name = "Error") + private Error error; + @XmlElement(namespace = NS, name = "Organization") + private Org org; + @XmlElement(namespace = NS, name = "Progress") + private Integer progress; + @XmlElement(namespace = NS, name = "Owner") + private Entity owner; + @XmlElement(namespace = NS, name = "User") + private Entity user; + @XmlElement(namespace = NS, name = "Params") + private Object params; + @XmlAttribute(namespace = NS, name = "status") + private String status; + @XmlAttribute(namespace = NS, name = "operation") + private String operation; + @XmlAttribute(namespace = NS, name = "operationName") + private String operationName; + @XmlAttribute(namespace = NS, name = "startTime") + private Date startTime; + @XmlAttribute(namespace = NS, name = "endTime") + private Date endTime; + @XmlAttribute(namespace = NS, name = "expiryTime") + private Date expiryTime; + + public Error getError() { + return error; + } + + public void setError(Error error) { + this.error = error; + } + + public Org getOrg() { + return org; + } + + public void setOrg(Org org) { + this.org = org; + } + + public Integer getProgress() { + return progress; + } + + public void setProgress(Integer progress) { + this.progress = progress; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getOperation() { + return operation; + } + + public void setOperation(String operation) { + this.operation = operation; + } + + public String getOperationName() { + return operationName; + } + + public void setOperationName(String operationName) { + this.operationName = operationName; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Date getExpiryTime() { + return expiryTime; + } + + public void setExpiryTime(Date expiryTime) { + this.expiryTime = expiryTime; + } + + @Override + public boolean equals(Object o) { + if (!super.equals(o)) + return false; + Task that = Task.class.cast(o); + return super.equals(that) && equal(this.error, that.error) && equal(this.org, that.org) && + equal(this.progress, that.progress) && equal(this.status, that.status) && + equal(this.operation, that.operation) && equal(this.operationName, that.operationName) && + equal(this.startTime, that.startTime) && equal(this.endTime, that.endTime) && + equal(this.expiryTime, that.expiryTime); + } + + @Override + public int hashCode() { + return super.hashCode() + Objects.hashCode(error, org, progress, status, operation, operationName, + startTime, endTime, expiryTime); + } + + @Override + public ToStringHelper string() { + return super.string().add("error", error).add("org", org).add("progress", progress).add("status", status) + .add("operation", operation).add("operationName", operationName).add("startTime", startTime) + .add("endTime", endTime).add("expiryTime", expiryTime); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TaskList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TaskList.java new file mode 100644 index 0000000000..c3a34c20b4 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TaskList.java @@ -0,0 +1,117 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.task/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.director.v1_5.domain; + +import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; + +import java.util.Collection; +import java.util.Set; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +/** + * A list of tasks. + * + * @author Adrian Cole + */ +@XmlRootElement(namespace = NS, name = "TaskList") +@XmlAccessorType(XmlAccessType.FIELD) +public class TaskList { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(); + } + + public static class Builder { + + protected Set tasks = Sets.newLinkedHashSet(); + + /** + * @see TaskList#getTasks() + */ + public Builder tasks(Collection tasks) { + this.tasks = Sets.newLinkedHashSet(checkNotNull(tasks, "tasks")); + return this; + } + + /** + * @see TaskList#getTasks() + */ + public Builder task(Task task) { + this.tasks.add(checkNotNull(task, "task")); + return this; + } + + public TaskList build() { + return new TaskList(tasks); + } + + public Builder fromTaskList(TaskList in) { + return tasks(in.getTasks()); + } + } + + protected TaskList() { + // For JAXB and builder use + } + + protected TaskList(Set tasks) { + this.tasks = ImmutableSet.copyOf(tasks); + } + + @XmlElement(namespace = NS, name = "Task") + private Set tasks = Sets.newLinkedHashSet(); + + public Set getTasks() { + return ImmutableSet.copyOf(tasks); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + TaskList that = TaskList.class.cast(o); + return equal(this.tasks, that.tasks); + } + + @Override + public int hashCode() { + return Objects.hashCode(tasks); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("tasks", tasks).toString(); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksInProgress.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksInProgress.java new file mode 100644 index 0000000000..3bec089111 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksInProgress.java @@ -0,0 +1,116 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.director.v1_5.domain; + +import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; + +import java.util.Collection; +import java.util.Set; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +/** + * @author grkvlt@apache.org + */ +@XmlRootElement(namespace = NS, name = "TasksInProgress") +@XmlAccessorType(XmlAccessType.FIELD) +public class TasksInProgress { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(); + } + + public static class Builder { + + protected Set tasks = Sets.newLinkedHashSet(); + + /** + * @see TasksInProgress#getTasks() + */ + public Builder tasks(Collection tasks) { + this.tasks = Sets.newLinkedHashSet(checkNotNull(tasks, "tasks")); + return this; + } + + /** + * @see TasksInProgress#getTasks() + */ + public Builder task(Task task) { + this.tasks.add(checkNotNull(task, "task")); + return this; + } + + public TaskList build() { + return new TaskList(tasks); + } + + public Builder fromTaskList(TaskList in) { + return tasks(in.getTasks()); + } + } + + protected TasksInProgress() { + // For JAXB and builder use + } + + protected TasksInProgress(Collection tasks) { + this.tasks = ImmutableSet.copyOf(tasks); + } + + @XmlElement(namespace = NS, name = "Task") + private Set tasks = Sets.newLinkedHashSet(); + + public Set getTasks() { + return ImmutableSet.copyOf(tasks); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + TasksInProgress that = TasksInProgress.class.cast(o); + return equal(this.tasks, that.tasks); + } + + @Override + public int hashCode() { + return Objects.hashCode(tasks); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("tasks", tasks).toString(); + } +} + From d2dac741485f008bd269599b6b3bd6d499ba0f4a Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Tue, 7 Feb 2012 13:48:53 +0000 Subject: [PATCH 03/14] Updates to domain objects for Task and TasksList --- .../vcloud/director/v1_5/domain/Entity.java | 8 ++-- .../director/v1_5/domain/EntityType.java | 34 ++++++++------ .../vcloud/director/v1_5/domain/Link.java | 6 +-- .../vcloud/director/v1_5/domain/Org.java | 14 +++--- .../director/v1_5/domain/ReferenceType.java | 2 +- .../director/v1_5/domain/ResourceType.java | 2 +- .../vcloud/director/v1_5/domain/Task.java | 15 +++--- .../director/v1_5/domain/TasksInProgress.java | 8 ++-- .../domain/{TaskList.java => TasksList.java} | 47 +++++++++++-------- 9 files changed, 74 insertions(+), 62 deletions(-) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{TaskList.java => TasksList.java} (67%) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java index c31c203205..1d932c9549 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java @@ -55,7 +55,7 @@ public class Entity extends EntityType { public Entity build() { Entity entity = new Entity(href, name); entity.setDescription(description); - entity.setTasks(tasks); + entity.setTasksInProgress(tasksInProgress); entity.setId(id); entity.setType(type); entity.setLinks(links); @@ -90,11 +90,11 @@ public class Entity extends EntityType { } /** - * @see EntityType#getTasks() + * @see EntityType#getTasksInProgress() */ @Override - public Builder tasks(TaskList tasks) { - this.tasks = tasks; + public Builder tasksInProgress(TasksInProgress tasksInProgress) { + this.tasksInProgress = tasksInProgress; return this; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java index c38e8d5886..cfedddaea3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java @@ -51,13 +51,13 @@ public class EntityType> extends ResourceType { @Override public Builder toBuilder() { - return new Builder().fromEntity(this); + return new Builder().fromEntityType(this); } public static class Builder> extends ResourceType.Builder { protected String description; - protected TaskList tasks; + protected TasksInProgress tasksInProgress; protected String name; protected String id; @@ -86,10 +86,10 @@ public class EntityType> extends ResourceType { } /** - * @see EntityType#getTasks() + * @see EntityType#getTasksInProgress() */ - public Builder tasks(TaskList tasks) { - this.tasks = tasks; + public Builder tasksInProgress(TasksInProgress tasksInProgress) { + this.tasksInProgress = tasksInProgress; return this; } @@ -97,7 +97,7 @@ public class EntityType> extends ResourceType { public EntityType build() { EntityType entity = new EntityType(href, name); entity.setDescription(description); - entity.setTasks(tasks); + entity.setTasksInProgress(tasksInProgress); entity.setId(id); entity.setType(type); entity.setLinks(links); @@ -149,14 +149,16 @@ public class EntityType> extends ResourceType { } public Builder fromEntityType(EntityType in) { - return fromResourceType(in).description(in.getDescription()).tasks(in.getTasks()).id(in.getId()).name(in.getName()); + return fromResourceType(in) + .description(in.getDescription()).tasksInProgress(in.getTasksInProgress()) + .id(in.getId()).name(in.getName()); } } @XmlElement(namespace = NS, name = "Description") private String description; @XmlElement(namespace = NS, name = "TasksInProgress") - private TaskList tasks; + private TasksInProgress tasksInProgress; @XmlAttribute private String id; @XmlAttribute @@ -185,12 +187,12 @@ public class EntityType> extends ResourceType { /** * A list of queued, running, or recently completed tasks associated with this entity. */ - public TaskList getTasks() { - return tasks; + public TasksInProgress getTasksInProgress() { + return tasksInProgress; } - public void setTasks(TaskList tasks) { - this.tasks = tasks; + public void setTasksInProgress(TasksInProgress tasksInProgress) { + this.tasksInProgress = tasksInProgress; } /** @@ -224,16 +226,18 @@ public class EntityType> extends ResourceType { if (!super.equals(o)) return false; EntityType that = EntityType.class.cast(o); - return super.equals(that) && equal(this.id, that.id) && equal(this.description, that.description) && equal(this.tasks, that.tasks); + return super.equals(that) && + equal(this.id, that.id) && equal(this.description, that.description) && + equal(this.tasksInProgress, that.tasksInProgress); } @Override public int hashCode() { - return super.hashCode() + Objects.hashCode(description, tasks, id, name); + return super.hashCode() + Objects.hashCode(description, tasksInProgress, id, name); } @Override public ToStringHelper string() { - return super.string().add("description", description).add("tasks", tasks).add("id", id).add("name", name); + return super.string().add("description", description).add("tasksInProgress", tasksInProgress).add("id", id).add("name", name); } } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java index 283ac6048e..2f2a661bcb 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java @@ -93,15 +93,15 @@ public class Link extends ReferenceType { } public Builder fromLink(Link in) { - return fromReference(in).rel(in.getRel()); + return fromReferenceType(in).rel(in.getRel()); } /** * {@inheritDoc} */ @Override - public Builder fromReference(ReferenceType in) { - return Builder.class.cast(super.fromReference(in)); + public Builder fromReferenceType(ReferenceType in) { + return Builder.class.cast(super.fromReferenceType(in)); } /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java index 36ed8383fa..2e7f63568c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java @@ -75,7 +75,7 @@ public class Org extends EntityType { org.setId(id); org.setType(type); org.setLinks(links); - org.setTasks(tasks); + org.setTasksInProgress(tasksInProgress); return org; } @@ -107,11 +107,11 @@ public class Org extends EntityType { } /** - * @see EntityType#getTasks() + * @see EntityType#getTasksInProgress() */ @Override - public Builder tasks(TaskList tasks) { - this.tasks = tasks; + public Builder tasksInProgress(TasksInProgress tasksInProgress) { + this.tasksInProgress = tasksInProgress; return this; } @@ -152,12 +152,12 @@ public class Org extends EntityType { } @Override - public Builder fromEntity(EntityType in) { - return Builder.class.cast(super.fromEntity(in)); + public Builder fromEntityType(EntityType in) { + return Builder.class.cast(super.fromEntityType(in)); } public Builder fromOrg(Org in) { - return fromEntity(in).fullName(in.getFullName()); + return fromEntityType(in).fullName(in.getFullName()); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ReferenceType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ReferenceType.java index 4804bcac59..24bdc3b47c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ReferenceType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ReferenceType.java @@ -49,7 +49,7 @@ public class ReferenceType> { } public Builder toBuilder() { - return new Builder().fromReference(this); + return new Builder().fromReferenceType(this); } public static class Builder> { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java index b04fcdccf2..15df502eb9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java @@ -53,7 +53,7 @@ public class ResourceType> { } public Builder toBuilder() { - return new Builder().fromResource(this); + return new Builder().fromResourceType(this); } public static class Builder> { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java index 7a0a269897..dcd2055acd 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java @@ -183,11 +183,11 @@ public class Task extends EntityType { } /** - * @see EntityType#getTasks() + * @see EntityType#getTasksInProgress() */ @Override - public Builder tasks(TaskList tasks) { - this.tasks = tasks; + public Builder tasksInProgress(TasksInProgress tasksInProgress) { + this.tasksInProgress = tasksInProgress; return this; } @@ -228,13 +228,14 @@ public class Task extends EntityType { } @Override - public Builder fromEntity(EntityType in) { - return Builder.class.cast(super.fromEntity(in)); + public Builder fromEntityType(EntityType in) { + return Builder.class.cast(super.fromEntityType(in)); } public Builder fromTask(Task in) { - return fromEntity(in).error(in.getError()).org(in.getOrg()).progress(in.getProgress()).status(in.getStatus()) - .operation(in.getOperation()).operationName(in.getOperationName()); + return fromEntityType(in) + .error(in.getError()).org(in.getOrg()).progress(in.getProgress()).status(in.getStatus()) + .operation(in.getOperation()).operationName(in.getOperationName()); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksInProgress.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksInProgress.java index 3bec089111..d220381781 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksInProgress.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksInProgress.java @@ -56,7 +56,7 @@ public class TasksInProgress { /** * @see TasksInProgress#getTasks() */ - public Builder tasks(Collection tasks) { + public Builder tasks(Set tasks) { this.tasks = Sets.newLinkedHashSet(checkNotNull(tasks, "tasks")); return this; } @@ -69,11 +69,11 @@ public class TasksInProgress { return this; } - public TaskList build() { - return new TaskList(tasks); + public TasksInProgress build() { + return new TasksInProgress(tasks); } - public Builder fromTaskList(TaskList in) { + public Builder fromTasksInProgress(TasksInProgress in) { return tasks(in.getTasks()); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TaskList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java similarity index 67% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TaskList.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java index c3a34c20b4..ca930800ed 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TaskList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java @@ -22,11 +22,9 @@ import static com.google.common.base.Objects.*; import static com.google.common.base.Preconditions.*; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; -import java.util.Collection; +import java.net.URI; import java.util.Set; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -39,52 +37,61 @@ import com.google.common.collect.Sets; * * @author Adrian Cole */ -@XmlRootElement(namespace = NS, name = "TaskList") -@XmlAccessorType(XmlAccessType.FIELD) -public class TaskList { +@XmlRootElement(namespace = NS, name = "TasksList") +public class TasksList extends EntityType { + @SuppressWarnings("unchecked") public static Builder builder() { return new Builder(); } + @Override public Builder toBuilder() { return new Builder(); } - public static class Builder { + public static class Builder extends EntityType.Builder { protected Set tasks = Sets.newLinkedHashSet(); /** - * @see TaskList#getTasks() + * @see TasksList#getTasks() */ - public Builder tasks(Collection tasks) { + public Builder tasks(Set tasks) { this.tasks = Sets.newLinkedHashSet(checkNotNull(tasks, "tasks")); return this; } /** - * @see TaskList#getTasks() + * @see TasksList#getTasks() */ public Builder task(Task task) { this.tasks.add(checkNotNull(task, "task")); return this; } - public TaskList build() { - return new TaskList(tasks); + @Override + public TasksList build() { + TasksList taskslist = new TasksList(href, name, tasks); + taskslist.setDescription(description); + taskslist.setTasksInProgress(tasksInProgress); + taskslist.setId(id); + taskslist.setType(type); + taskslist.setLinks(links); + return taskslist; } - public Builder fromTaskList(TaskList in) { + public Builder fromTasksList(TasksList in) { return tasks(in.getTasks()); } } - protected TaskList() { + protected TasksList() { // For JAXB and builder use } - protected TaskList(Set tasks) { + protected TasksList(URI href, String name, Set tasks) { + super(href, name); this.tasks = ImmutableSet.copyOf(tasks); } @@ -101,17 +108,17 @@ public class TaskList { return true; if (o == null || getClass() != o.getClass()) return false; - TaskList that = TaskList.class.cast(o); - return equal(this.tasks, that.tasks); + TasksList that = TasksList.class.cast(o); + return super.equals(that) && equal(this.tasks, that.tasks); } @Override public int hashCode() { - return Objects.hashCode(tasks); + return super.hashCode() + Objects.hashCode(tasks); } @Override - public String toString() { - return Objects.toStringHelper("").add("tasks", tasks).toString(); + public ToStringHelper string() { + return super.string().add("tasks", tasks); } } From 2819a4a4675226b853a6b118b932011630a93c88 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Mon, 6 Feb 2012 12:45:33 +0000 Subject: [PATCH 04/14] Clean up OrgClientExpectTest formatting --- .../vcloud/director/v1_5/features/OrgClientExpectTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index f059be2193..91298a7eb7 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -102,7 +102,6 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07")) .build()) .link(Link.builder() - .rel("down") .type("application/vnd.vmware.vcloud.tasksList+xml") .href(URI.create("https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) .build()) From 8f7f9e6988f03dcaf3145580a314aee25e6ad585 Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 6 Feb 2012 18:10:58 +0000 Subject: [PATCH 05/14] tidy up existing tests, add metadata ops --- .../vcloud/director/v1_5/domain/Metadata.java | 91 ++++++++ .../director/v1_5/domain/MetadataEntry.java | 148 +++++++++++++ .../director/v1_5/features/OrgClient.java | 16 ++ .../v1_5/features/OrgClientExpectTest.java | 194 +++++++++++------- .../src/test/resources/org/metadata.xml | 4 + .../src/test/resources/{ => org}/org.xml | 0 .../src/test/resources/{ => org}/orglist.xml | 0 7 files changed, 377 insertions(+), 76 deletions(-) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java create mode 100644 labs/vcloud-director/src/test/resources/org/metadata.xml rename labs/vcloud-director/src/test/resources/{ => org}/org.xml (100%) rename labs/vcloud-director/src/test/resources/{ => org}/orglist.xml (100%) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java new file mode 100644 index 0000000000..cc22cc5dcb --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java @@ -0,0 +1,91 @@ +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +@XmlRootElement(namespace = NS, name = "MetaDataList") +public class Metadata { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromMetadataList(this); + } + + public static class Builder { + + private Set metadata = Sets.newLinkedHashSet(); + + /** + * @see OrgList#getOrgs + */ + public Builder metadata(Set orgs) { + this.metadata = Sets.newLinkedHashSet(checkNotNull(orgs, "metadata")); + return this; + } + + /** + * @see OrgList#getOrgs + */ + public Builder addMetadata(MetadataEntry org) { + metadata.add(checkNotNull(org, "metadatum")); + return this; + } + + public Metadata build() { + return new Metadata(metadata); + } + + public Builder fromMetadataList(Metadata in) { + return metadata(in.getMetadata()); + } + } + + private Metadata() { + // For JAXB and builder use + } + + private Metadata(Set orgs) { + this.metadata = ImmutableSet.copyOf(orgs); + } + + @XmlElement(namespace = NS, name = "MetaData") + private Set metadata = Sets.newLinkedHashSet(); + + public Set getMetadata() { + return ImmutableSet.copyOf(metadata); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Metadata that = Metadata.class.cast(o); + return equal(metadata, that.metadata); + } + + @Override + public int hashCode() { + return Objects.hashCode(metadata); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("metadata", metadata).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java new file mode 100644 index 0000000000..d48fb31cad --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java @@ -0,0 +1,148 @@ +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import java.net.URI; +import java.util.Set; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +@XmlRootElement(namespace = NS, name = "org/metadata") +public class MetadataEntry extends BaseResource { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromMetadatum(this); + } + + public static class Builder extends BaseResource.Builder { + + private String key; + private String value; + private Set links = Sets.newLinkedHashSet(); + + /** + * @see MetadataEntry#getKey + */ + public Builder key(String key) { + this.key = key; + return this; + } + + /** + * @see MetadataEntry#getValue + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * @see MetadataEntry#? + */ + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } + + /** + * @see MetadataEntry#? + */ + public Builder addLink(Link org) { + links.add(checkNotNull(org, "org")); + return this; + } + + public MetadataEntry build() { + return new MetadataEntry(href, type, key, value, links); + } + + public Builder fromMetadatum(MetadataEntry in) { + return key(in.getKey()).value(in.getValue()); + } + + @Override + public Builder href(URI href) { + return Builder.class.cast(super.href(href)); + } + + @Override + public Builder type(String type) { + return Builder.class.cast(super.type(type)); + } + + } + + private MetadataEntry() { + // For JAXB and builder use + } + + private MetadataEntry(URI href, String type, String key, String value, Set links) { + super(href, type); + this.key = key; + this.value = value; + this.links = ImmutableSet.copyOf(links); + } + + @XmlAttribute + private String key; + @XmlElement(namespace = NS, name = "Value") + private String value; + @XmlElement(namespace = NS, name = "Link") + private Set links = Sets.newLinkedHashSet(); + + /** + * + * @return key of the entry + */ + public String getKey() { + return key; + } + + /** + * + * @return value of the entry + */ + public String getValue() { + return value; + } + + /** + * TODO + */ + public Set getLinks() { + return ImmutableSet.copyOf(links); + } + + + @Override + public boolean equals(Object o) { + if (!super.equals(o)) + return false; + MetadataEntry that = MetadataEntry.class.cast(o); + return equal(key, that.key); + } + + @Override + public int hashCode() { + return super.hashCode() + Objects.hashCode(key); + } + + @Override + public ToStringHelper string() { + return super.string().add("key", key).add("value", value); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java index 3a6d8d50b3..d5078f52c4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java @@ -22,6 +22,8 @@ import java.net.URI; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; +import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.OrgList; @@ -49,4 +51,18 @@ public interface OrgClient { * @return the org or null if not found */ Org getOrg(URI orgHref); + + /** + * Retrieves an list of the organization's metadata + * + * @return a list of metadata + */ + Metadata getMetadata(URI orgRef); + + /** + * Retrieves a metadata + * + * @return the metadata or null if not found + */ + MetadataEntry getMetadataEntry(URI metaDataRef); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index 91298a7eb7..4efd508409 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -27,6 +27,8 @@ import org.jclouds.http.HttpResponse; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Link; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; +import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.Reference; @@ -45,29 +47,32 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest @Test public void testWhenResponseIs2xxLoginReturnsValidOrgList() { HttpRequest orgListRequest = HttpRequest.builder() - .method("GET") - .endpoint(URI.create("http://localhost/api/org/")) - .headers(ImmutableMultimap. builder() - .put("Accept", "*/*") - .put("x-vcloud-authorization", token) - .build()) - .build(); + .method("GET") + .endpoint(URI.create("http://localhost/api/org/")) + .headers(ImmutableMultimap. builder() + .put("Accept", "*/*") + .put("x-vcloud-authorization",token) + .build()) + .build(); HttpResponse orgListResponse = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResourceWithContentType("/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML + ";version=1.5")) - .build(); + .statusCode(200) + .payload(payloadFromResourceWithContentType("/org/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML + +";version=1.5")) + .build(); - VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgListRequest, orgListResponse); + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgListRequest, + orgListResponse); + + OrgList actual = OrgList.builder() + .org(OrgLink.builder() + .type("application/vnd.vmware.vcloud.org+xml") + .name("JClouds") + .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) + .build()) + .build(); - assertEquals(client.getOrgClient().getOrgList(), OrgList.builder() - .org(Reference.builder() - .type("application/vnd.vmware.vcloud.org+xml") - .name("JClouds") - .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) - .build()) - .build() - ); + assertEquals(client.getOrgClient().getOrgList(), actual); } @Test @@ -75,67 +80,104 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"); HttpRequest orgRequest = HttpRequest.builder() - .method("GET") - .endpoint(orgRef) - .headers(ImmutableMultimap. builder() - .put("Accept", "*/*") - .put("x-vcloud-authorization", token) - .build()) - .build(); + .method("GET") + .endpoint(orgRef) + .headers(ImmutableMultimap. builder() + .put("Accept", "*/*") + .put("x-vcloud-authorization", token) + .build()) + .build(); HttpResponse orgResponse = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResourceWithContentType("/org.xml", VCloudDirectorMediaType.ORG_XML + ";version=1.5")) - .build(); + .statusCode(200) + .payload(payloadFromResourceWithContentType("/org/org.xml", VCloudDirectorMediaType.ORG_XML + ";version=1.5")) + .build(); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgRequest, orgResponse); + + Org actual = Org + .builder() + .name("JClouds") + .description("") + .fullName("JClouds") + .id("urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0") + .type(VCloudDirectorMediaType.ORG_XML) + .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.vcloud.vdc+xml") + .name("Cluster01-JClouds") + .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.vcloud.tasksList+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.vcloud.catalog+xml") + .name("Public") + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.vcloud.controlAccess+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c/controlAccess/")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.vcloud.orgNetwork+xml") + .name("ilsolation01-Jclouds") + .href(URI.create("https://vcloudbeta.bluelock.com/api/network/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.vcloud.orgNetwork+xml") + .name("internet01-Jclouds") + .href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.vcloud.metadata+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata")) + .build()) + .build(); - assertEquals(client.getOrgClient().getOrg(orgRef), Org.builder() - .name("JClouds") - .id("urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0") - .type(VCloudDirectorMediaType.ORG_XML) - .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) - .link(Link.builder() - .rel("down") - .type("application/vnd.vmware.vcloud.vdc+xml") - .name("Cluster01-JClouds") - .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07")) - .build()) - .link(Link.builder() - .type("application/vnd.vmware.vcloud.tasksList+xml") - .href(URI.create("https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) - .build()) - .link(Link.builder() - .rel("down") - .type("application/vnd.vmware.vcloud.catalog+xml") - .name("Public") - .href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c")) - .build()) - .link(Link.builder() - .rel("down") - .type("application/vnd.vmware.vcloud.controlAccess+xml") - .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c/controlAccess/")) - .build()) - .link(Link.builder() - .rel("down") - .type("application/vnd.vmware.vcloud.orgNetwork+xml") - .name("ilsolation01-Jclouds") - .href(URI.create("https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38")) - .build()) - .link(Link.builder() - .rel("down") - .type("application/vnd.vmware.vcloud.orgNetwork+xml") - .name("internet01-Jclouds") - .href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c")) - .build()) - .link(Link.builder() - .rel("down") - .type("application/vnd.vmware.vcloud.metadata+xml") - .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata")) - .build()) - .description("") - .fullName("JClouds") - .build() - ); + assertEquals(client.getOrgClient().getOrg(orgRef), actual); + } + + @Test + public void testWhenResponseIs2xxLoginReturnsValidMetadataList() { + URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("GET", orgRef), + getStandardPaylodResponse("/orglist.xml")); + + Metadata actual = Metadata.builder() +// .link(Link.builder() +// .rel("up") +// .type("application/vnd.vmware.vcloud.vdc+xml") +// .name("Cluster01-JClouds") +// .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07")) +// .build()) + .build(); + + assertEquals(client.getOrgClient().getMetadata(orgRef), actual); + } + + @Test(enabled=false) + public void testWhenResponseIs2xxLoginReturnsValidMetadata() { + URI metadataRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadataKEY"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("GET", metadataRef), + getStandardPaylodResponse("/org/metadata.xml")); + + MetadataEntry actual = MetadataEntry.builder() + .build(); + + assertEquals(client.getOrgClient().getMetadataEntry(metadataRef), actual); } } diff --git a/labs/vcloud-director/src/test/resources/org/metadata.xml b/labs/vcloud-director/src/test/resources/org/metadata.xml new file mode 100644 index 0000000000..992459fd0d --- /dev/null +++ b/labs/vcloud-director/src/test/resources/org/metadata.xml @@ -0,0 +1,4 @@ + + + + diff --git a/labs/vcloud-director/src/test/resources/org.xml b/labs/vcloud-director/src/test/resources/org/org.xml similarity index 100% rename from labs/vcloud-director/src/test/resources/org.xml rename to labs/vcloud-director/src/test/resources/org/org.xml diff --git a/labs/vcloud-director/src/test/resources/orglist.xml b/labs/vcloud-director/src/test/resources/org/orglist.xml similarity index 100% rename from labs/vcloud-director/src/test/resources/orglist.xml rename to labs/vcloud-director/src/test/resources/org/orglist.xml From c35794e8c77f715f102cd3ae7a98298be1f21618 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 7 Feb 2012 11:15:39 +0000 Subject: [PATCH 06/14] fix Org to use Links --- .../vcloud/director/v1_5/domain/OrgList.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java index 44c98f159e..bf6cbd7882 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java @@ -18,9 +18,9 @@ */ package org.jclouds.vcloud.director.v1_5.domain; -import static com.google.common.base.Objects.*; -import static com.google.common.base.Preconditions.*; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; import java.util.Set; @@ -49,12 +49,12 @@ public class OrgList { public static class Builder { - private Set orgs = Sets.newLinkedHashSet(); + private Set orgs = Sets.newLinkedHashSet(); /** * @see OrgList#getOrgs */ - public Builder orgs(Set orgs) { + public Builder orgs(Set orgs) { this.orgs = Sets.newLinkedHashSet(checkNotNull(orgs, "orgs")); return this; } @@ -62,7 +62,7 @@ public class OrgList { /** * @see OrgList#getOrgs */ - public Builder org(Reference org) { + public Builder addOrg(Link org) { orgs.add(checkNotNull(org, "org")); return this; } @@ -80,14 +80,14 @@ public class OrgList { // For JAXB and builder use } - private OrgList(Set orgs) { + private OrgList(Set orgs) { this.orgs = ImmutableSet.copyOf(orgs); } @XmlElement(namespace = NS, name = "Org") - private Set orgs = Sets.newLinkedHashSet(); + private Set orgs = Sets.newLinkedHashSet(); - public Set getOrgs() { + public Set getOrgs() { return ImmutableSet.copyOf(orgs); } @@ -98,7 +98,7 @@ public class OrgList { if (o == null || getClass() != o.getClass()) return false; OrgList that = OrgList.class.cast(o); - return equal(this.orgs, that.orgs); + return equal(orgs, that.orgs); } @Override From 90153df2d148766c8561a4ae202e71b6952259f3 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 7 Feb 2012 10:27:22 +0000 Subject: [PATCH 07/14] add common request/response methods --- .../vcloud/director/v1_5/domain/OrgList.java | 12 ++++++------ .../BaseVCloudDirectorRestClientExpectTest.java | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java index bf6cbd7882..5351747da1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java @@ -49,12 +49,12 @@ public class OrgList { public static class Builder { - private Set orgs = Sets.newLinkedHashSet(); + private Set orgs = Sets.newLinkedHashSet(); /** * @see OrgList#getOrgs */ - public Builder orgs(Set orgs) { + public Builder orgs(Set orgs) { this.orgs = Sets.newLinkedHashSet(checkNotNull(orgs, "orgs")); return this; } @@ -62,7 +62,7 @@ public class OrgList { /** * @see OrgList#getOrgs */ - public Builder addOrg(Link org) { + public Builder org(Reference org) { orgs.add(checkNotNull(org, "org")); return this; } @@ -80,14 +80,14 @@ public class OrgList { // For JAXB and builder use } - private OrgList(Set orgs) { + private OrgList(Set orgs) { this.orgs = ImmutableSet.copyOf(orgs); } @XmlElement(namespace = NS, name = "Org") - private Set orgs = Sets.newLinkedHashSet(); + private Set orgs = Sets.newLinkedHashSet(); - public Set getOrgs() { + public Set getOrgs() { return ImmutableSet.copyOf(orgs); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java index 99f5eea22b..1b5d01265e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java @@ -56,5 +56,19 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect identity = String.format("%s@%s", user, org); credential = password; } + + protected HttpRequest getStandardRequest(String method, URI uri) { + return HttpRequest.builder().method(method).endpoint(uri).headers( + ImmutableMultimap. builder() + .put("Accept", "*/*") + .put("x-vcloud-authorization",token) + .build()).build(); + } + + protected HttpResponse getStandardPaylodResponse(String relativeFilePath) { + return HttpResponse.builder().statusCode(200) + .payload(payloadFromResourceWithContentType(relativeFilePath, VCloudDirectorMediaType.ORGLIST_XML + + ";version=1.5")).build(); + } } From a1ebfc36f7c20958d05d16566bf9feb91fccc93f Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 7 Feb 2012 15:14:45 +0000 Subject: [PATCH 08/14] add metadata types --- .../vcloud/director/v1_5/VCloudDirectorMediaType.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java index 80d37a1ba8..078e95672c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java @@ -35,6 +35,11 @@ public interface VCloudDirectorMediaType { public final static String SESSION_XML = "application/vnd.vmware.vcloud.session+xml"; public final static String ORGLIST_XML = "application/vnd.vmware.vcloud.orgList+xml"; + + public final static String METADATA_XML = "application/vnd.vmware.vcloud.metadata+xml"; + public static final String METADATAENTRY_XML = "TODO"; // TODO + public final static String ORG_XML = "application/vnd.vmware.vcloud.org+xml"; + } From 86289bd7039004f7c8f69cadfc8f7c67823d02c5 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 7 Feb 2012 15:15:03 +0000 Subject: [PATCH 09/14] abstract out metadata type --- .../internal/BaseVCloudDirectorRestClientExpectTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java index 1b5d01265e..9177a97d2e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java @@ -65,10 +65,9 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect .build()).build(); } - protected HttpResponse getStandardPaylodResponse(String relativeFilePath) { + protected HttpResponse getStandardPaylodResponse(String relativeFilePath, String mediaType) { return HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType(relativeFilePath, VCloudDirectorMediaType.ORGLIST_XML - + ";version=1.5")).build(); + .payload(payloadFromResourceWithContentType(relativeFilePath, mediaType+";version=1.5")).build(); } } From 029b02187140d5bef21df32f6ad3786842e28ec6 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 7 Feb 2012 15:15:24 +0000 Subject: [PATCH 10/14] add metadata methods to synch client --- .../v1_5/features/OrgAsyncClient.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java index 4b513a5e9e..92a88593dc 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java @@ -29,6 +29,8 @@ import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; +import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; @@ -60,4 +62,23 @@ public interface OrgAsyncClient { @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture getOrg(@EndpointParam URI uri); + + /** + * @see OrgClient#getMetadata + */ + @GET + @Path("/metadata/") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getMetadata(@EndpointParam URI orgRef); + + /** + * @see OrgClient#getMetadataEntry + */ + @GET + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getMetadataEntry(@EndpointParam URI metaDataRef); } From 693af6dc2513eae10f061761d4990aa2898e9b14 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 7 Feb 2012 15:15:45 +0000 Subject: [PATCH 11/14] rebase metadata/entry on new base classes --- .../vcloud/director/v1_5/domain/Metadata.java | 83 ++++++++++++----- .../director/v1_5/domain/MetadataEntry.java | 90 +++++++++---------- 2 files changed, 107 insertions(+), 66 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java index cc22cc5dcb..316f83461a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java @@ -4,18 +4,21 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; +import java.net.URI; import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; -@XmlRootElement(namespace = NS, name = "MetaDataList") -public class Metadata { +@XmlRootElement(namespace = NS, name = "Metadata") +public class Metadata extends ResourceType{ + @SuppressWarnings("unchecked") public static Builder builder() { return new Builder(); } @@ -24,28 +27,67 @@ public class Metadata { return new Builder().fromMetadataList(this); } - public static class Builder { + public static class Builder extends ResourceType.Builder { - private Set metadata = Sets.newLinkedHashSet(); + private Set metadataEntries = Sets.newLinkedHashSet(); /** - * @see OrgList#getOrgs + * @see Metadata#getMetadata() */ - public Builder metadata(Set orgs) { - this.metadata = Sets.newLinkedHashSet(checkNotNull(orgs, "metadata")); + public Builder metadata(Set metadataEntries) { + this.metadataEntries = Sets.newLinkedHashSet(checkNotNull(metadataEntries, "metadataEntries")); return this; } /** - * @see OrgList#getOrgs + * @see Metadata#getMetadata() */ - public Builder addMetadata(MetadataEntry org) { - metadata.add(checkNotNull(org, "metadatum")); + public Builder entry(MetadataEntry metadataEntry) { + metadataEntries.add(checkNotNull(metadataEntry, "metadataEntry")); return this; } public Metadata build() { - return new Metadata(metadata); + Metadata metadata = new Metadata(href, metadataEntries); + metadata.setType(type); + metadata.setLinks(links); + return metadata; + } + + /** + * @see ResourceType#getHref() + */ + @Override + public Builder href(URI href) { + super.href(href); + return this; + } + + /** + * @see ResourceType#getType() + */ + @Override + public Builder type(String type) { + super.type(type); + return this; + } + + /** + * @see ResourceType#getLinks() + */ + @Override + public Builder links(Set links) { + super.links(Sets.newLinkedHashSet(checkNotNull(links, "links"))); + return this; + } + + /** + * @see ResourceType#getLinks() + */ + @Override + public Builder link(Link link) { + super.link(link); + return this; } public Builder fromMetadataList(Metadata in) { @@ -57,11 +99,12 @@ public class Metadata { // For JAXB and builder use } - private Metadata(Set orgs) { - this.metadata = ImmutableSet.copyOf(orgs); + private Metadata(URI href, Set metadataEntries) { + super(href); + this.metadata = ImmutableSet.copyOf(metadataEntries); } - @XmlElement(namespace = NS, name = "MetaData") + @XmlElement(namespace = NS, name = "MetadataEntry") private Set metadata = Sets.newLinkedHashSet(); public Set getMetadata() { @@ -70,22 +113,20 @@ public class Metadata { @Override public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) + if (!super.equals(o)) return false; Metadata that = Metadata.class.cast(o); - return equal(metadata, that.metadata); + return super.equals(that) && equal(metadata, that.metadata); } @Override public int hashCode() { - return Objects.hashCode(metadata); + return super.hashCode() + Objects.hashCode(metadata); } @Override - public String toString() { - return Objects.toStringHelper("").add("metadata", metadata).toString(); + public ToStringHelper string() { + return super.string().add("metadata", metadata); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java index d48fb31cad..e28cea3976 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java @@ -13,11 +13,10 @@ import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @XmlRootElement(namespace = NS, name = "org/metadata") -public class MetadataEntry extends BaseResource { +public class MetadataEntry extends ResourceType { @SuppressWarnings("unchecked") public static Builder builder() { @@ -25,14 +24,12 @@ public class MetadataEntry extends BaseResource { } public Builder toBuilder() { - return new Builder().fromMetadatum(this); + return new Builder().fromMetadata(this); } - public static class Builder extends BaseResource.Builder { - + public static class Builder extends ResourceType.Builder { private String key; private String value; - private Set links = Sets.newLinkedHashSet(); /** * @see MetadataEntry#getKey @@ -50,38 +47,51 @@ public class MetadataEntry extends BaseResource { return this; } - /** - * @see MetadataEntry#? - */ - public Builder links(Set links) { - this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); - return this; - } - - /** - * @see MetadataEntry#? - */ - public Builder addLink(Link org) { - links.add(checkNotNull(org, "org")); - return this; - } - public MetadataEntry build() { - return new MetadataEntry(href, type, key, value, links); + MetadataEntry metadataEntry = new MetadataEntry(href, key, value); + metadataEntry.setType(type); + metadataEntry.setLinks(links); + return metadataEntry; } - - public Builder fromMetadatum(MetadataEntry in) { - return key(in.getKey()).value(in.getValue()); - } - + + /** + * @see ResourceType#getHref() + */ @Override public Builder href(URI href) { - return Builder.class.cast(super.href(href)); + super.href(href); + return this; } + /** + * @see ResourceType#getType() + */ @Override public Builder type(String type) { - return Builder.class.cast(super.type(type)); + super.type(type); + return this; + } + + /** + * @see ResourceType#getLinks() + */ + @Override + public Builder links(Set links) { + super.links(Sets.newLinkedHashSet(checkNotNull(links, "links"))); + return this; + } + + /** + * @see ResourceType#getLinks() + */ + @Override + public Builder link(Link link) { + super.link(link); + return this; + } + + public Builder fromMetadata(MetadataEntry in) { + return key(in.getKey()).value(in.getValue()); } } @@ -90,19 +100,16 @@ public class MetadataEntry extends BaseResource { // For JAXB and builder use } - private MetadataEntry(URI href, String type, String key, String value, Set links) { - super(href, type); - this.key = key; - this.value = value; - this.links = ImmutableSet.copyOf(links); + private MetadataEntry(URI href, String key, String value) { + super(href); + this.key = checkNotNull(key, "key"); + this.value = checkNotNull(value, "value"); } @XmlAttribute private String key; @XmlElement(namespace = NS, name = "Value") private String value; - @XmlElement(namespace = NS, name = "Link") - private Set links = Sets.newLinkedHashSet(); /** * @@ -120,20 +127,13 @@ public class MetadataEntry extends BaseResource { return value; } - /** - * TODO - */ - public Set getLinks() { - return ImmutableSet.copyOf(links); - } - @Override public boolean equals(Object o) { if (!super.equals(o)) return false; MetadataEntry that = MetadataEntry.class.cast(o); - return equal(key, that.key); + return super.equals(that) && equal(key, that.key); } @Override From e368e8e4cc0b307910f61b4e643f8c8bf2942636 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 7 Feb 2012 15:15:55 +0000 Subject: [PATCH 12/14] fix tests --- .../v1_5/features/OrgClientExpectTest.java | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index 4efd508409..eae3034c18 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -64,15 +64,15 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgListRequest, orgListResponse); - OrgList actual = OrgList.builder() - .org(OrgLink.builder() + OrgList expected = OrgList.builder() + .org(Reference.builder() .type("application/vnd.vmware.vcloud.org+xml") .name("JClouds") .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) .build()) .build(); - assertEquals(client.getOrgClient().getOrgList(), actual); + assertEquals(client.getOrgClient().getOrgList(), expected); } @Test @@ -95,7 +95,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgRequest, orgResponse); - Org actual = Org + Org expected = Org .builder() .name("JClouds") .description("") @@ -129,7 +129,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest .rel("down") .type("application/vnd.vmware.vcloud.orgNetwork+xml") .name("ilsolation01-Jclouds") - .href(URI.create("https://vcloudbeta.bluelock.com/api/network/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) + .href(URI.create("https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38")) .build()) .link(Link.builder() .rel("down") @@ -144,40 +144,42 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest .build()) .build(); - assertEquals(client.getOrgClient().getOrg(orgRef), actual); + assertEquals(client.getOrgClient().getOrg(orgRef), expected); } @Test public void testWhenResponseIs2xxLoginReturnsValidMetadataList() { URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"); + URI metaRef = URI.create(orgRef.toASCIIString()+"/metadata/"); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - getStandardRequest("GET", orgRef), - getStandardPaylodResponse("/orglist.xml")); + getStandardRequest("GET", metaRef), + getStandardPaylodResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA_XML)); - Metadata actual = Metadata.builder() -// .link(Link.builder() -// .rel("up") -// .type("application/vnd.vmware.vcloud.vdc+xml") -// .name("Cluster01-JClouds") -// .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07")) -// .build()) + Metadata expected = Metadata.builder() + .type("application/vnd.vmware.vcloud.metadata+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata")) + .link(Link.builder() + .rel("up") + .type("application/vnd.vmware.vcloud.org+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) + .build()) .build(); - assertEquals(client.getOrgClient().getMetadata(orgRef), actual); + assertEquals(client.getOrgClient().getMetadata(orgRef), expected); } @Test(enabled=false) public void testWhenResponseIs2xxLoginReturnsValidMetadata() { - URI metadataRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadataKEY"); + URI metadataRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY"); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, getStandardRequest("GET", metadataRef), - getStandardPaylodResponse("/org/metadata.xml")); + getStandardPaylodResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML)); - MetadataEntry actual = MetadataEntry.builder() + MetadataEntry expected = MetadataEntry.builder() .build(); - assertEquals(client.getOrgClient().getMetadataEntry(metadataRef), actual); + assertEquals(client.getOrgClient().getMetadataEntry(metadataRef), expected); } } From 0feb27fd93a7f5694a80372bb128e07b04e07725 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 7 Feb 2012 15:21:11 +0000 Subject: [PATCH 13/14] fix typo and tidy tests --- .../v1_5/features/OrgClientExpectTest.java | 43 ++++--------------- ...aseVCloudDirectorRestClientExpectTest.java | 2 +- 2 files changed, 10 insertions(+), 35 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index eae3034c18..0f2d02e1a1 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -46,24 +46,11 @@ import com.google.common.collect.ImmutableMultimap; public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { @Test public void testWhenResponseIs2xxLoginReturnsValidOrgList() { - HttpRequest orgListRequest = HttpRequest.builder() - .method("GET") - .endpoint(URI.create("http://localhost/api/org/")) - .headers(ImmutableMultimap. builder() - .put("Accept", "*/*") - .put("x-vcloud-authorization",token) - .build()) - .build(); - HttpResponse orgListResponse = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResourceWithContentType("/org/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML - +";version=1.5")) - .build(); + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("GET", URI.create("http://localhost/api/org/")), + getStandardPayloadResponse("/org/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML)); - VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgListRequest, - orgListResponse); - OrgList expected = OrgList.builder() .org(Reference.builder() .type("application/vnd.vmware.vcloud.org+xml") @@ -79,21 +66,9 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest public void testWhenResponseIs2xxLoginReturnsValidOrg() { URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"); - HttpRequest orgRequest = HttpRequest.builder() - .method("GET") - .endpoint(orgRef) - .headers(ImmutableMultimap. builder() - .put("Accept", "*/*") - .put("x-vcloud-authorization", token) - .build()) - .build(); - - HttpResponse orgResponse = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResourceWithContentType("/org/org.xml", VCloudDirectorMediaType.ORG_XML + ";version=1.5")) - .build(); - - VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgRequest, orgResponse); + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("GET", orgRef), + getStandardPayloadResponse("/org/org.xml", VCloudDirectorMediaType.ORG_XML)); Org expected = Org .builder() @@ -154,7 +129,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, getStandardRequest("GET", metaRef), - getStandardPaylodResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA_XML)); + getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA_XML)); Metadata expected = Metadata.builder() .type("application/vnd.vmware.vcloud.metadata+xml") @@ -169,13 +144,13 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest assertEquals(client.getOrgClient().getMetadata(orgRef), expected); } - @Test(enabled=false) + @Test(enabled=false) // No metadata in exemplar xml... public void testWhenResponseIs2xxLoginReturnsValidMetadata() { URI metadataRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY"); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, getStandardRequest("GET", metadataRef), - getStandardPaylodResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML)); + getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML)); MetadataEntry expected = MetadataEntry.builder() .build(); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java index 9177a97d2e..244ede2323 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java @@ -65,7 +65,7 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect .build()).build(); } - protected HttpResponse getStandardPaylodResponse(String relativeFilePath, String mediaType) { + protected HttpResponse getStandardPayloadResponse(String relativeFilePath, String mediaType) { return HttpResponse.builder().statusCode(200) .payload(payloadFromResourceWithContentType(relativeFilePath, mediaType+";version=1.5")).build(); } From e8baca9b0a29166b795151f4488108749be7f2d2 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 7 Feb 2012 15:45:18 +0000 Subject: [PATCH 14/14] licensing, imports, other tidyup --- .../vcloud/director/v1_5/domain/Entity.java | 9 +----- .../director/v1_5/domain/EntityType.java | 7 ++-- .../vcloud/director/v1_5/domain/Error.java | 24 ++++++++++++-- .../vcloud/director/v1_5/domain/Link.java | 22 +++++++++++-- .../vcloud/director/v1_5/domain/Metadata.java | 27 ++++++++++++++++ .../director/v1_5/domain/MetadataEntry.java | 32 +++++++++++++++++-- .../vcloud/director/v1_5/domain/Resource.java | 13 +------- .../vcloud/director/v1_5/domain/Task.java | 6 ++-- .../v1_5/features/OrgClientExpectTest.java | 6 +--- 9 files changed, 107 insertions(+), 39 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java index 1d932c9549..e9e5c3611d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java @@ -18,18 +18,11 @@ */ package org.jclouds.vcloud.director.v1_5.domain; -import static com.google.common.base.Objects.*; -import static com.google.common.base.Preconditions.*; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; +import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Set; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.Sets; /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java index cfedddaea3..c14f0cf31d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java @@ -18,9 +18,9 @@ */ package org.jclouds.vcloud.director.v1_5.domain; -import static com.google.common.base.Objects.*; -import static com.google.common.base.Preconditions.*; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; import java.net.URI; import java.util.Set; @@ -143,6 +143,7 @@ public class EntityType> extends ResourceType { /** * {@inheritDoc} */ + @SuppressWarnings("unchecked") @Override public Builder fromResourceType(ResourceType in) { return Builder.class.cast(super.fromResourceType(in)); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java index 3032a03d0e..4820cd3471 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java @@ -1,8 +1,26 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.director.v1_5.domain; -import static com.google.common.base.Objects.*; -import static com.google.common.base.Preconditions.*; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java index 2f2a661bcb..274545149f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java @@ -1,7 +1,25 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.director.v1_5.domain; -import static com.google.common.base.Objects.*; -import static com.google.common.base.Preconditions.*; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Map; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java index 316f83461a..26936df2f0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java @@ -1,3 +1,21 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.director.v1_5.domain; import static com.google.common.base.Objects.equal; @@ -15,6 +33,15 @@ import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; +/** + * Represents a set of metadata + * + *
+ * <xs:complexType name="Metadata">
+ * 
+ * + * @author danikov + */ @XmlRootElement(namespace = NS, name = "Metadata") public class Metadata extends ResourceType{ diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java index e28cea3976..ce4cf0aeb3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java @@ -1,3 +1,21 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.director.v1_5.domain; import static com.google.common.base.Objects.equal; @@ -7,7 +25,6 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; import java.net.URI; import java.util.Set; -import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -15,7 +32,16 @@ import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.Sets; -@XmlRootElement(namespace = NS, name = "org/metadata") +/** + * Represents a metadata entry + * + *
+ * <xs:complexType name="MetadataType">
+ * 
+ * + * @author danikov + */ +@XmlRootElement(namespace = NS, name = "TODO") public class MetadataEntry extends ResourceType { @SuppressWarnings("unchecked") @@ -106,7 +132,7 @@ public class MetadataEntry extends ResourceType { this.value = checkNotNull(value, "value"); } - @XmlAttribute + @XmlElement(namespace = NS, name = "K") private String key; @XmlElement(namespace = NS, name = "Value") private String value; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java index 0778dd35ea..b380e200e0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java @@ -18,22 +18,11 @@ */ package org.jclouds.vcloud.director.v1_5.domain; -import static com.google.common.base.Objects.*; -import static com.google.common.base.Preconditions.*; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; +import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Set; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; - -import org.jclouds.vcloud.director.v1_5.domain.Resource.Builder; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.Sets; /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java index dcd2055acd..de82e172fc 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java @@ -18,9 +18,9 @@ */ package org.jclouds.vcloud.director.v1_5.domain; -import static com.google.common.base.Objects.*; -import static com.google.common.base.Preconditions.*; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; import java.net.URI; import java.util.Date; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index 0f2d02e1a1..f9ebe85644 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -18,12 +18,10 @@ */ package org.jclouds.vcloud.director.v1_5.features; -import static org.testng.Assert.*; +import static org.testng.Assert.assertEquals; import java.net.URI; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Link; @@ -35,8 +33,6 @@ import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableMultimap; - /** * Allows us to test a client via its side effects. *