directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r492729 - /directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java
Date Thu, 04 Jan 2007 20:39:03 GMT
Author: elecharny
Date: Thu Jan  4 12:39:02 2007
New Revision: 492729

URL: http://svn.apache.org/viewvc?view=rev&rev=492729
Log:
Fixed issue DIRSERVER-789, and added the associated tests. 
(was : searching for an attribute either with it's short form, alias, OID, or inherited attributetype,
like
cn, commonname, 2.5.4.3, name)

Modified:
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java?view=diff&rev=492729&r1=492728&r2=492729
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java
(original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java
Thu Jan  4 12:39:02 2007
@@ -20,6 +20,8 @@
 package org.apache.directory.server.core.partition.impl.btree;
 
 
+import java.util.Iterator;
+
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -30,6 +32,7 @@
 import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.UsageEnum;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 
 
 /**
@@ -192,17 +195,48 @@
         {
             entry = new LockableAttributesImpl();
 
+            Attributes attrs = rec.getAttributes();
+            
             for ( int ii = 0; ii < attrIds.length; ii++ )
             {
+                if ( "1.1".equals( attrIds[ii] ) )
+                {
+                    break;
+                }
+                
+                Attribute attr = AttributeUtils.getAttribute( attrs, registry.lookup( attrIds[ii]
) );
+                
                 // there is no attribute by that name in the entry so we continue
-                if ( null == rec.getAttributes().get( attrIds[ii] ) )
+                if ( null == attr )
                 {
-                    continue;
+                    // May be it's because the attributeType is a inherited one?
+                    Iterator descendants = registry.descendants( attrIds[ii] );
+                    boolean found = false;
+                    
+                    while ( descendants.hasNext() )
+                    {
+                        AttributeType atype = (AttributeType)descendants.next();
+                        
+                        attr = AttributeUtils.getAttribute( attrs, atype );
+                        
+                        if ( attr != null )
+                        {
+                            found = true;
+                            break;
+                        }
+                    }
+                    
+                    if ( found )
+                    {
+                        // clone attribute to stuff into the new resultant entry
+                        entry.put( (Attribute)attr.clone() );
+                    }
+                }
+                else
+                {
+                    // clone attribute to stuff into the new resultant entry
+                    entry.put( (Attribute)attr.clone() );
                 }
-
-                // clone attribute to stuff into the new resultant entry
-                Attribute attr = ( Attribute ) rec.getAttributes().get( attrIds[ii] ).clone();
-                entry.put( attr );
             }
         }
 



Mime
View raw message