directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r607915 [1/3] - in /directory/studio/trunk: studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/ studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ studio-ldapbrowser-commo...
Date Tue, 01 Jan 2008 21:07:50 GMT
Author: seelmann
Date: Tue Jan  1 13:07:48 2008
New Revision: 607915

URL: http://svn.apache.org/viewvc?rev=607915&view=rev
Log:
Fix for DIRSTUDIO-247, Moved enums AliasDereferencingMethod and ReferralHandlingMethod down to the connection-core plugin, Added 'manage' referrals handling, Removed Browser option 'Show alias and referral entries', Changed default options: always deref aliases, follow referrals, count limit 1000, Added constants for JNDI referral and alias handling

Modified:
    directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
    directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
    directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ReferralsInfo.java
    directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/BrowserPreferencePage.java
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserPreferences.java
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/AliasesDereferencingWidget.java
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReferralsHandlingWidget.java
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/SearchPageWrapper.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionIO.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCoreConstants.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CopyEntriesJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateEntryJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateValuesJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteAttributesValueJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportLdifJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeChildrenJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ModifyValueJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ReadEntryJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IBrowserConnection.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ISearch.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/SearchParameter.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/BrowserConnection.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyConnection.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/OpenBrowserConnectionsJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Search.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/JNDIUtils.java
    directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationApplyOnWizardPage.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java

Modified: directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/Connection.java?rev=607915&r1=607914&r2=607915&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/Connection.java (original)
+++ directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/Connection.java Tue Jan  1 13:07:48 2008
@@ -39,6 +39,135 @@
 public class Connection implements ConnectionPropertyPageProvider, IAdaptable
 {
 
+    /**
+     * Enum for alias dereferencing method.
+     * 
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    public static enum AliasDereferencingMethod
+    {
+    
+        /** Never. */
+        NEVER(0),
+    
+        /** Always. */
+        ALWAYS(1),
+    
+        /** Finding. */
+        FINDING(2),
+    
+        /** Search. */
+        SEARCH(3);
+    
+        private final int ordinal;
+    
+    
+        private AliasDereferencingMethod( int ordinal )
+        {
+            this.ordinal = ordinal;
+        }
+    
+    
+        /**
+         * Gets the ordinal.
+         * 
+         * @return the ordinal
+         */
+        public int getOrdinal()
+        {
+            return ordinal;
+        }
+    
+    
+        /**
+         * Gets the AliasDereferencingMethod by ordinal.
+         * 
+         * @param ordinal the ordinal
+         * 
+         * @return the AliasDereferencingMethod
+         */
+        public static AliasDereferencingMethod getByOrdinal( int ordinal )
+        {
+            switch ( ordinal )
+            {
+                case 0:
+                    return NEVER;
+                case 1:
+                    return ALWAYS;
+                case 2:
+                    return FINDING;
+                case 3:
+                    return SEARCH;
+                default:
+                    return null;
+            }
+        }
+    }
+
+
+    /**
+     * Enum for referral handling method.
+     * 
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    public static enum ReferralHandlingMethod
+    {
+    
+        /** Ignore. */
+        IGNORE(0),
+    
+        /** Follow. */
+        FOLLOW(1),
+    
+        /** Manage. */
+        MANAGE(2);
+    
+        private final int ordinal;
+    
+    
+        private ReferralHandlingMethod( int ordinal )
+        {
+            this.ordinal = ordinal;
+        }
+    
+    
+        /**
+         * Gets the ordinal.
+         * 
+         * @return the ordinal
+         */
+        public int getOrdinal()
+        {
+            return ordinal;
+        }
+    
+    
+        /**
+         * Gets the ReferralHandlingMethod by ordinal.
+         * 
+         * @param ordinal the ordinal
+         * 
+         * @return the ReferralHandlingMethod
+         */
+        public static ReferralHandlingMethod getByOrdinal( int ordinal )
+        {
+            switch ( ordinal )
+            {
+                case 0:
+                    return IGNORE;
+                case 1:
+                    return FOLLOW;
+                case 2:
+                    return MANAGE;
+                default:
+                    return null;
+            }
+        }
+    }
+
+
     private ConnectionParameter connectionParameter;
 
     private JNDIConnectionWrapper jndiConnectionWrapper;

Modified: directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java?rev=607915&r1=607914&r2=607915&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java (original)
+++ directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java Tue Jan  1 13:07:48 2008
@@ -39,6 +39,7 @@
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
 import javax.naming.ldap.LdapName;
+import javax.naming.ldap.ManageReferralControl;
 import javax.naming.ldap.StartTlsRequest;
 import javax.naming.ldap.StartTlsResponse;
 import javax.net.ssl.HostnameVerifier;
@@ -46,6 +47,8 @@
 
 import org.apache.directory.shared.ldap.codec.util.LdapURL;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.EmptyEnumeration;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
 import org.apache.directory.studio.connection.core.ConnectionParameter;
@@ -55,8 +58,11 @@
 import org.apache.directory.studio.connection.core.IReferralHandler;
 import org.apache.directory.studio.connection.core.Messages;
 import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
+import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
 import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
 import org.apache.directory.studio.connection.core.io.ConnectionWrapper;
+import org.apache.directory.studio.connection.core.io.jndi.ReferralsInfo.UrlAndDn;
 
 
 /**
@@ -67,12 +73,14 @@
  * - manages broken/closed connections
  * - delete old RDN
  * - exception handling 
+ * - referral handling
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
 public class JNDIConnectionWrapper implements ConnectionWrapper
 {
+
     private Connection connection;
 
     private boolean useLdaps;
@@ -97,13 +105,26 @@
 
     /** JNDI constant for "throw" referrals handling */
     public static final String REFERRAL_THROW = "throw";
-    
+
     /** JNDI constant for "follow" referrals handling */
     public static final String REFERRAL_FOLLOW = "follow";
 
     /** JNDI constant for "ignore" referrals handling */
     public static final String REFERRAL_IGNORE = "ignore";
-    
+
+    /** JNDI constant for "searching" alias dereferencing */
+    public static final String ALIAS_SEARCHING = "searching";
+
+    /** JNDI constant for "finding" alias dereferencing */
+    public static final String ALIAS_FINDING = "finding";
+
+    /** JNDI constant for "always" alias dereferencing */
+    public static final String ALIAS_ALWAYS = "always";
+
+    /** JNDI constant for "never" alias dereferencing */
+    public static final String ALIAS_NEVER = "never";
+
+
     /**
      * Creates a new instance of JNDIConnectionContext.
      * 
@@ -116,7 +137,7 @@
 
 
     /**
-     * @see org.apache.directory.studio.connection.core.io.ConnectionWrapper#connect(org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     * {@inheritDoc}
      */
     public void connect( StudioProgressMonitor monitor )
     {
@@ -137,7 +158,7 @@
 
 
     /**
-     * @see org.apache.directory.studio.connection.core.io.ConnectionWrapper#disconnect()
+     * {@inheritDoc}
      */
     public void disconnect()
     {
@@ -165,7 +186,7 @@
 
 
     /**
-     * @see org.apache.directory.studio.connection.core.io.ConnectionWrapper#bind(org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     * {@inheritDoc}
      */
     public void bind( StudioProgressMonitor monitor )
     {
@@ -182,7 +203,7 @@
 
 
     /**
-     * @see org.apache.directory.studio.connection.core.io.ConnectionWrapper#unbind()
+     * {@inheritDoc}
      */
     public void unbind()
     {
@@ -191,7 +212,7 @@
 
 
     /**
-     * @see org.apache.directory.studio.connection.core.io.ConnectionWrapper#isConnected()
+     * {@inheritDoc}
      */
     public boolean isConnected()
     {
@@ -214,27 +235,31 @@
      * @return the naming enumeration or null if an exception occurs.
      */
     public NamingEnumeration<SearchResult> search( final String searchBase, final String filter,
-        final SearchControls searchControls, final String aliasesDereferencingMethod, final String referralsHandlingMethod,
-        final Control[] controls, final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
+        final SearchControls searchControls, final AliasDereferencingMethod aliasesDereferencingMethod,
+        final ReferralHandlingMethod referralsHandlingMethod, final Control[] controls,
+        final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
         // start
         InnerRunnable runnable = new InnerRunnable()
         {
-            private NamingEnumeration<SearchResult> namingEnumeration = null;
-            private NamingException namingException = null;
-
-
             public void run()
             {
+                // add ManageDsaIT control
+                Control[] localControls = addManageDsaItControls( controls, referralsHandlingMethod );
+
                 try
                 {
-                    LdapContext searchCtx = context.newInstance( controls );
-                    searchCtx.addToEnvironment( "java.naming.ldap.derefAliases", aliasesDereferencingMethod ); //$NON-NLS-1$
-                    
-                    // use "throw" if referrals handling is set to "follow" as we handle referrals manually
-                    String localReferralsHandlingMethod = REFERRAL_FOLLOW.equals( referralsHandlingMethod ) ? REFERRAL_THROW : referralsHandlingMethod;
-                    searchCtx.addToEnvironment( Context.REFERRAL, localReferralsHandlingMethod );
+                    // create the search context
+                    LdapContext searchCtx = context.newInstance( localControls );
+
+                    // translate alias dereferencing method
+                    searchCtx.addToEnvironment(
+                        "java.naming.ldap.derefAliases", translateDerefAliasMethod( aliasesDereferencingMethod ) ); //$NON-NLS-1$
 
+                    // use "throw" as we handle referrals manually
+                    searchCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
+
+                    // perform the search
                     namingEnumeration = searchCtx.search( new LdapName( searchBase ), filter, searchControls );
                     namingEnumeration = new StudioNamingEnumeration( connection, namingEnumeration, searchBase, filter,
                         searchControls, aliasesDereferencingMethod, referralsHandlingMethod, controls, monitor,
@@ -242,30 +267,33 @@
                 }
                 catch ( PartialResultException pre )
                 {
-                    if ( REFERRAL_IGNORE.equals( referralsHandlingMethod ) )
-                    {
-                        // ignore
-                    }
-                    else
+                    // ignore exception if referrals handling method is IGNORE
+                    // report exception if referrals handling method is FOLLOW or MANGAGE
+                    if ( referralsHandlingMethod == ReferralHandlingMethod.FOLLOW
+                        || referralsHandlingMethod == ReferralHandlingMethod.MANAGE )
                     {
                         namingException = pre;
                     }
                 }
                 catch ( ReferralException re )
                 {
-                    if ( REFERRAL_IGNORE.equals( referralsHandlingMethod ) )
+                    // ignore exception if referrals handling method is IGNORE
+                    // report exception if referrals handling method is MANGAGE
+                    // follow referral if referrals handling method is FOLLOW
+                    if ( referralsHandlingMethod == ReferralHandlingMethod.MANAGE )
                     {
-                        // ignore
+                        namingException = re;
                     }
-                    else if ( REFERRAL_FOLLOW.equals( referralsHandlingMethod ) )
+                    else if ( referralsHandlingMethod == ReferralHandlingMethod.FOLLOW )
                     {
                         try
                         {
                             ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
-                            LdapURL url = newReferralsInfo.getNext();
-                            if ( url != null )
+                            UrlAndDn urlAndDn = newReferralsInfo.getNext();
+                            if ( urlAndDn != null )
                             {
-                                Connection referralConnection = getReferralConnection( url );
+                                LdapURL url = urlAndDn.getUrl();
+                                Connection referralConnection = getReferralConnection( url, monitor, this );
                                 if ( referralConnection != null )
                                 {
                                     String referralSearchBase = url.getDn() != null && !url.getDn().isEmpty() ? url
@@ -276,21 +304,15 @@
                                     SearchControls referralSearchControls = new SearchControls();
                                     referralSearchControls.setSearchScope( url.getScope() > -1 ? url.getScope()
                                         : searchControls.getSearchScope() );
-                                    referralSearchControls.setReturningAttributes( url.getAttributes() != null ? url
-                                        .getAttributes().toArray( new String[url.getAttributes().size()] )
-                                        : searchControls.getReturningAttributes() );
+                                    referralSearchControls.setReturningAttributes( url.getAttributes() != null
+                                        && url.getAttributes().size() > 0 ? url.getAttributes().toArray(
+                                        new String[url.getAttributes().size()] ) : searchControls
+                                        .getReturningAttributes() );
                                     referralSearchControls.setCountLimit( searchControls.getCountLimit() );
                                     referralSearchControls.setTimeLimit( searchControls.getTimeLimit() );
                                     referralSearchControls.setDerefLinkFlag( searchControls.getDerefLinkFlag() );
                                     referralSearchControls.setReturningObjFlag( searchControls.getReturningObjFlag() );
 
-                                    if ( referralConnection.getJNDIConnectionWrapper().isConnected() )
-                                    {
-                                        referralConnection.getJNDIConnectionWrapper().connect( monitor );
-                                        referralConnection.getJNDIConnectionWrapper().bind( monitor );
-                                        ConnectionEventRegistry.fireConnectionOpened( referralConnection, this );
-                                    }
-
                                     namingEnumeration = referralConnection.getJNDIConnectionWrapper().search(
                                         referralSearchBase, referralFilter, referralSearchControls,
                                         aliasesDereferencingMethod, referralsHandlingMethod, controls, monitor,
@@ -298,42 +320,18 @@
                                 }
                             }
                         }
-                        catch ( NamingException e )
+                        catch ( NamingException ne )
                         {
-                            // TODO Auto-generated catch block
-                            e.printStackTrace();
+                            namingException = ne;
                         }
                     }
-                    else
-                    {
-                        namingException = re;
-                    }
                 }
                 catch ( NamingException e )
                 {
+                    // report each other naming exception
                     namingException = e;
                 }
             }
-
-
-            public NamingException getException()
-            {
-                return namingException;
-            }
-
-
-            public NamingEnumeration<SearchResult> getResult()
-            {
-                return namingEnumeration;
-            }
-
-
-            public void reset()
-            {
-                namingEnumeration = null;
-                namingException = null;
-            }
-
         };
 
         try
@@ -357,112 +355,67 @@
         }
         else
         {
-            return null;
+            return new EmptyEnumeration<SearchResult>();
         }
     }
 
 
     /**
-     * Gets the referral connection from the given URL.
-     * 
-     * @param url the URL
-     * 
-     * @return the referral connection
-     */
-    static Connection getReferralConnection( LdapURL url )
-    {
-        Connection referralConnection = null;
-        IReferralHandler referralHandler = ConnectionCorePlugin.getDefault().getReferralHandler();
-        if ( referralHandler != null )
-        {
-            referralConnection = referralHandler.getReferralConnection( url );
-        }
-        return referralConnection;
-    }
-
-
-    /**
-     * Retrieves all referrals from the ReferralException and 
-     * creates or updates the ReferralsInfo.
-     * 
-     * @param referralException the referral exception
-     * @param initialReferralsInfo the initial referrals info, may be null
-     * 
-     * @return the created or updated referrals info
-     */
-    static ReferralsInfo handleReferralException( ReferralException referralException,
-        ReferralsInfo initialReferralsInfo ) throws NamingException
-    {
-        if ( initialReferralsInfo == null )
-        {
-            initialReferralsInfo = new ReferralsInfo();
-        }
-
-        try
-        {
-            initialReferralsInfo.addReferralUrl( new LdapURL( ( String ) referralException.getReferralInfo() ) );
-        }
-        catch ( LdapURLEncodingException e )
-        {
-        }
-
-        while ( referralException.skipReferral() )
-        {
-            try
-            {
-                Context ctx = referralException.getReferralContext();
-                ctx.list( "" ); //$NON-NLS-1$
-            }
-            catch ( NamingException ne )
-            {
-                if ( ne instanceof ReferralException )
-                {
-                    referralException = ( ReferralException ) ne;
-                    try
-                    {
-                        initialReferralsInfo.addReferralUrl( new LdapURL( ( String ) referralException
-                            .getReferralInfo() ) );
-                    }
-                    catch ( LdapURLEncodingException e )
-                    {
-                    }
-                }
-                else
-                {
-                    break;
-                }
-            }
-        }
-
-        return initialReferralsInfo;
-    }
-
-
-    /**
-     * Modify attributes.
+     * Modifies attributes of an entry.
      * 
      * @param dn the DN
      * @param modificationItems the modification items
+     * @param referralsHandlingMethod the referrals handling method
      * @param controls the controls
      * @param monitor the progress monitor
+     * @param referralsInfo the referrals info
      */
-    public void modifyAttributes( final String dn, final ModificationItem[] modificationItems,
-        final Control[] controls, final StudioProgressMonitor monitor )
+    public void modifyEntry( final String dn, final ModificationItem[] modificationItems,
+        final ReferralHandlingMethod referralsHandlingMethod, final Control[] controls,
+        final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
         InnerRunnable runnable = new InnerRunnable()
         {
-            private NamingException namingException = null;
-
-
             public void run()
             {
+                // add ManageDsaIT control
+                Control[] localControls = addManageDsaItControls( controls, referralsHandlingMethod );
+
                 try
                 {
-                    LdapContext modCtx = context.newInstance( controls );
-                    modCtx.addToEnvironment( Context.REFERRAL, "throw" ); //$NON-NLS-1$
+                    // create modify context
+                    LdapContext modCtx = context.newInstance( localControls );
+
+                    // use "throw" as we handle referrals manually
+                    modCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
 
+                    // perform modification
                     modCtx.modifyAttributes( new LdapName( dn ), modificationItems );
                 }
+                catch ( ReferralException re )
+                {
+                    try
+                    {
+                        ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
+                        UrlAndDn urlAndDn = newReferralsInfo.getNext();
+                        if ( urlAndDn != null )
+                        {
+                            Connection referralConnection = getReferralConnection( urlAndDn.getUrl(), monitor, this );
+                            if ( referralConnection != null )
+                            {
+                                String referralDn = urlAndDn.getDn() != null && !urlAndDn.getDn().isEmpty() ? urlAndDn
+                                    .getDn().getUpName() : dn;
+
+                                referralConnection.getJNDIConnectionWrapper().modifyEntry( referralDn,
+                                    modificationItems, referralsHandlingMethod, controls, monitor, newReferralsInfo );
+                            }
+                        }
+                    }
+                    catch ( NamingException ne )
+                    {
+                        namingException = ne;
+                    }
+                }
                 catch ( NamingException ne )
                 {
                     namingException = ne;
@@ -470,27 +423,9 @@
 
                 for ( IJndiLogger logger : getJndiLoggers() )
                 {
-                    logger.logChangetypeModify( connection, dn, modificationItems, controls, namingException );
+                    logger.logChangetypeModify( connection, dn, modificationItems, localControls, namingException );
                 }
             }
-
-
-            public NamingException getException()
-            {
-                return namingException;
-            }
-
-
-            public NamingEnumeration<SearchResult> getResult()
-            {
-                return null;
-            }
-
-
-            public void reset()
-            {
-                namingException = null;
-            }
         };
 
         try
@@ -512,27 +447,34 @@
     /**
      * Renames an entry.
      * 
-     * @param oldDn the old dn
-     * @param newDn the new dn
-     * @param deleteOldRdn the delete old rdn flag
+     * @param oldDn the old DN
+     * @param newDn the new DN
+     * @param deleteOldRdn true to delete the old RDN
+     * @param referralsHandlingMethod the referrals handling method
      * @param controls the controls
-     * @param monitor the monitor
+     * @param monitor the progress monitor
+     * @param referralsInfo the referrals info
      */
-    public void rename( final String oldDn, final String newDn, final boolean deleteOldRdn, final Control[] controls,
-        final StudioProgressMonitor monitor )
+    public void renameEntry( final String oldDn, final String newDn, final boolean deleteOldRdn,
+        final ReferralHandlingMethod referralsHandlingMethod, final Control[] controls,
+        final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
         InnerRunnable runnable = new InnerRunnable()
         {
-            private NamingException namingException = null;
-
-
             public void run()
             {
+                // add ManageDsaIT control
+                Control[] localControls = addManageDsaItControls( controls, referralsHandlingMethod );
+
                 try
                 {
-                    LdapContext modCtx = context.newInstance( controls );
-                    modCtx.addToEnvironment( Context.REFERRAL, "throw" ); //$NON-NLS-1$
+                    // create modify context
+                    LdapContext modCtx = context.newInstance( localControls );
+
+                    // use "throw" as we handle referrals manually
+                    modCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
 
+                    // delete old RDN
                     if ( deleteOldRdn )
                     {
                         modCtx.addToEnvironment( "java.naming.ldap.deleteRDN", "true" ); //$NON-NLS-1$ //$NON-NLS-2$
@@ -542,8 +484,33 @@
                         modCtx.addToEnvironment( "java.naming.ldap.deleteRDN", "false" ); //$NON-NLS-1$ //$NON-NLS-2$
                     }
 
+                    // rename entry
                     modCtx.rename( new LdapName( oldDn ), new LdapName( newDn ) );
                 }
+                catch ( ReferralException re )
+                {
+                    try
+                    {
+                        ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
+                        UrlAndDn urlAndDn = newReferralsInfo.getNext();
+                        if ( urlAndDn != null )
+                        {
+                            Connection referralConnection = getReferralConnection( urlAndDn.getUrl(), monitor, this );
+                            if ( referralConnection != null )
+                            {
+                                //                                String referralDn = url.getDn() != null && !url.getDn().isEmpty() ? url.getDn()
+                                //                                    .getUpName() : dn;
+                                // TODO: referral DN???
+                                referralConnection.getJNDIConnectionWrapper().renameEntry( oldDn, newDn, deleteOldRdn,
+                                    referralsHandlingMethod, controls, monitor, newReferralsInfo );
+                            }
+                        }
+                    }
+                    catch ( NamingException ne )
+                    {
+                        namingException = ne;
+                    }
+                }
                 catch ( NamingException ne )
                 {
                     namingException = ne;
@@ -551,27 +518,9 @@
 
                 for ( IJndiLogger logger : getJndiLoggers() )
                 {
-                    logger.logChangetypeModDn( connection, oldDn, newDn, deleteOldRdn, controls, namingException );
+                    logger.logChangetypeModDn( connection, oldDn, newDn, deleteOldRdn, localControls, namingException );
                 }
             }
-
-
-            public NamingException getException()
-            {
-                return namingException;
-            }
-
-
-            public NamingEnumeration<SearchResult> getResult()
-            {
-                return null;
-            }
-
-
-            public void reset()
-            {
-                namingException = null;
-            }
         };
 
         try
@@ -593,29 +542,59 @@
     /**
      * Creates an entry.
      * 
-     * @param dn the dn
-     * @param attributes the attributes
+     * @param dn the entry's DN
+     * @param attributes the entry's attributes
+     * @param referralsHandlingMethod the referrals handling method
      * @param controls the controls
-     * @param monitor the monitor
+     * @param monitor the progress monitor
+     * @param referralsInfo the referrals info
      */
-    public void createEntry( final String dn, final Attributes attributes, final Control[] controls,
-        final StudioProgressMonitor monitor )
+    public void createEntry( final String dn, final Attributes attributes,
+        final ReferralHandlingMethod referralsHandlingMethod, final Control[] controls,
+        final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
         InnerRunnable runnable = new InnerRunnable()
         {
-            private NamingException namingException = null;
-
-
             public void run()
             {
+                // add ManageDsaIT control
+                Control[] localControls = addManageDsaItControls( controls, referralsHandlingMethod );
 
                 try
                 {
-                    LdapContext modCtx = context.newInstance( controls );
-                    modCtx.addToEnvironment( Context.REFERRAL, "throw" ); //$NON-NLS-1$
+                    // create modify context
+                    LdapContext modCtx = context.newInstance( localControls );
 
+                    // use "throw" as we handle referrals manually
+                    modCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
+
+                    // create entry
                     modCtx.createSubcontext( new LdapName( dn ), attributes );
                 }
+                catch ( ReferralException re )
+                {
+                    try
+                    {
+                        ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
+                        UrlAndDn urlAndDn = newReferralsInfo.getNext();
+                        if ( urlAndDn != null )
+                        {
+                            Connection referralConnection = getReferralConnection( urlAndDn.getUrl(), monitor, this );
+                            if ( referralConnection != null )
+                            {
+                                String referralDn = urlAndDn.getDn() != null && !urlAndDn.getDn().isEmpty() ? urlAndDn
+                                    .getDn().getUpName() : dn;
+
+                                referralConnection.getJNDIConnectionWrapper().createEntry( referralDn, attributes,
+                                    referralsHandlingMethod, controls, monitor, newReferralsInfo );
+                            }
+                        }
+                    }
+                    catch ( NamingException ne )
+                    {
+                        namingException = ne;
+                    }
+                }
                 catch ( NamingException ne )
                 {
                     namingException = ne;
@@ -623,27 +602,9 @@
 
                 for ( IJndiLogger logger : getJndiLoggers() )
                 {
-                    logger.logChangetypeAdd( connection, dn, attributes, controls, namingException );
+                    logger.logChangetypeAdd( connection, dn, attributes, localControls, namingException );
                 }
             }
-
-
-            public NamingException getException()
-            {
-                return namingException;
-            }
-
-
-            public NamingEnumeration<SearchResult> getResult()
-            {
-                return null;
-            }
-
-
-            public void reset()
-            {
-                namingException = null;
-            }
         };
 
         try
@@ -665,26 +626,57 @@
     /**
      * Deletes an entry.
      * 
-     * @param dn the dn
+     * @param dn the DN of the entry to delete
+     * @param referralsHandlingMethod the referrals handling method
      * @param controls the controls
-     * @param monitor the monitor
+     * @param monitor the progress monitor
+     * @param referralsInfo the referrals info
      */
-    public void deleteEntry( final String dn, final Control[] controls, final StudioProgressMonitor monitor )
+    public void deleteEntry( final String dn, final ReferralHandlingMethod referralsHandlingMethod,
+        final Control[] controls, final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
         InnerRunnable runnable = new InnerRunnable()
         {
-            private NamingException namingException = null;
-
-
             public void run()
             {
+                // add ManageDsaIT control
+                Control[] localControls = addManageDsaItControls( controls, referralsHandlingMethod );
+
                 try
                 {
-                    LdapContext modCtx = context.newInstance( controls );
-                    modCtx.addToEnvironment( Context.REFERRAL, "throw" ); //$NON-NLS-1$
+                    // create modify context
+                    LdapContext modCtx = context.newInstance( localControls );
+
+                    // use "throw" as we handle referrals manually
+                    modCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
 
+                    // delete entry
                     modCtx.destroySubcontext( new LdapName( dn ) );
                 }
+                catch ( ReferralException re )
+                {
+                    try
+                    {
+                        ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
+                        UrlAndDn urlAndDn = newReferralsInfo.getNext();
+                        if ( urlAndDn != null )
+                        {
+                            Connection referralConnection = getReferralConnection( urlAndDn.getUrl(), monitor, this );
+                            if ( referralConnection != null )
+                            {
+                                String referralDn = urlAndDn.getDn() != null && !urlAndDn.getDn().isEmpty() ? urlAndDn
+                                    .getDn().getUpName() : dn;
+
+                                referralConnection.getJNDIConnectionWrapper().deleteEntry( referralDn,
+                                    referralsHandlingMethod, controls, monitor, newReferralsInfo );
+                            }
+                        }
+                    }
+                    catch ( NamingException ne )
+                    {
+                        namingException = ne;
+                    }
+                }
                 catch ( NamingException ne )
                 {
                     namingException = ne;
@@ -692,27 +684,9 @@
 
                 for ( IJndiLogger logger : getJndiLoggers() )
                 {
-                    logger.logChangetypeDelete( connection, dn, controls, namingException );
+                    logger.logChangetypeDelete( connection, dn, localControls, namingException );
                 }
             }
-
-
-            public NamingException getException()
-            {
-                return namingException;
-            }
-
-
-            public NamingEnumeration<SearchResult> getResult()
-            {
-                return null;
-            }
-
-
-            public void reset()
-            {
-                namingException = null;
-            }
         };
 
         try
@@ -769,9 +743,6 @@
 
         InnerRunnable runnable = new InnerRunnable()
         {
-            private NamingException namingException = null;
-
-
             public void run()
             {
                 try
@@ -808,24 +779,6 @@
                     namingException = ne;
                 }
             }
-
-
-            public NamingException getException()
-            {
-                return namingException;
-            }
-
-
-            public NamingEnumeration<SearchResult> getResult()
-            {
-                return null;
-            }
-
-
-            public void reset()
-            {
-                namingException = null;
-            }
         };
 
         runAndMonitor( runnable, monitor );
@@ -885,9 +838,6 @@
 
             InnerRunnable runnable = new InnerRunnable()
             {
-                private NamingException namingException = null;
-
-
                 public void run()
                 {
                     try
@@ -912,24 +862,6 @@
                         namingException = ne;
                     }
                 }
-
-
-                public NamingException getException()
-                {
-                    return namingException;
-                }
-
-
-                public NamingEnumeration<SearchResult> getResult()
-                {
-                    return null;
-                }
-
-
-                public void reset()
-                {
-                    namingException = null;
-                }
             };
 
             runAndMonitor( runnable, monitor );
@@ -1056,15 +988,21 @@
         }
     }
 
-    interface InnerRunnable extends Runnable
+    abstract class InnerRunnable implements Runnable
     {
+        protected NamingEnumeration<SearchResult> namingEnumeration = null;
+        protected NamingException namingException = null;
+
 
         /**
          * Gets the exception.
          * 
          * @return the exception
          */
-        NamingException getException();
+        public NamingException getException()
+        {
+            return namingException;
+        }
 
 
         /**
@@ -1072,17 +1010,194 @@
          * 
          * @return the result
          */
-        NamingEnumeration<SearchResult> getResult();
+        public NamingEnumeration<SearchResult> getResult()
+        {
+            return namingEnumeration;
+        }
 
 
         /**
          * Reset.
          */
-        void reset();
+        public void reset()
+        {
+            namingEnumeration = null;
+            namingException = null;
+        }
     }
 
+
     private List<IJndiLogger> getJndiLoggers()
     {
         return ConnectionCorePlugin.getDefault().getJndiLoggers();
     }
+
+
+    /**
+     * Translates the alias dereferencing method to its JNDI specific string.
+     * 
+     * @param aliasDereferencingMethod the alias dereferencing method
+     * 
+     * @return the JNDI specific alias dereferencing method string
+     */
+    private String translateDerefAliasMethod( AliasDereferencingMethod aliasDereferencingMethod )
+    {
+        String m = ALIAS_ALWAYS; //$NON-NLS-1$
+
+        switch ( aliasDereferencingMethod )
+        {
+            case NEVER:
+                m = ALIAS_NEVER; //$NON-NLS-1$
+                break;
+            case ALWAYS:
+                m = ALIAS_ALWAYS; //$NON-NLS-1$
+                break;
+            case FINDING:
+                m = ALIAS_FINDING; //$NON-NLS-1$
+                break;
+            case SEARCH:
+                m = ALIAS_SEARCHING; //$NON-NLS-1$
+                break;
+        }
+
+        return m;
+    }
+
+
+    /**
+     * Adds the ManageDsaIT controls if the referrals handling method is MANAGE and 
+     * if the current controls don't contain the ManageDsaIT control.
+     * 
+     * @param currentControls the current controls
+     * @param referralsHandlingMethod the referrals handling method
+     * 
+     * @return the new controls
+     */
+    private Control[] addManageDsaItControls( final Control[] currentControls,
+        final ReferralHandlingMethod referralsHandlingMethod )
+    {
+        Control[] localControls = currentControls;
+        if ( referralsHandlingMethod == ReferralHandlingMethod.MANAGE )
+        {
+            if ( currentControls == null )
+            {
+                localControls = new Control[]
+                    { new ManageReferralControl( false ) };
+            }
+            else
+            {
+                boolean manageDsaItControlAlreadyContained = false;
+                for ( Control control : currentControls )
+                {
+                    if ( ManageReferralControl.OID.equals( control.getID() ) )
+                    {
+                        manageDsaItControlAlreadyContained = true;
+                        break;
+                    }
+                }
+                if ( !manageDsaItControlAlreadyContained )
+                {
+                    localControls = new Control[currentControls.length + 1];
+                    System.arraycopy( currentControls, 0, localControls, 0, currentControls.length );
+                    localControls[localControls.length - 1] = new ManageReferralControl( false );
+                }
+            }
+        }
+        return localControls;
+    }
+
+
+    /**
+     * Gets the referral connection from the given URL.
+     * 
+     * @param url the URL
+     * @param monitor the progress monitor
+     * @param source the source
+     * 
+     * @return the referral connection
+     */
+    static Connection getReferralConnection( LdapURL url, StudioProgressMonitor monitor, Object source )
+    {
+        Connection referralConnection = null;
+        IReferralHandler referralHandler = ConnectionCorePlugin.getDefault().getReferralHandler();
+        if ( referralHandler != null )
+        {
+            referralConnection = referralHandler.getReferralConnection( url );
+
+            if ( referralConnection != null && !referralConnection.getJNDIConnectionWrapper().isConnected() )
+            {
+                referralConnection.getJNDIConnectionWrapper().connect( monitor );
+                referralConnection.getJNDIConnectionWrapper().bind( monitor );
+                ConnectionEventRegistry.fireConnectionOpened( referralConnection, source );
+            }
+        }
+        return referralConnection;
+    }
+
+
+    /**
+     * Retrieves all referrals from the ReferralException and
+     * creates or updates the ReferralsInfo.
+     * 
+     * @param referralException the referral exception
+     * @param initialReferralsInfo the initial referrals info, may be null
+     * 
+     * @return the created or updated referrals info
+     * 
+     * @throws NamingException if a loop was encountered.
+     */
+    static ReferralsInfo handleReferralException( ReferralException referralException,
+        ReferralsInfo initialReferralsInfo ) throws NamingException
+    {
+        if ( initialReferralsInfo == null )
+        {
+            initialReferralsInfo = new ReferralsInfo();
+        }
+
+        try
+        {
+            String info = ( String ) referralException.getReferralInfo();
+            String name = referralException.getRemainingName().toString();
+            LdapURL url = new LdapURL( info );
+            LdapDN dn = new LdapDN( name );
+            initialReferralsInfo.addReferralUrl( url, dn );
+        }
+        catch ( LdapURLEncodingException e )
+        {
+        }
+
+        while ( referralException.skipReferral() )
+        {
+            try
+            {
+                Context ctx = referralException.getReferralContext();
+                ctx.list( "" ); //$NON-NLS-1$
+            }
+            catch ( NamingException ne )
+            {
+                if ( ne instanceof ReferralException )
+                {
+                    referralException = ( ReferralException ) ne;
+                    try
+                    {
+                        String info = ( String ) referralException.getReferralInfo();
+                        String name = referralException.getRemainingName().toString();
+                        LdapURL url = new LdapURL( info );
+                        LdapDN dn = new LdapDN( name );
+                        initialReferralsInfo.addReferralUrl( url, dn );
+                    }
+                    catch ( LdapURLEncodingException e )
+                    {
+                    }
+                }
+                else
+                {
+                    break;
+                }
+            }
+        }
+
+        return initialReferralsInfo;
+    }
+
 }

Modified: directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ReferralsInfo.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ReferralsInfo.java?rev=607915&r1=607914&r2=607915&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ReferralsInfo.java (original)
+++ directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ReferralsInfo.java Tue Jan  1 13:07:48 2008
@@ -24,9 +24,9 @@
 import java.util.List;
 
 import javax.naming.LinkLoopException;
-import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.codec.util.LdapURL;
+import org.apache.directory.shared.ldap.name.LdapDN;
 
 
 /**
@@ -38,9 +38,9 @@
  */
 public class ReferralsInfo
 {
-    private List<LdapURL> referralsToProcess;
+    private List<UrlAndDn> referralsToProcess;
 
-    private List<LdapURL> processedReferrals;
+    private List<UrlAndDn> processedReferrals;
 
 
     /**
@@ -49,30 +49,32 @@
      */
     public ReferralsInfo()
     {
-        this.referralsToProcess = new ArrayList<LdapURL>();
-        this.processedReferrals = new ArrayList<LdapURL>();
+        this.referralsToProcess = new ArrayList<UrlAndDn>();
+        this.processedReferrals = new ArrayList<UrlAndDn>();
     }
 
 
     /**
-     * Adds the referral URL to the list of referrals to be processed.
+     * Adds the referral URL and DN to the list of referrals to be processed.
      * 
      * If the URL is already in the list or if the URL was already processed
      * a NamingException will be thrown
      * 
      * @param url the URL
+     * @param dn the DN
      * 
-     * @throws NamingException the naming exception
+     * @throws LinkLoopException if a loop was encountered.
      */
-    public void addReferralUrl( LdapURL url ) throws NamingException
+    public void addReferralUrl( LdapURL url, LdapDN dn ) throws LinkLoopException
     {
-        if ( !referralsToProcess.contains( url ) && !processedReferrals.contains( url ) )
+        UrlAndDn urlAndDn = new UrlAndDn( url, dn );
+        if ( !referralsToProcess.contains( urlAndDn ) && !processedReferrals.contains( urlAndDn ) )
         {
-            referralsToProcess.add( url );
+            referralsToProcess.add( urlAndDn );
         }
         else
         {
-            throw new LinkLoopException( "Loop detected: " + url.toString() );
+            throw new LinkLoopException( "Loop detected while following referral: " + urlAndDn.toString() );
         }
     }
 
@@ -82,18 +84,107 @@
      * 
      * @return the next referral URL or null
      */
-    public LdapURL getNext()
+    public UrlAndDn getNext()
     {
         if ( !referralsToProcess.isEmpty() )
         {
-            LdapURL url = referralsToProcess.remove( 0 );
-            processedReferrals.add( url );
-            return url;
+            UrlAndDn urlAndDn = referralsToProcess.remove( 0 );
+            processedReferrals.add( urlAndDn );
+            return urlAndDn;
         }
         else
         {
             return null;
         }
+    }
+
+    /**
+     * Container for an LDAP URL and an LDAP DN.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    class UrlAndDn
+    {
+        private LdapURL url;
+        private LdapDN dn;
+
+
+        /**
+         * Creates a new instance of UrlAndDn.
+         *
+         * @param url the URL, never null
+         * @param dn the DN, never null
+         */
+        private UrlAndDn( LdapURL url, LdapDN dn )
+        {
+            if ( url == null )
+            {
+                throw new IllegalArgumentException( "URL may not be null" );
+            }
+            if ( dn == null )
+            {
+                throw new IllegalArgumentException( "DN may not be null" );
+            }
+            this.url = url;
+            this.dn = dn;
+        }
+
+
+        /**
+         * Gets the URL.
+         * 
+         * @return the URL
+         */
+        public LdapURL getUrl()
+        {
+            return url;
+        }
+
+
+        /**
+         * Gets the DN.
+         * 
+         * @return the DN
+         */
+        public LdapDN getDn()
+        {
+            return dn;
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public int hashCode()
+        {
+            // dn and url are never null
+            int h = 37;
+            h = h * 17 + url.hashCode();
+            h = h * 17 + dn.hashCode();
+            return h;
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public boolean equals( Object obj )
+        {
+            // dn and url are never null
+            if ( this == obj )
+            {
+                return true;
+            }
+            if ( !( obj instanceof UrlAndDn ) )
+            {
+                return false;
+            }
+
+            UrlAndDn other = ( UrlAndDn ) obj;
+            return dn.equals( other.dn ) && url.equals( other.url );
+        }
+
     }
 
 }

Modified: directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java?rev=607915&r1=607914&r2=607915&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java (original)
+++ directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java Tue Jan  1 13:07:48 2008
@@ -31,7 +31,9 @@
 import org.apache.directory.shared.ldap.codec.util.LdapURL;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.StudioProgressMonitor;
-import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
+import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
+import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
+import org.apache.directory.studio.connection.core.io.jndi.ReferralsInfo.UrlAndDn;
 
 
 /**
@@ -48,8 +50,8 @@
     private String searchBase;
     private String filter;
     private SearchControls searchControls;
-    private String aliasesDereferencingMethod;
-    private String referralsHandlingMethod;
+    private AliasDereferencingMethod aliasesDereferencingMethod;
+    private ReferralHandlingMethod referralsHandlingMethod;
     private Control[] controls;
     private StudioProgressMonitor monitor;
     private ReferralsInfo referralsInfo;
@@ -70,8 +72,9 @@
      * @param referralsInfo the referrals info
      */
     public StudioNamingEnumeration( Connection connection, NamingEnumeration<SearchResult> delegate, String searchBase,
-        String filter, SearchControls searchControls, String aliasesDereferencingMethod,
-        String referralsHandlingMethod, Control[] controls, StudioProgressMonitor monitor, ReferralsInfo referralsInfo )
+        String filter, SearchControls searchControls, AliasDereferencingMethod aliasesDereferencingMethod,
+        ReferralHandlingMethod referralsHandlingMethod, Control[] controls, StudioProgressMonitor monitor,
+        ReferralsInfo referralsInfo )
     {
         this.connection = connection;
         this.delegate = delegate;
@@ -105,13 +108,14 @@
         {
             try
             {
-                return delegate.hasMore();
+                return delegate != null && delegate.hasMore();
             }
             catch ( PartialResultException pre )
             {
-                if ( JNDIConnectionWrapper.REFERRAL_IGNORE.equals( referralsHandlingMethod ) )
+                // ignore exception if referrals handling method is IGNORE
+                // report exception if referrals handling method is FOLLOW or MANGAGE
+                if ( referralsHandlingMethod == ReferralHandlingMethod.IGNORE )
                 {
-                    // ignore
                     return false;
                 }
                 else
@@ -121,18 +125,22 @@
             }
             catch ( ReferralException re )
             {
-                if ( JNDIConnectionWrapper.REFERRAL_IGNORE.equals( referralsHandlingMethod ) )
+                // ignore exception if referrals handling method is IGNORE
+                // report exception if referrals handling method is MANGAGE
+                // follow referral if referrals handling method is FOLLOW
+                if ( referralsHandlingMethod == ReferralHandlingMethod.IGNORE )
                 {
-                    // ignore
                     return false;
                 }
-                else if ( JNDIConnectionWrapper.REFERRAL_FOLLOW.equals( referralsHandlingMethod ) )
+                else if ( referralsHandlingMethod == ReferralHandlingMethod.FOLLOW )
                 {
                     referralsInfo = JNDIConnectionWrapper.handleReferralException( re, referralsInfo );
-                    LdapURL url = referralsInfo.getNext();
-                    if ( url != null )
+                    UrlAndDn urlAndDn = referralsInfo.getNext();
+                    if ( urlAndDn != null )
                     {
-                        Connection referralConnection = JNDIConnectionWrapper.getReferralConnection( url );
+                        LdapURL url = urlAndDn.getUrl();
+                        Connection referralConnection = JNDIConnectionWrapper
+                            .getReferralConnection( url, monitor, this );
                         if ( referralConnection != null )
                         {
                             String referralSearchBase = url.getDn() != null && !url.getDn().isEmpty() ? url.getDn()
@@ -142,20 +150,13 @@
                             SearchControls referralSearchControls = new SearchControls();
                             referralSearchControls.setSearchScope( url.getScope() > -1 ? url.getScope()
                                 : searchControls.getSearchScope() );
-                            referralSearchControls.setReturningAttributes( url.getAttributes() != null ? url
-                                .getAttributes().toArray( new String[url.getAttributes().size()] ) : searchControls
-                                .getReturningAttributes() );
+                            referralSearchControls.setReturningAttributes( url.getAttributes() != null
+                                && url.getAttributes().size() > 0 ? url.getAttributes().toArray(
+                                new String[url.getAttributes().size()] ) : searchControls.getReturningAttributes() );
                             referralSearchControls.setCountLimit( searchControls.getCountLimit() );
                             referralSearchControls.setTimeLimit( searchControls.getTimeLimit() );
                             referralSearchControls.setDerefLinkFlag( searchControls.getDerefLinkFlag() );
                             referralSearchControls.setReturningObjFlag( searchControls.getReturningObjFlag() );
-
-                            if ( referralConnection.getJNDIConnectionWrapper().isConnected() )
-                            {
-                                referralConnection.getJNDIConnectionWrapper().connect( monitor );
-                                referralConnection.getJNDIConnectionWrapper().bind( monitor );
-                                ConnectionEventRegistry.fireConnectionOpened( referralConnection, this );
-                            }
 
                             delegate = referralConnection.getJNDIConnectionWrapper().search( referralSearchBase,
                                 referralFilter, referralSearchControls, aliasesDereferencingMethod,

Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/BrowserPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/BrowserPreferencePage.java?rev=607915&r1=607914&r2=607915&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/BrowserPreferencePage.java (original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/BrowserPreferencePage.java Tue Jan  1 13:07:48 2008
@@ -75,8 +75,6 @@
 
     private Button checkForChildrenButton;
 
-    private Button showAliasAndReferralObjectsButton;
-
     private Button fetchSubentriesButton;
 
 
@@ -238,10 +236,6 @@
         checkForChildrenButton = BaseWidgetUtils.createCheckbox( composite, "Check for children", 1 );
         checkForChildrenButton
             .setSelection( coreStore.getBoolean( BrowserCoreConstants.PREFERENCE_CHECK_FOR_CHILDREN ) );
-        showAliasAndReferralObjectsButton = BaseWidgetUtils.createCheckbox( composite,
-            "Show alias and referral objects", 1 );
-        showAliasAndReferralObjectsButton.setSelection( coreStore
-            .getBoolean( BrowserCoreConstants.PREFERENCE_SHOW_ALIAS_AND_REFERRAL_OBJECTS ) );
         fetchSubentriesButton = BaseWidgetUtils.createCheckbox( composite,
             "Fetch subentries (requires additional search request)", 1 );
         fetchSubentriesButton.setSelection( coreStore.getBoolean( BrowserCoreConstants.PREFERENCE_FETCH_SUBENTRIES ) );
@@ -269,8 +263,6 @@
         Preferences coreStore = BrowserCorePlugin.getDefault().getPluginPreferences();
         coreStore.setValue( BrowserCoreConstants.PREFERENCE_CHECK_FOR_CHILDREN, this.checkForChildrenButton
             .getSelection() );
-        coreStore.setValue( BrowserCoreConstants.PREFERENCE_SHOW_ALIAS_AND_REFERRAL_OBJECTS,
-            this.showAliasAndReferralObjectsButton.getSelection() );
         coreStore
             .setValue( BrowserCoreConstants.PREFERENCE_FETCH_SUBENTRIES, this.fetchSubentriesButton.getSelection() );
         BrowserCorePlugin.getDefault().savePluginPreferences();
@@ -337,8 +329,6 @@
         Preferences coreStore = BrowserCorePlugin.getDefault().getPluginPreferences();
         checkForChildrenButton.setSelection( coreStore
             .getDefaultBoolean( BrowserCoreConstants.PREFERENCE_CHECK_FOR_CHILDREN ) );
-        showAliasAndReferralObjectsButton.setSelection( coreStore
-            .getDefaultBoolean( BrowserCoreConstants.PREFERENCE_SHOW_ALIAS_AND_REFERRAL_OBJECTS ) );
         fetchSubentriesButton.setSelection( coreStore
             .getDefaultBoolean( BrowserCoreConstants.PREFERENCE_FETCH_SUBENTRIES ) );
 

Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java?rev=607915&r1=607914&r2=607915&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java (original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java Tue Jan  1 13:07:48 2008
@@ -29,8 +29,6 @@
 import java.util.Map;
 
 import org.apache.directory.studio.connection.core.jobs.OpenConnectionsJob;
-import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
-import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
 import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeChildrenJob;
 import org.apache.directory.studio.ldapbrowser.core.jobs.SearchJob;
 import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
@@ -455,10 +453,7 @@
         if ( parent instanceof IEntry )
         {
             IEntry parentEntry = ( IEntry ) parent;
-            return parentEntry.hasChildren()
-                || ( BrowserCorePlugin.getDefault().getPluginPreferences().getBoolean(
-                    BrowserCoreConstants.PREFERENCE_SHOW_ALIAS_AND_REFERRAL_OBJECTS ) && ( parentEntry.isAlias() || parentEntry
-                    .isReferral() ) );
+            return parentEntry.hasChildren();
         }
         else if ( parent instanceof BrowserEntryPage )
         {

Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java?rev=607915&r1=607914&r2=607915&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java (original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java Tue Jan  1 13:07:48 2008
@@ -324,11 +324,11 @@
         {
             return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_BROWSER_SCHEMABROWSEREDITOR );
         }
-        else if ( preferences.isDerefAliasesAndReferralsWhileBrowsing() && entry.isAlias() )
+        else if ( entry.isAlias() )
         {
             return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_ENTRY_ALIAS );
         }
-        else if ( preferences.isDerefAliasesAndReferralsWhileBrowsing() && entry.isReferral() )
+        else if ( entry.isReferral() )
         {
             return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_ENTRY_REF );
         }

Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserPreferences.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserPreferences.java?rev=607915&r1=607914&r2=607915&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserPreferences.java (original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserPreferences.java Tue Jan  1 13:07:48 2008
@@ -310,19 +310,6 @@
 
 
     /**
-     * Returns true if the browser should dereference aliases and referrals.
-     * 
-     *
-     * @return true if the browser should dereference aliases and referrals
-     */
-    public boolean isDerefAliasesAndReferralsWhileBrowsing()
-    {
-        Preferences coreStore = BrowserCorePlugin.getDefault().getPluginPreferences();
-        return coreStore.getBoolean( BrowserCoreConstants.PREFERENCE_SHOW_ALIAS_AND_REFERRAL_OBJECTS );
-    }
-
-
-    /**
      * Returns true if subentries should be fetched while browsing.
      * 
      *

Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java?rev=607915&r1=607914&r2=607915&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java (original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java Tue Jan  1 13:07:48 2008
@@ -32,8 +32,6 @@
 import org.apache.directory.studio.ldapbrowser.common.widgets.search.ReferralsHandlingWidget;
 import org.apache.directory.studio.ldapbrowser.core.jobs.FetchBaseDNsJob;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
-import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.AliasDereferencingMethod;
-import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.ReferralHandlingMethod;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.BrowserConnection;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.swt.SWT;
@@ -136,7 +134,7 @@
      * 
      * @return the aliases dereferencing method
      */
-    private AliasDereferencingMethod getAliasesDereferencingMethod()
+    private Connection.AliasDereferencingMethod getAliasesDereferencingMethod()
     {
         return aliasesDereferencingWidget.getAliasesDereferencingMethod();
     }
@@ -147,7 +145,7 @@
      * 
      * @return the referrals handling method
      */
-    private ReferralHandlingMethod getReferralsHandlingMethod()
+    private Connection.ReferralHandlingMethod getReferralsHandlingMethod()
     {
         return referralsHandlingWidget.getReferralsHandlingMethod();
     }
@@ -214,13 +212,13 @@
     {
         Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
 
-        limitWidget = new LimitWidget();
+        limitWidget = new LimitWidget( 1000, 0 );
         limitWidget.createWidget( composite );
 
-        aliasesDereferencingWidget = new AliasesDereferencingWidget();
+        aliasesDereferencingWidget = new AliasesDereferencingWidget( Connection.AliasDereferencingMethod.ALWAYS );
         aliasesDereferencingWidget.createWidget( composite );
 
-        referralsHandlingWidget = new ReferralsHandlingWidget();
+        referralsHandlingWidget = new ReferralsHandlingWidget( Connection.ReferralHandlingMethod.FOLLOW );
         referralsHandlingWidget.createWidget( composite );
     }
 
@@ -276,13 +274,13 @@
 
         int referralsHandlingMethodOrdinal = parameter
             .getExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
-        ReferralHandlingMethod referralsHandlingMethod = ReferralHandlingMethod
+        Connection.ReferralHandlingMethod referralsHandlingMethod = Connection.ReferralHandlingMethod
             .getByOrdinal( referralsHandlingMethodOrdinal );
         referralsHandlingWidget.setReferralsHandlingMethod( referralsHandlingMethod );
 
         int aliasesDereferencingMethodOrdinal = parameter
             .getExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_ALIASES_DEREFERENCING_METHOD );
-        AliasDereferencingMethod aliasesDereferencingMethod = AliasDereferencingMethod
+        Connection.AliasDereferencingMethod aliasesDereferencingMethod = Connection.AliasDereferencingMethod
             .getByOrdinal( aliasesDereferencingMethodOrdinal );
         aliasesDereferencingWidget.setAliasesDereferencingMethod( aliasesDereferencingMethod );
 
@@ -391,19 +389,8 @@
         int countLimit = connectionParameter
             .getExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_COUNT_LIMIT );
         int timeLimit = connectionParameter.getExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_TIME_LIMIT );
-        int referralsHandlingMethodOrdinal = connectionParameter
-            .getExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
-        ReferralHandlingMethod referralsHandlingMethod = ReferralHandlingMethod
-            .getByOrdinal( referralsHandlingMethodOrdinal );
-        int aliasesDereferencingMethodOrdinal = connectionParameter
-            .getExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_ALIASES_DEREFERENCING_METHOD );
-        AliasDereferencingMethod aliasesDereferencingMethod = AliasDereferencingMethod
-            .getByOrdinal( aliasesDereferencingMethodOrdinal );
-        aliasesDereferencingWidget.setAliasesDereferencingMethod( aliasesDereferencingMethod );
 
-        return isReconnectionRequired() || countLimit != getCountLimit() || timeLimit != getTimeLimit()
-            || referralsHandlingMethod != getReferralsHandlingMethod()
-            || aliasesDereferencingMethod != getAliasesDereferencingMethod();
+        return isReconnectionRequired() || countLimit != getCountLimit() || timeLimit != getTimeLimit();
     }
 
 
@@ -420,9 +407,20 @@
         boolean fetchBaseDns = connectionParameter
             .getExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_FETCH_BASE_DNS );
         String baseDn = connectionParameter.getExtendedProperty( IBrowserConnection.CONNECTION_PARAMETER_BASE_DN );
+        int referralsHandlingMethodOrdinal = connectionParameter
+            .getExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
+        Connection.ReferralHandlingMethod referralsHandlingMethod = Connection.ReferralHandlingMethod
+            .getByOrdinal( referralsHandlingMethodOrdinal );
+        int aliasesDereferencingMethodOrdinal = connectionParameter
+            .getExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_ALIASES_DEREFERENCING_METHOD );
+        Connection.AliasDereferencingMethod aliasesDereferencingMethod = Connection.AliasDereferencingMethod
+            .getByOrdinal( aliasesDereferencingMethodOrdinal );
+
         return fetchBaseDns != isAutoFetchBaseDns() || ( baseDn == null && getBaseDN() != null )
             || ( baseDn != null && getBaseDN() == null )
-            || ( baseDn != getBaseDN() && !( baseDn.equals( getBaseDN() ) ) );
+            || ( baseDn != getBaseDN() && !( baseDn.equals( getBaseDN() ) ) )
+            || referralsHandlingMethod != getReferralsHandlingMethod()
+            || aliasesDereferencingMethod != getAliasesDereferencingMethod();
     }
 
 }

Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/AliasesDereferencingWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/AliasesDereferencingWidget.java?rev=607915&r1=607914&r2=607915&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/AliasesDereferencingWidget.java (original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/AliasesDereferencingWidget.java Tue Jan  1 13:07:48 2008
@@ -21,9 +21,9 @@
 package org.apache.directory.studio.ldapbrowser.common.widgets.search;
 
 
+import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.ldapbrowser.common.widgets.BrowserWidget;
-import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.AliasDereferencingMethod;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.widgets.Button;
@@ -43,7 +43,7 @@
 {
 
     /** The initial aliases dereferencing method */
-    private AliasDereferencingMethod initialAliasesDereferencingMethod;
+    private Connection.AliasDereferencingMethod initialAliasesDereferencingMethod;
 
     /** The group. */
     private Group group;
@@ -61,7 +61,7 @@
      * 
      * @param initialAliasesDereferencingMethod the initial aliases dereferencing method
      */
-    public AliasesDereferencingWidget( AliasDereferencingMethod initialAliasesDereferencingMethod )
+    public AliasesDereferencingWidget( Connection.AliasDereferencingMethod initialAliasesDereferencingMethod )
     {
         this.initialAliasesDereferencingMethod = initialAliasesDereferencingMethod;
     }
@@ -69,11 +69,11 @@
 
     /**
      * Creates a new instance of AliasesDereferencingWidget. The initial 
-     * dereferencing method is set to {@link AliasDereferencingMethod.NEVER}.
+     * dereferencing method is set to {@link Connection.AliasDereferencingMethod.ALWAYS}.
      */
     public AliasesDereferencingWidget()
     {
-        this.initialAliasesDereferencingMethod = AliasDereferencingMethod.NEVER;
+        this.initialAliasesDereferencingMethod = Connection.AliasDereferencingMethod.ALWAYS;
     }
 
 
@@ -115,13 +115,13 @@
      * 
      * @param aliasesDereferencingMethod the aliases dereferencing method
      */
-    public void setAliasesDereferencingMethod( AliasDereferencingMethod aliasesDereferencingMethod )
+    public void setAliasesDereferencingMethod( Connection.AliasDereferencingMethod aliasesDereferencingMethod )
     {
         initialAliasesDereferencingMethod = aliasesDereferencingMethod;
-        findingButton.setSelection( initialAliasesDereferencingMethod == AliasDereferencingMethod.FINDING
-            || initialAliasesDereferencingMethod == AliasDereferencingMethod.ALWAYS );
-        searchButton.setSelection( initialAliasesDereferencingMethod == AliasDereferencingMethod.SEARCH
-            || initialAliasesDereferencingMethod == AliasDereferencingMethod.ALWAYS );
+        findingButton.setSelection( initialAliasesDereferencingMethod == Connection.AliasDereferencingMethod.FINDING
+            || initialAliasesDereferencingMethod == Connection.AliasDereferencingMethod.ALWAYS );
+        searchButton.setSelection( initialAliasesDereferencingMethod == Connection.AliasDereferencingMethod.SEARCH
+            || initialAliasesDereferencingMethod == Connection.AliasDereferencingMethod.ALWAYS );
     }
 
 
@@ -130,23 +130,23 @@
      * 
      * @return the aliases dereferencing method
      */
-    public AliasDereferencingMethod getAliasesDereferencingMethod()
+    public Connection.AliasDereferencingMethod getAliasesDereferencingMethod()
     {
         if ( findingButton.getSelection() && searchButton.getSelection() )
         {
-            return AliasDereferencingMethod.ALWAYS;
+            return Connection.AliasDereferencingMethod.ALWAYS;
         }
         else if ( findingButton.getSelection() )
         {
-            return AliasDereferencingMethod.FINDING;
+            return Connection.AliasDereferencingMethod.FINDING;
         }
         else if ( searchButton.getSelection() )
         {
-            return AliasDereferencingMethod.SEARCH;
+            return Connection.AliasDereferencingMethod.SEARCH;
         }
         else
         {
-            return AliasDereferencingMethod.NEVER;
+            return Connection.AliasDereferencingMethod.NEVER;
         }
     }
 

Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReferralsHandlingWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReferralsHandlingWidget.java?rev=607915&r1=607914&r2=607915&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReferralsHandlingWidget.java (original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReferralsHandlingWidget.java Tue Jan  1 13:07:48 2008
@@ -21,9 +21,9 @@
 package org.apache.directory.studio.ldapbrowser.common.widgets.search;
 
 
+import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.ldapbrowser.common.widgets.BrowserWidget;
-import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.ReferralHandlingMethod;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.widgets.Button;
@@ -43,17 +43,20 @@
 {
 
     /** The initial referrals handling method. */
-    private ReferralHandlingMethod initialReferralsHandlingMethod;
+    private Connection.ReferralHandlingMethod initialReferralsHandlingMethod;
 
     /** The group. */
     private Group group;
+    
+    /** The follow button. */
+    private Button followButton;
 
     /** The ignore button. */
     private Button ignoreButton;
 
-    /** The follow button. */
-    private Button followButton;
-
+    /** The manage button. */
+    private Button manageButton;
+    
 
     /**
      * Creates a new instance of ReferralsHandlingWidget with the given
@@ -61,7 +64,7 @@
      * 
      * @param initialReferralsHandlingMethod the initial referrals handling method
      */
-    public ReferralsHandlingWidget( ReferralHandlingMethod initialReferralsHandlingMethod )
+    public ReferralsHandlingWidget( Connection.ReferralHandlingMethod initialReferralsHandlingMethod )
     {
         this.initialReferralsHandlingMethod = initialReferralsHandlingMethod;
     }
@@ -69,11 +72,11 @@
 
     /**
      * Creates a new instance of ReferralsHandlingWidget with initial 
-     * referrals handling method {@link ReferralHandlingMethod.IGNORE}.
+     * referrals handling method {@link Connection.ReferralHandlingMethod.FOLLOW}.
      */
     public ReferralsHandlingWidget()
     {
-        this.initialReferralsHandlingMethod = ReferralHandlingMethod.IGNORE;
+        this.initialReferralsHandlingMethod = Connection.ReferralHandlingMethod.FOLLOW;
     }
 
 
@@ -84,9 +87,17 @@
      */
     public void createWidget( Composite parent )
     {
-
         group = BaseWidgetUtils.createGroup( parent, "Referrals Handling", 1 );
         Composite groupComposite = BaseWidgetUtils.createColumnContainer( group, 1, 1 );
+        
+        followButton = BaseWidgetUtils.createRadiobutton( groupComposite, "Follow", 1 );
+        followButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                notifyListeners();
+            }
+        } );
 
         ignoreButton = BaseWidgetUtils.createRadiobutton( groupComposite, "Ignore", 1 );
         ignoreButton.addSelectionListener( new SelectionAdapter()
@@ -96,9 +107,9 @@
                 notifyListeners();
             }
         } );
-
-        followButton = BaseWidgetUtils.createRadiobutton( groupComposite, "Follow", 1 );
-        followButton.addSelectionListener( new SelectionAdapter()
+        
+        manageButton = BaseWidgetUtils.createRadiobutton( groupComposite, "Manage", 1 );
+        manageButton.addSelectionListener( new SelectionAdapter()
         {
             public void widgetSelected( SelectionEvent e )
             {
@@ -115,11 +126,12 @@
      * 
      * @param referralsHandlingMethod the referrals handling method
      */
-    public void setReferralsHandlingMethod( ReferralHandlingMethod referralsHandlingMethod )
+    public void setReferralsHandlingMethod( Connection.ReferralHandlingMethod referralsHandlingMethod )
     {
         initialReferralsHandlingMethod = referralsHandlingMethod;
-        ignoreButton.setSelection( initialReferralsHandlingMethod == ReferralHandlingMethod.IGNORE );
-        followButton.setSelection( initialReferralsHandlingMethod == ReferralHandlingMethod.FOLLOW );
+        followButton.setSelection( initialReferralsHandlingMethod == Connection.ReferralHandlingMethod.FOLLOW );
+        ignoreButton.setSelection( initialReferralsHandlingMethod == Connection.ReferralHandlingMethod.IGNORE );
+        manageButton.setSelection( initialReferralsHandlingMethod == Connection.ReferralHandlingMethod.MANAGE );
     }
 
 
@@ -128,15 +140,19 @@
      * 
      * @return the referrals handling method
      */
-    public ReferralHandlingMethod getReferralsHandlingMethod()
+    public Connection.ReferralHandlingMethod getReferralsHandlingMethod()
     {
         if ( ignoreButton.getSelection() )
         {
-            return ReferralHandlingMethod.IGNORE;
+            return Connection.ReferralHandlingMethod.IGNORE;
+        }
+        else if ( manageButton.getSelection() )
+        {
+            return Connection.ReferralHandlingMethod.MANAGE;
         }
         else
         {
-            return ReferralHandlingMethod.FOLLOW;
+            return Connection.ReferralHandlingMethod.FOLLOW;
         }
     }
 
@@ -149,8 +165,9 @@
     public void setEnabled( boolean b )
     {
         group.setEnabled( b );
-        ignoreButton.setEnabled( b );
         followButton.setEnabled( b );
+        ignoreButton.setEnabled( b );
+        manageButton.setEnabled( b );
     }
 
 }



Mime
View raw message