oldBase.remove( oldDn.size() - 1 );
DN newBase = ( DN ) newDn.clone();
newBase.remove( newDn.size() - 1 );
// Compute the RDN for each of the DN
RDN newRdn = newDn.getRdn( newDn.size() - 1 );
RDN oldRdn = oldDn.getRdn( oldDn.size() - 1 );
/*
* We need to determine if this rename operation corresponds to a simple
* RDN name change or a move operation. If the two names are the same
* except for the RDN then it is a simple modifyRdn operation. If the
* names differ in size or have a different baseDN then the operation is
* a move operation. Furthermore if the RDN in the move operation
* changes it is both an RDN change and a move operation.
*/
if ( ( oldDn.size() == newDn.size() ) && oldBase.equals( newBase ) )
{
adminSession.rename( oldDn, newRdn, delOldRdn );
}
else
{
DN target = ( DN ) newDn.clone();
target.remove( newDn.size() - 1 );
if ( newRdn.equals( oldRdn ) )
{
adminSession.move( oldDn, target );
}
else
{
adminSession.moveAndRename( oldDn, target, new RDN( newRdn ), delOldRdn );
}
}
}