Package org.apache.directory.shared.ldap.codec.search

Examples of org.apache.directory.shared.ldap.codec.search.SearchRequestCodec


     * Create a SearchRequestCodec ready to be sent.
     */
    private SearchRequestCodec createSearchMessage( SearchRequest searchRequest ) throws LdapException
    {
        // Create a new codec SearchRequest object
        SearchRequestCodec request = new SearchRequestCodec();

        // Creates the messageID and stores it into the
        // initial message and the transmitted message.
        int newId = messageId.incrementAndGet();
        searchRequest.setMessageId( newId );
        request.setMessageId( newId );

        // Set the name
        try
        {
            DN dn = new DN( searchRequest.getBaseDn() );
            request.setBaseObject( dn );
        }
        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 );

        // Set the attributes
        Set<String> attributes = searchRequest.getAttributes();

        if ( attributes != null )
        {
            for ( String attribute : attributes )
            {
                request.addAttribute( attribute );
            }
        }

        // Add the controls
        setControls( searchRequest.getControls(), request );
View Full Code Here


    {
        // If the session has not been establish, or is closed, we get out immediately
        checkSession();

        // Create the server request
        SearchRequestCodec request = createSearchMessage( searchRequest );

        LOG.debug( "-----------------------------------------------------------------" );
        LOG.debug( "Sending request \n{}", request );

        SearchFuture searchFuture = new SearchFuture( this, request.getMessageId() );
        addToFutureMap( request.getMessageId(), searchFuture );

        // Send the request to the server
        WriteFuture writeFuture = ldapSession.write( request );

        // Wait for the message to be sent to the server
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.codec.search.SearchRequestCodec

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.