directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Zoerner <ste...@labeo.de>
Subject Question regarding FilterVisitor implementation
Date Sat, 09 Sep 2006 17:15:40 GMT
Hi all!

I use ApacheDS 1.0 RC4 and have a question regarding FilterVisitor from org.apache.directory.shared.ldap.filter,
and related stuff. 

I have programmed a simple interceptor which determines attribute types most frequently used
in search filters, and periodically writes a report about them to disk. I plan to use it for
index optimization in my partition definition. Everything works well, but one question remained
unsolved for me.

I have overwritten the search method of BaseInterceptor and created an inner class which implements
FilterVisitor and looks like this:

    class AttributeDetector implements FilterVisitor {
        public boolean canVisit(ExprNode node) {
            return true;
        }

        public ArrayList getOrder(BranchNode branchNode, ArrayList nodes) {
            return nodes;
        }

        public boolean isPrefix() {
            return true;
        }

        public void visit(ExprNode node) {                
            if (node instanceof LeafNode) {
                LeafNode leaf = (LeafNode) node;
                addAttributeOccurence(leaf.getAttribute());
            }           
        }
    }

I use it within search to analyze the filter. 

My question is about the result of leaf.getAttribute() (which is a String). In most cases
it contains the OID of the attribute type, but sometimes, it contains the name ("cn" instead
of "2.5.4.3"). It seems that the name is returned in case of substring expressions.

For instance in "(&(objectClass=*)(sn=Amos)(cn=Tor*))" for the first two operands within
the AND expression, the OID is returned,for the third one "cn". I have created a work around
with the help of AttributeTypeRegistry. Lucky me -- it is available in interceptors. But I
am curios: is it a bug, that sometime not the OID but the (a) attribute name is returned?

Thanks in advance,
    Stefan


Mime
View raw message