directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r828937 - in /directory/studio/trunk: connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/ ldapbrowser-core/src/main/java/org/apac...
Date Fri, 23 Oct 2009 05:38:45 GMT
Author: seelmann
Date: Fri Oct 23 05:38:44 2009
New Revision: 828937

URL: http://svn.apache.org/viewvc?rev=828937&view=rev
Log:
DIRSTUDIO-409 (No error message in some special case)
o Better handling when canceling the selection of referral connection

Modified:
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioProgressMonitor.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateEntryRunnable.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java?rev=828937&r1=828936&r2=828937&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
(original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
Fri Oct 23 05:38:44 2009
@@ -403,6 +403,10 @@
             return null;
         }
 
+        if ( runnable.isCanceled() )
+        {
+            monitor.setCanceled( true );
+        }
         if ( runnable.getException() != null )
         {
             monitor.reportError( runnable.getException() );
@@ -461,12 +465,14 @@
                             Connection referralConnection = getReferralConnection( referral,
monitor, this );
                             if ( referralConnection != null )
                             {
-                                String referralDn = referral.getDn() != null && !referral.getDn().isEmpty()
? referral
-                                    .getDn().getUpName() : dn;
-
+                                String referralDn = referral.getLdapURLs().get( 0 ).getDn().getUpName();
                                 referralConnection.getJNDIConnectionWrapper().modifyEntry(
referralDn,
                                     modificationItems, controls, monitor, newReferralsInfo
);
                             }
+                            else
+                            {
+                                canceled = true;
+                            }
                         }
 
                         return;
@@ -500,6 +506,10 @@
             monitor.reportError( ne );
         }
 
+        if ( runnable.isCanceled() )
+        {
+            monitor.setCanceled( true );
+        }
         if ( runnable.getException() != null )
         {
             monitor.reportError( runnable.getException() );
@@ -567,6 +577,10 @@
                                 referralConnection.getJNDIConnectionWrapper().renameEntry(
oldDn, newDn, deleteOldRdn,
                                     controls, monitor, newReferralsInfo );
                             }
+                            else
+                            {
+                                canceled = true;
+                            }
                         }
                     }
                     catch ( NamingException ne )
@@ -598,6 +612,10 @@
             monitor.reportError( ne );
         }
 
+        if ( runnable.isCanceled() )
+        {
+            monitor.setCanceled( true );
+        }
         if ( runnable.getException() != null )
         {
             monitor.reportError( runnable.getException() );
@@ -651,12 +669,14 @@
                             Connection referralConnection = getReferralConnection( referral,
monitor, this );
                             if ( referralConnection != null )
                             {
-                                String referralDn = referral.getDn() != null && !referral.getDn().isEmpty()
? referral
-                                    .getDn().getUpName() : dn;
-
+                                String referralDn = referral.getLdapURLs().get( 0 ).getDn().getUpName();
                                 referralConnection.getJNDIConnectionWrapper().createEntry(
referralDn, attributes,
                                     controls, monitor, newReferralsInfo );
                             }
+                            else
+                            {
+                                canceled = true;
+                            }
                         }
                     }
                     catch ( NamingException ne )
@@ -688,6 +708,10 @@
             monitor.reportError( ne );
         }
 
+        if ( runnable.isCanceled() )
+        {
+            monitor.setCanceled( true );
+        }
         if ( runnable.getException() != null )
         {
             monitor.reportError( runnable.getException() );
@@ -740,12 +764,14 @@
                             Connection referralConnection = getReferralConnection( referral,
monitor, this );
                             if ( referralConnection != null )
                             {
-                                String referralDn = referral.getDn() != null && !referral.getDn().isEmpty()
? referral
-                                    .getDn().getUpName() : dn;
-
+                                String referralDn = referral.getLdapURLs().get( 0 ).getDn().getUpName();
                                 referralConnection.getJNDIConnectionWrapper().deleteEntry(
referralDn, controls,
                                     monitor, newReferralsInfo );
                             }
+                            else
+                            {
+                                canceled = true;
+                            }
                         }
                     }
                     catch ( NamingException ne )
@@ -777,6 +803,10 @@
             monitor.reportError( ne );
         }
 
+        if ( runnable.isCanceled() )
+        {
+            monitor.setCanceled( true );
+        }
         if ( runnable.getException() != null )
         {
             monitor.reportError( runnable.getException() );
@@ -1329,6 +1359,7 @@
     {
         protected StudioNamingEnumeration namingEnumeration = null;
         protected NamingException namingException = null;
+        protected boolean canceled = false;
 
 
         /**
@@ -1354,12 +1385,24 @@
 
 
         /**
+         * Checks if is canceled.
+         * 
+         * @return true, if is canceled
+         */
+        public boolean isCanceled()
+        {
+            return canceled;
+        }
+
+
+        /**
          * Reset.
          */
         public void reset()
         {
             namingEnumeration = null;
             namingException = null;
+            canceled = false;
         }
     }
 

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioProgressMonitor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioProgressMonitor.java?rev=828937&r1=828936&r2=828937&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioProgressMonitor.java
(original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioProgressMonitor.java
Fri Oct 23 05:38:44 2009
@@ -355,6 +355,10 @@
 
             return multiStatus;
         }
+        else if(isCanceled())
+        {
+            return Status.CANCEL_STATUS;
+        }
         else
         {
             return Status.OK_STATUS;

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateEntryRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateEntryRunnable.java?rev=828937&r1=828936&r2=828937&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateEntryRunnable.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateEntryRunnable.java
Fri Oct 23 05:38:44 2009
@@ -116,7 +116,7 @@
 
         createEntry( browserConnection, entryToCreate, monitor );
 
-        if ( !monitor.errorsReported() )
+        if ( !monitor.errorsReported() && !monitor.isCanceled() )
         {
             List<StudioControl> controls = new ArrayList<StudioControl>();
             if ( entryToCreate.isReferral() )
@@ -124,23 +124,33 @@
                 controls.add( StudioControl.MANAGEDSAIT_CONTROL );
             }
 
-            createdEntry = ReadEntryRunnable.getEntry( browserConnection, entryToCreate.getDn(),
controls, monitor );
-            createdEntry.setHasChildrenHint( false );
-
-            // set some flags at the parent
-            if ( createdEntry.hasParententry() )
+            // Here we try to read the created 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.
+            StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );
+            createdEntry = ReadEntryRunnable
+                .getEntry( browserConnection, entryToCreate.getDn(), controls, dummyMonitor
);
+            dummyMonitor.done();
+            if ( createdEntry != null )
             {
-                if ( createdEntry.isAlias() )
-                {
-                    createdEntry.getParententry().setFetchAliases( true );
-                }
-                if ( createdEntry.isReferral() )
-                {
-                    createdEntry.getParententry().setFetchReferrals( true );
-                }
-                if ( createdEntry.isSubentry() )
+                createdEntry.setHasChildrenHint( false );
+
+                // set some flags at the parent
+                if ( createdEntry.hasParententry() )
                 {
-                    createdEntry.getParententry().setFetchSubentries( true );
+                    if ( createdEntry.isAlias() )
+                    {
+                        createdEntry.getParententry().setFetchAliases( true );
+                    }
+                    if ( createdEntry.isReferral() )
+                    {
+                        createdEntry.getParententry().setFetchReferrals( true );
+                    }
+                    if ( createdEntry.isSubentry() )
+                    {
+                        createdEntry.getParententry().setFetchSubentries( true );
+                    }
                 }
             }
         }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java?rev=828937&r1=828936&r2=828937&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java
Fri Oct 23 05:38:44 2009
@@ -190,10 +190,10 @@
                             }
                         }
                     }
-                }
 
-                // delete from cache
-                browserConnection.uncacheEntryRecursive( entryToDelete );
+                    // delete from cache
+                    browserConnection.uncacheEntryRecursive( entryToDelete );
+                }
             }
             else
             {

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java?rev=828937&r1=828936&r2=828937&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java
Fri Oct 23 05:38:44 2009
@@ -141,7 +141,7 @@
         renameEntry( browserConnection, oldEntry, newDn, dummyMonitor );
 
         // do a simulated rename, if renaming of a non-leaf entry is not supported.
-        if ( dummyMonitor.errorsReported() )
+        if ( dummyMonitor.errorsReported() && !monitor.isCanceled() )
         {
             if ( dialog != null && dummyMonitor.getException() instanceof ContextNotEmptyException
)
             {
@@ -182,7 +182,7 @@
         }
 
         // update model
-        if ( !monitor.errorsReported() )
+        if ( !monitor.errorsReported() && !monitor.isCanceled() )
         {
             // uncache old entry
             browserConnection.uncacheEntryRecursive( oldEntry );
@@ -191,13 +191,24 @@
             IEntry parent = oldEntry.getParententry();
             boolean hasMoreChildren = parent.hasMoreChildren();
             parent.deleteChild( oldEntry );
+
             List<StudioControl> controls = new ArrayList<StudioControl>();
             if ( oldEntry.isReferral() )
             {
                 controls.add( StudioControl.MANAGEDSAIT_CONTROL );
             }
-            newEntry = ReadEntryRunnable.getEntry( browserConnection, newDn, controls, monitor
);
-            parent.addChild( newEntry );
+
+            // 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

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java?rev=828937&r1=828936&r2=828937&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java
Fri Oct 23 05:38:44 2009
@@ -56,6 +56,11 @@
     public void run( StudioProgressMonitor monitor )
     {
         super.run( monitor );
+        if ( monitor.isCanceled() )
+        {
+            // update attributes in any case, because the attributes are not initialized
+            monitor.setCanceled( false );
+        }
         InitializeAttributesRunnable.initializeAttributes( entry, monitor );
     }
 



Mime
View raw message