edu.vt.middleware.ldap.handler
Class RecursiveSearchResultHandler

java.lang.Object
  extended by edu.vt.middleware.ldap.handler.AbstractResultHandler<T,T>
      extended by edu.vt.middleware.ldap.handler.CopyResultHandler<SearchResult>
          extended by edu.vt.middleware.ldap.handler.CopySearchResultHandler
              extended by edu.vt.middleware.ldap.handler.RecursiveSearchResultHandler
All Implemented Interfaces:
ExtendedSearchResultHandler, ResultHandler<SearchResult,SearchResult>, SearchResultHandler

public class RecursiveSearchResultHandler
extends CopySearchResultHandler
implements ExtendedSearchResultHandler

RecursiveSearchResultHandler recursively searches based on a supplied attribute and merges those results into the original result set. For the following LDIF:

   dn: uugid=group1,ou=groups,dc=vt,dc=edu
   uugid: group1
   member: uugid=group2,ou=groups,dc=vt,dc=edu

   dn: uugid=group2,ou=groups,dc=vt,dc=edu
   uugid: group2
 

With the following code:

   RecursiveSearchResultHandler rsh = new RecurseSearchResultHandler(
     ldap, "member", new String[]{"uugid"});
 

Will produce this result for the query (uugid=group1):

   dn: uugid=group1,ou=groups,dc=vt,dc=edu
   uugid: group1
   uugid: group2
   member: uugid=group2,ou=groups,dc=vt,dc=edu
 

Version:
$Revision: 1330 $ $Date: 2010-05-23 18:10:53 -0400 (Sun, 23 May 2010) $
Author:
Middleware Services

Field Summary
 
Fields inherited from class edu.vt.middleware.ldap.handler.AbstractResultHandler
logger
 
Constructor Summary
RecursiveSearchResultHandler()
          Default constructor.
RecursiveSearchResultHandler(Ldap l, String searchAttr, String[] mergeAttrs)
          Creates a new RecursiveAttributeHandler with the supplied ldap, search attribute, and merge attributes.
RecursiveSearchResultHandler(String searchAttr, String[] mergeAttrs)
          Creates a new RecursiveAttributeHandler with the supplied search attribute and merge attributes.
 
Method Summary
 String[] getMergeAttributes()
          Returns the attribute names that will be merged by the recursive search.
 String getSearchAttribute()
          Returns the attribute name that will be recursively searched on.
 Ldap getSearchResultLdap()
          Gets the Ldap used by the search operation invoking this handler.
protected  void initalizeReturnAttributes()
          Initializes the return attributes array.
 List<SearchResult> process(SearchCriteria sc, List<? extends SearchResult> l)
          This will enumerate through the supplied List and return a List of those results.
 List<SearchResult> process(SearchCriteria sc, NamingEnumeration<? extends SearchResult> en, Class<?>[] ignore)
          This will enumerate through the supplied NamingEnumeration and return a List of those results.
 void setMergeAttributes(String[] s)
          Sets the attribute name that will be merged by the recursive search.
 void setSearchAttribute(String s)
          Sets the attribute name that will be recursively searched on.
 void setSearchResultLdap(Ldap l)
          Sets the Ldap used by the search operation invoking this handler.
 
Methods inherited from class edu.vt.middleware.ldap.handler.CopySearchResultHandler
getAttributeHandler, processAttributes, processDn, processResult, setAttributeHandler
 
Methods inherited from class edu.vt.middleware.ldap.handler.AbstractResultHandler
process
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.vt.middleware.ldap.handler.SearchResultHandler
getAttributeHandler, setAttributeHandler
 
Methods inherited from interface edu.vt.middleware.ldap.handler.ResultHandler
process
 

Constructor Detail

RecursiveSearchResultHandler

public RecursiveSearchResultHandler()
Default constructor.


RecursiveSearchResultHandler

public RecursiveSearchResultHandler(String searchAttr,
                                    String[] mergeAttrs)
Creates a new RecursiveAttributeHandler with the supplied search attribute and merge attributes.

Parameters:
searchAttr - String
mergeAttrs - String[]

RecursiveSearchResultHandler

public RecursiveSearchResultHandler(Ldap l,
                                    String searchAttr,
                                    String[] mergeAttrs)
Creates a new RecursiveAttributeHandler with the supplied ldap, search attribute, and merge attributes.

Parameters:
l - Ldap
searchAttr - String
mergeAttrs - String[]
Method Detail

getSearchResultLdap

public Ldap getSearchResultLdap()
Gets the Ldap used by the search operation invoking this handler.

Specified by:
getSearchResultLdap in interface ExtendedSearchResultHandler
Returns:
Ldap

setSearchResultLdap

public void setSearchResultLdap(Ldap l)
Sets the Ldap used by the search operation invoking this handler.

Specified by:
setSearchResultLdap in interface ExtendedSearchResultHandler
Parameters:
l - Ldap

getSearchAttribute

public String getSearchAttribute()
Returns the attribute name that will be recursively searched on.

Returns:
String attribute name

setSearchAttribute

public void setSearchAttribute(String s)
Sets the attribute name that will be recursively searched on.

Parameters:
s - String

getMergeAttributes

public String[] getMergeAttributes()
Returns the attribute names that will be merged by the recursive search.

Returns:
String[] attribute names

setMergeAttributes

public void setMergeAttributes(String[] s)
Sets the attribute name that will be merged by the recursive search.

Parameters:
s - String[]

initalizeReturnAttributes

protected void initalizeReturnAttributes()
Initializes the return attributes array. Must be called after both searchAttribute and mergeAttributes have been set.


process

public List<SearchResult> process(SearchCriteria sc,
                                  NamingEnumeration<? extends SearchResult> en,
                                  Class<?>[] ignore)
                           throws NamingException
This will enumerate through the supplied NamingEnumeration and return a List of those results. The results are unaltered and the dn is ignored. Any exceptions passed into this method will be ignored and results will be returned as if no exception occurred.

Specified by:
process in interface ResultHandler<SearchResult,SearchResult>
Overrides:
process in class AbstractResultHandler<SearchResult,SearchResult>
Parameters:
sc - SearchCriteria used to find enumeration
en - NamingEnumeration LDAP results
ignore - Class[] of exception types to ignore
Returns:
List - LDAP results
Throws:
NamingException - if the LDAP returns an error

process

public List<SearchResult> process(SearchCriteria sc,
                                  List<? extends SearchResult> l)
                           throws NamingException
This will enumerate through the supplied List and return a List of those results. The results are unaltered and the dn is ignored.

Specified by:
process in interface ResultHandler<SearchResult,SearchResult>
Overrides:
process in class AbstractResultHandler<SearchResult,SearchResult>
Parameters:
sc - SearchCriteria used to find enumeration
l - List LDAP results
Returns:
List - LDAP results
Throws:
NamingException - if the LDAP returns an error


Copyright © 2003-2010 Virginia Tech. All Rights Reserved.