directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r526277 - in /directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs: DeleteEntriesJob.java MoveEntriesJob.java RenameEntryJob.java
Date Fri, 06 Apr 2007 21:00:47 GMT
Author: seelmann
Date: Fri Apr  6 14:00:46 2007
New Revision: 526277

URL: http://svn.apache.org/viewvc?view=rev&rev=526277
Log:
Improved model state update when a directory operation failed:
  - don't delete entry from model when delete operation fails
  - update modification logs when modify operation fails

Modified:
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/DeleteEntriesJob.java
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/MoveEntriesJob.java
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/RenameEntryJob.java

Modified: directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/DeleteEntriesJob.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/DeleteEntriesJob.java?view=diff&rev=526277&r1=526276&r2=526277
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/DeleteEntriesJob.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/DeleteEntriesJob.java
Fri Apr  6 14:00:46 2007
@@ -30,6 +30,7 @@
 
 import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
 import org.apache.directory.ldapstudio.browser.core.events.ChildrenInitializedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryDeletedEvent;
 import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
 import org.apache.directory.ldapstudio.browser.core.events.SearchUpdateEvent;
 import org.apache.directory.ldapstudio.browser.core.internal.model.Search;
@@ -46,6 +47,8 @@
 
     private IEntry[] entriesToDelete;
 
+    private Set deletedEntriesSet = new HashSet();
+    
     private Set entriesToUpdateSet = new HashSet();
 
     private Set searchesToUpdateSet = new HashSet();
@@ -90,7 +93,7 @@
         monitor.worked( 1 );
 
         int num = 0;
-        for ( int i = 0; !monitor.isCanceled() && i < entriesToDelete.length;
i++ )
+        for ( int i = 0; !monitor.isCanceled() && !monitor.errorsReported() &&
i < entriesToDelete.length; i++ )
         {
 
             IEntry entryToDelete = entriesToDelete[i];
@@ -98,32 +101,38 @@
 
             // delete from directory
             // TODO: use TreeDelete Control, if available
+            int errorStatusSize1 = monitor.getErrorStatus( "" ).getChildren().length; //$NON-NLS-1$
             num = deleteEntryRecursive( entryToDelete, false, num, monitor );
+            int errorStatusSize2 = monitor.getErrorStatus( "" ).getChildren().length; //$NON-NLS-1$
+            deletedEntriesSet.add( entryToDelete );
 
-            // delete from parent
-            entryToDelete.getParententry().deleteChild( entryToDelete );
-            entriesToUpdateSet.add( entryToDelete.getParententry() );
-
-            // delete from searches
-            ISearch[] searches = connection.getSearchManager().getSearches();
-            for ( int j = 0; j < searches.length; j++ )
+            if ( errorStatusSize1 == errorStatusSize2 )
             {
-                ISearch search = searches[j];
-                if ( search.getSearchResults() != null )
+                // delete from parent
+                entryToDelete.getParententry().deleteChild( entryToDelete );
+                entriesToUpdateSet.add( entryToDelete.getParententry() );
+
+                // delete from searches
+                ISearch[] searches = connection.getSearchManager().getSearches();
+                for ( int j = 0; j < searches.length; j++ )
                 {
-                    ISearchResult[] searchResults = search.getSearchResults();
-                    for ( int k = 0; k < searchResults.length; k++ )
+                    ISearch search = searches[j];
+                    if ( search.getSearchResults() != null )
                     {
-                        ISearchResult result = searchResults[k];
-                        if ( entryToDelete.equals( result.getEntry() ) )
+                        ISearchResult[] searchResults = search.getSearchResults();
+                        for ( int k = 0; k < searchResults.length; k++ )
                         {
-                            ISearchResult[] newsrs = new ISearchResult[searchResults.length
- 1];
-                            System.arraycopy( searchResults, 0, newsrs, 0, k );
-                            System.arraycopy( searchResults, k + 1, newsrs, k, searchResults.length
- k - 1 );
-                            search.setSearchResults( newsrs );
-                            searchResults = newsrs;
-                            k--;
-                            searchesToUpdateSet.add( search );
+                            ISearchResult result = searchResults[k];
+                            if ( entryToDelete.equals( result.getEntry() ) )
+                            {
+                                ISearchResult[] newsrs = new ISearchResult[searchResults.length
- 1];
+                                System.arraycopy( searchResults, 0, newsrs, 0, k );
+                                System.arraycopy( searchResults, k + 1, newsrs, k, searchResults.length
- k - 1 );
+                                search.setSearchResults( newsrs );
+                                searchResults = newsrs;
+                                k--;
+                                searchesToUpdateSet.add( search );
+                            }
                         }
                     }
                 }
@@ -212,6 +221,11 @@
 
     protected void runNotification()
     {
+        for ( Iterator it = deletedEntriesSet.iterator(); it.hasNext(); )
+        {
+            IEntry entry = ( IEntry ) it.next();
+            EventRegistry.fireEntryUpdated( new EntryDeletedEvent( entry.getConnection(),
entry ), this );
+        }
         for ( Iterator it = entriesToUpdateSet.iterator(); it.hasNext(); )
         {
             IEntry parent = ( IEntry ) it.next();

Modified: directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/MoveEntriesJob.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/MoveEntriesJob.java?view=diff&rev=526277&r1=526276&r2=526277
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/MoveEntriesJob.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/MoveEntriesJob.java
Fri Apr  6 14:00:46 2007
@@ -91,6 +91,10 @@
         monitor.worked( 1 );
 
         this.newEntries = new IEntry[oldEntries.length];
+        for ( int i = 0; i < oldEntries.length; i++ )
+        {
+            this.newEntries[i] = oldEntries[i];
+        }
 
         for ( int i = 0; i < oldEntries.length; i++ )
         {

Modified: directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/RenameEntryJob.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/RenameEntryJob.java?view=diff&rev=526277&r1=526276&r2=526277
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/RenameEntryJob.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/RenameEntryJob.java
Fri Apr  6 14:00:46 2007
@@ -59,6 +59,7 @@
     {
         this.connection = entry.getConnection();
         this.oldEntry = entry;
+        this.newEntry = entry;
         this.newRdn = newRdn;
         this.deleteOldRdn = deleteOldRdn;
 



Mime
View raw message