directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r507271 - in /directory/apacheds/branches/1.0: core-unit/src/test/java/org/apache/directory/server/core/collective/ core/src/main/java/org/apache/directory/server/core/collective/
Date Tue, 13 Feb 2007 22:35:06 GMT
Author: ersiner
Date: Tue Feb 13 14:35:06 2007
New Revision: 507271

URL: http://svn.apache.org/viewvc?view=rev&rev=507271
Log:
Fixed DIRSERVER-820 and added test cases.

Modified:
    directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceITest.java
    directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java

Modified: directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceITest.java?view=diff&rev=507271&r1=507270&r2=507271
==============================================================================
--- directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceITest.java
(original)
+++ directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceITest.java
Tue Feb 13 14:35:06 2007
@@ -138,7 +138,7 @@
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
         controls.setReturningAttributes( new String[]
-            { "cn", "ou" } );
+            { "cn" } );
         NamingEnumeration results = super.sysRoot.search( "", "(objectClass=*)", controls
);
         
         while ( results.hasMore() )
@@ -445,5 +445,23 @@
         {
             // Intended execution point
         }
+    }
+    
+    
+    public void testPolymorphicReturnAttrLookup() throws Exception
+    {
+        // -------------------------------------------------------------------
+        // Setup the collective attribute specific administration point
+        // -------------------------------------------------------------------
+    
+        addAdministrativeRole( "collectiveAttributeSpecificArea" );
+        super.sysRoot.createSubcontext( "cn=testsubentry", getTestSubentry() );
+    
+        // request the collective attribute's super type specifically
+        Attributes attributes = super.sysRoot.getAttributes( "ou=interceptors,ou=configuration",
+            new String[] { "ou" } );
+        Attribute c_ou = attributes.get( "c-ou" );
+        assertNotNull( "a collective c-ou attribute should be present", c_ou );
+        assertTrue( c_ou.contains( "configuration" ) );
     }
 }

Modified: directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java?view=diff&rev=507271&r1=507270&r2=507271
==============================================================================
--- directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java
(original)
+++ directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java
Tue Feb 13 14:35:06 2007
@@ -42,6 +42,8 @@
 import javax.naming.directory.Attributes;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
+
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.HashSet;
@@ -193,19 +195,30 @@
                     continue;
                 }
 
+                Set allSuperTypes = getAllSuperTypes( attrType );
+                Iterator it = retIdsSet.iterator();
+                while ( it.hasNext() )
+                {
+                    String retId = ( String ) it.next();
+                    if ( retId.equals( "*" ) || retId.equals( "+" ) )
+                    {
+                        continue;
+                    }
+                    
+                    AttributeType retType = attrTypeRegistry.lookup( retId );
+                    if ( allSuperTypes.contains( retType ) )
+                    {
+                        retIdsSet.add( attrId );
+                        break;
+                    }
+                }
+                
                 /*
                  * If not all attributes or this collective attribute requested specifically
                  * then bypass the inclusion process.
                  */
                 if ( !( retIdsSet.contains( "*" ) || retIdsSet.contains( attrId ) ) )
                 {
-                    /*
-                     * TODO: Check if the requested attribute types list includes any type
-                     *       that is a supertype of any collective attribute that applies
-                     *       to this entry.
-                     *       
-                     * See: http://issues.apache.org/jira/browse/DIRSERVER-820
-                     */
                     continue;
                 }
                 
@@ -232,6 +245,24 @@
             }
         }
     }
+    
+    
+    private Set getAllSuperTypes( AttributeType id ) throws NamingException
+    {
+        Set allSuperTypes = new HashSet();
+        AttributeType superType = id;
+        while ( superType != null )
+        {
+            superType = superType.getSuperior();
+            if ( superType != null )
+            {
+                allSuperTypes.add( superType );
+            }
+        }
+        
+        return allSuperTypes;
+    }
+    
 
     public void init( DirectoryServiceConfiguration factoryCfg, InterceptorConfiguration
cfg ) throws NamingException
     {



Mime
View raw message