directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Seelmann <seelm...@apache.org>
Subject Fwd: Filtering entries on a custom partition
Date Fri, 29 Apr 2011 15:38:02 GMT
Just forwarding to ML, seems it was filtered because of an attached file.

--------------------------------------------------

Hi, thanks for your reply.

Yes, I implemented a custom partition (the interface
org.apache.directory.server.core.partition.Partition).

I'm using version is 1.5.5 of Apache DS.

What do you mean by Backend? Is this how I implement the data store?
Based on your comments, I need to add more 'ifs' to filter the
results? For example:

       if (!ctx.getFilter().toString().contains("objectClass=person"))

Then return only the entries I'm interested in?

This is an example of how I'm implementing the search method from
Partition interface (I simplified it a little bit). I attached the
same code to this mail for better reading.

public EntryFilteringCursor search(SearchOperationContext ctx) throws
Exception {

               //Not sure why this is necessary, got it from
SystemPropertyPartition from
http://svn.apache.org/repos/asf/directory/sandbox/szoerner/syspropPartition.
       if (!ctx.getFilter().toString().contains("objectClass=subentry")) {

                       //If the searched DN equals this partition base
DN then return top level entry.
           if (this.suffixDn.equals(ctx.getDn())) {
               switch (ctx.getScope()) {
                       case OBJECT:
                               //Get the entry itself
                           ServerEntry entry = new
DefaultServerEntry(//Some params);
                           return new BaseEntryFilteringCursor(new
SingletonCursor<ServerEntry>(entry), ctx);

                       case ONELEVEL:
                               //Get all entries directly below the
top level entry
                               ListCursor<ServerEntry> listOneLevel
=
new ListCursor<ServerEntry>(listOfEntries);
                               return new
BaseEntryFilteringCursor(listOneLevel, ctx);

                       case SUBTREE:
                                               //Return all entries
in
the data store that match the searched DN
                       ListCursor<ServerEntry> listSubTree = new
ListCursor<ServerEntry>(someEntries);
                           return new
BaseEntryFilteringCursor(listSubTree, ctx);
               }
           }
                       else {

               //We have to look for another entry in the data store

                               ServerEntry entry = findEntry(ctx.getDn());

                               switch (ctx.getScope()) {
                                       case OBJECT:
                                               //Return the entry
itself.
                                               return new
BaseEntryFilteringCursor(new SingletonCursor<ServerEntry>(entry),
ctx);
                                       case ONELEVEL:
                                               //Return all entries
directly below the entry found.
                                               ListCursor<ServerEntry>
listOneLevel = new ListCursor<ServerEntry>(getChildren(entry));
                                               return new
BaseEntryFilteringCursor(listOneLevel, ctx);
                                       case SUBTREE:
                                               //Return all entries
below 'entry' that match the base dn.
                                               ListCursor<ServerEntry>
list = new ListCursor<ServerEntry>(getAllChildren(entry));
                                               return new
BaseEntryFilteringCursor(list, ctx);
                               }
           }
       }

               // Otherwise return an empty result
               return new BaseEntryFilteringCursor(new
EmptyCursor<ServerEntry>(), ctx);
       }


Do you have any examples of the Subtree level search? Whenever I
return some data on the subtree case, I get a lot of errors on my
ApacheDS Server about entries not found. If I don't write any code for
the subtree case, then all works (that is weird). However I need to
implement it since I want to be able to perform subtree searches.

Sorry for my questions, I'm starting with ApacheDS and I think is
great, but there are lot of things I still have to learn.

Thank you,

LUIS JAVIER MENDEZ
Developer

O +506 2290 1960
Skype:  luis.javier.06

SEARCH TECHNOLOGIES
THE EXPERT IN THE SEARCH SPACE
www.searchtechnologies.com
Mime
View raw message