You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2007/12/05 00:15:23 UTC

svn commit: r601142 - /directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportLdifJob.java

Author: seelmann
Date: Tue Dec  4 15:15:22 2007
New Revision: 601142

URL: http://svn.apache.org/viewvc?rev=601142&view=rev
Log:
Fixed error counter.

Modified:
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportLdifJob.java

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportLdifJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportLdifJob.java?rev=601142&r1=601141&r2=601142&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportLdifJob.java (original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportLdifJob.java Tue Dec  4 15:15:22 2007
@@ -233,6 +233,7 @@
     static void importLdif( IBrowserConnection browserConnection, LdifEnumeration enumeration, Writer logWriter,
         boolean continueOnError, StudioProgressMonitor monitor )
     {
+        StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );
         int importedCount = 0;
         int errorCount = 0;
         try
@@ -246,62 +247,80 @@
                     LdifRecord record = ( LdifRecord ) container;
                     try
                     {
-                        importLdifRecord( browserConnection, record, monitor );
-                        logModification( browserConnection, logWriter, record, monitor );
-                        importedCount++;
-
-                        // update cache and adjust attribute/children initialization flags
-                        LdapDN dn = new LdapDN( record.getDnLine().getValueAsString() );
-                        IEntry entry = browserConnection.getEntryFromCache( dn );
-                        LdapDN parentDn = DnUtils.getParent( dn );
-                        IEntry parentEntry = parentDn != null ? browserConnection.getEntryFromCache( parentDn ) : null;
-
-                        if ( record instanceof LdifChangeDeleteRecord )
+                        dummyMonitor.reset();
+                        importLdifRecord( browserConnection, record, dummyMonitor );
+                        if ( dummyMonitor.errorsReported() )
                         {
-                            if ( entry != null )
-                            {
-                                entry.setAttributesInitialized( false );
-                                browserConnection.uncacheEntryRecursive( entry );
-                            }
-                            if ( parentEntry != null )
+                            errorCount++;
+                            logModificationError( browserConnection, logWriter, record, dummyMonitor.getException(),
+                                monitor );
+
+                            if ( !continueOnError )
                             {
-                                parentEntry.setChildrenInitialized( false );
+                                monitor.reportError( dummyMonitor.getException() );
+                                return;
                             }
                         }
-                        else if ( record instanceof LdifChangeModDnRecord )
+                        else
                         {
-                            if ( entry != null )
-                            {
-                                entry.setAttributesInitialized( false );
-                                browserConnection.uncacheEntryRecursive( entry );
-                            }
-                            if ( parentEntry != null )
+                            importedCount++;
+                            logModification( browserConnection, logWriter, record, monitor );
+
+                            // update cache and adjust attribute/children initialization flags
+                            LdapDN dn = new LdapDN( record.getDnLine().getValueAsString() );
+                            IEntry entry = browserConnection.getEntryFromCache( dn );
+                            LdapDN parentDn = DnUtils.getParent( dn );
+                            IEntry parentEntry = parentDn != null ? browserConnection.getEntryFromCache( parentDn )
+                                : null;
+
+                            if ( record instanceof LdifChangeDeleteRecord )
                             {
-                                parentEntry.setChildrenInitialized( false );
+                                if ( entry != null )
+                                {
+                                    entry.setAttributesInitialized( false );
+                                    browserConnection.uncacheEntryRecursive( entry );
+                                }
+                                if ( parentEntry != null )
+                                {
+                                    parentEntry.setChildrenInitialized( false );
+                                }
                             }
-                            LdifChangeModDnRecord modDnRecord = ( LdifChangeModDnRecord ) record;
-                            if ( modDnRecord.getNewsuperiorLine() != null )
+                            else if ( record instanceof LdifChangeModDnRecord )
                             {
-                                LdapDN newSuperiorDn = new LdapDN( modDnRecord.getNewsuperiorLine().getValueAsString() );
-                                IEntry newSuperiorEntry = browserConnection.getEntryFromCache( newSuperiorDn );
-                                if ( newSuperiorEntry != null )
+                                if ( entry != null )
                                 {
-                                    newSuperiorEntry.setChildrenInitialized( false );
+                                    entry.setAttributesInitialized( false );
+                                    browserConnection.uncacheEntryRecursive( entry );
+                                }
+                                if ( parentEntry != null )
+                                {
+                                    parentEntry.setChildrenInitialized( false );
+                                }
+                                LdifChangeModDnRecord modDnRecord = ( LdifChangeModDnRecord ) record;
+                                if ( modDnRecord.getNewsuperiorLine() != null )
+                                {
+                                    LdapDN newSuperiorDn = new LdapDN( modDnRecord.getNewsuperiorLine()
+                                        .getValueAsString() );
+                                    IEntry newSuperiorEntry = browserConnection.getEntryFromCache( newSuperiorDn );
+                                    if ( newSuperiorEntry != null )
+                                    {
+                                        newSuperiorEntry.setChildrenInitialized( false );
+                                    }
                                 }
                             }
-                        }
-                        else if ( record instanceof LdifChangeAddRecord || record instanceof LdifContentRecord )
-                        {
-                            if ( parentEntry != null )
+                            else if ( record instanceof LdifChangeAddRecord || record instanceof LdifContentRecord )
                             {
-                                parentEntry.setChildrenInitialized( false );
+                                if ( parentEntry != null )
+                                {
+                                    parentEntry.setChildrenInitialized( false );
+                                }
                             }
-                        }
-                        else
-                        {
-                            if ( entry != null )
+                            else
                             {
-                                entry.setAttributesInitialized( false );
+                                if ( entry != null )
+                                {
+                                    entry.setAttributesInitialized( false );
+                                }
                             }
                         }
                     }
@@ -513,7 +532,7 @@
      * @param monitor the progress monitor
      */
     private static void logModificationError( IBrowserConnection browserConnection, Writer logWriter,
-        LdifRecord record, Exception exception, StudioProgressMonitor monitor )
+        LdifRecord record, Throwable exception, StudioProgressMonitor monitor )
     {
         try
         {