{} ), 3 );
monitor.reportProgress( " " ); //$NON-NLS-1$
monitor.worked( 1 );
// use a dummy monitor to be able to handle exceptions
StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );
int numAdd = 0;
int numDel = 0;
boolean isSimulatedRename = false;
LdapDN parentDn = newParent.getDn();
for ( int i = 0; i < oldEntries.length; i++ )
{
dummyMonitor.reset();
IEntry oldEntry = oldEntries[i];
LdapDN oldDn = oldEntry.getDn();
LdapDN newDn = DnUtils.composeDn( oldDn.getRdn(), parentDn );
// try to move entry
RenameEntryJob.renameEntry( browserConnection, oldEntry, newDn, dummyMonitor );
// do a simulated rename, if renaming of a non-leaf entry is not supported.
if ( dummyMonitor.errorsReported() )
{
if ( dialog != null && dummyMonitor.getException() instanceof ContextNotEmptyException )
{
// open dialog
if ( numAdd == 0 )
{
dialog.setEntryInfo( browserConnection, oldDn, newDn );
dialog.open();
isSimulatedRename = dialog.isSimulateRename();
}
if ( isSimulatedRename )
{
// do simulated rename operation
dummyMonitor.reset();
numAdd = CopyEntriesJob.copyEntry( oldEntry, newParent, null, SearchControls.SUBTREE_SCOPE,
numAdd, null, dummyMonitor, monitor );
if ( !dummyMonitor.errorsReported() )
{
dummyMonitor.reset();
numDel = DeleteEntriesJob.optimisticDeleteEntryRecursive( browserConnection, oldDn, numDel,
dummyMonitor, monitor );
}
}
else
{
// no simulated rename operation
// report the exception to the real monitor
Throwable exception = dummyMonitor.getException();
monitor.reportError( exception );
}
}
else
{
// we have another exception
// report it to the real monitor
Throwable exception = dummyMonitor.getException();
monitor.reportError( exception );
}
}
// update model
if ( !dummyMonitor.errorsReported() )
{
// uncache old entry
browserConnection.uncacheEntryRecursive( oldEntry );
// remove old entry from old parent