From 4ed3b08887c800fb6f02ecc90df9092691b78208 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 30 Mar 2016 08:51:11 +0000
Subject: [PATCH] Prep work for OPENDJ-2803 Migrate Attribute
---
opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java | 18 +-
opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java | 14 +-
opendj-server-legacy/src/main/java/org/opends/server/core/ModifyOperationBasis.java | 27 ++-
opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java | 17 +-
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java | 34 ++--
opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java | 50 +-----
opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java | 29 +--
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java | 4
opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java | 20 +-
opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java | 22 +-
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java | 6
opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java | 6
opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java | 74 +++++-----
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java | 14 -
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java | 59 +++-----
15 files changed, 168 insertions(+), 226 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
index bb6c3ec..7af4b2a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -924,8 +924,7 @@
}
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);
}
@@ -935,8 +934,7 @@
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);
}
@@ -1081,8 +1079,7 @@
}
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);
}
@@ -3478,10 +3475,7 @@
DirectoryServer.getServerErrorResultCode(),
ERR_MEMORYBACKEND_ERROR_READING_LDIF.get(e), le);
}
- else
- {
- continue;
- }
+ continue;
}
importEntry(e);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java
index 3a306ac..2e383ba 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java
@@ -404,12 +404,12 @@
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.
@@ -437,14 +437,14 @@
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
@@ -453,12 +453,12 @@
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.
@@ -486,7 +486,7 @@
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));
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
index 34e528e..5208045 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
@@ -33,10 +33,10 @@
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
@@ -710,9 +710,7 @@
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));
}
@@ -721,7 +719,7 @@
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);
@@ -732,7 +730,7 @@
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);
@@ -759,8 +757,7 @@
{
// 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
@@ -769,8 +766,7 @@
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));
}
@@ -779,7 +775,7 @@
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);
@@ -790,7 +786,7 @@
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);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java
index 678149b..896e4fe 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java
@@ -904,9 +904,7 @@
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())
@@ -914,8 +912,7 @@
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
{
@@ -929,9 +926,7 @@
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);
@@ -944,24 +939,19 @@
}
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);
@@ -972,10 +962,7 @@
{
// 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
@@ -984,9 +971,7 @@
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())
@@ -994,8 +979,7 @@
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
{
@@ -1009,9 +993,7 @@
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);
@@ -1024,24 +1006,18 @@
}
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);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java
index 545022d..2b09373 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java
@@ -874,12 +874,12 @@
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);
@@ -891,8 +891,7 @@
}
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);
@@ -903,7 +902,7 @@
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);
@@ -915,8 +914,7 @@
}
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);
@@ -951,7 +949,7 @@
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();
@@ -959,7 +957,7 @@
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;
}
@@ -970,7 +968,7 @@
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);
@@ -979,11 +977,11 @@
// 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;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java
index afc0c8b..f3c97fe 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java
@@ -704,9 +704,7 @@
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));
}
@@ -715,7 +713,7 @@
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);
@@ -726,9 +724,7 @@
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);
@@ -738,7 +734,7 @@
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());
@@ -749,9 +745,7 @@
{
// 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
@@ -760,9 +754,7 @@
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));
}
@@ -771,8 +763,7 @@
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);
@@ -783,9 +774,7 @@
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);
@@ -795,7 +784,7 @@
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());
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java
index d3d791e..ea8d5ae 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java
@@ -634,7 +634,7 @@
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));
}
@@ -643,7 +643,7 @@
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);
@@ -654,9 +654,7 @@
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);
@@ -670,7 +668,7 @@
{
// 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
@@ -679,7 +677,7 @@
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));
}
@@ -688,7 +686,7 @@
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);
@@ -699,9 +697,7 @@
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);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java
index 2cd077b..302cf96 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java
@@ -23,6 +23,7 @@
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;
@@ -289,7 +290,8 @@
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
@@ -299,11 +301,11 @@
&& !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)
{
@@ -317,7 +319,7 @@
{
// 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())
@@ -325,8 +327,7 @@
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);
@@ -361,7 +362,7 @@
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);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyOperationBasis.java
index 5e16d4c..b115733 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyOperationBasis.java
@@ -21,6 +21,7 @@
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;
@@ -28,8 +29,19 @@
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;
@@ -197,25 +209,24 @@
{
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);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
index a08bd4b..49e4949 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
@@ -1160,7 +1160,7 @@
&& 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);
@@ -1168,7 +1168,7 @@
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.
@@ -1176,7 +1176,7 @@
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));
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
index fe7a952..bc97bc0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
@@ -1053,8 +1053,7 @@
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);
}
@@ -1062,28 +1061,16 @@
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);
}
@@ -1092,19 +1079,7 @@
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));
}
@@ -1112,6 +1087,18 @@
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);
+ }
+ }
/**
@@ -1377,7 +1364,7 @@
{
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);
}
}
@@ -1394,7 +1381,7 @@
{
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);
}
}
@@ -1426,7 +1413,7 @@
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;
@@ -1436,7 +1423,7 @@
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;
@@ -4443,7 +4430,7 @@
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);
@@ -4454,7 +4441,7 @@
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);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java b/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
index f028cb4..38a0a5b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
@@ -930,24 +930,21 @@
{
// 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);
@@ -1268,39 +1265,15 @@
{
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())
{
@@ -1309,19 +1282,42 @@
{
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.
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
index fc26459..5699217 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -903,13 +903,11 @@
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())
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
index 7f54715..650a941 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
@@ -614,7 +614,7 @@
&& !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<>();
@@ -648,7 +648,7 @@
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
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
index 31d4637..993626a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -707,7 +707,7 @@
{
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
@@ -720,7 +720,7 @@
{
throw newDirectoryException(currentEntry,
ResultCode.CONSTRAINT_VIOLATION,
- ERR_MODIFY_ATTR_IS_OBSOLETE.get(entryDN, attrDesc.getNameOrOID()));
+ ERR_MODIFY_ATTR_IS_OBSOLETE.get(entryDN, attrDesc));
}
@@ -826,7 +826,7 @@
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));
}
}
@@ -1142,7 +1142,7 @@
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())
@@ -1168,7 +1168,7 @@
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));
}
}
@@ -1198,8 +1198,8 @@
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)
{
@@ -1303,7 +1303,7 @@
{
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)
@@ -1311,13 +1311,13 @@
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));
}
}
@@ -1357,7 +1357,7 @@
&& !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()));
}
}
@@ -1378,19 +1378,19 @@
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();
@@ -1407,7 +1407,7 @@
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.
@@ -1416,7 +1416,7 @@
{
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.
@@ -1435,7 +1435,7 @@
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);
}
--
Gitblit v1.10.0