Package org.apache.directory.studio.dsmlv2.reponse

Examples of org.apache.directory.studio.dsmlv2.reponse.SearchResponseDsml


                break;

            case SEARCH_REQUEST:
                SearchCursor searchResponses = connection.search( ( SearchRequest ) request );

                SearchResponseDsml searchResponseDsml = new SearchResponseDsml( connection.getCodecService() );

                if ( respWriter != null )
                {
                    StringBuilder sb = new StringBuilder();
                    sb.append( "<searchResponse" );

                    if ( request.getDecorated().getMessageId() > 0 )
                    {
                        sb.append( " requestID=\"" );
                        sb.append( request.getDecorated().getMessageId() );
                        sb.append( '"' );
                    }

                    sb.append( '>' );

                    respWriter.write( sb.toString() );
                }

                while ( searchResponses.next() )
                {
                    Response searchResponse = searchResponses.get();

                    if ( searchResponse.getType() == MessageTypeEnum.SEARCH_RESULT_ENTRY )
                    {
                        SearchResultEntry searchResultEntry = ( SearchResultEntry ) searchResponse;

                        SearchResultEntryDsml searchResultEntryDsml = new SearchResultEntryDsml(
                            connection.getCodecService(), searchResultEntry );
                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
                            searchResultEntryDsml );

                        if ( respWriter != null )
                        {
                            writeResponse( respWriter, searchResultEntryDsml );
                        }
                        else
                        {
                            searchResponseDsml.addResponse( searchResultEntryDsml );
                        }
                    }
                    else if ( searchResponse.getType() == MessageTypeEnum.SEARCH_RESULT_REFERENCE )
                    {
                        SearchResultReference searchResultReference = ( SearchResultReference ) searchResponse;

                        SearchResultReferenceDsml searchResultReferenceDsml = new SearchResultReferenceDsml(
                            connection.getCodecService(), searchResultReference );
                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
                            searchResultReferenceDsml );

                        if ( respWriter != null )
                        {
                            writeResponse( respWriter, searchResultReferenceDsml );
                        }
                        else
                        {
                            searchResponseDsml.addResponse( searchResultReferenceDsml );
                        }
                    }
                }

                SearchResultDone srDone = searchResponses.getSearchResultDone();

                if ( srDone != null )
                {
                    resultCode = srDone.getLdapResult().getResultCode();

                    SearchResultDoneDsml srdDsml = new SearchResultDoneDsml( connection.getCodecService(), srDone );

                    if ( respWriter != null )
                    {
                        writeResponse( respWriter, srdDsml );
                        respWriter.write( "</searchResponse>" );
                    }
                    else
                    {
                        searchResponseDsml.addResponse( srdDsml );
                        batchResponse.addResponse( searchResponseDsml );
                    }
                }

                break;
View Full Code Here


     */
    public static void processAsDsmlResponse( StudioNamingEnumeration ne, BatchResponseDsml batchResponse,
        StudioProgressMonitor monitor, SearchParameter searchParameter ) throws LdapURLEncodingException, LdapException
    {
        // Creating and adding the search response
        SearchResponseDsml sr = new SearchResponseDsml( codec );
        batchResponse.addResponse( sr );

        try
        {
            int count = 0;

            if ( !monitor.errorsReported() )
            {
                // Creating and adding a search result entry or reference for each result
                while ( ne.hasMore() )
                {
                    SearchResult searchResult = ( SearchResult ) ne.next();
                    sr.addResponse( convertSearchResultToDsml( searchResult, searchParameter ) );

                    count++;
                    monitor.reportProgress( BrowserCoreMessages.bind( BrowserCoreMessages.jobs__export_progress,
                        new String[]
                            { Integer.toString( count ) } ) );
                }
            }
        }
        catch ( NamingException e )
        {
            int ldapStatusCode = JNDIUtils.getLdapStatusCode( e );
            if ( ldapStatusCode == 3 || ldapStatusCode == 4 || ldapStatusCode == 11 )
            {
                // ignore
            }
            else
            {
                monitor.reportError( e );
            }
        }

        // Creating and adding a search result done at the end of the results
        SearchResultDone srd = new SearchResultDoneImpl();
        LdapResult ldapResult = srd.getLdapResult();
        if ( !monitor.errorsReported() )
        {
            ldapResult.setResultCode( ResultCodeEnum.SUCCESS );
        }
        else
        {
            // Getting the exception
            Throwable t = monitor.getException();

            // Setting the result code
            ldapResult.setResultCode( ResultCodeEnum.getBestEstimate( t, MessageTypeEnum.SEARCH_REQUEST ) );

            // Setting the error message if there's one
            if ( t.getMessage() != null )
            {
                ldapResult.setDiagnosticMessage( t.getMessage() );
            }
        }
        sr.addResponse( new SearchResultDoneDsml( codec, srd ) );
    }
View Full Code Here

                break;

            case SEARCH_REQUEST:
                SearchCursor searchResponses = connection.search( ( SearchRequest ) request );

                SearchResponseDsml searchResponseDsml = new SearchResponseDsml( connection.getCodecService() );

                if ( respWriter != null )
                {
                    StringBuilder sb = new StringBuilder();
                    sb.append( "<searchResponse" );

                    if ( request.getDecorated().getMessageId() > 0 )
                    {
                        sb.append( " requestID=\"" );
                        sb.append( request.getDecorated().getMessageId() );
                        sb.append( '"' );
                    }

                    sb.append( '>' );

                    respWriter.write( sb.toString() );
                }

                while ( searchResponses.next() )
                {
                    Response searchResponse = searchResponses.get();

                    if ( searchResponse.getType() == MessageTypeEnum.SEARCH_RESULT_ENTRY )
                    {
                        SearchResultEntry searchResultEntry = ( SearchResultEntry ) searchResponse;

                        SearchResultEntryDsml searchResultEntryDsml = new SearchResultEntryDsml(
                            connection.getCodecService(), searchResultEntry );
                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
                            searchResultEntryDsml );

                        if ( respWriter != null )
                        {
                            writeResponse( respWriter, searchResultEntryDsml );
                        }
                        else
                        {
                            searchResponseDsml.addResponse( searchResultEntryDsml );
                        }
                    }
                    else if ( searchResponse.getType() == MessageTypeEnum.SEARCH_RESULT_REFERENCE )
                    {
                        SearchResultReference searchResultReference = ( SearchResultReference ) searchResponse;

                        SearchResultReferenceDsml searchResultReferenceDsml = new SearchResultReferenceDsml(
                            connection.getCodecService(), searchResultReference );
                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
                            searchResultReferenceDsml );

                        if ( respWriter != null )
                        {
                            writeResponse( respWriter, searchResultReferenceDsml );
                        }
                        else
                        {
                            searchResponseDsml.addResponse( searchResultReferenceDsml );
                        }
                    }
                }

                SearchResultDone srDone = searchResponses.getSearchResultDone();

                if ( srDone != null )
                {
                    resultCode = srDone.getLdapResult().getResultCode();

                    SearchResultDoneDsml srdDsml = new SearchResultDoneDsml( connection.getCodecService(), srDone );

                    if ( respWriter != null )
                    {
                        writeResponse( respWriter, srdDsml );
                        respWriter.write( "</searchResponse>" );
                    }
                    else
                    {
                        searchResponseDsml.addResponse( srdDsml );
                        batchResponse.addResponse( searchResponseDsml );
                    }
                }

                break;
View Full Code Here

                break;

            case SEARCH_REQUEST:
                SearchCursor searchResponses = connection.search( ( SearchRequest ) request );

                SearchResponseDsml searchResponseDsml = new SearchResponseDsml( connection.getCodecService() );

                if ( respWriter != null )
                {
                    StringBuilder sb = new StringBuilder();
                    sb.append( "<searchResponse" );

                    if ( request.getDecorated().getMessageId() > 0 )
                    {
                        sb.append( " requestID=\"" );
                        sb.append( request.getDecorated().getMessageId() );
                        sb.append( '"' );
                    }

                    sb.append( '>' );

                    respWriter.write( sb.toString() );
                }

                while ( searchResponses.next() )
                {
                    Response searchResponse = searchResponses.get();

                    if ( searchResponse.getType() == MessageTypeEnum.SEARCH_RESULT_ENTRY )
                    {
                        SearchResultEntry searchResultEntry = ( SearchResultEntry ) searchResponse;

                        SearchResultEntryDsml searchResultEntryDsml = new SearchResultEntryDsml(
                            connection.getCodecService(), searchResultEntry );
                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
                            searchResultEntryDsml );

                        if ( respWriter != null )
                        {
                            writeResponse( respWriter, searchResultEntryDsml );
                        }
                        else
                        {
                            searchResponseDsml.addResponse( searchResultEntryDsml );
                        }
                    }
                    else if ( searchResponse.getType() == MessageTypeEnum.SEARCH_RESULT_REFERENCE )
                    {
                        SearchResultReference searchResultReference = ( SearchResultReference ) searchResponse;

                        SearchResultReferenceDsml searchResultReferenceDsml = new SearchResultReferenceDsml(
                            connection.getCodecService(), searchResultReference );
                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
                            searchResultReferenceDsml );

                        if ( respWriter != null )
                        {
                            writeResponse( respWriter, searchResultReferenceDsml );
                        }
                        else
                        {
                            searchResponseDsml.addResponse( searchResultReferenceDsml );
                        }
                    }
                }

                SearchResultDone srDone = searchResponses.getSearchResultDone();

                if ( srDone != null )
                {
                    resultCode = srDone.getLdapResult().getResultCode();

                    SearchResultDoneDsml srdDsml = new SearchResultDoneDsml( connection.getCodecService(), srDone );

                    if ( respWriter != null )
                    {
                        writeResponse( respWriter, srdDsml );
                        respWriter.write( "</searchResponse>" );
                    }
                    else
                    {
                        searchResponseDsml.addResponse( srdDsml );
                        batchResponse.addResponse( searchResponseDsml );
                    }
                }

                break;
View Full Code Here

        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        SearchResponseDsml searchResponseDsml = ( SearchResponseDsml )
            parser.getBatchResponse().getCurrentResponse();
        SearchResponse response = ( SearchResponse ) searchResponseDsml.getDecorated();
        SearchResultEntry searchResultEntry = response.getSearchResultEntryList().get( 0 );

        assertEquals( "dc=example,dc=com", searchResultEntry.getObjectName().toString() );
    }
View Full Code Here

                break;

            case SEARCH_REQUEST:
                SearchCursor searchResponses = connection.search( ( SearchRequest ) request );

                SearchResponseDsml searchResponseDsml = new SearchResponseDsml( connection.getCodecService() );

                if ( respWriter != null )
                {
                    StringBuilder sb = new StringBuilder();
                    sb.append( "<searchResponse" );

                    if ( request.getDecorated().getMessageId() > 0 )
                    {
                        sb.append( " requestID=\"" );
                        sb.append( request.getDecorated().getMessageId() );
                        sb.append( '"' );
                    }

                    sb.append( '>' );

                    respWriter.write( sb.toString() );
                }

                while ( searchResponses.next() )
                {
                    Response searchResponse = searchResponses.get();

                    if ( searchResponse.getType() == MessageTypeEnum.SEARCH_RESULT_ENTRY )
                    {
                        SearchResultEntry searchResultEntry = ( SearchResultEntry ) searchResponse;

                        SearchResultEntryDsml searchResultEntryDsml = new SearchResultEntryDsml(
                            connection.getCodecService(), searchResultEntry );
                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
                            searchResultEntryDsml );

                        if ( respWriter != null )
                        {
                            writeResponse( respWriter, searchResultEntryDsml );
                        }
                        else
                        {
                            searchResponseDsml.addResponse( searchResultEntryDsml );
                        }
                    }
                    else if ( searchResponse.getType() == MessageTypeEnum.SEARCH_RESULT_REFERENCE )
                    {
                        SearchResultReference searchResultReference = ( SearchResultReference ) searchResponse;

                        SearchResultReferenceDsml searchResultReferenceDsml = new SearchResultReferenceDsml(
                            connection.getCodecService(), searchResultReference );
                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
                            searchResultReferenceDsml );

                        if ( respWriter != null )
                        {
                            writeResponse( respWriter, searchResultReferenceDsml );
                        }
                        else
                        {
                            searchResponseDsml.addResponse( searchResultReferenceDsml );
                        }
                    }
                }

                SearchResultDone srDone = searchResponses.getSearchResultDone();

                if ( srDone != null )
                {
                    resultCode = srDone.getLdapResult().getResultCode();

                    SearchResultDoneDsml srdDsml = new SearchResultDoneDsml( connection.getCodecService(), srDone );

                    if ( respWriter != null )
                    {
                        writeResponse( respWriter, srdDsml );
                        respWriter.write( "</searchResponse>" );
                    }
                    else
                    {
                        searchResponseDsml.addResponse( srdDsml );
                        batchResponse.addResponse( searchResponseDsml );
                    }
                }

                break;
View Full Code Here

            //     - 0 to n SearchResultEntry
            //     - O to n SearchResultReference
            //     - 1 (only) SearchResultDone
            // So we have to include those individual reponses in a "General" SearchResponse
            //            Element searchResponse = xmlResponse.getRootElement().addElement( "searchResponse" );
            SearchResponseDsml searchResponseDsml = new SearchResponseDsml();

            // RequestID
            int requestID = response.getMessageId();
            if ( requestID != 0 )
            {
                searchResponseDsml.setMessageId( requestID );
            }

            while ( LdapConstants.SEARCH_RESULT_DONE != response.getMessageType() )
            {
                if ( LdapConstants.SEARCH_RESULT_ENTRY == response.getMessageType() )
                {
                    SearchResultEntry sre = response.getSearchResultEntry();
                    copyMessageIdAndControls( response, sre );

                    SearchResultEntryDsml searchResultEntryDsml = new SearchResultEntryDsml( sre );
                    searchResponseDsml.addResponse( searchResultEntryDsml );
                }
                else if ( LdapConstants.SEARCH_RESULT_REFERENCE == response.getMessageType() )
                {
                    SearchResultReference srr = response.getSearchResultReference();
                    copyMessageIdAndControls( response, srr );

                    SearchResultReferenceDsml searchResultReferenceDsml = new SearchResultReferenceDsml( srr );
                    searchResponseDsml.addResponse( searchResultReferenceDsml );
                }

                response = readResponse( bb );
            }

            SearchResultDone srd = response.getSearchResultDone();
            copyMessageIdAndControls( response, srd );

            SearchResultDoneDsml searchResultDoneDsml = new SearchResultDoneDsml( response );
            searchResponseDsml.addResponse( searchResultDoneDsml );
        }

        LdapResponse realResponse = response.getLdapResponse();

        if ( !continueOnError )
View Full Code Here

    public static void processAsDsmlResponse( StudioNamingEnumeration ne, BatchResponseDsml batchResponse,
        StudioProgressMonitor monitor, SearchParameter searchParameter ) throws NamingException,
        LdapURLEncodingException
    {
        // Creating and adding the search response
        SearchResponseDsml sr = new SearchResponseDsml();
        batchResponse.addResponse( sr );

        if ( !monitor.errorsReported() )
        {
            // Creating and adding a search result entry or reference for each result
            while ( ne.hasMore() )
            {
                SearchResult searchResult = ( SearchResult ) ne.next();
                sr.addResponse( convertSearchResultToDsml( searchResult, searchParameter ) );
            }
        }

        // Creating and adding a search result done at the end of the results
        SearchResultDoneCodec srd = new SearchResultDoneCodec();
        LdapResultCodec ldapResult = new LdapResultCodec();
        if ( !monitor.errorsReported() )
        {
            ldapResult.setResultCode( ResultCodeEnum.SUCCESS );
        }
        else
        {
            // Getting the exception
            Throwable t = monitor.getException();

            // Setting the result code
            ldapResult.setResultCode( ResultCodeEnum.getBestEstimate( t, MessageTypeEnum.SEARCH_REQUEST ) );

            // Setting the error message if there's one
            if ( t.getMessage() != null )
            {
                ldapResult.setErrorMessage( t.getMessage() );
            }
        }
        srd.setLdapResult( ldapResult );
        sr.addResponse( new SearchResultDoneDsml( srd ) );
    }
View Full Code Here

                break;

            case SEARCH_REQUEST:
                SearchCursor searchResponses = connection.search( ( SearchRequest ) request );

                SearchResponseDsml searchResponseDsml = new SearchResponseDsml( connection.getCodecService() );

                if ( respWriter != null )
                {
                    StringBuilder sb = new StringBuilder();
                    sb.append( "<searchResponse" );

                    if ( request.getDecorated().getMessageId() > 0 )
                    {
                        sb.append( " requestID=\"" );
                        sb.append( request.getDecorated().getMessageId() );
                        sb.append( '"' );
                    }

                    sb.append( '>' );

                    respWriter.write( sb.toString() );
                }

                while ( searchResponses.next() )
                {
                    Response searchResponse = searchResponses.get();

                    if ( searchResponse.getType() == MessageTypeEnum.SEARCH_RESULT_ENTRY )
                    {
                        SearchResultEntry searchResultEntry = ( SearchResultEntry ) searchResponse;

                        SearchResultEntryDsml searchResultEntryDsml = new SearchResultEntryDsml(
                            connection.getCodecService(), searchResultEntry );
                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
                            searchResultEntryDsml );

                        if ( respWriter != null )
                        {
                            writeResponse( respWriter, searchResultEntryDsml );
                        }
                        else
                        {
                            searchResponseDsml.addResponse( searchResultEntryDsml );
                        }
                    }
                    else if ( searchResponse.getType() == MessageTypeEnum.SEARCH_RESULT_REFERENCE )
                    {
                        SearchResultReference searchResultReference = ( SearchResultReference ) searchResponse;

                        SearchResultReferenceDsml searchResultReferenceDsml = new SearchResultReferenceDsml(
                            connection.getCodecService(), searchResultReference );
                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
                            searchResultReferenceDsml );

                        if ( respWriter != null )
                        {
                            writeResponse( respWriter, searchResultReferenceDsml );
                        }
                        else
                        {
                            searchResponseDsml.addResponse( searchResultReferenceDsml );
                        }
                    }
                }

                SearchResultDone srDone = searchResponses.getSearchResultDone();

                if ( srDone != null )
                {
                    resultCode = srDone.getLdapResult().getResultCode();

                    SearchResultDoneDsml srdDsml = new SearchResultDoneDsml( connection.getCodecService(), srDone );

                    if ( respWriter != null )
                    {
                        writeResponse( respWriter, srdDsml );
                        respWriter.write( "</searchResponse>" );
                    }
                    else
                    {
                        searchResponseDsml.addResponse( srdDsml );
                        batchResponse.addResponse( searchResponseDsml );
                    }
                }

                break;
View Full Code Here

        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        SearchResponseDsml searchResponseDsml = ( SearchResponseDsml )
            parser.getBatchResponse().getCurrentResponse();
        SearchResponse response = ( SearchResponse ) searchResponseDsml.getDecorated();
        SearchResultEntry searchResultEntry = response.getSearchResultEntryList().get( 0 );

        assertEquals( "dc=example,dc=com", searchResultEntry.getObjectName().toString() );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.dsmlv2.reponse.SearchResponseDsml

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.