Search in sources :

Example 1 with LdapConnectionTimeOutException

use of org.apache.directory.ldap.client.api.exception.LdapConnectionTimeOutException in project directory-ldap-api by apache.

the class SearchCursorImpl method next.

/**
 * {@inheritDoc}
 */
@Override
public boolean next() throws LdapException, CursorException {
    if (done) {
        return false;
    }
    try {
        if (future.isCancelled()) {
            response = null;
            done = true;
            return false;
        }
        response = future.get(timeout, timeUnit);
    } catch (Exception e) {
        LdapException ldapException = new LdapException(LdapNetworkConnection.NO_RESPONSE_ERROR, e);
        // Send an abandon request
        if (!future.isCancelled()) {
            future.cancel(true);
        }
        // close the cursor
        try {
            close(ldapException);
        } catch (IOException ioe) {
            throw new LdapException(ioe.getMessage(), ioe);
        }
        throw ldapException;
    }
    if (response == null) {
        future.cancel(true);
        throw new LdapConnectionTimeOutException(LdapNetworkConnection.TIME_OUT_ERROR);
    }
    done = response instanceof SearchResultDone;
    if (done) {
        searchDoneResp = (SearchResultDone) response;
        response = null;
    }
    return !done;
}
Also used : SearchResultDone(org.apache.directory.api.ldap.model.message.SearchResultDone) IOException(java.io.IOException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) IOException(java.io.IOException) LdapConnectionTimeOutException(org.apache.directory.ldap.client.api.exception.LdapConnectionTimeOutException) CursorException(org.apache.directory.api.ldap.model.cursor.CursorException) InvalidCursorPositionException(org.apache.directory.api.ldap.model.cursor.InvalidCursorPositionException) LdapReferralException(org.apache.directory.api.ldap.model.exception.LdapReferralException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnectionTimeOutException(org.apache.directory.ldap.client.api.exception.LdapConnectionTimeOutException)

Aggregations

IOException (java.io.IOException)1 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)1 InvalidCursorPositionException (org.apache.directory.api.ldap.model.cursor.InvalidCursorPositionException)1 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)1 LdapReferralException (org.apache.directory.api.ldap.model.exception.LdapReferralException)1 SearchResultDone (org.apache.directory.api.ldap.model.message.SearchResultDone)1 LdapConnectionTimeOutException (org.apache.directory.ldap.client.api.exception.LdapConnectionTimeOutException)1