| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011 ForgeRock AS |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | |
| | | |
| | | import java.util.LinkedList; |
| | | import java.util.ArrayList; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.LinkedHashMap; |
| | |
| | | return PluginResult.PreOperation.continueOperationProcessing(); |
| | | } |
| | | |
| | | LinkedList<AttributeValue> recordedValues = |
| | | new LinkedList<AttributeValue>(); |
| | | for (AttributeType t : config.getType()) |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute(t); |
| | |
| | | if((conflictDN= |
| | | uniqueAttrValue2Dn.putIfAbsent(v, entry.getDN()))==null) |
| | | { |
| | | recordedValues.add(v); |
| | | conflictDN = getConflictingEntryDN(baseDNs, entry.getDN(), |
| | | config, v); |
| | | } |
| | | if (conflictDN != null) |
| | | { |
| | | // Before returning, we need to remove all values added |
| | | // in the uniqueAttrValue2Dn map, because PostOperation |
| | | // plugin does not get called. |
| | | for (AttributeValue v2 : recordedValues) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v2); |
| | | } |
| | | Message msg = ERR_PLUGIN_UNIQUEATTR_ATTR_NOT_UNIQUE.get( |
| | | t.getNameOrOID(), v.getValue().toString(), |
| | | conflictDN.toString()); |
| | | t.getNameOrOID(), v.getValue().toString(), |
| | | conflictDN.toString()); |
| | | return PluginResult.PreOperation.stopProcessing( |
| | | ResultCode.CONSTRAINT_VIOLATION, msg); |
| | | ResultCode.CONSTRAINT_VIOLATION, msg); |
| | | } |
| | | } |
| | | catch (DirectoryException de) |
| | |
| | | de.getResultCode().toString(), |
| | | de.getMessageObject()); |
| | | |
| | | // Try some cleanup before returning, to avoid memory leaks |
| | | for (AttributeValue v2 : recordedValues) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v2); |
| | | } |
| | | |
| | | return PluginResult.PreOperation.stopProcessing( |
| | | DirectoryServer.getServerErrorResultCode(), m); |
| | | } |
| | |
| | | return PluginResult.PreOperation.continueOperationProcessing(); |
| | | } |
| | | |
| | | LinkedList<AttributeValue> recordedValues = |
| | | new LinkedList<AttributeValue>(); |
| | | for (Modification m : modifyOperation.getModifications()) |
| | | { |
| | | Attribute a = m.getAttribute(); |
| | |
| | | if((conflictDN= |
| | | uniqueAttrValue2Dn.putIfAbsent(v, entryDN))==null) |
| | | { |
| | | conflictDN = getConflictingEntryDN(baseDNs, entryDN, config, |
| | | recordedValues.add(v); |
| | | conflictDN = getConflictingEntryDN(baseDNs, entryDN, config, |
| | | v); |
| | | } |
| | | if (conflictDN != null) |
| | | { |
| | | Message msg = ERR_PLUGIN_UNIQUEATTR_ATTR_NOT_UNIQUE.get( |
| | | // Before returning, we need to remove all values added |
| | | // in the uniqueAttrValue2Dn map, because PostOperation |
| | | // plugin does not get called. |
| | | for (AttributeValue v2 : recordedValues) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v2); |
| | | } |
| | | Message msg = ERR_PLUGIN_UNIQUEATTR_ATTR_NOT_UNIQUE.get( |
| | | t.getNameOrOID(), v.getValue().toString(), |
| | | conflictDN.toString()); |
| | | return PluginResult.PreOperation.stopProcessing( |
| | |
| | | if((conflictDN= |
| | | uniqueAttrValue2Dn.putIfAbsent(v, entryDN))==null) |
| | | { |
| | | recordedValues.add(v); |
| | | conflictDN = getConflictingEntryDN(baseDNs, entryDN, |
| | | config, v); |
| | | } |
| | | if (conflictDN != null) |
| | | { |
| | | // Before returning, we need to remove all values added |
| | | // in the uniqueAttrValue2Dn map, because PostOperation |
| | | // plugin does not get called. |
| | | for (AttributeValue v2 : recordedValues) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v2); |
| | | } |
| | | Message msg = ERR_PLUGIN_UNIQUEATTR_ATTR_NOT_UNIQUE.get( |
| | | t.getNameOrOID(), v.getValue().toString(), |
| | | conflictDN.toString()); |
| | |
| | | de.getResultCode().toString(), |
| | | de.getMessageObject()); |
| | | |
| | | // Try some cleanup before returning, to avoid memory leaks |
| | | for (AttributeValue v2 : recordedValues) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v2); |
| | | } |
| | | |
| | | return PluginResult.PreOperation.stopProcessing( |
| | | DirectoryServer.getServerErrorResultCode(), message); |
| | | } |
| | |
| | | return PluginResult.PreOperation.continueOperationProcessing(); |
| | | } |
| | | |
| | | LinkedList<AttributeValue> recordedValues = |
| | | new LinkedList<AttributeValue>(); |
| | | RDN newRDN = modifyDNOperation.getNewRDN(); |
| | | for (int i=0; i < newRDN.getNumValues(); i++) |
| | | { |
| | |
| | | if((conflictDN=uniqueAttrValue2Dn.putIfAbsent( |
| | | v, modifyDNOperation.getEntryDN()))==null) |
| | | { |
| | | recordedValues.add(v); |
| | | conflictDN = getConflictingEntryDN(baseDNs, |
| | | modifyDNOperation.getEntryDN(), config, v); |
| | | } |
| | | if (conflictDN != null) |
| | | { |
| | | // Before returning, we need to remove all values added |
| | | // in the uniqueAttrValue2Dn map, because PostOperation |
| | | // plugin does not get called. |
| | | for (AttributeValue v2 : recordedValues) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v2); |
| | | } |
| | | Message msg = ERR_PLUGIN_UNIQUEATTR_ATTR_NOT_UNIQUE.get( |
| | | t.getNameOrOID(), v.getValue().toString(), |
| | | conflictDN.toString()); |
| | |
| | | de.getResultCode().toString(), |
| | | de.getMessageObject()); |
| | | |
| | | // Try some cleanup before returning, to avoid memory leaks |
| | | for (AttributeValue v2 : recordedValues) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v2); |
| | | } |
| | | |
| | | return PluginResult.PreOperation.stopProcessing( |
| | | DirectoryServer.getServerErrorResultCode(), m); |
| | | } |