directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r695439 - in /directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs: ExportDsmlJob.java ImportDsmlJob.java
Date Mon, 15 Sep 2008 11:46:21 GMT
Author: pamarcelot
Date: Mon Sep 15 04:46:19 2008
New Revision: 695439

URL: http://svn.apache.org/viewvc?rev=695439&view=rev
Log:
Part of a fix for DIRSTUDIO-355 (DSML Import and Export fail with "Internal Error: null").
	o Improved error handling (again!).

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

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlJob.java?rev=695439&r1=695438&r2=695439&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlJob.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlJob.java
Mon Sep 15 04:46:19 2008
@@ -36,6 +36,7 @@
 import org.apache.directory.shared.ldap.codec.LdapResult;
 import org.apache.directory.shared.ldap.codec.search.SearchResultDone;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.message.MessageTypeEnum;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
@@ -244,9 +245,14 @@
         }
         else
         {
-            ldapResult.setResultCode( ResultCodeEnum.UNKNOWN );
+            // Getting the exception
             Throwable t = monitor.getException();
-            if ( ( t != null ) && ( t.getMessage() != null ) )
+
+            // Setting the result code
+            ldapResult.setResultCode( ResultCodeEnum.getBestEstimate( t, MessageTypeEnum.SEARCH_REQUEST
) );
+
+            // Setting the error message if there's one
+            if ( t.getMessage() != null )
             {
                 ldapResult.setErrorMessage( t.getMessage() );
             }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlJob.java?rev=695439&r1=695438&r2=695439&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlJob.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlJob.java
Mon Sep 15 04:46:19 2008
@@ -50,6 +50,7 @@
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.message.MessageTypeEnum;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.studio.connection.core.Connection;
@@ -321,7 +322,7 @@
         if ( batchResponseDsml != null )
         {
             AddResponseDsml addResponseDsml = new AddResponseDsml();
-            addResponseDsml.setLdapResult( getLdapResult( monitor ) );
+            addResponseDsml.setLdapResult( getLdapResult( monitor, MessageTypeEnum.ADD_REQUEST
) );
             batchResponseDsml.addResponse( addResponseDsml );
         }
     }
@@ -373,7 +374,7 @@
         if ( batchResponseDsml != null )
         {
             DelResponseDsml delResponseDsml = new DelResponseDsml();
-            delResponseDsml.setLdapResult( getLdapResult( monitor ) );
+            delResponseDsml.setLdapResult( getLdapResult( monitor, MessageTypeEnum.DEL_REQUEST
) );
             delResponseDsml.getLdapResult().setMatchedDN( request.getEntry() );
             batchResponseDsml.addResponse( delResponseDsml );
         }
@@ -434,7 +435,7 @@
         if ( batchResponseDsml != null )
         {
             ModifyResponseDsml modifyResponseDsml = new ModifyResponseDsml();
-            modifyResponseDsml.setLdapResult( getLdapResult( monitor ) );
+            modifyResponseDsml.setLdapResult( getLdapResult( monitor, MessageTypeEnum.MODIFY_REQUEST
) );
             batchResponseDsml.addResponse( modifyResponseDsml );
         }
     }
@@ -602,7 +603,7 @@
      * @return
      *      the corresponding LDAP Result
      */
-    private LdapResult getLdapResult( StudioProgressMonitor monitor )
+    private LdapResult getLdapResult( StudioProgressMonitor monitor, MessageTypeEnum messageType
)
     {
         LdapResult ldapResult = new LdapResult();
 
@@ -612,11 +613,14 @@
         }
         else
         {
-            // TODO: Improve error handling.
-
-            ldapResult.setResultCode( ResultCodeEnum.UNKNOWN );
+            // Getting the exception
             Throwable t = monitor.getException();
-            if ( ( t != null ) && ( t.getMessage() != null ) )
+
+            // Setting the result code
+            ldapResult.setResultCode( ResultCodeEnum.getBestEstimate( t, messageType ) );
+
+            // Setting the error message if there's one
+            if ( t.getMessage() != null )
             {
                 ldapResult.setErrorMessage( t.getMessage() );
             }



Mime
View raw message