directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r693479 - /directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlJob.java
Date Tue, 09 Sep 2008 15:06:59 GMT
Author: pamarcelot
Date: Tue Sep  9 08:06:58 2008
New Revision: 693479

URL: http://svn.apache.org/viewvc?rev=693479&view=rev
Log:
Part of a fix for DIRSTUDIO-355 (DSML Import and Export fail with "Internal Error: null").
	o Added javadoc
	o Fixed the issue with the SearchResultDone element.

Modified:
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlJob.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=693479&r1=693478&r2=693479&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
Tue Sep  9 08:06:58 2008
@@ -33,13 +33,17 @@
 import javax.naming.directory.SearchResult;
 
 import org.apache.commons.codec.digest.DigestUtils;
+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.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
 import org.apache.directory.studio.dsmlv2.reponse.BatchResponseDsml;
 import org.apache.directory.studio.dsmlv2.reponse.SearchResponseDsml;
+import org.apache.directory.studio.dsmlv2.reponse.SearchResultDoneDsml;
 import org.apache.directory.studio.dsmlv2.reponse.SearchResultEntryDsml;
 import org.apache.directory.studio.dsmlv2.request.AddRequestDsml;
 import org.apache.directory.studio.dsmlv2.request.BatchRequestDsml;
@@ -128,7 +132,7 @@
      */
     protected void executeAsyncJob( StudioProgressMonitor monitor )
     {
-        monitor.beginTask( BrowserCoreMessages.jobs__export_dsml_task, 2 );
+        monitor.beginTask( BrowserCoreMessages.jobs__export_dsml_task, 4 );
         monitor.reportProgress( " " ); //$NON-NLS-1$
         monitor.worked( 1 );
 
@@ -136,6 +140,7 @@
         {
             // Searching for the requested entries
             NamingEnumeration<SearchResult> ne = SearchRunnable.search( browserConnection,
searchParameter, monitor );
+            monitor.worked( 1 );
 
             // Getting the DSML string associated to the search
             // and the type of answer the user is expecting
@@ -149,6 +154,7 @@
                     dsmlExportString = processAsDsmlRequest( ne );
                     break;
             }
+            monitor.worked( 1 );
 
             // Writing the DSML string to the final destination file.
             if ( dsmlExportString != null )
@@ -161,6 +167,7 @@
                 osw.close();
                 fos.close();
             }
+            monitor.worked( 1 );
         }
         catch ( Exception e )
         {
@@ -182,10 +189,14 @@
     private String processAsDsmlResponse( NamingEnumeration<SearchResult> ne )
         throws InvalidAttributeIdentifierException, InvalidNameException
     {
+        // Creating the batch reponse
         BatchResponseDsml batchResponse = new BatchResponseDsml();
+
+        // Creating and adding the search response
         SearchResponseDsml sr = new SearchResponseDsml();
         batchResponse.addResponse( sr );
 
+        // Creating and adding a search result entry for each result
         while ( ne.hasMoreElements() )
         {
             SearchResult searchResult = ( SearchResult ) ne.nextElement();
@@ -193,6 +204,14 @@
             sr.addResponse( sreDsml );
         }
 
+        // Creating and adding a search result done at the end of the results
+        SearchResultDone srd = new SearchResultDone();
+        LdapResult ldapResult = new LdapResult();
+        ldapResult.setResultCode( ResultCodeEnum.SUCCESS );
+        srd.setLdapResult( ldapResult );
+        sr.addResponse( new SearchResultDoneDsml( srd ) );
+
+        // Returning the associated DSML
         return batchResponse.toDsml();
     }
 
@@ -232,8 +251,10 @@
     private String processAsDsmlRequest( NamingEnumeration<SearchResult> ne )
         throws InvalidAttributeIdentifierException, InvalidNameException
     {
+        // Creating the batch request
         BatchRequestDsml batchRequest = new BatchRequestDsml();
 
+        // Creating and adding an add request for each result
         while ( ne.hasMoreElements() )
         {
             SearchResult searchResult = ( SearchResult ) ne.nextElement();
@@ -241,6 +262,7 @@
             batchRequest.addRequest( arDsml );
         }
 
+        // Returning the associated DSML
         return batchRequest.toDsml();
     }
 



Mime
View raw message