mirror of https://github.com/apache/jclouds.git
removed awkward and unnecessary URISupplier type
This commit is contained in:
parent
a4b6c0c46e
commit
d536af3a95
|
@ -43,7 +43,7 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
CatalogReference.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() {
|
||||
return new Builder<T>();
|
||||
|
@ -176,14 +176,6 @@ public class ReferenceType<T extends ReferenceType<T>> implements URISupplier {
|
|||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see URISupplier#getURI()
|
||||
*/
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return getHref();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
|
|
|
@ -28,8 +28,6 @@ import java.util.Set;
|
|||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
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.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -46,7 +44,7 @@ import com.google.common.collect.Sets;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public abstract class ResourceType<T extends ResourceType<T>> implements URISupplier {
|
||||
public abstract class ResourceType<T extends ResourceType<T>> {
|
||||
|
||||
public NewBuilder<?> toNewBuilder() {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see URISupplier#getURI()
|
||||
*/
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return getHref();
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the type of the the entity.
|
||||
* <p/>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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.MetadataValue;
|
||||
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.functions.ThrowVCloudErrorOn4xx;
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.jclouds.rest.annotations.JAXBResponseParser;
|
|||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
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.URISupplier;
|
||||
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.ThrowVCloudErrorOn4xx;
|
||||
|
|
|
@ -26,7 +26,6 @@ import javax.inject.Singleton;
|
|||
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.Org;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
|
||||
import org.jclouds.vcloud.director.v1_5.features.OrgClient;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.predicates;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
@ -27,7 +25,6 @@ import javax.inject.Singleton;
|
|||
import org.jclouds.logging.Logger;
|
||||
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.URISupplier;
|
||||
import org.jclouds.vcloud.director.v1_5.features.TaskClient;
|
||||
|
||||
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);
|
||||
|
||||
// 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
|
||||
if (task == null) return false;
|
||||
|
|
|
@ -60,7 +60,7 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
|
|||
|
||||
AdminCatalog expected = catalog();
|
||||
|
||||
assertEquals(client.getAdminCatalogClient().getCatalog(catalogRef.getURI()), expected);
|
||||
assertEquals(client.getAdminCatalogClient().getCatalog(catalogRef.getHref()), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -77,7 +77,7 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
|
|||
|
||||
AdminCatalog expected = modifyCatalog();
|
||||
|
||||
assertEquals(client.getAdminCatalogClient().updateCatalog(catalogRef.getURI(), expected), expected);
|
||||
assertEquals(client.getAdminCatalogClient().updateCatalog(catalogRef.getHref(), expected), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -93,7 +93,7 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
|
|||
|
||||
Owner expected = owner();
|
||||
|
||||
assertEquals(client.getAdminCatalogClient().getOwner(catalogRef.getURI()), expected);
|
||||
assertEquals(client.getAdminCatalogClient().getOwner(catalogRef.getHref()), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -116,7 +116,7 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
|
|||
.build())
|
||||
.build();
|
||||
|
||||
client.getAdminCatalogClient().setOwner(catalogRef.getURI(), newOwner);
|
||||
client.getAdminCatalogClient().setOwner(catalogRef.getHref(), newOwner);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -134,7 +134,7 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
|
|||
.isPublished(true)
|
||||
.build();
|
||||
|
||||
client.getAdminCatalogClient().publishCatalog(catalogRef.getURI(), params);
|
||||
client.getAdminCatalogClient().publishCatalog(catalogRef.getHref(), params);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -147,7 +147,7 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
|
|||
new VcloudHttpResponsePrimer()
|
||||
.httpResponseBuilder().statusCode(204).build());
|
||||
|
||||
client.getAdminCatalogClient().deleteCatalog(catalogRef.getURI());
|
||||
client.getAdminCatalogClient().deleteCatalog(catalogRef.getHref());
|
||||
}
|
||||
|
||||
public static final AdminCatalog catalog() {
|
||||
|
|
|
@ -74,7 +74,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
|||
@Test(testName = "GET /admin/catalog/{id}")
|
||||
public void testGetCatalog() {
|
||||
assertNotNull(catalogRef, String.format(REF_REQ_LIVE, "Catalog"));
|
||||
catalog = catalogClient.getCatalog(catalogRef.getURI());
|
||||
catalog = catalogClient.getCatalog(catalogRef.getHref());
|
||||
|
||||
Checks.checkAdminCatalog(catalog);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
|||
@Test(testName = "GET /admin/catalog/{id}/owner",
|
||||
dependsOnMethods = { "testGetCatalog" })
|
||||
public void testGetCatalogOwner() {
|
||||
owner = catalogClient.getOwner(catalog.getURI());
|
||||
owner = catalogClient.getOwner(catalog.getHref());
|
||||
Checks.checkOwner(owner);
|
||||
}
|
||||
|
||||
|
@ -100,13 +100,13 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
|||
.build();
|
||||
|
||||
try {
|
||||
catalogClient.setOwner(catalog.getURI(), newOwner);
|
||||
owner = catalogClient.getOwner(catalog.getURI());
|
||||
catalogClient.setOwner(catalog.getHref(), newOwner);
|
||||
owner = catalogClient.getOwner(catalog.getHref());
|
||||
Checks.checkOwner(owner);
|
||||
assertTrue(equal(owner, newOwner), String.format(OBJ_FIELD_UPDATABLE, CATALOG, "owner"));
|
||||
} finally {
|
||||
catalogClient.setOwner(catalog.getURI(), oldOwner);
|
||||
owner = catalogClient.getOwner(catalog.getURI());
|
||||
catalogClient.setOwner(catalog.getHref(), oldOwner);
|
||||
owner = catalogClient.getOwner(catalog.getHref());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
|||
// .catalogItems(newCatalogItems)
|
||||
.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.getDescription(), newDescription),
|
||||
|
@ -144,7 +144,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
|||
// .catalogItems(oldCatalogItems)
|
||||
.build();
|
||||
|
||||
catalog = catalogClient.updateCatalog(catalog.getURI(), catalog);
|
||||
catalog = catalogClient.updateCatalog(catalog.getHref(), catalog);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,8 +158,8 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
|||
.isPublished(true)
|
||||
.build();
|
||||
|
||||
catalogClient.publishCatalog(catalogRef.getURI(), params);
|
||||
catalog = catalogClient.getCatalog(catalogRef.getURI());
|
||||
catalogClient.publishCatalog(catalogRef.getHref(), params);
|
||||
catalog = catalogClient.getCatalog(catalogRef.getHref());
|
||||
|
||||
assertTrue(catalog.isPublished(), String.format(OBJ_FIELD_EQ,
|
||||
CATALOG, "isPublished", true, catalog.isPublished()));
|
||||
|
@ -169,7 +169,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
|||
@Test(testName = "DELETE /admin/catalog/{id}",
|
||||
dependsOnMethods = { "testPublishCatalog" }, enabled = false )
|
||||
public void testDeleteCatalog() {
|
||||
catalogClient.deleteCatalog(catalogRef.getURI());
|
||||
catalogClient.deleteCatalog(catalogRef.getHref());
|
||||
|
||||
Error expected = Error.builder()
|
||||
.message("???")
|
||||
|
@ -178,7 +178,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
|||
.build();
|
||||
|
||||
try {
|
||||
catalog = catalogClient.getCatalog(catalogRef.getURI());
|
||||
catalog = catalogClient.getCatalog(catalogRef.getHref());
|
||||
fail("Should give HTTP 403 error");
|
||||
} catch (VCloudDirectorException vde) {
|
||||
assertEquals(vde.getError(), expected);
|
||||
|
|
|
@ -56,7 +56,7 @@ public class GroupClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
|
|||
|
||||
Group expected = group();
|
||||
|
||||
assertEquals(client.getGroupClient().getGroup(groupRef.getURI()), expected);
|
||||
assertEquals(client.getGroupClient().getGroup(groupRef.getHref()), expected);
|
||||
}
|
||||
|
||||
public static final Group group() {
|
||||
|
@ -79,7 +79,7 @@ public class GroupClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
|
|||
|
||||
Group expected = updateGroup();
|
||||
|
||||
assertEquals(client.getGroupClient().updateGroup(groupRef.getURI(), expected), expected);
|
||||
assertEquals(client.getGroupClient().updateGroup(groupRef.getHref(), expected), expected);
|
||||
}
|
||||
|
||||
public static Group updateGroup() {
|
||||
|
@ -96,6 +96,6 @@ public class GroupClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
|
|||
new VcloudHttpResponsePrimer()
|
||||
.httpResponseBuilder().statusCode(204).build());
|
||||
|
||||
client.getAdminCatalogClient().deleteCatalog(groupRef.getURI());
|
||||
client.getAdminCatalogClient().deleteCatalog(groupRef.getHref());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
@Test(testName = "GET /admin/group/{id}", enabled = false)
|
||||
public void testGetGroup() {
|
||||
assertNotNull(groupRef, String.format(REF_REQ_LIVE, "Group"));
|
||||
group = groupClient.getGroup(groupRef.getURI());
|
||||
group = groupClient.getGroup(groupRef.getHref());
|
||||
|
||||
Checks.checkGroup(group);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
.description(newDescription)
|
||||
.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.getDescription(), newDescription),
|
||||
|
@ -110,13 +110,13 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
.description(oldDescription)
|
||||
.build();
|
||||
|
||||
group = groupClient.updateGroup(group.getURI(), group);
|
||||
group = groupClient.updateGroup(group.getHref(), group);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(testName = "DELETE /admin/group/{id}", enabled = false )
|
||||
public void testDeleteCatalog() {
|
||||
groupClient.deleteGroup(groupRef.getURI());
|
||||
groupClient.deleteGroup(groupRef.getHref());
|
||||
|
||||
Error expected = Error.builder()
|
||||
.message("???")
|
||||
|
@ -125,7 +125,7 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
.build();
|
||||
|
||||
try {
|
||||
group = groupClient.getGroup(groupRef.getURI());
|
||||
group = groupClient.getGroup(groupRef.getHref());
|
||||
fail("Should give HTTP 403 error");
|
||||
} catch (VCloudDirectorException vde) {
|
||||
assertEquals(vde.getError(), expected);
|
||||
|
|
|
@ -92,7 +92,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
Reference orgRef = Iterables.getFirst(orgList.getOrgs(), null);
|
||||
assertNotNull(orgRef);
|
||||
|
||||
orgURI = orgRef.getURI();
|
||||
orgURI = orgRef.getHref();
|
||||
|
||||
// Call the method being tested
|
||||
org = orgClient.getOrg(orgURI);
|
||||
|
|
|
@ -92,7 +92,7 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
//TODO: upload media or something so you can get a fresh cancellable task?
|
||||
|
||||
Task taskRef = Iterables.getFirst(taskList.getTasks(), null);
|
||||
taskURI = taskRef.getURI();
|
||||
taskURI = taskRef.getHref();
|
||||
|
||||
// Call the method being tested
|
||||
task = taskClient.getTask(taskURI);
|
||||
|
|
Loading…
Reference in New Issue