String id = getParameterAsString(IPRangeProfile.ID);
String name = getParameterAsString(IPRangeProfile.NAME);
String description = getParameterAsString(IPRangeProfile.DESCRIPTION);
IPRange ipRange = getIpRangeManager().add(id);
ContainerUtil.enableLogging(ipRange, getLogger());
ipRange.setName(name);
ipRange.setDescription(description);
StringBuffer networkBuffer = new StringBuffer();
StringBuffer subnetBuffer = new StringBuffer();
for (int i = 0; i < 4; i++) {
if (i > 0) {
networkBuffer.append(".");
subnetBuffer.append(".");
}
Part netPart = (Part) getParameter(IPRangeProfile.NETWORK_ADDRESS + "-" + i);
networkBuffer.append(netPart.getValue());
Part subPart = (Part) getParameter(IPRangeProfile.SUBNET_MASK + "-" + i);
subnetBuffer.append(subPart.getValue());
}
InetAddress networkAddress = InetAddress.getByName(networkBuffer.toString());
ipRange.setNetworkAddress(networkAddress.getAddress());
InetAddress subnetMask = InetAddress.getByName(subnetBuffer.toString());
ipRange.setSubnetMask(subnetMask.getAddress());
ipRange.save();
setExitParameter(IPRangeProfile.ID, id);
}