You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/08/10 04:34:14 UTC
svn commit: r430215 - in /directory/branches/apacheds/1.0:
core-unit/src/test/java/org/apache/directory/server/core/jndi/
core/src/main/java/org/apache/directory/server/core/normalization/
core/src/main/java/org/apache/directory/server/core/partition/i...
Author: akarasulu
Date: Wed Aug 9 19:34:13 2006
New Revision: 430215
URL: http://svn.apache.org/viewvc?rev=430215&view=rev
Log:
Fixed DIRSERVER-249: Filters with less specific attributes do not return matching entries with more specific attributes
Added:
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java
Modified:
directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEvaluator.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/GlobalAttributeTypeRegistry.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java
directory/branches/apacheds/1.0/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java
Modified: directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java?rev=430215&r1=430214&r2=430215&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java (original)
+++ directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java Wed Aug 9 19:34:13 2006
@@ -375,4 +375,157 @@
}
assertEquals( "Expected number of results returned was incorrect", 1, map.size() );
}
+
+
+ public void testFilterExpansion0() throws Exception
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+ controls.setDerefLinkFlag( false );
+ sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP, DerefAliasesEnum.NEVERDEREFALIASES.getName() );
+
+ HashMap map = new HashMap();
+ NamingEnumeration list = sysRoot.search( "", "(name=testing00)", controls );
+ while ( list.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) list.next();
+ map.put( result.getName(), result.getAttributes() );
+ }
+ assertEquals( "size of results", 1, map.size() );
+ assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system" ) );
+ }
+
+
+ public void testFilterExpansion1() throws Exception
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+ controls.setDerefLinkFlag( false );
+ sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP, DerefAliasesEnum.NEVERDEREFALIASES.getName() );
+
+ HashMap map = new HashMap();
+ NamingEnumeration list = sysRoot.search( "", "(name=*)", controls );
+ while ( list.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) list.next();
+ map.put( result.getName(), result.getAttributes() );
+ }
+ assertEquals( "size of results", 14, map.size() );
+ assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system" ) );
+ assertTrue( "contains ou=testing01,ou=system", map.containsKey( "ou=testing01,ou=system" ) );
+ assertTrue( "contains ou=testing02,ou=system", map.containsKey( "ou=testing01,ou=system" ) );
+ assertTrue( "contains uid=akarasulu,ou=users,ou=system", map.containsKey( "uid=akarasulu,ou=users,ou=system" ) );
+ assertTrue( "contains ou=configuration,ou=system", map.containsKey( "ou=configuration,ou=system" ) );
+ assertTrue( "contains ou=groups,ou=system", map.containsKey( "ou=groups,ou=system" ) );
+ assertTrue( "contains ou=interceptors,ou=configuration,ou=system", map.containsKey( "ou=interceptors,ou=configuration,ou=system" ) );
+ assertTrue( "contains ou=partitions,ou=configuration,ou=system", map.containsKey( "ou=partitions,ou=configuration,ou=system" ) );
+ assertTrue( "contains ou=services,ou=configuration,ou=system", map.containsKey( "ou=services,ou=configuration,ou=system" ) );
+ assertTrue( "contains ou=subtest,ou=testing01,ou=system", map.containsKey( "ou=subtest,ou=testing01,ou=system" ) );
+ assertTrue( "contains ou=system", map.containsKey( "ou=system" ) );
+ assertTrue( "contains ou=users,ou=system", map.containsKey( "ou=users,ou=system" ) );
+ assertTrue( "contains uid=admin,ou=system", map.containsKey( "uid=admin,ou=system" ) );
+ assertTrue( "contains cn=administrators,ou=groups,ou=system", map.containsKey( "cn=administrators,ou=groups,ou=system" ) );
+ }
+
+
+ public void testFilterExpansion2() throws Exception
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+ controls.setDerefLinkFlag( false );
+ sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP, DerefAliasesEnum.NEVERDEREFALIASES.getName() );
+
+ HashMap map = new HashMap();
+ NamingEnumeration list = sysRoot.search( "", "(| (name=testing00)(name=testing01))", controls );
+ while ( list.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) list.next();
+ map.put( result.getName(), result.getAttributes() );
+ }
+ assertEquals( "size of results", 2, map.size() );
+ assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system" ) );
+ assertTrue( "contains ou=testing01,ou=system", map.containsKey( "ou=testing01,ou=system" ) );
+ }
+
+
+ public void testFilterExpansion4() throws Exception
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+ controls.setDerefLinkFlag( false );
+ sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP, DerefAliasesEnum.NEVERDEREFALIASES.getName() );
+
+ HashMap map = new HashMap();
+ NamingEnumeration list = sysRoot.search( "", "(name=testing*)", controls );
+ while ( list.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) list.next();
+ map.put( result.getName(), result.getAttributes() );
+ }
+ assertEquals( "size of results", 3, map.size() );
+ assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system" ) );
+ assertTrue( "contains ou=testing01,ou=system", map.containsKey( "ou=testing01,ou=system" ) );
+ assertTrue( "contains ou=testing02,ou=system", map.containsKey( "ou=testing01,ou=system" ) );
+ }
+
+
+ public void testFilterExpansion5() throws Exception
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+ controls.setDerefLinkFlag( false );
+ sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP, DerefAliasesEnum.NEVERDEREFALIASES.getName() );
+
+ HashMap map = new HashMap();
+ String filter = "(|(2.5.4.11.1=testing*)(2.5.4.54=testing*)(2.5.4.10=testing*)" +
+ "(2.5.4.6=testing*)(2.5.4.43=testing*)(2.5.4.7.1=testing*)(2.5.4.10.1=testing*)" +
+ "(2.5.4.44=testing*)(2.5.4.11=testing*)(2.5.4.4=testing*)(2.5.4.8.1=testing*)" +
+ "(2.5.4.12=testing*)(1.2.6.1.4.1.18060.1.1.1.3.3=testing*)" +
+ "(2.5.4.7=testing*)(2.5.4.3=testing*)(2.5.4.8=testing*)(2.5.4.42=testing*))";
+ NamingEnumeration list = sysRoot.search( "", filter, controls );
+ while ( list.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) list.next();
+ map.put( result.getName(), result.getAttributes() );
+ }
+ assertEquals( "size of results", 3, map.size() );
+ assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system" ) );
+ assertTrue( "contains ou=testing01,ou=system", map.containsKey( "ou=testing01,ou=system" ) );
+ assertTrue( "contains ou=testing02,ou=system", map.containsKey( "ou=testing01,ou=system" ) );
+ }
+
+
+ // this one is failing because it returns the admin user twice: count = 15
+// public void testFilterExpansion3() throws Exception
+// {
+// SearchControls controls = new SearchControls();
+// controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+// controls.setDerefLinkFlag( false );
+// sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP, DerefAliasesEnum.NEVERDEREFALIASES.getName() );
+//
+// List map = new ArrayList();
+// NamingEnumeration list = sysRoot.search( "", "(name=*)", controls );
+// while ( list.hasMore() )
+// {
+// SearchResult result = ( SearchResult ) list.next();
+// map.add( result.getName() );
+// }
+// assertEquals( "size of results", 14, map.size() );
+// assertTrue( "contains ou=testing00,ou=system", map.contains( "ou=testing00,ou=system" ) );
+// assertTrue( "contains ou=testing01,ou=system", map.contains( "ou=testing01,ou=system" ) );
+// assertTrue( "contains ou=testing02,ou=system", map.contains( "ou=testing01,ou=system" ) );
+// assertTrue( "contains uid=akarasulu,ou=users,ou=system", map.contains( "uid=akarasulu,ou=users,ou=system" ) );
+// assertTrue( "contains ou=configuration,ou=system", map.contains( "ou=configuration,ou=system" ) );
+// assertTrue( "contains ou=groups,ou=system", map.contains( "ou=groups,ou=system" ) );
+// assertTrue( "contains ou=interceptors,ou=configuration,ou=system", map.contains( "ou=interceptors,ou=configuration,ou=system" ) );
+// assertTrue( "contains ou=partitions,ou=configuration,ou=system", map.contains( "ou=partitions,ou=configuration,ou=system" ) );
+// assertTrue( "contains ou=services,ou=configuration,ou=system", map.contains( "ou=services,ou=configuration,ou=system" ) );
+// assertTrue( "contains ou=subtest,ou=testing01,ou=system", map.contains( "ou=subtest,ou=testing01,ou=system" ) );
+// assertTrue( "contains ou=system", map.contains( "ou=system" ) );
+// assertTrue( "contains ou=users,ou=system", map.contains( "ou=users,ou=system" ) );
+// assertTrue( "contains uid=admin,ou=system", map.contains( "uid=admin,ou=system" ) );
+// assertTrue( "contains cn=administrators,ou=groups,ou=system", map.contains( "cn=administrators,ou=groups,ou=system" ) );
+// }
+
+
}
Added: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java?rev=430215&view=auto
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java (added)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java Wed Aug 9 19:34:13 2006
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.directory.server.core.normalization;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.server.core.schema.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.filter.BranchNode;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.ExtensibleNode;
+import org.apache.directory.shared.ldap.filter.FilterVisitor;
+import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.PresenceNode;
+import org.apache.directory.shared.ldap.filter.SimpleNode;
+import org.apache.directory.shared.ldap.filter.SubstringNode;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+
+
+/**
+ *
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 429176 $
+ */
+public class ExpandingVisitor implements FilterVisitor
+{
+ private final AttributeTypeRegistry attrRegistry;
+
+
+ public ExpandingVisitor( AttributeTypeRegistry attrRegistry )
+ {
+ this.attrRegistry = attrRegistry;
+ }
+
+
+ public boolean canVisit( ExprNode node )
+ {
+ return node instanceof BranchNode;
+ }
+
+
+ public ArrayList getOrder( BranchNode node, ArrayList children )
+ {
+ return children;
+ }
+
+
+ public boolean isPrefix()
+ {
+ return false;
+ }
+
+
+ public void visit( ExprNode node )
+ {
+ BranchNode bnode = ( BranchNode ) node;
+
+ // --------------------------------------------------------------------
+ // we want to check each child leaf node to see if it must be expanded
+ // children that are branch nodes are recursively visited
+ // --------------------------------------------------------------------
+
+ final List children = bnode.getChildren();
+ final int limit = children.size();
+ for ( int ii = 0; ii < limit; ii++ )
+ {
+ ExprNode child = ( ExprNode ) children.get( ii );
+ if ( child instanceof LeafNode )
+ {
+ LeafNode leaf = ( LeafNode ) child;
+ try
+ {
+ if ( attrRegistry.hasDescendants( leaf.getAttribute() ) )
+ {
+ // create a new OR node to hold all descendent forms
+ // add to this node the generalized leaf node and
+ // replace the old leaf with the new OR branch node
+ BranchNode orNode = new BranchNode( BranchNode.OR );
+ orNode.getChildren().add( leaf );
+ children.set( ii, orNode );
+
+ // iterate through descendants adding them to the orNode
+ Iterator descendants = attrRegistry.descendants( leaf.getAttribute() );
+ while ( descendants.hasNext() )
+ {
+ LeafNode newLeaf = null;
+ AttributeType descendant = ( AttributeType ) descendants.next();
+
+ switch( leaf.getAssertionType() )
+ {
+ case( LeafNode.EXTENSIBLE ):
+ ExtensibleNode extensibleNode = ( ExtensibleNode ) leaf;
+ newLeaf = new ExtensibleNode( descendant.getOid(),
+ extensibleNode.getValue(),
+ extensibleNode.getMatchingRuleId(),
+ extensibleNode.dnAttributes() );
+ break;
+ case( LeafNode.PRESENCE ):
+ newLeaf = new PresenceNode( descendant.getOid() );
+ break;
+ case( LeafNode.SUBSTRING ):
+ SubstringNode substringNode = ( SubstringNode ) leaf;
+ newLeaf = new SubstringNode( descendant.getOid(),
+ substringNode.getInitial(),
+ substringNode.getFinal() );
+ break;
+ case( LeafNode.APPROXIMATE ):
+ case( LeafNode.EQUALITY ):
+ case( LeafNode.GREATEREQ ):
+ case( LeafNode.LESSEQ ):
+ SimpleNode simpleNode = ( SimpleNode ) leaf;
+ newLeaf = new SimpleNode( descendant.getOid(),
+ simpleNode.getValue(),
+ simpleNode.getAssertionType() );
+ break;
+ default:
+ throw new IllegalStateException( "Unknown assertion type: "
+ + leaf.getAssertionType() );
+ }
+ orNode.addNode( newLeaf );
+ }
+ }
+ }
+ catch ( NamingException e )
+ {
+ // log something here and throw a runtime excpetion
+ e.printStackTrace();
+ throw new RuntimeException( "Failed to expand node" );
+ }
+ }
+ else
+ {
+ visit( child );
+ }
+ } // end for loop
+ }
+}
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java?rev=430215&r1=430214&r2=430215&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java Wed Aug 9 19:34:13 2006
@@ -17,6 +17,7 @@
package org.apache.directory.server.core.normalization;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -38,9 +39,14 @@
import org.apache.directory.shared.ldap.filter.BranchNode;
import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.ExtensibleNode;
import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.PresenceNode;
+import org.apache.directory.shared.ldap.filter.SimpleNode;
+import org.apache.directory.shared.ldap.filter.SubstringNode;
import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.util.EmptyEnumeration;
import org.slf4j.LoggerFactory;
@@ -61,7 +67,9 @@
private static final Logger log = LoggerFactory.getLogger( NormalizationService.class );
/** a filter node value normalizer and undefined node remover */
- private NormalizingVisitor visitor;
+ private NormalizingVisitor normVisitor;
+ /** an expanding filter that makes expressions more specific */
+ private ExpandingVisitor expVisitor;
/** the attributeType registry used for normalization and determining if some filter nodes are undefined */
private AttributeTypeRegistry attributeRegistry;
@@ -71,7 +79,8 @@
OidRegistry oidRegistry = factoryCfg.getGlobalRegistries().getOidRegistry();
attributeRegistry = factoryCfg.getGlobalRegistries().getAttributeTypeRegistry();
NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( attributeRegistry, oidRegistry );
- visitor = new NormalizingVisitor( ncn, oidRegistry );
+ normVisitor = new NormalizingVisitor( ncn, oidRegistry );
+ expVisitor = new ExpandingVisitor( attributeRegistry );
}
@@ -177,7 +186,7 @@
}
}
- filter.accept( visitor );
+ filter.accept( normVisitor );
isFailure = false;
}
catch( UndefinedFilterAttributeException e )
@@ -230,6 +239,72 @@
filter = child.getChild();
}
}
+
+ // --------------------------------------------------------------------
+ // The filter below this point is now expanded to include specific
+ // attributes when a general one is supplied.
+ // --------------------------------------------------------------------
+
+ if ( !filter.isLeaf() )
+ {
+ expVisitor.visit( filter );
+ }
+ else
+ {
+ LeafNode leaf = ( LeafNode ) filter;
+ if ( attributeRegistry.hasDescendants( leaf.getAttribute() ) )
+ {
+ // create new OR node and add the filter leaf to it
+ // and set filter to this new branch node
+ BranchNode bnode = new BranchNode( BranchNode.OR );
+ bnode.getChildren().add( filter );
+ filter = bnode;
+
+ // add descendant nodes to this new branch node
+ Iterator descendants = attributeRegistry.descendants( leaf.getAttribute() );
+
+ while ( descendants.hasNext() )
+ {
+ LeafNode newLeaf = null;
+ AttributeType descendant = ( AttributeType ) descendants.next();
+
+ switch( leaf.getAssertionType() )
+ {
+ case( LeafNode.EXTENSIBLE ):
+ ExtensibleNode extensibleNode = ( ExtensibleNode ) leaf;
+ newLeaf = new ExtensibleNode( descendant.getOid(),
+ extensibleNode.getValue(),
+ extensibleNode.getMatchingRuleId(),
+ extensibleNode.dnAttributes() );
+ break;
+ case( LeafNode.PRESENCE ):
+ newLeaf = new PresenceNode( descendant.getOid() );
+ break;
+ case( LeafNode.SUBSTRING ):
+ SubstringNode substringNode = ( SubstringNode ) leaf;
+ newLeaf = new SubstringNode( descendant.getOid(),
+ substringNode.getInitial(),
+ substringNode.getFinal() );
+ break;
+ case( LeafNode.APPROXIMATE ):
+ case( LeafNode.EQUALITY ):
+ case( LeafNode.GREATEREQ ):
+ case( LeafNode.LESSEQ ):
+ SimpleNode simpleNode = ( SimpleNode ) leaf;
+ newLeaf = new SimpleNode( descendant.getOid(),
+ simpleNode.getValue(),
+ simpleNode.getAssertionType() );
+ break;
+ default:
+ throw new IllegalStateException( "Unknown assertion type: "
+ + leaf.getAssertionType() );
+ }
+
+ bnode.getChildren().add( newLeaf );
+ }
+ }
+ }
+
return nextInterceptor.search( base, env, filter, searchCtls );
}
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java?rev=430215&r1=430214&r2=430215&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java Wed Aug 9 19:34:13 2006
@@ -37,6 +37,7 @@
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.MatchingRule;
import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
/**
@@ -164,8 +165,9 @@
record.setAttributes( db.lookup( id ) );
}
- // get the attribute associated with the node
- Attribute attr = record.getAttributes().get( attrId );
+ // get the attribute associated with the node
+ Attribute attr = AttributeUtils.getAttribute( record.getAttributes(),
+ attributeTypeRegistry.lookup( node.getAttribute() ) );
// If we do not have the attribute just return false
if ( null == attr )
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEvaluator.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEvaluator.java?rev=430215&r1=430214&r2=430215&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEvaluator.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEvaluator.java Wed Aug 9 19:34:13 2006
@@ -32,6 +32,7 @@
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.MatchingRule;
import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
/**
@@ -138,7 +139,7 @@
}
// get the attribute
- Attribute attr = record.getAttributes().get( snode.getAttribute() );
+ Attribute attr = AttributeUtils.getAttribute( record.getAttributes(), type );
// if the attribute does not exist just return false
if ( null == attr )
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java?rev=430215&r1=430214&r2=430215&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java Wed Aug 9 19:34:13 2006
@@ -89,6 +89,16 @@
*/
Map getNormalizerMapping() throws NamingException;
+ /**
+ * Quick lookup to see if an attribute has descendants.
+ *
+ * @param ancestorId the name alias or OID for an attributeType
+ * @return an Iterator over the AttributeTypes which have the ancestor
+ * within their superior chain to the top
+ * @throws NamingException if the ancestor attributeType cannot be
+ * discerned from the ancestorId supplied
+ */
+ boolean hasDescendants( String ancestorId ) throws NamingException;
/**
* Get's an iterator over the set of descendant attributeTypes for
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/GlobalAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/GlobalAttributeTypeRegistry.java?rev=430215&r1=430214&r2=430215&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/GlobalAttributeTypeRegistry.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/GlobalAttributeTypeRegistry.java Wed Aug 9 19:34:13 2006
@@ -235,4 +235,10 @@
{
return bootstrap.descendants( ancestorId );
}
+
+
+ public boolean hasDescendants( String ancestorId ) throws NamingException
+ {
+ return bootstrap.hasDescendants( ancestorId );
+ }
}
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java?rev=430215&r1=430214&r2=430215&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java Wed Aug 9 19:34:13 2006
@@ -253,4 +253,16 @@
}
return descendants.iterator();
}
+
+
+ public boolean hasDescendants( String ancestorId ) throws NamingException
+ {
+ String oid = oidRegistry.getOid( ancestorId );
+ Set descendants = ( Set ) oidToDescendantSet.get( oid );
+ if ( descendants == null )
+ {
+ return false;
+ }
+ return !descendants.isEmpty();
+ }
}
Modified: directory/branches/apacheds/1.0/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java?rev=430215&r1=430214&r2=430215&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java (original)
+++ directory/branches/apacheds/1.0/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java Wed Aug 9 19:34:13 2006
@@ -457,4 +457,10 @@
{
return null;
}
+
+
+ public boolean hasDescendants( String ancestorId ) throws NamingException
+ {
+ return false;
+ }
}