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;