directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1211426 - /directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java
Date Wed, 07 Dec 2011 13:17:56 GMT
Author: pamarcelot
Date: Wed Dec  7 13:17:55 2011
New Revision: 1211426

URL: http://svn.apache.org/viewvc?rev=1211426&view=rev
Log:
Fix for DIRSTUDIO-716 (Error while opening connection : NPE)

Modified:
    directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java

Modified: directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java?rev=1211426&r1=1211425&r2=1211426&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java
Wed Dec  7 13:17:55 2011
@@ -458,7 +458,7 @@ public class SearchRunnable implements S
         String searchBase = parameter.getSearchBase().getName();
         SearchControls controls = new SearchControls();
         SearchScope scope = parameter.getScope();
-        
+
         switch ( scope )
         {
             case OBJECT:
@@ -473,7 +473,7 @@ public class SearchRunnable implements S
             default:
                 controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         }
-        
+
         controls.setReturningAttributes( parameter.getReturningAttributes() );
         controls.setCountLimit( parameter.getCountLimit() );
         int timeLimit = parameter.getTimeLimit() * 1000;
@@ -614,9 +614,9 @@ public class SearchRunnable implements S
         // build tree to parent
         LinkedList<Dn> parentDnList = new LinkedList<Dn>();
         Dn parentDn = dn;
-        while ( parentDn != null && browserConnection.getEntryFromCache(parentDn)
== null )
+        while ( parentDn != null && browserConnection.getEntryFromCache( parentDn
) == null )
         {
-            parentDnList.addFirst(parentDn);
+            parentDnList.addFirst( parentDn );
             parentDn = parentDn.getParent();
         }
 
@@ -628,10 +628,10 @@ public class SearchRunnable implements S
                 // only the root DSE has a null parent
                 entry = browserConnection.getRootDSE();
             }
-            else if ( !parentDn.isEmpty() && browserConnection.getEntryFromCache(parentDn)
!= null )
+            else if ( !parentDn.isEmpty() && browserConnection.getEntryFromCache(
parentDn ) != null )
             {
                 // a normal entry has a parent but the parent isn't the rootDSE
-                IEntry parentEntry = browserConnection.getEntryFromCache(parentDn);
+                IEntry parentEntry = browserConnection.getEntryFromCache( parentDn );
                 entry = new Entry( parentEntry, aDn.getRdn() );
                 entry.setDirectoryEntry( true );
                 parentEntry.addChild( entry );
@@ -645,7 +645,7 @@ public class SearchRunnable implements S
                 // we have a base Dn, check if the entry really exists in LDAP
                 // this is to avoid that a node "dc=com" is created for "dc=example,dc=com"
context entry
                 SearchParameter searchParameter = new SearchParameter();
-                searchParameter.setSearchBase(aDn);
+                searchParameter.setSearchBase( aDn );
                 searchParameter.setFilter( null );
                 searchParameter.setReturningAttributes( ISearch.NO_ATTRIBUTES );
                 searchParameter.setScope( SearchScope.OBJECT );
@@ -661,7 +661,7 @@ public class SearchRunnable implements S
                     if ( enumeration != null && enumeration.hasMore() )
                     {
                         // create base Dn entry
-                        entry = new BaseDNEntry(aDn, browserConnection );
+                        entry = new BaseDNEntry( aDn, browserConnection );
                         browserConnection.getRootDSE().addChild( entry );
                         browserConnection.cacheEntry( entry );
                         enumeration.close();
@@ -697,64 +697,68 @@ public class SearchRunnable implements S
         while ( attributeEnumeration.hasMore() )
         {
             Attribute attribute = attributeEnumeration.next();
-            String attributeDescription = attribute.getID();
-            NamingEnumeration<?> valueEnumeration = attribute.getAll();
-            if ( SchemaConstants.OBJECT_CLASS_AT.equalsIgnoreCase( attributeDescription )
)
+
+            if ( attribute != null )
             {
-                if ( entry.getAttribute( attributeDescription ) != null )
+                String attributeDescription = attribute.getID();
+                NamingEnumeration<?> valueEnumeration = attribute.getAll();
+                if ( SchemaConstants.OBJECT_CLASS_AT.equalsIgnoreCase( attributeDescription
) )
                 {
-                    entry.deleteAttribute( entry.getAttribute( attributeDescription ) );
+                    if ( entry.getAttribute( attributeDescription ) != null )
+                    {
+                        entry.deleteAttribute( entry.getAttribute( attributeDescription )
);
+                    }
+                    entry.addAttribute( new org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute(
entry,
+                        attributeDescription ) );
                 }
-                entry.addAttribute( new org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute(
entry,
-                    attributeDescription ) );
-            }
-            while ( valueEnumeration.hasMore() )
-            {
-                Object o = valueEnumeration.next();
-                if ( o instanceof String )
+                while ( valueEnumeration.hasMore() )
                 {
-                    String value = ( String ) o;
-
-                    if ( searchParameter.isInitHasChildrenFlag() )
+                    Object o = valueEnumeration.next();
+                    if ( o instanceof String )
                     {
-                        // hasChildren flag
-                        if ( SchemaConstants.HAS_SUBORDINATES_AT.equalsIgnoreCase( attributeDescription
) )
+                        String value = ( String ) o;
+
+                        if ( searchParameter.isInitHasChildrenFlag() )
                         {
-                            if ( "FALSE".equalsIgnoreCase( value ) ) { //$NON-NLS-1$
-                                entry.setHasChildrenHint( false );
+                            // hasChildren flag
+                            if ( SchemaConstants.HAS_SUBORDINATES_AT.equalsIgnoreCase( attributeDescription
) )
+                            {
+                                if ( "FALSE".equalsIgnoreCase( value ) ) { //$NON-NLS-1$
+                                    entry.setHasChildrenHint( false );
+                                }
                             }
-                        }
-                        if ( SchemaConstants.NUM_SUBORDINATES_AT.equalsIgnoreCase( attributeDescription
) )
-                        {
-                            if ( "0".equalsIgnoreCase( value ) ) { //$NON-NLS-1$
-                                entry.setHasChildrenHint( false );
+                            if ( SchemaConstants.NUM_SUBORDINATES_AT.equalsIgnoreCase( attributeDescription
) )
+                            {
+                                if ( "0".equalsIgnoreCase( value ) ) { //$NON-NLS-1$
+                                    entry.setHasChildrenHint( false );
+                                }
+                            }
+                            if ( SchemaConstants.SUBORDINATE_COUNT_AT.equalsIgnoreCase( attributeDescription
) )
+                            {
+                                if ( "0".equalsIgnoreCase( value ) ) { //$NON-NLS-1$
+                                    entry.setHasChildrenHint( false );
+                                }
                             }
                         }
-                        if ( SchemaConstants.SUBORDINATE_COUNT_AT.equalsIgnoreCase( attributeDescription
) )
+
+                        if ( SchemaConstants.OBJECT_CLASS_AT.equalsIgnoreCase( attributeDescription
) )
                         {
-                            if ( "0".equalsIgnoreCase( value ) ) { //$NON-NLS-1$
+                            if ( SchemaConstants.ALIAS_OC.equalsIgnoreCase( value ) )
+                            {
+                                entry.setAlias( true );
                                 entry.setHasChildrenHint( false );
                             }
-                        }
-                    }
 
-                    if ( SchemaConstants.OBJECT_CLASS_AT.equalsIgnoreCase( attributeDescription
) )
-                    {
-                        if ( SchemaConstants.ALIAS_OC.equalsIgnoreCase( value ) )
-                        {
-                            entry.setAlias( true );
-                            entry.setHasChildrenHint( false );
-                        }
+                            if ( SchemaConstants.REFERRAL_OC.equalsIgnoreCase( value ) )
+                            {
+                                entry.setReferral( true );
+                                entry.setHasChildrenHint( false );
+                            }
 
-                        if ( SchemaConstants.REFERRAL_OC.equalsIgnoreCase( value ) )
-                        {
-                            entry.setReferral( true );
-                            entry.setHasChildrenHint( false );
+                            IAttribute ocAttribute = entry.getAttribute( attributeDescription
);
+                            Value ocValue = new Value( ocAttribute, value );
+                            ocAttribute.addValue( ocValue );
                         }
-
-                        IAttribute ocAttribute = entry.getAttribute( attributeDescription
);
-                        Value ocValue = new Value( ocAttribute, value );
-                        ocAttribute.addValue( ocValue );
                     }
                 }
             }



Mime
View raw message