directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r507273 - in /directory/apacheds/trunk: core-unit/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceITest.java core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java
Date Tue, 13 Feb 2007 22:35:29 GMT
Author: ersiner
Date: Tue Feb 13 14:35:28 2007
New Revision: 507273

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

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

Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceITest.java?view=diff&rev=507273&r1=507272&r2=507273
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceITest.java
(original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceITest.java
Tue Feb 13 14:35:28 2007
@@ -136,7 +136,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() )
         {
@@ -234,7 +234,7 @@
         
         // unspecify the collective attribute in the returning attribute list
 
-        attributes = super.sysRoot.getAttributes( "ou=interceptors,ou=configuration", new
String[] { "ou" } );
+        attributes = super.sysRoot.getAttributes( "ou=interceptors,ou=configuration", new
String[] { "objectClass" } );
         c_ou = attributes.get( "c-ou" );
         assertNull( "a collective c-ou attribute should not be present", c_ou );
         
@@ -474,6 +474,24 @@
         {
             // 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/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java?view=diff&rev=507273&r1=507272&r2=507273
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java
Tue Feb 13 14:35:28 2007
@@ -21,6 +21,7 @@
 
 
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
@@ -202,6 +203,24 @@
                 {
                     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
@@ -209,13 +228,6 @@
                  */
                 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;
                 }
                 
@@ -241,6 +253,23 @@
                 }
             }
         }
+    }
+    
+    
+    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;
     }
 
 



Mime
View raw message