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

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


    /**
     * Test parsing of a response with 2 Attr 1 Value
     */
    public void testResponseWith2Attr1Value()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser();

            parser.setInputFile( SearchResultEntryTest.class.getResource( "response_with_2_attr_1_value.xml" )
                .getFile() );

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

        SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() )
            .getCurrentSearchResultEntry();

        Attributes attributes = searchResultEntry.getPartialAttributeList();

        assertEquals( 2, attributes.size() );
View Full Code Here


            // Executing the request
            Document xmlRequest = DocumentHelper.createDocument();
            Element rootElement = xmlRequest.addElement( "batchRequest" );
            SearchRequestDsml searchRequestDsml = new SearchRequestDsml( searchRequest );
            searchRequestDsml.toDsml( rootElement );
            Dsmlv2Engine engine = new Dsmlv2Engine( browserConnection.getConnection().getHost(), browserConnection
                .getConnection().getPort(), browserConnection.getConnection().getBindPrincipal(), browserConnection
                .getConnection().getBindPassword() );
            String response = engine.processDSML( xmlRequest.asXML() );

            // Saving the response
            FileOutputStream fout = new FileOutputStream( exportDsmlFilename );
            new PrintStream( fout ).println( response );
            fout.close();
View Full Code Here

        monitor.beginTask( BrowserCoreMessages.jobs__import_dsml_task, 2 );
        monitor.reportProgress( " " ); //$NON-NLS-1$
        monitor.worked( 1 );
       
        Dsmlv2Engine engine = new Dsmlv2Engine( browserConnection.getConnection().getHost(), browserConnection
            .getConnection().getPort(), browserConnection.getConnection().getBindPrincipal(), browserConnection
            .getConnection().getBindPassword() );
        try
        {
            // Executing the DSML request and getting the response
            String response = engine.processDSMLFile( dsmlFile.getAbsolutePath() );
           
            // Saving Response if needed
            if ( responseFile != null )
            {
                FileOutputStream fout = new FileOutputStream( responseFile );
View Full Code Here

            // Executing the request
            Document xmlRequest = DocumentHelper.createDocument();
            Element rootElement = xmlRequest.addElement( "batchRequest" );
            SearchRequestDsml searchRequestDsml = new SearchRequestDsml( searchRequest );
            searchRequestDsml.toDsml( rootElement );
            Dsmlv2Engine engine = new Dsmlv2Engine( browserConnection.getConnection().getHost(), browserConnection
                .getConnection().getPort(), browserConnection.getConnection().getBindPrincipal(), browserConnection
                .getConnection().getBindPassword() );
            String response = engine.processDSML( xmlRequest.asXML() );

            // Saving the response
            FileOutputStream fout = new FileOutputStream( exportDsmlFilename );
            new PrintStream( fout ).println( response );
            fout.close();
View Full Code Here

        monitor.beginTask( BrowserCoreMessages.jobs__import_dsml_task, 2 );
        monitor.reportProgress( " " ); //$NON-NLS-1$
        monitor.worked( 1 );
       
        Dsmlv2Engine engine = new Dsmlv2Engine( browserConnection.getConnection().getHost(), browserConnection
            .getConnection().getPort(), browserConnection.getConnection().getBindPrincipal(), browserConnection
            .getConnection().getBindPassword() );
        try
        {
            // Executing the DSML request and getting the response
            String response = engine.processDSMLFile( dsmlFile.getAbsolutePath() );
           
            // Saving Response if needed
            if ( responseFile != null )
            {
                FileOutputStream fout = new FileOutputStream( responseFile );
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

            //     - 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( srd );
            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.nextElement();
                sr.addResponse( convertSearchResultToDsml( searchResult, searchParameter ) );
            }
        }

        // Creating and adding a search result done at the end of the results
        SearchResultDone srd = new SearchResultDone();
        LdapResult ldapResult = new LdapResult();
        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

            }

            // Executing the request
            Document xmlRequest = DocumentHelper.createDocument();
            Element rootElement = xmlRequest.addElement( "batchRequest" );
            SearchRequestDsml searchRequestDsml = new SearchRequestDsml( searchRequest );
            searchRequestDsml.toDsml( rootElement );
            Dsmlv2Engine engine = new Dsmlv2Engine( browserConnection.getConnection().getHost(), browserConnection
                .getConnection().getPort(), browserConnection.getConnection().getBindPrincipal(), browserConnection
                .getConnection().getBindPassword() );
            String response = engine.processDSML( xmlRequest.asXML() );
View Full Code Here

            }

            // Executing the request
            Document xmlRequest = DocumentHelper.createDocument();
            Element rootElement = xmlRequest.addElement( "batchRequest" );
            SearchRequestDsml searchRequestDsml = new SearchRequestDsml( searchRequest );
            searchRequestDsml.toDsml( rootElement );
            Dsmlv2Engine engine = new Dsmlv2Engine( browserConnection.getConnection().getHost(), browserConnection
                .getConnection().getPort(), browserConnection.getConnection().getBindPrincipal(), browserConnection
                .getConnection().getBindPassword() );
            String response = engine.processDSML( xmlRequest.asXML() );
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.