Class PagedResultsClient

    • Field Detail

      • 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 from
        size - the results page size to request
    • Method Detail

      • hasMore

        public boolean hasMore​(SearchResponse result)
        Returns whether execute(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 the PagedResultsControl. The supplied request is modified in the following way:

        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 the PagedResultsControl. The supplied request is modified in the following way:

        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 execute
        manager - 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 the PagedResultsControl 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
      • appendRequestControls

        private RequestControl[] appendRequestControls​(SearchRequest request,
                                                       byte[] cookie)
        Creates a new array of request controls which includes the paged results control. Any other request controls are included.
        Parameters:
        request - to read controls from
        cookie - to add to the paged results control or null
        Returns:
        array of request controls ready to be used in a search operation