From f05115a9c42ed50dfc80d5dffcc12c750a186857 Mon Sep 17 00:00:00 2001 From: Jayapal Date: Wed, 4 Jul 2012 16:13:32 +0530 Subject: [PATCH] Bug: CS-15443, Fix for NPE while adding Firewall Rule --- api/src/com/cloud/api/commands/CreateFirewallRuleCmd.java | 5 +++-- api/src/com/cloud/api/commands/DeleteFirewallRuleCmd.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/src/com/cloud/api/commands/CreateFirewallRuleCmd.java b/api/src/com/cloud/api/commands/CreateFirewallRuleCmd.java index b13228b37c9..885405e64e0 100644 --- a/api/src/com/cloud/api/commands/CreateFirewallRuleCmd.java +++ b/api/src/com/cloud/api/commands/CreateFirewallRuleCmd.java @@ -33,6 +33,7 @@ import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.IpAddress; import com.cloud.network.rules.FirewallRule; +import com.cloud.network.rules.NetworkACL; import com.cloud.user.Account; import com.cloud.user.UserContext; import com.cloud.utils.net.NetUtils; @@ -117,13 +118,13 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal public void execute() throws ResourceUnavailableException { UserContext callerContext = UserContext.current(); boolean success = false; - FirewallRule rule = _entityMgr.findById(FirewallRule.class, getEntityId()); + FirewallRule rule = _entityMgr.findById(NetworkACL.class, getEntityId()); try { UserContext.current().setEventDetails("Rule Id: " + getEntityId()); success = _firewallService.applyFirewallRules(rule.getSourceIpAddressId(), callerContext.getCaller()); // State is different after the rule is applied, so get new object here - rule = _entityMgr.findById(FirewallRule.class, getEntityId()); + rule = _entityMgr.findById(NetworkACL.class, getEntityId()); FirewallResponse fwResponse = new FirewallResponse(); if (rule != null) { fwResponse = _responseGenerator.createFirewallResponse(rule); diff --git a/api/src/com/cloud/api/commands/DeleteFirewallRuleCmd.java b/api/src/com/cloud/api/commands/DeleteFirewallRuleCmd.java index 7d8f0e71174..0640be4f274 100644 --- a/api/src/com/cloud/api/commands/DeleteFirewallRuleCmd.java +++ b/api/src/com/cloud/api/commands/DeleteFirewallRuleCmd.java @@ -27,6 +27,7 @@ import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.rules.FirewallRule; +import com.cloud.network.rules.NetworkACL; import com.cloud.user.UserContext; @Implementation(description="Deletes a firewall rule", responseObject=SuccessResponse.class) @@ -75,11 +76,11 @@ public class DeleteFirewallRuleCmd extends BaseAsyncCmd { @Override public long getEntityOwnerId() { if (ownerId == null) { - FirewallRule rule = _entityMgr.findById(FirewallRule.class, id); + FirewallRule rule = _entityMgr.findById(NetworkACL.class, id); if (rule == null) { throw new InvalidParameterValueException("Unable to find firewall rule by id=" + id); } else { - ownerId = _entityMgr.findById(FirewallRule.class, id).getAccountId(); + ownerId = _entityMgr.findById(NetworkACL.class, id).getAccountId(); } } return ownerId;