while ( !monitor.isCanceled() && entries.hasMore() )
{
// get next entry to copy
SearchResult sr = entries.next();
LdapDN oldLdapDn = JNDIUtils.getDn( sr );
Rdn oldRdn = oldLdapDn.getRdn();
// reuse attributes of the entry to copy
Attributes newAttributes = sr.getAttributes();
// compose new DN
Rdn newRdn = oldLdapDn.getRdn();
if( forceNewRdn != null )
{
newRdn = forceNewRdn;
}
LdapDN newLdapDn = DnUtils.composeDn( newRdn, parentDn );
// apply new RDN to the attributes
applyNewRdn( newAttributes, oldRdn, newRdn );
// determine referrals handling method
ReferralHandlingMethod referralsHandlingMethod = newAttributes.get( "ref" ) != null ? ReferralHandlingMethod.MANAGE
: ReferralHandlingMethod.FOLLOW;
// create entry
targetBrowserConnection.getConnection().getJNDIConnectionWrapper().createEntry( newLdapDn.getUpName(),
newAttributes, referralsHandlingMethod, null, dummyMonitor, null );
while ( dummyMonitor.errorsReported() )
{
if ( dialog != null && dummyMonitor.getException() instanceof NameAlreadyBoundException )
{
// open dialog
dialog.setExistingEntry( targetBrowserConnection, newLdapDn );
dialog.open();
EntryExistsCopyStrategy strategy = dialog.getStrategy();
// boolean rememberSelection = dialog.isRememberSelection();
if ( strategy != null )
{
dummyMonitor.reset();
switch ( strategy )
{
case BREAK:
monitor.setCanceled( true );
break;
case IGNORE_AND_CONTINUE:
break;
// case OVERWRITE_AND_CONTINUE:
// break;
case RENAME_AND_CONTINUE:
Rdn renamedRdn = dialog.getRdn();
// apply renamed RDN to the attributes
applyNewRdn( newAttributes, newRdn, renamedRdn );
// compose new DN