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:
java.util.function.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=org
This handler should only be used with theSearchOperation.execute()
method since it leverages the connection to make further searches.- Author:
- Middleware Services
-
-
Field Summary
-
Fields inherited from class org.ldaptive.handler.AbstractEntryHandler
logger
-
-
Constructor Summary
Constructors Constructor Description RecursiveResultHandler()
Default constructor.RecursiveResultHandler(java.lang.String searchAttr, java.lang.String... mergeAttrs)
Creates a new recursive entry handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SearchResponse
apply(SearchResponse response)
boolean
equals(java.lang.Object o)
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.void
handleEntry(LdapEntry entry)
Handle the entry.int
hashCode()
protected void
initializeReturnAttributes()
Initializes the return attributes array.void
setMergeAttributes(java.lang.String... mergeAttrs)
Sets the attribute name that will be merged by the recursive search.void
setSearchAttribute(java.lang.String name)
Sets the attribute name that will be recursively searched on.java.lang.String
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
-
-
-
-
Constructor Detail
-
RecursiveResultHandler
public RecursiveResultHandler()
Default constructor.
-
RecursiveResultHandler
public RecursiveResultHandler(java.lang.String searchAttr, java.lang.String... mergeAttrs)
Creates a new recursive entry handler.- Parameters:
searchAttr
- attribute to search onmergeAttrs
- attribute names to merge
-
-
Method Detail
-
getSearchAttribute
public java.lang.String getSearchAttribute()
Returns the attribute name that will be recursively searched on.- Returns:
- attribute name
-
setSearchAttribute
public void setSearchAttribute(java.lang.String name)
Sets the attribute name that will be recursively searched on.- Parameters:
name
- of the search attribute
-
getMergeAttributes
public java.lang.String[] getMergeAttributes()
Returns the attribute names that will be merged by the recursive search.- Returns:
- attribute names
-
setMergeAttributes
public void setMergeAttributes(java.lang.String... mergeAttrs)
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
public SearchResponse apply(SearchResponse response)
- Specified by:
apply
in interfacejava.util.function.Function<SearchResponse,SearchResponse>
-
handleEntry
public void handleEntry(LdapEntry entry)
Description copied from class:AbstractEntryHandler
Handle the entry.- Overrides:
handleEntry
in classAbstractEntryHandler<SearchResponse>
- Parameters:
entry
- to handle
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classAbstractEntryHandler<SearchResponse>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in classAbstractEntryHandler<SearchResponse>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-