mirror of https://github.com/apache/jclouds.git
Issue 830: Updated ProductSection domain objects and associated tests
This commit is contained in:
parent
22a718c07e
commit
45fd7c443e
|
@ -62,6 +62,7 @@ public class ProductSectionList extends ResourceType implements Set<ProductSecti
|
|||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromProductSectionList(this);
|
||||
}
|
||||
|
@ -85,7 +86,7 @@ public class ProductSectionList extends ResourceType implements Set<ProductSecti
|
|||
/**
|
||||
* @see ProductSectionList#getProductSections()
|
||||
*/
|
||||
public B productSections(ProductSection productSection) {
|
||||
public B productSection(ProductSection productSection) {
|
||||
if (productSections == null)
|
||||
productSections = Sets.newLinkedHashSet();
|
||||
this.productSections.add(checkNotNull(productSection, "productSection"));
|
||||
|
@ -99,7 +100,7 @@ public class ProductSectionList extends ResourceType implements Set<ProductSecti
|
|||
|
||||
public B fromProductSectionList(ProductSectionList in) {
|
||||
return fromResourceType(in)
|
||||
.productSections(ImmutableSet.copyOf(in));
|
||||
.productSections(Sets.newLinkedHashSet(in));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +121,7 @@ public class ProductSectionList extends ResourceType implements Set<ProductSecti
|
|||
* Gets the value of the productSection property.
|
||||
*/
|
||||
public Set<ProductSection> getProductSections() {
|
||||
return productSections == null ? ImmutableSet.<ProductSection>of() : Collections.unmodifiableSet(productSections);
|
||||
return productSections != null ? ImmutableSet.copyOf(productSections) : Collections.<ProductSection>emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,50 +18,65 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.domain.cim;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAnyAttribute;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* Java class for cimString complex type.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="cimString" />
|
||||
* </pre>
|
||||
*/
|
||||
@XmlType(name = "cimString", namespace = "http://schemas.dmtf.org/wbem/wscim/1/common")
|
||||
@XmlType(name = "cimString")
|
||||
public class CimString {
|
||||
|
||||
@XmlValue
|
||||
protected String value;
|
||||
@XmlAnyAttribute
|
||||
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
|
||||
public CimString() {
|
||||
// JAXB
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the value property.
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
public CimString(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the value property.
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
@XmlValue
|
||||
protected String value;
|
||||
|
||||
/**
|
||||
* Gets a map that contains attributes that aren't bound to any typed property on this class.
|
||||
*/
|
||||
public Map<QName, String> getOtherAttributes() {
|
||||
return otherAttributes;
|
||||
}
|
||||
/**
|
||||
* Gets the value of the value property.
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CimString that = CimString.class.cast(obj);
|
||||
return equal(this.value, that.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper("").add("value", value).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* 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.ovf;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* Type for localizable string.
|
||||
*
|
||||
* Default string value
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="Msg_Type" />
|
||||
* </pre>
|
||||
*
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@XmlType(name = "Msg_Type")
|
||||
public class MsgType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromMsgType(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static abstract class Builder<B extends Builder<B>> {
|
||||
|
||||
protected String value;
|
||||
protected String msgid;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected B self() {
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see MsgType#getValue()
|
||||
*/
|
||||
public B value(String value) {
|
||||
this.value = value;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see MsgType#getMsgid()
|
||||
*/
|
||||
public B msgid(String msgid) {
|
||||
this.msgid = msgid;
|
||||
return self();
|
||||
}
|
||||
|
||||
public MsgType build() {
|
||||
return new MsgType(this);
|
||||
}
|
||||
|
||||
public B fromMsgType(MsgType in) {
|
||||
return value(in.getValue()).msgid(in.getMsgid());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlValue
|
||||
protected String value;
|
||||
@XmlAttribute
|
||||
protected String msgid;
|
||||
|
||||
private MsgType() {
|
||||
// JAXB
|
||||
}
|
||||
|
||||
private MsgType(Builder<?> builder) {
|
||||
this.value = builder.value;
|
||||
this.msgid = builder.msgid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the value property.
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the msgid property.
|
||||
*/
|
||||
public String getMsgid() {
|
||||
if (msgid == null) {
|
||||
return "";
|
||||
} else {
|
||||
return msgid;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(value, msgid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
MsgType that = MsgType.class.cast(obj);
|
||||
return equal(this.value, that.value) &&
|
||||
equal(this.msgid, that.msgid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("value", value).add("msgid", msgid).toString();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,12 +18,18 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.domain.ovf;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.cim.CimString;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -32,13 +38,13 @@ import com.google.common.collect.Sets;
|
|||
/**
|
||||
* The ProductSection element specifies product-information for an appliance, such as product name,
|
||||
* version, and vendor.
|
||||
*
|
||||
* TODO this should contain a multitude of other elements!
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @author Adam Lowe
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@XmlRootElement(name = "ProductSection", namespace = VCLOUD_OVF_NS)
|
||||
@XmlRootElement(name = "ProductSection")
|
||||
@XmlType(name = "ProductSection_Type")
|
||||
public class ProductSection extends SectionType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -53,12 +59,84 @@ public class ProductSection extends SectionType {
|
|||
}
|
||||
|
||||
public static class Builder<B extends Builder<B>> extends SectionType.Builder<B> {
|
||||
protected Set<org.jclouds.vcloud.director.v1_5.domain.ovf.Property> properties = Sets.newLinkedHashSet();
|
||||
|
||||
private MsgType product;
|
||||
private MsgType vendor;
|
||||
private CimString version;
|
||||
private CimString fullVersion;
|
||||
private CimString productUrl;
|
||||
private CimString vendorUrl;
|
||||
private CimString appUrl;
|
||||
protected Set<ProductSectionProperty> properties = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see ProductSection#getProperties
|
||||
* @see ProductSection#getProduct()
|
||||
*/
|
||||
public B property(org.jclouds.vcloud.director.v1_5.domain.ovf.Property property) {
|
||||
public B product(MsgType product) {
|
||||
this.product = product;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ProductSection#getVendor()
|
||||
*/
|
||||
public B vendor(MsgType vendor) {
|
||||
this.vendor = vendor;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ProductSection#getVersion()
|
||||
*/
|
||||
public B version(CimString version) {
|
||||
this.version = version;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ProductSection#geFullVersion()
|
||||
*/
|
||||
public B fullVersion(CimString fullVersion) {
|
||||
this.fullVersion = fullVersion;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ProductSection#getProductUrl()
|
||||
*/
|
||||
public B productUrl(CimString productUrl) {
|
||||
this.productUrl = productUrl;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ProductSection#getProductUrl()
|
||||
*/
|
||||
public B productUrl(String productUrl) {
|
||||
this.productUrl = new CimString(productUrl);
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ProductSection#getVendorUrl()
|
||||
*/
|
||||
public B vendorUrl(CimString vendorUrl) {
|
||||
this.vendorUrl = vendorUrl;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ProductSection#getAppUrl()
|
||||
*/
|
||||
public B appUrl(CimString appUrl) {
|
||||
this.appUrl = appUrl;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ProductSection#getProperties()
|
||||
*/
|
||||
public B property(ProductSectionProperty property) {
|
||||
this.properties.add(checkNotNull(property, "property"));
|
||||
return self();
|
||||
}
|
||||
|
@ -66,11 +144,11 @@ public class ProductSection extends SectionType {
|
|||
/**
|
||||
* @see ProductSection#getProperties
|
||||
*/
|
||||
public B properties(Iterable<org.jclouds.vcloud.director.v1_5.domain.ovf.Property> properties) {
|
||||
this.properties = ImmutableSet.<org.jclouds.vcloud.director.v1_5.domain.ovf.Property> copyOf(checkNotNull(properties, "properties"));
|
||||
public B properties(Iterable<ProductSectionProperty> properties) {
|
||||
this.properties = ImmutableSet.copyOf(checkNotNull(properties, "properties"));
|
||||
return self();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -80,25 +158,112 @@ public class ProductSection extends SectionType {
|
|||
}
|
||||
|
||||
public B fromProductSection(ProductSection in) {
|
||||
return info(in.getInfo()).properties(in.getProperties());
|
||||
return fromSectionType(in)
|
||||
.product(in.getProduct())
|
||||
.vendor(in.getVendor())
|
||||
.version(in.getVersion())
|
||||
.fullVersion(in.getFullVersion())
|
||||
.productUrl(in.getProductUrl())
|
||||
.vendorUrl(in.getVendorUrl())
|
||||
.appUrl(in.getAppUrl())
|
||||
.properties(Sets.newLinkedHashSet(in.getProperties()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Set<org.jclouds.vcloud.director.v1_5.domain.ovf.Property> properties;
|
||||
|
||||
private ProductSection(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.properties = ImmutableSet.copyOf(checkNotNull(builder.properties, "properties"));
|
||||
this.product = builder.product;
|
||||
this.vendor = builder.vendor;
|
||||
this.version = builder.version;
|
||||
this.fullVersion = builder.fullVersion;
|
||||
this.productUrl = builder.productUrl;
|
||||
this.vendorUrl = builder.vendorUrl;
|
||||
this.appUrl = builder.appUrl;
|
||||
this.properties = builder.properties != null ? ImmutableSet.copyOf(checkNotNull(builder.properties, "properties")) : Collections.<ProductSectionProperty>emptySet();
|
||||
}
|
||||
|
||||
private ProductSection() {
|
||||
// For JAXB
|
||||
}
|
||||
|
||||
@XmlElement(name = "Product")
|
||||
private MsgType product;
|
||||
@XmlElement(name = "Vendor")
|
||||
private MsgType vendor;
|
||||
@XmlElement(name = "Version", namespace = VCLOUD_CIM_NS)
|
||||
private CimString version;
|
||||
@XmlElement(name = "FullVersion", namespace = VCLOUD_CIM_NS)
|
||||
private CimString fullVersion;
|
||||
@XmlElement(name = "ProductUrl", namespace = VCLOUD_CIM_NS)
|
||||
private CimString productUrl;
|
||||
@XmlElement(name = "VendorUrl", namespace = VCLOUD_CIM_NS)
|
||||
private CimString vendorUrl;
|
||||
@XmlElement(name = "AppUrl", namespace = VCLOUD_CIM_NS)
|
||||
private CimString appUrl;
|
||||
@XmlElement(name = "Property")
|
||||
private Set<ProductSectionProperty> properties = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* Name of product.
|
||||
*/
|
||||
public MsgType getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of product vendor.
|
||||
*/
|
||||
public MsgType getVendor() {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Product version, short form.
|
||||
*/
|
||||
public CimString getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Product version, long form.
|
||||
*/
|
||||
public CimString getFullVersion() {
|
||||
return fullVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL resolving to product description.
|
||||
*/
|
||||
public CimString getProductUrl() {
|
||||
return productUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL resolving to vendor description.
|
||||
*/
|
||||
public CimString getVendorUrl() {
|
||||
return vendorUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Experimental: URL resolving to deployed product instance.
|
||||
*/
|
||||
public CimString getAppUrl() {
|
||||
return appUrl;
|
||||
}
|
||||
|
||||
// TODO Set<Icon>
|
||||
|
||||
/**
|
||||
* Properties for application-level customization.
|
||||
*/
|
||||
public Set<ProductSectionProperty> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), properties);
|
||||
return Objects.hashCode(super.hashCode(), product, vendor, version, fullVersion, productUrl, vendorUrl, appUrl, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -107,17 +272,29 @@ public class ProductSection extends SectionType {
|
|||
if (!super.equals(obj)) return false;
|
||||
if (getClass() != obj.getClass()) return false;
|
||||
|
||||
ProductSection other = (ProductSection) obj;
|
||||
return super.equals(other) && Objects.equal(properties, other.properties);
|
||||
ProductSection that = ProductSection.class.cast(obj);
|
||||
return super.equals(that) &&
|
||||
equal(this.product, that.product) &&
|
||||
equal(this.vendor, that.vendor) &&
|
||||
equal(this.version, that.version) &&
|
||||
equal(this.fullVersion, that.fullVersion) &&
|
||||
equal(this.productUrl, that.productUrl) &&
|
||||
equal(this.vendorUrl, that.vendorUrl) &&
|
||||
equal(this.appUrl, that.appUrl) &&
|
||||
equal(this.properties, that.properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Objects.ToStringHelper string() {
|
||||
return super.string().add("properties", properties);
|
||||
}
|
||||
|
||||
public Set<org.jclouds.vcloud.director.v1_5.domain.ovf.Property> getProperties() {
|
||||
return properties;
|
||||
return super.string()
|
||||
.add("product", product)
|
||||
.add("vendor", vendor)
|
||||
.add("version", version)
|
||||
.add("fullVersion", fullVersion)
|
||||
.add("productUrl", productUrl)
|
||||
.add("vendorUrl", vendorUrl)
|
||||
.add("appUrl", appUrl)
|
||||
.add("properties", properties);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* 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.ovf;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* Property element
|
||||
*
|
||||
* <pre>
|
||||
* <element name="Property" />
|
||||
* </pre>
|
||||
*
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@XmlType(name = "")
|
||||
@XmlRootElement(name = "Property")
|
||||
public class ProductSectionProperty extends Property {
|
||||
// TODO hashCode, equals, toString
|
||||
}
|
|
@ -18,89 +18,265 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.domain.ovf;
|
||||
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
* @author Adam Lowe
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@XmlType(name = "Property", namespace = VCLOUD_OVF_NS)
|
||||
@XmlType(name = "Property")
|
||||
@XmlSeeAlso({ ProductSectionProperty.class })
|
||||
public class Property {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromProperty(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static abstract class Builder<B extends Builder<B>> {
|
||||
|
||||
protected String key;
|
||||
protected String value;
|
||||
protected String label;
|
||||
protected String description;
|
||||
protected Set<PropertyConfigurationValueType> values = Sets.newLinkedHashSet();
|
||||
protected MsgType label;
|
||||
protected MsgType description;
|
||||
protected String type;
|
||||
protected String qualifiers;
|
||||
protected Boolean userConfigurable;
|
||||
protected String defaultValue = "";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected B self() {
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#getKey
|
||||
* @see Property#getKey()
|
||||
*/
|
||||
public Builder key(String key) {
|
||||
public B key(String key) {
|
||||
this.key = key;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#getValue
|
||||
* @see Property#getValues()
|
||||
*/
|
||||
public Builder value(String value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
public B values(Set<PropertyConfigurationValueType> values) {
|
||||
this.values = checkNotNull(values, "values");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#getLabel
|
||||
* @see Property#getValues()
|
||||
*/
|
||||
public Builder label(String label) {
|
||||
public B value(PropertyConfigurationValueType value) {
|
||||
this.values.add(checkNotNull(value, "value"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#getLabel()
|
||||
*/
|
||||
public B label(MsgType label) {
|
||||
this.label = label;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#getDescription
|
||||
* @see Property#getDescription()
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
public B description(MsgType description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#getType()
|
||||
*/
|
||||
public B type(String type) {
|
||||
this.type = type;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#getQualifiers()
|
||||
*/
|
||||
public B qualifiers(String qualifiers) {
|
||||
this.qualifiers = qualifiers;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#getQualifiers()
|
||||
*/
|
||||
public B qualifiers(Iterable<String> qualifiers) {
|
||||
this.qualifiers = Joiner.on(',').join(qualifiers);
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#getQualifiers()
|
||||
*/
|
||||
public B qualifiers(String...qualifiers) {
|
||||
this.qualifiers = Joiner.on(',').join(qualifiers);
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#isUserConfigurable()
|
||||
*/
|
||||
public B isUserConfigurable(Boolean userConfigurable) {
|
||||
this.userConfigurable = userConfigurable;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#isUserConfigurable()
|
||||
*/
|
||||
public B userConfigurable() {
|
||||
this.userConfigurable = Boolean.TRUE;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#isUserConfigurable()
|
||||
*/
|
||||
public B notUserConfigurable() {
|
||||
this.userConfigurable = Boolean.FALSE;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Property#getDefaultValue()
|
||||
*/
|
||||
public B defaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Property build() {
|
||||
return new Property(key, value, label, description);
|
||||
return new Property(this);
|
||||
}
|
||||
|
||||
public Builder fromProperty(Property in) {
|
||||
return key(in.getKey()).value(in.getValue()).description(in.getDescription()).label(in.getLabel());
|
||||
public B fromProperty(Property in) {
|
||||
return key(in.getKey()).values(in.getValues()).description(in.getDescription()).label(in.getLabel())
|
||||
.type(in.getType()).qualifiers(in.getQualifiers()).isUserConfigurable(in.isUserConfigurable()).defaultValue(in.getDefaultValue());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
private String key;
|
||||
private String value;
|
||||
private String label;
|
||||
private String description;
|
||||
@XmlElement(name = "Value")
|
||||
private Set<PropertyConfigurationValueType> values;
|
||||
@XmlElement(name = "Label")
|
||||
private MsgType label;
|
||||
@XmlElement(name = "Description")
|
||||
private MsgType description;
|
||||
@XmlAttribute(required = true)
|
||||
private String type;
|
||||
@XmlAttribute(required = true)
|
||||
private String qualifiers;
|
||||
@XmlAttribute
|
||||
private Boolean userConfigurable;
|
||||
@XmlAttribute(name = "value")
|
||||
private String defaultValue;
|
||||
|
||||
private Property(String key, String value, String label, String description) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
this.description = description;
|
||||
protected Property(Builder<?> builder) {
|
||||
this.key = builder.key;
|
||||
this.values = builder.values;
|
||||
this.label = builder.label;
|
||||
this.description = builder.description;
|
||||
this.type = builder.type;
|
||||
this.qualifiers = builder.qualifiers;
|
||||
this.userConfigurable = builder.userConfigurable;
|
||||
this.defaultValue = builder.defaultValue;
|
||||
}
|
||||
|
||||
private Property() {
|
||||
|
||||
protected Property() {
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
/**
|
||||
* Property identifier.
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description of property.
|
||||
*/
|
||||
public MsgType getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description of property.
|
||||
*/
|
||||
public MsgType getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alternative default property values for different configuration
|
||||
*/
|
||||
public Set<PropertyConfigurationValueType> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Property type.
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* A comma-separated set of type qualifiers.
|
||||
*/
|
||||
public String getQualifiers() {
|
||||
return qualifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the property value is configurable during installation.
|
||||
*/
|
||||
public Boolean isUserConfigurable() {
|
||||
return userConfigurable;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Default value for property.
|
||||
*/
|
||||
public String getDefaultValue() {
|
||||
if (defaultValue == null) {
|
||||
return "";
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((key == null) ? 0 : key.hashCode());
|
||||
return result;
|
||||
return Objects.hashCode(key, values, label, description, type, qualifiers, userConfigurable, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,33 +287,22 @@ public class Property {
|
|||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Property other = (Property) obj;
|
||||
if (key == null) {
|
||||
if (other.key != null)
|
||||
return false;
|
||||
} else if (!key.equals(other.key))
|
||||
return false;
|
||||
return true;
|
||||
Property that = Property.class.cast(obj);
|
||||
return equal(this.key, that.key) &&
|
||||
equal(this.values, that.values) &&
|
||||
equal(this.label, that.label) &&
|
||||
equal(this.description, that.description) &&
|
||||
equal(this.type, that.type) &&
|
||||
equal(this.qualifiers, that.qualifiers) &&
|
||||
equal(this.userConfigurable, that.userConfigurable) &&
|
||||
equal(this.defaultValue, that.defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[key=%s, value=%s, label=%s, description=%s]", key, value, label, description);
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
return Objects.toStringHelper("")
|
||||
.add("key", key).add("values", values).add("label", label).add("description", description)
|
||||
.add("type", type).add("qualifiers", qualifiers).add("userConfigurable", userConfigurable).add("defaultValue", defaultValue)
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* 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.ovf;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
/**
|
||||
* Type for alternative default values for properties when DeploymentOptionSection is used
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="PropertyConfigurationValue_Type">
|
||||
* </pre>
|
||||
*
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@XmlType(name = "PropertyConfigurationValue_Type")
|
||||
public class PropertyConfigurationValueType {
|
||||
|
||||
// TODO Builder
|
||||
|
||||
@XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1", required = true)
|
||||
protected String value;
|
||||
@XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1")
|
||||
protected String configuration;
|
||||
|
||||
/**
|
||||
* Gets the value of the value property.
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the configuration property.
|
||||
*/
|
||||
public String getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
// TODO hashCode, equals, toString
|
||||
}
|
|
@ -229,10 +229,8 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
|
|||
return result;
|
||||
}
|
||||
|
||||
protected static CimString cimString(String val) {
|
||||
CimString result = new CimString();
|
||||
result.setValue(val);
|
||||
return result;
|
||||
protected static CimString cimString(String value) {
|
||||
return new CimString(value);
|
||||
}
|
||||
|
||||
protected void checkHasMatchingItem(final String context, final RasdItemsList items, final String instanceId, final String elementName) {
|
||||
|
|
|
@ -20,9 +20,9 @@ package org.jclouds.vcloud.director.v1_5.features;
|
|||
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.CONDITION_FMT;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_EQUAL;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MATCHES_STRING_FMT;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ADMIN_USER;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.MEDIA;
|
||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkControlAccessParams;
|
||||
|
@ -81,8 +81,10 @@ import org.jclouds.vcloud.director.v1_5.domain.Task;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.MsgType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.ProductSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.RASD;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
|
||||
|
@ -430,6 +432,9 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
|
|||
// Check the modified section fields are set correctly
|
||||
assertEquals(modified.getComputerName(), newSection.getComputerName());
|
||||
|
||||
// Reset the admin password in the retrieved GuestCustomizationSection for equality check
|
||||
modified = modified.toBuilder().adminPassword(null).build();
|
||||
|
||||
// Check the section was modified correctly
|
||||
assertEquals(modified, newSection, String.format(ENTITY_EQUAL, "GuestCustomizationSection"));
|
||||
}
|
||||
|
@ -622,7 +627,6 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
|
|||
.info("Changed OperatingSystemSection Description")
|
||||
.description("Changed OperatingSystemSection Description")
|
||||
.build();
|
||||
debug(newSection);
|
||||
assertNotNull(newSection.getId());
|
||||
|
||||
// The method under test
|
||||
|
@ -680,17 +684,33 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
|
|||
|
||||
@Test(testName = "PUT /vApp/{id}/productSections", dependsOnMethods = { "testGetProductSections" })
|
||||
public void testModifyProductSections() {
|
||||
ProductSectionList origSections = vAppClient.getProductSections(vApp.getHref());
|
||||
ProductSectionList newSections = origSections.toBuilder().build();
|
||||
|
||||
// Copy existing section and update fields
|
||||
ProductSectionList oldSections = vAppClient.getProductSections(vApp.getHref());
|
||||
ProductSectionList newSections = oldSections.toBuilder()
|
||||
.productSection(ProductSection.builder()
|
||||
.info("Information about the installed software") // Default ovf:Info text
|
||||
.required(true)
|
||||
.product(MsgType.builder().value("jclouds").build())
|
||||
.vendor(MsgType.builder().value("jclouds Inc.").build())
|
||||
// NOTE other ProductSection elements not returned by vCloud
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// The method under test
|
||||
Task modifyProductSections = vAppClient.modifyProductSections(vApp.getHref(), newSections);
|
||||
assertTrue(retryTaskSuccess.apply(modifyProductSections), String.format(TASK_COMPLETE_TIMELY, "modifyProductSections"));
|
||||
|
||||
ProductSectionList modifiedList = vAppClient.getProductSections(vApp.getHref());
|
||||
Checks.checkProductSectionList(modifiedList);
|
||||
|
||||
// TODO What to modify, to confirm that changes took effect?
|
||||
// Retrieve the modified section
|
||||
ProductSectionList modified = vAppClient.getProductSections(vApp.getHref());
|
||||
|
||||
// Check the retrieved object is well formed
|
||||
checkProductSectionList(modified);
|
||||
|
||||
// Check the modified section fields are set correctly
|
||||
assertEquals(modified.getProductSections().size(), oldSections.getProductSections().size() + 1);
|
||||
|
||||
// Check the section was modified correctly
|
||||
assertEquals(modified, newSections, String.format(ENTITY_EQUAL, "ProductSectionList"));
|
||||
}
|
||||
|
||||
@Test(testName = "GET /vApp/{id}/question", dependsOnMethods = { "testGetVApp" })
|
||||
|
|
Loading…
Reference in New Issue