Package org.apache.directory.ldap.client.api.exception

Examples of org.apache.directory.ldap.client.api.exception.LdapException


           
            response = future.get( timeout, timeUnit );
        }
        catch ( Exception e )
        {
            LdapException ldapException = new LdapException( LdapConnection.NO_RESPONSE_ERROR );
            ldapException.initCause( e );

            // Send an abandon request
            if ( !future.isCancelled() )
            {
                future.cancel( true );
            }

            // close the cursor
            close( ldapException );
           
            throw ldapException;
        }

        if ( response == null )
        {
            future.cancel( true );

            throw new LdapException( LdapConnection.TIME_OUT_ERROR );
        }

        done = ( response instanceof SearchResultDone );

        if ( done )
View Full Code Here


                }
                catch ( Exception e )
                {
                    String msg = "Failed to initialize the SSL context";
                    LOG.error( msg, e );
                    throw new LdapException( msg, e );
                }
            }

            // Add an executor so that this connection can be used
            // for handling more than one request (mainly because
View Full Code Here

           
            if ( addResponse == null )
            {
                // We didn't received anything : this is an error
                LOG.error( "Add failed : timeout occured" );
                throw new LdapException( TIME_OUT_ERROR );
            }
           
            if ( addResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
            {
                // Everything is fine, return the response
                LOG.debug( "Add successful : {}", addResponse );
            }
            else
            {
                // We have had an error
                LOG.debug( "Add failed : {}", addResponse );
            }

            return addResponse;
        }
        catch ( TimeoutException te )
        {
            // Send an abandon request
            if ( !addFuture.isCancelled() )
            {
                abandon( addRequest.getMessageId() );
            }

            // We didn't received anything : this is an error
            LOG.error( "Add failed : timeout occured" );
            throw new LdapException( TIME_OUT_ERROR );
        }
        catch ( Exception ie )
        {
            // Catch all other exceptions
            LOG.error( NO_RESPONSE_ERROR, ie );
            LdapException ldapException = new LdapException( NO_RESPONSE_ERROR );
            ldapException.initCause( ie );

            // Send an abandon request
            if ( !addFuture.isCancelled() )
            {
                abandon( addRequest.getMessageId() );
View Full Code Here

        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
        {
            // We didn't received anything : this is an error
            LOG.error( "Add failed : timeout occured" );

            throw new LdapException( TIME_OUT_ERROR );
        }
       
        // Ok, done return the future
        return addFuture;
    }
View Full Code Here

           
            if ( bindResponse == null )
            {
                // We didn't received anything : this is an error
                LOG.error( "Bind failed : timeout occured" );
                throw new LdapException( TIME_OUT_ERROR );
            }
           
            if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
            {
                authenticated.set( true );

                // Everything is fine, return the response
                LOG.debug( "Bind successful : {}", bindResponse );
            }
            else
            {
                // We have had an error
                LOG.debug( "Bind failed : {}", bindResponse );
            }

            return bindResponse;
        }
        catch ( TimeoutException te )
        {
            // Send an abandon request
            if ( !bindFuture.isCancelled() )
            {
                abandon( bindRequest.getMessageId() );
            }

            // We didn't received anything : this is an error
            LOG.error( "Bind failed : timeout occured" );
            throw new LdapException( TIME_OUT_ERROR );
        }
        catch ( Exception ie )
        {
            // Catch all other exceptions
            LOG.error( NO_RESPONSE_ERROR, ie );
            LdapException ldapException = new LdapException( NO_RESPONSE_ERROR );
            ldapException.initCause( ie );

            // Send an abandon request
            if ( !bindFuture.isCancelled() )
            {
                abandon( bindRequest.getMessageId() );
View Full Code Here

        }
        catch ( InvalidNameException ine )
        {
            String msg = "The given dn '" + searchRequest.getBaseDn() + "' is not valid";
            LOG.error( msg );
            LdapException ldapException = new LdapException( msg );
            ldapException.initCause( ine );

            throw ldapException;
        }

        // Set the scope
        request.setScope( searchRequest.getScope() );

        // Set the typesOnly flag
        request.setDerefAliases( searchRequest.getDerefAliases().getValue() );

        // Set the timeLimit
        request.setTimeLimit( searchRequest.getTimeLimit() );

        // Set the sizeLimit
        request.setSizeLimit( searchRequest.getSizeLimit() );

        // Set the typesOnly flag
        request.setTypesOnly( searchRequest.getTypesOnly() );

        // Set the filter
        Filter filter = null;

        try
        {
            ExprNode filterNode = FilterParser.parse( searchRequest.getFilter() );

            filter = LdapTransformer.transformFilter( filterNode );
        }
        catch ( ParseException pe )
        {
            String msg = "The given filter '" + searchRequest.getFilter() + "' is not valid";
            LOG.error( msg );
            LdapException ldapException = new LdapException( msg );
            ldapException.initCause( pe );

            throw ldapException;
        }

        request.setFilter( filter );
View Full Code Here

        }
        catch ( InvalidNameException ine )
        {
            String msg = "The given dn '" + bindRequest.getName() + "' is not valid";
            LOG.error( msg );
            LdapException ldapException = new LdapException( msg );
            ldapException.initCause( ine );

            throw ldapException;
        }

        // Set the credentials
View Full Code Here

        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
        {
            // We didn't received anything : this is an error
            LOG.error( "Bind failed : timeout occured" );

            throw new LdapException( TIME_OUT_ERROR );
        }
       
        // Ok, done return the future
        return bindFuture;
    }
View Full Code Here

        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
        {
            // We didn't received anything : this is an error
            LOG.error( "Search failed : timeout occured" );

            throw new LdapException( TIME_OUT_ERROR );
        }
       
        // Ok, done return the future
        return searchFuture;
View Full Code Here

                AddFuture addFuture = (AddFuture)responseFuture;

                if ( addFuture == null )
                {
                    LOG.error( "AddFuture is null" );
                    throw new LdapException( "AddFuture is null"  );
                }
               
                // remove the listener from the listener map
                if ( LOG.isDebugEnabled() )
                {
                    if ( addResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
                    {
                        // Everything is fine, return the response
                        LOG.debug( "Add successful : {}", addResponse );
                    }
                    else
                    {
                        // We have had an error
                        LOG.debug( "Add failed : {}", addResponse );
                    }
                }

                // Store the response into the future
                addFuture.set( addResponse );
               
                // Remove the future from the map
                removeFromFutureMaps( messageId );
               
                break;

            case BIND_RESPONSE:
                // Transform the response
                BindResponseCodec bindResponseCodec = (BindResponseCodec)response;
                bindResponseCodec.setMessageId( messageId );
                bindResponseCodec.addControl( response.getCurrentControl() );
                BindResponse bindResponse = convert( bindResponseCodec );

                BindFuture bindFuture = (BindFuture)responseFuture;

                if ( bindFuture == null )
                {
                    LOG.error( "BindFuture is null" );
                    throw new LdapException( "BindFuture is null"  );
                }
               
                // remove the listener from the listener map
                if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
                {
                    authenticated.set( true );

                    // Everything is fine, return the response
                    LOG.debug( "Bind successful : {}", bindResponse );
                }
                else
                {
                    // We have had an error
                    LOG.debug( "Bind failed : {}", bindResponse );
                }

                // Store the response into the future
                bindFuture.set( bindResponse );

                // Remove the future from the map
                removeFromFutureMaps( messageId );

                break;

            case COMPARE_RESPONSE:
                // Transform the response
                CompareResponseCodec compResCodec = (CompareResponseCodec)response;
                compResCodec.setMessageId( messageId );
                compResCodec.addControl( response.getCurrentControl() );

                CompareResponse compareResponse = convert( compResCodec );
               
                CompareFuture compareFuture = (CompareFuture)responseFuture;

                if ( compareFuture == null )
                {
                    LOG.error( "CompareFuture is null" );
                    throw new LdapException( "CompareFuture is null"  );
                }
               
                // remove the listener from the listener map
                if ( LOG.isDebugEnabled() )
                {
                    if ( compareResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
                    {
                        // Everything is fine, return the response
                        LOG.debug( "Compare successful : {}", compareResponse );
                    }
                    else
                    {
                        // We have had an error
                        LOG.debug( "Compare failed : {}", compareResponse );
                    }
                }

                // Store the response into the future
                compareFuture.set( compareResponse );
               
                // Remove the future from the map
                removeFromFutureMaps( messageId );
               
                break;

            case DEL_RESPONSE:
                // Transform the response
                DelResponseCodec delRespCodec = (DelResponseCodec)response;
                delRespCodec.addControl( response.getCurrentControl() );
                delRespCodec.setMessageId( messageId );

                DeleteResponse deleteResponse = convert( delRespCodec );
               
                DeleteFuture deleteFuture = (DeleteFuture)responseFuture;

                if ( deleteFuture == null )
                {
                    LOG.error( "DeleteFuture is null" );
                    throw new LdapException( "DeleteFuture is null"  );
                }
               
                if ( LOG.isDebugEnabled() )
                {
                    if ( deleteResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
                    {
                        // Everything is fine, return the response
                        LOG.debug( "Delete successful : {}", deleteResponse );
                    }
                    else
                    {
                        // We have had an error
                        LOG.debug( "Delete failed : {}", deleteResponse );
                    }
                }

                // Store the response into the future
                deleteFuture.set( deleteResponse );
               
                // Remove the future from the map
                removeFromFutureMaps( messageId );
               
                break;

            case EXTENDED_RESPONSE:
                // Transform the response
                ExtendedResponseCodec extResCodec = (ExtendedResponseCodec)response;
                extResCodec.setMessageId( messageId );
                extResCodec.addControl( response.getCurrentControl() );

                ExtendedResponse extendedResponse = convert( extResCodec );

                ExtendedFuture extendedFuture = (ExtendedFuture)responseFuture;

                if ( extendedFuture == null )
                {
                    LOG.error( "ExtendedFuture is null" );
                    throw new LdapException( "extendedFuture is null"  );
                }

                // remove the listener from the listener map
                if ( LOG.isDebugEnabled() )
                {
                    if ( extendedResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
                    {
                        // Everything is fine, return the response
                        LOG.debug( "Extended successful : {}", extendedResponse );
                    }
                    else
                    {
                        // We have had an error
                        LOG.debug( "Extended failed : {}", extendedResponse );
                    }
                }

                // Store the response into the future
                extendedFuture.set( extendedResponse );

                // Remove the future from the map
                removeFromFutureMaps( messageId );

                break;

            case INTERMEDIATE_RESPONSE:
                IntermediateResponseCodec intermediateResponseCodec = (IntermediateResponseCodec)response;
                intermediateResponseCodec.setMessageId( messageId );
                intermediateResponseCodec.addControl( response.getCurrentControl() );

                setIResponse( intermediateResponseCodec, responseFuture );
               
                break;

            case MODIFY_RESPONSE:
                // Transform the response
                ModifyResponseCodec modRespCodec = (ModifyResponseCodec)response;
                modRespCodec.setMessageId( messageId );
                modRespCodec.addControl( response.getCurrentControl() );

                ModifyResponse modifyResp = convert( modRespCodec );
               
                ModifyFuture modifyFuture = (ModifyFuture)responseFuture;

                if ( modifyFuture == null )
                {
                    LOG.error( "ModifyFuture is null" );
                    throw new LdapException( "ModifyFuture is null"  );
                }
               
                if ( LOG.isDebugEnabled() )
                {
                    if ( modifyResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
                    {
                        // Everything is fine, return the response
                        LOG.debug( "ModifyFuture successful : {}", modifyResp );
                    }
                    else
                    {
                        // We have had an error
                        LOG.debug( "ModifyFuture failed : {}", modifyResp );
                    }
                }

                // Store the response into the future
                modifyFuture.set( modifyResp );
               
                // Remove the future from the map
                removeFromFutureMaps( messageId );
               
                break;

            case MODIFYDN_RESPONSE:
                // Transform the response
                ModifyDNResponseCodec modDnRespCodec = (ModifyDNResponseCodec)response;
                modDnRespCodec.setMessageId( messageId );
                modDnRespCodec.addControl( response.getCurrentControl() );

                ModifyDnResponse modifyDnResp = convert( modDnRespCodec );
               
                ModifyDnFuture modifyDnFuture = (ModifyDnFuture)responseFuture;

                if ( modifyDnFuture == null )
                {
                    LOG.error( "ModifyDNFuture is null" );
                    throw new LdapException( "ModifyDNFuture is null"  );
                }
               
                if ( LOG.isDebugEnabled() )
                {
                    if ( modifyDnResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
                    {
                        // Everything is fine, return the response
                        LOG.debug( "ModifyDN successful : {}", modifyDnResp );
                    }
                    else
                    {
                        // We have had an error
                        LOG.debug( "ModifyDN failed : {}", modifyDnResp );
                    }
                }

                // Store the response into the future
                modifyDnFuture.set( modifyDnResp );
               
                // Remove the future from the map
                removeFromFutureMaps( messageId );
               
                break;
               
            case SEARCH_RESULT_DONE:
                // Store the response into the responseQueue
                SearchResultDoneCodec searchResultDoneCodec = (SearchResultDoneCodec)response;
                searchResultDoneCodec.setMessageId( messageId );
                searchResultDoneCodec.addControl( response.getCurrentControl() );
                SearchResultDone searchResultDone = convert( searchResultDoneCodec );

                SearchFuture searchFuture = (SearchFuture)responseFuture;
               
                if ( searchFuture == null )
                {
                    LOG.error( "SearchFuture is null" );
                    throw new LdapException( "SearchFuture is null"  );
                }
               
                if ( LOG.isDebugEnabled() )
                {
                    if ( searchResultDone.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
                    {
                        // Everything is fine, return the response
                        LOG.debug( "Search successful : {}", searchResultDone );
                    }
                    else
                    {
                        // We have had an error
                        LOG.debug( "Search failed : {}", searchResultDone );
                    }
                }

                // Store the response into the future
                searchFuture.set( searchResultDone );
               
                // Remove the future from the map
                removeFromFutureMaps( messageId );

                break;

            case SEARCH_RESULT_ENTRY:
                // Store the response into the responseQueue
                SearchResultEntryCodec searchResultEntryCodec = (SearchResultEntryCodec)response;
                searchResultEntryCodec.setMessageId( messageId );
                searchResultEntryCodec.addControl( response.getCurrentControl() );

                SearchResultEntry srchEntry = convert( searchResultEntryCodec );

                searchFuture = (SearchFuture)responseFuture;
               
                if ( searchFuture == null )
                {
                    LOG.error( "SearchFuture is null" );
                    throw new LdapException( "SearchFuture is null"  );
                }
               
                if ( LOG.isDebugEnabled() )
                {
                    LOG.debug( "Search entry found : {}", srchEntry );
                }

                // Store the response into the future
                searchFuture.set( srchEntry );
               
                break;

            case SEARCH_RESULT_REFERENCE:
                // Store the response into the responseQueue
                SearchResultReferenceCodec searchResultReferenceCodec = (SearchResultReferenceCodec)response;
                searchResultReferenceCodec.setMessageId( messageId );
                searchResultReferenceCodec.addControl( response.getCurrentControl() );

                SearchResultReference searchResultReference = convert( searchResultReferenceCodec );

                searchFuture = (SearchFuture)responseFuture;
               
                if ( searchFuture == null )
                {
                    LOG.error( "SearchFuture is null" );
                    throw new LdapException( "SearchFuture is null"  );
                }
               
                if ( LOG.isDebugEnabled() )
                {
                    LOG.debug( "Search reference found : {}", searchResultReference );
View Full Code Here

TOP

Related Classes of org.apache.directory.ldap.client.api.exception.LdapException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.