renameApexEntry(txn, newID, oldApexEntry, newApexEntry);
}
AbstractTransaction cursorTxn =
new AbstractTransaction(rootContainer);
DN2IDSearchCursor cursor = dn2id.getSearchCursor(cursorTxn, oldApexDN);
cursor.open();
try {
SearchCursorResult result = null;
// Step forward until we pass the ending value.
while ((result = cursor.getNext()) != null) {
// We have found a subordinate entry.
long oldID = result.id;
String oldDN = result.dn;
Entry oldEntry = null;
AbstractTransaction subTxn = new AbstractTransaction(rootContainer);
try {
oldEntry = dn2id.get(subTxn, DN.decode(oldDN),
NdbOperation.LockMode.LM_Exclusive);
if (oldEntry != null) {
if (!isManageDsaITOperation(modifyDNOperation)) {
checkTargetForReferral(oldEntry, null);
}
// Construct the new DN of the entry.
DN newDN = modDN(oldEntry.getDN(),
oldApexDN.getNumComponents(),
newApexEntry.getDN());
if (requestedNewSuperiorDN != null) {
// Assign a new entry ID if we are renumbering.
long newID = oldID;
if (newApexID != oldApexID) {
newID = rootContainer.getNextEntryID(subTxn.getNdb());
}
// Move this entry.
moveSubordinateEntry(subTxn, newID, oldEntry, newDN);
} else {
// Rename this entry.
renameSubordinateEntry(subTxn, oldID, oldEntry, newDN);
}
}
} finally {
if (subTxn != null) {
subTxn.commit();
}
}
if (modifyDNOperation != null) {
modifyDNOperation.checkIfCanceled(false);
}
}
} finally {
cursor.close();
cursorTxn.close();
}
}