final ReportProgressDialog progressDialog,
final SwingGuiContext swingGuiContext) throws ReportProcessingException
{
if (report == null)
{
throw new ReportProcessingException("HtmlDirExportTask(..): Report-Parameter cannot be null"); //$NON-NLS-1$
}
this.progressDialog = progressDialog;
this.report = report;
final Configuration config = report.getConfiguration();
final String dataDirectoryName = config.getConfigProperty
("org.pentaho.reporting.engine.classic.core.modules.gui.html.file.DataDirectory"); //$NON-NLS-1$
final String targetFileName = config.getConfigProperty
("org.pentaho.reporting.engine.classic.core.modules.gui.html.file.TargetFileName"); //$NON-NLS-1$
exportMethod = config.getConfigProperty
("org.pentaho.reporting.engine.classic.core.modules.gui.html.file.ExportMethod"); //$NON-NLS-1$
try
{
if (swingGuiContext != null)
{
this.statusListener = swingGuiContext.getStatusListener();
this.messages = new Messages(swingGuiContext.getLocale(), HtmlExportGUIModule.BASE_RESOURCE_CLASS,
ObjectUtilities.getClassLoader(HtmlExportGUIModule.class));
}
else
{
this.messages = new Messages(Locale.getDefault(), HtmlExportGUIModule.BASE_RESOURCE_CLASS,
ObjectUtilities.getClassLoader(HtmlExportGUIModule.class));
}
final File targetFile = new File(targetFileName).getCanonicalFile();
targetDirectory = targetFile.getParentFile();
final File tempDataDir = new File(dataDirectoryName).getCanonicalFile();
if ("".equals(dataDirectoryName) == false && tempDataDir.isAbsolute())
{
dataDirectory = tempDataDir;
}
else
{
dataDirectory = new File(targetDirectory, dataDirectoryName).getCanonicalFile();
}
if (dataDirectory.exists() && dataDirectory.isDirectory() == false)
{
dataDirectory = dataDirectory.getParentFile();
if (dataDirectory.isDirectory() == false)
{
throw new ReportProcessingException
("HtmlDirExportTask(..): Data-Directory is invalid: " + dataDirectory); //$NON-NLS-1$
}
}
else if (dataDirectory.exists() == false)
{
dataDirectory.mkdirs();
}
suffix = getSuffix(targetFileName);
filename = IOUtils.getInstance().stripFileExtension(targetFile.getName());
if (targetFile.exists())
{
// lets try to delete it ..
if (targetFile.delete() == false)
{
throw new ReportProcessingException(messages.getErrorString("HtmlDirExportTask.ERROR_0003_TARGET_FILE_EXISTS",
targetFile.getAbsolutePath())); //$NON-NLS-1$
}
}
}
catch (IOException ioe)
{
throw new ReportProcessingException("Failed to normalize directories.", ioe);
}
}