You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2007/08/29 12:40:33 UTC

svn commit: r570745 - in /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core: collective/ partition/ partition/impl/btree/ schema/ sp/ subtree/

Author: elecharny
Date: Wed Aug 29 03:40:29 2007
New Revision: 570745

URL: http://svn.apache.org/viewvc?rev=570745&view=rev
Log:
o Added constants for "*", "+" and "1.1" special attributes
o Modified the code to use those constants
o Added a workaround for clients who are sending empty parameters
o Correctly handling the "1.1" special attribute mixed with other attributes (=> ignoring it) 

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java

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?rev=570745&r1=570744&r2=570745&view=diff
==============================================================================
--- 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 Wed Aug 29 03:40:29 2007
@@ -165,7 +165,7 @@
          */
         if ( retAttrs == null )
         {
-            retAttrs = new String[] { "*" };
+            retAttrs = SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY;
         }
         
         /*
@@ -211,15 +211,18 @@
                 
                 Set allSuperTypes = getAllSuperTypes( attrType );
                 Iterator it = retIdsSet.iterator();
+                
                 while ( it.hasNext() )
                 {
                     String retId = ( String ) it.next();
-                    if ( retId.equals( "*" ) || retId.equals( "+" ) )
+                    
+                    if ( retId.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) || retId.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) )
                     {
                         continue;
                     }
                     
                     AttributeType retType = attrTypeRegistry.lookup( retId );
+                    
                     if ( allSuperTypes.contains( retType ) )
                     {
                         retIdsSet.add( attrId );
@@ -231,7 +234,7 @@
                  * If not all attributes or this collective attribute requested specifically
                  * then bypass the inclusion process.
                  */
-                if ( !( retIdsSet.contains( "*" ) || retIdsSet.contains( attrId ) ) )
+                if ( !( retIdsSet.contains( SchemaConstants.ALL_USER_ATTRIBUTES ) || retIdsSet.contains( attrId ) ) )
                 {
                     continue;
                 }
@@ -294,7 +297,7 @@
         
         if ( ( opContext.getAttrsId() == null ) || ( opContext.getAttrsId().size() == 0 ) ) 
         {
-            addCollectiveAttributes( opContext.getDn(), result, new String[] { "*" } );
+            addCollectiveAttributes( opContext.getDn(), result, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
         }
         else
         {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?rev=570745&r1=570744&r2=570745&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java Wed Aug 29 03:40:29 2007
@@ -865,18 +865,20 @@
                 boolean containsAsterisk = false;
                 boolean containsPlus = false;
                 boolean containsOneDotOne = false;
-                for ( int ii = 0; ii < ids.length; ii++ )
+                
+                for ( String id:ids )
                 {
-                    String id = ids[ii].trim();
-                    if ( id.equals( "*" ) )
+                    String idTrimmed = id.trim();
+                    
+                    if ( idTrimmed.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) )
                     {
                         containsAsterisk = true;
                     }
-                    else if ( id.equals( "+" ) )
+                    else if ( idTrimmed.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) )
                     {
                         containsPlus = true;
                     }
-                    else if ( id.equals( "1.1" ) )
+                    else if ( idTrimmed.equals( SchemaConstants.NO_ATTRIBUTE ) )
                     {
                         containsOneDotOne = true;
                     }
@@ -884,11 +886,11 @@
                     {
                         try
                         {
-                            realIds.add( oidRegistry.getOid( id ) );
+                            realIds.add( oidRegistry.getOid( idTrimmed ) );
                         }
                         catch ( NamingException e )
                         {
-                            realIds.add( id );
+                            realIds.add( idTrimmed );
                         }
                     }
                 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java?rev=570745&r1=570744&r2=570745&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java Wed Aug 29 03:40:29 2007
@@ -68,6 +68,7 @@
 import org.apache.directory.server.core.interceptor.context.UnbindOperationContext;
 import org.apache.directory.server.core.invocation.Invocation;
 import org.apache.directory.server.core.invocation.InvocationStack;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapSizeLimitExceededException;
 import org.apache.directory.shared.ldap.exception.LdapTimeLimitExceededException;
 import org.apache.directory.shared.ldap.filter.ExprNode;
@@ -515,7 +516,7 @@
     			
         		return ROOT_DSE_NO_OPERATIONNAL;
     		}
-    		else if ( ( attrs.size() == 1 ) && ( attrs.contains( "+" ) ) )
+    		else if ( ( attrs.size() == 1 ) && ( attrs.contains( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) ) )
     		{
     			synchronized( ROOT_DSE_ALL_MUTEX )
     			{

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java?rev=570745&r1=570744&r2=570745&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java Wed Aug 29 03:40:29 2007
@@ -29,6 +29,7 @@
 
 import org.apache.directory.server.core.enumeration.SearchResultEnumeration;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.UsageEnum;
@@ -126,7 +127,7 @@
             // add all listed attributes
             for ( int ii = 0; ii < attrIds.length; ii++ )
             {
-                if ( attrIds[ii].equals( "+" ) )
+                if ( attrIds[ii].equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) )
                 {
                     continue;
                 }
@@ -163,7 +164,7 @@
             // add all listed operational attributes
             for ( int ii = 0; ii < attrIds.length; ii++ )
             {
-                if ( attrIds[ii].equals( "*" ) )
+                if ( attrIds[ii].equals( SchemaConstants.ALL_USER_ATTRIBUTES ) )
                 {
                     continue;
                 }
@@ -199,7 +200,7 @@
             
             for ( int ii = 0; ii < attrIds.length; ii++ )
             {
-                if ( "1.1".equals( attrIds[ii] ) )
+                if ( SchemaConstants.NO_ATTRIBUTE.equals( attrIds[ii] ) )
                 {
                     break;
                 }
@@ -249,7 +250,7 @@
 
         for ( int ii = ids.length - 1; ii >= 0; ii-- )
         {
-            if ( ids[ii].trim().equals( "*" ) )
+            if ( ids[ii].trim().equals( SchemaConstants.ALL_USER_ATTRIBUTES ) )
             {
                 return true;
             }
@@ -268,7 +269,7 @@
 
         for ( int ii = ids.length - 1; ii >= 0; ii-- )
         {
-            if ( ids[ii].trim().equals( "+" ) )
+            if ( ids[ii].trim().equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) )
             {
                 return true;
             }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?rev=570745&r1=570744&r2=570745&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Wed Aug 29 03:40:29 2007
@@ -403,21 +403,36 @@
 
         if ( ( attributes == null ) || ( attributes.length == 0 ) )
         {
+            // We have no attributes, that means "*" (all users attributes)
+            searchCtls.setReturningAttributes( SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
             return;
         }
         
         Map<String, String> filteredAttrs = new HashMap<String, String>(); 
+        boolean hasNoAttribute = false;
+        boolean hasAttributes = false;
         
         for ( String attribute:attributes )
         {
             // Skip special attributes
-            if ( ( "*".equals( attribute ) ) || ( "+".equals( attribute ) ) || ( "1.1".equals( attribute ) ) )
+            if ( ( SchemaConstants.ALL_USER_ATTRIBUTES.equals( attribute ) ) || 
+                ( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES.equals( attribute ) ) || 
+                ( SchemaConstants.NO_ATTRIBUTE.equals( attribute ) ) )
             {
                 if ( !filteredAttrs.containsKey( attribute ) )
                 {
                     filteredAttrs.put( attribute, attribute );
                 }
 
+                if ( SchemaConstants.NO_ATTRIBUTE.equals( attribute ) )
+                {
+                    hasNoAttribute = true;
+                }
+                else
+                {
+                    hasAttributes = true;
+                }
+                
                 continue;
             }
             
@@ -438,6 +453,8 @@
 		                }
 	                }
             	}
+                
+                hasAttributes = true;
             }
             catch ( NamingException ne )
             {
@@ -445,6 +462,12 @@
             }
         }
         
+        // Treat a special case : if we have an attribute and "1.1", then discard "1.1"
+        if ( hasAttributes && hasNoAttribute )
+        {
+            filteredAttrs.remove( SchemaConstants.NO_ATTRIBUTE );
+        }
+        
         // If we still have the same attribute number, then we can just get out the method
         if ( filteredAttrs.size() == attributes.length )
         {
@@ -454,9 +477,9 @@
         // Deal with the special case where the attribute list is now empty
         if (  filteredAttrs.size() == 0 )
         {
-        	// We just have to pass the special 1.1 ayttribute,
+        	// We just have to pass the special 1.1 attribute,
         	// as we don't want to return any attribute
-        	searchCtls.setReturningAttributes( new String[]{ "1.1" } );
+        	searchCtls.setReturningAttributes( SchemaConstants.NO_ATTRIBUTE_ARRAY );
         	return;
         }
         
@@ -597,12 +620,11 @@
         {
             // Check whether the set contains a plus, and use it below to include all
             // operational attributes.  Due to RFC 3673, and issue DIREVE-228 in JIRA
-            if ( "+".equals( id ) )
+            if ( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES.equals( id ) )
             {
-                // set.add( "+" );
                 returnAllOperationalAttributes = true;
             }
-            else if ( "*".equals(  id ) )
+            else if ( SchemaConstants.ALL_USER_ATTRIBUTES.equals(  id ) )
             {
                 setOids.add( id );
             }
@@ -791,7 +813,7 @@
         }
 
         // add the objectClass attribute
-        if ( setOids.contains( "*" ) || 
+        if ( setOids.contains( SchemaConstants.ALL_USER_ATTRIBUTES ) || 
              setOids.contains( SchemaConstants.OBJECT_CLASS_AT_OID ) || 
              setOids.size() == minSetSize )
         {
@@ -804,7 +826,7 @@
         }
 
         // add the cn attribute as required for the RDN
-        if ( setOids.contains( "*" ) || 
+        if ( setOids.contains( SchemaConstants.ALL_USER_ATTRIBUTES ) || 
              setOids.contains( SchemaConstants.CN_AT_OID ) || 
              setOids.size() == minSetSize )
         {
@@ -1230,7 +1252,7 @@
         next.rename( opContext );
     }
 
-    private final static String[] schemaSubentryReturnAttributes = new String[] { "+", "*" };
+    private final static String[] schemaSubentryReturnAttributes = new String[] { SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES };
     
     public void modify( NextInterceptor next, ModifyOperationContext opContext ) throws NamingException
     {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java?rev=570745&r1=570744&r2=570745&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java Wed Aug 29 03:40:29 2007
@@ -32,6 +32,8 @@
 
 import javax.naming.ldap.LdapContext;
 
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+
 /**
  * A Factory type class which holds a registry of supported {@link StoredProcEngineConfig}s. A container reference
  * as the base for Stored Procedure storage on the DIT is also handled by this class.
@@ -71,7 +73,7 @@
     public Attributes findStoredProcUnit( LdapContext rootDSE, String fullSPName ) throws NamingException
     {
         SearchControls controls = new SearchControls();
-        controls.setReturningAttributes( new String[] { "*" } );
+        controls.setReturningAttributes( SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
         controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
         String spUnitName = StoredProcUtils.extractStoredProcUnitName( fullSPName );
         String filter = "(storedProcUnitName=" + spUnitName + ")";

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java?rev=570745&r1=570744&r2=570745&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java Wed Aug 29 03:40:29 2007
@@ -452,7 +452,7 @@
             SearchControls controls = new SearchControls();
             controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
             controls.setReturningAttributes( new String[]
-                { "+", "*" } );
+                { SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
 
             NamingEnumeration subentries = 
                 nexus.search( 
@@ -579,7 +579,7 @@
             SearchControls controls = new SearchControls();
             controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
             controls.setReturningAttributes( new String[]
-                { "+", "*" } );
+                { SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
 
             NamingEnumeration subentries = 
                 nexus.search( 
@@ -741,7 +741,7 @@
             ExprNode filter = new PresenceNode( oidRegistry.getOid( SchemaConstants.OBJECT_CLASS_AT ) );
             SearchControls controls = new SearchControls();
             controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-            controls.setReturningAttributes( new String[] { "+", "*" } );
+            controls.setReturningAttributes( new String[] { SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
             NamingEnumeration subentries = 
                 nexus.search( 
                     new SearchOperationContext( baseDn, factoryCfg.getEnvironment(), filter, controls ) );
@@ -822,7 +822,7 @@
             ExprNode filter = new PresenceNode( oidRegistry.getOid( SchemaConstants.OBJECT_CLASS_AT ) );
             SearchControls controls = new SearchControls();
             controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-            controls.setReturningAttributes( new String[] { "+", "*" } );
+            controls.setReturningAttributes( new String[] { SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
             NamingEnumeration subentries = 
                 nexus.search( 
                     new SearchOperationContext( baseDn, factoryCfg.getEnvironment(), filter, controls ) );
@@ -897,7 +897,7 @@
             SearchControls controls = new SearchControls();
             controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
             controls.setReturningAttributes( new String[]
-                { "+", "*" } );
+                { SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
             NamingEnumeration subentries = 
                 nexus.search( 
                     new SearchOperationContext( baseDn, factoryCfg.getEnvironment(), filter, controls ) );
@@ -1064,7 +1064,7 @@
             SearchControls controls = new SearchControls();
             controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
             controls.setReturningAttributes( new String[]
-                { "+", "*" } );
+                { SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
             NamingEnumeration subentries = 
                 nexus.search( 
                     new SearchOperationContext( oldBaseDn, factoryCfg.getEnvironment(), filter, controls ) );