directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kiran Ayyagari <kayyag...@apache.org>
Subject Re: Filtering entries on a custom partition
Date Fri, 29 Apr 2011 16:12:23 GMT
On Fri, Apr 29, 2011 at 9:08 PM, Stefan Seelmann <seelmann@apache.org> wrote:
> 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.
>
to put it simply, your search implementation requires lot more
evaluations to consider if an entry matches the given search
criteria. One way to solve this is to extend AbstractXdbmPartition
(don't remember the name of the same in version 1.5.5 but take a look
at the JdbmPartition that will give you the idea).

Once you implement the necessary methods the search will be
automatically taken care of.

Take a look at the DefaultSearchEngine class to see how this search is
performed and returns the entries. Then take a look at the
BaseEntryFilteringCursor class to see way attributes are filtered

Having said this let us know if your requirement doesn't fit into the
model of xdbm/JdbmPartition architecture, and if you provide more
details that will help us to understand better.

> 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
>



-- 
Kiran Ayyagari

Mime
View raw message