directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r540369 - /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
Date Mon, 21 May 2007 23:59:29 GMT
Author: elecharny
Date: Mon May 21 16:59:29 2007
New Revision: 540369

URL: http://svn.apache.org/viewvc?view=rev&rev=540369
Log:
Added a name to the SearchResultFilteringEnumeration constructore
for debug purpose
Fixed the filterAttributesToReturn method so that invalid attributes
are removed from the list of returned attributes.
If the list is empty after the removing, then "1.1" is passed to 
the filter chain.

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java

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?view=diff&rev=540369&r1=540368&r2=540369
==============================================================================
--- 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
Mon May 21 16:59:29 2007
@@ -380,7 +380,7 @@
     {
         NamingEnumeration e = nextInterceptor.list( opContext );
         Invocation invocation = InvocationStack.getInstance().peek();
-        return new SearchResultFilteringEnumeration( e, new SearchControls(), invocation,
binaryAttributeFilter );
+        return new SearchResultFilteringEnumeration( e, new SearchControls(), invocation,
binaryAttributeFilter, "List Schema Filter" );
     }
 
     /**
@@ -420,12 +420,21 @@
             
             try
             {
-                String oid = registries.getOidRegistry().getOid( attribute );
-    
-                if ( !filteredAttrs.containsKey( oid ) )
-                {
-                    filteredAttrs.put( oid, attribute );
-                }
+            	// Check that the attribute is declared
+            	if ( registries.getOidRegistry().hasOid( attribute ) )
+            	{
+	                String oid = registries.getOidRegistry().getOid( attribute );
+	                
+            		// The attribute must be an AttributeType
+	                if ( registries.getAttributeTypeRegistry().hasAttributeType( oid ) )
+	                {
+		                if ( !filteredAttrs.containsKey( oid ) )
+		                {
+		                	// Ok, we can add the attribute to the list of filtered attributes
+		                    filteredAttrs.put( oid, attribute );
+		                }
+	                }
+            	}
             }
             catch ( NamingException ne )
             {
@@ -439,6 +448,15 @@
             return;
         }
         
+        // 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,
+        	// as we don't want to return any attribute
+        	searchCtls.setReturningAttributes( new String[]{ "1.1" } );
+        	return;
+        }
+        
         // Some attributes have been removed. let's modify the searchControl
         String[] newAttributesList = new String[filteredAttrs.size()];
         
@@ -476,10 +494,10 @@
 
             if ( searchCtls.getReturningAttributes() != null )
             {
-                return new SearchResultFilteringEnumeration( e, new SearchControls(), invocation,
topFilter );
+                return new SearchResultFilteringEnumeration( e, new SearchControls(), invocation,
topFilter, "Search Schema Filter top" );
             }
 
-            return new SearchResultFilteringEnumeration( e, searchCtls, invocation, filters
);
+            return new SearchResultFilteringEnumeration( e, searchCtls, invocation, filters,
"Search Schema Filter" );
         }
 
         // The user was searching into the subSchemaSubEntry



Mime
View raw message