Prep work for OPENDJ-2803 Migrate Attribute
Getting rid of calls to AttributeDescription.getNameOrOID():
Converted ArgN.get(..., attrDesc.getNameOrOID(), ...) to ArgN.get(..., attrDesc, ...)
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SCHEMA_MODIFY_UNSUPPORTED_ATTRIBUTE_TYPE.get(a.getAttributeDescription().getNameOrOID()); |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_UNSUPPORTED_ATTRIBUTE_TYPE.get(a.getAttributeDescription()); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | |
| | | case DELETE: |
| | | if (a.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SCHEMA_MODIFY_DELETE_NO_VALUES.get(a.getAttributeDescription().getNameOrOID()); |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_DELETE_NO_VALUES.get(a.getAttributeDescription()); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SCHEMA_MODIFY_UNSUPPORTED_ATTRIBUTE_TYPE.get(a.getAttributeDescription().getNameOrOID()); |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_UNSUPPORTED_ATTRIBUTE_TYPE.get(a.getAttributeDescription()); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | |
| | | DirectoryServer.getServerErrorResultCode(), |
| | | ERR_MEMORYBACKEND_ERROR_READING_LDIF.get(e), le); |
| | | } |
| | | else |
| | | { |
| | | continue; |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | importEntry(e); |
| | |
| | | if (pendingValueSet) |
| | | { |
| | | // We cannot have multiple pending values. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(attrDesc)); |
| | | } |
| | | if (a.isEmpty()) |
| | | { |
| | | // This is illegal -- it must have a value. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc)); |
| | | } |
| | | |
| | | // Get the value and parse it as a Boolean. |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | // This is illegal -- it must be single-valued. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // This is illegal -- only the pending option is allowed for |
| | | // configuration attributes. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(attrDesc)); |
| | | } |
| | | } |
| | | else |
| | |
| | | if (activeValueSet) |
| | | { |
| | | // We cannot have multiple active values. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(attrDesc)); |
| | | } |
| | | if (a.isEmpty()) |
| | | { |
| | | // This is illegal -- it must have a value. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc)); |
| | | } |
| | | |
| | | // Get the value and parse it as a Boolean. |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | // This is illegal -- it must be single-valued. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc)); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | |
| | | /** |
| | | * This class defines a DN configuration attribute, which can hold zero or more |
| | |
| | | if (pendingValues != null) |
| | | { |
| | | // We cannot have multiple pending value sets. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(attrDesc.getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(attrDesc)); |
| | | } |
| | | |
| | | |
| | |
| | | if (isRequired()) |
| | | { |
| | | // This is illegal -- it must have a value. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc)); |
| | | } |
| | | // This is fine. The pending value set can be empty. |
| | | pendingValues = new ArrayList<>(0); |
| | |
| | | if (numValues > 1 && !isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc)); |
| | | } |
| | | |
| | | pendingValues = new ArrayList<>(numValues); |
| | |
| | | { |
| | | // This is illegal -- only the pending option is allowed for |
| | | // configuration attributes. |
| | | throw new ConfigException( |
| | | ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(attrDesc)); |
| | | } |
| | | } |
| | | else |
| | |
| | | if (activeValues!= null) |
| | | { |
| | | // We cannot have multiple active value sets. |
| | | throw new ConfigException( |
| | | ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(attrDesc)); |
| | | } |
| | | |
| | | |
| | |
| | | if (isRequired()) |
| | | { |
| | | // This is illegal -- it must have a value. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc)); |
| | | } |
| | | // This is fine. The active value set can be empty. |
| | | activeValues = new ArrayList<>(0); |
| | |
| | | if (numValues > 1 && !isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc)); |
| | | } |
| | | |
| | | activeValues = new ArrayList<>(numValues); |
| | |
| | | if (pendingValues != null) |
| | | { |
| | | // We cannot have multiple pending value sets. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(a.getAttributeDescription().getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(attrDesc)); |
| | | } |
| | | |
| | | if (a.isEmpty()) |
| | |
| | | if (isRequired()) |
| | | { |
| | | // This is illegal -- it must have a value. |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getAttributeDescription().getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc)); |
| | | } |
| | | else |
| | | { |
| | |
| | | if (numValues > 1 && !isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(a.getAttributeDescription().getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc)); |
| | | } |
| | | |
| | | pendingValues = new ArrayList<>(numValues); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_INT_COULD_NOT_PARSE.get( |
| | | v, a.getAttributeDescription().getNameOrOID(), e); |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_INT_COULD_NOT_PARSE.get(v, attrDesc, e); |
| | | throw new ConfigException(message, e); |
| | | } |
| | | |
| | | // Check the bounds set for this attribute. |
| | | if (hasLowerBound && longValue < lowerBound) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_INT_BELOW_LOWER_BOUND.get( |
| | | a.getAttributeDescription().getNameOrOID(), longValue, lowerBound); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_INT_BELOW_LOWER_BOUND.get(attrDesc, longValue, lowerBound)); |
| | | } |
| | | |
| | | if (hasUpperBound && longValue > upperBound) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_INT_ABOVE_UPPER_BOUND.get( |
| | | a.getAttributeDescription().getNameOrOID(), longValue, upperBound); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_INT_ABOVE_UPPER_BOUND.get(attrDesc, longValue, upperBound)); |
| | | } |
| | | |
| | | pendingValues.add(longValue); |
| | |
| | | { |
| | | // This is illegal -- only the pending option is allowed for |
| | | // configuration attributes. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get( |
| | | a.getAttributeDescription().getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(attrDesc)); |
| | | } |
| | | } |
| | | else |
| | |
| | | if (activeValues!= null) |
| | | { |
| | | // We cannot have multiple active value sets. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(a.getAttributeDescription().getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(attrDesc)); |
| | | } |
| | | |
| | | if (a.isEmpty()) |
| | |
| | | if (isRequired()) |
| | | { |
| | | // This is illegal -- it must have a value. |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getAttributeDescription().getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc)); |
| | | } |
| | | else |
| | | { |
| | |
| | | if (numValues > 1 && !isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(a.getAttributeDescription().getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc)); |
| | | } |
| | | |
| | | activeValues = new ArrayList<>(numValues); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_INT_COULD_NOT_PARSE.get( |
| | | v, a.getAttributeDescription().getNameOrOID(), e); |
| | | throw new ConfigException(message, e); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_INT_COULD_NOT_PARSE.get(v, attrDesc, e), e); |
| | | } |
| | | |
| | | // Check the bounds set for this attribute. |
| | | if (hasLowerBound && longValue < lowerBound) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_INT_BELOW_LOWER_BOUND.get( |
| | | a.getAttributeDescription().getNameOrOID(), longValue, lowerBound); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_INT_BELOW_LOWER_BOUND.get(attrDesc, longValue, lowerBound)); |
| | | } |
| | | |
| | | if (hasUpperBound && longValue > upperBound) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_INT_ABOVE_UPPER_BOUND.get( |
| | | a.getAttributeDescription().getNameOrOID(), longValue, upperBound); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_INT_ABOVE_UPPER_BOUND.get(attrDesc, longValue, upperBound)); |
| | | } |
| | | |
| | | activeValues.add(longValue); |
| | |
| | | if (!attrDesc.hasOption(OPTION_PENDING_VALUES)) |
| | | { |
| | | // This is illegal -- only the pending option is allowed for configuration attributes. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(attrDesc)); |
| | | } |
| | | if (pendingUnit != null) |
| | | { |
| | | // We cannot have multiple pending value sets. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(attrDesc)); |
| | | } |
| | | |
| | | String valueString = getValue(a); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_COULD_NOT_PARSE_INT_COMPONENT.get( |
| | | valueString, attrDesc.getNameOrOID(), e)); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_COULD_NOT_PARSE_INT_COMPONENT.get(valueString, attrDesc, e)); |
| | | } |
| | | |
| | | pendingCalculatedValue = calculateValue(pendingIntValue, activeUnit, pendingUnit, a); |
| | |
| | | if (activeUnit != null) |
| | | { |
| | | // We cannot have multiple active value sets. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(attrDesc)); |
| | | } |
| | | |
| | | String valueString = getValue(a); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_COULD_NOT_PARSE_INT_COMPONENT.get( |
| | | valueString, attrDesc.getNameOrOID(), e)); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_COULD_NOT_PARSE_INT_COMPONENT.get(valueString, attrDesc, e)); |
| | | } |
| | | |
| | | activeCalculatedValue = calculateValue(activeIntValue, activeUnit, activeUnit, a); |
| | |
| | | if (a.isEmpty()) |
| | | { |
| | | // This is illegal -- it must have a value. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc)); |
| | | } |
| | | |
| | | Iterator<ByteString> iterator = a.iterator(); |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc)); |
| | | } |
| | | return valueString; |
| | | } |
| | |
| | | AttributeDescription attrDesc = a.getAttributeDescription(); |
| | | if (!units.containsKey(pendingUnit)) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_INVALID_UNIT.get(pendingUnit, attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_INVALID_UNIT.get(pendingUnit, attrDesc)); |
| | | } |
| | | |
| | | double multiplier = units.get(activeUnit); |
| | |
| | | // Check the bounds set for this attribute. |
| | | if (hasLowerBound && result < lowerBound) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_INT_BELOW_LOWER_BOUND.get(attrDesc.getNameOrOID(), result, lowerBound)); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_INT_BELOW_LOWER_BOUND.get(attrDesc, result, lowerBound)); |
| | | } |
| | | if (hasUpperBound && result > upperBound) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_INT_ABOVE_UPPER_BOUND.get(attrDesc.getNameOrOID(), result, upperBound)); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_INT_ABOVE_UPPER_BOUND.get(attrDesc, result, upperBound)); |
| | | } |
| | | return result; |
| | | } |
| | |
| | | if (pendingValues != null) |
| | | { |
| | | // We cannot have multiple pending value sets. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(attrDesc.getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(attrDesc)); |
| | | } |
| | | |
| | | |
| | |
| | | if (isRequired()) |
| | | { |
| | | // This is illegal -- it must have a value. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc)); |
| | | } |
| | | // This is fine. The pending value set can be empty. |
| | | pendingValues = new ArrayList<>(0); |
| | |
| | | if (numValues > 1 && !isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc.getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc)); |
| | | } |
| | | |
| | | pendingValues = new ArrayList<>(numValues); |
| | |
| | | if (! allowedValues.contains(lowerValue)) |
| | | { |
| | | // This is illegal -- the value is not allowed. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(v, attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(v, attrDesc)); |
| | | } |
| | | |
| | | pendingValues.add(v.toString()); |
| | |
| | | { |
| | | // This is illegal -- only the pending option is allowed for |
| | | // configuration attributes. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(attrDesc.getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(attrDesc)); |
| | | } |
| | | } |
| | | else |
| | |
| | | if (activeValues!= null) |
| | | { |
| | | // We cannot have multiple active value sets. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(attrDesc.getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(attrDesc)); |
| | | } |
| | | |
| | | |
| | |
| | | if (isRequired()) |
| | | { |
| | | // This is illegal -- it must have a value. |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc.getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc)); |
| | | } |
| | | // This is fine. The active value set can be empty. |
| | | activeValues = new ArrayList<>(0); |
| | |
| | | if (numValues > 1 && ! isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc.getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc)); |
| | | } |
| | | |
| | | activeValues = new ArrayList<>(numValues); |
| | |
| | | if (! allowedValues.contains(lowerValue)) |
| | | { |
| | | // This is illegal -- the value is not allowed. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(v, attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(v, attrDesc)); |
| | | } |
| | | |
| | | activeValues.add(v.toString()); |
| | |
| | | if (pendingValues != null) |
| | | { |
| | | // We cannot have multiple pending value sets. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(attrDesc)); |
| | | } |
| | | |
| | | |
| | |
| | | if (isRequired()) |
| | | { |
| | | // This is illegal -- it must have a value. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc)); |
| | | } |
| | | // This is fine. The pending value set can be empty. |
| | | pendingValues = new ArrayList<>(0); |
| | |
| | | if (numValues > 1 && !isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc.getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc)); |
| | | } |
| | | |
| | | pendingValues = new ArrayList<>(numValues); |
| | |
| | | { |
| | | // This is illegal -- only the pending option is allowed for |
| | | // configuration attributes. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(attrDesc)); |
| | | } |
| | | } |
| | | else |
| | |
| | | if (activeValues!= null) |
| | | { |
| | | // We cannot have multiple active value sets. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(attrDesc)); |
| | | } |
| | | |
| | | |
| | |
| | | if (isRequired()) |
| | | { |
| | | // This is illegal -- it must have a value. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc.getNameOrOID())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(attrDesc)); |
| | | } |
| | | // This is fine. The active value set can be empty. |
| | | activeValues = new ArrayList<>(0); |
| | |
| | | if (numValues > 1 && !isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc.getNameOrOID()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(attrDesc)); |
| | | } |
| | | |
| | | activeValues = new ArrayList<>(numValues); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | try |
| | | { |
| | | Attribute attr = a.toAttribute(); |
| | | AttributeType attrType = attr.getAttributeDescription().getAttributeType(); |
| | | AttributeDescription attrDesc = attr.getAttributeDescription(); |
| | | AttributeType attrType = attrDesc.getAttributeType(); |
| | | |
| | | // If the attribute type is marked "NO-USER-MODIFICATION" then fail |
| | | // unless this is an internal operation or is related to |
| | |
| | | && !isSynchronizationOperation()) |
| | | { |
| | | throw new LDAPException(LDAPResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_ADD_ATTR_IS_NO_USER_MOD.get(entryDN, attr.getAttributeDescription().getNameOrOID())); |
| | | ERR_ADD_ATTR_IS_NO_USER_MOD.get(entryDN, attrDesc)); |
| | | } |
| | | |
| | | boolean hasBinaryOption = attr.getAttributeDescription().hasOption("binary"); |
| | | if(attrType.getSyntax().isBEREncodingRequired()) |
| | | boolean hasBinaryOption = attrDesc.hasOption("binary"); |
| | | if (attrType.getSyntax().isBEREncodingRequired()) |
| | | { |
| | | if (!hasBinaryOption) |
| | | { |
| | |
| | | { |
| | | // binary option is not honored for non-BER-encodable attributes. |
| | | throw new LDAPException(LDAPResultCode.UNDEFINED_ATTRIBUTE_TYPE, |
| | | ERR_ADD_ATTR_IS_INVALID_OPTION.get(entryDN, attr.getAttributeDescription().getNameOrOID())); |
| | | ERR_ADD_ATTR_IS_INVALID_OPTION.get(entryDN, attrDesc)); |
| | | } |
| | | |
| | | if (attrType.isObjectClass()) |
| | |
| | | for (ByteString os : a.getValues()) |
| | | { |
| | | String ocName = os.toString(); |
| | | ObjectClass oc = |
| | | DirectoryServer.getObjectClass(toLowerCase(ocName)); |
| | | ObjectClass oc = DirectoryServer.getObjectClass(toLowerCase(ocName)); |
| | | if (oc == null) |
| | | { |
| | | oc = DirectoryServer.getDefaultObjectClass(ocName); |
| | |
| | | boolean attributeSeen = false; |
| | | for (int i = 0; i < attrs.size(); i++) { |
| | | Attribute ea = attrs.get(i); |
| | | if (ea.getAttributeDescription().equals(attr.getAttributeDescription())) |
| | | if (ea.getAttributeDescription().equals(attrDesc)) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(ea); |
| | | builder.addAll(attr); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.AbstractOperation; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.CancelResult; |
| | | import org.opends.server.types.CanceledOperationException; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.OperationType; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.types.operation.PostResponseModifyOperation; |
| | | import org.opends.server.types.operation.PreParseModifyOperation; |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendModifyOperation; |
| | |
| | | { |
| | | Modification mod = m.toModification(); |
| | | Attribute attr = mod.getAttribute(); |
| | | AttributeType type = attr.getAttributeDescription().getAttributeType(); |
| | | AttributeDescription attrDesc = attr.getAttributeDescription(); |
| | | |
| | | boolean hasBinaryOption = attr.getAttributeDescription().hasOption("binary"); |
| | | if (type.getSyntax().isBEREncodingRequired()) |
| | | boolean hasBinaryOption = attrDesc.hasOption("binary"); |
| | | if (attrDesc.getAttributeType().getSyntax().isBEREncodingRequired()) |
| | | { |
| | | if (!hasBinaryOption) |
| | | { |
| | | //A binary option wasn't provided by the client so add it. |
| | | AttributeBuilder builder = new AttributeBuilder(attr); |
| | | builder.setOption("binary"); |
| | | attr = builder.toAttribute(); |
| | | mod.setAttribute(attr); |
| | | mod.setAttribute(builder.toAttribute()); |
| | | } |
| | | } |
| | | else if (hasBinaryOption) |
| | | { |
| | | // binary option is not honored for non-BER-encodable attributes. |
| | | throw new LDAPException(LDAPResultCode.UNDEFINED_ATTRIBUTE_TYPE, |
| | | ERR_ADD_ATTR_IS_INVALID_OPTION.get(entryDN, attr.getAttributeDescription().getNameOrOID())); |
| | | ERR_ADD_ATTR_IS_INVALID_OPTION.get(entryDN, attrDesc)); |
| | | } |
| | | |
| | | modifications.add(mod); |
| | |
| | | && valueEntryDN.isInScopeOf(entryBaseDN, SearchScope.SUBORDINATES)) |
| | | { |
| | | return PluginResult.PreOperation.stopProcessing(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_PLUGIN_REFERENT_NAMINGCONTEXT_MISMATCH.get(valueEntryDN, attrDesc.getNameOrOID(), entryDN)); |
| | | ERR_PLUGIN_REFERENT_NAMINGCONTEXT_MISMATCH.get(valueEntryDN, attrDesc, entryDN)); |
| | | } |
| | | valueEntry = DirectoryServer.getEntry(valueEntryDN); |
| | | |
| | |
| | | if (valueEntry == null) |
| | | { |
| | | return PluginResult.PreOperation.stopProcessing(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_PLUGIN_REFERENT_ENTRY_MISSING.get(valueEntryDN, attrDesc.getNameOrOID(), entryDN)); |
| | | ERR_PLUGIN_REFERENT_ENTRY_MISSING.get(valueEntryDN, attrDesc, entryDN)); |
| | | } |
| | | |
| | | // Verify that the value entry conforms to the filter. |
| | |
| | | if (filter != null && !filter.matchesEntry(valueEntry)) |
| | | { |
| | | return PluginResult.PreOperation.stopProcessing(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_PLUGIN_REFERENT_FILTER_MISMATCH.get(valueEntry.getName(), attrDesc.getNameOrOID(), entryDN, filter)); |
| | | ERR_PLUGIN_REFERENT_FILTER_MISMATCH.get(valueEntry.getName(), attrDesc, entryDN, filter)); |
| | | } |
| | | } |
| | | } |
| | |
| | | Attribute a = getExactAttribute(attribute.getAttributeDescription()); |
| | | if (a == null) |
| | | { |
| | | LocalizableMessage message = ERR_ENTRY_INCREMENT_NO_SUCH_ATTRIBUTE.get( |
| | | attribute.getAttributeDescription().getNameOrOID()); |
| | | LocalizableMessage message = ERR_ENTRY_INCREMENT_NO_SUCH_ATTRIBUTE.get(attribute.getAttributeDescription()); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE, message); |
| | | } |
| | | |
| | |
| | | Iterator<ByteString> i = attribute.iterator(); |
| | | if (!i.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_ENTRY_INCREMENT_INVALID_VALUE_COUNT.get( |
| | | attribute.getAttributeDescription().getNameOrOID()); |
| | | LocalizableMessage message = ERR_ENTRY_INCREMENT_INVALID_VALUE_COUNT.get(attribute.getAttributeDescription()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | String incrementValue = i.next().toString(); |
| | | long increment; |
| | | try |
| | | { |
| | | increment = Long.parseLong(incrementValue); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | LocalizableMessage message = ERR_ENTRY_INCREMENT_CANNOT_PARSE_AS_INT.get( |
| | | attribute.getAttributeDescription().getNameOrOID()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | long increment = parseLong(incrementValue, attribute); |
| | | |
| | | if (i.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_ENTRY_INCREMENT_INVALID_VALUE_COUNT.get( |
| | | attribute.getAttributeDescription().getNameOrOID()); |
| | | LocalizableMessage message = ERR_ENTRY_INCREMENT_INVALID_VALUE_COUNT.get(attribute.getAttributeDescription()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | |
| | | |
| | | for (ByteString v : a) |
| | | { |
| | | long currentValue; |
| | | try |
| | | { |
| | | currentValue = Long.parseLong(v.toString()); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | LocalizableMessage message = ERR_ENTRY_INCREMENT_CANNOT_PARSE_AS_INT.get( |
| | | attribute.getAttributeDescription().getNameOrOID()); |
| | | throw new DirectoryException( |
| | | ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | long currentValue = parseLong(v.toString(), attribute); |
| | | long newValue = currentValue + increment; |
| | | builder.add(String.valueOf(newValue)); |
| | | } |
| | |
| | | replaceAttribute(builder.toAttribute()); |
| | | } |
| | | |
| | | private long parseLong(String value, Attribute attribute) throws DirectoryException |
| | | { |
| | | try |
| | | { |
| | | return Long.parseLong(value); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | LocalizableMessage message = ERR_ENTRY_INCREMENT_CANNOT_PARSE_AS_INT.get(attribute.getAttributeDescription()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | { |
| | | if (!relaxConstraints) |
| | | { |
| | | LocalizableMessage message = ERR_ENTRY_DUPLICATE_VALUES.get(a.getAttributeDescription().getNameOrOID()); |
| | | LocalizableMessage message = ERR_ENTRY_DUPLICATE_VALUES.get(a.getAttributeDescription()); |
| | | throw new DirectoryException(ATTRIBUTE_OR_VALUE_EXISTS, message); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (objectClasses.remove(oc) == null && !relaxConstraints) |
| | | { |
| | | LocalizableMessage message = ERR_ENTRY_NO_SUCH_VALUE.get(a.getAttributeDescription().getNameOrOID()); |
| | | LocalizableMessage message = ERR_ENTRY_NO_SUCH_VALUE.get(a.getAttributeDescription()); |
| | | throw new DirectoryException(NO_SUCH_ATTRIBUTE, message); |
| | | } |
| | | } |
| | |
| | | addAttribute(a, duplicateValues); |
| | | if (!duplicateValues.isEmpty() && !relaxConstraints) |
| | | { |
| | | LocalizableMessage message = ERR_ENTRY_DUPLICATE_VALUES.get(a.getAttributeDescription().getNameOrOID()); |
| | | LocalizableMessage message = ERR_ENTRY_DUPLICATE_VALUES.get(a.getAttributeDescription()); |
| | | throw new DirectoryException(ATTRIBUTE_OR_VALUE_EXISTS, message); |
| | | } |
| | | break; |
| | |
| | | removeAttribute(a, missingValues); |
| | | if (!missingValues.isEmpty() && !relaxConstraints) |
| | | { |
| | | LocalizableMessage message = ERR_ENTRY_NO_SUCH_VALUE.get(a.getAttributeDescription().getNameOrOID()); |
| | | LocalizableMessage message = ERR_ENTRY_NO_SUCH_VALUE.get(a.getAttributeDescription()); |
| | | throw new DirectoryException(NO_SUCH_ATTRIBUTE, message); |
| | | } |
| | | break; |
| | |
| | | for (Map.Entry<AttributeType, List<Attribute>> e : userAttributes.entrySet()) |
| | | { |
| | | AttributeType t = e.getKey(); |
| | | if (t.hasNameOrOID(attrName)) |
| | | if (t.hasNameOrOID(attrType.getNameOrOID())) |
| | | { |
| | | mergeAttributeLists(e.getValue(), userAttrsCopy, attrDesc, |
| | | omitValues, omitReal, omitVirtual); |
| | |
| | | for (Map.Entry<AttributeType, List<Attribute>> e : operationalAttributes.entrySet()) |
| | | { |
| | | AttributeType t = e.getKey(); |
| | | if (t.hasNameOrOID(attrName)) |
| | | if (t.hasNameOrOID(attrType.getNameOrOID())) |
| | | { |
| | | mergeAttributeLists(e.getValue(), operationalAttrsCopy, attrDesc, |
| | | omitValues, omitReal, omitVirtual); |
| | |
| | | { |
| | | // Parse the attribute type description. |
| | | int colonPos = parseColonPosition(lines, line); |
| | | String attrDescr = line.substring(0, colonPos); |
| | | AttributeDescription attrDesc = parseAttrDescription(attrDescr); |
| | | String attrName = attrDesc.getNameOrOID(); |
| | | String attrDescStr = line.substring(0, colonPos); |
| | | AttributeDescription attrDesc = parseAttrDescription(attrDescStr); |
| | | |
| | | if (attributeName != null) |
| | | { |
| | | AttributeDescription expectedAttrDesc = parseAttrDescription(attributeName); |
| | | if (!attrDesc.equals(expectedAttrDesc)) |
| | | { |
| | | LocalizableMessage message = ERR_LDIF_INVALID_CHANGERECORD_ATTRIBUTE.get( |
| | | attrDescr, attributeName); |
| | | LocalizableMessage message = ERR_LDIF_INVALID_CHANGERECORD_ATTRIBUTE.get(attrDescStr, attributeName); |
| | | throw new LDIFException(message, lastEntryLineNumber, false); |
| | | } |
| | | } |
| | | |
| | | // Now parse the attribute value. |
| | | ByteString value = parseSingleValue(lines, line, entryDN, |
| | | colonPos, attrName); |
| | | ByteString value = parseSingleValue(lines, line, entryDN, colonPos, attrDescStr); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(attrDesc); |
| | | builder.add(value); |
| | |
| | | { |
| | | StringBuilder line = lines.remove(); |
| | | Attribute attr = readSingleValueAttribute(lines, line, entryDN, null); |
| | | String name = attr.getAttributeDescription().getNameOrOID(); |
| | | |
| | | // Get the attribute description |
| | | String attrDescr = attr.iterator().next().toString(); |
| | | String attrDescStr = attr.iterator().next().toString(); |
| | | |
| | | ModificationType modType; |
| | | String lowerName = toLowerCase(name); |
| | | if (lowerName.equals("add")) |
| | | { |
| | | modType = ModificationType.ADD; |
| | | } |
| | | else if (lowerName.equals("delete")) |
| | | { |
| | | modType = ModificationType.DELETE; |
| | | } |
| | | else if (lowerName.equals("replace")) |
| | | { |
| | | modType = ModificationType.REPLACE; |
| | | } |
| | | else if (lowerName.equals("increment")) |
| | | { |
| | | modType = ModificationType.INCREMENT; |
| | | } |
| | | else |
| | | { |
| | | // Invalid attribute name. |
| | | LocalizableMessage message = ERR_LDIF_INVALID_MODIFY_ATTRIBUTE.get(name, |
| | | "add, delete, replace, increment"); |
| | | throw new LDIFException(message, lineNumber, true); |
| | | } |
| | | String name = attr.getAttributeDescription().getAttributeType().getNameOrOID(); |
| | | ModificationType modType = toModType(name); |
| | | |
| | | // Now go through the rest of the attributes till the "-" line is reached. |
| | | AttributeDescription modAttrDesc = LDIFReader.parseAttrDescription(attrDescr); |
| | | AttributeDescription modAttrDesc = LDIFReader.parseAttrDescription(attrDescStr); |
| | | AttributeBuilder builder = new AttributeBuilder(modAttrDesc); |
| | | while (! lines.isEmpty()) |
| | | { |
| | |
| | | { |
| | | break; |
| | | } |
| | | Attribute a = readSingleValueAttribute(lines, line, entryDN, attrDescr); |
| | | builder.addAll(a); |
| | | builder.addAll(readSingleValueAttribute(lines, line, entryDN, attrDescStr)); |
| | | } |
| | | |
| | | LDAPAttribute ldapAttr = new LDAPAttribute(builder.toAttribute()); |
| | | LDAPModification mod = new LDAPModification(modType, ldapAttr); |
| | | modifications.add(mod); |
| | | modifications.add(new LDAPModification(modType, ldapAttr)); |
| | | } |
| | | |
| | | return new ModifyChangeRecordEntry(entryDN, modifications); |
| | | } |
| | | |
| | | |
| | | private ModificationType toModType(String name) throws LDIFException |
| | | { |
| | | if ("add".equalsIgnoreCase(name)) |
| | | { |
| | | return ModificationType.ADD; |
| | | } |
| | | else if ("delete".equalsIgnoreCase(name)) |
| | | { |
| | | return ModificationType.DELETE; |
| | | } |
| | | else if ("replace".equalsIgnoreCase(name)) |
| | | { |
| | | return ModificationType.REPLACE; |
| | | } |
| | | else if ("increment".equalsIgnoreCase(name)) |
| | | { |
| | | return ModificationType.INCREMENT; |
| | | } |
| | | else |
| | | { |
| | | // Invalid attribute name. |
| | | LocalizableMessage message = ERR_LDIF_INVALID_MODIFY_ATTRIBUTE.get(name, "add, delete, replace, increment"); |
| | | throw new LDIFException(message, lineNumber, true); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Parse a delete change record entry from LDIF. |
| | |
| | | if (!syntax.isHumanReadable() || syntax.isBEREncodingRequired()) |
| | | { |
| | | // Value is not human-readable |
| | | message = WARN_ADD_OP_INVALID_SYNTAX_NO_VALUE. |
| | | get(entryDN, a.getAttributeDescription().getNameOrOID(), invalidReason); |
| | | message = WARN_ADD_OP_INVALID_SYNTAX_NO_VALUE.get(entryDN, a.getAttributeDescription(), invalidReason); |
| | | } |
| | | else |
| | | { |
| | | message = WARN_ADD_OP_INVALID_SYNTAX. |
| | | get(entryDN, v, a.getAttributeDescription().getNameOrOID(), invalidReason); |
| | | message = WARN_ADD_OP_INVALID_SYNTAX.get(entryDN, v, a.getAttributeDescription(), invalidReason); |
| | | } |
| | | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | |
| | | && !isSynchronizationOperation()) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_MODDN_OLD_RDN_ATTR_IS_NO_USER_MOD.get(entryDN, a.getAttributeDescription().getNameOrOID())); |
| | | ERR_MODDN_OLD_RDN_ATTR_IS_NO_USER_MOD.get(entryDN, a.getAttributeDescription())); |
| | | } |
| | | |
| | | List<ByteString> missingValues = new LinkedList<>(); |
| | |
| | | if (!isInternalOperation() && !isSynchronizationOperation()) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_MODDN_NEW_RDN_ATTR_IS_NO_USER_MOD.get(entryDN, a.getAttributeDescription().getNameOrOID())); |
| | | ERR_MODDN_NEW_RDN_ATTR_IS_NO_USER_MOD.get(entryDN, a.getAttributeDescription())); |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | throw newDirectoryException(currentEntry, |
| | | ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_MODIFY_ATTR_IS_NO_USER_MOD.get(entryDN, attrDesc.getNameOrOID())); |
| | | ERR_MODIFY_ATTR_IS_NO_USER_MOD.get(entryDN, attrDesc)); |
| | | } |
| | | |
| | | // If the attribute type is marked "OBSOLETE" and the modification is |
| | |
| | | { |
| | | throw newDirectoryException(currentEntry, |
| | | ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_MODIFY_ATTR_IS_OBSOLETE.get(entryDN, attrDesc.getNameOrOID())); |
| | | ERR_MODIFY_ATTR_IS_OBSOLETE.get(entryDN, attrDesc)); |
| | | } |
| | | |
| | | |
| | |
| | | default: |
| | | AttributeDescription attrDesc = m.getAttribute().getAttributeDescription(); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_MODIFY_INVALID_MOD_TYPE_FOR_PASSWORD.get(m.getModificationType(), attrDesc.getNameOrOID())); |
| | | ERR_MODIFY_INVALID_MOD_TYPE_FOR_PASSWORD.get(m.getModificationType(), attrDesc)); |
| | | } |
| | | } |
| | | |
| | |
| | | if (attr.isEmpty()) |
| | | { |
| | | throw newDirectoryException(currentEntry, ResultCode.PROTOCOL_ERROR, |
| | | ERR_MODIFY_ADD_NO_VALUES.get(entryDN, attrDesc.getNameOrOID())); |
| | | ERR_MODIFY_ADD_NO_VALUES.get(entryDN, attrDesc)); |
| | | } |
| | | |
| | | if (mustCheckSchema()) |
| | |
| | | |
| | | throw newDirectoryException(currentEntry, |
| | | ResultCode.ATTRIBUTE_OR_VALUE_EXISTS, |
| | | ERR_MODIFY_ADD_DUPLICATE_VALUE.get(entryDN, attrDesc.getNameOrOID(), duplicateValuesStr)); |
| | | ERR_MODIFY_ADD_DUPLICATE_VALUE.get(entryDN, attrDesc, duplicateValuesStr)); |
| | | } |
| | | } |
| | | |
| | |
| | | if (!syntax.valueIsAcceptable(v, invalidReason)) |
| | | { |
| | | LocalizableMessage msg = isHumanReadable(syntax) |
| | | ? invalidSyntaxErrorMsg.get(entryDN, attrDesc.getNameOrOID(), v, invalidReason) |
| | | : invalidSyntaxNoValueErrorMsg.get(entryDN, attrDesc.getNameOrOID(), invalidReason); |
| | | ? invalidSyntaxErrorMsg.get(entryDN, attrDesc, v, invalidReason) |
| | | : invalidSyntaxNoValueErrorMsg.get(entryDN, attrDesc, invalidReason); |
| | | |
| | | switch (syntaxPolicy) |
| | | { |
| | |
| | | { |
| | | throw newDirectoryException(currentEntry, |
| | | ResultCode.NOT_ALLOWED_ON_RDN, |
| | | ERR_MODIFY_DELETE_RDN_ATTR.get(entryDN, attrDesc.getNameOrOID())); |
| | | ERR_MODIFY_DELETE_RDN_ATTR.get(entryDN, attrDesc)); |
| | | } |
| | | } |
| | | else if (!permissiveModify) |
| | |
| | | String missingValuesStr = Utils.joinAsString(", ", missingValues); |
| | | |
| | | throw newDirectoryException(currentEntry, ResultCode.NO_SUCH_ATTRIBUTE, |
| | | ERR_MODIFY_DELETE_MISSING_VALUES.get(entryDN, attrDesc.getNameOrOID(), missingValuesStr)); |
| | | ERR_MODIFY_DELETE_MISSING_VALUES.get(entryDN, attrDesc, missingValuesStr)); |
| | | } |
| | | } |
| | | else if (!permissiveModify) |
| | | { |
| | | throw newDirectoryException(currentEntry, ResultCode.NO_SUCH_ATTRIBUTE, |
| | | ERR_MODIFY_DELETE_NO_SUCH_ATTR.get(entryDN, attrDesc.getNameOrOID())); |
| | | ERR_MODIFY_DELETE_NO_SUCH_ATTR.get(entryDN, attrDesc)); |
| | | } |
| | | } |
| | | |
| | |
| | | && !modifiedEntry.hasValue(attr.getAttributeDescription(), rdn.getAttributeValue(t))) |
| | | { |
| | | throw newDirectoryException(modifiedEntry, ResultCode.NOT_ALLOWED_ON_RDN, |
| | | ERR_MODIFY_DELETE_RDN_ATTR.get(entryDN, attr.getAttributeDescription().getNameOrOID())); |
| | | ERR_MODIFY_DELETE_RDN_ATTR.get(entryDN, attr.getAttributeDescription())); |
| | | } |
| | | } |
| | | |
| | |
| | | if (rdn != null && rdn.hasAttributeType(t)) |
| | | { |
| | | throw newDirectoryException(modifiedEntry, ResultCode.NOT_ALLOWED_ON_RDN, |
| | | ERR_MODIFY_INCREMENT_RDN.get(entryDN, attrDesc.getNameOrOID())); |
| | | ERR_MODIFY_INCREMENT_RDN.get(entryDN, attrDesc)); |
| | | } |
| | | |
| | | // The provided attribute must have a single value, and it must be an integer |
| | | if (attr.isEmpty()) |
| | | { |
| | | throw newDirectoryException(modifiedEntry, ResultCode.PROTOCOL_ERROR, |
| | | ERR_MODIFY_INCREMENT_REQUIRES_VALUE.get(entryDN, attrDesc.getNameOrOID())); |
| | | ERR_MODIFY_INCREMENT_REQUIRES_VALUE.get(entryDN, attrDesc)); |
| | | } |
| | | else if (attr.size() > 1) |
| | | { |
| | | throw newDirectoryException(modifiedEntry, ResultCode.PROTOCOL_ERROR, |
| | | ERR_MODIFY_INCREMENT_REQUIRES_SINGLE_VALUE.get(entryDN, attrDesc.getNameOrOID())); |
| | | ERR_MODIFY_INCREMENT_REQUIRES_SINGLE_VALUE.get(entryDN, attrDesc)); |
| | | } |
| | | |
| | | MatchingRule eqRule = t.getEqualityMatchingRule(); |
| | |
| | | logger.traceException(e); |
| | | |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_MODIFY_INCREMENT_PROVIDED_VALUE_NOT_INTEGER.get(entryDN, attrDesc.getNameOrOID(), v), e); |
| | | ERR_MODIFY_INCREMENT_PROVIDED_VALUE_NOT_INTEGER.get(entryDN, attrDesc, v), e); |
| | | } |
| | | |
| | | // Get the attribute that is to be incremented. |
| | |
| | | { |
| | | throw newDirectoryException(modifiedEntry, |
| | | ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_MODIFY_INCREMENT_REQUIRES_EXISTING_VALUE.get(entryDN, attrDesc.getNameOrOID())); |
| | | ERR_MODIFY_INCREMENT_REQUIRES_EXISTING_VALUE.get(entryDN, attrDesc)); |
| | | } |
| | | |
| | | // Increment each attribute value by the specified amount. |
| | |
| | | |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_MODIFY_INCREMENT_REQUIRES_INTEGER_VALUE.get(entryDN, modifiedAttrDesc.getNameOrOID(), existingValue), |
| | | ERR_MODIFY_INCREMENT_REQUIRES_INTEGER_VALUE.get(entryDN, modifiedAttrDesc, existingValue), |
| | | e); |
| | | } |
| | | |