directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r423997 - in /directory/branches/apacheds/optimization/core/src: main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java main/schema/system.schema test/java/org/apache/directory/server/core/jndi/RootDSETest.java
Date Thu, 20 Jul 2006 17:24:19 GMT
Author: akarasulu
Date: Thu Jul 20 10:24:18 2006
New Revision: 423997

URL: http://svn.apache.org/viewvc?rev=423997&view=rev
Log:
fixed issues with 1.1, + and * special attributes on the RootDSE

Modified:
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
    directory/branches/apacheds/optimization/core/src/main/schema/system.schema
    directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/jndi/RootDSETest.java

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?rev=423997&r1=423996&r2=423997&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
Thu Jul 20 10:24:18 2006
@@ -63,6 +63,7 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.schema.UsageEnum;
 import org.apache.directory.shared.ldap.util.DateUtils;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 import org.apache.directory.shared.ldap.util.SingletonEnumeration;
@@ -109,6 +110,9 @@
     /** the read only rootDSE attributes */
     private final Attributes rootDSE;
 
+    private AttributeTypeRegistry attrRegistry;
+    private OidRegistry oidRegistry;
+
 
     /**
      * Creates the root nexus singleton of the entire system.  The root DSE has
@@ -118,7 +122,7 @@
      *
      * @see <a href="http://www.faqs.org/rfcs/rfc3045.html">Vendor Information</a>
      */
-    public DefaultPartitionNexus(Attributes rootDSE)
+    public DefaultPartitionNexus( Attributes rootDSE )
     {
         // setup that root DSE
         this.rootDSE = rootDSE;
@@ -183,7 +187,9 @@
         }
 
         this.factoryCfg = factoryCfg;
-
+        this.attrRegistry = this.factoryCfg.getGlobalRegistries().getAttributeTypeRegistry();
+        this.oidRegistry = this.factoryCfg.getGlobalRegistries().getOidRegistry();
+        
         List initializedPartitionCfgs = new ArrayList();
         initializedPartitionCfgs.add( initializeSystemPartition() );
 
@@ -726,31 +732,104 @@
              */
             if ( filter instanceof PresenceNode && isObjectScope && isSearchAll
)
             {
-                Attributes attrs = ( Attributes ) getRootDSE().clone();
                 String[] ids = searchCtls.getReturningAttributes();
 
-                if ( ids != null && ids.length > 0 )
+                // -----------------------------------------------------------
+                // If nothing is asked for then we just return the entry asis.
+                // We let other mechanisms filter out operational attributes.
+                // -----------------------------------------------------------
+                if ( ids == null || ids.length == 0 )
                 {
-                    boolean doSwap = true;
-                    Attributes askedFor = new LockableAttributesImpl();
-
-                    for ( int ii = 0; ii < ids.length; ii++ )
+                    SearchResult result = new SearchResult( "", null, ( Attributes ) getRootDSE().clone(),
false );
+                    return new SingletonEnumeration( result );
+                }
+                
+                // -----------------------------------------------------------
+                // Collect all the real attributes besides 1.1, +, and * and
+                // note if we've seen these special attributes as well.
+                // -----------------------------------------------------------
+
+                Set realIds = new HashSet();
+                boolean containsAsterisk = false;
+                boolean containsPlus = false;
+                boolean containsOneDotOne = false;
+                for ( int ii = 0; ii < ids.length; ii++ )
+                {
+                    String id = ids[ii].trim();
+                    if ( id.equals( "*" ) )
+                    {
+                        containsAsterisk = true;
+                    }
+                    else if ( id.equals( "+" ) )
                     {
-                        if ( ids[ii].trim().equals( "*" ) )
+                        containsPlus = true;
+                    }
+                    else if ( id.equals( "1.1" ) )
+                    {
+                        containsOneDotOne = true;
+                    }
+                    else
+                    {
+                        try
                         {
-                            doSwap = false;
-                            break;
+                            realIds.add( oidRegistry.getOid( id ) );
                         }
-
-                        if ( attrs.get( ids[ii] ) != null )
+                        catch ( NamingException e )
                         {
-                            askedFor.put( attrs.get( ids[ii] ) );
+                            realIds.add( id );
                         }
                     }
+                }
 
-                    if ( doSwap )
+                // return nothing
+                if ( containsOneDotOne )
+                {
+                    SearchResult result = new SearchResult( "", null, new LockableAttributesImpl(),
false );
+                    return new SingletonEnumeration( result );
+                }
+                
+                // return everything
+                if ( containsAsterisk && containsPlus )
+                {
+                    SearchResult result = new SearchResult( "", null, ( Attributes ) getRootDSE().clone(),
false );
+                    return new SingletonEnumeration( result );
+                }
+                
+                Attributes attrs = new LockableAttributesImpl();
+                if ( containsAsterisk )
+                {
+                    for ( NamingEnumeration ii = getRootDSE().getAll(); ii.hasMore(); /**/
)
                     {
-                        attrs = askedFor;
+                        // add all user attribute
+                        Attribute attr = ( Attribute ) ii.next();
+                        AttributeType type = attrRegistry.lookup( attr.getID() );
+                        if ( type.getUsage() == UsageEnum.USERAPPLICATIONS )
+                        {
+                            attrs.put( attr );
+                        }
+                        // add attributes specifically asked for
+                        else if ( realIds.contains( type.getOid() ) )
+                        {
+                            attrs.put( attr );
+                        }
+                    }
+                }
+                else if ( containsPlus )
+                {
+                    for ( NamingEnumeration ii = getRootDSE().getAll(); ii.hasMore(); /**/
)
+                    {
+                        // add all operational attributes
+                        Attribute attr = ( Attribute ) ii.next();
+                        AttributeType type = attrRegistry.lookup( attr.getID() );
+                        if ( type.getUsage() != UsageEnum.USERAPPLICATIONS )
+                        {
+                            attrs.put( attr );
+                        }
+                        // add user attributes specifically asked for
+                        else if ( realIds.contains( type.getOid() ) )
+                        {
+                            attrs.put( attr );
+                        }
                     }
                 }
 

Modified: directory/branches/apacheds/optimization/core/src/main/schema/system.schema
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/schema/system.schema?rev=423997&r1=423996&r2=423997&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/schema/system.schema (original)
+++ directory/branches/apacheds/optimization/core/src/main/schema/system.schema Thu Jul 20
10:24:18 2006
@@ -248,6 +248,10 @@
     EQUALITY caseExactMatch
     SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
 
+attributetype ( 1.3.6.1.4.1.4203.1.3.5 NAME 'supportedFeatures'
+    EQUALITY objectIdentifierMatch
+    SYNTAX 1.3.6.1.4.1.1466.115.121.1.38
+    USAGE dSAOperation )
 
 # ==============
 # objectClasses
@@ -313,3 +317,4 @@
     DESC 'RFC2589: Dynamic Object'
     SUP top
     AUXILIARY )
+

Modified: directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/jndi/RootDSETest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/jndi/RootDSETest.java?rev=423997&r1=423996&r2=423997&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/jndi/RootDSETest.java
(original)
+++ directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/jndi/RootDSETest.java
Thu Jul 20 10:24:18 2006
@@ -161,7 +161,7 @@
         Attributes attributes = ctx.getAttributes( "" );
 
         // Added some objectClass attributes to the rootDSE
-        assertEquals( 2, attributes.size() );
+        assertEquals( 1, attributes.size() );
     }
 
 



Mime
View raw message