// Getting the batch request
BatchRequest batchRequest = parser.getBatchRequest();
// Creating a DSML batch response (only if needed)
BatchResponseDsml batchResponseDsml = null;
if ( responseFile != null )
{
batchResponseDsml = new BatchResponseDsml();
}
// Setting the errors counter
int errorsCount = 0;
// Creating a dummy monitor that will be used to check if something
// went wrong when executing the request
StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );
// Processing each request
List<?> requests = batchRequest.getRequests();
for ( Object request : requests )
{
// Processing the request
processRequest( request, batchResponseDsml, dummyMonitor );
// Verifying if any error has been reported
if ( dummyMonitor.errorsReported() )
{
errorsCount++;
}
dummyMonitor.reset();
}
// Writing the DSML response file to its final destination file.
if ( responseFile != null )
{
FileOutputStream fos = new FileOutputStream( responseFile );
OutputStreamWriter osw = new OutputStreamWriter( fos, "UTF-8" );
BufferedWriter bufferedWriter = new BufferedWriter( osw );
bufferedWriter.write( batchResponseDsml.toDsml() );
bufferedWriter.close();
osw.close();
fos.close();
}