mirror of https://github.com/apache/jclouds.git
Issue #830 vcloud-director: combined ReferenceType and Reference domain classes
This commit is contained in:
parent
68d455d1d9
commit
a862b53fe5
|
@ -5,20 +5,20 @@ import java.net.URI;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
@XmlRootElement(name = "CatalogReference")
|
@XmlRootElement(name = "CatalogReference")
|
||||||
public class CatalogReference extends ReferenceType {
|
public class CatalogReference extends Reference {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromReferenceType(this);
|
return builder().fromCatalogReference(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder<B extends Builder<B>> extends ReferenceType.Builder<B> {
|
public static class Builder<B extends Builder<B>> extends Reference.Builder<B> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CatalogReference build() {
|
public CatalogReference build() {
|
||||||
|
@ -26,7 +26,7 @@ public class CatalogReference extends ReferenceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected B fromCatalogReference(CatalogReference in) {
|
protected B fromCatalogReference(CatalogReference in) {
|
||||||
return fromReferenceType(in);
|
return fromReference(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class GroupsList {
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Objects of the following type(s) are allowed in the list
|
* Objects of the following type(s) are allowed in the list
|
||||||
* {@link ReferenceType }
|
* {@link Reference }
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -52,14 +52,14 @@ public class InstantiateVAppParamsType extends VAppCreationParamsType {
|
||||||
|
|
||||||
public static abstract class Builder<B extends Builder<B>> extends VAppCreationParamsType.Builder<B> {
|
public static abstract class Builder<B extends Builder<B>> extends VAppCreationParamsType.Builder<B> {
|
||||||
|
|
||||||
private ReferenceType source;
|
private Reference source;
|
||||||
private Boolean sourceDelete;
|
private Boolean sourceDelete;
|
||||||
private Boolean linkedClone;
|
private Boolean linkedClone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see InstantiateVAppParamsType#getSource()
|
* @see InstantiateVAppParamsType#getSource()
|
||||||
*/
|
*/
|
||||||
public B source(ReferenceType source) {
|
public B source(Reference source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ public class InstantiateVAppParamsType extends VAppCreationParamsType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(name = "Source", required = true)
|
@XmlElement(name = "Source", required = true)
|
||||||
private ReferenceType source;
|
private Reference source;
|
||||||
@XmlElement(name = "IsSourceDelete")
|
@XmlElement(name = "IsSourceDelete")
|
||||||
private Boolean sourceDelete;
|
private Boolean sourceDelete;
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
|
@ -146,7 +146,7 @@ public class InstantiateVAppParamsType extends VAppCreationParamsType {
|
||||||
/**
|
/**
|
||||||
* Gets the value of the source property.
|
* Gets the value of the source property.
|
||||||
*/
|
*/
|
||||||
public ReferenceType getSource() {
|
public Reference getSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ import com.google.common.base.Objects.ToStringHelper;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "Link")
|
@XmlRootElement(name = "Link")
|
||||||
public class Link extends ReferenceType {
|
public class Link extends Reference {
|
||||||
|
|
||||||
public static final class Rel {
|
public static final class Rel {
|
||||||
public static final String ADD = "add";
|
public static final String ADD = "add";
|
||||||
|
@ -132,7 +132,7 @@ public class Link extends ReferenceType {
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder<B extends Builder<B>> extends ReferenceType.Builder<B> {
|
public static class Builder<B extends Builder<B>> extends Reference.Builder<B> {
|
||||||
|
|
||||||
private String rel;
|
private String rel;
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ public class Link extends ReferenceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
public B fromLink(Link in) {
|
public B fromLink(Link in) {
|
||||||
return fromReferenceType(in).rel(in.getRel());
|
return fromReference(in).rel(in.getRel());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class Networks {
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Objects of the following type(s) are allowed in the list
|
* Objects of the following type(s) are allowed in the list
|
||||||
* {@link ReferenceType }
|
* {@link Reference }
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -42,13 +42,13 @@ public class OrgNetwork extends NetworkType {
|
||||||
|
|
||||||
public static abstract class Builder<B extends Builder<B>> extends NetworkType.Builder<B> {
|
public static abstract class Builder<B extends Builder<B>> extends NetworkType.Builder<B> {
|
||||||
|
|
||||||
private ReferenceType networkPool;
|
private Reference networkPool;
|
||||||
private IpAddresses allowedExternalIpAddresses;
|
private IpAddresses allowedExternalIpAddresses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see OrgNetwork#getNetworkPool()
|
* @see OrgNetwork#getNetworkPool()
|
||||||
*/
|
*/
|
||||||
public B networkPool(ReferenceType networkPool) {
|
public B networkPool(Reference networkPool) {
|
||||||
this.networkPool = networkPool;
|
this.networkPool = networkPool;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
@ -84,14 +84,14 @@ public class OrgNetwork extends NetworkType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(name = "NetworkPool")
|
@XmlElement(name = "NetworkPool")
|
||||||
private ReferenceType networkPool;
|
private Reference networkPool;
|
||||||
@XmlElement(name = "AllowedExternalIpAddresses")
|
@XmlElement(name = "AllowedExternalIpAddresses")
|
||||||
private IpAddresses allowedExternalIpAddresses;
|
private IpAddresses allowedExternalIpAddresses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return optional network pool
|
* @return optional network pool
|
||||||
*/
|
*/
|
||||||
public ReferenceType getNetworkPool() {
|
public Reference getNetworkPool() {
|
||||||
return networkPool;
|
return networkPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,12 +53,12 @@ public class Owner extends ResourceType {
|
||||||
|
|
||||||
public static abstract class Builder<B extends Builder<B>> extends ResourceType.Builder<B> {
|
public static abstract class Builder<B extends Builder<B>> extends ResourceType.Builder<B> {
|
||||||
|
|
||||||
private ReferenceType user;
|
private Reference user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Owner#getUser()
|
* @see Owner#getUser()
|
||||||
*/
|
*/
|
||||||
public B user(ReferenceType user) {
|
public B user(Reference user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
@ -84,12 +84,12 @@ public class Owner extends ResourceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(name = "User", required = true)
|
@XmlElement(name = "User", required = true)
|
||||||
private ReferenceType user;
|
private Reference user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the user property.
|
* Gets the value of the user property.
|
||||||
*/
|
*/
|
||||||
public ReferenceType getUser() {
|
public Reference getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,36 @@
|
||||||
*/
|
*/
|
||||||
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.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
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.
|
||||||
|
* <p>
|
||||||
|
* <pre>
|
||||||
|
* <xs:complexType name="ReferenceType">
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
public class Reference extends ReferenceType {
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class Reference {
|
||||||
|
|
||||||
|
@javax.annotation.Resource
|
||||||
|
protected static Logger logger = Logger.NULL;
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
|
@ -38,34 +60,145 @@ public class Reference extends ReferenceType {
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder<B extends Builder<B>> extends ReferenceType.Builder<B> {
|
public static class Builder<B extends Builder<B>> {
|
||||||
|
|
||||||
|
private URI href;
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
protected B self() {
|
||||||
|
return (B) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Reference#getHref()
|
||||||
|
*/
|
||||||
|
public B href(URI href) {
|
||||||
|
this.href = href;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Reference#getId()
|
||||||
|
*/
|
||||||
|
public B id(String id) {
|
||||||
|
this.id = id;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Reference#getType()
|
||||||
|
*/
|
||||||
|
public B type(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Reference#getName()
|
||||||
|
*/
|
||||||
|
public B name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Reference build() {
|
public Reference build() {
|
||||||
return new Reference(this);
|
return new Reference(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public B fromReference(Reference in) {
|
protected B fromReference(Reference in) {
|
||||||
return fromReferenceType(in);
|
return href(in.getHref()).id(in.getId()).name(in.getName()).type(in.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public B fromEntity(EntityType in) {
|
public B fromEntity(EntityType in) {
|
||||||
return href(in.getHref()).id(in.getId()).name(in.getName()).type(in.getType());
|
return href(in.getHref()).id(in.getId()).name(in.getName()).type(in.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected B 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(required = true)
|
||||||
|
private URI href;
|
||||||
|
@XmlAttribute
|
||||||
|
private String id;
|
||||||
|
@XmlAttribute
|
||||||
|
private String name;
|
||||||
|
@XmlAttribute
|
||||||
|
private String type;
|
||||||
|
|
||||||
protected Reference(Builder<?> builder) {
|
protected Reference(Builder<?> builder) {
|
||||||
super(builder);
|
this.href = builder.href;
|
||||||
|
this.id = builder.id;
|
||||||
|
this.name = builder.name;
|
||||||
|
this.type = builder.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Reference(URI href, String id, String name, String type) {
|
protected Reference(URI href, String id, String name, String type) {
|
||||||
super(href, id, name, type);
|
this.href = href;
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Reference() {
|
protected Reference() {
|
||||||
// For JAXB
|
// For JAXB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the URI to the entity.
|
||||||
|
* <p/>
|
||||||
|
* 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.
|
||||||
|
* <p/>
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the name of the the entity.
|
||||||
|
* <p/>
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the type of the the entity.
|
||||||
|
* <p/>
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o)
|
if (this == o)
|
||||||
|
@ -73,13 +206,27 @@ public class Reference extends ReferenceType {
|
||||||
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 super.equals(that);
|
return equal(this.href, that.href) && equal(this.id, that.id) && equal(this.name, that.name) && equal(this.type, that.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReferenceType toAdminReference(String endpoint) {
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Reference toAdminReference(String endpoint) {
|
||||||
return toBuilder()
|
return toBuilder()
|
||||||
.type(null)
|
.type(null)
|
||||||
.href(URI.create(getHref().toASCIIString().replace(endpoint, endpoint+"/admin")))
|
.href(URI.create(getHref().toASCIIString().replace(endpoint, endpoint+"/admin")))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,221 +0,0 @@
|
||||||
/**
|
|
||||||
* 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 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 org.jclouds.logging.Logger;
|
|
||||||
|
|
||||||
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.
|
|
||||||
* <p>
|
|
||||||
* <pre>
|
|
||||||
* <xs:complexType name="ReferenceType">
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author grkvlt@apache.org
|
|
||||||
*/
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
|
||||||
public class ReferenceType {
|
|
||||||
|
|
||||||
@javax.annotation.Resource
|
|
||||||
protected static Logger logger = Logger.NULL;
|
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
|
||||||
return new ConcreteBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
|
||||||
return builder().fromReferenceType(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder<B extends Builder<B>> {
|
|
||||||
|
|
||||||
private URI href;
|
|
||||||
private String id;
|
|
||||||
private String name;
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected B self() {
|
|
||||||
return (B) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ReferenceType#getHref()
|
|
||||||
*/
|
|
||||||
public B href(URI href) {
|
|
||||||
this.href = href;
|
|
||||||
return self();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ReferenceType#getId()
|
|
||||||
*/
|
|
||||||
public B id(String id) {
|
|
||||||
this.id = id;
|
|
||||||
return self();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ReferenceType#getType()
|
|
||||||
*/
|
|
||||||
public B type(String type) {
|
|
||||||
this.type = type;
|
|
||||||
return self();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ReferenceType#getName()
|
|
||||||
*/
|
|
||||||
public B name(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return self();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReferenceType build() {
|
|
||||||
return new ReferenceType(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected B fromReferenceType(ReferenceType in) {
|
|
||||||
return href(in.getHref()).id(in.getId()).name(in.getName()).type(in.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected B 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(required = true)
|
|
||||||
private URI href;
|
|
||||||
@XmlAttribute
|
|
||||||
private String id;
|
|
||||||
@XmlAttribute
|
|
||||||
private String name;
|
|
||||||
@XmlAttribute
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
protected ReferenceType(Builder<?> builder) {
|
|
||||||
this.href = builder.href;
|
|
||||||
this.id = builder.id;
|
|
||||||
this.name = builder.name;
|
|
||||||
this.type = builder.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ReferenceType(URI href, String id, String name, String type) {
|
|
||||||
this.href = href;
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ReferenceType() {
|
|
||||||
// For JAXB
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains the URI to the entity.
|
|
||||||
* <p/>
|
|
||||||
* 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.
|
|
||||||
* <p/>
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains the name of the the entity.
|
|
||||||
* <p/>
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains the type of the the entity.
|
|
||||||
* <p/>
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -86,9 +86,9 @@ public class RelocateParams {
|
||||||
* Gets the value of the datastore property.
|
* Gets the value of the datastore property.
|
||||||
*
|
*
|
||||||
* @return possible object is
|
* @return possible object is
|
||||||
* {@link ReferenceType }
|
* {@link Reference }
|
||||||
*/
|
*/
|
||||||
public ReferenceType getDatastore() {
|
public Reference getDatastore() {
|
||||||
return datastore;
|
return datastore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class UsersList {
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Objects of the following type(s) are allowed in the list
|
* Objects of the following type(s) are allowed in the list
|
||||||
* {@link ReferenceType }
|
* {@link Reference }
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class Vdcs {
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Objects of the following type(s) are allowed in the list
|
* Objects of the following type(s) are allowed in the list
|
||||||
* {@link ReferenceType }
|
* {@link Reference }
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Set;
|
||||||
import javax.xml.bind.annotation.XmlElementRef;
|
import javax.xml.bind.annotation.XmlElementRef;
|
||||||
|
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -60,12 +60,12 @@ public class QueryResultReferences extends ContainerType {
|
||||||
|
|
||||||
public static class Builder<B extends Builder<B>> extends ContainerType.Builder<B> {
|
public static class Builder<B extends Builder<B>> extends ContainerType.Builder<B> {
|
||||||
|
|
||||||
private Set<ReferenceType> references = Sets.newLinkedHashSet();
|
private Set<Reference> references = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see QueryResultReferences#getReferences()
|
* @see QueryResultReferences#getReferences()
|
||||||
*/
|
*/
|
||||||
public B references(Set<? extends ReferenceType> references) {
|
public B references(Set<? extends Reference> references) {
|
||||||
this.references = Sets.newLinkedHashSet(checkNotNull(references, "references"));
|
this.references = Sets.newLinkedHashSet(checkNotNull(references, "references"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class QueryResultReferences extends ContainerType {
|
||||||
/**
|
/**
|
||||||
* @see QueryResultReferences#getReferences()
|
* @see QueryResultReferences#getReferences()
|
||||||
*/
|
*/
|
||||||
public B reference(ReferenceType reference) {
|
public B reference(Reference reference) {
|
||||||
this.references.add(reference);
|
this.references.add(reference);
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
@ -99,12 +99,12 @@ public class QueryResultReferences extends ContainerType {
|
||||||
|
|
||||||
// NOTE add other types as they are used. probably not the best way to do this.
|
// NOTE add other types as they are used. probably not the best way to do this.
|
||||||
@XmlElementRef
|
@XmlElementRef
|
||||||
private Set<ReferenceType> references = Sets.newLinkedHashSet();
|
private Set<Reference> references = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set of references representing query results.
|
* Set of references representing query results.
|
||||||
*/
|
*/
|
||||||
public Set<ReferenceType> getReferences() {
|
public Set<Reference> getReferences() {
|
||||||
return references;
|
return references;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* 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.predicates;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
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.Reference;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Predicates handy when working with Reference Types
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ReferencePredicates {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* matches references of the given name
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
* type of the Reference, ex. {@link Link}
|
||||||
|
* @param name
|
||||||
|
* ex. {@code context.getApi().getCurrentSession().getOrg()}
|
||||||
|
* @return predicate that will match references of the given name
|
||||||
|
*/
|
||||||
|
public static <T extends Reference> Predicate<T> nameEquals(final String name) {
|
||||||
|
checkNotNull(name, "name must be defined");
|
||||||
|
|
||||||
|
return new Predicate<T>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(T reference) {
|
||||||
|
return name.equals(reference.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "nameEquals(" + name + ")";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* matches references of the given type
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
* type of the Reference, ex. {@link Link}
|
||||||
|
* @param type
|
||||||
|
* ex. {@link VCloudDirectorMediaType#CATALOG}
|
||||||
|
* @return predicate that will match references of the given type
|
||||||
|
* @see VCloudDirectorMediaType
|
||||||
|
*/
|
||||||
|
public static <T extends Reference> Predicate<T> typeEquals(final String type) {
|
||||||
|
checkNotNull(type, "type must be defined");
|
||||||
|
|
||||||
|
return new Predicate<T>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(T reference) {
|
||||||
|
return type.equals(reference.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "typeEquals(" + type + ")";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,7 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
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.ReferenceType;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class ReferenceTypePredicates {
|
||||||
* ex. {@code context.getApi().getCurrentSession().getOrg()}
|
* ex. {@code context.getApi().getCurrentSession().getOrg()}
|
||||||
* @return predicate that will match references of the given name
|
* @return predicate that will match references of the given name
|
||||||
*/
|
*/
|
||||||
public static <T extends ReferenceType> Predicate<T> nameEquals(final String name) {
|
public static <T extends Reference> Predicate<T> nameEquals(final String name) {
|
||||||
checkNotNull(name, "name must be defined");
|
checkNotNull(name, "name must be defined");
|
||||||
|
|
||||||
return new Predicate<T>() {
|
return new Predicate<T>() {
|
||||||
|
@ -69,7 +69,7 @@ public class ReferenceTypePredicates {
|
||||||
* @return predicate that will match references of the given type
|
* @return predicate that will match references of the given type
|
||||||
* @see VCloudDirectorMediaType
|
* @see VCloudDirectorMediaType
|
||||||
*/
|
*/
|
||||||
public static <T extends ReferenceType> Predicate<T> typeEquals(final String type) {
|
public static <T extends Reference> Predicate<T> typeEquals(final String type) {
|
||||||
checkNotNull(type, "type must be defined");
|
checkNotNull(type, "type must be defined");
|
||||||
|
|
||||||
return new Predicate<T>() {
|
return new Predicate<T>() {
|
||||||
|
|
|
@ -100,11 +100,11 @@ public class Checks {
|
||||||
*
|
*
|
||||||
* @see checkReferenceType(ReferenceType, Collection<String>)
|
* @see checkReferenceType(ReferenceType, Collection<String>)
|
||||||
*/
|
*/
|
||||||
public static void checkReferenceType(ReferenceType reference) {
|
public static void checkReferenceType(Reference reference) {
|
||||||
checkReferenceType(reference, VCloudDirectorMediaType.ALL);
|
checkReferenceType(reference, VCloudDirectorMediaType.ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkReferenceType(ReferenceType reference, Collection<String> validTypes) {
|
public static void checkReferenceType(Reference reference, Collection<String> validTypes) {
|
||||||
// Check required fields
|
// Check required fields
|
||||||
assertNotNull(reference.getHref(), String.format(NOT_NULL_OBJECT_FMT, "Href", "ReferenceType"));
|
assertNotNull(reference.getHref(), String.format(NOT_NULL_OBJECT_FMT, "Href", "ReferenceType"));
|
||||||
|
|
||||||
|
@ -183,13 +183,13 @@ public class Checks {
|
||||||
// NOTE startTime cannot be checked
|
// NOTE startTime cannot be checked
|
||||||
// NOTE endTime cannot be checked
|
// NOTE endTime cannot be checked
|
||||||
// NOTE expiryTimecannot be checked
|
// NOTE expiryTimecannot be checked
|
||||||
ReferenceType owner = task.getOwner();
|
Reference owner = task.getOwner();
|
||||||
if (owner != null) checkReferenceType(owner);
|
if (owner != null) checkReferenceType(owner);
|
||||||
Error error = task.getError();
|
Error error = task.getError();
|
||||||
if (error != null) checkError(error);
|
if (error != null) checkError(error);
|
||||||
ReferenceType user = task.getUser();
|
Reference user = task.getUser();
|
||||||
if (user != null) checkReferenceType(user);
|
if (user != null) checkReferenceType(user);
|
||||||
ReferenceType org = task.getOrg();
|
Reference org = task.getOrg();
|
||||||
if (org != null) checkReferenceType(org);
|
if (org != null) checkReferenceType(org);
|
||||||
Integer progress = task.getProgress();
|
Integer progress = task.getProgress();
|
||||||
if (progress != null) checkProgress(progress);
|
if (progress != null) checkProgress(progress);
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Owner;
|
import org.jclouds.vcloud.director.v1_5.domain.Owner;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams;
|
import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
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;
|
||||||
|
@ -88,8 +87,6 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
|
||||||
|
|
||||||
AdminCatalog expected = catalog();
|
AdminCatalog expected = catalog();
|
||||||
|
|
||||||
// assertEquals(client.getAdminCatalogClient().getCatalog(catalogRef.getHref()), expected);
|
|
||||||
|
|
||||||
AdminCatalog actual = client.getAdminCatalogClient().getCatalog(catalogRef.getHref());
|
AdminCatalog actual = client.getAdminCatalogClient().getCatalog(catalogRef.getHref());
|
||||||
assertEquals(actual.getHref(), expected.getHref());
|
assertEquals(actual.getHref(), expected.getHref());
|
||||||
assertEquals(actual.getLinks(), expected.getLinks());
|
assertEquals(actual.getLinks(), expected.getLinks());
|
||||||
|
@ -98,10 +95,13 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
|
||||||
System.out.println(actual.getOwner());
|
System.out.println(actual.getOwner());
|
||||||
System.out.println(expected.getOwner());
|
System.out.println(expected.getOwner());
|
||||||
|
|
||||||
assertEquals(actual.getOwner().getUser(), expected.getOwner().getUser());
|
Reference actualUser = actual.getOwner().getUser();
|
||||||
|
Reference expectedUser = expected.getOwner().getUser();
|
||||||
|
assertEquals(actualUser, expectedUser);
|
||||||
|
|
||||||
assertEquals(actual.getOwner(), expected.getOwner());
|
assertEquals(actual.getOwner(), expected.getOwner());
|
||||||
|
|
||||||
|
assertEquals(client.getAdminCatalogClient().getCatalog(catalogRef.getHref()), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)//TODO
|
@Test(enabled = false)//TODO
|
||||||
|
|
|
@ -36,7 +36,6 @@ import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Owner;
|
import org.jclouds.vcloud.director.v1_5.domain.Owner;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams;
|
import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -62,7 +61,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
||||||
/*
|
/*
|
||||||
* Shared state between dependant tests.
|
* Shared state between dependant tests.
|
||||||
*/
|
*/
|
||||||
private ReferenceType orgRef;
|
private Reference orgRef;
|
||||||
private AdminCatalog catalog;
|
private AdminCatalog catalog;
|
||||||
private Owner owner;
|
private Owner owner;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgSettings;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgSettings;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings;
|
import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
@ -60,7 +60,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
/*
|
/*
|
||||||
* Shared state between dependant tests.
|
* Shared state between dependant tests.
|
||||||
*/
|
*/
|
||||||
private ReferenceType orgRef;
|
private Reference orgRef;
|
||||||
private OrgSettings settings, newSettings;
|
private OrgSettings settings, newSettings;
|
||||||
private OrgEmailSettings emailSettings, newEmailSettings;
|
private OrgEmailSettings emailSettings, newEmailSettings;
|
||||||
private OrgGeneralSettings generalSettings, newGeneralSettings;
|
private OrgGeneralSettings generalSettings, newGeneralSettings;
|
||||||
|
|
|
@ -42,7 +42,6 @@ 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.MetadataEntry;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
|
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
|
@ -71,9 +70,9 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
* Shared state between dependant tests.
|
* Shared state between dependant tests.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private ReferenceType catalogRef;
|
private Reference catalogRef;
|
||||||
private ReferenceType catalogItemRef;
|
private Reference catalogItemRef;
|
||||||
private ReferenceType newCatalogItemRef;
|
private Reference newCatalogItemRef;
|
||||||
private CatalogType catalog;
|
private CatalogType catalog;
|
||||||
private CatalogItem catalogItem;
|
private CatalogItem catalogItem;
|
||||||
private CatalogItem newCatalogItem;
|
private CatalogItem newCatalogItem;
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Group;
|
import org.jclouds.vcloud.director.v1_5.domain.Group;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -59,7 +58,7 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
/*
|
/*
|
||||||
* Shared state between dependant tests.
|
* Shared state between dependant tests.
|
||||||
*/
|
*/
|
||||||
private ReferenceType groupRef;
|
private Reference groupRef;
|
||||||
private Group group;
|
private Group group;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -35,7 +35,7 @@ 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.MetadataEntry;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -76,7 +76,7 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
Checks.checkNetworkType(network);
|
Checks.checkNetworkType(network);
|
||||||
|
|
||||||
// optional
|
// optional
|
||||||
ReferenceType networkPoolRef = network.getNetworkPool();
|
Reference networkPoolRef = network.getNetworkPool();
|
||||||
if (networkPoolRef != null) {
|
if (networkPoolRef != null) {
|
||||||
Checks.checkReferenceType(networkPoolRef);
|
Checks.checkReferenceType(networkPoolRef);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.User;
|
import org.jclouds.vcloud.director.v1_5.domain.User;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
@ -58,7 +57,7 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
/*
|
/*
|
||||||
* Shared state between dependant tests.
|
* Shared state between dependant tests.
|
||||||
*/
|
*/
|
||||||
private ReferenceType orgRef;
|
private Reference orgRef;
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -64,7 +64,6 @@ import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList;
|
import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.RecomposeVAppParams;
|
import org.jclouds.vcloud.director.v1_5.domain.RecomposeVAppParams;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.RelocateParams;
|
import org.jclouds.vcloud.director.v1_5.domain.RelocateParams;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status;
|
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.RuntimeInfoSection;
|
import org.jclouds.vcloud.director.v1_5.domain.RuntimeInfoSection;
|
||||||
|
@ -805,7 +804,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
.notPowerOn()
|
.notPowerOn()
|
||||||
.description("Test VApp")
|
.description("Test VApp")
|
||||||
.instantiationParams(instantiationParams())
|
.instantiationParams(instantiationParams())
|
||||||
.source(ReferenceType.builder().href(vAppTemplateURI).build())
|
.source(Reference.builder().href(vAppTemplateURI).build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// debug(instantiate);
|
// debug(instantiate);
|
||||||
|
|
|
@ -36,7 +36,6 @@ 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.Org;
|
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
import org.jclouds.vcloud.director.v1_5.predicates.ReferenceTypePredicates;
|
import org.jclouds.vcloud.director.v1_5.predicates.ReferenceTypePredicates;
|
||||||
|
@ -155,7 +154,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
context.close();
|
context.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public URI toAdminUri(ReferenceType ref) {
|
public URI toAdminUri(Reference ref) {
|
||||||
return toAdminUri(ref.getHref());
|
return toAdminUri(ref.getHref());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
* 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.predicates;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "ReferencePredicatesTest")
|
||||||
|
public class ReferencePredicatesTest {
|
||||||
|
Reference ref = Reference.builder().type("application/vnd.vmware.vcloud.catalogItem+xml").name("image").href(
|
||||||
|
URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/67a469a1-aafe-4b5b-bb31-a6202ad8961f")).build();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNameEqualsWhenEqual() {
|
||||||
|
assert ReferencePredicates.<Reference> nameEquals("image").apply(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNameEqualsWhenNotEqual() {
|
||||||
|
assert !ReferencePredicates.<Reference> nameEquals("foo").apply(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTypeEqualsWhenEqual() {
|
||||||
|
assert ReferencePredicates.<Reference> typeEquals(VCloudDirectorMediaType.CATALOG_ITEM).apply(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTypeEqualsWhenNotEqual() {
|
||||||
|
assert !ReferencePredicates.<Reference> typeEquals("foo").apply(ref);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue