Stefan Zoerner a écrit :
> 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.
Very interesting piece of work ! I think this will be very usefull in
the soon future.
>
> 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.
Strange. From what I understand of the code - and sure Alex can give you
a better explanation -, there is a 'visit' method in the
NormalizingVisitor which is applied to all the attributes found in a
filter into the NormalizationService.search(). It seems that for some
attributes, like ObjectClass and cn, there is no transformation to an
OID form. I don't know if it's a bug, or if the search fails because of
this behavior, but definitively this need some further investigation.
>
> 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?
I really don't know, but I can reasonably say that it should not work
the way it does :) Let's open a JIRA !
>
> Thanks in advance,
> Stefan
Emmanuel.
|