int errorCount = 0;
try
{
while ( !monitor.isCanceled() && enumeration.hasNext( monitor ) )
{
LdifContainer container = enumeration.next( monitor );
if ( container instanceof LdifRecord )
{
LdifRecord record = ( LdifRecord ) container;
try
{
this.applyModificationAndLog( record, monitor );
// update cache and adjust attribute/children initialization flags
DN dn = new DN( record.getDnLine().getValueAsString() );
IEntry entry = connection.getEntryFromCache( dn );
DN parentDn = dn.getParentDn();
IEntry parentEntry = parentDn != null ? connection.getEntryFromCache( dn.getParentDn() ) : null;
if ( record instanceof LdifChangeDeleteRecord )
{
if ( entry != null )
{
entry.setAttributesInitialized( false );
connection.uncacheEntry( entry );
}
if ( parentEntry != null )
{
parentEntry.setChildrenInitialized( false );
}
}
else if ( record instanceof LdifChangeModDnRecord )
{
if ( entry != null )
{
entry.setAttributesInitialized( false );
connection.uncacheEntry( entry );
}
if ( parentEntry != null )
{
parentEntry.setChildrenInitialized( false );
}
LdifChangeModDnRecord modDnRecord = ( LdifChangeModDnRecord ) record;
if ( modDnRecord.getNewsuperiorLine() != null )
{
DN newSuperiorDn = new DN( modDnRecord.getNewsuperiorLine().getValueAsString() );
IEntry newSuperiorEntry = connection.getEntryFromCache( newSuperiorDn );
if ( newSuperiorEntry != null )
{
newSuperiorEntry.setChildrenInitialized( false );
}
}
}
else if ( record instanceof LdifChangeAddRecord || record instanceof LdifContentRecord )
{
if ( parentEntry != null )
{
parentEntry.setChildrenInitialized( false );
}
}
else
{
if ( entry != null )
{
entry.setAttributesInitialized( false );
}
}
logModification( logWriter, record, monitor );
importedCount++;
}
catch ( Exception e )
{
logModificationError( logWriter, record, e, monitor );
errorCount++;
if ( !continueOnError )
{
monitor.reportError( e );
return;
}
}
monitor.reportProgress( BrowserCoreMessages.bind(
BrowserCoreMessages.ldif__imported_n_entries_m_errors, new String[]
{ "" + importedCount, "" + errorCount } ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
else
{
logWriter.write( container.toRawString() );
}
}
if ( errorCount > 0 )
{