Java Code Examples for org.apache.directory.api.ldap.model.message.ResultCodeEnum#ALIAS_DEREFERENCING_PROBLEM

The following examples show how to use org.apache.directory.api.ldap.model.message.ResultCodeEnum#ALIAS_DEREFERENCING_PROBLEM . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LdapAliasDereferencingException.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new instance of LdapAliasDereferencingException.
 */
public LdapAliasDereferencingException()
{
    super( ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM, null );
}
 
Example 2
Source File: SearchRequestHandler.java    From MyVirtualDirectory with Apache License 2.0 4 votes vote down vote up
/**
 * Handles processing with referrals without ManageDsaIT decorator.
 */
public void handleException( LdapSession session, ResultResponseRequest req, Exception e )
{
    LdapResult result = req.getResultResponse().getLdapResult();
    Exception cause = null;

    /*
     * Set the result code or guess the best option.
     */
    ResultCodeEnum code;

    if ( e instanceof CursorClosedException )
    {
        cause = ( Exception ) ( ( CursorClosedException ) e ).getCause();

        if ( cause == null )
        {
            cause = e;
        }
    }
    else
    {
        cause = e;
    }

    if ( cause instanceof LdapOperationException )
    {
        code = ( ( LdapOperationException ) cause ).getResultCode();
    }
    else
    {
        code = ResultCodeEnum.getBestEstimate( cause, req.getType() );
    }

    result.setResultCode( code );

    /*
     * Setup the error message to put into the request and put entire
     * exception into the message if we are in debug mode.  Note we
     * embed the result code name into the message.
     */
    String msg = code.toString() + ": failed for " + req + ": " + cause.getLocalizedMessage();

    if ( IS_DEBUG )
    {
        LOG.debug( msg, cause );
        msg += ":\n" + ExceptionUtils.getStackTrace( cause );
    }

    result.setDiagnosticMessage( msg );

    if ( cause instanceof LdapOperationException )
    {
        LdapOperationException ne = ( LdapOperationException ) cause;

        // Add the matchedDN if necessary
        boolean setMatchedDn = code == ResultCodeEnum.NO_SUCH_OBJECT || code == ResultCodeEnum.ALIAS_PROBLEM
            || code == ResultCodeEnum.INVALID_DN_SYNTAX || code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM;

        if ( ( ne.getResolvedDn() != null ) && setMatchedDn )
        {
            result.setMatchedDn( ne.getResolvedDn() );
        }
    }

    session.getIoSession().write( req.getResultResponse() );
}
 
Example 3
Source File: SearchRequestHandler.java    From MyVirtualDirectory with Apache License 2.0 4 votes vote down vote up
/**
 * Handles processing with referrals without ManageDsaIT decorator.
 */
public void handleException( LdapSession session, ResultResponseRequest req, Exception e )
{
    LdapResult result = req.getResultResponse().getLdapResult();
    Exception cause = null;

    /*
     * Set the result code or guess the best option.
     */
    ResultCodeEnum code;

    if ( e instanceof CursorClosedException )
    {
        cause = ( Exception ) ( ( CursorClosedException ) e ).getCause();

        if ( cause == null )
        {
            cause = e;
        }
    }
    else
    {
        cause = e;
    }

    if ( cause instanceof LdapOperationException )
    {
        code = ( ( LdapOperationException ) cause ).getResultCode();
    }
    else
    {
        code = ResultCodeEnum.getBestEstimate( cause, req.getType() );
    }

    result.setResultCode( code );

    /*
     * Setup the error message to put into the request and put entire
     * exception into the message if we are in debug mode.  Note we
     * embed the result code name into the message.
     */
    String msg = code.toString() + ": failed for " + req + ": " + cause.getLocalizedMessage();

    if ( IS_DEBUG )
    {
        LOG.debug( msg, cause );
        msg += ":\n" + ExceptionUtils.getStackTrace( cause );
    }

    result.setDiagnosticMessage( msg );

    if ( cause instanceof LdapOperationException )
    {
        LdapOperationException ne = ( LdapOperationException ) cause;

        // Add the matchedDN if necessary
        boolean setMatchedDn = code == ResultCodeEnum.NO_SUCH_OBJECT || code == ResultCodeEnum.ALIAS_PROBLEM
            || code == ResultCodeEnum.INVALID_DN_SYNTAX || code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM;

        if ( ( ne.getResolvedDn() != null ) && setMatchedDn )
        {
            result.setMatchedDn( ne.getResolvedDn() );
        }
    }

    session.getIoSession().write( req.getResultResponse() );
}
 
Example 4
Source File: LdapAliasDereferencingException.java    From directory-ldap-api with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new instance of LdapAliasDereferencingException.
 *
 * @param message The exception message
 */
public LdapAliasDereferencingException( String message )
{
    super( ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM, message );
}