@Override public void execute() { CallContext.current().setEventDetails("Rule ID: " + id); boolean result = _firewallService.revokeRelatedFirewallRule(id, true); result = result && _rulesService.revokeStaticNatRule(id, true); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete IP forwarding rule"); } }
@Override public void execute() throws ResourceUnavailableException { boolean result = true; FirewallRule rule = null; try { CallContext.current().setEventDetails("Rule ID: " + getEntityId()); if (getOpenFirewall()) { result = result && _firewallService.applyIngressFirewallRules(ipAddressId, CallContext.current().getCallingAccount()); } result = result && _rulesService.applyStaticNatRules(ipAddressId, CallContext.current().getCallingAccount()); rule = _entityMgr.findById(FirewallRule.class, getEntityId()); StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false); IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(staticNatRule); fwResponse.setResponseName(getCommandName()); setResponseObject(fwResponse); } finally { if (!result || rule == null) { if (getOpenFirewall()) { _firewallService.revokeRelatedFirewallRule(getEntityId(), true); } _rulesService.revokeStaticNatRule(getEntityId(), true); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Error in creating IP forwarding rule on the domr"); } } }
@Override public void execute() { CallContext.current().setEventDetails("Rule ID: " + id); boolean result = _firewallService.revokeRelatedFirewallRule(id, true); result = result && _rulesService.revokeStaticNatRule(id, true); if (result) { final SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete IP forwarding rule"); } }
@Override public void execute() throws ResourceUnavailableException { boolean result = true; FirewallRule rule = null; try { CallContext.current().setEventDetails("Rule ID: " + getEntityId()); if (getOpenFirewall()) { result = result && _firewallService.applyIngressFirewallRules(ipAddressId, CallContext.current().getCallingAccount()); } result = result && _rulesService.applyStaticNatRules(ipAddressId, CallContext.current().getCallingAccount()); rule = _entityMgr.findById(FirewallRule.class, getEntityId()); final StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false); final IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(staticNatRule); fwResponse.setResponseName(getCommandName()); setResponseObject(fwResponse); } finally { if (!result || rule == null) { if (getOpenFirewall()) { _firewallService.revokeRelatedFirewallRule(getEntityId(), true); } _rulesService.revokeStaticNatRule(getEntityId(), true); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Error in creating IP forwarding rule on the domr"); } } }