directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r749143 - in /directory/studio/trunk: connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/ ldapbrowser-core/src/main/java/org/apac...
Date Sun, 01 Mar 2009 22:36:51 GMT
Author: seelmann
Date: Sun Mar  1 22:36:51 2009
New Revision: 749143

URL: http://svn.apache.org/viewvc?rev=749143&view=rev
Log:
o Removed wrapping of NamingExceptions
o Show more meaningful message in the error dialog
o Show stack trace in the details of the error dialog

Removed:
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ConnectionException.java
Modified:
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/OpenConnectionsRunnable.java
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioProgressMonitor.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportCsvJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportLdifJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportXlsJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/FetchBaseDNsRunnable.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportLdifJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ReadEntryRunnable.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/JNDIUtils.java

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java (original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java Sun Mar  1 22:36:51 2009
@@ -194,7 +194,7 @@
         catch ( NamingException ne )
         {
             disconnect();
-            monitor.reportError( ne.getMessage(), ne );
+            monitor.reportError( ne );
         }
     }
 
@@ -239,7 +239,7 @@
         catch ( NamingException ne )
         {
             disconnect();
-            monitor.reportError( ne.getMessage(), ne );
+            monitor.reportError( ne );
         }
     }
 
@@ -434,13 +434,13 @@
         }
         catch ( NamingException ne )
         {
-            monitor.reportError( ne.getMessage(), ne );
+            monitor.reportError( ne );
             return null;
         }
 
         if ( runnable.getException() != null )
         {
-            monitor.reportError( runnable.getException().getMessage(), runnable.getException() );
+            monitor.reportError( runnable.getException() );
             return null;
         }
         else if ( runnable.getResult() != null )
@@ -535,12 +535,12 @@
         }
         catch ( NamingException ne )
         {
-            monitor.reportError( ne.getMessage(), ne );
+            monitor.reportError( ne );
         }
 
         if ( runnable.getException() != null )
         {
-            monitor.reportError( runnable.getException().getMessage(), runnable.getException() );
+            monitor.reportError( runnable.getException() );
         }
     }
 
@@ -636,12 +636,12 @@
         }
         catch ( NamingException ne )
         {
-            monitor.reportError( ne.getMessage(), ne );
+            monitor.reportError( ne );
         }
 
         if ( runnable.getException() != null )
         {
-            monitor.reportError( runnable.getException().getMessage(), runnable.getException() );
+            monitor.reportError( runnable.getException() );
         }
     }
 
@@ -726,12 +726,12 @@
         }
         catch ( NamingException ne )
         {
-            monitor.reportError( ne.getMessage(), ne );
+            monitor.reportError( ne );
         }
 
         if ( runnable.getException() != null )
         {
-            monitor.reportError( runnable.getException().getMessage(), runnable.getException() );
+            monitor.reportError( runnable.getException() );
         }
     }
 
@@ -814,12 +814,12 @@
         }
         catch ( NamingException ne )
         {
-            monitor.reportError( ne.getMessage(), ne );
+            monitor.reportError( ne );
         }
 
         if ( runnable.getException() != null )
         {
-            monitor.reportError( runnable.getException().getMessage(), runnable.getException() );
+            monitor.reportError( runnable.getException() );
         }
     }
 

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/OpenConnectionsRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/OpenConnectionsRunnable.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/OpenConnectionsRunnable.java (original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/OpenConnectionsRunnable.java Sun Mar  1 22:36:51 2009
@@ -109,7 +109,10 @@
                 monitor.worked( 1 );
 
                 connection.getJNDIConnectionWrapper().connect( monitor );
-                connection.getJNDIConnectionWrapper().bind( monitor );
+                if(connection.getJNDIConnectionWrapper().isConnected())
+                {
+                    connection.getJNDIConnectionWrapper().bind( monitor );
+                }
             }
         }
 

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioProgressMonitor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioProgressMonitor.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioProgressMonitor.java (original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioProgressMonitor.java Sun Mar  1 22:36:51 2009
@@ -21,11 +21,16 @@
 package org.apache.directory.studio.connection.core.jobs;
 
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.SocketException;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
 import org.apache.directory.studio.connection.core.Messages;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -60,7 +65,7 @@
                     {
                         StudioProgressMonitor next = it.next();
                         StudioProgressMonitor spm = next;
-    
+
                         do
                         {
                             // check report progress message
@@ -69,7 +74,7 @@
                                 spm.subTask( spm.reportProgressMessage );
                                 spm.reportProgressMessage = null;
                             }
-    
+
                             // check if canceled
                             if ( spm.isCanceled() )
                             {
@@ -79,7 +84,7 @@
                             {
                                 it.remove();
                             }
-    
+
                             if ( spm.getWrappedProgressMonitor() != null
                                 && spm.getWrappedProgressMonitor() instanceof StudioProgressMonitor )
                             {
@@ -232,48 +237,35 @@
     /**
      * Report error.
      * 
-     * @param throwable the throwable
+     * @param exception the exception
      */
-    public void reportError( Throwable throwable )
+    public void reportError( Exception exception )
     {
-        reportError( throwable.getMessage() != null ? throwable.getMessage() : throwable.toString(), throwable );
+        reportError( null, exception );
     }
 
 
     /**
      * Report error.
      * 
-     * @param exception the exception
      * @param message the message
+     * @param exception the exception
      */
-    public void reportError( String message, Throwable exception )
+    public void reportError( String message, Exception exception )
     {
         if ( errorStatusList == null )
         {
             errorStatusList = new ArrayList<Status>( 3 );
         }
 
-        do
+        if ( message == null )
         {
-            if ( message == null )
-            {
-                message = ""; //$NON-NLS-1$
-            }
-
-            Status errorStatus = new Status( IStatus.ERROR, ConnectionCoreConstants.PLUGIN_ID, IStatus.ERROR, message,
-                exception );
-            errorStatusList.add( errorStatus );
-
-            if ( exception != null )
-            {
-                exception = exception.getCause();
-            }
-            if ( exception != null )
-            {
-                message = exception.getMessage();
-            }
+            message = ""; //$NON-NLS-1$
         }
-        while ( exception != null );
+
+        Status errorStatus = new Status( IStatus.ERROR, ConnectionCoreConstants.PLUGIN_ID, IStatus.ERROR, message,
+            exception );
+        errorStatusList.add( errorStatus );
     }
 
 
@@ -292,36 +284,78 @@
      * Gets the error status.
      * 
      * @param message the message
+     * @param TODO: context message, e.g. search parameters or mod-ldif
      * 
      * @return the error status
      */
     public IStatus getErrorStatus( String message )
     {
+        // multi: message + für jeden errorStatus (\n + message)
+        // children: alle errorStatus + stacktrace->message
+
         if ( errorStatusList != null && !errorStatusList.isEmpty() )
         {
-            Throwable exception = null;
-            for ( Iterator<Status> it = errorStatusList.iterator(); it.hasNext(); )
+            // append status messages to message
+            for ( Status status : errorStatusList )
             {
-                Status status = it.next();
-                if ( status.getException() != null )
+                String statusMessage = status.getMessage();
+                Throwable exception = status.getException();
+                String exceptionMessage = exception != null ? exception.getMessage() : null;
+
+                // Tweak exception message for some well-know exceptions
+                Throwable e = exception;
+                while ( e != null )
                 {
-                    exception = status.getException();
-                    break;
+                    if ( e instanceof UnknownHostException )
+                    {
+                        exceptionMessage = "Unknown Host: " + e.getMessage(); //$NON-NLS-1$
+                    }
+                    else if ( e instanceof SocketException )
+                    {
+                        exceptionMessage = e.getMessage() + " (" + exceptionMessage + ")";; //$NON-NLS-1$ //$NON-NLS-2$
+                    }
+
+                    // next cause
+                    e = e.getCause();
+                }
+
+                // append explicit status message
+                if ( !StringUtils.isEmpty( statusMessage ) )
+                {
+                    message += "\n - " + statusMessage;
+                }
+                // append exception message if different to status message
+                if ( exception != null && exceptionMessage != null && !exceptionMessage.equals( statusMessage ) )
+                {
+                    // strip control characters
+                    int indexOfAny = StringUtils.indexOfAny( exceptionMessage, "\n\r\t" );
+                    if ( indexOfAny > -1 )
+                    {
+                        exceptionMessage = exceptionMessage.substring( 0, indexOfAny - 1 );
+                    }
+                    message += "\n - " + exceptionMessage;
                 }
             }
 
-            MultiStatus multiStatus = new MultiStatus( ConnectionCoreConstants.PLUGIN_ID, IStatus.ERROR, message,
-                exception );
+            // create main status
+            MultiStatus multiStatus = new MultiStatus( ConnectionCoreConstants.PLUGIN_ID, IStatus.ERROR, message, null );
 
-            for ( Iterator<Status> it = errorStatusList.iterator(); it.hasNext(); )
+            // append child status
+            for ( Status status : errorStatusList )
             {
-                Status status = it.next();
-                multiStatus.add( new Status( status.getSeverity(), status.getPlugin(), status.getCode(), status
-                    .getMessage(), null ) );
+                String statusMessage = status.getMessage();
+                if ( status.getException() != null )
+                {
+                    StringWriter sw = new StringWriter();
+                    PrintWriter pw = new PrintWriter( sw );
+                    status.getException().printStackTrace( pw );
+                    statusMessage = sw.toString();
+                }
+                multiStatus.add( new Status( status.getSeverity(), status.getPlugin(), status.getCode(), statusMessage,
+                    status.getException() ) );
             }
 
             return multiStatus;
-
         }
         else
         {
@@ -335,11 +369,11 @@
      * 
      * @return the exception
      */
-    public Throwable getException()
+    public Exception getException()
     {
         if ( errorStatusList != null )
         {
-            return errorStatusList.get( 0 ).getException();
+            return ( Exception ) errorStatusList.get( 0 ).getException();
         }
         return null;
     }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java Sun Mar  1 22:36:51 2009
@@ -46,7 +46,6 @@
 import org.apache.directory.studio.ldapbrowser.core.events.EntryDeletedEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
 import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateEvent;
-import org.apache.directory.studio.ldapbrowser.core.model.ConnectionException;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
@@ -265,13 +264,8 @@
                 try
                 {
                     // delete all child entries
-                    while ( !dummyMonitor.isCanceled() && result.hasMore() )
+                    while ( !dummyMonitor.isCanceled() && !dummyMonitor.errorsReported() && result.hasMore() )
                     {
-                        if ( dummyMonitor.errorsReported() )
-                        {
-                            throw dummyMonitor.getException();
-                        }
-
                         SearchResult sr = result.next();
                         LdapDN childDn = JNDIUtils.getDn( sr );
 
@@ -280,17 +274,16 @@
                         numberInBatch++;
                     }
                 }
-                catch ( Throwable e )
+                catch ( Exception e )
                 {
-                    ConnectionException ce = JNDIUtils.createConnectionException( null, e );
-
-                    if ( ce.getLdapStatusCode() == 3 || ce.getLdapStatusCode() == 4 || ce.getLdapStatusCode() == 11 )
+                    int ldapStatusCode = JNDIUtils.getLdapStatusCode( e );
+                    if ( ldapStatusCode == 3 || ldapStatusCode == 4 || ldapStatusCode == 11 )
                     {
                         // continue with search
                     }
                     else
                     {
-                        dummyMonitor.reportError( ce );
+                        dummyMonitor.reportError( e );
                         break;
                     }
                 }
@@ -312,7 +305,7 @@
         }
         else
         {
-            Throwable exception = dummyMonitor.getException();
+            Exception exception = dummyMonitor.getException();
             // we have another exception
             // report it to the dummy monitor if we are in the recursion
             dummyMonitor.reportError( exception );

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportCsvJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportCsvJob.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportCsvJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportCsvJob.java Sun Mar  1 22:36:51 2009
@@ -29,6 +29,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.naming.NamingException;
+
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
@@ -37,9 +39,9 @@
 import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
 import org.apache.directory.studio.ldapbrowser.core.jobs.ExportLdifJob.JndiLdifEnumeration;
 import org.apache.directory.studio.ldapbrowser.core.model.AttributeDescription;
-import org.apache.directory.studio.ldapbrowser.core.model.ConnectionException;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
+import org.apache.directory.studio.ldapbrowser.core.utils.JNDIUtils;
 import org.apache.directory.studio.ldifparser.LdifUtils;
 import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
 import org.apache.directory.studio.ldifparser.model.container.LdifContentRecord;
@@ -186,17 +188,16 @@
      * @param exportDn the export dn
      * 
      * @throws IOException Signals that an I/O exception has occurred.
-     * @throws ConnectionException the connection exception
      */
     private static void exportToCsv( IBrowserConnection browserConnection, SearchParameter searchParameter,
         BufferedWriter bufferedWriter, int count, StudioProgressMonitor monitor, String[] attributes,
         String attributeDelimiter, String valueDelimiter, String quoteCharacter, String lineSeparator, String encoding,
-        int binaryEncoding, boolean exportDn ) throws IOException, ConnectionException
+        int binaryEncoding, boolean exportDn ) throws IOException
     {
         try
         {
             JndiLdifEnumeration enumeration = ExportLdifJob.search( browserConnection, searchParameter, monitor );
-            while ( !monitor.isCanceled() && enumeration.hasNext() )
+            while ( !monitor.isCanceled() && !monitor.errorsReported() && enumeration.hasNext() )
             {
                 LdifContainer container = enumeration.next();
 
@@ -214,10 +215,10 @@
                 }
             }
         }
-        catch ( ConnectionException ce )
+        catch ( NamingException ce )
         {
-
-            if ( ce.getLdapStatusCode() == 3 || ce.getLdapStatusCode() == 4 || ce.getLdapStatusCode() == 11 )
+            int ldapStatusCode = JNDIUtils.getLdapStatusCode( ce );
+            if ( ldapStatusCode == 3 || ldapStatusCode == 4 || ldapStatusCode == 11 )
             {
                 // nothing
             }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportLdifJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportLdifJob.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportLdifJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportLdifJob.java Sun Mar  1 22:36:51 2009
@@ -41,7 +41,6 @@
 import org.apache.directory.studio.connection.core.io.jndi.StudioNamingEnumeration;
 import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
-import org.apache.directory.studio.ldapbrowser.core.model.ConnectionException;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
 import org.apache.directory.studio.ldapbrowser.core.model.StudioControl;
@@ -147,15 +146,14 @@
 
 
     private static void export( IBrowserConnection browserConnection, SearchParameter searchParameter,
-        BufferedWriter bufferedWriter, int count, StudioProgressMonitor monitor ) throws IOException,
-        ConnectionException
+        BufferedWriter bufferedWriter, int count, StudioProgressMonitor monitor ) throws IOException
     {
         try
         {
             AttributeComparator comparator = new AttributeComparator( browserConnection );
             JndiLdifEnumeration enumeration = search( browserConnection, searchParameter, monitor );
 
-            while ( !monitor.isCanceled() && enumeration.hasNext() )
+            while ( !monitor.isCanceled() && !monitor.errorsReported() && enumeration.hasNext() )
             {
                 LdifContainer container = enumeration.next();
 
@@ -186,17 +184,16 @@
                 }
             }
         }
-        catch ( ConnectionException ce )
+        catch ( NamingException ne )
         {
-            if ( ce.getLdapStatusCode() == ConnectionException.STAUS_CODE_TIMELIMIT_EXCEEDED
-                || ce.getLdapStatusCode() == ConnectionException.STAUS_CODE_SIZELIMIT_EXCEEDED
-                || ce.getLdapStatusCode() == ConnectionException.STAUS_CODE_ADMINLIMIT_EXCEEDED )
+            int ldapStatusCode = JNDIUtils.getLdapStatusCode( ne );
+            if ( ldapStatusCode == 3 || ldapStatusCode == 4 || ldapStatusCode == 11 )
             {
                 // ignore
             }
             else
             {
-                monitor.reportError( ce );
+                monitor.reportError( ne );
             }
         }
     }
@@ -209,14 +206,9 @@
 
 
     static JndiLdifEnumeration search( IBrowserConnection browserConnection, SearchParameter parameter,
-        StudioProgressMonitor monitor ) throws ConnectionException
+        StudioProgressMonitor monitor )
     {
         StudioNamingEnumeration result = SearchRunnable.search( browserConnection, parameter, monitor );
-
-        if ( monitor.errorsReported() )
-        {
-            throw JNDIUtils.createConnectionException( null, monitor.getException() );
-        }
         return new JndiLdifEnumeration( result, browserConnection, parameter, monitor );
     }
 
@@ -242,92 +234,78 @@
         }
 
 
-        public boolean hasNext() throws ConnectionException
+        public boolean hasNext() throws NamingException
         {
-            try
+            if ( enumeration != null )
             {
-                if ( enumeration != null )
+                if ( enumeration.hasMore() )
                 {
-                    if ( enumeration.hasMore() )
-                    {
-                        return true;
-                    }
+                    return true;
+                }
 
-                    Control[] jndiControls = enumeration.getResponseControls();
-                    if ( jndiControls != null )
+                Control[] jndiControls = enumeration.getResponseControls();
+                if ( jndiControls != null )
+                {
+                    for ( Control jndiControl : jndiControls )
                     {
-                        for ( Control jndiControl : jndiControls )
+                        if ( jndiControl instanceof PagedResultsResponseControl )
                         {
-                            if ( jndiControl instanceof PagedResultsResponseControl )
+                            PagedResultsResponseControl prrc = ( PagedResultsResponseControl ) jndiControl;
+                            byte[] cookie = prrc.getCookie();
+                            if ( cookie != null )
                             {
-                                PagedResultsResponseControl prrc = ( PagedResultsResponseControl ) jndiControl;
-                                byte[] cookie = prrc.getCookie();
-                                if ( cookie != null )
+                                // search again: pass the response cookie to the request control
+                                for ( StudioControl studioControl : parameter.getControls() )
                                 {
-                                    // search again: pass the response cookie to the request control
-                                    for ( StudioControl studioControl : parameter.getControls() )
+                                    if ( studioControl instanceof StudioPagedResultsControl )
                                     {
-                                        if ( studioControl instanceof StudioPagedResultsControl )
-                                        {
-                                            StudioPagedResultsControl sprc = ( StudioPagedResultsControl ) studioControl;
-                                            sprc.setCookie( cookie );
-                                        }
+                                        StudioPagedResultsControl sprc = ( StudioPagedResultsControl ) studioControl;
+                                        sprc.setCookie( cookie );
                                     }
-                                    enumeration = SearchRunnable.search( browserConnection, parameter, monitor );
-                                    return enumeration != null && enumeration.hasMore();
                                 }
+                                enumeration = SearchRunnable.search( browserConnection, parameter, monitor );
+                                return enumeration != null && enumeration.hasMore();
                             }
                         }
                     }
                 }
-
-                return false;
-            }
-            catch ( NamingException e )
-            {
-                throw JNDIUtils.createConnectionException( parameter, e );
             }
+
+            return false;
         }
 
 
-        public LdifContainer next() throws ConnectionException
+        public LdifContainer next() throws NamingException
         {
-            try
-            {
-                SearchResult sr = enumeration.next();
-                LdapDN dn = JNDIUtils.getDn( sr );
-                LdifContentRecord record = LdifContentRecord.create( dn.getUpName() );
+            SearchResult sr = enumeration.next();
+            LdapDN dn = JNDIUtils.getDn( sr );
+            LdifContentRecord record = LdifContentRecord.create( dn.getUpName() );
 
-                NamingEnumeration<? extends Attribute> attributeEnumeration = sr.getAttributes().getAll();
-                while ( attributeEnumeration.hasMore() )
+            NamingEnumeration<? extends Attribute> attributeEnumeration = sr.getAttributes().getAll();
+            while ( attributeEnumeration.hasMore() )
+            {
+                Attribute attribute = attributeEnumeration.next();
+                String attributeName = attribute.getID();
+                NamingEnumeration<?> valueEnumeration = attribute.getAll();
+                while ( valueEnumeration.hasMore() )
                 {
-                    Attribute attribute = attributeEnumeration.next();
-                    String attributeName = attribute.getID();
-                    NamingEnumeration<?> valueEnumeration = attribute.getAll();
-                    while ( valueEnumeration.hasMore() )
+                    Object o = valueEnumeration.next();
+                    if ( o instanceof String )
                     {
-                        Object o = valueEnumeration.next();
-                        if ( o instanceof String )
-                        {
-                            record.addAttrVal( LdifAttrValLine.create( attributeName, ( String ) o ) );
-                        }
-                        if ( o instanceof byte[] )
-                        {
-                            record.addAttrVal( LdifAttrValLine.create( attributeName, ( byte[] ) o ) );
-                        }
+                        record.addAttrVal( LdifAttrValLine.create( attributeName, ( String ) o ) );
+                    }
+                    if ( o instanceof byte[] )
+                    {
+                        record.addAttrVal( LdifAttrValLine.create( attributeName, ( byte[] ) o ) );
                     }
                 }
+            }
 
-                record.finish( LdifSepLine.create() );
-
-                return record;
+            record.finish( LdifSepLine.create() );
 
-            }
-            catch ( NamingException e )
-            {
-                throw JNDIUtils.createConnectionException( parameter, e );
-            }
+            return record;
         }
+
     }
 
 }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportXlsJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportXlsJob.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportXlsJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportXlsJob.java Sun Mar  1 22:36:51 2009
@@ -26,6 +26,8 @@
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+import javax.naming.NamingException;
+
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
@@ -33,9 +35,9 @@
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
 import org.apache.directory.studio.ldapbrowser.core.jobs.ExportLdifJob.JndiLdifEnumeration;
-import org.apache.directory.studio.ldapbrowser.core.model.ConnectionException;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
+import org.apache.directory.studio.ldapbrowser.core.utils.JNDIUtils;
 import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
 import org.apache.directory.studio.ldifparser.model.container.LdifContentRecord;
 import org.apache.poi.hssf.usermodel.HSSFCell;
@@ -211,17 +213,16 @@
      * @param exportDn the export dn
      * 
      * @throws IOException Signals that an I/O exception has occurred.
-     * @throws ConnectionException the connection exception
      */
     private static void exportToXls( IBrowserConnection browserConnection, SearchParameter searchParameter,
         HSSFSheet sheet, HSSFRow headerRow, int count, StudioProgressMonitor monitor,
         LinkedHashMap<String, Short> attributeNameMap, String valueDelimiter, int binaryEncoding, boolean exportDn )
-        throws IOException, ConnectionException
+        throws IOException
     {
         try
         {
             JndiLdifEnumeration enumeration = ExportLdifJob.search( browserConnection, searchParameter, monitor );
-            while ( !monitor.isCanceled() && enumeration.hasNext() )
+            while ( !monitor.isCanceled() && !monitor.errorsReported() && enumeration.hasNext() )
             {
                 LdifContainer container = enumeration.next();
 
@@ -239,15 +240,16 @@
             }
 
         }
-        catch ( ConnectionException ce )
+        catch ( NamingException ne )
         {
-            if ( ce.getLdapStatusCode() == 3 || ce.getLdapStatusCode() == 4 || ce.getLdapStatusCode() == 11 )
+            int ldapStatusCode = JNDIUtils.getLdapStatusCode( ne );
+            if ( ldapStatusCode == 3 || ldapStatusCode == 4 || ldapStatusCode == 11 )
             {
                 // nothing
             }
             else
             {
-                monitor.reportError( ce );
+                monitor.reportError( ne );
             }
         }
     }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/FetchBaseDNsRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/FetchBaseDNsRunnable.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/FetchBaseDNsRunnable.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/FetchBaseDNsRunnable.java Sun Mar  1 22:36:51 2009
@@ -26,6 +26,7 @@
 
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.jobs.StudioBulkRunnableWithProgress;
+import org.apache.directory.studio.connection.core.jobs.StudioConnectionJob;
 import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
@@ -98,7 +99,8 @@
         monitor.worked( 1 );
 
         IRootDSE rootDSE = connection.getRootDSE();
-        InitializeAttributesRunnable.initializeAttributes( rootDSE, true, monitor );
+        InitializeRootDSERunnable runnable = new InitializeRootDSERunnable( rootDSE );
+        runnable.run( monitor );
 
         IEntry[] baseDNEntries = connection.getRootDSE().getChildren();
         if ( baseDNEntries != null )

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportLdifJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportLdifJob.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportLdifJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportLdifJob.java Sun Mar  1 22:36:51 2009
@@ -37,6 +37,7 @@
 
 import javax.naming.InvalidNameException;
 import javax.naming.NameAlreadyBoundException;
+import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
@@ -56,7 +57,6 @@
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
 import org.apache.directory.studio.ldapbrowser.core.events.BulkModificationEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
-import org.apache.directory.studio.ldapbrowser.core.model.ConnectionException;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.utils.ModelConverter;
@@ -393,14 +393,14 @@
      * @param updateIfEntryExists the update if entry exists flag
      * @param monitor the progress monitor
      * 
-     * @throws ConnectionException the connection exception
+     * @throws NamingException the naming exception
      */
     static void importLdifRecord( IBrowserConnection browserConnection, LdifRecord record, boolean updateIfEntryExists,
-        StudioProgressMonitor monitor ) throws ConnectionException
+        StudioProgressMonitor monitor ) throws NamingException
     {
         if ( !record.isValid() )
         {
-            throw new ConnectionException( BrowserCoreMessages.model__invalid_record );
+            throw new NamingException( BrowserCoreMessages.model__invalid_record );
         }
 
         String dn = record.getDnLine().getValueAsString();
@@ -515,25 +515,20 @@
                 String newRdn = modDnRecord.getNewrdnLine().getValueAsString();
                 boolean deleteOldRdn = modDnRecord.getDeloldrdnLine().isDeleteOldRdn();
 
-                try
+                LdapDN newDn;
+                if ( modDnRecord.getNewsuperiorLine() != null )
                 {
-                    LdapDN newDn;
-                    if ( modDnRecord.getNewsuperiorLine() != null )
-                        newDn = DnUtils.composeDn( newRdn, modDnRecord.getNewsuperiorLine().getValueAsString() );
-                    else
-                    {
-                        LdapDN dnObject = new LdapDN( dn );
-                        LdapDN parent = DnUtils.getParent( dnObject );
-                        newDn = DnUtils.composeDn( newRdn, parent.getUpName() );
-                    }
-
-                    browserConnection.getConnection().getJNDIConnectionWrapper().renameEntry( dn, newDn.toString(),
-                        deleteOldRdn, ReferralHandlingMethod.IGNORE, getControls( modDnRecord ), monitor, null );
+                    newDn = DnUtils.composeDn( newRdn, modDnRecord.getNewsuperiorLine().getValueAsString() );
                 }
-                catch ( InvalidNameException ne )
+                else
                 {
-                    throw new ConnectionException( ne );
+                    LdapDN dnObject = new LdapDN( dn );
+                    LdapDN parent = DnUtils.getParent( dnObject );
+                    newDn = DnUtils.composeDn( newRdn, parent.getUpName() );
                 }
+
+                browserConnection.getConnection().getJNDIConnectionWrapper().renameEntry( dn, newDn.toString(),
+                    deleteOldRdn, ReferralHandlingMethod.IGNORE, getControls( modDnRecord ), monitor, null );
             }
         }
     }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java Sun Mar  1 22:36:51 2009
@@ -182,7 +182,7 @@
                     {
                         // no simulated rename operation
                         // report the exception to the real monitor
-                        Throwable exception = dummyMonitor.getException();
+                        Exception exception = dummyMonitor.getException();
                         monitor.reportError( exception );
                     }
                 }
@@ -190,7 +190,7 @@
                 {
                     // we have another exception
                     // report it to the real monitor
-                    Throwable exception = dummyMonitor.getException();
+                    Exception exception = dummyMonitor.getException();
                     monitor.reportError( exception );
                 }
             }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ReadEntryRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ReadEntryRunnable.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ReadEntryRunnable.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ReadEntryRunnable.java Sun Mar  1 22:36:51 2009
@@ -180,7 +180,7 @@
         }
         catch ( Exception e )
         {
-            monitor.reportError( e.getMessage(), e );
+            monitor.reportError( e );
             return null;
         }
     }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java Sun Mar  1 22:36:51 2009
@@ -166,7 +166,7 @@
                 {
                     // no simulated rename operation
                     // report the exception to the real monitor
-                    Throwable exception = dummyMonitor.getException();
+                    Exception exception = dummyMonitor.getException();
                     monitor.reportError( exception );
                 }
             }
@@ -174,7 +174,7 @@
             {
                 // we have another exception
                 // report it to the real monitor
-                Throwable exception = dummyMonitor.getException();
+                Exception exception = dummyMonitor.getException();
                 monitor.reportError( exception );
             }
         }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java Sun Mar  1 22:36:51 2009
@@ -53,7 +53,6 @@
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
 import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateEvent;
 import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
-import org.apache.directory.studio.ldapbrowser.core.model.ConnectionException;
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
@@ -362,15 +361,14 @@
                 }
                 catch ( Exception e )
                 {
-                    ConnectionException ce = JNDIUtils.createConnectionException( searchParameter, e );
-
-                    if ( ce.getLdapStatusCode() == 3 || ce.getLdapStatusCode() == 4 || ce.getLdapStatusCode() == 11 )
+                    int ldapStatusCode = JNDIUtils.getLdapStatusCode( e );
+                    if ( ldapStatusCode == 3 || ldapStatusCode == 4 || ldapStatusCode == 11 )
                     {
                         search.setCountLimitExceeded( true );
                     }
                     else
                     {
-                        monitor.reportError( ce );
+                        monitor.reportError( e );
                     }
                 }
 
@@ -407,8 +405,7 @@
                 }
                 catch ( Exception e )
                 {
-                    ConnectionException ce = JNDIUtils.createConnectionException( searchParameter, e );
-                    monitor.reportError( ce );
+                    monitor.reportError( e );
                 }
 
                 monitor.reportProgress( searchResultList.size() == 1 ? BrowserCoreMessages.model__retrieved_1_entry

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/JNDIUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/JNDIUtils.java?rev=749143&r1=749142&r2=749143&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/JNDIUtils.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/JNDIUtils.java Sun Mar  1 22:36:51 2009
@@ -21,17 +21,9 @@
 package org.apache.directory.studio.ldapbrowser.core.utils;
 
 
-import java.net.ConnectException;
-import java.net.NoRouteToHostException;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
-import org.apache.directory.studio.ldapbrowser.core.model.ConnectionException;
-import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
 
 
 /**
@@ -84,84 +76,32 @@
 
 
     /**
-     * Creates a connection exception.
+     * Gets the LDAP status code from the exception.
      * 
-     * @param searchParameter the search parameter
-     * @param e the exception
+     * @param exception the exception
      * 
-     * @return the connection exception
+     * @return the LDAP status code, -1 if none
      */
-    public static ConnectionException createConnectionException( SearchParameter searchParameter, Throwable e )
+    public static int getLdapStatusCode( Exception exception )
     {
-        // TODO: remove when improving error handling
-        e.printStackTrace();
-
-        ConnectionException connectionException = null;
-        ConnectionException lastException = null;
-
-        do
-        {
-            String message = e.getMessage() != null ? e.getMessage() : e.getClass().getName();
-            int ldapStatusCode = -1;
-
-            // get LDAP status code
-            // [LDAP: error code 21 - telephoneNumber: value #0 invalid per syntax]
-            if ( message != null && message.startsWith( "[LDAP: error code " ) ) { //$NON-NLS-1$
-                int begin = "[LDAP: error code ".length(); //$NON-NLS-1$
-                int end = begin + 2;
-                try
-                {
-                    ldapStatusCode = Integer.parseInt( message.substring( begin, end ).trim() );
-                }
-                catch ( NumberFormatException nfe )
-                {
-                }
-            }
+        int ldapStatusCode = -1;
 
-            // special causes
-            // java_io_IOException=I/O exception occurred: {0}
-            // java_io_EOFException=End of file encountered: {0}
-            // java_io_FileNotFoundException=File not found: {0}
-            // java_io_InterruptedIOException=I/O has been interrupted.
-            // java_net_UnknownHostException=Cannot locate host: {0}
-            // java_net_ConnectException=Cannot connect to host: {0}
-            // java_net_SocketException=Socket Exception: {0}
-            // java_net_NoRouteToHostException={0}
-            if ( e instanceof ConnectException )
-            {
-                message = e.getMessage() + " (" + e.getMessage() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-            }
-            if ( e instanceof NoRouteToHostException )
-            {
-                message += e.getMessage() + " (" + e.getMessage() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-            }
-            if ( e instanceof UnknownHostException )
+        // get LDAP status code
+        // [LDAP: error code 21 - telephoneNumber: value #0 invalid per syntax]
+        String message = exception.getMessage();
+        if ( message != null && message.startsWith( "[LDAP: error code " ) ) { //$NON-NLS-1$
+            int begin = "[LDAP: error code ".length(); //$NON-NLS-1$
+            int end = begin + 2;
+            try
             {
-                message = BrowserCoreMessages.model__unknown_host + e.getMessage();
+                ldapStatusCode = Integer.parseInt( message.substring( begin, end ).trim() );
             }
-            if ( e instanceof SocketException )
+            catch ( NumberFormatException nfe )
             {
-                message = e.getMessage() + " (" + e.getMessage() + ")";; //$NON-NLS-1$ //$NON-NLS-2$
             }
-
-            ConnectionException ce = new ConnectionException( ldapStatusCode, message, e );
-            if ( lastException != null )
-            {
-                lastException.initCause( ce );
-            }
-            lastException = ce;
-            if ( connectionException == null )
-            {
-                connectionException = lastException;
-            }
-
-            // next cause
-            e = e.getCause();
         }
-        while ( e != null );
-
-        return connectionException;
 
+        return ldapStatusCode;
     }
 
 }



Mime
View raw message