}
for (Modification m : modifyOperation.getModifications())
{
Attribute a = m.getAttribute();
AttributeType t = a.getAttributeType();
if (! config.getType().contains(t))
{
// This modification isn't for a unique attribute.
continue;
}
switch (m.getModificationType())
{
case ADD:
case REPLACE:
for (AttributeValue v : a)
{
try
{
DN conflictDN = null;
//Raise an exception if a conflicting concurrent operation is in
//progress. Otherwise, store this attribute value with its
//corresponding DN and proceed.
if((conflictDN=
uniqueAttrValue2Dn.putIfAbsent(v, entryDN))==null)
{
conflictDN = getConflictingEntryDN(baseDNs, entryDN, config,
v);
}
if (conflictDN != null)
{
Message msg = ERR_PLUGIN_UNIQUEATTR_ATTR_NOT_UNIQUE.get(
t.getNameOrOID(), v.getValue().toString(),
conflictDN.toString());
return PluginResult.PreOperation.stopProcessing(
ResultCode.CONSTRAINT_VIOLATION, msg);
}
}
catch (DirectoryException de)
{
if (debugEnabled())
{
TRACER.debugCaught(DebugLogLevel.ERROR, de);
}
Message message = ERR_PLUGIN_UNIQUEATTR_INTERNAL_ERROR.get(
de.getResultCode().toString(),
de.getMessageObject());
return PluginResult.PreOperation.stopProcessing(
DirectoryServer.getServerErrorResultCode(), message);
}
}
break;
case INCREMENT:
// We could calculate the new value, but we'll just take it from the
// updated entry.
List<Attribute> attrList =
modifyOperation.getModifiedEntry().getAttribute(t,
a.getOptions());
if (attrList != null)
{
for (Attribute updatedAttr : attrList)
{
if (! updatedAttr.optionsEqual(a.getOptions()))
{
continue;
}
for (AttributeValue v : updatedAttr)
{
try
{
DN conflictDN = null;
//Raise an exception if a conflicting concurrent operation is
//in progress. Otherwise, store this attribute value with its
//corresponding DN and proceed.
if((conflictDN=
uniqueAttrValue2Dn.putIfAbsent(v, entryDN))==null)
{
conflictDN = getConflictingEntryDN(baseDNs, entryDN,
config, v);
}
if (conflictDN != null)
{
Message msg = ERR_PLUGIN_UNIQUEATTR_ATTR_NOT_UNIQUE.get(
t.getNameOrOID(), v.getValue().toString(),
conflictDN.toString());
return PluginResult.PreOperation.stopProcessing(
ResultCode.CONSTRAINT_VIOLATION, msg);
}
}