Issue 830: Use XmlElementWrapper annotation where possible

This commit is contained in:
Andrew Donald Kennedy 2012-03-27 12:28:13 +01:00
parent d4713572e4
commit 9e860a2328
18 changed files with 248 additions and 1309 deletions

View File

@ -1,122 +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.*;
import static com.google.common.base.Preconditions.*;
import java.util.List;
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 javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
/**
* A list of access settings for a resource.
*
* <pre>
* &lt;complexType name="AccessSettings" /&gt;
* </pre>
*
* @since 0.9
*/
@XmlRootElement(name = "AccessSettings")
@XmlType(name = "AccessSettingsType")
public class AccessSettings {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromAccessSettings(this);
}
public static class Builder {
private List<AccessSetting> accessSettings = Lists.newArrayList();
/**
* @see AccessSettings#getAccessSettings()
*/
public Builder accessSettings(List<AccessSetting> accessSettings) {
this.accessSettings = checkNotNull(accessSettings, "accessSettings");
return this;
}
/**
* @see AccessSettings#getAccessSettings()
*/
public Builder accessSetting(AccessSetting accessSetting) {
this.accessSettings.add(checkNotNull(accessSetting, "accessSetting"));
return this;
}
public AccessSettings build() {
return new AccessSettings(accessSettings);
}
public Builder fromAccessSettings(AccessSettings in) {
return accessSettings(in.getAccessSettings());
}
}
protected AccessSettings() {
// For JAXB and builder use
}
public AccessSettings(List<AccessSetting> accessSettings) {
this.accessSettings = accessSettings;
}
@XmlElement(name = "AccessSetting", required = true)
protected List<AccessSetting> accessSettings = Lists.newArrayList();
/**
* Gets the value of the accessSetting property.
*/
public List<AccessSetting> getAccessSettings() {
return accessSettings;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
AccessSettings that = AccessSettings.class.cast(o);
return equal(this.accessSettings, that.accessSettings);
}
@Override
public int hashCode() {
return Objects.hashCode(accessSettings);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("accessSettings", accessSettings).toString();
}
}

View File

@ -45,6 +45,7 @@ public class AdminCatalog extends CatalogType {
return new ConcreteBuilder(); return new ConcreteBuilder();
} }
@Override
public Builder<?> toBuilder() { public Builder<?> toBuilder() {
return builder().fromAdminCatalog(this); return builder().fromAdminCatalog(this);
} }
@ -54,6 +55,7 @@ public class AdminCatalog extends CatalogType {
public static abstract class Builder<B extends Builder<B>> extends CatalogType.Builder<B> { public static abstract class Builder<B extends Builder<B>> extends CatalogType.Builder<B> {
@Override
public AdminCatalog build() { public AdminCatalog build() {
return new AdminCatalog(this); return new AdminCatalog(this);
} }

View File

@ -19,15 +19,19 @@
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;
import static com.google.common.base.Preconditions.checkNotNull;
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.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
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;
/** /**
* The AdminOrg represents an administrative view of an organization. * The AdminOrg represents an administrative view of an organization.
@ -67,6 +71,7 @@ public class AdminOrg extends Org {
return new ConcreteBuilder(); return new ConcreteBuilder();
} }
@Override
public Builder<?> toBuilder() { public Builder<?> toBuilder() {
return builder().fromAdminOrg(this); return builder().fromAdminOrg(this);
} }
@ -77,11 +82,11 @@ public class AdminOrg extends Org {
public static abstract class Builder<B extends Builder<B>> extends Org.Builder<B> { public static abstract class Builder<B extends Builder<B>> extends Org.Builder<B> {
private OrgSettings settings; private OrgSettings settings;
private UsersList users; private Set<Reference> users = Sets.newLinkedHashSet();
private GroupsList groups; private Set<Reference> groups = Sets.newLinkedHashSet();
private CatalogsList catalogs; private Set<Reference> catalogs = Sets.newLinkedHashSet();
private Vdcs vdcs; private Set<Reference> vdcs = Sets.newLinkedHashSet();
private Networks networks; private Set<Reference> networks = Sets.newLinkedHashSet();
/** /**
* @see AdminOrg#getSettings() * @see AdminOrg#getSettings()
@ -94,43 +99,82 @@ public class AdminOrg extends Org {
/** /**
* @see AdminOrg#getUsers() * @see AdminOrg#getUsers()
*/ */
public B users(UsersList users) { public B users(Iterable<Reference> users) {
this.users = users; this.users = Sets.newLinkedHashSet(checkNotNull(users, "users"));
return self();
}
/**
* @see AdminOrg#getUsers()
*/
public B user(Reference user) {
users.add(checkNotNull(user, "user"));
return self(); return self();
} }
/** /**
* @see AdminOrg#getGroups() * @see AdminOrg#getGroups()
*/ */
public B groups(GroupsList groups) { public B groups(Iterable<Reference> groups) {
this.groups = groups; this.groups = Sets.newLinkedHashSet(checkNotNull(groups, "groups"));
return self();
}
/**
* @see AdminOrg#getGroups()
*/
public B group(Reference group) {
groups.add(checkNotNull(group, "group"));
return self();
}
/**
* @see AdminOrg#getCatalogs()
*/
public B catalogs(Iterable<Reference> catalogReferences) {
this.catalogs = Sets.newLinkedHashSet(checkNotNull(catalogs, "catalogs"));
return self(); return self();
} }
/** /**
* @see AdminOrg#getCatalogs() * @see AdminOrg#getCatalogs()
*/ */
public B catalogs(CatalogsList catalogs) { public B catalog(Reference catalog) {
this.catalogs = catalogs; this.catalogs.add(checkNotNull(catalog, "catalog"));
return self();
}
/**
* @see AdminOrg#getVdcs()
*/
public B vdcs(Iterable<Reference> vdcs) {
this.vdcs = Sets.newLinkedHashSet(checkNotNull(vdcs, "vdcs"));
return self(); return self();
} }
/** /**
* @see AdminOrg#getVdcs() * @see AdminOrg#getVdcs()
*/ */
public B vdcs(Vdcs vdcs) { public B vdc(Reference vdc) {
this.vdcs = vdcs; this.vdcs.add(checkNotNull(vdc, "vdc"));
return self(); return self();
} }
/** /**
* @see AdminOrg#getNetworks() * @see AdminOrg#getNetworks()
*/ */
public B networks(Networks networks) { public B networks(Iterable<Reference> networks) {
this.networks = networks; this.networks = Sets.newLinkedHashSet(checkNotNull(networks, "networks"));
return self(); return self();
} }
/**
* @see AdminOrg#getNetworks()
*/
public B network(Reference network) {
this.networks.add(checkNotNull(network, "network"));
return self();
}
@Override
public AdminOrg build() { public AdminOrg build() {
return new AdminOrg(this); return new AdminOrg(this);
} }
@ -153,33 +197,33 @@ public class AdminOrg extends Org {
protected AdminOrg(Builder<?> builder) { protected AdminOrg(Builder<?> builder) {
super(builder); super(builder);
this.settings = builder.settings; this.settings = builder.settings;
this.users = builder.users; this.users = builder.users == null ? Sets.<Reference>newLinkedHashSet() : ImmutableSet.copyOf(builder.users);
this.groups = builder.groups; this.groups = builder.groups == null ? Sets.<Reference>newLinkedHashSet() : ImmutableSet.copyOf(builder.groups);
this.catalogs = builder.catalogs; this.catalogs = builder.catalogs == null ? Sets.<Reference>newLinkedHashSet() : ImmutableSet.copyOf(builder.catalogs);
this.vdcs = builder.vdcs; this.vdcs = builder.vdcs == null ? Sets.<Reference>newLinkedHashSet() : ImmutableSet.copyOf(builder.vdcs);
this.networks = builder.networks; this.networks = builder.networks == null ? Sets.<Reference>newLinkedHashSet() : ImmutableSet.copyOf(builder.networks);
} }
@XmlElement(name = "Settings", required = true) @XmlElement(name = "Settings", required = true)
private OrgSettings settings; private OrgSettings settings;
@XmlElement(name = "Users") @XmlElementWrapper(name = "Users")
private UsersList users; @XmlElement(name = "UserReference")
@XmlElement(name = "Groups") protected Set<Reference> users = Sets.newLinkedHashSet();
private GroupsList groups; @XmlElementWrapper(name = "Groups")
@XmlElement(name = "Catalogs") @XmlElement(name = "GroupReference")
private CatalogsList catalogs; protected Set<Reference> groups = Sets.newLinkedHashSet();
@XmlElement(name = "Vdcs") @XmlElementWrapper(name = "Catalogs")
private Vdcs vdcs; @XmlElement(name = "CatalogReference")
@XmlElement(name = "Networks") private Set<Reference> catalogs = Sets.newLinkedHashSet();
private Networks networks; @XmlElementWrapper(name = "Vdcs")
@XmlElement(name = "Vdc")
protected Set<Reference> vdcs = Sets.newLinkedHashSet();
@XmlElementWrapper(name = "Networks")
@XmlElement(name = "Network")
protected Set<Reference> networks = Sets.newLinkedHashSet();
/** /**
* Gets the value of the settings property. * Gets the value of the settings property.
*
* @return
* possible object is
* {@link OrgSettings }
*
*/ */
public OrgSettings getSettings() { public OrgSettings getSettings() {
return settings; return settings;
@ -187,61 +231,36 @@ public class AdminOrg extends Org {
/** /**
* Gets the value of the users property. * Gets the value of the users property.
*
* @return
* possible object is
* {@link UsersList }
*
*/ */
public UsersList getUsers() { public Set<Reference> getUsers() {
return users; return users;
} }
/** /**
* Gets the value of the groups property. * Gets the value of the groups property.
*
* @return
* possible object is
* {@link GroupsList }
*
*/ */
public GroupsList getGroups() { public Set<Reference> getGroups() {
return groups; return groups;
} }
/** /**
* Gets the value of the catalogs property. * Gets the value of the catalogs property.
*
* @return
* possible object is
* {@link CatalogsList }
*
*/ */
public CatalogsList getCatalogs() { public Set<Reference> getCatalogs() {
return catalogs; return catalogs;
} }
/** /**
* Gets the value of the vdcs property. * Gets the value of the vdcs property.
*
* @return
* possible object is
* {@link Vdcs }
*
*/ */
public Vdcs getVdcs() { public Set<Reference> getVdcs() {
return vdcs; return vdcs;
} }
/** /**
* Gets the value of the networks property. * Gets the value of the networks property.
*
* @return
* possible object is
* {@link Networks }
*
*/ */
public Networks getNetworks() { public Set<Reference> getNetworks() {
return networks; return networks;
} }

View File

@ -1,130 +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 static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
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 list of catalog item references.
* <p/>
* <pre>
* &lt;complexType name="CatalogItemsType" /&gt;
* </pre>
*
* @author grkvlt@apache.org
*/
@XmlRootElement(name = "CatalogItems")
public class CatalogItems {
public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG_ITEMS;
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder();
}
public static class Builder {
private Set<Reference> catalogItems = Sets.newLinkedHashSet();
/**
* @see CatalogItems#getCatalogItems()
*/
public Builder items(Collection<Reference> catalogItems) {
this.catalogItems = Sets.newLinkedHashSet(checkNotNull(catalogItems, "catalogItems"));
return this;
}
/**
* @see CatalogItems#getCatalogItems()
*/
public Builder item(Reference catalogItem) {
this.catalogItems.add(checkNotNull(catalogItem, "catalogItem"));
return this;
}
public CatalogItems build() {
return new CatalogItems(catalogItems);
}
public Builder fromCatalogItems(CatalogItems in) {
return items(in.getCatalogItems());
}
}
private CatalogItems() {
// For JAXB
}
private CatalogItems(Set<Reference> catalogItems) {
this.catalogItems = ImmutableSet.copyOf(catalogItems);
}
@XmlElement(name = "CatalogItem")
private Set<Reference> catalogItems = Sets.newLinkedHashSet();
/**
* Gets the value of the catalogItems property.
*/
public Set<Reference> getCatalogItems() {
return Collections.unmodifiableSet(this.catalogItems);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
CatalogItems that = CatalogItems.class.cast(o);
return equal(this.catalogItems, that.catalogItems);
}
@Override
public int hashCode() {
return Objects.hashCode(catalogItems);
}
@Override
public String toString() {
return string().toString();
}
protected ToStringHelper string() {
return Objects.toStringHelper("").add("catalogItems", catalogItems);
}
}

View File

@ -19,16 +19,22 @@
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;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
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;
/** /**
* Container for references to VappTemplate and Media objects. * Container for references to VappTemplate and Media objects.
* <p/> *
* <pre> * <pre>
* &lt;complexType name="CatalogType" /&gt; * &lt;complexType name="CatalogType" /&gt;
* </pre> * </pre>
@ -42,6 +48,7 @@ public class CatalogType extends EntityType {
return new ConcreteBuilder(); return new ConcreteBuilder();
} }
@Override
public Builder<?> toBuilder() { public Builder<?> toBuilder() {
return builder().fromCatalogType(this); return builder().fromCatalogType(this);
} }
@ -52,7 +59,7 @@ public class CatalogType extends EntityType {
public static class Builder<B extends Builder<B>> extends EntityType.Builder<B> { public static class Builder<B extends Builder<B>> extends EntityType.Builder<B> {
private Owner owner; private Owner owner;
private CatalogItems catalogItems; private Set<Reference> catalogItems = Sets.newLinkedHashSet();
private Boolean isPublished; private Boolean isPublished;
/** /**
@ -64,10 +71,18 @@ public class CatalogType extends EntityType {
} }
/** /**
* @see CatalogType#getCatalogItems() * @see CatalogItems#getCatalogItems()
*/ */
public B catalogItems(CatalogItems catalogItems) { public B items(Iterable<Reference> catalogItems) {
this.catalogItems = catalogItems; this.catalogItems = Sets.newLinkedHashSet(checkNotNull(catalogItems, "catalogItems"));
return self();
}
/**
* @see CatalogItems#getCatalogItems()
*/
public B item(Reference catalogItem) {
this.catalogItems.add(checkNotNull(catalogItem, "catalogItem"));
return self(); return self();
} }
@ -93,14 +108,14 @@ public class CatalogType extends EntityType {
} }
public B fromCatalogType(CatalogType in) { public B fromCatalogType(CatalogType in) {
return fromEntityType(in).owner(in.getOwner()).catalogItems(in.getCatalogItems()).isPublished(in.isPublished()); return fromEntityType(in).owner(in.getOwner()).items(in.getCatalogItems()).isPublished(in.isPublished());
} }
} }
protected CatalogType(Builder<?> builder) { protected CatalogType(Builder<?> builder) {
super(builder); super(builder);
this.owner = builder.owner; this.owner = builder.owner;
this.catalogItems = builder.catalogItems; this.catalogItems = builder.catalogItems == null || builder.catalogItems.isEmpty() ? null : ImmutableSet.copyOf(builder.catalogItems);
this.isPublished = builder.isPublished; this.isPublished = builder.isPublished;
} }
@ -110,8 +125,9 @@ public class CatalogType extends EntityType {
@XmlElement(name = "Owner") @XmlElement(name = "Owner")
private Owner owner; private Owner owner;
@XmlElement(name = "CatalogItems") @XmlElementWrapper(name = "CatalogItems")
private CatalogItems catalogItems; @XmlElement(name = "CatalogItem")
private Set<Reference> catalogItems;
@XmlElement(name = "IsPublished") @XmlElement(name = "IsPublished")
private Boolean isPublished; private Boolean isPublished;
@ -125,8 +141,8 @@ public class CatalogType extends EntityType {
/** /**
* Gets the value of the catalogItems property. * Gets the value of the catalogItems property.
*/ */
public CatalogItems getCatalogItems() { public Set<Reference> getCatalogItems() {
return catalogItems; return catalogItems == null ? ImmutableSet.<Reference>of() : ImmutableSet.copyOf(catalogItems);
} }
/** /**
@ -145,19 +161,19 @@ public class CatalogType extends EntityType {
CatalogType that = CatalogType.class.cast(o); CatalogType that = CatalogType.class.cast(o);
return super.equals(that) && return super.equals(that) &&
equal(this.owner, that.owner) && equal(this.owner, that.owner) &&
equal(this.catalogItems, that.catalogItems) && equal(this.getCatalogItems(), that.getCatalogItems()) &&
equal(this.isPublished, that.isPublished); equal(this.isPublished, that.isPublished);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(super.hashCode(), owner, catalogItems, catalogItems); return Objects.hashCode(super.hashCode(), owner, getCatalogItems(), catalogItems);
} }
@Override @Override
public ToStringHelper string() { public ToStringHelper string() {
return super.string().add("owner", owner) return super.string().add("owner", owner)
.add("catalogItems", catalogItems) .add("catalogItems", getCatalogItems())
.add("isPublished", isPublished); .add("isPublished", isPublished);
} }

View File

@ -1,129 +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 static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
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;
/**
* Container for ReferenceType elements that reference catalogs.
* <p/>
* <pre>
* &lt;complexType name="CatalogsListType" /&gt;
* </pre>
*
* @author grkvlt@apache.org
*/
@XmlRootElement(name = "CatalogsList")
public class CatalogsList {
public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG_ITEMS;
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder();
}
public static class Builder {
private Set<Reference> catalogReferences = Sets.newLinkedHashSet();
/**
* @see CatalogsList#getCatalogItems()
*/
public Builder catalogs(Set<Reference> catalogReferences) {
this.catalogReferences = checkNotNull(catalogReferences, "catalogReferences");
return this;
}
/**
* @see CatalogsList#getCatalogItems()
*/
public Builder catalog(Reference catalog) {
this.catalogReferences.add(checkNotNull(catalog, "catalog"));
return this;
}
public CatalogsList build() {
return new CatalogsList(catalogReferences);
}
public Builder fromCatalogsList(CatalogsList in) {
return catalogs(in.getCatalogItems());
}
}
private CatalogsList() {
// for JAXB
}
private CatalogsList(Set<Reference> catalogReferences) {
this.catalogReferences = ImmutableSet.copyOf(checkNotNull(catalogReferences, "catalogReferences"));
}
@XmlElement(name = "CatalogReference")
private Set<Reference> catalogReferences = Sets.newLinkedHashSet();
/**
* Gets the value of the catalogReferences property.
*/
public Set<Reference> getCatalogItems() {
return Collections.unmodifiableSet(this.catalogReferences);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
CatalogsList that = CatalogsList.class.cast(o);
return equal(this.catalogReferences, that.catalogReferences);
}
@Override
public int hashCode() {
return Objects.hashCode(catalogReferences);
}
@Override
public String toString() {
return string().toString();
}
protected ToStringHelper string() {
return Objects.toStringHelper("").add("catalogReferences", catalogReferences);
}
}

View File

@ -18,15 +18,19 @@
*/ */
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.checkNotNull;
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.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
/** /**
* Used to control access to resources. * Used to control access to resources.
@ -53,7 +57,7 @@ public class ControlAccessParams {
private Boolean sharedToEveryone = Boolean.FALSE; private Boolean sharedToEveryone = Boolean.FALSE;
private String everyoneAccessLevel; private String everyoneAccessLevel;
private AccessSettings accessSettings; private Set<AccessSetting> accessSettings = Sets.newLinkedHashSet();
/** /**
* @see ControlAccessParams#getIsSharedToEveryone() * @see ControlAccessParams#getIsSharedToEveryone()
@ -90,8 +94,16 @@ public class ControlAccessParams {
/** /**
* @see ControlAccessParams#getAccessSettings() * @see ControlAccessParams#getAccessSettings()
*/ */
public Builder accessSettings(AccessSettings accessSettings) { public Builder accessSettings(Iterable<AccessSetting> accessSettings) {
this.accessSettings = accessSettings; this.accessSettings = Sets.newLinkedHashSet(checkNotNull(accessSettings, "accessSettings"));
return this;
}
/**
* @see ControlAccessParams#getAccessSettings()
*/
public Builder accessSetting(AccessSetting accessSetting) {
this.accessSettings.add(checkNotNull(accessSetting, "accessSetting"));
return this; return this;
} }
@ -109,18 +121,19 @@ public class ControlAccessParams {
// For JAXB and builder use // For JAXB and builder use
} }
public ControlAccessParams(Boolean sharedToEveryone, String everyoneAccessLevel, AccessSettings accessSettings) { public ControlAccessParams(Boolean sharedToEveryone, String everyoneAccessLevel, Iterable<AccessSetting> accessSettings) {
this.sharedToEveryone = sharedToEveryone; this.sharedToEveryone = sharedToEveryone;
this.everyoneAccessLevel = everyoneAccessLevel; this.everyoneAccessLevel = everyoneAccessLevel;
this.accessSettings = accessSettings; this.accessSettings = accessSettings == null ? Sets.<AccessSetting>newLinkedHashSet() : ImmutableSet.copyOf(accessSettings);
} }
@XmlElement(name = "IsSharedToEveryone", required = true) @XmlElement(name = "IsSharedToEveryone", required = true)
protected Boolean sharedToEveryone; protected Boolean sharedToEveryone;
@XmlElement(name = "EveryoneAccessLevel") @XmlElement(name = "EveryoneAccessLevel")
protected String everyoneAccessLevel; protected String everyoneAccessLevel;
@XmlElement(name = "AccessSettings") @XmlElementWrapper(name = "AccessSettings")
protected AccessSettings accessSettings; @XmlElement(name = "AccessSetting")
protected Set<AccessSetting> accessSettings = Sets.newLinkedHashSet();
/** /**
* If true, this means that the resource is shared with everyone in the organization. * If true, this means that the resource is shared with everyone in the organization.
@ -143,7 +156,7 @@ public class ControlAccessParams {
* *
* Required on create and modify if {@link #isSharedToEveryone()} is false. * Required on create and modify if {@link #isSharedToEveryone()} is false.
*/ */
public AccessSettings getAccessSettings() { public Set<AccessSetting> getAccessSettings() {
return accessSettings; return accessSettings;
} }

View File

@ -19,6 +19,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.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
@ -52,6 +53,7 @@ public class EntityType extends ResourceType {
return new ConcreteBuilder(); return new ConcreteBuilder();
} }
@Override
public Builder<?> toBuilder() { public Builder<?> toBuilder() {
return builder().fromEntityType(this); return builder().fromEntityType(this);
} }
@ -62,7 +64,7 @@ public class EntityType 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 String description; private String description;
private Set<Task> tasks; private Set<Task> tasks = Sets.newLinkedHashSet();
private String name; private String name;
private String id; private String id;
@ -93,8 +95,16 @@ public class EntityType extends ResourceType {
/** /**
* @see EntityType#getTasks() * @see EntityType#getTasks()
*/ */
public B tasks(Set<Task> tasks) { public B tasks(Iterable<Task> tasks) {
this.tasks = tasks; this.tasks = Sets.newLinkedHashSet(checkNotNull(tasks, "tasks"));
return self();
}
/**
* @see EntityType#getTasks()
*/
public B task(Task task) {
this.tasks.add(checkNotNull(task, "task"));
return self(); return self();
} }
@ -105,7 +115,7 @@ public class EntityType extends ResourceType {
public B fromEntityType(EntityType in) { public B fromEntityType(EntityType in) {
return fromResourceType(in) return fromResourceType(in)
.description(in.getDescription()).tasks(Sets.newLinkedHashSet(in.getTasks())) .description(in.getDescription()).tasks(in.getTasks())
.id(in.getId()).name(in.getName()); .id(in.getId()).name(in.getName());
} }
} }
@ -123,7 +133,6 @@ public class EntityType extends ResourceType {
protected EntityType(Builder<?> builder) { protected EntityType(Builder<?> builder) {
super(builder); super(builder);
this.description = builder.description; this.description = builder.description;
// nullable so that jaxb wont persist empty collections
this.tasks = builder.tasks == null || builder.tasks.isEmpty() ? null : ImmutableSet.copyOf(builder.tasks); this.tasks = builder.tasks == null || builder.tasks.isEmpty() ? null : ImmutableSet.copyOf(builder.tasks);
this.id = builder.id; this.id = builder.id;
this.name = builder.name; this.name = builder.name;

View File

@ -20,14 +20,20 @@
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;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
/** /**
@ -69,6 +75,7 @@ public class Group extends EntityType {
return new ConcreteBuilder(); return new ConcreteBuilder();
} }
@Override
public Builder<?> toBuilder() { public Builder<?> toBuilder() {
return builder().fromGroup(this); return builder().fromGroup(this);
} }
@ -79,7 +86,7 @@ public class Group extends EntityType {
public static abstract class Builder<B extends Builder<B>> extends EntityType.Builder<B> { public static abstract class Builder<B extends Builder<B>> extends EntityType.Builder<B> {
private String nameInSource; private String nameInSource;
private UsersList usersList; private Set<Reference> users = Sets.newLinkedHashSet();
private Reference role; private Reference role;
/** /**
@ -91,10 +98,18 @@ public class Group extends EntityType {
} }
/** /**
* @see Group#getUsersList() * @see Group#getUsers()
*/ */
public B usersList(UsersList usersList) { public B users(Iterable<Reference> users) {
this.usersList = usersList; this.users = Sets.newLinkedHashSet(checkNotNull(users, "users"));
return self();
}
/**
* @see Group#getUsers()
*/
public B user(Reference user) {
users.add(checkNotNull(user, "user"));
return self(); return self();
} }
@ -106,6 +121,7 @@ public class Group extends EntityType {
return self(); return self();
} }
@Override
public Group build() { public Group build() {
return new Group(this); return new Group(this);
} }
@ -113,7 +129,7 @@ public class Group extends EntityType {
public B fromGroup(Group in) { public B fromGroup(Group in) {
return fromEntityType(in) return fromEntityType(in)
.nameInSource(in.getNameInSource()) .nameInSource(in.getNameInSource())
.usersList(in.getUsersList()) .users(in.getUsersList())
.role(in.getRole()); .role(in.getRole());
} }
} }
@ -126,48 +142,34 @@ public class Group extends EntityType {
protected Group(Builder<?> builder) { protected Group(Builder<?> builder) {
super(builder); super(builder);
this.nameInSource = builder.nameInSource; this.nameInSource = builder.nameInSource;
this.usersList = builder.usersList; this.usersList = builder.users == null ? Sets.<Reference>newLinkedHashSet() : ImmutableSet.copyOf(builder.users);
this.role = builder.role; this.role = builder.role;
} }
@XmlElement(name = "NameInSource") @XmlElement(name = "NameInSource")
protected String nameInSource; protected String nameInSource;
@XmlElement(name = "UsersList") @XmlElementWrapper(name = "UsersList")
protected UsersList usersList; @XmlElement(name = "UserReference")
protected Set<Reference> usersList = Sets.newLinkedHashSet();
@XmlElement(name = "Role") @XmlElement(name = "Role")
protected Reference role; protected Reference role;
/** /**
* Gets the value of the nameInSource property. * Gets the value of the nameInSource property.
*
* @return
* possible object is
* {@link String }
*
*/ */
public String getNameInSource() { public String getNameInSource() {
return nameInSource; return nameInSource;
} }
/** /**
* Gets the value of the usersList property. * Gets the value of the users property.
*
* @return
* possible object is
* {@link UsersList }
*
*/ */
public UsersList getUsersList() { public Set<Reference> getUsersList() {
return usersList; return usersList;
} }
/** /**
* Gets the value of the role property. * Gets the value of the role property.
*
* @return
* possible object is
* {@link Reference }
*
*/ */
public Reference getRole() { public Reference getRole() {
return role; return role;

View File

@ -1,165 +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 static com.google.common.base.Preconditions.checkNotNull;
import java.util.ArrayList;
import java.util.List;
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 javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
/**
*
* Container for ReferenceType elements that reference groups.
*
*
* <p>Java class for GroupsList complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="GroupsList">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
* &lt;sequence>
* &lt;element name="GroupReference" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "GroupsList")
@XmlType(propOrder = {
"groups"
})
public class GroupsList {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromGroupsList(this);
}
public static class Builder {
private List<Reference> groups;
/**
* @see GroupsList#getGroupReference()
*/
public Builder groups(List<Reference> groups) {
this.groups = ImmutableList.copyOf(groups);
return this;
}
/**
* @see GroupsList#getGroupReference()
*/
public Builder group(Reference group) {
groups.add(checkNotNull(group, "group"));
return this;
}
public GroupsList build() {
return new GroupsList(groups);
}
public Builder fromGroupsList(GroupsList in) {
return groups(in.getGroups());
}
}
private GroupsList() {
// For JAXB
}
private GroupsList(List<Reference> groups) {
this.groups = groups;
}
@XmlElement(name = "GroupReference")
protected List<Reference> groups;
/**
* Gets the value of the groupReference property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the groupReference property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getGroupReference().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Reference }
*
*
*/
public List<Reference> getGroups() {
if (groups == null) {
groups = new ArrayList<Reference>();
}
return this.groups;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
GroupsList that = GroupsList.class.cast(o);
return equal(groups, that.groups);
}
@Override
public int hashCode() {
return Objects.hashCode(groups);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("groups", groups).toString();
}
}

View File

@ -1,172 +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 static com.google.common.base.Preconditions.checkNotNull;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
/**
*
* Container for ReferenceType elements that reference ExternalNetwork objects.
* This element is created by the server and is read only.
*
*
* <p>Java class for Networks complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Networks">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
* &lt;sequence>
* &lt;element name="Network" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Networks", propOrder = {
"networks"
})
public class Networks {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromNetworks(this);
}
public static class Builder {
private List<Reference> networks = Lists.newArrayList();
/**
* @see Networks#getNetwork()
*/
public Builder networks(List<Reference> networks) {
this.networks = ImmutableList.copyOf(networks);
return this;
}
/**
* @see Networks#getNetwork()
*/
public Builder network(Reference network) {
this.networks.add(checkNotNull(network, "network"));
return this;
}
public Networks build() {
return new Networks(networks);
}
public Builder fromNetworks(Networks in) {
return networks(in.getNetwork());
}
}
private Networks() {
// For JAXB
}
private Networks(List<Reference> networks) {
this.networks = networks;
}
@XmlElement(name = "Network")
protected List<Reference> networks;
/**
* Gets the value of the network property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the network property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getNetwork().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Reference }
*
*
*/
public List<Reference> getNetwork() {
if (networks == null) {
networks = new ArrayList<Reference>();
}
return this.networks;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Networks that = Networks.class.cast(o);
return equal(networks, that.networks);
}
@Override
public int hashCode() {
return Objects.hashCode(networks);
}
@Override
public String toString() {
return string().toString();
}
public ToStringHelper string() {
return Objects.toStringHelper("")
.add("networks", networks);
}
}

View File

@ -1,166 +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 static com.google.common.base.Preconditions.checkNotNull;
import java.util.ArrayList;
import java.util.List;
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 javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
/**
*
* Container for ReferenceType elements that reference users.
*
*
* <p>Java class for UsersList complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="UsersList">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
* &lt;sequence>
* &lt;element name="UserReference" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "UsersList")
@XmlType(propOrder = {
"users"
})
public class UsersList {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromUsersList(this);
}
public static class Builder {
private List<Reference> users = Lists.newArrayList();
/**
* @see UsersList#getUsers()
*/
public Builder users(List<Reference> users) {
this.users = ImmutableList.copyOf(users);
return this;
}
/**
* @see UsersList#getUsers()
*/
public Builder user(Reference user) {
users.add(checkNotNull(user, "user"));
return this;
}
public UsersList build() {
return new UsersList(users);
}
public Builder fromUsersList(UsersList in) {
return users(in.getUsers());
}
}
private UsersList() {
// For JAXB and builder use
}
private UsersList(List<Reference> users) {
this.users = users;
}
@XmlElement(name = "UserReference")
protected List<Reference> users;
/**
* Gets the value of the userReference property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the userReference property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getUserReference().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Reference }
*
*
*/
public List<Reference> getUsers() {
if (users == null) {
users = new ArrayList<Reference>();
}
return this.users;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
UsersList that = UsersList.class.cast(o);
return equal(users, that.users);
}
@Override
public int hashCode() {
return Objects.hashCode(users);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("userReference", users).toString();
}
}

View File

@ -1,176 +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 static com.google.common.base.Preconditions.checkNotNull;
import java.util.ArrayList;
import java.util.List;
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 javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
/**
*
* Represents a list of references to virtual data centers.
*
*
* <p>Java class for Vdcs complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Vdcs">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
* &lt;sequence>
* &lt;element name="Vdc" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Vdcs")
@XmlType(propOrder = {
"vdcs"
})
public class Vdcs {
// FIXME Delete Vdcs, and use Set<Vdc>
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromVdcs(this);
}
public static class Builder {
private List<Reference> vdcs = Lists.newArrayList();
/**
* @see Vdcs#getVdc()
*/
public Builder vdcs(List<Reference> vdcs) {
this.vdcs = ImmutableList.copyOf(vdcs);
return this;
}
/**
* @see Vdcs#getVdc()
*/
public Builder vdc(Reference vdc) {
this.vdcs.add(checkNotNull(vdc, "vdc"));
return this;
}
public Vdcs build() {
return new Vdcs(vdcs);
}
public Builder fromVdcs(Vdcs in) {
return vdcs(in.getVdcs());
}
}
private Vdcs() {
// For JAXB and builder use
}
private Vdcs(List<Reference> vdcs) {
this.vdcs = vdcs;
}
@XmlElement(name = "Vdc")
protected List<Reference> vdcs;
/**
* Gets the value of the vdc property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the vdc property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getVdc().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Reference }
*
*
*/
public List<Reference> getVdcs() {
if (vdcs == null) {
vdcs = new ArrayList<Reference>();
}
return this.vdcs;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Vdcs that = Vdcs.class.cast(o);
return equal(vdcs, that.vdcs);
}
@Override
public int hashCode() {
return Objects.hashCode(vdcs);
}
@Override
public String toString() {
return string().toString();
}
public ToStringHelper string() {
return Objects.toStringHelper("")
.add("vdcs", vdcs);
}
}

View File

@ -68,6 +68,7 @@ import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
import com.beust.jcommander.internal.Maps; import com.beust.jcommander.internal.Maps;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
@ -110,12 +111,19 @@ public class Checks {
/** /**
* Assumes the validTypes to be vcloud-specific types. * Assumes the validTypes to be vcloud-specific types.
* *
* @see checkReferenceType(ReferenceType, Collection<String>) * @see #checkReferenceType(Reference, Collection)
*/ */
public static void checkReferenceType(Reference reference) { public static void checkReferenceType(Reference reference) {
checkReferenceType(reference, VCloudDirectorMediaType.ALL); checkReferenceType(reference, VCloudDirectorMediaType.ALL);
} }
/**
* @see #checkReferenceType(Reference, Collection)
*/
public static void checkReferenceType(Reference reference, String type) {
checkReferenceType(reference, ImmutableSet.of(type));
}
public static void checkReferenceType(Reference 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_OBJ_FIELD_FMT, "Href", "ReferenceType")); assertNotNull(reference.getHref(), String.format(NOT_NULL_OBJ_FIELD_FMT, "Href", "ReferenceType"));
@ -283,41 +291,26 @@ public class Checks {
assertNotNull(org.getSettings(), String.format(NOT_NULL_OBJ_FIELD_FMT, "settings", "AdminOrg")); assertNotNull(org.getSettings(), String.format(NOT_NULL_OBJ_FIELD_FMT, "settings", "AdminOrg"));
// optional // optional
if (org.getGroups() != null) { for (Reference user : org.getUsers()) {
checkGroupsList(org.getGroups()); checkReferenceType(user, VCloudDirectorMediaType.ADMIN_USER);
} }
if (org.getCatalogs() != null) { for (Reference group : org.getGroups()) {
checkCatalogsList(org.getCatalogs()); checkReferenceType(group, VCloudDirectorMediaType.GROUP);
} }
if (org.getVdcs() != null) { for (Reference catalog : org.getCatalogs()) {
checkVdcs(org.getVdcs()); checkReferenceType(catalog, VCloudDirectorMediaType.ADMIN_CATALOG);
} }
if (org.getNetworks() != null) { for (Reference vdc : org.getVdcs()) {
checkNetworks(org.getNetworks()); checkReferenceType(vdc, VCloudDirectorMediaType.ADMIN_VDC);
}
for (Reference network : org.getNetworks()) {
checkReferenceType(network, VCloudDirectorMediaType.ADMIN_NETWORK);
} }
// Check parent type // Check parent type
checkOrg(org); checkOrg(org);
} }
public static void checkCatalogsList(CatalogsList catalogList) {
for (Reference catalogItem : catalogList.getCatalogItems()) {
checkReferenceType(catalogItem);
}
}
public static void checkVdcs(Vdcs vdcs) {
for (Reference vdc : vdcs.getVdcs()) {
checkReferenceType(vdc);
}
}
public static void checkNetworks(Networks networks) {
for (Reference network : networks.getNetwork()) {
checkReferenceType(network);
}
}
public static void checkAdminCatalog(AdminCatalog catalog) { public static void checkAdminCatalog(AdminCatalog catalog) {
// Check parent type // Check parent type
checkCatalogType(catalog); checkCatalogType(catalog);
@ -327,11 +320,8 @@ public class Checks {
// Check optional elements/attributes // Check optional elements/attributes
Owner owner = catalog.getOwner(); Owner owner = catalog.getOwner();
if (owner != null) checkOwner(owner); if (owner != null) checkOwner(owner);
CatalogItems catalogItems = catalog.getCatalogItems(); for (Reference catalogItemReference : catalog.getCatalogItems()) {
if (catalogItems != null) { checkReferenceType(catalogItemReference, VCloudDirectorMediaType.CATALOG_ITEM);
for (Reference catalogItemReference : catalogItems.getCatalogItems()) {
checkReferenceType(catalogItemReference);
}
} }
// NOTE isPublished cannot be checked // NOTE isPublished cannot be checked
@ -695,14 +685,7 @@ public class Checks {
if (params.isSharedToEveryone()) { if (params.isSharedToEveryone()) {
assertNotNull(params.getEveryoneAccessLevel(), String.format(OBJ_FIELD_REQ, "ControlAccessParams", "EveryoneAccessLevel")); assertNotNull(params.getEveryoneAccessLevel(), String.format(OBJ_FIELD_REQ, "ControlAccessParams", "EveryoneAccessLevel"));
} else { } else {
AccessSettings accessSettings = params.getAccessSettings(); for (AccessSetting setting : params.getAccessSettings()) {
checkAccessSettings(accessSettings);
}
}
public static void checkAccessSettings(AccessSettings accessSettings) {
if (accessSettings != null && accessSettings.getAccessSettings() != null) {
for (AccessSetting setting : accessSettings.getAccessSettings()) {
checkAccessSetting(setting); checkAccessSetting(setting);
} }
} }
@ -778,38 +761,20 @@ public class Checks {
checkResourceEntityType(media); checkResourceEntityType(media);
} }
public static void checkGroupsList(GroupsList groupsList) {
// Check optional fields
if (groupsList.getGroups() != null) {
for (Reference group : groupsList.getGroups()) {
checkReferenceType(group);
}
}
}
public static void checkGroup(Group group) { public static void checkGroup(Group group) {
// Check optional fields // Check optional fields
// NOTE nameInSource cannot be checked // NOTE nameInSource cannot be checked
if (group.getUsersList() != null) { for (Reference user : group.getUsersList()) {
checkUsersList(group.getUsersList()); checkReferenceType(user, VCloudDirectorMediaType.USER);
} }
if (group.getRole() != null) { if (group.getRole() != null) {
checkReferenceType(group.getRole()); checkReferenceType(group.getRole(), VCloudDirectorMediaType.ROLE);
} }
// parent type // parent type
checkEntityType(group); checkEntityType(group);
} }
public static void checkUsersList(UsersList usersList) {
// Check optional fields
if (usersList.getUsers() != null) {
for (Reference user : usersList.getUsers()) {
checkReferenceType(user);
}
}
}
public static void checkOrgSettings(OrgSettings settings) { public static void checkOrgSettings(OrgSettings settings) {
// Check optional fields // Check optional fields
if (settings.getGeneralSettings() != null) { if (settings.getGeneralSettings() != null) {

View File

@ -25,7 +25,6 @@ import java.net.URI;
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.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog;
import org.jclouds.vcloud.director.v1_5.domain.CatalogItems;
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.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;
@ -37,7 +36,7 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
/** /**
* Test the {@link CatalogClient} by observing its side effects. * Test the {@link AdminCatalogClient} by observing its side effects.
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@ -289,8 +288,6 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
.build()) .build())
.build()) .build())
.build()) .build())
.catalogItems(CatalogItems.builder()
.build())
.isPublished(false) .isPublished(false)
.build(); .build();
} }
@ -337,7 +334,6 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
.build()) .build())
.description("Testing") .description("Testing")
.owner(owner()) .owner(owner())
.catalogItems(CatalogItems.builder()
.item(Reference.builder() .item(Reference.builder()
.type("application/vnd.vmware.vcloud.catalogItem+xml") .type("application/vnd.vmware.vcloud.catalogItem+xml")
.name("image") .name("image")
@ -358,7 +354,6 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
.name("TestCase") .name("TestCase")
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/f7598606-aea4-41d7-8f67-2090e28e7876")) .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/f7598606-aea4-41d7-8f67-2090e28e7876"))
.build()) .build())
.build())
.isPublished(false) .isPublished(false)
.build(); .build();
} }

View File

@ -25,10 +25,7 @@ import java.net.URI;
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.AdminOrg; import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
import org.jclouds.vcloud.director.v1_5.domain.CatalogsList;
import org.jclouds.vcloud.director.v1_5.domain.GroupsList;
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.Networks;
import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
@ -38,13 +35,11 @@ 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.Reference; 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.domain.UsersList;
import org.jclouds.vcloud.director.v1_5.domain.Vdcs;
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;
/** /**
* Test the {@link GroupClient} by observing its side effects. * Test the {@link AdminOrgClient} by observing its side effects.
* *
* @author danikov * @author danikov
*/ */
@ -126,7 +121,6 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
.fullName("JClouds") .fullName("JClouds")
.isEnabled(true) .isEnabled(true)
.settings(settings()) .settings(settings())
.users(UsersList.builder()
.user(Reference.builder() .user(Reference.builder()
.type("application/vnd.vmware.admin.user+xml") .type("application/vnd.vmware.admin.user+xml")
.name("adam.lowe@cloudsoftcorp.com") .name("adam.lowe@cloudsoftcorp.com")
@ -152,10 +146,6 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
.name("adk@cloudsoftcorp.com") .name("adk@cloudsoftcorp.com")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9")) .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"))
.build()) .build())
.build())
.groups(GroupsList.builder()
.build())
.catalogs(CatalogsList.builder()
.catalog(Reference.builder() .catalog(Reference.builder()
.type("application/vnd.vmware.admin.catalog+xml") .type("application/vnd.vmware.admin.catalog+xml")
.name("QunyingTestCatalog") .name("QunyingTestCatalog")
@ -176,15 +166,11 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
.name("test") .name("test")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/b7289d54-4ca4-497f-9a93-2d4afc97e3da")) .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/b7289d54-4ca4-497f-9a93-2d4afc97e3da"))
.build()) .build())
.build())
.vdcs(Vdcs.builder()
.vdc(Reference.builder() .vdc(Reference.builder()
.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())
.build())
.networks(Networks.builder()
.network(Reference.builder() .network(Reference.builder()
.type("application/vnd.vmware.admin.network+xml") .type("application/vnd.vmware.admin.network+xml")
.name("ilsolation01-Jclouds") .name("ilsolation01-Jclouds")
@ -195,7 +181,6 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
.name("internet01-Jclouds") .name("internet01-Jclouds")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/network/55a677cf-ab3f-48ae-b880-fab90421980c")) .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/network/55a677cf-ab3f-48ae-b880-fab90421980c"))
.build()) .build())
.build())
.build(); .build();
} }

View File

@ -27,7 +27,6 @@ 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.CatalogItem; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
import org.jclouds.vcloud.director.v1_5.domain.CatalogItems;
import org.jclouds.vcloud.director.v1_5.domain.CatalogType; import org.jclouds.vcloud.director.v1_5.domain.CatalogType;
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.Metadata;
@ -376,7 +375,6 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
assertEquals(client.getCatalogClient().getCatalogItemMetadataClient().deleteMetadataEntry(catalogItemURI, "KEY"), expected); assertEquals(client.getCatalogClient().getCatalogItemMetadataClient().deleteMetadataEntry(catalogItemURI, "KEY"), expected);
} }
@SuppressWarnings("unchecked")
public static final CatalogType catalog() { public static final CatalogType catalog() {
return CatalogType.builder() return CatalogType.builder()
.name("QunyingTestCatalog") .name("QunyingTestCatalog")
@ -398,7 +396,6 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
.type("application/vnd.vmware.vcloud.metadata+xml") .type("application/vnd.vmware.vcloud.metadata+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata")) .href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata"))
.build()) .build())
.catalogItems(CatalogItems.builder()
.item(Reference.builder() .item(Reference.builder()
.type("application/vnd.vmware.vcloud.catalogItem+xml") .type("application/vnd.vmware.vcloud.catalogItem+xml")
.name("ubuntu10") .name("ubuntu10")
@ -409,7 +406,6 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
.name("imageTesting") .name("imageTesting")
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a9e0afdb-a42b-4688-8409-2ac68cf22939")) .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a9e0afdb-a42b-4688-8409-2ac68cf22939"))
.build()) .build())
.build())
.description("Testing") .description("Testing")
.isPublished(false) .isPublished(false)
.build(); .build();

View File

@ -64,7 +64,6 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.domain.AccessSetting; import org.jclouds.vcloud.director.v1_5.domain.AccessSetting;
import org.jclouds.vcloud.director.v1_5.domain.AccessSettings;
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.ControlAccessParams; import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams;
import org.jclouds.vcloud.director.v1_5.domain.DeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.DeployVAppParams;
@ -325,12 +324,10 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
public void testControlAccessUser() { public void testControlAccessUser() {
ControlAccessParams params = ControlAccessParams.builder() ControlAccessParams params = ControlAccessParams.builder()
.notSharedToEveryone() .notSharedToEveryone()
.accessSettings(AccessSettings.builder()
.accessSetting(AccessSetting.builder() .accessSetting(AccessSetting.builder()
.subject(Reference.builder().href(userURI).type(ADMIN_USER).build()) .subject(Reference.builder().href(userURI).type(ADMIN_USER).build())
.accessLevel("ReadOnly") .accessLevel("ReadOnly")
.build()) .build())
.build())
.build(); .build();
// The method under test // The method under test