/** * Validates the ACL rule number field. If the field is null, then we do not have anything to check here. * If the number is not null, we perform the following checks: * <ul> * <li>If number is less than one, than we throw an {@link InvalidParameterValueException}; * <li>if there is already an ACL configured with the given number for the network, we also throw an {@link InvalidParameterValueException}. The check is performed using {@link NetworkACLItemDao#findByAclAndNumber(long, int)} method. * </ul> * * At the end, if not exception is thrown, the number of the ACL rule is valid. */ protected void validateAclRuleNumber(CreateNetworkACLCmd createNetworkAclCmd, NetworkACL acl) { Integer number = createNetworkAclCmd.getNumber(); if (number != null) { if (number < 1) { throw new InvalidParameterValueException(String.format("Invalid number [%d]. Number cannot be < 1", number)); } if (_networkACLItemDao.findByAclAndNumber(acl.getId(), createNetworkAclCmd.getNumber()) != null) { throw new InvalidParameterValueException("ACL item with number " + number + " already exists in ACL: " + acl.getUuid()); } } }
Integer number = updateNetworkACLItemCmd.getNumber(); if (number != null) { NetworkACLItemVO aclNumber = _networkACLItemDao.findByAclAndNumber(acl.getId(), number); if (aclNumber != null && aclNumber.getId() != networkACLItemVo.getId()) { throw new InvalidParameterValueException("ACL item with number " + number + " already exists in ACL: " + acl.getUuid());