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
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-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 newRecursiveAttributeHandler
with the supplied ldap, search attribute, and merge attributes.RecursiveSearchResultHandler(java.lang.String searchAttr, java.lang.String[] mergeAttrs)
Creates a newRecursiveAttributeHandler
with 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.String
getSearchAttribute()
Returns the attribute name that will be recursively searched on.Ldap
getSearchResultLdap()
Gets theLdap
used by the search operation invoking this handler.protected void
initalizeReturnAttributes()
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 suppliedList
and 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 suppliedNamingEnumeration
and return a List of those results.void
setMergeAttributes(java.lang.String[] s)
Sets the attribute name that will be merged by the recursive search.void
setSearchAttribute(java.lang.String s)
Sets the attribute name that will be recursively searched on.void
setSearchResultLdap(Ldap l)
Sets theLdap
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.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 newRecursiveAttributeHandler
with the supplied search attribute and merge attributes.- Parameters:
searchAttr
-String
mergeAttrs
-String[]
-
RecursiveSearchResultHandler
public RecursiveSearchResultHandler(Ldap l, java.lang.String searchAttr, java.lang.String[] mergeAttrs)
Creates a newRecursiveAttributeHandler
with the supplied ldap, search attribute, and merge attributes.- Parameters:
l
-Ldap
searchAttr
-String
mergeAttrs
-String[]
-
-
Method Detail
-
getSearchResultLdap
public Ldap getSearchResultLdap()
Gets theLdap
used by the search operation invoking this handler.- Specified by:
getSearchResultLdap
in interfaceExtendedSearchResultHandler
- Returns:
Ldap
-
setSearchResultLdap
public void setSearchResultLdap(Ldap l)
Sets theLdap
used by the search operation invoking this handler.- Specified by:
setSearchResultLdap
in interfaceExtendedSearchResultHandler
- Parameters:
l
-Ldap
-
getSearchAttribute
public java.lang.String getSearchAttribute()
Returns the attribute name that will be recursively searched on.- Returns:
String
attribute 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 suppliedNamingEnumeration
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 interfaceResultHandler<javax.naming.directory.SearchResult,javax.naming.directory.SearchResult>
- Overrides:
process
in classAbstractResultHandler<javax.naming.directory.SearchResult,javax.naming.directory.SearchResult>
- Parameters:
sc
-SearchCriteria
used to find enumerationen
-NamingEnumeration
LDAP 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 suppliedList
and return a List of those results. The results are unaltered and the dn is ignored.- Specified by:
process
in interfaceResultHandler<javax.naming.directory.SearchResult,javax.naming.directory.SearchResult>
- Overrides:
process
in classAbstractResultHandler<javax.naming.directory.SearchResult,javax.naming.directory.SearchResult>
- Parameters:
sc
-SearchCriteria
used to find enumerationl
-List
LDAP results- Returns:
List
- LDAP results- Throws:
javax.naming.NamingException
- if the LDAP returns an error
-
-