mirror of https://github.com/apache/jclouds.git
attempting to operate against or retrieve pieces of a resource that doesn't exist should result in a ResourceNotFoundException, not null
This commit is contained in:
parent
70fa2b6c6d
commit
1fdfe5761f
|
@ -83,7 +83,6 @@ public interface NATAsyncClient {
|
|||
@QueryParams(keys = { "command", "listAll" }, values = { "listIpForwardingRules", "true" })
|
||||
@SelectJson("ipforwardingrule")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<IPForwardingRule>> getIPForwardingRulesForIPAddress(@QueryParam("ipaddressid") String id);
|
||||
|
||||
/**
|
||||
|
@ -93,7 +92,6 @@ public interface NATAsyncClient {
|
|||
@QueryParams(keys = { "command", "listAll" }, values = { "listIpForwardingRules", "true" })
|
||||
@SelectJson("ipforwardingrule")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<IPForwardingRule>> getIPForwardingRulesForVirtualMachine(@QueryParam("virtualmachineid") String id);
|
||||
|
||||
/**
|
||||
|
@ -133,7 +131,6 @@ public interface NATAsyncClient {
|
|||
@QueryParams(keys = "command", values = "disableStaticNat")
|
||||
@SelectJson("jobid")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<String> disableStaticNATOnPublicIP(@QueryParam("ipaddressid") String IPAddressId);
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.jclouds.concurrent.Timeout;
|
|||
* Provides synchronous access to CloudStack IPForwardingRule features.
|
||||
* <p/>
|
||||
*
|
||||
* @see IPForwardingRuleAsyncClient
|
||||
* @see NATAsyncClient
|
||||
* @see <a
|
||||
* href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html"
|
||||
* />
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
package org.jclouds.cloudstack.functions;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.cloudstack.CloudStackClient;
|
||||
import org.jclouds.cloudstack.domain.IPForwardingRule;
|
||||
|
||||
import com.google.common.cache.CacheLoader;
|
||||
|
||||
@Singleton
|
||||
public class GetIPForwardingRulesByVirtualMachine extends CacheLoader<String, Set<IPForwardingRule>> {
|
||||
private final CloudStackClient client;
|
||||
|
@ -24,7 +27,6 @@ public class GetIPForwardingRulesByVirtualMachine extends CacheLoader<String, Se
|
|||
*/
|
||||
@Override
|
||||
public Set<IPForwardingRule> load(String input) {
|
||||
Set<IPForwardingRule> rules = client.getNATClient().getIPForwardingRulesForVirtualMachine(input);
|
||||
return rules != null ? rules : ImmutableSet.<IPForwardingRule>of();
|
||||
return client.getNATClient().getIPForwardingRulesForVirtualMachine(input);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
|
|||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
|
||||
|
|
Loading…
Reference in New Issue