Package edu.vt.middleware.ldap.handler
Class RecursiveSearchResultHandler
- java.lang.Object
-
- edu.vt.middleware.ldap.handler.AbstractResultHandler<T,T>
-
- edu.vt.middleware.ldap.handler.CopyResultHandler<javax.naming.directory.SearchResult>
-
- edu.vt.middleware.ldap.handler.CopySearchResultHandler
-
- edu.vt.middleware.ldap.handler.RecursiveSearchResultHandler
-
- All Implemented Interfaces:
ExtendedSearchResultHandler,ResultHandler<javax.naming.directory.SearchResult,javax.naming.directory.SearchResult>,SearchResultHandler
public class RecursiveSearchResultHandler extends CopySearchResultHandler implements ExtendedSearchResultHandler
RecursiveSearchResultHandlerrecursively 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-24 00:10:53 +0200 (Mon, 24 May 2010) $
- Author:
- Middleware Services
-
-
Field Summary
-
Fields inherited from class edu.vt.middleware.ldap.handler.AbstractResultHandler
logger
-
-
Constructor Summary
Constructors Constructor Description RecursiveSearchResultHandler()Default constructor.RecursiveSearchResultHandler(Ldap l, java.lang.String searchAttr, java.lang.String[] mergeAttrs)Creates a newRecursiveAttributeHandlerwith the supplied ldap, search attribute, and merge attributes.RecursiveSearchResultHandler(java.lang.String searchAttr, java.lang.String[] mergeAttrs)Creates a newRecursiveAttributeHandlerwith the supplied search attribute and merge attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]getMergeAttributes()Returns the attribute names that will be merged by the recursive search.java.lang.StringgetSearchAttribute()Returns the attribute name that will be recursively searched on.LdapgetSearchResultLdap()Gets theLdapused by the search operation invoking this handler.protected voidinitalizeReturnAttributes()Initializes the return attributes array.java.util.List<javax.naming.directory.SearchResult>process(SearchCriteria sc, java.util.List<? extends javax.naming.directory.SearchResult> l)This will enumerate through the suppliedListand return a List of those results.java.util.List<javax.naming.directory.SearchResult>process(SearchCriteria sc, javax.naming.NamingEnumeration<? extends javax.naming.directory.SearchResult> en, java.lang.Class<?>[] ignore)This will enumerate through the suppliedNamingEnumerationand return a List of those results.voidsetMergeAttributes(java.lang.String[] s)Sets the attribute name that will be merged by the recursive search.voidsetSearchAttribute(java.lang.String s)Sets the attribute name that will be recursively searched on.voidsetSearchResultLdap(Ldap l)Sets theLdapused 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.ResultHandler
process
-
Methods inherited from interface edu.vt.middleware.ldap.handler.SearchResultHandler
getAttributeHandler, setAttributeHandler
-
-
-
-
Constructor Detail
-
RecursiveSearchResultHandler
public RecursiveSearchResultHandler()
Default constructor.
-
RecursiveSearchResultHandler
public RecursiveSearchResultHandler(java.lang.String searchAttr, java.lang.String[] mergeAttrs)Creates a newRecursiveAttributeHandlerwith the supplied search attribute and merge attributes.- Parameters:
searchAttr-StringmergeAttrs-String[]
-
RecursiveSearchResultHandler
public RecursiveSearchResultHandler(Ldap l, java.lang.String searchAttr, java.lang.String[] mergeAttrs)
Creates a newRecursiveAttributeHandlerwith the supplied ldap, search attribute, and merge attributes.- Parameters:
l-LdapsearchAttr-StringmergeAttrs-String[]
-
-
Method Detail
-
getSearchResultLdap
public Ldap getSearchResultLdap()
Gets theLdapused by the search operation invoking this handler.- Specified by:
getSearchResultLdapin interfaceExtendedSearchResultHandler- Returns:
Ldap
-
setSearchResultLdap
public void setSearchResultLdap(Ldap l)
Sets theLdapused by the search operation invoking this handler.- Specified by:
setSearchResultLdapin interfaceExtendedSearchResultHandler- Parameters:
l-Ldap
-
getSearchAttribute
public java.lang.String getSearchAttribute()
Returns the attribute name that will be recursively searched on.- Returns:
Stringattribute name
-
setSearchAttribute
public void setSearchAttribute(java.lang.String s)
Sets the attribute name that will be recursively searched on.- Parameters:
s-String
-
getMergeAttributes
public java.lang.String[] getMergeAttributes()
Returns the attribute names that will be merged by the recursive search.- Returns:
String[]attribute names
-
setMergeAttributes
public void setMergeAttributes(java.lang.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 java.util.List<javax.naming.directory.SearchResult> process(SearchCriteria sc, javax.naming.NamingEnumeration<? extends javax.naming.directory.SearchResult> en, java.lang.Class<?>[] ignore) throws javax.naming.NamingException
This will enumerate through the suppliedNamingEnumerationand 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:
processin interfaceResultHandler<javax.naming.directory.SearchResult,javax.naming.directory.SearchResult>- Overrides:
processin classAbstractResultHandler<javax.naming.directory.SearchResult,javax.naming.directory.SearchResult>- Parameters:
sc-SearchCriteriaused to find enumerationen-NamingEnumerationLDAP resultsignore-Class[]of exception types to ignore- Returns:
List- LDAP results- Throws:
javax.naming.NamingException- if the LDAP returns an error
-
process
public java.util.List<javax.naming.directory.SearchResult> process(SearchCriteria sc, java.util.List<? extends javax.naming.directory.SearchResult> l) throws javax.naming.NamingException
This will enumerate through the suppliedListand return a List of those results. The results are unaltered and the dn is ignored.- Specified by:
processin interfaceResultHandler<javax.naming.directory.SearchResult,javax.naming.directory.SearchResult>- Overrides:
processin classAbstractResultHandler<javax.naming.directory.SearchResult,javax.naming.directory.SearchResult>- Parameters:
sc-SearchCriteriaused to find enumerationl-ListLDAP results- Returns:
List- LDAP results- Throws:
javax.naming.NamingException- if the LDAP returns an error
-
-