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 ) );
}