directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1427838 - /directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorUtils.java
Date Wed, 02 Jan 2013 16:08:05 GMT
Author: pamarcelot
Date: Wed Jan  2 16:08:05 2013
New Revision: 1427838

URL: http://svn.apache.org/viewvc?rev=1427838&view=rev
Log:
Speed up the "save configuration" process by avoiding unnecessary events firing.

Modified:
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorUtils.java

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorUtils.java?rev=1427838&r1=1427837&r2=1427838&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorUtils.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorUtils.java
Wed Jan  2 16:08:05 2013
@@ -35,6 +35,7 @@ import org.apache.directory.studio.apach
 import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
 import org.apache.directory.studio.common.ui.CommonUIUtils;
 import org.apache.directory.studio.common.ui.filesystem.PathEditorInput;
+import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
 import org.apache.directory.studio.ldapbrowser.core.jobs.ExecuteLdifRunnable;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
@@ -335,40 +336,52 @@ public class ServerConfigurationEditorUt
             newconfigurationPartition.addEntry( new DefaultEntry( schemaManager, ldifEntry.getEntry()
) );
         }
 
-        // Comparing both partitions to get the list of modifications to be applied
-        PartitionsDiffComputer partitionsDiffComputer = new PartitionsDiffComputer();
-        partitionsDiffComputer.setOriginalPartition( originalPartition );
-        partitionsDiffComputer.setDestinationPartition( newconfigurationPartition );
-        List<LdifEntry> modificationsList = partitionsDiffComputer.computeModifications(
new String[]
-            { SchemaConstants.ALL_USER_ATTRIBUTES } );
-
-        // Building the resulting LDIF
-        StringBuilder modificationsLdif = new StringBuilder();
-        for ( LdifEntry ldifEntry : modificationsList )
+        // Suspends event firing in current thread.
+        ConnectionEventRegistry.suspendEventFiringInCurrentThread();
+
+        try
         {
-            modificationsLdif.append( ldifEntry.toString() );
-        }
 
-        // Getting the browser connection associated with the connection
-        IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
-            .getBrowserConnection( input.getConnection() );
-
-        // Creating a StudioProgressMonitor to run the LDIF with
-        StudioProgressMonitor studioProgressMonitor = new StudioProgressMonitor( new NullProgressMonitor()
);
-
-        // Updating the configuration with the resulting LDIF
-        ExecuteLdifRunnable.executeLdif( browserConnection, modificationsLdif.toString(),
true, true,
-            studioProgressMonitor );
+            // Comparing both partitions to get the list of modifications to be applied
+            PartitionsDiffComputer partitionsDiffComputer = new PartitionsDiffComputer();
+            partitionsDiffComputer.setOriginalPartition( originalPartition );
+            partitionsDiffComputer.setDestinationPartition( newconfigurationPartition );
+            List<LdifEntry> modificationsList = partitionsDiffComputer.computeModifications(
new String[]
+                { SchemaConstants.ALL_USER_ATTRIBUTES } );
 
-        // Checking if there were errors during the execution of the LDIF
-        if ( studioProgressMonitor.errorsReported() )
-        {
-            throw new Exception( "Changes could not be saved to the connection." );
+            // Building the resulting LDIF
+            StringBuilder modificationsLdif = new StringBuilder();
+            for ( LdifEntry ldifEntry : modificationsList )
+            {
+                modificationsLdif.append( ldifEntry.toString() );
+            }
+
+            // Getting the browser connection associated with the connection
+            IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
+                .getBrowserConnection( input.getConnection() );
+
+            // Creating a StudioProgressMonitor to run the LDIF with
+            StudioProgressMonitor studioProgressMonitor = new StudioProgressMonitor( new
NullProgressMonitor() );
+
+            // Updating the configuration with the resulting LDIF
+            ExecuteLdifRunnable.executeLdif( browserConnection, modificationsLdif.toString(),
true, true,
+                studioProgressMonitor );
+
+            // Checking if there were errors during the execution of the LDIF
+            if ( studioProgressMonitor.errorsReported() )
+            {
+                throw new Exception( "Changes could not be saved to the connection." );
+            }
+            else
+            {
+                // Swapping the new configuration partition
+                input.setOriginalPartition( newconfigurationPartition );
+            }
         }
-        else
+        finally
         {
-            // Swapping the new configuration partition
-            input.setOriginalPartition( newconfigurationPartition );
+            // Resumes event firing in current thread.
+            ConnectionEventRegistry.resumeEventFiringInCurrentThread();
         }
     }
 



Mime
View raw message