return response;
}
@Override
public NetworkACLResponse createNetworkACLResponse(FirewallRule networkACL) {
NetworkACLResponse response = new NetworkACLResponse();
response.setId(networkACL.getUuid());
response.setProtocol(networkACL.getProtocol());
if (networkACL.getSourcePortStart() != null) {
response.setStartPort(Integer.toString(networkACL.getSourcePortStart()));
}
if (networkACL.getSourcePortEnd() != null) {
response.setEndPort(Integer.toString(networkACL.getSourcePortEnd()));
}
List<String> cidrs = ApiDBUtils.findFirewallSourceCidrs(networkACL.getId());
response.setCidrList(StringUtils.join(cidrs, ","));
response.setTrafficType(networkACL.getTrafficType().toString());
FirewallRule.State state = networkACL.getState();
String stateToSet = state.toString();
if (state.equals(FirewallRule.State.Revoke)) {
stateToSet = "Deleting";
}
response.setIcmpCode(networkACL.getIcmpCode());
response.setIcmpType(networkACL.getIcmpType());
response.setState(stateToSet);
//set tag information
List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.NetworkACL, networkACL.getId());
List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
for (ResourceTag tag : tags) {
ResourceTagResponse tagResponse = createResourceTagResponse(tag, true);
tagResponses.add(tagResponse);
}
response.setTags(tagResponses);
response.setObjectName("networkacl");
return response;
}