@Override public void execute() throws ResourceUnavailableException { boolean success = false; NetworkACLItem rule = _networkACLService.getNetworkACLItem(getEntityId()); try { CallContext.current().setEventDetails("Rule ID: " + getEntityId()); success = _networkACLService.applyNetworkACL(rule.getAclId()); // State is different after the rule is applied, so get new object here rule = _networkACLService.getNetworkACLItem(getEntityId()); NetworkACLItemResponse aclResponse = new NetworkACLItemResponse(); if (rule != null) { aclResponse = _responseGenerator.createNetworkACLItemResponse(rule); setResponseObject(aclResponse); } aclResponse.setResponseName(getCommandName()); } finally { if (!success || rule == null) { _networkACLService.revokeNetworkACLItem(getEntityId()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network ACL Item"); } } } }
@Override public void create() { NetworkACL result = _networkACLService.createNetworkACL(getName(), getDescription(), getVpcId(), isDisplay()); setEntityId(result.getId()); setEntityUuid(result.getUuid()); }
@Override public void create() { NetworkACLItem result = _networkACLService.createNetworkACLItem(this); setEntityId(result.getId()); setEntityUuid(result.getUuid()); }
@Override public void execute() throws ResourceUnavailableException { if (getNetworkId() == null && getPrivateGatewayId() == null) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Network ID and private gateway can't be null at the same time"); } if (getNetworkId() != null && getPrivateGatewayId() != null) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Network ID and private gateway can't be passed at the same time"); } CallContext.current().setEventDetails("Network ACL ID: " + aclId); boolean result = false; if (getPrivateGatewayId() != null) { result = _networkACLService.replaceNetworkACLonPrivateGw(aclId, privateGatewayId); } else { result = _networkACLService.replaceNetworkACL(aclId, networkId); } if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to replace network ACL"); } } }
@Override public void execute() throws ResourceUnavailableException { validateAPICall(); CallContext.current().setEventDetails("Network ACL ID: " + aclId); boolean result = false; if (getPrivateGatewayId() != null) { result = _networkACLService.replaceNetworkACLonPrivateGw(aclId, privateGatewayId); } else if (getNetworkId() != null) { result = _networkACLService.replaceNetworkACL(aclId, networkId); } else if (getPublicIpId() != null) { result = _networkACLService.replacePublicIpACL(aclId, publicIpId); } if (result) { final SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to replace network ACL"); } }
@Override public void execute() throws ResourceUnavailableException { CallContext.current().setEventDetails("Network ACL ID: " + id); boolean result = _networkACLService.deleteNetworkACL(id); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network ACL"); } } }
@Override public void execute() throws ResourceUnavailableException { NetworkACL acl = _networkACLService.getNetworkACL(getEntityId()); if (acl != null) { NetworkACLResponse aclResponse = _responseGenerator.createNetworkACLResponse(acl); setResponseObject(aclResponse); aclResponse.setResponseName(getCommandName()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network ACL"); } }
@Override public void execute() { Pair<List<? extends NetworkACL>, Integer> result = _networkACLService.listNetworkACLs(this); ListResponse<NetworkACLResponse> response = new ListResponse<NetworkACLResponse>(); List<NetworkACLResponse> aclResponses = new ArrayList<NetworkACLResponse>(); for (NetworkACL acl : result.first()) { NetworkACLResponse aclResponse = _responseGenerator.createNetworkACLResponse(acl); aclResponses.add(aclResponse); } response.setResponses(aclResponses, result.second()); response.setResponseName(getCommandName()); setResponseObject(response); } }
@Override public void execute() { Pair<List<? extends NetworkACLItem>, Integer> result = _networkACLService.listNetworkACLItems(this); ListResponse<NetworkACLItemResponse> response = new ListResponse<NetworkACLItemResponse>(); List<NetworkACLItemResponse> aclResponses = new ArrayList<NetworkACLItemResponse>(); for (NetworkACLItem acl : result.first()) { NetworkACLItemResponse ruleData = _responseGenerator.createNetworkACLItemResponse(acl); aclResponses.add(ruleData); } response.setResponses(aclResponses, result.second()); response.setResponseName(getCommandName()); setResponseObject(response); } }
@Override public void execute() throws ResourceUnavailableException { CallContext.current().setEventDetails("Network ACL ID: " + id); final boolean result = _networkACLService.deleteNetworkACL(id); if (result) { final SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network ACL"); } }
@Override public void execute() throws ResourceUnavailableException { final NetworkACL acl = _networkACLService.getNetworkACL(getEntityId()); if (acl != null) { final NetworkACLResponse aclResponse = _responseGenerator.createNetworkACLResponse(acl); setResponseObject(aclResponse); aclResponse.setResponseName(getCommandName()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network ACL"); } }
@Override public void execute() { final Pair<List<? extends NetworkACL>, Integer> result = _networkACLService.listNetworkACLs(this); final ListResponse<NetworkACLResponse> response = new ListResponse<>(); final List<NetworkACLResponse> aclResponses = new ArrayList<>(); for (final NetworkACL acl : result.first()) { final NetworkACLResponse aclResponse = _responseGenerator.createNetworkACLResponse(acl); aclResponses.add(aclResponse); } response.setResponses(aclResponses, result.second()); response.setResponseName(getCommandName()); setResponseObject(response); }
@Override public void execute() { final Pair<List<? extends NetworkACLItem>, Integer> result = _networkACLService.listNetworkACLItems(this); final ListResponse<NetworkACLItemResponse> response = new ListResponse<>(); final List<NetworkACLItemResponse> aclResponses = new ArrayList<>(); for (final NetworkACLItem acl : result.first()) { final NetworkACLItemResponse ruleData = _responseGenerator.createNetworkACLItemResponse(acl); aclResponses.add(ruleData); } response.setResponses(aclResponses, result.second()); response.setResponseName(getCommandName()); setResponseObject(response); }
@Override public void execute() throws ResourceUnavailableException { boolean success = false; NetworkACLItem rule = _networkACLService.getNetworkACLItem(getEntityId()); try { CallContext.current().setEventDetails("Rule ID: " + getEntityId()); success = _networkACLService.applyNetworkACL(rule.getAclId()); // State is different after the rule is applied, so get new object here rule = _networkACLService.getNetworkACLItem(getEntityId()); NetworkACLItemResponse aclResponse = new NetworkACLItemResponse(); if (rule != null) { aclResponse = _responseGenerator.createNetworkACLItemResponse(rule); setResponseObject(aclResponse); } aclResponse.setResponseName(getCommandName()); } finally { if (!success || rule == null) { _networkACLService.revokeNetworkACLItem(getEntityId()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network ACL Item"); } } }
@Override public void create() { final NetworkACL result = _networkACLService.createNetworkACL(getName(), getDescription(), getVpcId(), isDisplay()); setEntityId(result.getId()); setEntityUuid(result.getUuid()); }
@Override public void create() { final NetworkACLItem result = _networkACLService.createNetworkACLItem(this); setEntityId(result.getId()); setEntityUuid(result.getUuid()); }