entry.put( newRdnAttr, newRdnValue );
if ( hasUserIndexOn( newRdnAttr ) )
{
Index idx = getUserIndex( newRdnAttr );
idx.add( newRdnValue, id );
// Make sure the altered entry shows the existance of the new attrib
if ( ! existanceIdx.hasValue( newRdnAttr, id ) )
{
existanceIdx.add( newRdnAttr, id );
}
}
/*
* H A N D L E O L D R D N
* ====================================================================
* If the old Rdn is to be removed we need to get the attribute and
* value for it. Keep in mind the old Rdn need not be based on the
* same Rdn as the new one. We remove the Rdn value from the entry
* and remove the value/id tuple from the index on the old Rdn attr
* if any. We also test if the delete of the old Rdn index tuple
* removed all the attribute values of the old Rdn using a reverse
* lookup. If so that means we blew away the last value of the old
* Rdn attribute. In this case we need to remove the attrName/id
* tuple from the existance index.
*/
if ( deleteOldRdn )
{
String oldRdn = updn.get( updn.size() - 1 );
String oldRdnAttr = NamespaceTools.getRdnAttribute( oldRdn );
String oldRdnValue = NamespaceTools.getRdnValue( oldRdn );
entry.get( oldRdnAttr ).remove( oldRdnValue );
if ( hasUserIndexOn( oldRdnAttr ) )
{
Index idx = getUserIndex( oldRdnAttr );
idx.drop( oldRdnValue, id );
/*
* If there is no value for id in this index due to our
* drop above we remove the oldRdnAttr from the existance idx
*/
if ( null == idx.reverseLookup( id ) )
{
existanceIdx.drop( oldRdnAttr, id );
}
}
}