if (a.hasOption(OPTION_PENDING_VALUES))
{
if (pendingValues != null)
{
// We cannot have multiple pending value sets.
Message message =
ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(a.getName());
throw new ConfigException(message);
}
if (a.isEmpty())
{
if (isRequired())
{
// This is illegal -- it must have a value.
Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName());
throw new ConfigException(message);
}
else
{
// This is fine. The pending value set can be empty.
pendingValues = new ArrayList<DN>(0);
}
}
else
{
int numValues = a.size();
if ((numValues > 1) && (! isMultiValued()))
{
// This is illegal -- the attribute is single-valued.
Message message =
ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(a.getName());
throw new ConfigException(message);
}
pendingValues = new ArrayList<DN>(numValues);
for (AttributeValue v : a)
{
DN dn;
try
{
dn = DN.decode(v.getValue().toString());
}
catch (Exception e)
{
if (debugEnabled())
{
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
Message message = ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get(
v.getValue().toString(), getName(), String.valueOf(e));
throw new ConfigException(message, e);
}
pendingValues.add(dn);
}
}
}
else
{
// This is illegal -- only the pending option is allowed for
// configuration attributes.
Message message =
ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(a.getName());
throw new ConfigException(message);
}
}
else
{
// This must be the active value.
if (activeValues!= null)
{
// We cannot have multiple active value sets.
Message message =
ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(a.getName());
throw new ConfigException(message);
}
if (a.isEmpty())
{
if (isRequired())
{
// This is illegal -- it must have a value.
Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName());
throw new ConfigException(message);
}
else
{
// This is fine. The active value set can be empty.
activeValues = new ArrayList<DN>(0);
}
}
else
{
int numValues = a.size();
if ((numValues > 1) && (! isMultiValued()))
{
// This is illegal -- the attribute is single-valued.
Message message =
ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(a.getName());
throw new ConfigException(message);
}
activeValues = new ArrayList<DN>(numValues);
for (AttributeValue v : a)
{
DN dn;
try
{
dn = DN.decode(v.getValue().toString());
}
catch (Exception e)
{
if (debugEnabled())
{
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
Message message = ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get(
v.getValue().toString(), getName(), String.valueOf(e));
throw new ConfigException(message, e);
}
activeValues.add(dn);
}
}
}
}
if (activeValues == null)
{
// This is not OK. The value set must contain an active value.
Message message = ERR_CONFIG_ATTR_NO_ACTIVE_VALUE_SET.get(getName());
throw new ConfigException(message);
}
if (pendingValues == null)
{