Some findbugs fixes in cloud-api project
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/394be902 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/394be902 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/394be902 Branch: refs/heads/vpc-toolkit-hugo Commit: 394be902ebf909c356eef06813f128a2b9a7410c Parents: e0d4af5 Author: Koushik Das <kous...@apache.org> Authored: Thu Jul 10 16:51:28 2014 +0530 Committer: Koushik Das <kous...@apache.org> Committed: Thu Jul 10 16:51:28 2014 +0530 ---------------------------------------------------------------------- .../api/command/admin/region/CreatePortableIpRangeCmd.java | 7 +++---- .../api/command/admin/region/ListPortableIpRangesCmd.java | 2 +- .../command/user/firewall/CreatePortForwardingRuleCmd.java | 2 +- .../user/loadbalancer/CreateLoadBalancerRuleCmd.java | 4 ++-- .../command/user/loadbalancer/ListLoadBalancerRulesCmd.java | 2 +- .../region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java | 4 ---- .../region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java | 9 +++------ 7 files changed, 11 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/394be902/api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java index 955bb9c..403eaf3 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java @@ -114,12 +114,11 @@ public class CreatePortableIpRangeCmd extends BaseAsyncCreateCmd { @Override public void execute() { PortableIpRange portableIpRange = _entityMgr.findById(PortableIpRange.class, getEntityId()); - PortableIpRangeResponse response = null; if (portableIpRange != null) { - response = _responseGenerator.createPortableIPRangeResponse(portableIpRange); + PortableIpRangeResponse response = _responseGenerator.createPortableIPRangeResponse(portableIpRange); + response.setResponseName(getCommandName()); + this.setResponseObject(response); } - response.setResponseName(getCommandName()); - this.setResponseObject(response); } @Override http://git-wip-us.apache.org/repos/asf/cloudstack/blob/394be902/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java index 100572e..ed0ddd6 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java @@ -98,8 +98,8 @@ public class ListPortableIpRangesCmd extends BaseListCmd { } responses.add(rangeResponse); } + response.setResponses(responses, portableIpRanges.size()); } - response.setResponses(responses, portableIpRanges.size()); response.setResponseName(getCommandName()); this.setResponseObject(response); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/394be902/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java index 865cd1b..3247af8 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java @@ -184,7 +184,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P if (ipAddressId != null) { IpAddress ipAddr = _networkService.getIp(ipAddressId); if (ipAddr == null || !ipAddr.readyToUse()) { - throw new InvalidParameterValueException("Unable to create PF rule, invalid IP address id " + ipAddr.getId()); + throw new InvalidParameterValueException("Unable to create PF rule, invalid IP address id " + ipAddressId); } else { return ipAddr.getVpcId(); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/394be902/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java index 7c37192..e33e584 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java @@ -153,7 +153,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements L if (publicIpId != null) { IpAddress ipAddr = _networkService.getIp(publicIpId); if (ipAddr == null || !ipAddr.readyToUse()) { - throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + ipAddr.getId()); + throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + publicIpId); } } else if (getEntityId() != null) { LoadBalancer rule = _entityMgr.findById(LoadBalancer.class, getEntityId()); @@ -167,7 +167,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements L if (publicIpId != null) { IpAddress ipAddr = _networkService.getIp(publicIpId); if (ipAddr == null || !ipAddr.readyToUse()) { - throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + ipAddr.getId()); + throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + publicIpId); } else { return ipAddr.getVpcId(); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/394be902/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRulesCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRulesCmd.java index df6c989..71d8232 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRulesCmd.java @@ -130,8 +130,8 @@ public class ListLoadBalancerRulesCmd extends BaseListTaggedResourcesCmd { lbResponse.setObjectName("loadbalancerrule"); lbResponses.add(lbResponse); } + response.setResponses(lbResponses, loadBalancers.second()); } - response.setResponses(lbResponses, loadBalancers.second()); response.setResponseName(getCommandName()); this.setResponseObject(response); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/394be902/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java index 177939b..8e1b4dd 100644 --- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java @@ -45,7 +45,6 @@ import com.cloud.region.ha.GlobalLoadBalancerRule; import com.cloud.region.ha.GlobalLoadBalancingRulesService; import com.cloud.user.Account; import com.cloud.utils.StringUtils; -import com.cloud.utils.db.EntityManager; @APICommand(name = "assignToGlobalLoadBalancerRule", description = "Assign load balancer rule or list of load " + "balancer rules to a global load balancer rules.", @@ -58,9 +57,6 @@ public class AssignToGlobalLoadBalancerRuleCmd extends BaseAsyncCmd { private static final String s_name = "assigntogloballoadbalancerruleresponse"; - @Inject - public EntityManager _entityMgr; - ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// http://git-wip-us.apache.org/repos/asf/cloudstack/blob/394be902/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java index 6782576..18f5b76 100644 --- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java @@ -147,15 +147,12 @@ public class CreateGlobalLoadBalancerRuleCmd extends BaseAsyncCreateCmd { @Override public void execute() throws ResourceAllocationException, ResourceUnavailableException { - - CallContext callerContext = CallContext.current(); GlobalLoadBalancerRule rule = _entityMgr.findById(GlobalLoadBalancerRule.class, getEntityId()); - GlobalLoadBalancerResponse response = null; if (rule != null) { - response = _responseGenerator.createGlobalLoadBalancerResponse(rule); - setResponseObject(response); + GlobalLoadBalancerResponse response = _responseGenerator.createGlobalLoadBalancerResponse(rule); + response.setResponseName(getCommandName()); + this.setResponseObject(response); } - response.setResponseName(getCommandName()); } @Override