diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java index e16f506dd1..280fb7ee6c 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java @@ -31,35 +31,34 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.atmos.binders.BindMetadataToHeaders; import org.jclouds.atmos.domain.AtmosObject; import org.jclouds.atmos.domain.BoundedSet; import org.jclouds.atmos.domain.DirectoryEntry; import org.jclouds.atmos.domain.SystemMetadata; import org.jclouds.atmos.domain.UserMetadata; +import org.jclouds.atmos.fallbacks.EndpointIfAlreadyExists; import org.jclouds.atmos.filters.SignRequest; import org.jclouds.atmos.functions.AtmosObjectName; import org.jclouds.atmos.functions.ParseDirectoryListFromContentAndHeaders; import org.jclouds.atmos.functions.ParseObjectFromHeadersAndHttpContent; import org.jclouds.atmos.functions.ParseSystemMetadataFromHeaders; import org.jclouds.atmos.functions.ParseUserMetadataFromHeaders; -import org.jclouds.atmos.functions.ReturnEndpointIfAlreadyExists; import org.jclouds.atmos.functions.ReturnTrueIfGroupACLIsOtherRead; import org.jclouds.atmos.options.ListOptions; import org.jclouds.atmos.options.PutOptions; -import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404; -import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404; +import org.jclouds.blobstore.BlobStoreFallbacks.ThrowContainerNotFoundOn404; +import org.jclouds.blobstore.BlobStoreFallbacks.ThrowKeyNotFoundOn404; import org.jclouds.http.options.GetOptions; import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.ParamParser; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; - -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; import com.google.inject.Provides; @@ -95,7 +94,7 @@ public interface AtmosAsyncClient { @GET @Path("/{directoryName}/") @ResponseParser(ParseDirectoryListFromContentAndHeaders.class) - @ExceptionParser(ThrowContainerNotFoundOn404.class) + @Fallback(ThrowContainerNotFoundOn404.class) @Consumes(MediaType.TEXT_XML) ListenableFuture> listDirectory( @PathParam("directoryName") String directoryName, ListOptions... options); @@ -105,7 +104,7 @@ public interface AtmosAsyncClient { */ @POST @Path("/{directoryName}/") - @ExceptionParser(ReturnEndpointIfAlreadyExists.class) + @Fallback(EndpointIfAlreadyExists.class) @Produces(MediaType.APPLICATION_OCTET_STREAM) @Consumes(MediaType.WILDCARD) ListenableFuture createDirectory(@PathParam("directoryName") String directoryName, PutOptions... options); @@ -126,7 +125,7 @@ public interface AtmosAsyncClient { */ @PUT @Path("/{parent}/{name}") - @ExceptionParser(ThrowKeyNotFoundOn404.class) + @Fallback(ThrowKeyNotFoundOn404.class) @Consumes(MediaType.WILDCARD) ListenableFuture updateFile( @PathParam("parent") String parent, @@ -138,7 +137,7 @@ public interface AtmosAsyncClient { */ @GET @ResponseParser(ParseObjectFromHeadersAndHttpContent.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @Path("/{path}") @Consumes(MediaType.WILDCARD) ListenableFuture readFile(@PathParam("path") String path, GetOptions... options); @@ -148,7 +147,7 @@ public interface AtmosAsyncClient { */ @HEAD @ResponseParser(ParseObjectFromHeadersAndHttpContent.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @Path("/{path}") @Consumes(MediaType.WILDCARD) ListenableFuture headFile(@PathParam("path") String path); @@ -158,7 +157,7 @@ public interface AtmosAsyncClient { */ @HEAD @ResponseParser(ParseSystemMetadataFromHeaders.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) // currently throws 403 errors @QueryParams(keys = "metadata/system") @Path("/{path}") @Consumes(MediaType.WILDCARD) @@ -169,7 +168,7 @@ public interface AtmosAsyncClient { */ @HEAD @ResponseParser(ParseUserMetadataFromHeaders.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @Path("/{path}") @QueryParams(keys = "metadata/user") @Consumes(MediaType.WILDCARD) @@ -179,7 +178,7 @@ public interface AtmosAsyncClient { * @see AtmosClient#deletePath */ @DELETE - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) @Path("/{path}") @Consumes(MediaType.WILDCARD) ListenableFuture deletePath(@PathParam("path") String path); @@ -188,7 +187,7 @@ public interface AtmosAsyncClient { * @see AtmosClient#pathExists */ @HEAD - @ExceptionParser(ReturnFalseOnNotFoundOr404.class) + @Fallback(FalseOnNotFoundOr404.class) @Path("/{path}") @Consumes(MediaType.WILDCARD) ListenableFuture pathExists(@PathParam("path") String path); @@ -200,7 +199,7 @@ public interface AtmosAsyncClient { @ResponseParser(ReturnTrueIfGroupACLIsOtherRead.class) @Path("/{path}") @Consumes(MediaType.WILDCARD) - @ExceptionParser(ReturnFalseOnNotFoundOr404.class) + @Fallback(FalseOnNotFoundOr404.class) ListenableFuture isPublic(@PathParam("path") String path); } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/functions/ReturnEndpointIfAlreadyExists.java b/apis/atmos/src/main/java/org/jclouds/atmos/fallbacks/EndpointIfAlreadyExists.java similarity index 64% rename from apis/atmos/src/main/java/org/jclouds/atmos/functions/ReturnEndpointIfAlreadyExists.java rename to apis/atmos/src/main/java/org/jclouds/atmos/fallbacks/EndpointIfAlreadyExists.java index c45336cdd0..db5f135e09 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/functions/ReturnEndpointIfAlreadyExists.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/fallbacks/EndpointIfAlreadyExists.java @@ -16,9 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.atmos.functions; +package org.jclouds.atmos.fallbacks; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Throwables.propagate; +import static com.google.common.util.concurrent.Futures.immediateFuture; import java.net.URI; @@ -28,32 +30,32 @@ import org.jclouds.javax.annotation.Nullable; import org.jclouds.rest.InvocationContext; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Throwables; +import com.google.common.util.concurrent.FutureFallback; +import com.google.common.util.concurrent.ListenableFuture; /** * * @author Adrian Cole */ -public class ReturnEndpointIfAlreadyExists implements Function, - InvocationContext { +public class EndpointIfAlreadyExists implements FutureFallback, InvocationContext { private URI endpoint; - public URI apply(Exception from) { - if (checkNotNull(from, "exception") instanceof KeyAlreadyExistsException) { - return endpoint; + @Override + public ListenableFuture create(Throwable t) { + if (checkNotNull(t, "throwable") instanceof KeyAlreadyExistsException) { + return immediateFuture(endpoint); } - throw Throwables.propagate(from); + throw propagate(t); } @Override - public ReturnEndpointIfAlreadyExists setContext(HttpRequest request) { + public EndpointIfAlreadyExists setContext(HttpRequest request) { return setEndpoint(request == null ? null : request.getEndpoint()); } @VisibleForTesting - ReturnEndpointIfAlreadyExists setEndpoint(@Nullable URI endpoint) { + EndpointIfAlreadyExists setEndpoint(@Nullable URI endpoint) { this.endpoint = endpoint; return this; } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java index 878e0e7e8f..73feca4b44 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java @@ -25,30 +25,30 @@ import java.lang.reflect.Method; import javax.ws.rs.core.HttpHeaders; +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.apis.ApiMetadata; import org.jclouds.atmos.blobstore.functions.BlobToObject; import org.jclouds.atmos.config.AtmosRestClientModule; import org.jclouds.atmos.domain.AtmosObject; +import org.jclouds.atmos.fallbacks.EndpointIfAlreadyExists; import org.jclouds.atmos.filters.SignRequest; import org.jclouds.atmos.functions.ParseDirectoryListFromContentAndHeaders; import org.jclouds.atmos.functions.ParseObjectFromHeadersAndHttpContent; import org.jclouds.atmos.functions.ParseSystemMetadataFromHeaders; -import org.jclouds.atmos.functions.ReturnEndpointIfAlreadyExists; import org.jclouds.atmos.functions.ReturnTrueIfGroupACLIsOtherRead; import org.jclouds.atmos.options.ListOptions; import org.jclouds.atmos.options.PutOptions; +import org.jclouds.blobstore.BlobStoreFallbacks.ThrowContainerNotFoundOn404; +import org.jclouds.blobstore.BlobStoreFallbacks.ThrowKeyNotFoundOn404; import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest; -import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404; -import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.options.GetOptions; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.BeforeClass; @@ -79,7 +79,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ParseDirectoryListFromContentAndHeaders.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertFallbackClassEquals(method, null); checkFilters(request); } @@ -94,7 +94,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ParseDirectoryListFromContentAndHeaders.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ThrowContainerNotFoundOn404.class); + assertFallbackClassEquals(method, ThrowContainerNotFoundOn404.class); checkFilters(request); } @@ -109,7 +109,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ParseDirectoryListFromContentAndHeaders.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertFallbackClassEquals(method, null); checkFilters(request); } @@ -124,7 +124,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ParseDirectoryListFromContentAndHeaders.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ThrowContainerNotFoundOn404.class); + assertFallbackClassEquals(method, ThrowContainerNotFoundOn404.class); checkFilters(request); } @@ -139,7 +139,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ParseURIFromListOrLocationHeaderIf20x.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEndpointIfAlreadyExists.class); + assertFallbackClassEquals(method, EndpointIfAlreadyExists.class); checkFilters(request); } @@ -155,7 +155,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ParseURIFromListOrLocationHeaderIf20x.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEndpointIfAlreadyExists.class); + assertFallbackClassEquals(method, EndpointIfAlreadyExists.class); checkFilters(request); } @@ -172,7 +172,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ParseURIFromListOrLocationHeaderIf20x.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertFallbackClassEquals(method, null); checkFilters(request); } @@ -190,7 +190,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ParseURIFromListOrLocationHeaderIf20x.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertFallbackClassEquals(method, null); checkFilters(request); } @@ -207,7 +207,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ThrowKeyNotFoundOn404.class); + assertFallbackClassEquals(method, ThrowKeyNotFoundOn404.class); checkFilters(request); } @@ -225,7 +225,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ThrowKeyNotFoundOn404.class); + assertFallbackClassEquals(method, ThrowKeyNotFoundOn404.class); checkFilters(request); } @@ -240,7 +240,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ParseObjectFromHeadersAndHttpContent.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertFallbackClassEquals(method, NullOnNotFoundOr404.class); checkFilters(request); } @@ -255,7 +255,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ParseSystemMetadataFromHeaders.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertFallbackClassEquals(method, NullOnNotFoundOr404.class); checkFilters(request); } @@ -270,7 +270,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class); + assertFallbackClassEquals(method, VoidOnNotFoundOr404.class); checkFilters(request); } @@ -285,7 +285,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest assertResponseParserClassEquals(method, request, ReturnTrueIfGroupACLIsOtherRead.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); + assertFallbackClassEquals(method, FalseOnNotFoundOr404.class); checkFilters(request); } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/functions/ReturnEndpointIfAlreadyExistsTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/fallbacks/EndpointIfAlreadyExistsTest.java similarity index 70% rename from apis/atmos/src/test/java/org/jclouds/atmos/functions/ReturnEndpointIfAlreadyExistsTest.java rename to apis/atmos/src/test/java/org/jclouds/atmos/fallbacks/EndpointIfAlreadyExistsTest.java index ee5aef43f0..61fa945287 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/functions/ReturnEndpointIfAlreadyExistsTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/fallbacks/EndpointIfAlreadyExistsTest.java @@ -16,9 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.atmos.functions; +package org.jclouds.atmos.fallbacks; +import static com.google.common.util.concurrent.Futures.getUnchecked; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; import java.net.URI; @@ -30,27 +32,27 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit") -public class ReturnEndpointIfAlreadyExistsTest { +public class EndpointIfAlreadyExistsTest { @Test public void testFoundIsNullWhenEndpointNotSet() { - assertEquals(new ReturnEndpointIfAlreadyExists().apply(new KeyAlreadyExistsException()), null); + assertNull(getUnchecked(new EndpointIfAlreadyExists().create(new KeyAlreadyExistsException()))); } @Test public void testFoundIsEndpointWhenSet() { assertEquals( - new ReturnEndpointIfAlreadyExists().setEndpoint(URI.create("foo")).apply(new KeyAlreadyExistsException()), - URI.create("foo")); + getUnchecked(new EndpointIfAlreadyExists().setEndpoint(URI.create("foo")).create( + new KeyAlreadyExistsException())), URI.create("foo")); } @Test(expectedExceptions = RuntimeException.class) public void testNotFoundPropagates() { - new ReturnEndpointIfAlreadyExists().apply(new RuntimeException()); + new EndpointIfAlreadyExists().create(new RuntimeException()); } @Test(expectedExceptions = NullPointerException.class) public void testNullIsBad() { - new ReturnEndpointIfAlreadyExists().apply(null); + new EndpointIfAlreadyExists().create(null); } } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java index 5ee158369a..0b78910b64 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java @@ -20,6 +20,7 @@ package org.jclouds.cloudfiles; import java.net.URI; import java.util.Set; +import java.util.concurrent.ExecutionException; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -32,7 +33,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; -import org.jclouds.blobstore.functions.ReturnNullOnContainerNotFound; +import org.jclouds.blobstore.BlobStoreFallbacks.NullOnContainerNotFound; import org.jclouds.cloudfiles.binders.BindIterableToHeadersWithPurgeCDNObjectEmail; import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; import org.jclouds.cloudfiles.functions.ParseCdnUriFromHeaders; @@ -44,7 +45,7 @@ import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.Storage; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Endpoint; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.Headers; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; @@ -82,7 +83,7 @@ public interface CloudFilesAsyncClient extends CommonSwiftAsyncClient { */ @HEAD @ResponseParser(ParseContainerCDNMetadataFromHeaders.class) - @ExceptionParser(ReturnNullOnContainerNotFound.class) + @Fallback(NullOnContainerNotFound.class) @Path("/{container}") @Endpoint(CDNManagement.class) ListenableFuture getCDNMetadata(@PathParam("container") String container); @@ -161,7 +162,7 @@ public interface CloudFilesAsyncClient extends CommonSwiftAsyncClient { ListenableFuture disableCDN(@PathParam("container") String container); /** - * @see CloudFilesClient#purgeCDNObject(String, String, List) + * @see CloudFilesClient#purgeCDNObject(String, String, Iterable) */ @DELETE @Path("/{container}/{object}") diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java index a04d3a5cbb..aecd7d6ec7 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java @@ -19,6 +19,7 @@ package org.jclouds.cloudservers; import java.util.Set; +import java.util.concurrent.ExecutionException; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -30,6 +31,10 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.cloudservers.binders.BindBackupScheduleToJsonPayload; import org.jclouds.cloudservers.domain.Addresses; import org.jclouds.cloudservers.domain.BackupSchedule; @@ -43,23 +48,18 @@ import org.jclouds.cloudservers.options.CreateServerOptions; import org.jclouds.cloudservers.options.CreateSharedIpGroupOptions; import org.jclouds.cloudservers.options.ListOptions; import org.jclouds.cloudservers.options.RebuildServerOptions; -import org.jclouds.http.functions.ReturnFalseOn404; import org.jclouds.openstack.filters.AddTimestampQuery; import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.services.Compute; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Endpoint; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.Payload; import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.Unwrap; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -86,7 +86,7 @@ public interface CloudServersAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "format", values = "json") @Path("/limits") - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture getLimits(); /** @@ -97,7 +97,7 @@ public interface CloudServersAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "format", values = "json") @Path("/servers") - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listServers(ListOptions... options); /** @@ -107,7 +107,7 @@ public interface CloudServersAsyncClient { @Unwrap @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "format", values = "json") - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @Path("/servers/{id}") ListenableFuture getServer(@PathParam("id") int id); @@ -115,7 +115,7 @@ public interface CloudServersAsyncClient { * @see CloudServersClient#deleteServer */ @DELETE - @ExceptionParser(ReturnFalseOnNotFoundOr404.class) + @Fallback(FalseOnNotFoundOr404.class) @Path("/servers/{id}") ListenableFuture deleteServer(@PathParam("id") int id); @@ -196,7 +196,7 @@ public interface CloudServersAsyncClient { */ @DELETE @Path("/servers/{id}/ips/public/{address}") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture unshareIp(@PathParam("address") String addressToShare, @PathParam("id") int serverToTosignBindressTo); @@ -226,7 +226,7 @@ public interface CloudServersAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "format", values = "json") @Path("/flavors") - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listFlavors(ListOptions... options); /** @@ -237,7 +237,7 @@ public interface CloudServersAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "format", values = "json") @Path("/flavors/{id}") - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getFlavor(@PathParam("id") int id); /** @@ -248,7 +248,7 @@ public interface CloudServersAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "format", values = "json") @Path("/images") - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listImages(ListOptions... options); /** @@ -257,7 +257,7 @@ public interface CloudServersAsyncClient { @GET @Unwrap @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @QueryParams(keys = "format", values = "json") @Path("/images/{id}") ListenableFuture getImage(@PathParam("id") int id); @@ -266,7 +266,7 @@ public interface CloudServersAsyncClient { * @see CloudServersClient#deleteImage */ @DELETE - @ExceptionParser(ReturnFalseOnNotFoundOr404.class) + @Fallback(FalseOnNotFoundOr404.class) @Path("/images/{id}") ListenableFuture deleteImage(@PathParam("id") int id); @@ -291,7 +291,7 @@ public interface CloudServersAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "format", values = "json") @Path("/shared_ip_groups") - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listSharedIpGroups(ListOptions... options); /** @@ -302,7 +302,7 @@ public interface CloudServersAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "format", values = "json") @Path("/shared_ip_groups/{id}") - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getSharedIpGroup(@PathParam("id") int id); /** @@ -321,7 +321,7 @@ public interface CloudServersAsyncClient { * @see CloudServersClient#deleteSharedIpGroup */ @DELETE - @ExceptionParser(ReturnFalseOnNotFoundOr404.class) + @Fallback(FalseOnNotFoundOr404.class) @Path("/shared_ip_groups/{id}") ListenableFuture deleteSharedIpGroup(@PathParam("id") int id); @@ -339,7 +339,7 @@ public interface CloudServersAsyncClient { * @see CloudServersClient#deleteBackupSchedule */ @DELETE - @ExceptionParser(ReturnFalseOnNotFoundOr404.class) + @Fallback(FalseOnNotFoundOr404.class) @Path("/servers/{id}/backup_schedule") ListenableFuture deleteBackupSchedule(@PathParam("id") int serverId); @@ -347,7 +347,6 @@ public interface CloudServersAsyncClient { * @see CloudServersClient#replaceBackupSchedule */ @POST - @ExceptionParser(ReturnFalseOn404.class) @Path("/servers/{id}/backup_schedule") ListenableFuture replaceBackupSchedule(@PathParam("id") int id, @BinderParam(BindBackupScheduleToJsonPayload.class) BackupSchedule backupSchedule); @@ -370,7 +369,7 @@ public interface CloudServersAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "format", values = "json") @Path("/servers/{id}/ips/public") - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listPublicAddresses(@PathParam("id") int serverId); /** @@ -381,7 +380,7 @@ public interface CloudServersAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "format", values = "json") @Path("/servers/{id}/ips/private") - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listPrivateAddresses(@PathParam("id") int serverId); } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java index 1ebb9270c2..7421ea5250 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java @@ -38,6 +38,10 @@ import java.util.Properties; import javax.inject.Singleton; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.apis.ApiMetadata; import org.jclouds.cloudservers.config.CloudServersRestClientModule; import org.jclouds.cloudservers.domain.BackupSchedule; @@ -49,9 +53,9 @@ import org.jclouds.cloudservers.options.CreateSharedIpGroupOptions; import org.jclouds.cloudservers.options.ListOptions; import org.jclouds.cloudservers.options.RebuildServerOptions; import org.jclouds.domain.Credentials; +import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.http.functions.ReturnFalseOn404; import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.openstack.filters.AddTimestampQuery; @@ -60,11 +64,6 @@ import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.Ge import org.jclouds.openstack.keystone.v1_1.domain.Auth; import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -99,7 +98,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest getProfileInfo(); @@ -132,7 +132,7 @@ public interface CloudSigmaAsyncClient { * @see CloudSigmaClient#getDriveInfo */ @GET - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class) @Path("/drives/{uuid}/info") ListenableFuture getDriveInfo(@PathParam("uuid") String uuid); @@ -141,7 +141,7 @@ public interface CloudSigmaAsyncClient { * @see CloudSigmaClient#createDrive */ @POST - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class) @Path("/drives/create") ListenableFuture createDrive(@BinderParam(BindDriveToPlainTextString.class) Drive createDrive); @@ -159,7 +159,7 @@ public interface CloudSigmaAsyncClient { * @see CloudSigmaClient#createServer */ @POST - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class) @Path("/servers/create") ListenableFuture createServer(@BinderParam(BindServerToPlainTextString.class) Server createServer); @@ -176,7 +176,7 @@ public interface CloudSigmaAsyncClient { * @see CloudSigmaClient#getServerInfo */ @GET - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class) @Path("/servers/{uuid}/info") ListenableFuture getServerInfo(@PathParam("uuid") String uuid); @@ -185,7 +185,7 @@ public interface CloudSigmaAsyncClient { * @see CloudSigmaClient#setServerConfiguration */ @POST - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class) @Path("/servers/{uuid}/set") ListenableFuture setServerConfiguration(@PathParam("uuid") String uuid, @@ -204,7 +204,7 @@ public interface CloudSigmaAsyncClient { */ @GET @Path("/servers/{uuid}/destroy") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture destroyServer(@PathParam("uuid") String uuid); /** @@ -248,14 +248,14 @@ public interface CloudSigmaAsyncClient { */ @GET @Path("/drives/{uuid}/destroy") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture destroyDrive(@PathParam("uuid") String uuid); /** * @see CloudSigmaClient#createVLAN */ @POST - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class) @Path("/resources/vlan/create") @Payload("name {name}\n") @@ -274,7 +274,7 @@ public interface CloudSigmaAsyncClient { * @see CloudSigmaClient#getVLANInfo */ @GET - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class) @Path("/resources/vlan/{uuid}/info") ListenableFuture getVLANInfo(@PathParam("uuid") String uuid); @@ -302,14 +302,14 @@ public interface CloudSigmaAsyncClient { */ @GET @Path("/resources/vlan/{uuid}/destroy") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture destroyVLAN(@PathParam("uuid") String uuid); /** * @see CloudSigmaClient#createStaticIP */ @POST - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @ResponseParser(KeyValuesDelimitedByBlankLinesToStaticIPInfo.class) @Path("/resources/ip/create") ListenableFuture createStaticIP(); @@ -326,7 +326,7 @@ public interface CloudSigmaAsyncClient { * @see CloudSigmaClient#getStaticIPInfo */ @GET - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @ResponseParser(KeyValuesDelimitedByBlankLinesToStaticIPInfo.class) @Path("/resources/ip/{uuid}/info") ListenableFuture getStaticIPInfo(@PathParam("uuid") String uuid); @@ -344,7 +344,7 @@ public interface CloudSigmaAsyncClient { */ @GET @Path("/resources/ip/{uuid}/destroy") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture destroyStaticIP(@PathParam("uuid") String uuid); } diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java index 7b0312d639..43a59764d9 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java @@ -23,6 +23,8 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.apis.ApiMetadata; import org.jclouds.cloudsigma.binders.BindServerToPlainTextStringTest; import org.jclouds.cloudsigma.domain.CreateDriveRequest; @@ -41,12 +43,10 @@ import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToVL import org.jclouds.cloudsigma.functions.SplitNewlines; import org.jclouds.cloudsigma.functions.SplitNewlinesAndReturnSecondField; import org.jclouds.cloudsigma.options.CloneDriveOptions; +import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -74,7 +74,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest> listAccounts(ListAccountsOptions... options); /** @@ -67,7 +67,7 @@ public interface AccountAsyncClient { @SelectJson("account") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getAccount(@QueryParam("id") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/AddressAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/AddressAsyncClient.java index b1cb47137e..d80da3fdbe 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/AddressAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/AddressAsyncClient.java @@ -25,20 +25,20 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.AsyncCreateResponse; import org.jclouds.cloudstack.domain.PublicIPAddress; import org.jclouds.cloudstack.filters.AuthenticationFilter; -import org.jclouds.cloudstack.functions.ReturnVoidOnNotFoundOr404OrUnableToFindAccountOwner; +import org.jclouds.cloudstack.functions.CloudStackFallbacks.VoidOnNotFoundOr404OrUnableToFindAccountOwner; import org.jclouds.cloudstack.options.AssociateIPAddressOptions; import org.jclouds.cloudstack.options.ListPublicIPAddressesOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.Unwrap; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -61,7 +61,7 @@ public interface AddressAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listPublicIpAddresses", "true" }) @SelectJson("publicipaddress") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listPublicIPAddresses(ListPublicIPAddressesOptions... options); /** @@ -72,7 +72,7 @@ public interface AddressAsyncClient { @SelectJson("publicipaddress") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getPublicIPAddress(@QueryParam("id") String id); /** @@ -90,7 +90,7 @@ public interface AddressAsyncClient { */ @GET @QueryParams(keys = "command", values = "disassociateIpAddress") - @ExceptionParser(ReturnVoidOnNotFoundOr404OrUnableToFindAccountOwner.class) + @Fallback(VoidOnNotFoundOr404OrUnableToFindAccountOwner.class) ListenableFuture disassociateIPAddress(@QueryParam("id") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/AsyncJobAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/AsyncJobAsyncClient.java index a05ccf076a..04f4b86eb7 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/AsyncJobAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/AsyncJobAsyncClient.java @@ -25,17 +25,17 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.AsyncJob; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.functions.ParseAsyncJobFromHttpResponse; import org.jclouds.cloudstack.functions.ParseAsyncJobsFromHttpResponse; import org.jclouds.cloudstack.options.ListAsyncJobsOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -57,7 +57,7 @@ public interface AsyncJobAsyncClient { @GET @QueryParams(keys = { "command", "listAll" }, values = { "listAsyncJobs", "true" }) @ResponseParser(ParseAsyncJobsFromHttpResponse.class) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture>> listAsyncJobs(ListAsyncJobsOptions... options); /** @@ -67,7 +67,7 @@ public interface AsyncJobAsyncClient { @QueryParams(keys = "command", values = "queryAsyncJobResult") @Consumes(MediaType.APPLICATION_JSON) @ResponseParser(ParseAsyncJobFromHttpResponse.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture> getAsyncJob(@QueryParam("jobid") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainAccountAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainAccountAsyncClient.java index 268b9fbec1..7a7397513a 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainAccountAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainAccountAsyncClient.java @@ -23,15 +23,15 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.AsyncCreateResponse; import org.jclouds.cloudstack.filters.AuthenticationFilter; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.Unwrap; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -55,7 +55,7 @@ public interface DomainAccountAsyncClient extends AccountAsyncClient { @QueryParams(keys = "command", values = "enableAccount") @SelectJson("account") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture enableAccount(@QueryParam("account") String accountName, @QueryParam("domainid") String domainId); @@ -66,7 +66,7 @@ public interface DomainAccountAsyncClient extends AccountAsyncClient { @QueryParams(keys = "command", values = "disableAccount") @Unwrap @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture disableAccount(@QueryParam("account") String accountName, @QueryParam("domainid") String domainId, @QueryParam("lock") boolean onlyLock); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainDomainAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainDomainAsyncClient.java index e7a9df7921..5c7e99fcef 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainDomainAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainDomainAsyncClient.java @@ -25,17 +25,17 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.Domain; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.ListDomainChildrenOptions; import org.jclouds.cloudstack.options.ListDomainsOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -59,7 +59,7 @@ public interface DomainDomainAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listDomains", "true" }) @SelectJson("domain") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listDomains(ListDomainsOptions... options); /** @@ -70,7 +70,7 @@ public interface DomainDomainAsyncClient { @SelectJson("domain") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getDomainById(@QueryParam("id") String domainId); /** @@ -80,6 +80,6 @@ public interface DomainDomainAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listDomainChildren", "true" }) @SelectJson("domain") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listDomainChildren(ListDomainChildrenOptions... options); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainUserAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainUserAsyncClient.java index dc141c407a..cb0c9a7882 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainUserAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainUserAsyncClient.java @@ -25,17 +25,17 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.AsyncCreateResponse; import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.ListUsersOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.Unwrap; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -59,7 +59,7 @@ public interface DomainUserAsyncClient { @QueryParams(keys = "command", values = "listUsers") @SelectJson("user") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listUsers(ListUsersOptions... options); /** @@ -69,7 +69,7 @@ public interface DomainUserAsyncClient { @QueryParams(keys = "command", values = "enableUser") @SelectJson("user") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture enableUser(@QueryParam("id") String userId); /** @@ -79,7 +79,7 @@ public interface DomainUserAsyncClient { @QueryParams(keys = "command", values = "disableUser") @Unwrap @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture disableUser(@QueryParam("id") String userId); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/EventAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/EventAsyncClient.java index f47409ef4d..6592125716 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/EventAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/EventAsyncClient.java @@ -24,16 +24,16 @@ import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.domain.Event; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.functions.ParseEventTypesFromHttpResponse; import org.jclouds.cloudstack.options.ListEventsOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -55,7 +55,7 @@ public interface EventAsyncClient { @QueryParams(keys = "command", values = "listEventTypes") @Consumes(MediaType.APPLICATION_JSON) @ResponseParser(ParseEventTypesFromHttpResponse.class) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listEventTypes(); /** @@ -65,7 +65,7 @@ public interface EventAsyncClient { @QueryParams(keys = "command", values = "listEvents") @SelectJson("event") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listEvents(ListEventsOptions...options); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/FirewallAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/FirewallAsyncClient.java index c560b5395b..7efa307028 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/FirewallAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/FirewallAsyncClient.java @@ -25,6 +25,9 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.cloudstack.domain.AsyncCreateResponse; import org.jclouds.cloudstack.domain.FirewallRule; import org.jclouds.cloudstack.domain.PortForwardingRule; @@ -32,15 +35,12 @@ import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.CreateFirewallRuleOptions; import org.jclouds.cloudstack.options.ListFirewallRulesOptions; import org.jclouds.cloudstack.options.ListPortForwardingRulesOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.Unwrap; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -63,7 +63,7 @@ public interface FirewallAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listFirewallRules", "true" }) @SelectJson("firewallrule") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listFirewallRules(ListFirewallRulesOptions... options); /** @@ -74,7 +74,7 @@ public interface FirewallAsyncClient { @SelectJson("firewallrule") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getFirewallRule(@QueryParam("id") String id); /** @@ -105,7 +105,7 @@ public interface FirewallAsyncClient { */ @GET @QueryParams(keys = "command", values = "deleteFirewallRule") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture deleteFirewallRule(@QueryParam("id") String id); /** @@ -115,7 +115,7 @@ public interface FirewallAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listPortForwardingRules", "true" }) @SelectJson("portforwardingrule") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listPortForwardingRules(ListPortForwardingRulesOptions... options); /** @@ -126,7 +126,7 @@ public interface FirewallAsyncClient { @SelectJson("portforwardingrule") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getPortForwardingRule(@QueryParam("id") String id); /** @@ -146,7 +146,7 @@ public interface FirewallAsyncClient { */ @GET @QueryParams(keys = "command", values = "deletePortForwardingRule") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture deletePortForwardingRule(@QueryParam("id") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalAccountAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalAccountAsyncClient.java index 8fe5eaf0c0..382e687eb1 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalAccountAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalAccountAsyncClient.java @@ -23,15 +23,15 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.CreateAccountOptions; import org.jclouds.cloudstack.options.UpdateAccountOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -55,7 +55,7 @@ public interface GlobalAccountAsyncClient extends DomainAccountAsyncClient { @QueryParams(keys = "command", values = "createAccount") @SelectJson("account") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture createAccount(@QueryParam("username") String userName, @QueryParam("accounttype") Account.Type accountType, @QueryParam("email") String email, @QueryParam("firstname") String firstName, @QueryParam("lastname") String lastName, @@ -68,7 +68,7 @@ public interface GlobalAccountAsyncClient extends DomainAccountAsyncClient { @QueryParams(keys = "command", values = "updateAccount") @SelectJson("account") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture updateAccount(@QueryParam("account") String accountName, @QueryParam("domainid") String domainId, @QueryParam("newname") String newName, UpdateAccountOptions... options); @@ -78,6 +78,6 @@ public interface GlobalAccountAsyncClient extends DomainAccountAsyncClient { @GET @QueryParams(keys = "command", values = "deleteAccount") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture deleteAccount(@QueryParam("id") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalAlertAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalAlertAsyncClient.java index fc21c8c13c..96bb4cdfa8 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalAlertAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalAlertAsyncClient.java @@ -24,14 +24,14 @@ import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.domain.Alert; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.ListAlertsOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -55,7 +55,7 @@ public interface GlobalAlertAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listAlerts", "true" }) @SelectJson("alert") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listAlerts(ListAlertsOptions...options); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalCapacityAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalCapacityAsyncClient.java index 5155539702..4c41425027 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalCapacityAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalCapacityAsyncClient.java @@ -24,14 +24,14 @@ import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.domain.Capacity; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.ListCapacityOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -55,7 +55,7 @@ public interface GlobalCapacityAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listCapacity", "true" }) @SelectJson("capacity") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listCapacity(ListCapacityOptions...options); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalConfigurationAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalConfigurationAsyncClient.java index b919423722..9714d61e12 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalConfigurationAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalConfigurationAsyncClient.java @@ -25,15 +25,15 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.ConfigurationEntry; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.ListConfigurationEntriesOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -57,7 +57,7 @@ public interface GlobalConfigurationAsyncClient extends ConfigurationAsyncClient @QueryParams(keys = { "command", "listAll" }, values = { "listConfigurations", "true" }) @SelectJson("configuration") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listConfigurationEntries(ListConfigurationEntriesOptions... options); /** @@ -67,7 +67,7 @@ public interface GlobalConfigurationAsyncClient extends ConfigurationAsyncClient @QueryParams(keys = "command", values = "updateConfiguration") @SelectJson("configuration") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture updateConfigurationEntry( @QueryParam("name") String name, @QueryParam("value") String value); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalDomainAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalDomainAsyncClient.java index 931acb1d30..c5476c92ab 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalDomainAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalDomainAsyncClient.java @@ -23,16 +23,16 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.cloudstack.domain.Domain; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.CreateDomainOptions; import org.jclouds.cloudstack.options.UpdateDomainOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -56,7 +56,7 @@ public interface GlobalDomainAsyncClient extends DomainDomainAsyncClient { @QueryParams(keys = "command", values = "createDomain") @SelectJson("domain") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture createDomain(@QueryParam("name") String name, CreateDomainOptions... options); /** @@ -66,7 +66,7 @@ public interface GlobalDomainAsyncClient extends DomainDomainAsyncClient { @QueryParams(keys = "command", values = "updateDomain") @SelectJson("domain") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture updateDomain(@QueryParam("id") String domainId, UpdateDomainOptions... options); /** @@ -74,7 +74,7 @@ public interface GlobalDomainAsyncClient extends DomainDomainAsyncClient { */ @GET @QueryParams(keys = {"command", "cleanup"}, values = {"deleteDomain", "false"}) - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture deleteOnlyDomain(@QueryParam("id") String id); /** @@ -82,7 +82,7 @@ public interface GlobalDomainAsyncClient extends DomainDomainAsyncClient { */ @GET @QueryParams(keys = {"command", "cleanup"}, values = {"deleteDomain", "true"}) - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture deleteDomainAndAttachedResources(@QueryParam("id") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java index 17b0a90f95..d90e892e75 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java @@ -25,6 +25,7 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.domain.Cluster; import org.jclouds.cloudstack.domain.Host; import org.jclouds.cloudstack.filters.AuthenticationFilter; @@ -36,11 +37,10 @@ import org.jclouds.cloudstack.options.ListClustersOptions; import org.jclouds.cloudstack.options.ListHostsOptions; import org.jclouds.cloudstack.options.UpdateClusterOptions; import org.jclouds.cloudstack.options.UpdateHostOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -63,7 +63,7 @@ public interface GlobalHostAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listHosts", "true" }) @SelectJson("host") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listHosts(ListHostsOptions... options); /** @@ -175,7 +175,7 @@ public interface GlobalHostAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listClusters", "true" }) @SelectJson("cluster") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listClusters(ListClustersOptions... options); /** diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalOfferingAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalOfferingAsyncClient.java index d661347d1a..308829f600 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalOfferingAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalOfferingAsyncClient.java @@ -23,6 +23,7 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.DiskOffering; import org.jclouds.cloudstack.domain.NetworkOffering; import org.jclouds.cloudstack.domain.ServiceOffering; @@ -32,11 +33,10 @@ import org.jclouds.cloudstack.options.CreateServiceOfferingOptions; import org.jclouds.cloudstack.options.UpdateDiskOfferingOptions; import org.jclouds.cloudstack.options.UpdateNetworkOfferingOptions; import org.jclouds.cloudstack.options.UpdateServiceOfferingOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -59,7 +59,7 @@ public interface GlobalOfferingAsyncClient extends OfferingAsyncClient { @QueryParams(keys = "command", values = "createServiceOffering") @SelectJson("serviceoffering") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture createServiceOffering(@QueryParam("name") String name, @QueryParam("displaytext") String displayText, @QueryParam("cpunumber") int cpuNumber, @QueryParam("cpuspeed") int cpuSpeedInMHz, @QueryParam("memory") int memoryInMB, CreateServiceOfferingOptions... options); @@ -71,7 +71,7 @@ public interface GlobalOfferingAsyncClient extends OfferingAsyncClient { @QueryParams(keys = "command", values = "updateServiceOffering") @SelectJson("serviceoffering") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture updateServiceOffering(@QueryParam("id") String id, UpdateServiceOfferingOptions... options); /** @@ -80,7 +80,7 @@ public interface GlobalOfferingAsyncClient extends OfferingAsyncClient { @GET @QueryParams(keys = "command", values = "deleteServiceOffering") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture deleteServiceOffering(@QueryParam("id") String id); /** @@ -90,7 +90,7 @@ public interface GlobalOfferingAsyncClient extends OfferingAsyncClient { @QueryParams(keys = "command", values = "createDiskOffering") @SelectJson("diskoffering") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture createDiskOffering(@QueryParam("name") String name, @QueryParam("displaytext") String displayText, CreateDiskOfferingOptions... options); @@ -101,7 +101,7 @@ public interface GlobalOfferingAsyncClient extends OfferingAsyncClient { @QueryParams(keys = "command", values = "updateDiskOffering") @SelectJson("diskoffering") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture updateDiskOffering(@QueryParam("id") String id, UpdateDiskOfferingOptions... options); /** @@ -110,7 +110,7 @@ public interface GlobalOfferingAsyncClient extends OfferingAsyncClient { @GET @QueryParams(keys = "command", values = "deleteDiskOffering") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture deleteDiskOffering(@QueryParam("id") String id); /** @@ -120,6 +120,6 @@ public interface GlobalOfferingAsyncClient extends OfferingAsyncClient { @QueryParams(keys = "command", values ="updateNetworkOffering") @SelectJson("networkoffering") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture updateNetworkOffering(@QueryParam("id") String id, UpdateNetworkOfferingOptions... options); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalPodAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalPodAsyncClient.java index 0731c26678..5706910997 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalPodAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalPodAsyncClient.java @@ -25,19 +25,19 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.cloudstack.domain.Pod; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.CreatePodOptions; import org.jclouds.cloudstack.options.ListPodsOptions; import org.jclouds.cloudstack.options.UpdatePodOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -61,7 +61,7 @@ public interface GlobalPodAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listPods", "true" }) @SelectJson("pod") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listPods(ListPodsOptions... options); /** @@ -72,7 +72,7 @@ public interface GlobalPodAsyncClient { @SelectJson("pod") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getPod(@QueryParam("id") String id); /** @@ -91,7 +91,7 @@ public interface GlobalPodAsyncClient { @QueryParams(keys = "command", values = "createPod") @SelectJson("pod") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture createPod(@QueryParam("name") String name, @QueryParam("zoneid") String zoneId, @QueryParam("startip") String startIp, @QueryParam("endip") String endIp, @QueryParam("gateway") String gateway, @QueryParam("netmask") String netmask, CreatePodOptions... createPodOptions); /** @@ -109,7 +109,7 @@ public interface GlobalPodAsyncClient { @QueryParams(keys = "command", values = "createPod") @SelectJson("pod") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture createPod(@QueryParam("name") String name, @QueryParam("zoneid") String zoneId, @QueryParam("startip") String startIp, @QueryParam("gateway") String gateway, @QueryParam("netmask") String netmask, CreatePodOptions... createPodOptions); /** @@ -119,7 +119,7 @@ public interface GlobalPodAsyncClient { @GET @QueryParams(keys = "command", values = "deletePod") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture deletePod(@QueryParam("id") String id); /** @@ -132,7 +132,7 @@ public interface GlobalPodAsyncClient { @QueryParams(keys = "command", values = "updatePod") @SelectJson("pod") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture updatePod(@QueryParam("id") String id, UpdatePodOptions... updatePodOptions); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalUserAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalUserAsyncClient.java index bfba4ec100..793eaf8e39 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalUserAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalUserAsyncClient.java @@ -23,16 +23,16 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.ApiKeyPair; import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.CreateUserOptions; import org.jclouds.cloudstack.options.UpdateUserOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -56,7 +56,7 @@ public interface GlobalUserAsyncClient extends DomainUserAsyncClient { @QueryParams(keys = "command", values = "createUser") @SelectJson("user") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuturecreateUser(@QueryParam("username") String userName, @QueryParam("account") String accountName, @QueryParam("email") String email, @QueryParam("password") String hashedPassword, @QueryParam("firstname") String firstName, @QueryParam("lastname") String lastName, CreateUserOptions... options); @@ -68,7 +68,7 @@ public interface GlobalUserAsyncClient extends DomainUserAsyncClient { @QueryParams(keys = "command", values = "registerUserKeys") @SelectJson("userkeys") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture registerUserKeys(@QueryParam("id") String userId); /** @@ -78,7 +78,7 @@ public interface GlobalUserAsyncClient extends DomainUserAsyncClient { @QueryParams(keys = "command", values = "updateUser") @SelectJson("user") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture updateUser(@QueryParam("id") String id, UpdateUserOptions... options); /** @@ -87,6 +87,6 @@ public interface GlobalUserAsyncClient extends DomainUserAsyncClient { @GET @QueryParams(keys = "command", values = "deleteUser") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture deleteUser(@QueryParam("id") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalVlanAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalVlanAsyncClient.java index de924c4b0f..a8b69f5b74 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalVlanAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalVlanAsyncClient.java @@ -25,18 +25,18 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.cloudstack.domain.VlanIPRange; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.CreateVlanIPRangeOptions; import org.jclouds.cloudstack.options.ListVlanIPRangesOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -62,7 +62,7 @@ public interface GlobalVlanAsyncClient { @SelectJson("vlaniprange") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getVlanIPRange(@QueryParam("id") String id); /** @@ -75,7 +75,7 @@ public interface GlobalVlanAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listVlanIpRanges", "true" }) @SelectJson("vlaniprange") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listVlanIPRanges(ListVlanIPRangesOptions... options); /** @@ -90,7 +90,7 @@ public interface GlobalVlanAsyncClient { @QueryParams(keys = "command", values = "createVlanIpRange") @SelectJson("vlaniprange") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture createVlanIPRange(@QueryParam("startip") String startIP, @QueryParam("endip") String endIP, CreateVlanIPRangeOptions... options); /** @@ -101,6 +101,6 @@ public interface GlobalVlanAsyncClient { @GET @QueryParams(keys = "command", values = "deleteVlanIpRange") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture deleteVlanIPRange(@QueryParam("id") String rangeId); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalZoneAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalZoneAsyncClient.java index 589796b98b..be8c51e9c5 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalZoneAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalZoneAsyncClient.java @@ -23,17 +23,17 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.cloudstack.domain.NetworkType; import org.jclouds.cloudstack.domain.Zone; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.CreateZoneOptions; import org.jclouds.cloudstack.options.UpdateZoneOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -57,7 +57,7 @@ public interface GlobalZoneAsyncClient extends ZoneAsyncClient { @QueryParams(keys = "command", values = "createZone") @SelectJson("zone") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture createZone(@QueryParam("name") String name, @QueryParam("networktype") NetworkType networkType, @QueryParam("dns1") String externalDns1, @QueryParam("internaldns1") String internalDns1, CreateZoneOptions... options); @@ -68,7 +68,7 @@ public interface GlobalZoneAsyncClient extends ZoneAsyncClient { @QueryParams(keys = "command", values = "updateZone") @SelectJson("zone") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture updateZone(@QueryParam("id") String id, UpdateZoneOptions... options); /** @@ -77,6 +77,6 @@ public interface GlobalZoneAsyncClient extends ZoneAsyncClient { @GET @QueryParams(keys = "command", values = "deleteZone") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture deleteZone(@QueryParam("id") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GuestOSAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GuestOSAsyncClient.java index 6bc16b2764..6104cfc9a3 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GuestOSAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GuestOSAsyncClient.java @@ -26,19 +26,19 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.OSType; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.functions.ParseIdToNameEntryFromHttpResponse; import org.jclouds.cloudstack.functions.ParseIdToNameFromHttpResponse; import org.jclouds.cloudstack.options.ListOSTypesOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -61,7 +61,7 @@ public interface GuestOSAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listOsTypes", "true" }) @SelectJson("ostype") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listOSTypes(ListOSTypesOptions... options); /** @@ -72,7 +72,7 @@ public interface GuestOSAsyncClient { @SelectJson("ostype") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getOSType(@QueryParam("id") String id); /** @@ -81,7 +81,7 @@ public interface GuestOSAsyncClient { @GET @QueryParams(keys = { "command", "listAll" }, values = { "listOsCategories", "true" }) @ResponseParser(ParseIdToNameFromHttpResponse.class) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listOSCategories(); /** @@ -90,7 +90,7 @@ public interface GuestOSAsyncClient { @GET @QueryParams(keys = { "command", "listAll" }, values = { "listOsCategories", "true" }) @ResponseParser(ParseIdToNameEntryFromHttpResponse.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture> getOSCategory(@QueryParam("id") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/HypervisorAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/HypervisorAsyncClient.java index 7041f1c198..1f9b2446aa 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/HypervisorAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/HypervisorAsyncClient.java @@ -23,13 +23,13 @@ import java.util.Set; import javax.ws.rs.GET; import javax.ws.rs.QueryParam; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.functions.ParseNamesFromHttpResponse; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -51,7 +51,7 @@ public interface HypervisorAsyncClient { @GET @QueryParams(keys = { "command", "listAll" }, values = { "listHypervisors", "true" }) @ResponseParser(ParseNamesFromHttpResponse.class) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listHypervisors(); /** @@ -60,6 +60,6 @@ public interface HypervisorAsyncClient { @GET @QueryParams(keys = { "command", "listAll" }, values = { "listHypervisors", "true" }) @ResponseParser(ParseNamesFromHttpResponse.class) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listHypervisorsInZone(@QueryParam("zoneid") String zoneId); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/ISOAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/ISOAsyncClient.java index a8cd057ca1..b776058635 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/ISOAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/ISOAsyncClient.java @@ -25,6 +25,8 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.AsyncCreateResponse; import org.jclouds.cloudstack.domain.ExtractMode; import org.jclouds.cloudstack.domain.ISO; @@ -37,14 +39,12 @@ import org.jclouds.cloudstack.options.ListISOsOptions; import org.jclouds.cloudstack.options.RegisterISOOptions; import org.jclouds.cloudstack.options.UpdateISOOptions; import org.jclouds.cloudstack.options.UpdateISOPermissionsOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.Unwrap; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -96,7 +96,7 @@ public interface ISOAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listIsos", "true" }) @SelectJson("iso") @OnlyElement - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getISO(@QueryParam("id") String id); /** @@ -109,7 +109,7 @@ public interface ISOAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = { "command", "listAll" }, values = { "listIsos", "true" }) @SelectJson("iso") - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listISOs(ListISOsOptions... options); /** diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LimitAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LimitAsyncClient.java index fd75039370..b6cb2886b7 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LimitAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LimitAsyncClient.java @@ -24,14 +24,14 @@ import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.domain.ResourceLimit; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.ListResourceLimitsOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -53,7 +53,7 @@ public interface LimitAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listResourceLimits", "true" }) @SelectJson("resourcelimit") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listResourceLimits(ListResourceLimitsOptions... options); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClient.java index 9ca885b944..4687f3dfff 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClient.java @@ -25,22 +25,22 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.LoadBalancerRule; -import org.jclouds.cloudstack.domain.VirtualMachine; import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; +import org.jclouds.cloudstack.domain.VirtualMachine; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions; import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions; import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions; import org.jclouds.functions.JoinOnComma; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.ParamParser; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -63,7 +63,7 @@ public interface LoadBalancerAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listLoadBalancerRules", "true" }) @SelectJson("loadbalancerrule") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listLoadBalancerRules(ListLoadBalancerRulesOptions... options); /** @@ -74,7 +74,7 @@ public interface LoadBalancerAsyncClient { @SelectJson("loadbalancerrule") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getLoadBalancerRule(@QueryParam("id") String id); /** @@ -97,7 +97,7 @@ public interface LoadBalancerAsyncClient { @SelectJson("loadbalancerrule") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture updateLoadBalancerRule(@QueryParam("id") String id, UpdateLoadBalancerRuleOptions... options); /** @@ -107,7 +107,7 @@ public interface LoadBalancerAsyncClient { @QueryParams(keys = "command", values = "deleteLoadBalancerRule") @SelectJson("jobid") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture deleteLoadBalancerRule(@QueryParam("id") String id); /** @@ -115,7 +115,7 @@ public interface LoadBalancerAsyncClient { */ @GET @QueryParams(keys = "command", values = "assignToLoadBalancerRule") - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @SelectJson("jobid") @Consumes(MediaType.APPLICATION_JSON) ListenableFuture assignVirtualMachinesToLoadBalancerRule(@QueryParam("id") String id, @@ -126,7 +126,7 @@ public interface LoadBalancerAsyncClient { */ @GET @QueryParams(keys = "command", values = "assignToLoadBalancerRule") - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @SelectJson("jobid") @Consumes(MediaType.APPLICATION_JSON) ListenableFuture assignVirtualMachinesToLoadBalancerRule(@QueryParam("id") String id, @@ -137,7 +137,7 @@ public interface LoadBalancerAsyncClient { */ @GET @QueryParams(keys = "command", values = "removeFromLoadBalancerRule") - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @SelectJson("jobid") @Consumes(MediaType.APPLICATION_JSON) ListenableFuture removeVirtualMachinesFromLoadBalancerRule(@QueryParam("id") String id, @@ -148,7 +148,7 @@ public interface LoadBalancerAsyncClient { */ @GET @QueryParams(keys = "command", values = "removeFromLoadBalancerRule") - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) @SelectJson("jobid") @Consumes(MediaType.APPLICATION_JSON) ListenableFuture removeVirtualMachinesFromLoadBalancerRule(@QueryParam("id") String id, @@ -161,7 +161,7 @@ public interface LoadBalancerAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listLoadBalancerRuleInstances", "true" }) @SelectJson("loadbalancerruleinstance") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listVirtualMachinesAssignedToLoadBalancerRule(@QueryParam("id") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATAsyncClient.java index 283ae82fed..b2b8d82a15 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATAsyncClient.java @@ -25,19 +25,19 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.AsyncCreateResponse; import org.jclouds.cloudstack.domain.IPForwardingRule; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.CreateIPForwardingRuleOptions; import org.jclouds.cloudstack.options.ListIPForwardingRulesOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.Unwrap; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -62,7 +62,7 @@ public interface NATAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listIpForwardingRules", "true" }) @SelectJson("ipforwardingrule") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listIPForwardingRules(ListIPForwardingRulesOptions... options); /** @@ -73,7 +73,7 @@ public interface NATAsyncClient { @SelectJson("ipforwardingrule") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getIPForwardingRule(@QueryParam("id") String id); /** @@ -121,7 +121,7 @@ public interface NATAsyncClient { @QueryParams(keys = "command", values = "deleteIpForwardingRule") @SelectJson("jobid") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture deleteIPForwardingRule(@QueryParam("id") String id); /** diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NetworkAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NetworkAsyncClient.java index 86a9deca7c..9f358e9c14 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NetworkAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NetworkAsyncClient.java @@ -25,17 +25,17 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.Network; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.CreateNetworkOptions; import org.jclouds.cloudstack.options.ListNetworksOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -58,7 +58,7 @@ public interface NetworkAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listNetworks", "true" }) @SelectJson("network") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listNetworks(ListNetworksOptions... options); /** @@ -69,7 +69,7 @@ public interface NetworkAsyncClient { @SelectJson("network") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getNetwork(@QueryParam("id") String id); /** @@ -90,6 +90,6 @@ public interface NetworkAsyncClient { @QueryParams(keys = "command", values = "deleteNetwork") @SelectJson("jobid") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture deleteNetwork(@QueryParam("id") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/OfferingAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/OfferingAsyncClient.java index 3769c924fe..a73636ce00 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/OfferingAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/OfferingAsyncClient.java @@ -25,6 +25,8 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.DiskOffering; import org.jclouds.cloudstack.domain.NetworkOffering; import org.jclouds.cloudstack.domain.ServiceOffering; @@ -32,13 +34,11 @@ import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.ListDiskOfferingsOptions; import org.jclouds.cloudstack.options.ListNetworkOfferingsOptions; import org.jclouds.cloudstack.options.ListServiceOfferingsOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -61,7 +61,7 @@ public interface OfferingAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listServiceOfferings", "true" }) @SelectJson("serviceoffering") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listServiceOfferings(ListServiceOfferingsOptions... options); /** @@ -72,7 +72,7 @@ public interface OfferingAsyncClient { @SelectJson("serviceoffering") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getServiceOffering(@QueryParam("id") String id); /** @@ -82,7 +82,7 @@ public interface OfferingAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listDiskOfferings", "true" }) @SelectJson("diskoffering") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listDiskOfferings(ListDiskOfferingsOptions... options); /** @@ -93,7 +93,7 @@ public interface OfferingAsyncClient { @SelectJson("diskoffering") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getDiskOffering(@QueryParam("id") String id); /** @@ -103,7 +103,7 @@ public interface OfferingAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listNetworkOfferings", "true" }) @SelectJson("networkoffering") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listNetworkOfferings(ListNetworkOfferingsOptions... options); /** @@ -114,7 +114,7 @@ public interface OfferingAsyncClient { @SelectJson("networkoffering") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getNetworkOffering(@QueryParam("id") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClient.java index 99c6e5e7ae..27f99469f7 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClient.java @@ -25,17 +25,17 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.cloudstack.domain.SshKeyPair; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -57,7 +57,7 @@ public interface SSHKeyPairAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listSSHKeyPairs", "true" }) @SelectJson("sshkeypair") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listSSHKeyPairs(ListSSHKeyPairsOptions... options); /** @@ -86,7 +86,7 @@ public interface SSHKeyPairAsyncClient { @SelectJson("sshkeypair") @OnlyElement() @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getSSHKeyPair(@QueryParam("name") String name); /** @@ -94,7 +94,7 @@ public interface SSHKeyPairAsyncClient { */ @GET @QueryParams(keys = "command", values = "deleteSSHKeyPair") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture deleteSSHKeyPair(@QueryParam("name") String name); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SecurityGroupAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SecurityGroupAsyncClient.java index 27e54974ac..fcceaa173c 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SecurityGroupAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SecurityGroupAsyncClient.java @@ -25,6 +25,9 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.cloudstack.binders.BindAccountSecurityGroupPairsToIndexedQueryParams; import org.jclouds.cloudstack.binders.BindCIDRsToCommaDelimitedQueryParam; import org.jclouds.cloudstack.domain.SecurityGroup; @@ -32,14 +35,11 @@ import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.AccountInDomainOptions; import org.jclouds.cloudstack.options.ListSecurityGroupsOptions; import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.collect.Multimap; import com.google.common.util.concurrent.ListenableFuture; @@ -63,7 +63,7 @@ public interface SecurityGroupAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listSecurityGroups", "true" }) @SelectJson("securitygroup") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listSecurityGroups(ListSecurityGroupsOptions... options); /** @@ -74,7 +74,7 @@ public interface SecurityGroupAsyncClient { @SelectJson("securitygroup") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getSecurityGroup(@QueryParam("id") String id); /** @@ -141,7 +141,7 @@ public interface SecurityGroupAsyncClient { */ @GET @QueryParams(keys = "command", values = "revokeSecurityGroupIngress") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) @SelectJson("jobid") @Consumes(MediaType.APPLICATION_JSON) ListenableFuture revokeIngressRule(@QueryParam("id") String id, AccountInDomainOptions... options); @@ -151,7 +151,7 @@ public interface SecurityGroupAsyncClient { */ @GET @QueryParams(keys = "command", values = "deleteSecurityGroup") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture deleteSecurityGroup(@QueryParam("id") String id); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SessionAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SessionAsyncClient.java index 3ad40510bd..a984b36170 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SessionAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SessionAsyncClient.java @@ -23,13 +23,13 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.cloudstack.domain.LoginResponse; import org.jclouds.cloudstack.functions.ParseLoginResponseFromHttpResponse; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -51,7 +51,7 @@ public interface SessionAsyncClient { @QueryParams(keys = "command", values = "login") @ResponseParser(ParseLoginResponseFromHttpResponse.class) @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture loginUserInDomainWithHashOfPassword(@QueryParam("username") String userName, @QueryParam("domain") String domain, @QueryParam("password") String hashedPassword); @@ -60,6 +60,6 @@ public interface SessionAsyncClient { */ @GET @QueryParams(keys = "command", values = "logout") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture logoutUser(@QueryParam("sessionkey") String sessionKey); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SnapshotAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SnapshotAsyncClient.java index b2ba570c4f..c6ebccf709 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SnapshotAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SnapshotAsyncClient.java @@ -25,6 +25,9 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.cloudstack.binders.BindIdListToCommaDelimitedQueryParam; import org.jclouds.cloudstack.binders.BindSnapshotPolicyScheduleToQueryParam; import org.jclouds.cloudstack.domain.AsyncCreateResponse; @@ -36,15 +39,12 @@ import org.jclouds.cloudstack.options.CreateSnapshotOptions; import org.jclouds.cloudstack.options.ListSnapshotPoliciesOptions; import org.jclouds.cloudstack.options.ListSnapshotsOptions; import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.Unwrap; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -84,7 +84,7 @@ public interface SnapshotAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listSnapshots", "true" }) @SelectJson("snapshot") @Unwrap - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listSnapshots(ListSnapshotsOptions... options); /** @@ -98,7 +98,7 @@ public interface SnapshotAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listSnapshots", "true" }) @SelectJson("snapshot") @OnlyElement - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture getSnapshot(@QueryParam("id") String id); /** @@ -110,7 +110,7 @@ public interface SnapshotAsyncClient { @GET @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "command", values = "deleteSnapshot") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture deleteSnapshot(@QueryParam("id") String id); /** @@ -137,7 +137,7 @@ public interface SnapshotAsyncClient { @GET @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "command", values = "deleteSnapshotPolicies") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture deleteSnapshotPolicy(@QueryParam("id") String id); /** @@ -149,7 +149,7 @@ public interface SnapshotAsyncClient { @GET @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "command", values = "deleteSnapshotPolicies") - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Fallback(VoidOnNotFoundOr404.class) ListenableFuture deleteSnapshotPolicies(@BinderParam(BindIdListToCommaDelimitedQueryParam.class) Iterable id); /** @@ -163,6 +163,6 @@ public interface SnapshotAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = { "command", "listAll" }, values = { "listSnapshotPolicies", "true" }) @Unwrap - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listSnapshotPolicies(@QueryParam("volumeid") String volumeId, ListSnapshotPoliciesOptions... options); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/TemplateAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/TemplateAsyncClient.java index 0785b39524..56a956c298 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/TemplateAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/TemplateAsyncClient.java @@ -25,6 +25,8 @@ import javax.ws.rs.GET; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.binders.BindTemplateMetadataToQueryParams; import org.jclouds.cloudstack.domain.AsyncCreateResponse; import org.jclouds.cloudstack.domain.ExtractMode; @@ -41,14 +43,12 @@ import org.jclouds.cloudstack.options.RegisterTemplateOptions; import org.jclouds.cloudstack.options.UpdateTemplateOptions; import org.jclouds.cloudstack.options.UpdateTemplatePermissionsOptions; import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.Unwrap; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -124,7 +124,7 @@ public interface TemplateAsyncClient { @QueryParams(keys = { "command", "listAll", "templatefilter" }, values = { "listTemplates", "true", "executable" }) @SelectJson("template") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listTemplates(); /** @@ -134,7 +134,7 @@ public interface TemplateAsyncClient { @QueryParams(keys = { "command", "listAll" }, values = { "listTemplates", "true" }) @SelectJson("template") @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + @Fallback(EmptySetOnNotFoundOr404.class) ListenableFuture> listTemplates(ListTemplatesOptions options); /** @@ -146,7 +146,7 @@ public interface TemplateAsyncClient { @SelectJson("template") @OnlyElement @Consumes(MediaType.APPLICATION_JSON) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Fallback(NullOnNotFoundOr404.class) ListenableFuture