directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r594711 - in /directory/studio/trunk: studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ studio-ldapbrowser-core...
Date Tue, 13 Nov 2007 23:31:59 GMT
Author: seelmann
Date: Tue Nov 13 15:31:58 2007
New Revision: 594711

URL: http://svn.apache.org/viewvc?rev=594711&view=rev
Log:
Fixed some referral issues (DIRSTUDIO-197, DIRSTUDIO-233, DIRSTUDIO-184)

Modified:
    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-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/SearchJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeDescription.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/JNDIUtils.java

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=594711&r1=594710&r2=594711&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 Nov 13 15:31:58 2007
@@ -260,41 +260,50 @@
                     }
                     else if ( REFERRAL_FOLLOW.equals( referralsHandlingMethod ) )
                     {
-                        ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo
);
-                        LdapURL url = newReferralsInfo.getNext();
-                        if ( url != null )
+                        try
                         {
-                            Connection referralConnection = getReferralConnection( url );
-                            if ( referralConnection != null )
+                            ReferralsInfo newReferralsInfo = handleReferralException( re,
referralsInfo );
+                            LdapURL url = newReferralsInfo.getNext();
+                            if ( url != null )
                             {
-                                String referralSearchBase = url.getDn() != null &&
!url.getDn().isEmpty() ? url.getDn()
-                                    .getUpName() : searchBase;
-                                String referralFilter = url.getFilter() != null &&
url.getFilter().length() == 0 ? url
-                                    .getFilter() : filter;
-                                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.setCountLimit( searchControls.getCountLimit()
);
-                                referralSearchControls.setTimeLimit( searchControls.getTimeLimit()
);
-                                referralSearchControls.setDerefLinkFlag( searchControls.getDerefLinkFlag()
);
-                                referralSearchControls.setReturningObjFlag( searchControls.getReturningObjFlag()
);
-    
-                                if ( referralConnection.getJNDIConnectionWrapper().isConnected()
)
+                                Connection referralConnection = getReferralConnection( url
);
+                                if ( referralConnection != null )
                                 {
-                                    referralConnection.getJNDIConnectionWrapper().connect(
monitor );
-                                    referralConnection.getJNDIConnectionWrapper().bind( monitor
);
-                                    ConnectionEventRegistry.fireConnectionOpened( referralConnection,
this );
+                                    String referralSearchBase = url.getDn() != null &&
!url.getDn().isEmpty() ? url
+                                        .getDn().getUpName() : searchBase;
+                                    String referralFilter = url.getFilter() != null &&
url.getFilter().length() == 0 ? url
+                                        .getFilter()
+                                        : filter;
+                                    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.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,
+                                        newReferralsInfo );
                                 }
-                                
-                                namingEnumeration = referralConnection.getJNDIConnectionWrapper().search(
-                                    referralSearchBase, referralFilter, referralSearchControls,
-                                    aliasesDereferencingMethod, referralsHandlingMethod,
controls, monitor,
-                                    newReferralsInfo );
                             }
                         }
+                        catch ( NamingException e )
+                        {
+                            // TODO Auto-generated catch block
+                            e.printStackTrace();
+                        }
                     }
                     else
                     {
@@ -343,7 +352,7 @@
             monitor.reportError( runnable.getException().getMessage(), runnable.getException()
);
             return null;
         }
-        else if ( runnable.getResult() != null && runnable.getResult() instanceof
NamingEnumeration )
+        else if ( runnable.getResult() != null )
         {
             return runnable.getResult();
         }
@@ -383,7 +392,7 @@
      * @return the created or updated referrals info
      */
     static ReferralsInfo handleReferralException( ReferralException referralException,
-        ReferralsInfo initialReferralsInfo )
+        ReferralsInfo initialReferralsInfo ) throws NamingException
     {
         if ( initialReferralsInfo == null )
         {

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=594711&r1=594710&r2=594711&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 Nov 13 15:31:58 2007
@@ -23,6 +23,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.naming.LinkLoopException;
+import javax.naming.NamingException;
+
 import org.apache.directory.shared.ldap.codec.util.LdapURL;
 
 
@@ -53,15 +56,23 @@
 
     /**
      * Adds the referral URL to the list of referrals to be processed.
-     * If the URL is already
+     * 
+     * If the URL is already in the list or if the URL was already processed
+     * a NamingException will be thrown
      * 
      * @param url the URL
+     * 
+     * @throws NamingException the naming exception
      */
-    public void addReferralUrl( LdapURL url )
+    public void addReferralUrl( LdapURL url ) throws NamingException
     {
         if ( !referralsToProcess.contains( url ) && !processedReferrals.contains(
url ) )
         {
             referralsToProcess.add( url );
+        }
+        else
+        {
+            throw new LinkLoopException( "Loop detected: " + url.toString() );
         }
     }
 

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesJob.java?rev=594711&r1=594710&r2=594711&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesJob.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesJob.java
Tue Nov 13 15:31:58 2007
@@ -23,9 +23,11 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import javax.naming.InvalidNameException;
@@ -33,7 +35,9 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
 import org.apache.directory.studio.ldapbrowser.core.events.AttributesInitializedEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
@@ -246,38 +250,42 @@
     {
         // delete old children
         IEntry[] oldChildren = browserConnection.getRootDSE().getChildren();
-        for ( int i = 0; oldChildren != null && i < oldChildren.length; i++ )
+        if(oldChildren != null)
         {
-            if ( oldChildren[i] != null )
+            for ( IEntry entry : oldChildren )
             {
-                browserConnection.getRootDSE().deleteChild( oldChildren[i] );
+                if ( entry != null )
+                {
+                    browserConnection.getRootDSE().deleteChild( entry );
+                }
             }
         }
         browserConnection.getRootDSE().setChildrenInitialized( false );
 
-        // get well-known root DSE attributes, includes + and *
+        // load well-known Root DSE attributes, includes + and *
         ISearch search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE,
             InitializeAttributesJob.ROOT_DSE_ATTRIBUTES, SearchScope.OBJECT, 0, 0,
             AliasDereferencingMethod.NEVER, ReferralHandlingMethod.IGNORE, false, false,
             null );
         SearchJob.searchAndUpdateModel( browserConnection, search, monitor );
 
-        // get base DNs
+        // the list of entries under the Root DSE
+        Map<LdapDN, IEntry> rootDseEntries = new HashMap<LdapDN, IEntry>();
+        
+        // 1st: add base DNs, either the specified or from the namingContexts attribute
         if( !browserConnection.isFetchBaseDNs() && browserConnection.getBaseDN()
!= null && !"".equals( browserConnection.getBaseDN().toString() ))
         {
+            // only add the specified base DN
             try
             {
-                // only add the specified base DN
                 LdapDN dn = browserConnection.getBaseDN();
-                IEntry entry = new BaseDNEntry( new LdapDN( dn ), browserConnection );
-                browserConnection.cacheEntry( entry );
-                browserConnection.getRootDSE().addChild( entry );
-                
-                // check if entry exists
-                // TODO: use browserConnection.getEntry( dn, monitor ) ??
-                search = new Search( null, browserConnection, dn, ISearch.FILTER_TRUE, ISearch.NO_ATTRIBUTES,
SearchScope.OBJECT, 1, 0,
-                    AliasDereferencingMethod.NEVER, ReferralHandlingMethod.IGNORE, true,
true, null );
-                SearchJob.searchAndUpdateModel( browserConnection, search, monitor );
+                IEntry entry = browserConnection.getEntryFromCache( dn );
+                if(entry == null)
+                {
+                    entry = new BaseDNEntry( new LdapDN( dn ), browserConnection );
+                    browserConnection.cacheEntry( entry );
+                }
+                rootDseEntries.put( dn, entry );
             }
             catch ( InvalidNameException e )
             {
@@ -286,7 +294,7 @@
         }
         else
         {
-            // get naming contexts 
+            // get base DNs from namingContexts attribute
             Set<String> namingContextSet = new HashSet<String>();
             IAttribute attribute = browserConnection.getRootDSE().getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_NAMINGCONTEXTS
);
             if ( attribute != null )
@@ -302,9 +310,14 @@
                 if ( !"".equals( namingContext ) ) { //$NON-NLS-1$
                     try
                     {
-                        IEntry entry = new BaseDNEntry( new LdapDN( namingContext ), browserConnection
);
-                        browserConnection.getRootDSE().addChild( entry );
-                        browserConnection.cacheEntry( entry );
+                        LdapDN dn = new LdapDN( namingContext );
+                        IEntry entry = browserConnection.getEntryFromCache( dn );
+                        if(entry == null)
+                        {
+                            entry = new BaseDNEntry( new LdapDN( dn ), browserConnection
);
+                            browserConnection.cacheEntry( entry );
+                        }
+                        rootDseEntries.put( dn, entry );
                     }
                     catch ( InvalidNameException e )
                     {
@@ -313,43 +326,65 @@
                 }
                 else
                 {
-                    // special handling of empty namingContext: perform a one-level search
and add all result DNs to the set
+                    // 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, AliasDereferencingMethod.NEVER, ReferralHandlingMethod.IGNORE,
false, false, null );
                     SearchJob.searchAndUpdateModel( browserConnection, search, monitor );
                     ISearchResult[] results = search.getSearchResults();
-                    for ( int k = 0; results != null && k < results.length; k++
)
+                    for ( ISearchResult searchResult : results )
                     {
-                        ISearchResult result = results[k];
-                        IEntry entry = result.getEntry();
-                        browserConnection.getRootDSE().addChild( entry );
+                        IEntry entry = searchResult.getEntry();
+                        rootDseEntries.put( entry.getDn(), entry );
                     }
                 }
             }
         }
 
-        // get schema sub-entry
-        DirectoryMetadataEntry[] schemaEntries = getDirectoryMetadataEntries( browserConnection,
IRootDSE.ROOTDSE_ATTRIBUTE_SUBSCHEMASUBENTRY );
-        for ( int i = 0; i < schemaEntries.length; i++ )
+        // 2nd: add schema sub-entry
+        IEntry[] schemaEntries = getDirectoryMetadataEntries( browserConnection,
+            IRootDSE.ROOTDSE_ATTRIBUTE_SUBSCHEMASUBENTRY );
+        for ( IEntry entry : schemaEntries )
         {
-            schemaEntries[i].setSchemaEntry( true );
-            browserConnection.getRootDSE().addChild( ( IEntry ) schemaEntries[i] );
+            if ( entry instanceof DirectoryMetadataEntry )
+            {
+                ( ( DirectoryMetadataEntry ) entry ).setSchemaEntry( true );
+            }
+            rootDseEntries.put( entry.getDn(), entry );
         }
         
-        // get other metadata entries
-        // TODO: check all attributes if they are valid DNs
-        String[] metadataAttributeNames = new String[]
-            { IRootDSE.ROOTDSE_ATTRIBUTE_MONITORCONTEXT, IRootDSE.ROOTDSE_ATTRIBUTE_CONFIGCONTEXT,
-                IRootDSE.ROOTDSE_ATTRIBUTE_DSANAME };
-        for ( int x = 0; x < metadataAttributeNames.length; x++ )
+        // get other meta data entries
+        IAttribute[] rootDseAttributes = browserConnection.getRootDSE().getAttributes();
+        for ( IAttribute attribute : rootDseAttributes )
         {
-            DirectoryMetadataEntry[] metadataEntries = getDirectoryMetadataEntries( browserConnection,
metadataAttributeNames[x] );
-            for ( int i = 0; i < metadataEntries.length; i++ )
+            IEntry[] metadataEntries = getDirectoryMetadataEntries( browserConnection, attribute.getDescription()
);
+            for ( IEntry entry : metadataEntries )
             {
-                browserConnection.getRootDSE().addChild( ( IEntry ) metadataEntries[i] );
+                rootDseEntries.put( entry.getDn(), entry );
             }
         }
         
+//        // TODO: check all attributes if they are valid DNs
+//        String[] metadataAttributeNames = new String[]
+//            { IRootDSE.ROOTDSE_ATTRIBUTE_MONITORCONTEXT, IRootDSE.ROOTDSE_ATTRIBUTE_CONFIGCONTEXT,
+//                IRootDSE.ROOTDSE_ATTRIBUTE_DSANAME };
+//        for ( int x = 0; x < metadataAttributeNames.length; x++ )
+//        {
+//            IEntry[] metadataEntries = getDirectoryMetadataEntries( browserConnection,
metadataAttributeNames[x] );
+//            for ( int i = 0; i < metadataEntries.length; i++ )
+//            {
+//                rootDseEntries.add( metadataEntries[i] );
+//            }
+//        }
+        
+        // try to init entries
+        StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );
+        for ( IEntry entry : rootDseEntries.values() )
+        {
+            initBaseEntry( entry.getBrowserConnection(), entry.getDn(), dummyMonitor );
+            // TODO: log if a base entry doesn't exist
+        }
+        
         // set flags
         browserConnection.getRootDSE().setHasMoreChildren( false );
         browserConnection.getRootDSE().setAttributesInitialized( true );
@@ -359,32 +394,71 @@
     }
 
 
-    private static DirectoryMetadataEntry[] getDirectoryMetadataEntries( IBrowserConnection
browserConnection, String metadataAttributeName )
+    private static void initBaseEntry( IBrowserConnection browserConnection, LdapDN dn, StudioProgressMonitor
monitor )
     {
-        List<LdapDN> metadataEntryList = new ArrayList<LdapDN>();
+        ISearch search;
+        IEntry entry;
+        // search the entry
+        AliasDereferencingMethod derefAliasMethod = browserConnection.getAliasesDereferencingMethod();
+        ReferralHandlingMethod handleReferralsMethod = browserConnection.getReferralsHandlingMethod();
+        if ( BrowserCorePlugin.getDefault().getPluginPreferences().getBoolean(
+            BrowserCoreConstants.PREFERENCE_SHOW_ALIAS_AND_REFERRAL_OBJECTS )
+            && browserConnection.getRootDSE().isControlSupported(
+                IBrowserConnection.CONTROL_MANAGEDSAIT ) )
+        {
+            derefAliasMethod = AliasDereferencingMethod.NEVER;
+            handleReferralsMethod = ReferralHandlingMethod.IGNORE;
+        }
+        search = new Search( null, browserConnection, dn, ISearch.FILTER_TRUE, ISearch.NO_ATTRIBUTES,
SearchScope.OBJECT, 1, 0,
+            derefAliasMethod, handleReferralsMethod, true, true, null );
+        SearchJob.searchAndUpdateModel( browserConnection, search, monitor );
+        
+        // add entry to Root DSE
+        ISearchResult[] results = search.getSearchResults();
+        if(results != null && results.length == 1)
+        {
+            ISearchResult result = results[0];
+            entry = result.getEntry();
+            browserConnection.getRootDSE().addChild( entry );
+        }
+    }
+
+
+    private static IEntry[] getDirectoryMetadataEntries( IBrowserConnection browserConnection,
String metadataAttributeName )
+    {
+        List<LdapDN> metadataEntryDnList = new ArrayList<LdapDN>();
         IAttribute attribute = browserConnection.getRootDSE().getAttribute( metadataAttributeName
);
         if ( attribute != null )
         {
             String[] values = attribute.getStringValues();
-            for ( int i = 0; i < values.length; i++ )
+            for ( String dn : values )
             {
-                try
-                {
-                    metadataEntryList.add( new LdapDN( values[i] ) );
-                }
-                catch ( InvalidNameException e )
+                if( dn != null && !"".equals( dn ))
                 {
+                    try
+                    {
+                        metadataEntryDnList.add( new LdapDN( dn ) );
+                    }
+                    catch ( InvalidNameException e )
+                    {
+                    }
                 }
             }
         }
 
-        DirectoryMetadataEntry[] metadataEntries = new DirectoryMetadataEntry[metadataEntryList.size()];
-        for ( int i = 0; i < metadataEntryList.size(); i++ )
+        IEntry[] metadataEntries = new IEntry[metadataEntryDnList.size()];
+        for ( int i = 0; i < metadataEntryDnList.size(); i++ )
         {
-            metadataEntries[i] = new DirectoryMetadataEntry( metadataEntryList.get( i ),
browserConnection );
-            metadataEntries[i].setDirectoryEntry( true );
-            browserConnection.cacheEntry( metadataEntries[i] );
+            LdapDN dn = metadataEntryDnList.get( i );
+            metadataEntries[i] = browserConnection.getEntryFromCache( dn );
+            if(metadataEntries[i] == null)
+            {
+                metadataEntries[i] = new DirectoryMetadataEntry( dn, browserConnection );
+                metadataEntries[i].setDirectoryEntry( true );
+                browserConnection.cacheEntry( metadataEntries[i] );
+            }
         }
         return metadataEntries;
     }
+
 }

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeChildrenJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeChildrenJob.java?rev=594711&r1=594710&r2=594711&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeChildrenJob.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeChildrenJob.java
Tue Nov 13 15:31:58 2007
@@ -42,7 +42,6 @@
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.ReferralHandlingMethod;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.AliasBaseEntry;
-import org.apache.directory.studio.ldapbrowser.core.model.impl.ReferralBaseEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.Search;
 
 
@@ -223,15 +222,7 @@
 
                 for ( int i = 0; srs != null && i < srs.length; i++ )
                 {
-                    if ( parent.isReferral() )
-                    {
-                        ReferralBaseEntry referralBaseEntry = new ReferralBaseEntry( srs[i].getEntry().getBrowserConnection(),
-                            srs[i].getEntry().getDn() );
-                        parent.addChild( referralBaseEntry );
-                        // System.out.println("Ref: " +
-                        // referralBaseEntry.getUrl());
-                    }
-                    else if ( parent.isAlias() )
+                    if ( parent.isAlias() && !( srs[i].getEntry() instanceof AliasBaseEntry
) )
                     {
                         AliasBaseEntry aliasBaseEntry = new AliasBaseEntry( srs[i].getEntry().getBrowserConnection(),
srs[i]
                             .getEntry().getDn() );

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java?rev=594711&r1=594710&r2=594711&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java
Tue Nov 13 15:31:58 2007
@@ -195,25 +195,32 @@
                     NamingEnumeration<SearchResult> enumeration = search( browserConnection,
searchParameter, monitor );
 
                     // iterate through the search result
-                    while ( !monitor.isCanceled() && enumeration.hasMore() )
+                    while ( !monitor.isCanceled() && enumeration != null &&
enumeration.hasMore() )
                     {
                         SearchResult sr = enumeration.next();
                         LdapDN dn = JNDIUtils.getDn( sr );
                         boolean isReferral = false;
+                        IBrowserConnection resultBrowserConnection = browserConnection;
                         if ( sr instanceof StudioSearchResult )
                         {
                             StudioSearchResult ssr = ( StudioSearchResult ) sr;
+                            
                             isReferral = ssr.isReferral();
+                            
                             Connection connection = ssr.getConnection();
-                            browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
+                            IBrowserConnection bc = BrowserCorePlugin.getDefault().getConnectionManager()
                                 .getBrowserConnection( connection );
+                            if( bc != null )
+                            {
+                                resultBrowserConnection = bc;
+                            }
                         }
 
                         // get entry from cache or create it
-                        IEntry entry = browserConnection.getEntryFromCache( dn );
+                        IEntry entry = resultBrowserConnection.getEntryFromCache( dn );
                         if ( entry == null )
                         {
-                            entry = createAndCacheEntry( browserConnection, dn );
+                            entry = createAndCacheEntry( resultBrowserConnection, dn );
                         }
                         
                         // initialize special flags
@@ -221,10 +228,10 @@
 
                         // fill the attributes
                         fillAttributes( entry, sr, search.getSearchParameter() );
-
-                        if(isReferral)
+                        
+                        if ( isReferral  )
                         {
-                            entry = new ReferralBaseEntry( browserConnection, dn );
+                            entry = new ReferralBaseEntry( resultBrowserConnection, dn );
                         }
                         
                         searchResultList.add( new org.apache.directory.studio.ldapbrowser.core.model.impl.SearchResult(

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeDescription.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeDescription.java?rev=594711&r1=594710&r2=594711&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeDescription.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeDescription.java
Tue Nov 13 15:31:58 2007
@@ -88,8 +88,9 @@
         this.parsedAttributeType = attributeDescriptionComponents[0];
         this.parsedLangList = new ArrayList<String>();
         this.parsedOptionList = new ArrayList<String>();
-        for ( String component : attributeDescriptionComponents )
+        for ( int i = 1; i < attributeDescriptionComponents.length; i++ )
         {
+            String component = attributeDescriptionComponents[i];
             if ( component.startsWith( IAttribute.OPTION_LANG_PREFIX ) )
             {
                 this.parsedLangList.add( component );

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java?rev=594711&r1=594710&r2=594711&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java
Tue Nov 13 15:31:58 2007
@@ -778,4 +778,21 @@
         return null;
     }
 
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean equals( Object o )
+    {
+        // check argument
+        if ( o == null || !( o instanceof IEntry ) )
+        {
+            return false;
+        }
+        IEntry e = ( IEntry ) o;
+
+        // compare dn and connection
+        return getDn() == null ? e.getDn() == null : ( getDn().equals( e.getDn() ) &&
getBrowserConnection().equals(
+            e.getBrowserConnection() ) );
+    }
 }

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/JNDIUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/JNDIUtils.java?rev=594711&r1=594710&r2=594711&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/JNDIUtils.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/JNDIUtils.java
Tue Nov 13 15:31:58 2007
@@ -93,6 +93,9 @@
      */
     public static ConnectionException createConnectionException( SearchParameter searchParameter,
Throwable e )
     {
+    	// TODO: remove when improving error handling
+        e.printStackTrace();
+        
         ConnectionException connectionException = null;
         ConnectionException lastException = null;
 



Mime
View raw message