Class PagedResultsClient
- java.lang.Object
-
- org.ldaptive.AbstractSearchOperationFactory
-
- org.ldaptive.control.util.PagedResultsClient
-
- All Implemented Interfaces:
ConnectionFactoryManager
public class PagedResultsClient extends AbstractSearchOperationFactory
Client that simplifies using the paged results control.
-
-
Field Summary
Fields Modifier and Type Field Description protected Logger
logger
Logger for this class.private int
resultSize
Results page size.
-
Constructor Summary
Constructors Constructor Description PagedResultsClient(ConnectionFactory cf, int size)
Creates a new paged results client.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SearchResponse
execute(SearchRequest request)
Performs a search operation with thePagedResultsControl
.SearchResponse
execute(SearchRequest request, CookieManager manager)
Performs a search operation with thePagedResultsControl
.SearchResponse
execute(SearchRequest request, SearchResponse result)
Performs a search operation with thePagedResultsControl
.SearchResponse
executeToCompletion(SearchRequest request)
Performs a search operation with thePagedResultsControl
.SearchResponse
executeToCompletion(SearchRequest request, CookieManager manager)
Performs a search operation with thePagedResultsControl
.protected byte[]
getPagedResultsCookie(SearchResponse result)
Returns the paged results cookie in the supplied response or null if no cookie exists.PagedResultsControl
getResponseControl(SearchResponse result)
Returns thePagedResultsControl
in the supplied response.boolean
hasMore(SearchResponse result)
Returns whetherexecute(SearchRequest, SearchResponse)
can be invoked again.-
Methods inherited from class org.ldaptive.AbstractSearchOperationFactory
createSearchOperation, createSearchOperation, getConnectionFactory, getControlHandlers, getEntryHandlers, getExceptionHandler, getIntermediateResponseHandlers, getReferenceHandlers, getReferralHandlers, getRequestHandlers, getResultHandlers, getSearchResultHandlers, getThrowCondition, getUnsolicitedNotificationHandlers, setConnectionFactory, setControlHandlers, setEntryHandlers, setExceptionHandler, setIntermediateResponseHandlers, setReferenceHandlers, setReferralHandlers, setRequestHandlers, setResultHandlers, setSearchResultHandlers, setThrowCondition, setUnsolicitedNotificationHandlers
-
-
-
-
Field Detail
-
logger
protected final Logger logger
Logger for this class.
-
resultSize
private final int resultSize
Results page size.
-
-
Constructor Detail
-
PagedResultsClient
public PagedResultsClient(ConnectionFactory cf, int size)
Creates a new paged results client.- Parameters:
cf
- to get a connection fromsize
- the results page size to request
-
-
Method Detail
-
execute
public SearchResponse execute(SearchRequest request) throws LdapException
Performs a search operation with thePagedResultsControl
. The supplied request is modified in the following way:- Parameters:
request
- search request to execute- Returns:
- search operation response
- Throws:
LdapException
- if the search fails
-
execute
public SearchResponse execute(SearchRequest request, SearchResponse result) throws LdapException
Performs a search operation with thePagedResultsControl
. The supplied request is modified in the following way:AbstractRequestMessage.setControls( org.ldaptive.control.RequestControl...)
is invoked withPagedResultsControl
The cookie is extracted from the supplied response and replayed in the request.
- Parameters:
request
- search request to executeresult
- of a previous paged results operation- Returns:
- search operation response
- Throws:
LdapException
- if the search fails
-
execute
public SearchResponse execute(SearchRequest request, CookieManager manager) throws LdapException
Performs a search operation with thePagedResultsControl
. The supplied request is modified in the following way:AbstractRequestMessage.setControls( org.ldaptive.control.RequestControl...)
is invoked withPagedResultsControl
The cookie used in the request is read from the cookie manager and written to the cookie manager after a successful search, if the response contains a cookie.
- Parameters:
request
- search request to executemanager
- for reading and writing cookies- Returns:
- search operation response
- Throws:
LdapException
- if the search fails
-
hasMore
public boolean hasMore(SearchResponse result)
Returns whetherexecute(SearchRequest, SearchResponse)
can be invoked again.- Parameters:
result
- of a previous paged results operation- Returns:
- whether more paged search results can be retrieved from the server
-
executeToCompletion
public SearchResponse executeToCompletion(SearchRequest request) throws LdapException
Performs a search operation with thePagedResultsControl
. The supplied request is modified in the following way:AbstractRequestMessage.setControls( RequestControl...)
is invoked withPagedResultsControl
and any other controls previously set on the search request.
This method will continue to execute search operations until all paged search results have been retrieved from the server. The returned response contains the response data of the last paged result operation plus the entries and references returned by all previous search operations.
- Parameters:
request
- search request to execute- Returns:
- search operation response of the last paged result operation
- Throws:
LdapException
- if the search fails
-
executeToCompletion
public SearchResponse executeToCompletion(SearchRequest request, CookieManager manager) throws LdapException
Performs a search operation with thePagedResultsControl
. The supplied request is modified in the following way:AbstractRequestMessage.setControls( RequestControl...)
is invoked withPagedResultsControl
and any other controls previously set on the search request.
This method will continue to execute search operations until all paged search results have been retrieved from the server. The returned response contains the response data of the last paged result operation plus the entries and references returned by all previous search operations.
The cookie used for each request is read from the cookie manager and written to the cookie manager after a successful search, if the response contains a cookie.
This method builds a synthetic response which contains the results of all search operations. Any ordering imposed by result handlers may be lost by this process.
- Parameters:
request
- search request to executemanager
- for reading and writing cookies- Returns:
- search operation response of the last paged result operation
- Throws:
LdapException
- if the search fails
-
getResponseControl
public PagedResultsControl getResponseControl(SearchResponse result)
Returns thePagedResultsControl
in the supplied response.- Parameters:
result
- to inspect for a response control- Returns:
- paged results response control or null if it does not exist
-
getPagedResultsCookie
protected byte[] getPagedResultsCookie(SearchResponse result)
Returns the paged results cookie in the supplied response or null if no cookie exists.- Parameters:
result
- of a previous paged results operation- Returns:
- paged results cookie or null
-
-