From c8148751ffd281964dccbfa8dc306840dfb34047 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Thu, 9 Feb 2012 03:17:17 +0000 Subject: [PATCH] Added CatalogClient domain objects --- .../vcloud/director/v1_5/domain/Catalog.java | 239 ++++++++++++++++++ .../director/v1_5/domain/CatalogItem.java | 220 ++++++++++++++++ .../director/v1_5/domain/CatalogItems.java | 113 +++++++++ .../director/v1_5/domain/CatalogsList.java | 113 +++++++++ .../vcloud/director/v1_5/domain/Property.java | 126 +++++++++ 5 files changed, 811 insertions(+) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Property.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java new file mode 100644 index 0000000000..ee6cc24be7 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java @@ -0,0 +1,239 @@ +/* + * 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.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*; + +import java.net.URI; +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.collect.Sets; + +/** + * Container for references to VappTemplate and Media objects. + * + *
+ * <complexType name="CatalogType" />
+ * 
+ * + * @author grkvlt@apache.org + */ +@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Catalog") +public class Catalog extends EntityType { + + public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG; + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder().fromCatalog(this); + } + + public static class Builder extends EntityType.Builder { + + private Entity owner; + private CatalogItems catalogItems; + private Boolean isPublished; + + /** + * @see Catalog#getOwner() + */ + public Builder owner(Entity owner) { + this.owner = owner; + return this; + } + + /** + * @see Catalog#getCatalogItems() + */ + public Builder catalogItems(CatalogItems catalogItems) { + this.catalogItems = catalogItems; + return this; + } + + /** + * @see Catalog#isPublished() + */ + public Builder isPublished(Boolean isPublished) { + this.isPublished = isPublished; + return this; + } + + /** + * @see Catalog#isPublished() + */ + public Builder published() { + this.isPublished = Boolean.TRUE; + return this; + } + + @Override + public Catalog build() { + Catalog catalog = new Catalog(href, name); + catalog.setOwner(owner); + catalog.setCatalogItems(catalogItems); + catalog.setIsPublished(isPublished); + catalog.setDescription(description); + catalog.setId(id); + catalog.setType(type); + catalog.setLinks(links); + catalog.setTasksInProgress(tasksInProgress); + return catalog; + } + + /** + * @see EntityType#getName() + */ + @Override + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see EntityType#getDescription() + */ + @Override + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see EntityType#getId() + */ + @Override + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see EntityType#getTasksInProgress() + */ + @Override + public Builder tasksInProgress(TasksInProgress tasksInProgress) { + this.tasksInProgress = tasksInProgress; + return this; + } + + /** + * @see ReferenceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ReferenceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder link(Link link) { + this.links.add(checkNotNull(link, "link")); + return this; + } + + @Override + public Builder fromEntityType(EntityType in) { + return Builder.class.cast(super.fromEntityType(in)); + } + + public Builder fromCatalog(Catalog in) { + return fromEntityType(in).owner(in.getOwner()).catalogItems(in.getCatalogItems()).isPublished(in.isPublished()); + } + } + + private Catalog() { + // For JAXB and builder use + } + + private Catalog(URI href, String name) { + super(href, name); + } + + @XmlElement(name = "Owner") + private Entity owner; + @XmlElement(name = "CatalogItems") + private CatalogItems catalogItems; + @XmlElement(name = "IsPublished") + private Boolean isPublished; + + /** + * Gets the value of the owner property. + */ + public Entity getOwner() { + return owner; + } + + public void setOwner(Entity value) { + this.owner = value; + } + + /** + * Gets the value of the catalogItems property. + */ + public CatalogItems getCatalogItems() { + return catalogItems; + } + + public void setCatalogItems(CatalogItems value) { + this.catalogItems = value; + } + + /** + * Gets the value of the isPublished property. + */ + public Boolean isPublished() { + return isPublished; + } + + public void setIsPublished(Boolean value) { + this.isPublished = value; + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java new file mode 100644 index 0000000000..f098177137 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java @@ -0,0 +1,220 @@ +/* + * 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.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*; + +import java.net.URI; +import java.util.List; +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.collect.Lists; +import com.google.common.collect.Sets; + +/** + * + * Contains a reference to a VappTemplate or Media object and related metadata. + * + *
+ * <complexType name="CatalogItemType" />
+ * 
+ * + * @author grkvlt@apache.org + */ +@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Catalog") +public class CatalogItem extends EntityType { + + public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG_ITEM; + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder().fromCatalogItem(this); + } + + public static class Builder extends EntityType.Builder { + + private Reference entity; + private List properties = Lists.newArrayList(); + + /** + * @see CatalogItem#getEntity() + */ + public Builder entity(Reference entity) { + this.entity = entity; + return this; + } + + /** + * @see CatalogItem#getProperties() + */ + public Builder properties(List properties) { + this.properties = Lists.newArrayList(checkNotNull(properties, "properties")); + return this; + } + + /** + * @see CatalogItem#getProperties() + */ + public Builder property(Property property) { + this.properties.add(checkNotNull(property, "property")); + return this; + } + + @Override + public CatalogItem build() { + CatalogItem catalog = new CatalogItem(href, name, entity); + catalog.setProperties(properties); + catalog.setDescription(description); + catalog.setId(id); + catalog.setType(type); + catalog.setLinks(links); + catalog.setTasksInProgress(tasksInProgress); + return catalog; + } + + /** + * @see EntityType#getName() + */ + @Override + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see EntityType#getDescription() + */ + @Override + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see EntityType#getId() + */ + @Override + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see EntityType#getTasksInProgress() + */ + @Override + public Builder tasksInProgress(TasksInProgress tasksInProgress) { + this.tasksInProgress = tasksInProgress; + return this; + } + + /** + * @see ReferenceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ReferenceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder link(Link link) { + this.links.add(checkNotNull(link, "link")); + return this; + } + + @Override + public Builder fromEntityType(EntityType in) { + return Builder.class.cast(super.fromEntityType(in)); + } + + public Builder fromCatalogItem(CatalogItem in) { + return fromEntityType(in).entity(in.getEntity()).properties(in.getProperties()); + } + } + + private CatalogItem() { + // For JAXB and builder use + } + + private CatalogItem(URI href, String name, Reference entity) { + super(href, name); + this.entity = entity; + this.setProperties(properties); + } + + @XmlElement(name = "Entity", required = true) + private Reference entity; + @XmlElement(name = "Property") + private List properties = Lists.newArrayList(); + + /** + * Gets the value of the entity property. + */ + public Reference getEntity() { + return entity; + } + + /** + * Gets the value of the properties property. + */ + public List getProperties() { + return this.properties; + } + + public void setProperties(List properties) { + this.properties = Lists.newArrayList(checkNotNull(properties, "properties")); + } + + public void addProperty(Property property) { + this.properties.add(checkNotNull(property, "property")); + } +} 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 new file mode 100644 index 0000000000..7feb6c4e33 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java @@ -0,0 +1,113 @@ +/* + * 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.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*; + +import java.util.Collection; +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 org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; + +import com.google.common.collect.Lists; + +/** + * Represents a list of catalog item references. + * + *
+ * <complexType name="CatalogItemsType" />
+ * 
+ * + * @author grkvlt@apache.org + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(namespace = VCLOUD_1_5_NS, 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 List catalogItems = Lists.newArrayList(); + + /** + * @see CatalogItems#getCatalogItems() + */ + public Builder items(List catalogItems) { + this.catalogItems = Lists.newArrayList(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 and builder use + } + + private CatalogItems(Collection tasks) { + this.catalogItems = Lists.newArrayList(checkNotNull(catalogItems, "catalogItems")); + } + + @XmlElement(name = "CatalogItem") + private List catalogItems = Lists.newArrayList(); + + /** + * Gets the value of the catalogItems property. + */ + public List getCatalogItems() { + return this.catalogItems; + } + + public void setCatalogItems(List catalogItems) { + this.catalogItems = Lists.newArrayList(checkNotNull(catalogItems, "catalogItems")); + } + + public void addCatalogItem(Reference catalogItem) { + this.catalogItems.add(checkNotNull(catalogItem, "catalogItem")); + } +} 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 new file mode 100644 index 0000000000..bb51299197 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java @@ -0,0 +1,113 @@ +/* + * 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.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*; + +import java.util.Collection; +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 org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; + +import com.google.common.collect.Lists; + +/** + * Container for ReferenceType elements that reference catalogs. + * + *
+ * <complexType name="CatalogsListType" />
+ * 
+ * + * @author grkvlt@apache.org + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(namespace = VCLOUD_1_5_NS, 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 List catalogReferences = Lists.newArrayList(); + + /** + * @see CatalogsList#getCatalogItems() + */ + public Builder catalogs(List catalogReferences) { + this.catalogReferences = Lists.newArrayList(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.getCatalogsList()); + } + } + + private CatalogsList() { + // For JAXB and builder use + } + + private CatalogsList(Collection tasks) { + this.catalogReferences = Lists.newArrayList(checkNotNull(catalogReferences, "catalogReferences")); + } + + @XmlElement(name = "CatalogReference") + private List catalogReferences = Lists.newArrayList(); + + /** + * Gets the value of the catalogReferences property. + */ + public List getCatalogsList() { + return this.catalogReferences; + } + + public void setCatalogsList(List catalogReferences) { + this.catalogReferences = Lists.newArrayList(checkNotNull(catalogReferences, "catalogReferences")); + } + + public void addCatalog(Reference catalog) { + this.catalogReferences.add(checkNotNull(catalog, "catalog")); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Property.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Property.java new file mode 100644 index 0000000000..768ebedf8e --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Property.java @@ -0,0 +1,126 @@ +/* + * 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 org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlValue; + +import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; + +/** + * Contains key/value pair as property. + * + *
+ * <complexType name="PropertyType" />
+ * 
+ * + * @author grkvlt@apache.org + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Property") +public class Property { + + public static final String MEDIA_TYPE = VCloudDirectorMediaType.PROPERTY; + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(); + } + + public static class Builder { + + private String value; + private String key; + + /** + * @see Property#getKey() + */ + public Builder key(String key) { + this.key = key; + return this; + } + + /** + * @see Property#getValue() + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * @see Property#getKey() + * @see Property#getValue() + */ + public Builder property(String key, String value) { + this.key = key; + this.value = value; + return this; + } + + public Property build() { + Property property = new Property(key); + property.setValue(value); + return property; + } + + public Builder fromProperty(Property in) { + return property(in.getKey(), in.getValue()); + } + } + + private Property() { + // For JAXB and builder use + } + + private Property(String key) { + this.key = key; + } + + @XmlValue + private String value; + @XmlAttribute(required = true) + private String key; + + /** + * Gets the value of the value property. + */ + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the key property. + */ + public String getKey() { + return key; + } +}