You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2011/12/22 15:02:18 UTC

svn commit: r1222237 - /directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryRunnable.java

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;
+                            }
                         }
                     }
                 }