removed awkward and unnecessary URISupplier type

This commit is contained in:
Adrian Cole 2012-03-11 10:56:48 -07:00
parent a4b6c0c46e
commit d536af3a95
13 changed files with 31 additions and 102 deletions

View File

@ -43,7 +43,7 @@ import com.google.common.base.Objects.ToStringHelper;
CatalogReference.class, CatalogReference.class,
Reference.class Reference.class
}) })
public class ReferenceType<T extends ReferenceType<T>> implements URISupplier { public class ReferenceType<T extends ReferenceType<T>> {
public static <T extends ReferenceType<T>> Builder<T> builder() { public static <T extends ReferenceType<T>> Builder<T> builder() {
return new Builder<T>(); return new Builder<T>();
@ -176,14 +176,6 @@ public class ReferenceType<T extends ReferenceType<T>> implements URISupplier {
return type; return type;
} }
/**
* @see URISupplier#getURI()
*/
@Override
public URI getURI() {
return getHref();
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) if (this == o)

View File

@ -28,8 +28,6 @@ import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import org.jclouds.vcloud.director.v1_5.domain.EntityType.NewBuilder;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -46,7 +44,7 @@ import com.google.common.collect.Sets;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public abstract class ResourceType<T extends ResourceType<T>> implements URISupplier { public abstract class ResourceType<T extends ResourceType<T>> {
public NewBuilder<?> toNewBuilder() { public NewBuilder<?> toNewBuilder() {
throw new UnsupportedOperationException("New builder not yet implemented for this class"); throw new UnsupportedOperationException("New builder not yet implemented for this class");
@ -179,14 +177,6 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
return href; return href;
} }
/**
* @see URISupplier#getURI()
*/
@Override
public URI getURI() {
return getHref();
}
/** /**
* Contains the type of the the entity. * Contains the type of the the entity.
* <p/> * <p/>

View File

@ -1,47 +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 java.net.URI;
/**
* @author grkvlt@apache.org
*/
public interface URISupplier {
/**
* This returns the {@link URI} for a particular {@link ReferenceType} or {@link ResourceType} object.
*
* @see ResourceType#getHref()
* @see ReferenceType#getHref()
*/
public URI getURI();
public static class SingleURI {
public static URISupplier fromURI(final URI uri) {
return new URISupplier(){
@Override
public URI getURI() {
return uri;
}
};
}
}
}

View File

@ -39,7 +39,6 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;

View File

@ -31,7 +31,6 @@ import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.vcloud.director.v1_5.domain.Task; 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.TasksList;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; 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.OrgReferenceToTaskListEndpoint;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;

View File

@ -26,7 +26,6 @@ import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; 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.Link;
import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.Org;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.features.OrgClient; import org.jclouds.vcloud.director.v1_5.features.OrgClient;
import com.google.common.base.Function; import com.google.common.base.Function;

View File

@ -18,8 +18,6 @@
*/ */
package org.jclouds.vcloud.director.v1_5.predicates; package org.jclouds.vcloud.director.v1_5.predicates;
import java.net.URI;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -27,7 +25,6 @@ import javax.inject.Singleton;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.features.TaskClient; import org.jclouds.vcloud.director.v1_5.features.TaskClient;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -56,7 +53,7 @@ public class TaskSuccess implements Predicate<Task> {
logger.trace("looking for status on task %s", task); logger.trace("looking for status on task %s", task);
// TODO shouldn't we see if it's already done before getting it from API server? // TODO shouldn't we see if it's already done before getting it from API server?
task = taskClient.getTask(task.getURI()); task = taskClient.getTask(task.getHref());
// perhaps task isn't available, yet // perhaps task isn't available, yet
if (task == null) return false; if (task == null) return false;

View File

@ -60,7 +60,7 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
AdminCatalog expected = catalog(); AdminCatalog expected = catalog();
assertEquals(client.getAdminCatalogClient().getCatalog(catalogRef.getURI()), expected); assertEquals(client.getAdminCatalogClient().getCatalog(catalogRef.getHref()), expected);
} }
@Test @Test
@ -77,7 +77,7 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
AdminCatalog expected = modifyCatalog(); AdminCatalog expected = modifyCatalog();
assertEquals(client.getAdminCatalogClient().updateCatalog(catalogRef.getURI(), expected), expected); assertEquals(client.getAdminCatalogClient().updateCatalog(catalogRef.getHref(), expected), expected);
} }
@Test @Test
@ -93,7 +93,7 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
Owner expected = owner(); Owner expected = owner();
assertEquals(client.getAdminCatalogClient().getOwner(catalogRef.getURI()), expected); assertEquals(client.getAdminCatalogClient().getOwner(catalogRef.getHref()), expected);
} }
@Test @Test
@ -116,7 +116,7 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
.build()) .build())
.build(); .build();
client.getAdminCatalogClient().setOwner(catalogRef.getURI(), newOwner); client.getAdminCatalogClient().setOwner(catalogRef.getHref(), newOwner);
} }
@Test @Test
@ -134,7 +134,7 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
.isPublished(true) .isPublished(true)
.build(); .build();
client.getAdminCatalogClient().publishCatalog(catalogRef.getURI(), params); client.getAdminCatalogClient().publishCatalog(catalogRef.getHref(), params);
} }
@Test @Test
@ -147,7 +147,7 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
new VcloudHttpResponsePrimer() new VcloudHttpResponsePrimer()
.httpResponseBuilder().statusCode(204).build()); .httpResponseBuilder().statusCode(204).build());
client.getAdminCatalogClient().deleteCatalog(catalogRef.getURI()); client.getAdminCatalogClient().deleteCatalog(catalogRef.getHref());
} }
public static final AdminCatalog catalog() { public static final AdminCatalog catalog() {

View File

@ -74,7 +74,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
@Test(testName = "GET /admin/catalog/{id}") @Test(testName = "GET /admin/catalog/{id}")
public void testGetCatalog() { public void testGetCatalog() {
assertNotNull(catalogRef, String.format(REF_REQ_LIVE, "Catalog")); assertNotNull(catalogRef, String.format(REF_REQ_LIVE, "Catalog"));
catalog = catalogClient.getCatalog(catalogRef.getURI()); catalog = catalogClient.getCatalog(catalogRef.getHref());
Checks.checkAdminCatalog(catalog); Checks.checkAdminCatalog(catalog);
} }
@ -82,7 +82,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
@Test(testName = "GET /admin/catalog/{id}/owner", @Test(testName = "GET /admin/catalog/{id}/owner",
dependsOnMethods = { "testGetCatalog" }) dependsOnMethods = { "testGetCatalog" })
public void testGetCatalogOwner() { public void testGetCatalogOwner() {
owner = catalogClient.getOwner(catalog.getURI()); owner = catalogClient.getOwner(catalog.getHref());
Checks.checkOwner(owner); Checks.checkOwner(owner);
} }
@ -100,13 +100,13 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
.build(); .build();
try { try {
catalogClient.setOwner(catalog.getURI(), newOwner); catalogClient.setOwner(catalog.getHref(), newOwner);
owner = catalogClient.getOwner(catalog.getURI()); owner = catalogClient.getOwner(catalog.getHref());
Checks.checkOwner(owner); Checks.checkOwner(owner);
assertTrue(equal(owner, newOwner), String.format(OBJ_FIELD_UPDATABLE, CATALOG, "owner")); assertTrue(equal(owner, newOwner), String.format(OBJ_FIELD_UPDATABLE, CATALOG, "owner"));
} finally { } finally {
catalogClient.setOwner(catalog.getURI(), oldOwner); catalogClient.setOwner(catalog.getHref(), oldOwner);
owner = catalogClient.getOwner(catalog.getURI()); owner = catalogClient.getOwner(catalog.getHref());
} }
} }
@ -127,7 +127,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
// .catalogItems(newCatalogItems) // .catalogItems(newCatalogItems)
.build(); .build();
catalog = catalogClient.updateCatalog(catalog.getURI(), catalog); catalog = catalogClient.updateCatalog(catalog.getHref(), catalog);
assertTrue(equal(catalog.getName(), newName), String.format(OBJ_FIELD_UPDATABLE, CATALOG, "name")); assertTrue(equal(catalog.getName(), newName), String.format(OBJ_FIELD_UPDATABLE, CATALOG, "name"));
assertTrue(equal(catalog.getDescription(), newDescription), assertTrue(equal(catalog.getDescription(), newDescription),
@ -144,7 +144,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
// .catalogItems(oldCatalogItems) // .catalogItems(oldCatalogItems)
.build(); .build();
catalog = catalogClient.updateCatalog(catalog.getURI(), catalog); catalog = catalogClient.updateCatalog(catalog.getHref(), catalog);
} }
} }
@ -158,8 +158,8 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
.isPublished(true) .isPublished(true)
.build(); .build();
catalogClient.publishCatalog(catalogRef.getURI(), params); catalogClient.publishCatalog(catalogRef.getHref(), params);
catalog = catalogClient.getCatalog(catalogRef.getURI()); catalog = catalogClient.getCatalog(catalogRef.getHref());
assertTrue(catalog.isPublished(), String.format(OBJ_FIELD_EQ, assertTrue(catalog.isPublished(), String.format(OBJ_FIELD_EQ,
CATALOG, "isPublished", true, catalog.isPublished())); CATALOG, "isPublished", true, catalog.isPublished()));
@ -169,7 +169,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
@Test(testName = "DELETE /admin/catalog/{id}", @Test(testName = "DELETE /admin/catalog/{id}",
dependsOnMethods = { "testPublishCatalog" }, enabled = false ) dependsOnMethods = { "testPublishCatalog" }, enabled = false )
public void testDeleteCatalog() { public void testDeleteCatalog() {
catalogClient.deleteCatalog(catalogRef.getURI()); catalogClient.deleteCatalog(catalogRef.getHref());
Error expected = Error.builder() Error expected = Error.builder()
.message("???") .message("???")
@ -178,7 +178,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
.build(); .build();
try { try {
catalog = catalogClient.getCatalog(catalogRef.getURI()); catalog = catalogClient.getCatalog(catalogRef.getHref());
fail("Should give HTTP 403 error"); fail("Should give HTTP 403 error");
} catch (VCloudDirectorException vde) { } catch (VCloudDirectorException vde) {
assertEquals(vde.getError(), expected); assertEquals(vde.getError(), expected);

View File

@ -56,7 +56,7 @@ public class GroupClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
Group expected = group(); Group expected = group();
assertEquals(client.getGroupClient().getGroup(groupRef.getURI()), expected); assertEquals(client.getGroupClient().getGroup(groupRef.getHref()), expected);
} }
public static final Group group() { public static final Group group() {
@ -79,7 +79,7 @@ public class GroupClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
Group expected = updateGroup(); Group expected = updateGroup();
assertEquals(client.getGroupClient().updateGroup(groupRef.getURI(), expected), expected); assertEquals(client.getGroupClient().updateGroup(groupRef.getHref(), expected), expected);
} }
public static Group updateGroup() { public static Group updateGroup() {
@ -96,6 +96,6 @@ public class GroupClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
new VcloudHttpResponsePrimer() new VcloudHttpResponsePrimer()
.httpResponseBuilder().statusCode(204).build()); .httpResponseBuilder().statusCode(204).build());
client.getAdminCatalogClient().deleteCatalog(groupRef.getURI()); client.getAdminCatalogClient().deleteCatalog(groupRef.getHref());
} }
} }

View File

@ -76,7 +76,7 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /admin/group/{id}", enabled = false) @Test(testName = "GET /admin/group/{id}", enabled = false)
public void testGetGroup() { public void testGetGroup() {
assertNotNull(groupRef, String.format(REF_REQ_LIVE, "Group")); assertNotNull(groupRef, String.format(REF_REQ_LIVE, "Group"));
group = groupClient.getGroup(groupRef.getURI()); group = groupClient.getGroup(groupRef.getHref());
Checks.checkGroup(group); Checks.checkGroup(group);
} }
@ -95,7 +95,7 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
.description(newDescription) .description(newDescription)
.build(); .build();
group = groupClient.updateGroup(group.getURI(), group); group = groupClient.updateGroup(group.getHref(), group);
assertTrue(equal(group.getName(), newName), String.format(OBJ_FIELD_UPDATABLE, GROUP, "name")); assertTrue(equal(group.getName(), newName), String.format(OBJ_FIELD_UPDATABLE, GROUP, "name"));
assertTrue(equal(group.getDescription(), newDescription), assertTrue(equal(group.getDescription(), newDescription),
@ -110,13 +110,13 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
.description(oldDescription) .description(oldDescription)
.build(); .build();
group = groupClient.updateGroup(group.getURI(), group); group = groupClient.updateGroup(group.getHref(), group);
} }
} }
@Test(testName = "DELETE /admin/group/{id}", enabled = false ) @Test(testName = "DELETE /admin/group/{id}", enabled = false )
public void testDeleteCatalog() { public void testDeleteCatalog() {
groupClient.deleteGroup(groupRef.getURI()); groupClient.deleteGroup(groupRef.getHref());
Error expected = Error.builder() Error expected = Error.builder()
.message("???") .message("???")
@ -125,7 +125,7 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
.build(); .build();
try { try {
group = groupClient.getGroup(groupRef.getURI()); group = groupClient.getGroup(groupRef.getHref());
fail("Should give HTTP 403 error"); fail("Should give HTTP 403 error");
} catch (VCloudDirectorException vde) { } catch (VCloudDirectorException vde) {
assertEquals(vde.getError(), expected); assertEquals(vde.getError(), expected);

View File

@ -92,7 +92,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Reference orgRef = Iterables.getFirst(orgList.getOrgs(), null); Reference orgRef = Iterables.getFirst(orgList.getOrgs(), null);
assertNotNull(orgRef); assertNotNull(orgRef);
orgURI = orgRef.getURI(); orgURI = orgRef.getHref();
// Call the method being tested // Call the method being tested
org = orgClient.getOrg(orgURI); org = orgClient.getOrg(orgURI);

View File

@ -92,7 +92,7 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest {
//TODO: upload media or something so you can get a fresh cancellable task? //TODO: upload media or something so you can get a fresh cancellable task?
Task taskRef = Iterables.getFirst(taskList.getTasks(), null); Task taskRef = Iterables.getFirst(taskList.getTasks(), null);
taskURI = taskRef.getURI(); taskURI = taskRef.getHref();
// Call the method being tested // Call the method being tested
task = taskClient.getTask(taskURI); task = taskClient.getTask(taskURI);