Updates to query client and more domain objects and tests

This commit is contained in:
Andrew Donald Kennedy 2012-02-17 01:14:27 +00:00
parent e764785219
commit 97f4d09778
16 changed files with 1160 additions and 468 deletions

View File

@ -75,10 +75,15 @@ public class VCloudDirectorMediaType {
public static final String QUERY_RESULT_RECORDS = "application/vnd.vmware.vcloud.query.records+xml";
public static final String QUERY_RESULT_REFERENCES = "application/vnd.vmware.vcloud.query.references+xml";
public static final String QUERY_RESULT_ID_RECORDS = "application/vnd.vmware.vcloud.query.idrecords+xml";
public static final List<String> ALL = Arrays.asList(
SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY,
METADATA_VALUE, ORG, TASKS_LIST, TASK, ORG_NETWORK,
CATALOG, CATALOG_ITEM, CATALOG_ITEMS, CATALOGS_LIST, PROPERTY,
MEDIA, OWNER, VDC, ADMIN_USER, QUERY_RESULT_RECORDS
);
SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY,
METADATA_VALUE, ORG, TASKS_LIST, TASK, ORG_NETWORK,
CATALOG, CATALOG_ITEM, CATALOG_ITEMS, CATALOGS_LIST, PROPERTY,
MEDIA, OWNER, VDC, ADMIN_USER, QUERY_RESULT_RECORDS,
QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS
);
}

View File

@ -0,0 +1,97 @@
package org.jclouds.vcloud.director.v1_5.domain;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
import java.net.URI;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "catalogReference")
public class CatalogReference extends ReferenceType<CatalogReference> {
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
@Override
public Builder toBuilder() {
return new Builder().fromCatalogReference(this);
}
public static class Builder extends ReferenceType.Builder<CatalogReference> {
@Override
public CatalogReference build() {
CatalogReference reference = new CatalogReference(href);
reference.setId(id);
reference.setName(name);
reference.setType(type);
return reference;
}
/**
* @see ReferenceType#getHref()
*/
@Override
public Builder href(URI href) {
this.href = href;
return this;
}
/**
* @see ReferenceType#getId()
*/
@Override
public Builder id(String id) {
this.id = id;
return this;
}
/**
* @see ReferenceType#getType()
*/
@Override
public Builder type(String type) {
this.type = type;
return this;
}
/**
* @see ReferenceType#getName()
*/
@Override
public Builder name(String name) {
this.name = name;
return this;
}
@Override
protected Builder fromReferenceType(ReferenceType<CatalogReference> in) {
return Builder.class.cast(super.fromReferenceType(in));
}
protected Builder fromCatalogReference(CatalogReference in) {
return fromReferenceType(in);
}
}
protected CatalogReference(URI href) {
super(href);
}
protected CatalogReference() {
// For JAXB
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Reference that = Reference.class.cast(o);
return super.equals(that);
}
}

View File

@ -51,9 +51,15 @@ public class Link extends ReferenceType<Link> {
public static final String REMOVE = "remove";
public static final String CATALOG_ITEM = "catalogItem";
public static final String TASK_CANCEL = "task:cancel";
public static final String ALTERNATE = "alternate";
public static final String NEXT_PAGE = "nextPage";
public static final String PREVIOUS_PAGE = "previousPage";
public static final String LAST_PAGE = "lastPage";
public static final String FIRST_PAGE = "firstPage";
public static final List<String> ALL = Arrays.asList(
UP, DOWN, EDIT, DELETE, ADD, REMOVE, CATALOG_ITEM, TASK_CANCEL
UP, DOWN, EDIT, DELETE, ADD, REMOVE, CATALOG_ITEM, TASK_CANCEL,
ALTERNATE, NEXT_PAGE, PREVIOUS_PAGE, LAST_PAGE, FIRST_PAGE
);
}

View File

@ -1,4 +1,4 @@
/**
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -16,16 +16,22 @@
* 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.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.collect.Sets;
/**
*
@ -57,16 +63,8 @@ import javax.xml.bind.annotation.XmlType;
@XmlType(name = "ResourceEntity", propOrder = {
"files"
})
@XmlSeeAlso({
MediaType.class,
VAppTemplateType.class,
AbstractVAppType.class,
NetworkPoolType.class
})
public class ResourceEntity
extends EntityType<ResourceEntity>
public class ResourceEntity extends EntityType<ResourceEntity> {
{
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
@ -78,13 +76,13 @@ public class ResourceEntity
public static class Builder extends EntityType.Builder<ResourceEntity> {
private FilesList files;
private Object /* FilesList */ files;
private Integer status;
/**
* @see ResourceEntity#getFiles()
*/
public Builder files(FilesList files) {
public Builder files(Object /* FilesList */ files) {
this.files = files;
return this;
}
@ -172,14 +170,14 @@ public class ResourceEntity
}
}
private ResourceEntity() {
protected ResourceEntity() {
// For JAXB and builder use
}
@XmlElement(name = "Files")
protected FilesList files;
protected Object /* FilesList */ files;
@XmlAttribute
protected Integer status;
@ -191,7 +189,7 @@ public class ResourceEntity
* {@link FilesList }
*
*/
public FilesList getFiles() {
public Object /* FilesList */ getFiles() {
return files;
}
@ -203,7 +201,7 @@ public class ResourceEntity
* {@link FilesList }
*
*/
public void setFiles(FilesList value) {
public void setFiles(Object /* FilesList */ value) {
this.files = value;
}

View File

@ -1,4 +1,4 @@
/**
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -16,14 +16,21 @@
* 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.net.URI;
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.XmlType;
import com.google.common.base.Objects;
import com.google.common.collect.Sets;
/**
*
@ -119,7 +126,7 @@ public class User
private Integer deployedVmQuota;
private Reference role;
private String password;
private GroupsList groupReferences;
private Object /* GroupsList */ groupReferences;
/**
* @see User#getFullName()
@ -260,7 +267,7 @@ public class User
/**
* @see User#getGroupReferences()
*/
public Builder groupReferences(GroupsList groupReferences) {
public Builder groupReferences(Object /* GroupsList */ groupReferences) {
this.groupReferences = groupReferences;
return this;
}
@ -353,16 +360,16 @@ public class User
.fullName(in.getFullName())
.emailAddress(in.getEmailAddress())
.telephone(in.getTelephone())
.isEnabled(in.getIsEnabled())
.isLocked(in.getIsLocked())
.im(in.getIm())
.isEnabled(in.isEnabled())
.isLocked(in.isLocked())
.im(in.getIM())
.nameInSource(in.getNameInSource())
.isAlertEnabled(in.getIsAlertEnabled())
.isAlertEnabled(in.isAlertEnabled())
.alertEmailPrefix(in.getAlertEmailPrefix())
.alertEmail(in.getAlertEmail())
.isExternal(in.getIsExternal())
.isDefaultCached(in.getIsDefaultCached())
.isGroupRole(in.getIsGroupRole())
.isExternal(in.isExternal())
.isDefaultCached(in.isDefaultCached())
.isGroupRole(in.isGroupRole())
.storedVmQuota(in.getStoredVmQuota())
.deployedVmQuota(in.getDeployedVmQuota())
.role(in.getRole())
@ -415,7 +422,7 @@ public class User
@XmlElement(name = "Password")
protected String password;
@XmlElement(name = "GroupReferences")
protected GroupsList groupReferences;
protected Object /* GroupsList */ groupReferences;
/**
* Gets the value of the fullName property.
@ -497,7 +504,7 @@ public class User
* {@link Boolean }
*
*/
public Boolean isIsEnabled() {
public Boolean isEnabled() {
return isEnabled;
}
@ -521,7 +528,7 @@ public class User
* {@link Boolean }
*
*/
public Boolean isIsLocked() {
public Boolean isLocked() {
return isLocked;
}
@ -593,7 +600,7 @@ public class User
* {@link Boolean }
*
*/
public Boolean isIsAlertEnabled() {
public Boolean isAlertEnabled() {
return isAlertEnabled;
}
@ -665,7 +672,7 @@ public class User
* {@link Boolean }
*
*/
public Boolean isIsExternal() {
public Boolean isExternal() {
return isExternal;
}
@ -689,7 +696,7 @@ public class User
* {@link Boolean }
*
*/
public Boolean isIsDefaultCached() {
public Boolean isDefaultCached() {
return isDefaultCached;
}
@ -713,7 +720,7 @@ public class User
* {@link Boolean }
*
*/
public Boolean isIsGroupRole() {
public Boolean isGroupRole() {
return isGroupRole;
}
@ -833,7 +840,7 @@ public class User
* {@link GroupsList }
*
*/
public GroupsList getGroupReferences() {
public Object /* GroupsList */ getGroupReferences() {
return groupReferences;
}
@ -845,7 +852,7 @@ public class User
* {@link GroupsList }
*
*/
public void setGroupReferences(GroupsList value) {
public void setGroupReferences(Object /* GroupsList */ value) {
this.groupReferences = value;
}

View File

@ -0,0 +1,152 @@
/**
* 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.query;
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.XmlRootElement;
import org.jclouds.vcloud.director.v1_5.domain.CatalogReference;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import com.google.common.collect.Sets;
/**
* Represents the results from a vCloud query as references.
*
* <pre>
* &lt;complexType name="QueryResultReferences" /&gt;
* </pre>
*
* @author grkvlt@apache.org
*/
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "CatalogReferences")
public class CatalogReferences extends QueryResultReferences<CatalogReference> {
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
@Override
public Builder toBuilder() {
return new Builder().fromQueryResultReferences(this);
}
public static class Builder extends QueryResultReferences.Builder<CatalogReference> {
@Override
public CatalogReferences build() {
CatalogReferences queryResultReferences = new CatalogReferences(href);
queryResultReferences.setReferences(references);
queryResultReferences.setName(name);
queryResultReferences.setPage(page);
queryResultReferences.setPageSize(pageSize);
queryResultReferences.setTotal(total);
queryResultReferences.setType(type);
queryResultReferences.setLinks(links);
return queryResultReferences;
}
/**
* @see Container#getName()
*/
@Override
public Builder name(String name) {
this.name = name;
return this;
}
/**
* @see Container#getPage()
*/
@Override
public Builder page(Integer page) {
this.page = page;
return this;
}
/**
* @see Container#getPageSize()
*/
@Override
public Builder pageSize(Integer pageSize) {
this.pageSize = pageSize;
return this;
}
/**
* @see ResourceType#getHref()
*/
@Override
public Builder href(URI href) {
super.href(href);
return this;
}
/**
* @see ResourceType#getType()
*/
@Override
public Builder type(String type) {
super.type(type);
return this;
}
/**
* @see ResourceType#getLinks()
*/
@Override
public Builder links(Set<Link> links) {
super.links(Sets.newLinkedHashSet(checkNotNull(links, "links")));
return this;
}
/**
* @see ResourceType#getLinks()
*/
@Override
public Builder link(Link link) {
super.link(link);
return this;
}
@Override
public Builder fromQueryResultReferences(QueryResultReferences<CatalogReference> in) {
return Builder.class.cast(super.fromContainerType(in));
}
public Builder fromCatalogReferences(CatalogReferences in) {
return Builder.class.cast(fromQueryResultReferences(in).references(in.getReferences()));
}
}
protected CatalogReferences() {
// For JAXB and builder use
}
protected CatalogReferences(URI href) {
super(href);
}
}

View File

@ -0,0 +1,98 @@
/*
* 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.query;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects.ToStringHelper;
/**
*
* Container for the list of typed queries available to the
* requesting user.
*
*
* <p>Java class for QueryList complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="QueryList">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}ContainerType">
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlType(name = "QueryList")
public class QueryList extends ContainerType<QueryList> {
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromQueryList(this);
}
public static class Builder extends ContainerType.Builder<QueryList> {
public QueryList build() {
QueryList queryList = new QueryList();
return queryList;
}
@Override
public Builder fromContainerType(ContainerType<QueryList> in) {
return Builder.class.cast(super.fromContainerType(in));
}
public Builder fromQueryList(QueryList in) {
return fromContainerType(in);
}
}
private QueryList() {
// For JAXB and builder use
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
QueryList that = QueryList.class.cast(o);
return super.equals(that) ;
}
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public ToStringHelper string() {
return super.string();
}
}

View File

@ -21,12 +21,14 @@ package org.jclouds.vcloud.director.v1_5.domain.query;
import static com.google.common.base.Objects.*;
import static com.google.common.base.Preconditions.*;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
import java.net.URI;
import java.util.Date;
import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import org.jclouds.vcloud.director.v1_5.domain.Link;
@ -44,6 +46,7 @@ import com.google.common.collect.Sets;
*
* @author grkvlt@apache.org
*/
@XmlRootElement(name = "CatalogRecord", namespace = VCLOUD_1_5_NS)
public class QueryResultCatalogRecord extends QueryResultRecordType<QueryResultCatalogRecord> {
@SuppressWarnings("unchecked")
@ -66,7 +69,7 @@ public class QueryResultCatalogRecord extends QueryResultRecordType<QueryResultC
private String ownerName;
private Integer numberOfVAppTemplates;
private Integer numberOfMedia;
private String owner;
private URI owner;
/**
* @see QueryResultCatalogRecord#getName()
@ -167,7 +170,7 @@ public class QueryResultCatalogRecord extends QueryResultRecordType<QueryResultC
/**
* @see QueryResultCatalogRecord#getOwner()
*/
public Builder owner(String owner) {
public Builder owner(URI owner) {
this.owner = owner;
return this;
}
@ -272,7 +275,7 @@ public class QueryResultCatalogRecord extends QueryResultRecordType<QueryResultC
@XmlAttribute
protected Integer numberOfMedia;
@XmlAttribute
protected String owner;
protected URI owner;
/**
* Gets the value of the name property.
@ -365,11 +368,11 @@ public class QueryResultCatalogRecord extends QueryResultRecordType<QueryResultC
/**
* Gets the value of the owner property.
*/
public String getOwner() {
public URI getOwner() {
return owner;
}
public void setOwner(String value) {
public void setOwner(URI value) {
this.owner = value;
}

View File

@ -33,6 +33,7 @@ import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.namespace.QName;
import org.jclouds.vcloud.director.v1_5.domain.Link;
@ -51,6 +52,10 @@ import com.google.common.collect.Sets;
* @author grkvlt@apache.org
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlSeeAlso({
QueryResultCatalogRecord.class,
QueryResultNetworkRecord.class,
})
public class QueryResultRecordType<T extends QueryResultRecordType<T>> {
public static <T extends QueryResultRecordType<T>> Builder<T> builder() {

View File

@ -28,10 +28,10 @@ import java.util.List;
import java.util.Set;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.query.ContainerType.Builder;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
@ -47,28 +47,28 @@ import com.google.common.collect.Sets;
*
* @author grkvlt@apache.org
*/
public class QueryResultRecords extends ContainerType<QueryResultRecords> {
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "QueryResultRecords")
public class QueryResultRecords<T extends QueryResultRecordType<T>> extends ContainerType<QueryResultRecords<T>> {
public static final String MEDIA_TYPE = VCloudDirectorMediaType.QUERY_RESULT_RECORDS;
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
public static <T extends QueryResultRecordType<T>> Builder<T> builder() {
return new Builder<T>();
}
@Override
public Builder toBuilder() {
return new Builder().fromQueryResultRecords(this);
public Builder<T> toBuilder() {
return new Builder<T>().fromQueryResultRecords(this);
}
public static class Builder extends ContainerType.Builder<QueryResultRecords> {
public static class Builder<T extends QueryResultRecordType<T>> extends ContainerType.Builder<QueryResultRecords<T>> {
private List<QueryResultRecordType<?>> records = Lists.newArrayList();
private List<T> records = Lists.newArrayList();
/**
* @see QueryResultRecords#getRecords()
*/
public Builder records(List<QueryResultRecordType<?>> records) {
public Builder<T> records(List<T> records) {
this.records = records;
return this;
}
@ -76,14 +76,14 @@ public class QueryResultRecords extends ContainerType<QueryResultRecords> {
/**
* @see QueryResultRecords#getRecords()
*/
public Builder record(QueryResultRecordType<?> record) {
public Builder<T> record(T record) {
this.records.add(record);
return this;
}
@Override
public QueryResultRecords build() {
QueryResultRecords queryResultRecords = new QueryResultRecords(href);
public QueryResultRecords<T> build() {
QueryResultRecords<T> queryResultRecords = new QueryResultRecords<T>(href);
queryResultRecords.setRecords(records);
queryResultRecords.setName(name);
queryResultRecords.setPage(page);
@ -95,37 +95,46 @@ public class QueryResultRecords extends ContainerType<QueryResultRecords> {
}
/**
* @see Container#getName()
* @see ContainerType#getName()
*/
@Override
public Builder name(String name) {
public Builder<T> name(String name) {
this.name = name;
return this;
}
/**
* @see Container#getPage()
* @see ContainerType#getPage()
*/
@Override
public Builder page(Integer page) {
public Builder<T> page(Integer page) {
this.page = page;
return this;
}
/**
* @see Container#getPageSize()
* @see ContainerType#getPageSize()
*/
@Override
public Builder pageSize(Integer pageSize) {
public Builder<T> pageSize(Integer pageSize) {
this.pageSize = pageSize;
return this;
}
/**
* @see ContainerType#getTotal()
*/
@Override
public Builder<T> total(Long total) {
this.total = total;
return this;
}
/**
* @see ResourceType#getHref()
*/
@Override
public Builder href(URI href) {
public Builder<T> href(URI href) {
super.href(href);
return this;
}
@ -134,7 +143,7 @@ public class QueryResultRecords extends ContainerType<QueryResultRecords> {
* @see ResourceType#getType()
*/
@Override
public Builder type(String type) {
public Builder<T> type(String type) {
super.type(type);
return this;
}
@ -143,7 +152,7 @@ public class QueryResultRecords extends ContainerType<QueryResultRecords> {
* @see ResourceType#getLinks()
*/
@Override
public Builder links(Set<Link> links) {
public Builder<T> links(Set<Link> links) {
super.links(Sets.newLinkedHashSet(checkNotNull(links, "links")));
return this;
}
@ -152,40 +161,44 @@ public class QueryResultRecords extends ContainerType<QueryResultRecords> {
* @see ResourceType#getLinks()
*/
@Override
public Builder link(Link link) {
public Builder<T> link(Link link) {
super.link(link);
return this;
}
@Override
public Builder fromContainerType(ContainerType<QueryResultRecords> in) {
public Builder<T> fromContainerType(ContainerType<QueryResultRecords<T>> in) {
return Builder.class.cast(super.fromContainerType(in));
}
public Builder fromQueryResultRecords(QueryResultRecords in) {
public Builder<T> fromQueryResultRecords(QueryResultRecords<T> in) {
return fromContainerType(in).records(in.getRecords());
}
}
private QueryResultRecords() {
protected QueryResultRecords() {
// For JAXB and builder use
}
@XmlElementRef(name = "Record", namespace = VCLOUD_1_5_NS)
protected List<QueryResultRecordType<?>> records;
protected QueryResultRecords(URI href) {
super(href);
}
@XmlElementRef
protected List<T> records;
/**
* Set of records representing query results.
*/
public List<QueryResultRecordType<?>> getRecords() {
public List<T> getRecords() {
return records;
}
public void setRecords(List<QueryResultRecordType<?>> links) {
this.records = Lists.newArrayList(checkNotNull(links, "links"));
public void setRecords(List<T> records) {
this.records = Lists.newArrayList(checkNotNull(records, "records"));
}
public void addRecords(QueryResultRecordType<?> record) {
public void addRecords(T record) {
this.records.add(checkNotNull(record, "record"));
}
@ -195,7 +208,7 @@ public class QueryResultRecords extends ContainerType<QueryResultRecords> {
return true;
if (o == null || getClass() != o.getClass())
return false;
QueryResultRecords that = QueryResultRecords.class.cast(o);
QueryResultRecords<T> that = QueryResultRecords.class.cast(o);
return super.equals(that) && equal(this.records, that.records);
}

View File

@ -0,0 +1,215 @@
/**
* 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.query;
import static com.google.common.base.Objects.*;
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.XmlElementRef;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
/**
* Represents the results from a vCloud query as references.
*
* <pre>
* &lt;complexType name="QueryResultReferences" /&gt;
* </pre>
*
* @author grkvlt@apache.org
*/
public class QueryResultReferences<T extends ReferenceType<T>> extends ContainerType<QueryResultReferences<T>> {
public static final String MEDIA_TYPE = VCloudDirectorMediaType.QUERY_RESULT_REFERENCES;
public static <T extends ReferenceType<T>> Builder<T> builder() {
return new Builder<T>();
}
@Override
public Builder<T> toBuilder() {
return new Builder<T>().fromQueryResultReferences(this);
}
public static class Builder<T extends ReferenceType<T>> extends ContainerType.Builder<QueryResultReferences<T>> {
protected List<T> references = Lists.newArrayList();
/**
* @see QueryResultReferences#getReferences()
*/
public Builder<T> references(List<T> references) {
this.references = references;
return this;
}
/**
* @see QueryResultReferences#getReferences()
*/
public Builder<T> reference(T reference) {
this.references.add(reference);
return this;
}
@Override
public QueryResultReferences<T> build() {
QueryResultReferences<T> queryResultReferences = new QueryResultReferences<T>(href);
queryResultReferences.setReferences(references);
queryResultReferences.setName(name);
queryResultReferences.setPage(page);
queryResultReferences.setPageSize(pageSize);
queryResultReferences.setTotal(total);
queryResultReferences.setType(type);
queryResultReferences.setLinks(links);
return queryResultReferences;
}
/**
* @see Container#getName()
*/
@Override
public Builder<T> name(String name) {
this.name = name;
return this;
}
/**
* @see Container#getPage()
*/
@Override
public Builder<T> page(Integer page) {
this.page = page;
return this;
}
/**
* @see Container#getPageSize()
*/
@Override
public Builder<T> pageSize(Integer pageSize) {
this.pageSize = pageSize;
return this;
}
/**
* @see ResourceType#getHref()
*/
@Override
public Builder<T> href(URI href) {
super.href(href);
return this;
}
/**
* @see ResourceType#getType()
*/
@Override
public Builder<T> type(String type) {
super.type(type);
return this;
}
/**
* @see ResourceType#getLinks()
*/
@Override
public Builder<T> links(Set<Link> links) {
super.links(Sets.newLinkedHashSet(checkNotNull(links, "links")));
return this;
}
/**
* @see ResourceType#getLinks()
*/
@Override
public Builder<T> link(Link link) {
super.link(link);
return this;
}
@Override
public Builder<T> fromContainerType(ContainerType<QueryResultReferences<T>> in) {
return Builder.class.cast(super.fromContainerType(in));
}
public Builder<T> fromQueryResultReferences(QueryResultReferences<T> in) {
return fromContainerType(in).references(in.getReferences());
}
}
protected QueryResultReferences() {
// For JAXB and builder use
}
protected QueryResultReferences(URI href) {
super(href);
}
@XmlElementRef(name = "Reference", namespace = VCLOUD_1_5_NS)
protected List<T> references;
/**
* Set of references representing query results.
*/
public List<T> getReferences() {
return references;
}
public void setReferences(List<T> references) {
this.references = Lists.newArrayList(checkNotNull(references, "references"));
}
public void addReference(T reference) {
this.references.add(checkNotNull(reference, "reference"));
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
QueryResultReferences<T> that = QueryResultReferences.class.cast(o);
return super.equals(that) && equal(this.references, that.references);
}
@Override
public int hashCode() {
return super.hashCode() + Objects.hashCode(references);
}
@Override
public ToStringHelper string() {
return super.string().add("references", references);
}
}

View File

@ -1,15 +1,26 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.08 at 02:47:44 PM GMT
//
/*
* 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.vapp;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@ -18,18 +29,9 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import com.vmware.vcloud.api.rest.schema.ovf.AnnotationSectionType;
import com.vmware.vcloud.api.rest.schema.ovf.DeploymentOptionSectionType;
import com.vmware.vcloud.api.rest.schema.ovf.DiskSectionType;
import com.vmware.vcloud.api.rest.schema.ovf.EulaSectionType;
import com.vmware.vcloud.api.rest.schema.ovf.InstallSectionType;
import com.vmware.vcloud.api.rest.schema.ovf.NetworkSectionType;
import com.vmware.vcloud.api.rest.schema.ovf.OperatingSystemSectionType;
import com.vmware.vcloud.api.rest.schema.ovf.ProductSectionType;
import com.vmware.vcloud.api.rest.schema.ovf.ResourceAllocationSectionType;
import com.vmware.vcloud.api.rest.schema.ovf.SectionType;
import com.vmware.vcloud.api.rest.schema.ovf.StartupSectionType;
import com.vmware.vcloud.api.rest.schema.ovf.VirtualHardwareSectionType;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity;
/**
@ -63,115 +65,109 @@ import com.vmware.vcloud.api.rest.schema.ovf.VirtualHardwareSectionType;
"vAppParent",
"section"
})
@XmlSeeAlso({
VmType.class,
VAppType.class
})
public abstract class AbstractVAppType
extends ResourceEntityType
{
public abstract class AbstractVAppType extends ResourceEntity {
@XmlElement(name = "VAppParent")
protected ReferenceType vAppParent;
@XmlElementRef(name = "Section", namespace = "http://schemas.dmtf.org/ovf/envelope/1", type = JAXBElement.class)
protected List<JAXBElement<? extends SectionType>> section;
@XmlAttribute
protected Boolean deployed;
/**
* Gets the value of the vAppParent property.
*
* @return
* possible object is
* {@link ReferenceType }
*
*/
public ReferenceType getVAppParent() {
return vAppParent;
}
/**
* Sets the value of the vAppParent property.
*
* @param value
* allowed object is
* {@link ReferenceType }
*
*/
public void setVAppParent(ReferenceType value) {
this.vAppParent = value;
}
/**
*
* Specific ovf:Section with additional information for the vApp.
* Gets the value of the section 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 section property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getSection().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link JAXBElement }{@code <}{@link SectionType }{@code >}
* {@link JAXBElement }{@code <}{@link VirtualHardwareSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link LeaseSettingsSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link EulaSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link RuntimeInfoSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link AnnotationSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link DeploymentOptionSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link StartupSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link ResourceAllocationSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link NetworkConnectionSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link CustomizationSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link ProductSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link GuestCustomizationSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link OperatingSystemSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link NetworkConfigSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link NetworkSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link DiskSectionType }{@code >}
* {@link JAXBElement }{@code <}{@link InstallSectionType }{@code >}
*
*
*/
public List<JAXBElement<? extends SectionType>> getSection() {
if (section == null) {
section = new ArrayList<JAXBElement<? extends SectionType>>();
}
return this.section;
}
/**
* Gets the value of the deployed property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isDeployed() {
return deployed;
}
/**
* Sets the value of the deployed property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setDeployed(Boolean value) {
this.deployed = value;
}
// @XmlElement(name = "VAppParent")
// protected ReferenceType vAppParent;
// @XmlElementRef(name = "Section", namespace = "http://schemas.dmtf.org/ovf/envelope/1", type = JAXBElement.class)
// protected List<JAXBElement<? extends SectionType>> section;
// @XmlAttribute
// protected Boolean deployed;
//
// /**
// * Gets the value of the vAppParent property.
// *
// * @return
// * possible object is
// * {@link ReferenceType }
// *
// */
// public ReferenceType getVAppParent() {
// return vAppParent;
// }
//
// /**
// * Sets the value of the vAppParent property.
// *
// * @param value
// * allowed object is
// * {@link ReferenceType }
// *
// */
// public void setVAppParent(ReferenceType value) {
// this.vAppParent = value;
// }
//
// /**
// *
// * Specific ovf:Section with additional information for the vApp.
// * Gets the value of the section 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 section property.
// *
// * <p>
// * For example, to add a new item, do as follows:
// * <pre>
// * getSection().add(newItem);
// * </pre>
// *
// *
// * <p>
// * Objects of the following type(s) are allowed in the list
// * {@link JAXBElement }{@code <}{@link SectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link VirtualHardwareSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link LeaseSettingsSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link EulaSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link RuntimeInfoSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link AnnotationSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link DeploymentOptionSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link StartupSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link ResourceAllocationSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link NetworkConnectionSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link CustomizationSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link ProductSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link GuestCustomizationSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link OperatingSystemSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link NetworkConfigSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link NetworkSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link DiskSectionType }{@code >}
// * {@link JAXBElement }{@code <}{@link InstallSectionType }{@code >}
// *
// *
// */
// public List<JAXBElement<? extends SectionType>> getSection() {
// if (section == null) {
// section = new ArrayList<JAXBElement<? extends SectionType>>();
// }
// return this.section;
// }
//
// /**
// * Gets the value of the deployed property.
// *
// * @return
// * possible object is
// * {@link Boolean }
// *
// */
// public Boolean isDeployed() {
// return deployed;
// }
//
// /**
// * Sets the value of the deployed property.
// *
// * @param value
// * allowed object is
// * {@link Boolean }
// *
// */
// public void setDeployed(Boolean value) {
// this.deployed = value;
// }
}

View File

@ -1,4 +1,4 @@
/**
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -16,15 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain.vapp;
import static com.google.common.base.Objects.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import org.jclouds.vcloud.director.v1_5.domain.Owner;
import com.google.common.base.Objects;
/**
*
@ -59,221 +63,219 @@ import javax.xml.bind.annotation.XmlType;
"inMaintenanceMode",
"children"
})
public class VApp
extends AbstractVAppType<VApp>
{
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromVApp(this);
}
public static class Builder extends AbstractVAppType.Builder<VApp> {
private Owner owner;
private Boolean inMaintenanceMode;
private VAppChildren children;
private Boolean ovfDescriptorUploaded;
/**
* @see VApp#getOwner()
*/
public Builder owner(Owner owner) {
this.owner = owner;
return this;
}
/**
* @see VApp#getInMaintenanceMode()
*/
public Builder inMaintenanceMode(Boolean inMaintenanceMode) {
this.inMaintenanceMode = inMaintenanceMode;
return this;
}
/**
* @see VApp#getChildren()
*/
public Builder children(VAppChildren children) {
this.children = children;
return this;
}
/**
* @see VApp#getOvfDescriptorUploaded()
*/
public Builder ovfDescriptorUploaded(Boolean ovfDescriptorUploaded) {
this.ovfDescriptorUploaded = ovfDescriptorUploaded;
return this;
}
public VApp build() {
VApp vApp = new VApp();
vApp.setOwner(owner);
vApp.setInMaintenanceMode(inMaintenanceMode);
vApp.setChildren(children);
vApp.setOvfDescriptorUploaded(ovfDescriptorUploaded);
return vApp;
}
@Override
public Builder fromAbstractVAppType(AbstractVAppType<VApp> in) {
return Builder.class.cast(super.fromAbstractVAppType(in));
}
public Builder fromVApp(VApp in) {
return fromAbstractVAppType(in)
.owner(in.getOwner())
.inMaintenanceMode(in.getInMaintenanceMode())
.children(in.getChildren())
.ovfDescriptorUploaded(in.getOvfDescriptorUploaded());
}
}
private VApp() {
// For JAXB and builder use
}
@XmlElement(name = "Owner")
protected Owner owner;
@XmlElement(name = "InMaintenanceMode")
protected Boolean inMaintenanceMode;
@XmlElement(name = "Children")
protected VAppChildren children;
@XmlAttribute
protected Boolean ovfDescriptorUploaded;
/**
* Gets the value of the owner property.
*
* @return
* possible object is
* {@link Owner }
*
*/
public Owner getOwner() {
return owner;
}
/**
* Sets the value of the owner property.
*
* @param value
* allowed object is
* {@link Owner }
*
*/
public void setOwner(Owner value) {
this.owner = value;
}
/**
* Gets the value of the inMaintenanceMode property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isInMaintenanceMode() {
return inMaintenanceMode;
}
/**
* Sets the value of the inMaintenanceMode property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setInMaintenanceMode(Boolean value) {
this.inMaintenanceMode = value;
}
/**
* Gets the value of the children property.
*
* @return
* possible object is
* {@link VAppChildren }
*
*/
public VAppChildren getChildren() {
return children;
}
/**
* Sets the value of the children property.
*
* @param value
* allowed object is
* {@link VAppChildren }
*
*/
public void setChildren(VAppChildren value) {
this.children = value;
}
/**
* Gets the value of the ovfDescriptorUploaded property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isOvfDescriptorUploaded() {
return ovfDescriptorUploaded;
}
/**
* Sets the value of the ovfDescriptorUploaded property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setOvfDescriptorUploaded(Boolean value) {
this.ovfDescriptorUploaded = value;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
VApp that = VApp.class.cast(o);
return equal(owner, that.owner) &&
equal(inMaintenanceMode, that.inMaintenanceMode) &&
equal(children, that.children) &&
equal(ovfDescriptorUploaded, that.ovfDescriptorUploaded);
}
@Override
public int hashCode() {
return Objects.hashCode(owner,
inMaintenanceMode,
children,
ovfDescriptorUploaded);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("owner", owner)
.add("inMaintenanceMode", inMaintenanceMode)
.add("children", children)
.add("ovfDescriptorUploaded", ovfDescriptorUploaded).toString();
}
public class VApp extends AbstractVAppType {
//
// @SuppressWarnings("unchecked")
// public static Builder builder() {
// return new Builder();
// }
//
// public Builder toBuilder() {
// return new Builder().fromVApp(this);
// }
//
// public static class Builder extends AbstractVAppType.Builder<VApp> {
//
// private Owner owner;
// private Boolean inMaintenanceMode;
// private VAppChildren children;
// private Boolean ovfDescriptorUploaded;
//
// /**
// * @see VApp#getOwner()
// */
// public Builder owner(Owner owner) {
// this.owner = owner;
// return this;
// }
//
// /**
// * @see VApp#getInMaintenanceMode()
// */
// public Builder inMaintenanceMode(Boolean inMaintenanceMode) {
// this.inMaintenanceMode = inMaintenanceMode;
// return this;
// }
//
// /**
// * @see VApp#getChildren()
// */
// public Builder children(VAppChildren children) {
// this.children = children;
// return this;
// }
//
// /**
// * @see VApp#getOvfDescriptorUploaded()
// */
// public Builder ovfDescriptorUploaded(Boolean ovfDescriptorUploaded) {
// this.ovfDescriptorUploaded = ovfDescriptorUploaded;
// return this;
// }
//
//
// public VApp build() {
// VApp vApp = new VApp();
// vApp.setOwner(owner);
// vApp.setInMaintenanceMode(inMaintenanceMode);
// vApp.setChildren(children);
// vApp.setOvfDescriptorUploaded(ovfDescriptorUploaded);
// return vApp;
// }
//
//
// @Override
// public Builder fromAbstractVAppType(AbstractVAppType<VApp> in) {
// return Builder.class.cast(super.fromAbstractVAppType(in));
// }
// public Builder fromVApp(VApp in) {
// return fromAbstractVAppType(in)
// .owner(in.getOwner())
// .inMaintenanceMode(in.getInMaintenanceMode())
// .children(in.getChildren())
// .ovfDescriptorUploaded(in.getOvfDescriptorUploaded());
// }
// }
//
// private VApp() {
// // For JAXB and builder use
// }
//
//
//
// @XmlElement(name = "Owner")
// protected Owner owner;
// @XmlElement(name = "InMaintenanceMode")
// protected Boolean inMaintenanceMode;
// @XmlElement(name = "Children")
// protected VAppChildren children;
// @XmlAttribute
// protected Boolean ovfDescriptorUploaded;
//
// /**
// * Gets the value of the owner property.
// *
// * @return
// * possible object is
// * {@link Owner }
// *
// */
// public Owner getOwner() {
// return owner;
// }
//
// /**
// * Sets the value of the owner property.
// *
// * @param value
// * allowed object is
// * {@link Owner }
// *
// */
// public void setOwner(Owner value) {
// this.owner = value;
// }
//
// /**
// * Gets the value of the inMaintenanceMode property.
// *
// * @return
// * possible object is
// * {@link Boolean }
// *
// */
// public Boolean isInMaintenanceMode() {
// return inMaintenanceMode;
// }
//
// /**
// * Sets the value of the inMaintenanceMode property.
// *
// * @param value
// * allowed object is
// * {@link Boolean }
// *
// */
// public void setInMaintenanceMode(Boolean value) {
// this.inMaintenanceMode = value;
// }
//
// /**
// * Gets the value of the children property.
// *
// * @return
// * possible object is
// * {@link VAppChildren }
// *
// */
// public VAppChildren getChildren() {
// return children;
// }
//
// /**
// * Sets the value of the children property.
// *
// * @param value
// * allowed object is
// * {@link VAppChildren }
// *
// */
// public void setChildren(VAppChildren value) {
// this.children = value;
// }
//
// /**
// * Gets the value of the ovfDescriptorUploaded property.
// *
// * @return
// * possible object is
// * {@link Boolean }
// *
// */
// public Boolean isOvfDescriptorUploaded() {
// return ovfDescriptorUploaded;
// }
//
// /**
// * Sets the value of the ovfDescriptorUploaded property.
// *
// * @param value
// * allowed object is
// * {@link Boolean }
// *
// */
// public void setOvfDescriptorUploaded(Boolean value) {
// this.ovfDescriptorUploaded = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (o == null || getClass() != o.getClass())
// return false;
// VApp that = VApp.class.cast(o);
// return equal(owner, that.owner) &&
// equal(inMaintenanceMode, that.inMaintenanceMode) &&
// equal(children, that.children) &&
// equal(ovfDescriptorUploaded, that.ovfDescriptorUploaded);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(owner,
// inMaintenanceMode,
// children,
// ovfDescriptorUploaded);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper("")
// .add("owner", owner)
// .add("inMaintenanceMode", inMaintenanceMode)
// .add("children", children)
// .add("ovfDescriptorUploaded", ovfDescriptorUploaded).toString();
// }
}

View File

@ -18,59 +18,81 @@
*/
package org.jclouds.vcloud.director.v1_5.features;
import java.net.URI;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.TasksList;
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.OrgReferenceToTaskListEndpoint;
import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import com.google.common.util.concurrent.ListenableFuture;
/**
* @see TaskClient
* @see QueryClient
* @author grkvlt@apache.org
*/
@RequestFilters(AddVCloudAuthorizationToRequest.class)
public interface QueryAsyncClient {
/**
* @see TaskClient#getTaskList(ReferenceType<?>)
* REST API General queries handler.
*/
@GET
@Path("/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<TasksList> getTaskList(@EndpointParam(parser = OrgReferenceToTaskListEndpoint.class) ReferenceType<?> orgRef);
ListenableFuture<QueryResultRecords> query(@QueryParam("type") String type, @QueryParam("filter") String filter);
@GET
@Path("/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords> query(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize,
@QueryParam("format") String format, @QueryParam("type") String type, @QueryParam("filter") String filter);
/**
* @see TaskClient#getTask(URI)
* Retrieves a list of Catalogs by using REST API general QueryHandler.
*/
@GET
@Path("/catalogs/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> getTask(@EndpointParam URI taskUri);
ListenableFuture<QueryResultRecords> catalogsQuery(@QueryParam("filter") String filter);
/**
* @see TaskClient#cancelTask(URI)
*/
@POST
@Path("/action/cancel")
@GET
@Path("/catalogs/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Void> cancelTask(@EndpointParam URI taskUri);
ListenableFuture<QueryResultRecords> catalogsQuery(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize,
@QueryParam("format") String format, @QueryParam("filter") String filter);
@GET
@Path("/catalogs/query")
@Consumes
@DefaultValue("references")
@QueryParam("format")
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<CatalogReferences> catalogReferencesQuery(@QueryParam("filter") String filter);
@GET
@Path("/catalogs/query")
@Consumes
@DefaultValue("references")
@QueryParam("format")
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<CatalogReferences> catalogReferencesQuery(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize,
@QueryParam("filter") String filter);
}

View File

@ -18,13 +18,11 @@
*/
package org.jclouds.vcloud.director.v1_5.features;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.TasksList;
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
/**
* Provides synchronous access to The REST API query interface.
@ -39,10 +37,12 @@ public interface QueryClient {
* REST API General queries handler.
*
* <pre>
* GET /query/
* GET /query
* </pre>
*/
ContainerType query(String queryParams);
QueryResultRecords query(String type, String filter);
QueryResultRecords query(Integer page, Integer pageSize, String format, String type, String filter);
/**
* Retrieves a list of Catalogs by using REST API general QueryHandler.
@ -52,11 +52,15 @@ public interface QueryClient {
* Default format is references.
*
* <pre>
* GET /catalogs/query/
* GET /catalogs/query
* </pre>
*
* @param orgId the unique id for the organization
* @return a list of tasks
*/
ContainerType catalogsQuery(ReferenceType<?> orgRef);
QueryResultRecords catalogsQuery(String filter);
QueryResultRecords catalogsQuery(Integer page, Integer pageSize, String format, String filter);
CatalogReferences catalogReferencesQuery(String filter);
CatalogReferences catalogReferencesQuery(Integer page, Integer pageSize, String filter);
}

View File

@ -25,12 +25,10 @@ import java.net.URI;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Error;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.TasksList;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultCatalogRecord;
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
import org.testng.annotations.Test;
@ -46,7 +44,78 @@ public class QueryClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
@Test
public void testQueryCatalogNoParam() {
assertTrue(true);
HttpRequest queryRequest = HttpRequest.builder()
.method("GET")
.endpoint(URI.create(endpoint + "/catalogs/query?filter="))
.headers(ImmutableMultimap.<String, String> builder()
.put("Accept", "*/*")
.put("x-vcloud-authorization", token)
.build())
.build();
HttpResponse queryResponse= HttpResponse.builder()
.statusCode(200)
.payload(payloadFromResourceWithContentType("/query/allCatalogs.xml", VCloudDirectorMediaType.QUERY_RESULT_RECORDS + ";version=1.5"))
.build();
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse);
QueryResultRecords<QueryResultCatalogRecord> expected = QueryResultRecords.<QueryResultCatalogRecord>builder()
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogs/query?page=1&pageSize=25&format=records"))
.type("application/vnd.vmware.vcloud.query.records+xml")
.name("catalog")
.page(1)
.pageSize(25)
.total(3L)
.link(Link.builder()
.rel("alternate")
.type("application/vnd.vmware.vcloud.query.references+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogs/query?page=1&pageSize=25&format=references"))
.build())
.link(Link.builder()
.rel("alternate")
.type("application/vnd.vmware.vcloud.query.idrecords+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogs/query?page=1&pageSize=25&format=idrecords"))
.build())
.record(QueryResultCatalogRecord.builder()
.ownerName("qunying.huang@enstratus.com")
.owner(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/967d317c-4273-4a95-b8a4-bf63b78e9c69"))
.orgName("JClouds")
.numberOfVAppTemplates(0)
.numberOfMedia(0)
.name("QunyingTestCatalog")
.shared()
.notPublished()
.creationDate(dateService.iso8601DateParse("2012-02-07T00:16:28.323-05:00"))
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
.build())
.record(QueryResultCatalogRecord.builder()
.ownerName("system")
.owner(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/0ebf2453-5e95-48ab-b223-02671965ee91"))
.orgName("Bluelock")
.numberOfVAppTemplates(0)
.numberOfMedia(0)
.name("Public")
.notShared()
.published()
.creationDate(dateService.iso8601DateParse("2011-09-28T13:45:44.207-04:00"))
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c"))
.build())
.record(QueryResultCatalogRecord.builder()
.ownerName("adk@cloudsoftcorp.com")
.owner(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"))
.orgName("JClouds")
.numberOfVAppTemplates(0)
.numberOfMedia(0)
.name("test")
.shared()
.notPublished()
.creationDate(dateService.iso8601DateParse("2012-02-09T12:32:17.723-05:00"))
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/b7289d54-4ca4-497f-9a93-2d4afc97e3da"))
.build())
.build();
assertEquals(client.getQueryClient().catalogsQuery(""), expected);
}
}