diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AccessSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AccessSettings.java deleted file mode 100644 index 8d75f1dfd9..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AccessSettings.java +++ /dev/null @@ -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. - * - *
- * <complexType name="AccessSettings" />
- * 
- * - * @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 accessSettings = Lists.newArrayList(); - - /** - * @see AccessSettings#getAccessSettings() - */ - public Builder accessSettings(List 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 accessSettings) { - this.accessSettings = accessSettings; - } - - @XmlElement(name = "AccessSetting", required = true) - protected List accessSettings = Lists.newArrayList(); - - /** - * Gets the value of the accessSetting property. - */ - public List 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(); - } -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminCatalog.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminCatalog.java index f9d3170b76..3c0683066f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminCatalog.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminCatalog.java @@ -45,6 +45,7 @@ public class AdminCatalog extends CatalogType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromAdminCatalog(this); } @@ -54,6 +55,7 @@ public class AdminCatalog extends CatalogType { public static abstract class Builder> extends CatalogType.Builder { + @Override public AdminCatalog build() { return new AdminCatalog(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminOrg.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminOrg.java index 76a83f8cd0..4ab924e91e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminOrg.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminOrg.java @@ -19,15 +19,19 @@ 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.Set; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; 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.ImmutableSet; +import com.google.common.collect.Sets; /** * The AdminOrg represents an administrative view of an organization. @@ -67,6 +71,7 @@ public class AdminOrg extends Org { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromAdminOrg(this); } @@ -77,11 +82,11 @@ public class AdminOrg extends Org { public static abstract class Builder> extends Org.Builder { private OrgSettings settings; - private UsersList users; - private GroupsList groups; - private CatalogsList catalogs; - private Vdcs vdcs; - private Networks networks; + private Set users = Sets.newLinkedHashSet(); + private Set groups = Sets.newLinkedHashSet(); + private Set catalogs = Sets.newLinkedHashSet(); + private Set vdcs = Sets.newLinkedHashSet(); + private Set networks = Sets.newLinkedHashSet(); /** * @see AdminOrg#getSettings() @@ -94,43 +99,82 @@ public class AdminOrg extends Org { /** * @see AdminOrg#getUsers() */ - public B users(UsersList users) { - this.users = users; + public B users(Iterable 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(); } /** * @see AdminOrg#getGroups() */ - public B groups(GroupsList groups) { - this.groups = groups; + public B groups(Iterable 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(CatalogsList catalogs) { - this.catalogs = catalogs; + public B catalogs(Iterable catalogReferences) { + this.catalogs = Sets.newLinkedHashSet(checkNotNull(catalogs, "catalogs")); + return self(); + } + + /** + * @see AdminOrg#getCatalogs() + */ + public B catalog(Reference catalog) { + this.catalogs.add(checkNotNull(catalog, "catalog")); return self(); } - /** * @see AdminOrg#getVdcs() */ - public B vdcs(Vdcs vdcs) { - this.vdcs = vdcs; + public B vdcs(Iterable vdcs) { + this.vdcs = Sets.newLinkedHashSet(checkNotNull(vdcs, "vdcs")); return self(); } - + + /** + * @see AdminOrg#getVdcs() + */ + public B vdc(Reference vdc) { + this.vdcs.add(checkNotNull(vdc, "vdc")); + return self(); + } + /** * @see AdminOrg#getNetworks() */ - public B networks(Networks networks) { - this.networks = networks; + public B networks(Iterable networks) { + this.networks = Sets.newLinkedHashSet(checkNotNull(networks, "networks")); + return self(); + } + + /** + * @see AdminOrg#getNetworks() + */ + public B network(Reference network) { + this.networks.add(checkNotNull(network, "network")); return self(); } + @Override public AdminOrg build() { return new AdminOrg(this); } @@ -153,33 +197,33 @@ public class AdminOrg extends Org { protected AdminOrg(Builder builder) { super(builder); this.settings = builder.settings; - this.users = builder.users; - this.groups = builder.groups; - this.catalogs = builder.catalogs; - this.vdcs = builder.vdcs; - this.networks = builder.networks; + this.users = builder.users == null ? Sets.newLinkedHashSet() : ImmutableSet.copyOf(builder.users); + this.groups = builder.groups == null ? Sets.newLinkedHashSet() : ImmutableSet.copyOf(builder.groups); + this.catalogs = builder.catalogs == null ? Sets.newLinkedHashSet() : ImmutableSet.copyOf(builder.catalogs); + this.vdcs = builder.vdcs == null ? Sets.newLinkedHashSet() : ImmutableSet.copyOf(builder.vdcs); + this.networks = builder.networks == null ? Sets.newLinkedHashSet() : ImmutableSet.copyOf(builder.networks); } @XmlElement(name = "Settings", required = true) private OrgSettings settings; - @XmlElement(name = "Users") - private UsersList users; - @XmlElement(name = "Groups") - private GroupsList groups; - @XmlElement(name = "Catalogs") - private CatalogsList catalogs; - @XmlElement(name = "Vdcs") - private Vdcs vdcs; - @XmlElement(name = "Networks") - private Networks networks; + @XmlElementWrapper(name = "Users") + @XmlElement(name = "UserReference") + protected Set users = Sets.newLinkedHashSet(); + @XmlElementWrapper(name = "Groups") + @XmlElement(name = "GroupReference") + protected Set groups = Sets.newLinkedHashSet(); + @XmlElementWrapper(name = "Catalogs") + @XmlElement(name = "CatalogReference") + private Set catalogs = Sets.newLinkedHashSet(); + @XmlElementWrapper(name = "Vdcs") + @XmlElement(name = "Vdc") + protected Set vdcs = Sets.newLinkedHashSet(); + @XmlElementWrapper(name = "Networks") + @XmlElement(name = "Network") + protected Set networks = Sets.newLinkedHashSet(); /** * Gets the value of the settings property. - * - * @return - * possible object is - * {@link OrgSettings } - * */ public OrgSettings getSettings() { return settings; @@ -187,61 +231,36 @@ public class AdminOrg extends Org { /** * Gets the value of the users property. - * - * @return - * possible object is - * {@link UsersList } - * */ - public UsersList getUsers() { + public Set getUsers() { return users; } /** * Gets the value of the groups property. - * - * @return - * possible object is - * {@link GroupsList } - * */ - public GroupsList getGroups() { + public Set getGroups() { return groups; } /** * Gets the value of the catalogs property. - * - * @return - * possible object is - * {@link CatalogsList } - * */ - public CatalogsList getCatalogs() { + public Set getCatalogs() { return catalogs; } /** * Gets the value of the vdcs property. - * - * @return - * possible object is - * {@link Vdcs } - * */ - public Vdcs getVdcs() { + public Set getVdcs() { return vdcs; } /** * Gets the value of the networks property. - * - * @return - * possible object is - * {@link Networks } - * */ - public Networks getNetworks() { + public Set getNetworks() { return networks; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java deleted file mode 100644 index 6e0a09cff1..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java +++ /dev/null @@ -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. - *

- *

- * <complexType name="CatalogItemsType" />
- * 
- * - * @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 catalogItems = Sets.newLinkedHashSet(); - - /** - * @see CatalogItems#getCatalogItems() - */ - public Builder items(Collection 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 catalogItems) { - this.catalogItems = ImmutableSet.copyOf(catalogItems); - } - - @XmlElement(name = "CatalogItem") - private Set catalogItems = Sets.newLinkedHashSet(); - - /** - * Gets the value of the catalogItems property. - */ - public Set 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); - } -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogType.java index 8880d7e25e..91fe4de009 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogType.java @@ -19,16 +19,22 @@ 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.Set; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; /** * Container for references to VappTemplate and Media objects. - *

+ * *

  * <complexType name="CatalogType" />
  * 
@@ -42,6 +48,7 @@ public class CatalogType extends EntityType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromCatalogType(this); } @@ -52,7 +59,7 @@ public class CatalogType extends EntityType { public static class Builder> extends EntityType.Builder { private Owner owner; - private CatalogItems catalogItems; + private Set catalogItems = Sets.newLinkedHashSet(); private Boolean isPublished; /** @@ -64,10 +71,18 @@ public class CatalogType extends EntityType { } /** - * @see CatalogType#getCatalogItems() + * @see CatalogItems#getCatalogItems() */ - public B catalogItems(CatalogItems catalogItems) { - this.catalogItems = catalogItems; + public B items(Iterable 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(); } @@ -93,14 +108,14 @@ public class CatalogType extends EntityType { } 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) { super(builder); 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; } @@ -110,8 +125,9 @@ public class CatalogType extends EntityType { @XmlElement(name = "Owner") private Owner owner; - @XmlElement(name = "CatalogItems") - private CatalogItems catalogItems; + @XmlElementWrapper(name = "CatalogItems") + @XmlElement(name = "CatalogItem") + private Set catalogItems; @XmlElement(name = "IsPublished") private Boolean isPublished; @@ -125,8 +141,8 @@ public class CatalogType extends EntityType { /** * Gets the value of the catalogItems property. */ - public CatalogItems getCatalogItems() { - return catalogItems; + public Set getCatalogItems() { + return catalogItems == null ? ImmutableSet.of() : ImmutableSet.copyOf(catalogItems); } /** @@ -145,19 +161,19 @@ public class CatalogType extends EntityType { CatalogType that = CatalogType.class.cast(o); return super.equals(that) && equal(this.owner, that.owner) && - equal(this.catalogItems, that.catalogItems) && + equal(this.getCatalogItems(), that.getCatalogItems()) && equal(this.isPublished, that.isPublished); } @Override public int hashCode() { - return Objects.hashCode(super.hashCode(), owner, catalogItems, catalogItems); + return Objects.hashCode(super.hashCode(), owner, getCatalogItems(), catalogItems); } @Override public ToStringHelper string() { return super.string().add("owner", owner) - .add("catalogItems", catalogItems) + .add("catalogItems", getCatalogItems()) .add("isPublished", isPublished); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java deleted file mode 100644 index ee0b2af588..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java +++ /dev/null @@ -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. - *

- *

- * <complexType name="CatalogsListType" />
- * 
- * - * @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 catalogReferences = Sets.newLinkedHashSet(); - - /** - * @see CatalogsList#getCatalogItems() - */ - public Builder catalogs(Set 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 catalogReferences) { - this.catalogReferences = ImmutableSet.copyOf(checkNotNull(catalogReferences, "catalogReferences")); - } - - @XmlElement(name = "CatalogReference") - private Set catalogReferences = Sets.newLinkedHashSet(); - - /** - * Gets the value of the catalogReferences property. - */ - public Set 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); - } -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java index 7259eea2a3..6272246149 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java @@ -18,15 +18,19 @@ */ 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.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; /** * Used to control access to resources. @@ -53,7 +57,7 @@ public class ControlAccessParams { private Boolean sharedToEveryone = Boolean.FALSE; private String everyoneAccessLevel; - private AccessSettings accessSettings; + private Set accessSettings = Sets.newLinkedHashSet(); /** * @see ControlAccessParams#getIsSharedToEveryone() @@ -90,8 +94,16 @@ public class ControlAccessParams { /** * @see ControlAccessParams#getAccessSettings() */ - public Builder accessSettings(AccessSettings accessSettings) { - this.accessSettings = accessSettings; + public Builder accessSettings(Iterable 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; } @@ -109,18 +121,19 @@ public class ControlAccessParams { // For JAXB and builder use } - public ControlAccessParams(Boolean sharedToEveryone, String everyoneAccessLevel, AccessSettings accessSettings) { + public ControlAccessParams(Boolean sharedToEveryone, String everyoneAccessLevel, Iterable accessSettings) { this.sharedToEveryone = sharedToEveryone; this.everyoneAccessLevel = everyoneAccessLevel; - this.accessSettings = accessSettings; + this.accessSettings = accessSettings == null ? Sets.newLinkedHashSet() : ImmutableSet.copyOf(accessSettings); } @XmlElement(name = "IsSharedToEveryone", required = true) protected Boolean sharedToEveryone; @XmlElement(name = "EveryoneAccessLevel") protected String everyoneAccessLevel; - @XmlElement(name = "AccessSettings") - protected AccessSettings accessSettings; + @XmlElementWrapper(name = "AccessSettings") + @XmlElement(name = "AccessSetting") + protected Set accessSettings = Sets.newLinkedHashSet(); /** * 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. */ - public AccessSettings getAccessSettings() { + public Set getAccessSettings() { return accessSettings; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java index 970ee7d19c..20fa5a53ab 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java @@ -19,6 +19,7 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; import java.util.Collections; import java.util.Set; @@ -52,6 +53,7 @@ public class EntityType extends ResourceType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromEntityType(this); } @@ -62,7 +64,7 @@ public class EntityType extends ResourceType { public static abstract class Builder> extends ResourceType.Builder { private String description; - private Set tasks; + private Set tasks = Sets.newLinkedHashSet(); private String name; private String id; @@ -93,8 +95,16 @@ public class EntityType extends ResourceType { /** * @see EntityType#getTasks() */ - public B tasks(Set tasks) { - this.tasks = tasks; + public B tasks(Iterable 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(); } @@ -105,7 +115,7 @@ public class EntityType extends ResourceType { public B fromEntityType(EntityType in) { return fromResourceType(in) - .description(in.getDescription()).tasks(Sets.newLinkedHashSet(in.getTasks())) + .description(in.getDescription()).tasks(in.getTasks()) .id(in.getId()).name(in.getName()); } } @@ -123,7 +133,6 @@ public class EntityType extends ResourceType { protected EntityType(Builder builder) { super(builder); 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.id = builder.id; this.name = builder.name; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Group.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Group.java index 0d49bb5156..790b0fa06d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Group.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Group.java @@ -20,14 +20,20 @@ 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.Set; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; 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(); } + @Override public Builder toBuilder() { return builder().fromGroup(this); } @@ -79,7 +86,7 @@ public class Group extends EntityType { public static abstract class Builder> extends EntityType.Builder { private String nameInSource; - private UsersList usersList; + private Set users = Sets.newLinkedHashSet(); private Reference role; /** @@ -91,10 +98,18 @@ public class Group extends EntityType { } /** - * @see Group#getUsersList() + * @see Group#getUsers() */ - public B usersList(UsersList usersList) { - this.usersList = usersList; + public B users(Iterable users) { + this.users = Sets.newLinkedHashSet(checkNotNull(users, "users")); + return self(); + } + + /** + * @see Group#getUsers() + */ + public B user(Reference user) { + users.add(checkNotNull(user, "user")); return self(); } @@ -106,6 +121,7 @@ public class Group extends EntityType { return self(); } + @Override public Group build() { return new Group(this); } @@ -113,7 +129,7 @@ public class Group extends EntityType { public B fromGroup(Group in) { return fromEntityType(in) .nameInSource(in.getNameInSource()) - .usersList(in.getUsersList()) + .users(in.getUsersList()) .role(in.getRole()); } } @@ -126,48 +142,34 @@ public class Group extends EntityType { protected Group(Builder builder) { super(builder); this.nameInSource = builder.nameInSource; - this.usersList = builder.usersList; + this.usersList = builder.users == null ? Sets.newLinkedHashSet() : ImmutableSet.copyOf(builder.users); this.role = builder.role; } @XmlElement(name = "NameInSource") protected String nameInSource; - @XmlElement(name = "UsersList") - protected UsersList usersList; + @XmlElementWrapper(name = "UsersList") + @XmlElement(name = "UserReference") + protected Set usersList = Sets.newLinkedHashSet(); @XmlElement(name = "Role") protected Reference role; /** * Gets the value of the nameInSource property. - * - * @return - * possible object is - * {@link String } - * */ public String getNameInSource() { return nameInSource; } /** - * Gets the value of the usersList property. - * - * @return - * possible object is - * {@link UsersList } - * + * Gets the value of the users property. */ - public UsersList getUsersList() { + public Set getUsersList() { return usersList; } /** * Gets the value of the role property. - * - * @return - * possible object is - * {@link Reference } - * */ public Reference getRole() { return role; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GroupsList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GroupsList.java deleted file mode 100644 index 6c644b4a18..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GroupsList.java +++ /dev/null @@ -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. - * - * - *

Java class for GroupsList complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="GroupsList">
- *   <complexContent>
- *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
- *       <sequence>
- *         <element name="GroupReference" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <anyAttribute processContents='lax' namespace='##other'/>
- *     </extension>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@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 groups; - - /** - * @see GroupsList#getGroupReference() - */ - public Builder groups(List 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 groups) { - this.groups = groups; - } - - @XmlElement(name = "GroupReference") - protected List groups; - - /** - * Gets the value of the groupReference property. - * - *

- * 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 set method for the groupReference property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getGroupReference().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Reference } - * - * - */ - public List getGroups() { - if (groups == null) { - groups = new ArrayList(); - } - 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(); - } - -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Networks.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Networks.java deleted file mode 100644 index 6509e9f213..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Networks.java +++ /dev/null @@ -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. - * - * - *

Java class for Networks complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="Networks">
- *   <complexContent>
- *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
- *       <sequence>
- *         <element name="Network" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <anyAttribute processContents='lax' namespace='##other'/>
- *     </extension>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@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 networks = Lists.newArrayList(); - - /** - * @see Networks#getNetwork() - */ - public Builder networks(List 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 networks) { - this.networks = networks; - } - - @XmlElement(name = "Network") - protected List networks; - - /** - * Gets the value of the network property. - * - *

- * 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 set method for the network property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getNetwork().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Reference } - * - * - */ - public List getNetwork() { - if (networks == null) { - networks = new ArrayList(); - } - 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); - } - -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UsersList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UsersList.java deleted file mode 100644 index 26250eff5d..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UsersList.java +++ /dev/null @@ -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. - * - * - *

Java class for UsersList complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="UsersList">
- *   <complexContent>
- *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
- *       <sequence>
- *         <element name="UserReference" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <anyAttribute processContents='lax' namespace='##other'/>
- *     </extension>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@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 users = Lists.newArrayList(); - - /** - * @see UsersList#getUsers() - */ - public Builder users(List 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 users) { - this.users = users; - } - - @XmlElement(name = "UserReference") - protected List users; - - /** - * Gets the value of the userReference property. - * - *

- * 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 set method for the userReference property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getUserReference().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Reference } - * - * - */ - public List getUsers() { - if (users == null) { - users = new ArrayList(); - } - 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(); - } - -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdcs.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdcs.java deleted file mode 100644 index 99f23f9ead..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdcs.java +++ /dev/null @@ -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. - * - * - *

Java class for Vdcs complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="Vdcs">
- *   <complexContent>
- *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
- *       <sequence>
- *         <element name="Vdc" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <anyAttribute processContents='lax' namespace='##other'/>
- *     </extension>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "Vdcs") -@XmlType(propOrder = { - "vdcs" -}) -public class Vdcs { - - // FIXME Delete Vdcs, and use Set - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromVdcs(this); - } - - public static class Builder { - - private List vdcs = Lists.newArrayList(); - - /** - * @see Vdcs#getVdc() - */ - public Builder vdcs(List 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 vdcs) { - this.vdcs = vdcs; - } - - - @XmlElement(name = "Vdc") - protected List vdcs; - - /** - * Gets the value of the vdc property. - * - *

- * 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 set method for the vdc property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getVdc().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Reference } - * - * - */ - public List getVdcs() { - if (vdcs == null) { - vdcs = new ArrayList(); - } - 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); - } - -} diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java index 659d53f85c..41a30749a4 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java @@ -68,6 +68,7 @@ import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType; import com.beust.jcommander.internal.Maps; import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.net.InetAddresses; @@ -110,11 +111,18 @@ public class Checks { /** * Assumes the validTypes to be vcloud-specific types. * - * @see checkReferenceType(ReferenceType, Collection) + * @see #checkReferenceType(Reference, Collection) */ public static void checkReferenceType(Reference reference) { 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 validTypes) { // Check required fields @@ -283,41 +291,26 @@ public class Checks { assertNotNull(org.getSettings(), String.format(NOT_NULL_OBJ_FIELD_FMT, "settings", "AdminOrg")); // optional - if (org.getGroups() != null) { - checkGroupsList(org.getGroups()); + for (Reference user : org.getUsers()) { + checkReferenceType(user, VCloudDirectorMediaType.ADMIN_USER); } - if (org.getCatalogs() != null) { - checkCatalogsList(org.getCatalogs()); + for (Reference group : org.getGroups()) { + checkReferenceType(group, VCloudDirectorMediaType.GROUP); } - if (org.getVdcs() != null) { - checkVdcs(org.getVdcs()); + for (Reference catalog : org.getCatalogs()) { + checkReferenceType(catalog, VCloudDirectorMediaType.ADMIN_CATALOG); } - if (org.getNetworks() != null) { - checkNetworks(org.getNetworks()); + for (Reference vdc : org.getVdcs()) { + checkReferenceType(vdc, VCloudDirectorMediaType.ADMIN_VDC); + } + for (Reference network : org.getNetworks()) { + checkReferenceType(network, VCloudDirectorMediaType.ADMIN_NETWORK); } // Check parent type 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) { // Check parent type checkCatalogType(catalog); @@ -327,11 +320,8 @@ public class Checks { // Check optional elements/attributes Owner owner = catalog.getOwner(); if (owner != null) checkOwner(owner); - CatalogItems catalogItems = catalog.getCatalogItems(); - if (catalogItems != null) { - for (Reference catalogItemReference : catalogItems.getCatalogItems()) { - checkReferenceType(catalogItemReference); - } + for (Reference catalogItemReference : catalog.getCatalogItems()) { + checkReferenceType(catalogItemReference, VCloudDirectorMediaType.CATALOG_ITEM); } // NOTE isPublished cannot be checked @@ -695,16 +685,9 @@ public class Checks { if (params.isSharedToEveryone()) { assertNotNull(params.getEveryoneAccessLevel(), String.format(OBJ_FIELD_REQ, "ControlAccessParams", "EveryoneAccessLevel")); } else { - AccessSettings accessSettings = params.getAccessSettings(); - checkAccessSettings(accessSettings); - } - } - - public static void checkAccessSettings(AccessSettings accessSettings) { - if (accessSettings != null && accessSettings.getAccessSettings() != null) { - for (AccessSetting setting : accessSettings.getAccessSettings()) { - checkAccessSetting(setting); - } + for (AccessSetting setting : params.getAccessSettings()) { + checkAccessSetting(setting); + } } } @@ -778,37 +761,19 @@ public class Checks { 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) { // Check optional fields // NOTE nameInSource cannot be checked - if (group.getUsersList() != null) { - checkUsersList(group.getUsersList()); + for (Reference user : group.getUsersList()) { + checkReferenceType(user, VCloudDirectorMediaType.USER); } if (group.getRole() != null) { - checkReferenceType(group.getRole()); + checkReferenceType(group.getRole(), VCloudDirectorMediaType.ROLE); } // parent type 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) { // Check optional fields diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminCatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminCatalogClientExpectTest.java index 9921d41933..3ce56c12fc 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminCatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminCatalogClientExpectTest.java @@ -25,7 +25,6 @@ import java.net.URI; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; 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.CatalogItems; 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.PublishCatalogParams; @@ -37,7 +36,7 @@ import org.testng.annotations.Test; 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 */ @@ -289,8 +288,6 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx .build()) .build()) .build()) - .catalogItems(CatalogItems.builder() - .build()) .isPublished(false) .build(); } @@ -337,27 +334,25 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx .build()) .description("Testing") .owner(owner()) - .catalogItems(CatalogItems.builder() - .item(Reference.builder() - .type("application/vnd.vmware.vcloud.catalogItem+xml") - .name("image") - .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/67a469a1-aafe-4b5b-bb31-a6202ad8961f")) - .build()) - .item(Reference.builder() - .type("application/vnd.vmware.vcloud.catalogItem+xml") - .name("ubuntu10") - .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df")) - .build()) - .item(Reference.builder() - .type("application/vnd.vmware.vcloud.catalogItem+xml") - .name("imageTesting") - .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a9e0afdb-a42b-4688-8409-2ac68cf22939")) - .build()) - .item(Reference.builder() - .type("application/vnd.vmware.vcloud.catalogItem+xml") - .name("TestCase") - .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/f7598606-aea4-41d7-8f67-2090e28e7876")) - .build()) + .item(Reference.builder() + .type("application/vnd.vmware.vcloud.catalogItem+xml") + .name("image") + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/67a469a1-aafe-4b5b-bb31-a6202ad8961f")) + .build()) + .item(Reference.builder() + .type("application/vnd.vmware.vcloud.catalogItem+xml") + .name("ubuntu10") + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df")) + .build()) + .item(Reference.builder() + .type("application/vnd.vmware.vcloud.catalogItem+xml") + .name("imageTesting") + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a9e0afdb-a42b-4688-8409-2ac68cf22939")) + .build()) + .item(Reference.builder() + .type("application/vnd.vmware.vcloud.catalogItem+xml") + .name("TestCase") + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/f7598606-aea4-41d7-8f67-2090e28e7876")) .build()) .isPublished(false) .build(); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientExpectTest.java index f2cd65ddf8..a98e91110d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientExpectTest.java @@ -25,10 +25,7 @@ import java.net.URI; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; 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.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.Networks; 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.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.Reference; 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.testng.annotations.Test; /** - * Test the {@link GroupClient} by observing its side effects. + * Test the {@link AdminOrgClient} by observing its side effects. * * @author danikov */ @@ -126,7 +121,6 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect .fullName("JClouds") .isEnabled(true) .settings(settings()) - .users(UsersList.builder() .user(Reference.builder() .type("application/vnd.vmware.admin.user+xml") .name("adam.lowe@cloudsoftcorp.com") @@ -152,10 +146,6 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect .name("adk@cloudsoftcorp.com") .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9")) .build()) - .build()) - .groups(GroupsList.builder() - .build()) - .catalogs(CatalogsList.builder() .catalog(Reference.builder() .type("application/vnd.vmware.admin.catalog+xml") .name("QunyingTestCatalog") @@ -176,15 +166,11 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect .name("test") .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/b7289d54-4ca4-497f-9a93-2d4afc97e3da")) .build()) - .build()) - .vdcs(Vdcs.builder() .vdc(Reference.builder() .type("application/vnd.vmware.vcloud.vdc+xml") .name("Cluster01-JClouds") .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07")) .build()) - .build()) - .networks(Networks.builder() .network(Reference.builder() .type("application/vnd.vmware.admin.network+xml") .name("ilsolation01-Jclouds") @@ -195,7 +181,6 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect .name("internet01-Jclouds") .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/network/55a677cf-ab3f-48ae-b880-fab90421980c")) .build()) - .build()) .build(); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java index 2d202cdc6a..a1883fedbc 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java @@ -27,7 +27,6 @@ import org.jclouds.http.HttpResponse; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.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.Link; 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); } - @SuppressWarnings("unchecked") public static final CatalogType catalog() { return CatalogType.builder() .name("QunyingTestCatalog") @@ -398,18 +396,16 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT .type("application/vnd.vmware.vcloud.metadata+xml") .href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata")) .build()) - .catalogItems(CatalogItems.builder() - .item(Reference.builder() - .type("application/vnd.vmware.vcloud.catalogItem+xml") - .name("ubuntu10") - .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df")) - .build()) - .item(Reference.builder() - .type("application/vnd.vmware.vcloud.catalogItem+xml") - .name("imageTesting") - .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a9e0afdb-a42b-4688-8409-2ac68cf22939")) - .build()) - .build()) + .item(Reference.builder() + .type("application/vnd.vmware.vcloud.catalogItem+xml") + .name("ubuntu10") + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df")) + .build()) + .item(Reference.builder() + .type("application/vnd.vmware.vcloud.catalogItem+xml") + .name("imageTesting") + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a9e0afdb-a42b-4688-8409-2ac68cf22939")) + .build()) .description("Testing") .isPublished(false) .build(); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java index f076865a66..dd8406b2b6 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java @@ -64,7 +64,6 @@ import java.util.concurrent.TimeUnit; 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.AccessSettings; 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.DeployVAppParams; @@ -325,11 +324,9 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { public void testControlAccessUser() { ControlAccessParams params = ControlAccessParams.builder() .notSharedToEveryone() - .accessSettings(AccessSettings.builder() - .accessSetting(AccessSetting.builder() - .subject(Reference.builder().href(userURI).type(ADMIN_USER).build()) - .accessLevel("ReadOnly") - .build()) + .accessSetting(AccessSetting.builder() + .subject(Reference.builder().href(userURI).type(ADMIN_USER).build()) + .accessLevel("ReadOnly") .build()) .build();