Search in sources :

Example 6 with SearchResultReferenceProtocolOp

use of com.unboundid.ldap.protocol.SearchResultReferenceProtocolOp in project ldapsdk by pingidentity.

the class LDAPListenerClientConnection method sendSearchResultReference.

/**
 * Sends a search result reference message to the client with the provided
 * information.
 *
 * @param  messageID   The message ID for the LDAP message to send to the
 *                     client.  It must match the message ID of the associated
 *                     search request.
 * @param  protocolOp  The search result reference protocol op to include in
 *                     the LDAP message to send to the client.
 * @param  controls    The set of controls to include in the response message.
 *                     It may be empty or {@code null} if no controls should
 *                     be included.
 *
 * @throws  LDAPException  If a problem occurs while attempting to send the
 *                         provided response message.  If an exception is
 *                         thrown, then the client connection will have been
 *                         terminated.
 */
public void sendSearchResultReference(final int messageID, @NotNull final SearchResultReferenceProtocolOp protocolOp, @Nullable final Control... controls) throws LDAPException {
    if (searchReferenceTransformers.isEmpty()) {
        sendMessage(new LDAPMessage(messageID, protocolOp, controls));
    } else {
        Control[] c;
        SearchResultReferenceProtocolOp op = protocolOp;
        if (controls == null) {
            c = EMPTY_CONTROL_ARRAY;
        } else {
            c = controls;
        }
        for (final SearchReferenceTransformer t : searchReferenceTransformers) {
            try {
                final ObjectPair<SearchResultReferenceProtocolOp, Control[]> p = t.transformReference(messageID, op, c);
                if (p == null) {
                    return;
                }
                op = p.getFirst();
                c = p.getSecond();
            } catch (final Exception e) {
                Debug.debugException(e);
                sendMessage(new LDAPMessage(messageID, protocolOp, c));
                throw new LDAPException(ResultCode.LOCAL_ERROR, ERR_CONN_SEARCH_REFERENCE_TRANSFORMER_EXCEPTION.get(t.getClass().getName(), String.valueOf(op), StaticUtils.getExceptionMessage(e)), e);
            }
        }
        sendMessage(new LDAPMessage(messageID, op, c));
    }
}
Also used : SearchResultReferenceProtocolOp(com.unboundid.ldap.protocol.SearchResultReferenceProtocolOp) Control(com.unboundid.ldap.sdk.Control) LDAPException(com.unboundid.ldap.sdk.LDAPException) LDAPMessage(com.unboundid.ldap.protocol.LDAPMessage) LDAPRuntimeException(com.unboundid.ldap.sdk.LDAPRuntimeException) LDAPException(com.unboundid.ldap.sdk.LDAPException) IOException(java.io.IOException)

Aggregations

SearchResultReferenceProtocolOp (com.unboundid.ldap.protocol.SearchResultReferenceProtocolOp)6 LDAPException (com.unboundid.ldap.sdk.LDAPException)3 LDAPMessage (com.unboundid.ldap.protocol.LDAPMessage)2 SearchResultDoneProtocolOp (com.unboundid.ldap.protocol.SearchResultDoneProtocolOp)2 Control (com.unboundid.ldap.sdk.Control)2 SearchRequest (com.unboundid.ldap.sdk.SearchRequest)2 SearchResultReference (com.unboundid.ldap.sdk.SearchResultReference)2 Test (org.testng.annotations.Test)2 SearchRequestProtocolOp (com.unboundid.ldap.protocol.SearchRequestProtocolOp)1 SearchResultEntryProtocolOp (com.unboundid.ldap.protocol.SearchResultEntryProtocolOp)1 Attribute (com.unboundid.ldap.sdk.Attribute)1 LDAPRuntimeException (com.unboundid.ldap.sdk.LDAPRuntimeException)1 SearchResultEntry (com.unboundid.ldap.sdk.SearchResultEntry)1 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)1 ManageDsaITRequestControl (com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)1 NotNull (com.unboundid.util.NotNull)1 Nullable (com.unboundid.util.Nullable)1 ObjectPair (com.unboundid.util.ObjectPair)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1