/**
* Exports the report into a CSV file.
*/
public void run()
{
Writer out = null;
final File file = new File(fileName);
try
{
final File directory = file.getAbsoluteFile().getParentFile();
if (directory != null)
{
if (directory.exists() == false)
{
if (directory.mkdirs() == false)
{
CSVDataExportTask.logger.warn("Can't create directories. Hoping and praying now.."); //$NON-NLS-1$
}
}
}
final String encoding = report.getConfiguration().getConfigProperty
(CSVProcessor.CSV_ENCODING, EncodingRegistry.getPlatformDefaultEncoding());
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), encoding));
final CSVProcessor target = new CSVProcessor(report);
if (progressDialog != null)
{
progressDialog.setModal(false);
progressDialog.setVisible(true);
target.addReportProgressListener(progressDialog);
}
target.setWriter(out);
target.processReport();
out.close();
out = null;
if (progressDialog != null)
{
target.removeReportProgressListener(progressDialog);
}
if (statusListener != null)
{
statusListener.setStatus
(StatusType.INFORMATION, messages.getString("CSVRawExportTask.USER_TASK_COMPLETE"), null); //$NON-NLS-1$
}
}
catch (ReportInterruptedException re)
{
if (statusListener != null)
{
statusListener.setStatus
(StatusType.INFORMATION, messages.getString("CSVRawExportTask.USER_TASK_ABORTED"), null); //$NON-NLS-1$
}
try
{
out.close();
out = null;
if (file.delete() == false)
{
CSVDataExportTask.logger.warn("Unable to delete incomplete export:" + file); //$NON-NLS-1$
}
}
catch (SecurityException se)
{
// ignore me
}
catch (IOException ioe)
{
// ignore me...
}
}
catch (Exception re)
{
CSVDataExportTask.logger.error("Exporting failed .", re); //$NON-NLS-1$
if (statusListener != null)
{
statusListener.setStatus
(StatusType.ERROR, messages.getString("CSVRawExportTask.USER_TASK_FAILED"), re); //$NON-NLS-1$
}
}
finally
{
try
{
if (out != null)
{
out.close();
}
}
catch (Exception e)
{
if (statusListener != null)