directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r675885 - in /directory/studio/trunk: ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/ ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/
Date Fri, 11 Jul 2008 09:30:14 GMT
Author: seelmann
Date: Fri Jul 11 02:30:13 2008
New Revision: 675885

URL: http://svn.apache.org/viewvc?rev=675885&view=rev
Log:
Fix for DIRSTUDIO-273: Do a one-level search under the Root DSE if there is no namingContexts
attribute

Modified:
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/FetchBaseDNsRunnable.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesRunnable.java

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java?rev=675885&r1=675884&r2=675885&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
Fri Jul 11 02:30:13 2008
@@ -21,6 +21,8 @@
 package org.apache.directory.studio.ldapbrowser.common.widgets.connection;
 
 
+import java.util.List;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.studio.connection.core.Connection;
@@ -303,16 +305,16 @@
                 IStatus status = RunnableContextRunner.execute( runnable, runnableContext,
true );
                 if ( status.isOK() )
                 {
-                    if ( runnable.getBaseDNs().length > 0 )
+                    if ( !runnable.getBaseDNs().isEmpty() )
                     {
-                        String[] baseDNs = runnable.getBaseDNs();
-                        baseDNCombo.setItems( baseDNs );
+                        List<String> baseDNs = runnable.getBaseDNs();
+                        baseDNCombo.setItems( baseDNs.toArray( new String[baseDNs.size()]
) );
                         baseDNCombo.select( 0 );
 
                         String msg = "The server returned the following base DNs:";
-                        for ( int i = 0; i < baseDNs.length; i++ )
+                        for ( String baseDN : baseDNs )
                         {
-                            msg += "\n  - " + baseDNs[i];
+                            msg += "\n  - " + baseDN;
                         }
                         MessageDialog.openInformation( Display.getDefault().getActiveShell(),
"Fetch Base DNs", msg );
                     }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/FetchBaseDNsRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/FetchBaseDNsRunnable.java?rev=675885&r1=675884&r2=675885&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/FetchBaseDNsRunnable.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/FetchBaseDNsRunnable.java
Fri Jul 11 02:30:13 2008
@@ -21,13 +21,17 @@
 package org.apache.directory.studio.ldapbrowser.core.jobs;
 
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.jobs.StudioBulkRunnableWithProgress;
 import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
-import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.IRootDSE;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.DirectoryMetadataEntry;
 
 
 /**
@@ -41,7 +45,7 @@
 
     private IBrowserConnection connection;
 
-    private String[] baseDNs;
+    private List<String> baseDNs;
 
 
     /**
@@ -52,6 +56,7 @@
     public FetchBaseDNsRunnable( IBrowserConnection connection )
     {
         this.connection = connection;
+        this.baseDNs = new ArrayList<String>();
     }
 
 
@@ -94,19 +99,22 @@
 
         IRootDSE rootDSE = connection.getRootDSE();
         InitializeAttributesRunnable.initializeAttributes( rootDSE, true, monitor );
-        //        IEntry[] baseDNEntries = connection.getRootDSE().getChildren();
-        //        baseDNs = new String[baseDNEntries.length];
-        //        for ( int i = 0; i < baseDNs.length; i++ )
-        //        {
-        //            baseDNs[i] = baseDNEntries[i].getDn().toString();
-        //        }
 
-        IAttribute attribute = rootDSE.getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_NAMINGCONTEXTS
);
-        if ( attribute != null )
+        IEntry[] baseDNEntries = connection.getRootDSE().getChildren();
+        for ( IEntry baseDNEntry : baseDNEntries )
         {
-            baseDNs = attribute.getStringValues();
+            if ( !( baseDNEntry instanceof DirectoryMetadataEntry ) )
+            {
+                baseDNs.add( baseDNEntry.getDn().getUpName() );
+            }
         }
 
+//        IAttribute attribute = rootDSE.getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_NAMINGCONTEXTS
);
+//        if ( attribute != null )
+//        {
+//            baseDNs = attribute.getStringValues();
+//        }
+
         monitor.worked( 1 );
     }
 
@@ -125,12 +133,8 @@
      * 
      * @return the base DNs
      */
-    public String[] getBaseDNs()
+    public List<String> getBaseDNs()
     {
-        if ( baseDNs == null )
-        {
-            baseDNs = new String[0];
-        }
         return baseDNs;
     }
 

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesRunnable.java?rev=675885&r1=675884&r2=675885&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesRunnable.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesRunnable.java
Fri Jul 11 02:30:13 2008
@@ -325,41 +325,42 @@
                     namingContextSet.add( values[i] );
                 }
             }
-            for ( String namingContext : namingContextSet )
+            
+            if ( !namingContextSet.isEmpty() )
             {
-                if ( !"".equals( namingContext ) ) { //$NON-NLS-1$
-                    try
-                    {
-                        LdapDN dn = new LdapDN( namingContext );
-                        IEntry entry = browserConnection.getEntryFromCache( dn );
-                        if ( entry == null )
+                for ( String namingContext : namingContextSet )
+                {
+                    if ( !"".equals( namingContext ) ) { //$NON-NLS-1$
+                        try
                         {
-                            entry = new BaseDNEntry( dn, browserConnection );
-                            browserConnection.cacheEntry( entry );
+                            LdapDN dn = new LdapDN( namingContext );
+                            IEntry entry = browserConnection.getEntryFromCache( dn );
+                            if ( entry == null )
+                            {
+                                entry = new BaseDNEntry( dn, browserConnection );
+                                browserConnection.cacheEntry( entry );
+                            }
+                            rootDseEntries.put( dn, entry );
+                        }
+                        catch ( InvalidNameException e )
+                        {
+                            monitor.reportError( BrowserCoreMessages.model__error_setting_base_dn,
e );
                         }
-                        rootDseEntries.put( dn, entry );
-                    }
-                    catch ( InvalidNameException e )
-                    {
-                        monitor.reportError( BrowserCoreMessages.model__error_setting_base_dn,
e );
                     }
-                }
-                else
-                {
-                    // special handling of empty namingContext (Novell eDirectory): 
-                    // perform a one-level search and add all result DNs to the set
-                    search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE,
-                        ISearch.NO_ATTRIBUTES, SearchScope.ONELEVEL, 0, 0, Connection.AliasDereferencingMethod.NEVER,
-                        Connection.ReferralHandlingMethod.IGNORE, false, null );
-                    SearchRunnable.searchAndUpdateModel( browserConnection, search, monitor
);
-                    ISearchResult[] results = search.getSearchResults();
-                    for ( ISearchResult searchResult : results )
+                    else
                     {
-                        IEntry entry = searchResult.getEntry();
-                        rootDseEntries.put( entry.getDn(), entry );
+                        // special handling of empty namingContext (Novell eDirectory): 
+                        // perform a one-level search and add all result DNs to the set
+                        searchRootDseEntries( browserConnection, rootDseEntries, monitor
);
                     }
                 }
             }
+            else
+            {
+                // special handling of non-existing namingContexts attribute (Oracle Internet
Directory)
+                // perform a one-level search and add all result DNs to the set
+                searchRootDseEntries( browserConnection, rootDseEntries, monitor );
+            }
         }
 
         // 2nd: add schema sub-entry
@@ -465,4 +466,19 @@
         return metadataEntries;
     }
 
+
+    private static void searchRootDseEntries( IBrowserConnection browserConnection, Map<LdapDN,
IEntry> rootDseEntries,
+        StudioProgressMonitor monitor )
+    {
+        ISearch search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE,
+            ISearch.NO_ATTRIBUTES, SearchScope.ONELEVEL, 0, 0, Connection.AliasDereferencingMethod.NEVER,
+            Connection.ReferralHandlingMethod.IGNORE, false, null );
+        SearchRunnable.searchAndUpdateModel( browserConnection, search, monitor );
+        ISearchResult[] results = search.getSearchResults();
+        for ( ISearchResult searchResult : results )
+        {
+            IEntry entry = searchResult.getEntry();
+            rootDseEntries.put( entry.getDn(), entry );
+        }
+    }
 }



Mime
View raw message