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/01/29 21:52:39 UTC
svn commit: r501180 -
/directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
Author: elecharny
Date: Mon Jan 29 12:52:38 2007
New Revision: 501180
URL: http://svn.apache.org/viewvc?view=rev&rev=501180
Log:
Fixed the Search operation, which was throwing a NPE when doing a search woth a bad filter on subschemaSubentry
Modified:
directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
Modified: directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?view=diff&rev=501180&r1=501179&r2=501180
==============================================================================
--- directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Mon Jan 29 12:52:38 2007
@@ -73,6 +73,7 @@
import org.apache.directory.shared.ldap.schema.UsageEnum;
import org.apache.directory.shared.ldap.util.AttributeUtils;
import org.apache.directory.shared.ldap.util.DateUtils;
+import org.apache.directory.shared.ldap.util.EmptyEnumeration;
import org.apache.directory.shared.ldap.util.SingletonEnumeration;
import org.apache.directory.shared.ldap.util.StringTools;
import org.slf4j.Logger;
@@ -428,8 +429,6 @@
SearchControls searchCtls ) throws NamingException
{
// check to make sure the DN searched for is a subentry
- Invocation invocation = InvocationStack.getInstance().peek();
-
// We have to eliminate bad attributes from the request, accordingly
// to RFC 2251, chap. 4.5.1. Basically, all unknown attributes are removed
// from the list
@@ -439,6 +438,8 @@
{
NamingEnumeration e = nextInterceptor.search( base, env, filter, searchCtls );
+ Invocation invocation = InvocationStack.getInstance().peek();
+
if ( searchCtls.getReturningAttributes() != null )
{
return new SearchResultFilteringEnumeration( e, new SearchControls(), invocation, topFilter );
@@ -447,52 +448,52 @@
return new SearchResultFilteringEnumeration( e, searchCtls, invocation, filters );
}
- if ( ( searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE ) && ( filter instanceof SimpleNode ) )
+ if ( searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE )
{
- SimpleNode node = ( SimpleNode ) filter;
- String compareto = null;
-
- if ( node.getValue() instanceof String )
+ if ( filter instanceof SimpleNode )
{
- compareto = ( String ) node.getValue();
- }
- else
- {
- compareto = node.getValue().toString();
+ SimpleNode node = ( SimpleNode ) filter;
+ String compareto = null;
+
+ if ( node.getValue() instanceof String )
+ {
+ compareto = ( String ) node.getValue();
+ }
+ else
+ {
+ compareto = node.getValue().toString();
+ }
+
+ // see if node attribute is objectClass
+ if ( node.getAttribute().equalsIgnoreCase( "2.5.4.0" )
+ && "subschema".equalsIgnoreCase( compareto ) && ( node.getAssertionType() == SimpleNode.EQUALITY ) )
+ {
+ // call.setBypass( true );
+ Attributes attrs = getSubschemaEntry( searchCtls.getReturningAttributes() );
+ SearchResult result = new SearchResult( base.toString(), null, attrs );
+ return new SingletonEnumeration( result );
+ }
+ else
+ {
+ return new EmptyEnumeration();
+ }
}
-
- // see if node attribute is objectClass
- if ( node.getAttribute().equalsIgnoreCase( "2.5.4.0" )
- && "subschema".equalsIgnoreCase( compareto ) && ( node.getAssertionType() == SimpleNode.EQUALITY ) )
+ else if ( filter instanceof PresenceNode )
{
- // call.setBypass( true );
- Attributes attrs = getSubschemaEntry( searchCtls.getReturningAttributes() );
- SearchResult result = new SearchResult( base.toString(), null, attrs );
- return new SingletonEnumeration( result );
- }
- }
- else if ( ( searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE ) && ( filter instanceof PresenceNode ) )
- {
- PresenceNode node = ( PresenceNode ) filter;
+ PresenceNode node = ( PresenceNode ) filter;
- // see if node attribute is objectClass
- if ( node.getAttribute().equalsIgnoreCase( "2.5.4.0" ) )
- {
- // call.setBypass( true );
- Attributes attrs = getSubschemaEntry( searchCtls.getReturningAttributes() );
- SearchResult result = new SearchResult( base.toString(), null, attrs );
- return new SingletonEnumeration( result );
+ // see if node attribute is objectClass
+ if ( node.getAttribute().equalsIgnoreCase( "2.5.4.0" ) )
+ {
+ // call.setBypass( true );
+ Attributes attrs = getSubschemaEntry( searchCtls.getReturningAttributes() );
+ SearchResult result = new SearchResult( base.toString(), null, attrs );
+ return new SingletonEnumeration( result );
+ }
}
}
- NamingEnumeration e = nextInterceptor.search( base, env, filter, searchCtls );
-
- if ( searchCtls.getReturningAttributes() != null )
- {
- return new SearchResultFilteringEnumeration( e, searchCtls, invocation, topFilter );
- }
-
- return new SearchResultFilteringEnumeration( e, searchCtls, invocation, filters );
+ return new EmptyEnumeration();
}