Class PagedResultsClient
- java.lang.Object
-
- org.ldaptive.AbstractFreezable
-
- org.ldaptive.AbstractOperationFactory<SearchRequest,SearchResponse>
-
- org.ldaptive.AbstractSearchOperationFactory
-
- org.ldaptive.control.util.PagedResultsClient
-
- All Implemented Interfaces:
ConnectionFactoryManager
,Freezable
public class PagedResultsClient extends AbstractSearchOperationFactory
Client that simplifies using the paged results control.
-
-
Field Summary
Fields Modifier and Type Field Description private int
resultSize
Results page size.-
Fields inherited from class org.ldaptive.AbstractOperationFactory
logger
-
-
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, freeze, getEntryHandlers, getReferenceHandlers, getSearchResultHandlers, setEntryHandlers, setReferenceHandlers, setSearchResultHandlers, toString
-
Methods inherited from class org.ldaptive.AbstractOperationFactory
getConnectionFactory, getControlHandlers, getExceptionHandler, getIntermediateResponseHandlers, getReferralHandlers, getRequestHandlers, getResultHandlers, getThrowCondition, getUnsolicitedNotificationHandlers, initializeOperation, setConnectionFactory, setControlHandlers, setExceptionHandler, setIntermediateResponseHandlers, setReferralHandlers, setRequestHandlers, setResultHandlers, setThrowCondition, setUnsolicitedNotificationHandlers
-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, isFrozen
-
-
-
-
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
-
-