directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1222237 - /directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryRunnable.java
Date Thu, 22 Dec 2011 14:02:18 GMT
Author: pamarcelot
Date: Thu Dec 22 14:02:17 2011
New Revision: 1222237

URL: http://svn.apache.org/viewvc?rev=1222237&view=rev
Log:
Fix for DIRSTUDIO-708 (NPE when renaming a referral in 'Automatic' or 'Manual' Referral Handling
mode).

Modified:
    directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryRunnable.java

Modified: directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryRunnable.java?rev=1222237&r1=1222236&r2=1222237&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryRunnable.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryRunnable.java
Thu Dec 22 14:02:17 2011
@@ -148,7 +148,7 @@ public class RenameEntryRunnable impleme
         Dn oldDn = oldEntry.getDn();
         Dn parentDn = oldDn.getParent();
         Dn newDn = null;
-        
+
         try
         {
             newDn = parentDn.add( newRdn );
@@ -213,42 +213,45 @@ public class RenameEntryRunnable impleme
 
             // remove old entry and add new entry to parent
             IEntry parent = oldEntry.getParententry();
-            boolean hasMoreChildren = parent.hasMoreChildren();
-            parent.deleteChild( oldEntry );
-
-            List<StudioControl> controls = new ArrayList<StudioControl>();
-            if ( oldEntry.isReferral() )
+            if ( parent != null )
             {
-                controls.add( StudioControl.MANAGEDSAIT_CONTROL );
-            }
+                boolean hasMoreChildren = parent.hasMoreChildren();
+                parent.deleteChild( oldEntry );
 
-            // Here we try to read the renamed entry to be able to send the right event notification.
-            // In some cases this don't work:
-            // - if there was a referral and the entry was created on another (master) server
and not yet sync'ed to the current server
-            // So we use a dummy monitor to no bother the user with an error message.
-            dummyMonitor.reset();
-            newEntry = ReadEntryRunnable.getEntry( browserConnection, newDn, controls, dummyMonitor
);
-            dummyMonitor.done();
-            if ( newEntry != null )
-            {
-                parent.addChild( newEntry );
-            }
-            parent.setHasMoreChildren( hasMoreChildren );
+                List<StudioControl> controls = new ArrayList<StudioControl>();
+                if ( oldEntry.isReferral() )
+                {
+                    controls.add( StudioControl.MANAGEDSAIT_CONTROL );
+                }
 
-            // reset searches, if the renamed entry is a result of a search
-            List<ISearch> searches = browserConnection.getSearchManager().getSearches();
-            for ( ISearch search : searches )
-            {
-                if ( search.getSearchResults() != null )
+                // Here we try to read the renamed entry to be able to send the right event
notification.
+                // In some cases this don't work:
+                // - if there was a referral and the entry was created on another (master)
server and not yet sync'ed to the current server
+                // So we use a dummy monitor to no bother the user with an error message.
+                dummyMonitor.reset();
+                newEntry = ReadEntryRunnable.getEntry( browserConnection, newDn, controls,
dummyMonitor );
+                dummyMonitor.done();
+                if ( newEntry != null )
+                {
+                    parent.addChild( newEntry );
+                }
+                parent.setHasMoreChildren( hasMoreChildren );
+
+                // reset searches, if the renamed entry is a result of a search
+                List<ISearch> searches = browserConnection.getSearchManager().getSearches();
+                for ( ISearch search : searches )
                 {
-                    ISearchResult[] searchResults = search.getSearchResults();
-                    for ( ISearchResult result : searchResults )
+                    if ( search.getSearchResults() != null )
                     {
-                        if ( oldEntry.equals( result.getEntry() ) )
+                        ISearchResult[] searchResults = search.getSearchResults();
+                        for ( ISearchResult result : searchResults )
                         {
-                            search.setSearchResults( null );
-                            searchesToUpdateSet.add( search );
-                            break;
+                            if ( oldEntry.equals( result.getEntry() ) )
+                            {
+                                search.setSearchResults( null );
+                                searchesToUpdateSet.add( search );
+                                break;
+                            }
                         }
                     }
                 }



Mime
View raw message