Package org.ldaptive.handler
Class RecursiveResultHandler
java.lang.Object
org.ldaptive.transport.MessageFunctional<Q,S>
org.ldaptive.transport.MessageFunctional.Function<SearchRequest,SearchResponse,T,T>
org.ldaptive.handler.AbstractEntryHandler<SearchResponse>
org.ldaptive.handler.RecursiveResultHandler
- All Implemented Interfaces:
Function<SearchResponse,
,SearchResponse> SearchResultHandler
public class RecursiveResultHandler
extends AbstractEntryHandler<SearchResponse>
implements SearchResultHandler
This recursively searches based on a supplied attribute and merges those results into the original entry. For the
following LDIF:
dn: uugid=group1,ou=groups,dc=ldaptive,dc=org uugid: group1 member: uugid=group2,ou=groups,dc=ldaptive,dc=org dn: uugid=group2,ou=groups,dc=ldaptive,dc=org uugid: group2
With the following code:
RecursiveResultHandler reh = new RecursiveResultHandler("member", "uugid");
Will produce this result for the query (uugid=group1):
dn: uugid=group1,ou=groups,dc=ldaptive,dc=org uugid: group1 uugid: group2 member: uugid=group2,ou=groups,dc=ldaptive,dc=orgThis handler should only be used with the
SearchOperation.execute()
method since it leverages
the connection to make further searches.-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
hash code seed.private String[]
Attribute(s) to merge.private String[]
Attributes to return when searching, mergeAttributes + searchAttribute.private String
Attribute to recursively search on.Fields inherited from class org.ldaptive.handler.AbstractEntryHandler
logger
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.RecursiveResultHandler
(String searchAttr, String... mergeAttrs) Creates a new recursive entry handler. -
Method Summary
Modifier and TypeMethodDescriptionapply
(SearchResponse response) boolean
String[]
Returns the attribute names that will be merged by the recursive search.Returns the attribute name that will be recursively searched on.void
handleEntry
(LdapEntry entry) Handle the entry.int
hashCode()
protected void
Initializes the return attributes array.private void
readSearchAttribute
(LdapEntry entry, List<String> searchedDns) Reads the values ofsearchAttribute
from the supplied attributes and callsrecursiveSearch(java.lang.String, org.ldaptive.LdapEntry, java.util.List<java.lang.String>)
for each.private void
recursiveSearch
(String dn, LdapEntry entry, List<String> searchedDns) Recursively gets the attribute(s)mergeAttributes
for the supplied dn and adds the values to the supplied attributes.void
setMergeAttributes
(String... mergeAttrs) Sets the attribute name that will be merged by the recursive search.void
setSearchAttribute
(String name) Sets the attribute name that will be recursively searched on.toString()
Methods inherited from class org.ldaptive.handler.AbstractEntryHandler
handleAttribute, handleAttributeName, handleAttributes, handleAttributeValue, handleAttributeValue, handleDn
Methods inherited from class org.ldaptive.transport.MessageFunctional
getConnection, getHandle, getRequest, setConnection, setHandle, setRequest
-
Field Details
-
HASH_CODE_SEED
private static final int HASH_CODE_SEEDhash code seed.- See Also:
-
searchAttribute
Attribute to recursively search on. -
mergeAttributes
Attribute(s) to merge. -
retAttrs
Attributes to return when searching, mergeAttributes + searchAttribute.
-
-
Constructor Details
-
RecursiveResultHandler
public RecursiveResultHandler()Default constructor. -
RecursiveResultHandler
Creates a new recursive entry handler.- Parameters:
searchAttr
- attribute to search onmergeAttrs
- attribute names to merge
-
-
Method Details
-
getSearchAttribute
Returns the attribute name that will be recursively searched on.- Returns:
- attribute name
-
setSearchAttribute
Sets the attribute name that will be recursively searched on.- Parameters:
name
- of the search attribute
-
getMergeAttributes
Returns the attribute names that will be merged by the recursive search.- Returns:
- attribute names
-
setMergeAttributes
Sets the attribute name that will be merged by the recursive search.- Parameters:
mergeAttrs
- attribute names to merge
-
initializeReturnAttributes
protected void initializeReturnAttributes()Initializes the return attributes array. Must be called after both searchAttribute and mergeAttributes have been set. -
apply
- Specified by:
apply
in interfaceFunction<SearchResponse,
SearchResponse>
-
handleEntry
Description copied from class:AbstractEntryHandler
Handle the entry.- Overrides:
handleEntry
in classAbstractEntryHandler<SearchResponse>
- Parameters:
entry
- to handle
-
readSearchAttribute
Reads the values ofsearchAttribute
from the supplied attributes and callsrecursiveSearch(java.lang.String, org.ldaptive.LdapEntry, java.util.List<java.lang.String>)
for each.- Parameters:
entry
- to readsearchedDns
- list of DNs whose attributes have been read
-
recursiveSearch
Recursively gets the attribute(s)mergeAttributes
for the supplied dn and adds the values to the supplied attributes.- Parameters:
dn
- to get attribute(s) forentry
- to merge withsearchedDns
- list of DNs that have been searched for
-
equals
- Overrides:
equals
in classAbstractEntryHandler<SearchResponse>
-
hashCode
public int hashCode()- Specified by:
hashCode
in classAbstractEntryHandler<SearchResponse>
-
toString
-