mirror of https://github.com/apache/jclouds.git
Merge pull request #355 from danikov/vcloud-director-org-metadata
Issue 830: vCloud Org (inc. metadata)
This commit is contained in:
commit
f254a6700e
|
@ -36,5 +36,10 @@ public interface VCloudDirectorMediaType {
|
||||||
|
|
||||||
public final static String ORGLIST_XML = "application/vnd.vmware.vcloud.orgList+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";
|
public final static String ORG_XML = "application/vnd.vmware.vcloud.org+xml";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,83 +18,37 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.*;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*;
|
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import com.google.common.collect.Sets;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic entity type in the vCloud object model.
|
* An entity.
|
||||||
*
|
*
|
||||||
* Includes a name, an optional description, and an optional list of links
|
* @author grkvlt@apache.org
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* <xs:complexType name="EntityType">
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
*/
|
||||||
public class Entity<T extends Entity<T>> extends Resource<T> {
|
public class Entity extends EntityType<Entity> {
|
||||||
|
|
||||||
public static <T extends Entity<T>> Builder<T> builder() {
|
@SuppressWarnings("unchecked")
|
||||||
return new Builder<T>();
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder<T> toBuilder() {
|
public Builder toBuilder() {
|
||||||
return new Builder<T>().fromEntity(this);
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder<T extends Entity<T>> extends Resource.Builder<T> {
|
public static class Builder extends EntityType.Builder<Entity> {
|
||||||
|
|
||||||
protected String description;
|
|
||||||
protected TaskList tasks;
|
|
||||||
protected String name;
|
|
||||||
protected String id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Entity#getName()
|
|
||||||
*/
|
|
||||||
public Builder<T> name(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Entity#getDescription()
|
|
||||||
*/
|
|
||||||
public Builder<T> description(String description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Entity#getId()
|
|
||||||
*/
|
|
||||||
public Builder<T> id(String id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Entity#getTasks()
|
|
||||||
*/
|
|
||||||
public Builder<T> tasks(TaskList tasks) {
|
|
||||||
this.tasks = tasks;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Entity<T> build() {
|
public Entity build() {
|
||||||
Entity<T> entity = new Entity<T>(href, name);
|
Entity entity = new Entity(href, name);
|
||||||
entity.setDescription(description);
|
entity.setDescription(description);
|
||||||
entity.setTasks(tasks);
|
entity.setTasksInProgress(tasksInProgress);
|
||||||
entity.setId(id);
|
entity.setId(id);
|
||||||
entity.setType(type);
|
entity.setType(type);
|
||||||
entity.setLinks(links);
|
entity.setLinks(links);
|
||||||
|
@ -102,99 +56,100 @@ public class Entity<T extends Entity<T>> extends Resource<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* @see EntityType#getName()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Builder<T> fromResource(Resource<T> in) {
|
public Builder name(String name) {
|
||||||
return Builder.class.cast(super.fromResource(in));
|
this.name = name;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<T> fromEntity(Entity<T> 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "Description")
|
/**
|
||||||
protected String description;
|
* @see EntityType#getId()
|
||||||
@XmlElement(namespace = NS, name = "TasksInProgress")
|
*/
|
||||||
protected TaskList tasks;
|
@Override
|
||||||
@XmlAttribute
|
public Builder id(String id) {
|
||||||
protected String id;
|
this.id = id;
|
||||||
@XmlAttribute
|
return this;
|
||||||
protected String name;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getTasksInProgress()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||||
|
this.tasksInProgress = tasksInProgress;
|
||||||
|
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<Link> 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<Entity> in) {
|
||||||
|
return Builder.class.cast(super.fromEntityType(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromEntity(Entity in) {
|
||||||
|
return fromEntityType(in);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected Entity(URI href, String name) {
|
protected Entity(URI href, String name) {
|
||||||
super(href);
|
super(href, name);
|
||||||
this.name = name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Entity() {
|
protected Entity() {
|
||||||
// For JAXB
|
// 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
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!super.equals(o))
|
if (!super.equals(o))
|
||||||
return false;
|
return false;
|
||||||
Entity<?> that = Entity.class.cast(o);
|
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);
|
return super.equals(that);
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,244 @@
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
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 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
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <xs:complexType name="EntityType">
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
public class EntityType<T extends EntityType<T>> extends ResourceType<T> {
|
||||||
|
|
||||||
|
public static <T extends EntityType<T>> Builder<T> builder() {
|
||||||
|
return new Builder<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder<T> toBuilder() {
|
||||||
|
return new Builder<T>().fromEntityType(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder<T extends EntityType<T>> extends ResourceType.Builder<T> {
|
||||||
|
|
||||||
|
protected String description;
|
||||||
|
protected TasksInProgress tasksInProgress;
|
||||||
|
protected String name;
|
||||||
|
protected String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getName()
|
||||||
|
*/
|
||||||
|
public Builder<T> name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getDescription()
|
||||||
|
*/
|
||||||
|
public Builder<T> description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getId()
|
||||||
|
*/
|
||||||
|
public Builder<T> id(String id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getTasksInProgress()
|
||||||
|
*/
|
||||||
|
public Builder<T> tasksInProgress(TasksInProgress tasksInProgress) {
|
||||||
|
this.tasksInProgress = tasksInProgress;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityType<T> build() {
|
||||||
|
EntityType<T> entity = new EntityType<T>(href, name);
|
||||||
|
entity.setDescription(description);
|
||||||
|
entity.setTasksInProgress(tasksInProgress);
|
||||||
|
entity.setId(id);
|
||||||
|
entity.setType(type);
|
||||||
|
entity.setLinks(links);
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getHref()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder<T> href(URI href) {
|
||||||
|
this.href = href;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder<T> type(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getLinks()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder<T> links(Set<Link> links) {
|
||||||
|
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getLinks()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder<T> link(Link link) {
|
||||||
|
this.links.add(checkNotNull(link, "link"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public Builder<T> fromResourceType(ResourceType<T> in) {
|
||||||
|
return Builder.class.cast(super.fromResourceType(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> fromEntityType(EntityType<T> in) {
|
||||||
|
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 TasksInProgress tasksInProgress;
|
||||||
|
@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 TasksInProgress getTasksInProgress() {
|
||||||
|
return tasksInProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTasksInProgress(TasksInProgress tasksInProgress) {
|
||||||
|
this.tasksInProgress = tasksInProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.tasksInProgress, that.tasksInProgress);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return super.hashCode() + Objects.hashCode(description, tasksInProgress, id, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ToStringHelper string() {
|
||||||
|
return super.string().add("description", description).add("tasksInProgress", tasksInProgress).add("id", id).add("name", name);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,29 @@
|
||||||
|
/**
|
||||||
|
* 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;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.*;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.*;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@ -16,9 +36,10 @@ import com.google.common.base.Objects;
|
||||||
* <xs:complexType name="ErrorType">
|
* <xs:complexType name="ErrorType">
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "Error")
|
@XmlRootElement(namespace = NS, name = "Error")
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class Error {
|
public class Error {
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
@ -94,15 +115,15 @@ public class Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
protected String message;
|
private String message;
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
protected int majorErrorCode;
|
private int majorErrorCode;
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
protected String minorErrorCode;
|
private String minorErrorCode;
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
protected String vendorSpecificErrorCode;
|
private String vendorSpecificErrorCode;
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
protected String stackTrace;
|
private String stackTrace;
|
||||||
|
|
||||||
private Error(String message, int majorErrorCode, String minorErrorCode) {
|
private Error(String message, int majorErrorCode, String minorErrorCode) {
|
||||||
this.message = checkNotNull(message, "message");
|
this.message = checkNotNull(message, "message");
|
||||||
|
|
|
@ -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;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
|
@ -20,7 +38,7 @@ import com.google.common.base.Objects.ToStringHelper;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class Link extends Reference<Link> {
|
public class Link extends ReferenceType<Link> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
@ -35,7 +53,7 @@ public class Link extends Reference<Link> {
|
||||||
return new Builder().fromLink(this);
|
return new Builder().fromLink(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder extends Reference.Builder<Link> {
|
public static class Builder extends ReferenceType.Builder<Link> {
|
||||||
|
|
||||||
protected String rel;
|
protected String rel;
|
||||||
|
|
||||||
|
@ -47,27 +65,67 @@ public class Link extends Reference<Link> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Link build() {
|
public Link build() {
|
||||||
Link link = new Link(href, rel);
|
Link link = new Link(href, rel);
|
||||||
link.setId(id);
|
link.setId(id);
|
||||||
link.setName(name);
|
link.setName(name);
|
||||||
link.setType(type);
|
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) {
|
public Builder fromLink(Link in) {
|
||||||
return fromReference(in).rel(in.getRel());
|
return fromReferenceType(in).rel(in.getRel());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public Builder fromReference(Reference<Link> in) {
|
@Override
|
||||||
return Builder.class.cast(super.fromReference(in));
|
public Builder fromReferenceType(ReferenceType<Link> in) {
|
||||||
|
return Builder.class.cast(super.fromReferenceType(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Builder fromAttributes(Map<String, String> attributes) {
|
public Builder fromAttributes(Map<String, String> attributes) {
|
||||||
super.fromAttributes(attributes);
|
super.fromAttributes(attributes);
|
||||||
rel(attributes.get("rel"));
|
rel(attributes.get("rel"));
|
||||||
|
@ -76,7 +134,7 @@ public class Link extends Reference<Link> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
protected String rel;
|
private String rel;
|
||||||
|
|
||||||
private Link(URI href, String rel) {
|
private Link(URI href, String rel) {
|
||||||
super(href);
|
super(href);
|
||||||
|
|
|
@ -0,0 +1,159 @@
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a set of metadata
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <xs:complexType name="Metadata">
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author danikov
|
||||||
|
*/
|
||||||
|
@XmlRootElement(namespace = NS, name = "Metadata")
|
||||||
|
public class Metadata extends ResourceType<Metadata>{
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromMetadataList(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends ResourceType.Builder<Metadata> {
|
||||||
|
|
||||||
|
private Set<MetadataEntry> metadataEntries = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Metadata#getMetadata()
|
||||||
|
*/
|
||||||
|
public Builder metadata(Set<MetadataEntry> metadataEntries) {
|
||||||
|
this.metadataEntries = Sets.newLinkedHashSet(checkNotNull(metadataEntries, "metadataEntries"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Metadata#getMetadata()
|
||||||
|
*/
|
||||||
|
public Builder entry(MetadataEntry metadataEntry) {
|
||||||
|
metadataEntries.add(checkNotNull(metadataEntry, "metadataEntry"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Metadata build() {
|
||||||
|
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<Link> 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) {
|
||||||
|
return metadata(in.getMetadata());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Metadata() {
|
||||||
|
// For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
private Metadata(URI href, Set<MetadataEntry> metadataEntries) {
|
||||||
|
super(href);
|
||||||
|
this.metadata = ImmutableSet.copyOf(metadataEntries);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(namespace = NS, name = "MetadataEntry")
|
||||||
|
private Set<MetadataEntry> metadata = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
public Set<MetadataEntry> getMetadata() {
|
||||||
|
return ImmutableSet.copyOf(metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (!super.equals(o))
|
||||||
|
return false;
|
||||||
|
Metadata that = Metadata.class.cast(o);
|
||||||
|
return super.equals(that) && equal(metadata, that.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return super.hashCode() + Objects.hashCode(metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ToStringHelper string() {
|
||||||
|
return super.string().add("metadata", metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,174 @@
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
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.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a metadata entry
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <xs:complexType name="MetadataType">
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author danikov
|
||||||
|
*/
|
||||||
|
@XmlRootElement(namespace = NS, name = "TODO")
|
||||||
|
public class MetadataEntry extends ResourceType<MetadataEntry> {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromMetadata(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends ResourceType.Builder<MetadataEntry> {
|
||||||
|
private String key;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetadataEntry build() {
|
||||||
|
MetadataEntry metadataEntry = new MetadataEntry(href, key, value);
|
||||||
|
metadataEntry.setType(type);
|
||||||
|
metadataEntry.setLinks(links);
|
||||||
|
return metadataEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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<Link> 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private MetadataEntry() {
|
||||||
|
// For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
private MetadataEntry(URI href, String key, String value) {
|
||||||
|
super(href);
|
||||||
|
this.key = checkNotNull(key, "key");
|
||||||
|
this.value = checkNotNull(value, "value");
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(namespace = NS, name = "K")
|
||||||
|
private String key;
|
||||||
|
@XmlElement(namespace = NS, name = "Value")
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return key of the entry
|
||||||
|
*/
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return value of the entry
|
||||||
|
*/
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (!super.equals(o))
|
||||||
|
return false;
|
||||||
|
MetadataEntry that = MetadataEntry.class.cast(o);
|
||||||
|
return super.equals(that) && 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,22 +18,18 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
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.checkNotNull;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
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;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +44,7 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "Org")
|
@XmlRootElement(namespace = NS, name = "Org")
|
||||||
public class Org extends Entity<Org> {
|
public class Org extends EntityType<Org> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
@ -60,7 +56,7 @@ public class Org extends Entity<Org> {
|
||||||
return new Builder().fromOrg(this);
|
return new Builder().fromOrg(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder extends Entity.Builder<Org> {
|
public static class Builder extends EntityType.Builder<Org> {
|
||||||
|
|
||||||
private String fullName;
|
private String fullName;
|
||||||
|
|
||||||
|
@ -79,17 +75,89 @@ public class Org extends Entity<Org> {
|
||||||
org.setId(id);
|
org.setId(id);
|
||||||
org.setType(type);
|
org.setType(type);
|
||||||
org.setLinks(links);
|
org.setLinks(links);
|
||||||
org.setTasks(tasks);
|
org.setTasksInProgress(tasksInProgress);
|
||||||
return org;
|
return org;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getName()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Builder fromEntity(Entity<Org> in) {
|
public Builder name(String name) {
|
||||||
return Builder.class.cast(super.fromEntity(in));
|
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#getTasksInProgress()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||||
|
this.tasksInProgress = tasksInProgress;
|
||||||
|
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<Link> 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<Org> in) {
|
||||||
|
return Builder.class.cast(super.fromEntityType(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromOrg(Org in) {
|
public Builder fromOrg(Org in) {
|
||||||
return fromEntity(in).fullName(in.getFullName());
|
return fromEntityType(in).fullName(in.getFullName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,12 @@ public class OrgList {
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
private Set<OrgLink> orgs = Sets.newLinkedHashSet();
|
private Set<Reference> orgs = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see OrgList#getOrgs
|
* @see OrgList#getOrgs
|
||||||
*/
|
*/
|
||||||
public Builder orgs(Set<OrgLink> orgs) {
|
public Builder orgs(Set<Reference> orgs) {
|
||||||
this.orgs = Sets.newLinkedHashSet(checkNotNull(orgs, "orgs"));
|
this.orgs = Sets.newLinkedHashSet(checkNotNull(orgs, "orgs"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class OrgList {
|
||||||
/**
|
/**
|
||||||
* @see OrgList#getOrgs
|
* @see OrgList#getOrgs
|
||||||
*/
|
*/
|
||||||
public Builder addOrg(OrgLink org) {
|
public Builder org(Reference org) {
|
||||||
orgs.add(checkNotNull(org, "org"));
|
orgs.add(checkNotNull(org, "org"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -80,14 +80,14 @@ public class OrgList {
|
||||||
// For JAXB and builder use
|
// For JAXB and builder use
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrgList(Set<OrgLink> orgs) {
|
private OrgList(Set<Reference> orgs) {
|
||||||
this.orgs = ImmutableSet.copyOf(orgs);
|
this.orgs = ImmutableSet.copyOf(orgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "Org")
|
@XmlElement(namespace = NS, name = "Org")
|
||||||
private Set<OrgLink> orgs = Sets.newLinkedHashSet();
|
private Set<Reference> orgs = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
public Set<OrgLink> getOrgs() {
|
public Set<Reference> getOrgs() {
|
||||||
return ImmutableSet.copyOf(orgs);
|
return ImmutableSet.copyOf(orgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,202 +18,97 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
|
||||||
|
|
||||||
import java.net.URI;
|
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.
|
* A reference to a resource.
|
||||||
*
|
*
|
||||||
* Contains an href attribute and optional name and type attributes.
|
* @author grkvlt@apache.org
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* <xs:complexType name="ReferenceType">
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
*/
|
||||||
public class Reference<T extends Reference<T>> {
|
public class Reference extends ReferenceType<Reference> {
|
||||||
|
|
||||||
public static <T extends Reference<T>> Builder<T> builder() {
|
@SuppressWarnings("unchecked")
|
||||||
return new Builder<T>();
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<T> toBuilder() {
|
@Override
|
||||||
return new Builder<T>().fromReference(this);
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromReference(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder<T extends Reference<T>> {
|
public static class Builder extends ReferenceType.Builder<Reference> {
|
||||||
|
|
||||||
protected URI href;
|
@Override
|
||||||
protected String id;
|
public Reference build() {
|
||||||
protected String name;
|
Reference reference = new Reference(href);
|
||||||
protected String type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Reference#getHref()
|
|
||||||
*/
|
|
||||||
public Builder<T> href(URI href) {
|
|
||||||
this.href = href;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Reference#getId()
|
|
||||||
*/
|
|
||||||
public Builder<T> id(String id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Reference#getType()
|
|
||||||
*/
|
|
||||||
public Builder<T> type(String type) {
|
|
||||||
this.type = type;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Reference#getName()
|
|
||||||
*/
|
|
||||||
public Builder<T> name(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Reference<T> build() {
|
|
||||||
Reference<T> reference = new Reference<T>(href);
|
|
||||||
reference.setId(id);
|
reference.setId(id);
|
||||||
reference.setName(name);
|
reference.setName(name);
|
||||||
reference.setType(type);
|
reference.setType(type);
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Builder<T> fromReference(Reference<T> 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<T> fromAttributes(Map<String, String> 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAttribute
|
/**
|
||||||
protected URI href;
|
* @see ReferenceType#getName()
|
||||||
@XmlAttribute
|
*/
|
||||||
protected String id;
|
@Override
|
||||||
@XmlAttribute
|
public Builder name(String name) {
|
||||||
protected String name;
|
this.name = name;
|
||||||
@XmlAttribute
|
return this;
|
||||||
protected String type;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Builder fromReferenceType(ReferenceType<Reference> in) {
|
||||||
|
return Builder.class.cast(super.fromReferenceType(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Builder fromReference(Reference in) {
|
||||||
|
return fromReferenceType(in);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected Reference(URI href) {
|
protected Reference(URI href) {
|
||||||
this.href = href;
|
super(href);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Reference() {
|
protected Reference() {
|
||||||
// For JAXB
|
// 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
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o)
|
if (this == o)
|
||||||
return true;
|
return true;
|
||||||
if (o == null || getClass() != o.getClass())
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
Reference<?> that = Reference.class.cast(o);
|
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);
|
return super.equals(that);
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <xs:complexType name="ReferenceType">
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class ReferenceType<T extends ReferenceType<T>> {
|
||||||
|
|
||||||
|
public static <T extends ReferenceType<T>> Builder<T> builder() {
|
||||||
|
return new Builder<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> toBuilder() {
|
||||||
|
return new Builder<T>().fromReferenceType(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder<T extends ReferenceType<T>> {
|
||||||
|
|
||||||
|
protected URI href;
|
||||||
|
protected String id;
|
||||||
|
protected String name;
|
||||||
|
protected String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getHref()
|
||||||
|
*/
|
||||||
|
public Builder<T> href(URI href) {
|
||||||
|
this.href = href;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getId()
|
||||||
|
*/
|
||||||
|
public Builder<T> id(String id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getType()
|
||||||
|
*/
|
||||||
|
public Builder<T> type(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getName()
|
||||||
|
*/
|
||||||
|
public Builder<T> name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceType<T> build() {
|
||||||
|
ReferenceType<T> reference = new ReferenceType<T>(href);
|
||||||
|
reference.setId(id);
|
||||||
|
reference.setName(name);
|
||||||
|
reference.setType(type);
|
||||||
|
return reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Builder<T> fromReferenceType(ReferenceType<T> in) {
|
||||||
|
return href(in.getHref()).id(in.getId()).name(in.getName()).type(in.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Builder<T> fromAttributes(Map<String, String> 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,185 +18,101 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
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.Preconditions.*;
|
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*;
|
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
|
||||||
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Task.Builder;
|
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base type for all objects in the vCloud model.
|
* A resource.
|
||||||
*
|
*
|
||||||
* Has an optional list of links and href and type attributes.
|
* @author grkvlt@apache.org
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* <xs:complexType name="ResourceType">
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
*/
|
||||||
public class Resource<T extends Resource<T>> {
|
public class Resource extends ResourceType<Resource> {
|
||||||
|
|
||||||
public static <T extends Resource<T>> Builder<T> builder() {
|
@SuppressWarnings("unchecked")
|
||||||
return new Builder<T>();
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<T> toBuilder() {
|
@Override
|
||||||
return new Builder<T>().fromResource(this);
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromResource(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder<T extends Resource<T>> {
|
public static class Builder extends ResourceType.Builder<Resource> {
|
||||||
|
|
||||||
protected URI href;
|
@Override
|
||||||
protected String type;
|
public Resource build() {
|
||||||
protected Set<Link> links = Sets.newLinkedHashSet();
|
Resource reference = new Resource(href);
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Reference#getHref()
|
|
||||||
*/
|
|
||||||
public Builder<T> href(URI href) {
|
|
||||||
this.href = href;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Reference#getType()
|
|
||||||
*/
|
|
||||||
public Builder<T> type(String type) {
|
|
||||||
this.type = type;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Reference#getLinks()
|
|
||||||
*/
|
|
||||||
public Builder<T> links(Set<Link> links) {
|
|
||||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Reference#getLinks()
|
|
||||||
*/
|
|
||||||
public Builder<T> link(Link link) {
|
|
||||||
this.links.add(checkNotNull(link, "link"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Resource<T> build() {
|
|
||||||
Resource<T> reference = new Resource<T>(href);
|
|
||||||
reference.setType(type);
|
reference.setType(type);
|
||||||
reference.setLinks(links);
|
reference.setLinks(links);
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Builder<T> fromResource(Resource<T> 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAttribute
|
/**
|
||||||
protected URI href;
|
* @see ResourceType#getType()
|
||||||
@XmlAttribute
|
*/
|
||||||
protected String type;
|
@Override
|
||||||
@XmlElement(namespace = NS, name = "Link")
|
public Builder type(String type) {
|
||||||
protected Set<Link> links = Sets.newLinkedHashSet();
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceType#getLinks()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder links(Set<Link> 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<Resource> in) {
|
||||||
|
return Builder.class.cast(super.fromResourceType(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Builder fromResource(Resource in) {
|
||||||
|
return fromResourceType(in);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected Resource(URI href) {
|
protected Resource(URI href) {
|
||||||
this.href = href;
|
super(href);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Resource() {
|
protected Resource() {
|
||||||
// For JAXB
|
// 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 Set<Link>getLinks() {
|
|
||||||
return links;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLinks(Set<Link> 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
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o)
|
if (this == o)
|
||||||
return true;
|
return true;
|
||||||
if (o == null || getClass() != o.getClass())
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
Resource<?> that = Resource.class.cast(o);
|
Resource that = Resource.class.cast(o);
|
||||||
return equal(this.href, that.href) && equal(this.links, that.links) && equal(this.type, that.type);
|
return super.equals(that);
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <xs:complexType name="ResourceType">
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class ResourceType<T extends ResourceType<T>> {
|
||||||
|
|
||||||
|
public static <T extends ResourceType<T>> Builder<T> builder() {
|
||||||
|
return new Builder<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> toBuilder() {
|
||||||
|
return new Builder<T>().fromResourceType(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder<T extends ResourceType<T>> {
|
||||||
|
|
||||||
|
protected URI href;
|
||||||
|
protected String type;
|
||||||
|
protected Set<Link> links = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceType#getHref()
|
||||||
|
*/
|
||||||
|
public Builder<T> href(URI href) {
|
||||||
|
this.href = href;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceType#getType()
|
||||||
|
*/
|
||||||
|
public Builder<T> type(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceType#getLinks()
|
||||||
|
*/
|
||||||
|
public Builder<T> links(Set<Link> links) {
|
||||||
|
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceType#getLinks()
|
||||||
|
*/
|
||||||
|
public Builder<T> link(Link link) {
|
||||||
|
this.links.add(checkNotNull(link, "link"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceType<T> build() {
|
||||||
|
ResourceType<T> reference = new ResourceType<T>(href);
|
||||||
|
reference.setType(type);
|
||||||
|
reference.setLinks(links);
|
||||||
|
return reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Builder<T> fromResourceType(ResourceType<T> 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<Link> 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 Set<Link>getLinks() {
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinks(Set<Link> 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,13 +18,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
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.checkNotNull;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
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.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
@ -41,6 +43,7 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "Session")
|
@XmlRootElement(namespace = NS, name = "Session")
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class Session {
|
public class Session {
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
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;
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ public class SessionWithToken {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Session session;
|
private Session session;
|
||||||
protected String token;
|
private String token;
|
||||||
|
|
||||||
protected SessionWithToken(String token, Session session) {
|
protected SessionWithToken(String token, Session session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
|
|
@ -0,0 +1,371 @@
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
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;
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <xs:complexType name="TaskType">
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@XmlRootElement(namespace = NS, name = "Task")
|
||||||
|
public class Task extends EntityType<Task> {
|
||||||
|
|
||||||
|
@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<Task> {
|
||||||
|
|
||||||
|
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#getTasksInProgress()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||||
|
this.tasksInProgress = tasksInProgress;
|
||||||
|
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<Link> 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<Task> in) {
|
||||||
|
return Builder.class.cast(super.fromEntityType(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromTask(Task in) {
|
||||||
|
return fromEntityType(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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Task> tasks = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TasksInProgress#getTasks()
|
||||||
|
*/
|
||||||
|
public Builder tasks(Set<Task> 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 TasksInProgress build() {
|
||||||
|
return new TasksInProgress(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromTasksInProgress(TasksInProgress in) {
|
||||||
|
return tasks(in.getTasks());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TasksInProgress() {
|
||||||
|
// For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TasksInProgress(Collection<Task> tasks) {
|
||||||
|
this.tasks = ImmutableSet.copyOf(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(namespace = NS, name = "Task")
|
||||||
|
private Set<Task> tasks = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
public Set<Task> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
/**
|
||||||
|
* 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.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.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of tasks.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@XmlRootElement(namespace = NS, name = "TasksList")
|
||||||
|
public class TasksList extends EntityType<TasksList> {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends EntityType.Builder<TasksList> {
|
||||||
|
|
||||||
|
protected Set<Task> tasks = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TasksList#getTasks()
|
||||||
|
*/
|
||||||
|
public Builder tasks(Set<Task> tasks) {
|
||||||
|
this.tasks = Sets.newLinkedHashSet(checkNotNull(tasks, "tasks"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TasksList#getTasks()
|
||||||
|
*/
|
||||||
|
public Builder task(Task task) {
|
||||||
|
this.tasks.add(checkNotNull(task, "task"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 fromTasksList(TasksList in) {
|
||||||
|
return tasks(in.getTasks());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TasksList() {
|
||||||
|
// For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TasksList(URI href, String name, Set<Task> tasks) {
|
||||||
|
super(href, name);
|
||||||
|
this.tasks = ImmutableSet.copyOf(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(namespace = NS, name = "Task")
|
||||||
|
private Set<Task> tasks = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
public Set<Task> getTasks() {
|
||||||
|
return ImmutableSet.copyOf(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
TasksList that = TasksList.class.cast(o);
|
||||||
|
return super.equals(that) && equal(this.tasks, that.tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return super.hashCode() + Objects.hashCode(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ToStringHelper string() {
|
||||||
|
return super.string().add("tasks", tasks);
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,6 +29,8 @@ import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.JAXBResponseParser;
|
import org.jclouds.rest.annotations.JAXBResponseParser;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
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.Org;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||||
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||||
|
@ -60,4 +62,23 @@ public interface OrgAsyncClient {
|
||||||
@JAXBResponseParser
|
@JAXBResponseParser
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<Org> getOrg(@EndpointParam URI uri);
|
ListenableFuture<Org> getOrg(@EndpointParam URI uri);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see OrgClient#getMetadata
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("/metadata/")
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Metadata> getMetadata(@EndpointParam URI orgRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see OrgClient#getMetadataEntry
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<MetadataEntry> getMetadataEntry(@EndpointParam URI metaDataRef);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ import java.net.URI;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
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.Org;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||||
|
|
||||||
|
@ -49,4 +51,18 @@ public interface OrgClient {
|
||||||
* @return the org or null if not found
|
* @return the org or null if not found
|
||||||
*/
|
*/
|
||||||
Org getOrg(URI orgHref);
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,19 +22,17 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
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.VCloudDirectorClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
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.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.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.OrgList;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows us to test a client via its side effects.
|
* Allows us to test a client via its side effects.
|
||||||
*
|
*
|
||||||
|
@ -44,99 +42,115 @@ import com.google.common.collect.ImmutableMultimap;
|
||||||
public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||||
@Test
|
@Test
|
||||||
public void testWhenResponseIs2xxLoginReturnsValidOrgList() {
|
public void testWhenResponseIs2xxLoginReturnsValidOrgList() {
|
||||||
HttpRequest orgListRequest = HttpRequest.builder()
|
|
||||||
.method("GET")
|
|
||||||
.endpoint(URI.create("http://localhost/api/org/"))
|
|
||||||
.headers(ImmutableMultimap.<String, String> builder()
|
|
||||||
.put("Accept", "*/*")
|
|
||||||
.put("x-vcloud-authorization", token)
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
HttpResponse orgListResponse = HttpResponse.builder()
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
.statusCode(200)
|
getStandardRequest("GET", URI.create("http://localhost/api/org/")),
|
||||||
.payload(payloadFromResourceWithContentType("/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML + ";version=1.5"))
|
getStandardPayloadResponse("/org/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML));
|
||||||
.build();
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgListRequest, orgListResponse);
|
OrgList expected = OrgList.builder()
|
||||||
|
.org(Reference.builder()
|
||||||
assertEquals(client.getOrgClient().getOrgList(), OrgList.builder()
|
|
||||||
.addOrg(OrgLink.builder()
|
|
||||||
.type("application/vnd.vmware.vcloud.org+xml")
|
.type("application/vnd.vmware.vcloud.org+xml")
|
||||||
.name("JClouds")
|
.name("JClouds")
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
.build())
|
.build())
|
||||||
.build()
|
.build();
|
||||||
);
|
|
||||||
|
assertEquals(client.getOrgClient().getOrgList(), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenResponseIs2xxLoginReturnsValidOrg() {
|
public void testWhenResponseIs2xxLoginReturnsValidOrg() {
|
||||||
URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0");
|
URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0");
|
||||||
|
|
||||||
HttpRequest orgRequest = HttpRequest.builder()
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
.method("GET")
|
getStandardRequest("GET", orgRef),
|
||||||
.endpoint(orgRef)
|
getStandardPayloadResponse("/org/org.xml", VCloudDirectorMediaType.ORG_XML));
|
||||||
.headers(ImmutableMultimap.<String, String> builder()
|
|
||||||
.put("Accept", "*/*")
|
|
||||||
.put("x-vcloud-authorization", token)
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
HttpResponse orgResponse = HttpResponse.builder()
|
Org expected = Org
|
||||||
.statusCode(200)
|
.builder()
|
||||||
.payload(payloadFromResourceWithContentType("/org.xml", VCloudDirectorMediaType.ORG_XML + ";version=1.5"))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgRequest, orgResponse);
|
|
||||||
|
|
||||||
assertEquals(client.getOrgClient().getOrg(orgRef), Org.builder()
|
|
||||||
.name("JClouds")
|
.name("JClouds")
|
||||||
|
.description("")
|
||||||
|
.fullName("JClouds")
|
||||||
.id("urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0")
|
.id("urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0")
|
||||||
.type(VCloudDirectorMediaType.ORG_XML)
|
.type(VCloudDirectorMediaType.ORG_XML)
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
.addLink(Link.builder()
|
.link(Link.builder()
|
||||||
.rel("down")
|
.rel("down")
|
||||||
.type("application/vnd.vmware.vcloud.vdc+xml")
|
.type("application/vnd.vmware.vcloud.vdc+xml")
|
||||||
.name("Cluster01-JClouds")
|
.name("Cluster01-JClouds")
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07"))
|
||||||
.build())
|
.build())
|
||||||
.addLink(Link.builder()
|
.link(Link.builder()
|
||||||
.rel("down")
|
.rel("down")
|
||||||
.type("application/vnd.vmware.vcloud.tasksList+xml")
|
.type("application/vnd.vmware.vcloud.tasksList+xml")
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
.build())
|
.build())
|
||||||
.addLink(Link.builder()
|
.link(Link.builder()
|
||||||
.rel("down")
|
.rel("down")
|
||||||
.type("application/vnd.vmware.vcloud.catalog+xml")
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
.name("Public")
|
.name("Public")
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c"))
|
||||||
.build())
|
.build())
|
||||||
.addLink(Link.builder()
|
.link(Link.builder()
|
||||||
.rel("down")
|
.rel("down")
|
||||||
.type("application/vnd.vmware.vcloud.controlAccess+xml")
|
.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/"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c/controlAccess/"))
|
||||||
.build())
|
.build())
|
||||||
.addLink(Link.builder()
|
.link(Link.builder()
|
||||||
.rel("down")
|
.rel("down")
|
||||||
.type("application/vnd.vmware.vcloud.orgNetwork+xml")
|
.type("application/vnd.vmware.vcloud.orgNetwork+xml")
|
||||||
.name("ilsolation01-Jclouds")
|
.name("ilsolation01-Jclouds")
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"))
|
||||||
.build())
|
.build())
|
||||||
.addLink(Link.builder()
|
.link(Link.builder()
|
||||||
.rel("down")
|
.rel("down")
|
||||||
.type("application/vnd.vmware.vcloud.orgNetwork+xml")
|
.type("application/vnd.vmware.vcloud.orgNetwork+xml")
|
||||||
.name("internet01-Jclouds")
|
.name("internet01-Jclouds")
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"))
|
||||||
.build())
|
.build())
|
||||||
.addLink(Link.builder()
|
.link(Link.builder()
|
||||||
.rel("down")
|
.rel("down")
|
||||||
.type("application/vnd.vmware.vcloud.metadata+xml")
|
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"))
|
||||||
.build())
|
.build())
|
||||||
.description("")
|
.build();
|
||||||
.fullName("JClouds")
|
|
||||||
.build()
|
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", metaRef),
|
||||||
|
getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA_XML));
|
||||||
|
|
||||||
|
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), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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),
|
||||||
|
getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML));
|
||||||
|
|
||||||
|
MetadataEntry expected = MetadataEntry.builder()
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getOrgClient().getMetadataEntry(metadataRef), expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,4 +57,17 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
|
||||||
credential = password;
|
credential = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected HttpRequest getStandardRequest(String method, URI uri) {
|
||||||
|
return HttpRequest.builder().method(method).endpoint(uri).headers(
|
||||||
|
ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.put("x-vcloud-authorization",token)
|
||||||
|
.build()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected HttpResponse getStandardPayloadResponse(String relativeFilePath, String mediaType) {
|
||||||
|
return HttpResponse.builder().statusCode(200)
|
||||||
|
.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType+";version=1.5")).build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Metadata xmlns="http://www.vmware.com/vcloud/v1.5" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
|
||||||
|
<Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
|
||||||
|
</Metadata>
|
Loading…
Reference in New Issue