@Test public void testCreateParentFolder() { String filename = getTestDirectory() + "/" + "testfile.html"; MasterReport report = Mockito.mock( MasterReport.class ); ModifiableConfiguration conf = Mockito.spy( new DefaultConfiguration() ); conf.setConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.html.stream.TargetFileName", filename ); conf.setConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.html.stream.CreateParentFolder", "true" ); Mockito.doReturn(conf).when(report).getConfiguration(); File file = null; File directory; try { file = new File( filename ).getCanonicalFile(); directory = file.getParentFile(); if ( directory != null ) { if ( directory.exists() == true ) { directory.delete(); } } Assert.assertFalse( directory.exists() ); HtmlStreamExportTask task = new HtmlStreamExportTask( report, null, null ); task.run(); } catch (Exception e1) { e1.printStackTrace(); } directory = file.getParentFile(); Assert.assertTrue( directory != null ); Assert.assertTrue( directory.exists() ); file.delete(); directory.delete(); }
public void run() { try { if ( createParentFolder ) { final File directory = targetDirectory.getCanonicalFile(); if ( directory != null ) { if ( directory.exists() == false ) { if ( directory.mkdirs() == false ) { HtmlStreamExportTask.logger.warn( "Can't create directories." ); } } } } final FileRepository targetRepository = new FileRepository( targetDirectory ); final ContentLocation targetRoot = targetRepository.getRoot(); ReportProcessor reportProcessor; ReportStructureValidator validator = new ReportStructureValidator(); if ( validator.isValidForFastProcessing( report ) == false ) { final HtmlOutputProcessor outputProcessor = new StreamHtmlOutputProcessor( report.getConfiguration() ); final HtmlPrinter printer = new AllItemsHtmlPrinter( report.getResourceManager() ); printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, filename, suffix ) ); printer.setDataWriter( null, null ); printer.setUrlRewriter( new FileSystemURLRewriter() ); outputProcessor.setPrinter( printer ); reportProcessor = new StreamReportProcessor( report, outputProcessor ); } else { FastHtmlContentItems printer = new FastHtmlContentItems(); printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, filename, suffix ) ); printer.setDataWriter( null, null ); printer.setUrlRewriter( new FileSystemURLRewriter() ); reportProcessor = new FastHtmlExportProcessor( report, printer ); } if ( progressDialog != null ) { progressDialog.setModal( false ); progressDialog.setVisible( true ); reportProcessor.addReportProgressListener( progressDialog ); } reportProcessor.processReport(); if ( progressDialog != null ) { reportProcessor.removeReportProgressListener( progressDialog ); } if ( statusListener != null ) { statusListener.setStatus( StatusType.INFORMATION, messages .getString( "HtmlStreamExportTask.USER_TASK_FINISHED" ), null ); } } catch ( ReportInterruptedException re ) { if ( statusListener != null ) { statusListener.setStatus( StatusType.INFORMATION, messages.getString( "HtmlStreamExportTask.USER_TASK_ABORTED" ), null ); } } catch ( Exception re ) { HtmlStreamExportTask.logger.error( "Exporting failed .", re ); if ( statusListener != null ) { statusListener.setStatus( StatusType.ERROR, messages.getString( "HtmlStreamExportTask.USER_TASK_ERROR" ), re ); } } if ( progressDialog != null ) { progressDialog.setVisible( false ); } }
HtmlStreamExportTask implements Runnable { public void run() { try { if ( createParentFolder ) { final File directory = targetDirectory.getCanonicalFile(); if ( directory != null ) { if ( directory.exists() == false ) { if ( directory.mkdirs() == false ) { HtmlStreamExportTask.logger.warn( "Can't create directories." ); } } } } final FileRepository targetRepository = new FileRepository( targetDirectory ); final ContentLocation targetRoot = targetRepository.getRoot(); ReportProcessor reportProcessor; ReportStructureValidator validator = new ReportStructureValidator(); if ( validator.isValidForFastProcessing( report ) == false ) { final HtmlOutputProcessor outputProcessor = new StreamHtmlOutputProcessor( report.getConfiguration() ); final HtmlPrinter printer = new AllItemsHtmlPrinter( report.getResourceManager() ); printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, filename, suffix ) ); printer.setDataWriter( null, null ); printer.setUrlRewriter( new FileSystemURLRewriter() ); outputProcessor.setPrinter( printer ); reportProcessor = new StreamReportProcessor( report, outputProcessor ); } else { FastHtmlContentItems printer = new FastHtmlContentItems(); printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, filename, suffix ) ); printer.setDataWriter( null, null ); printer.setUrlRewriter( new FileSystemURLRewriter() ); reportProcessor = new FastHtmlExportProcessor( report, printer ); } if ( progressDialog != null ) { progressDialog.setModal( false ); progressDialog.setVisible( true ); reportProcessor.addReportProgressListener( progressDialog ); } reportProcessor.processReport(); if ( progressDialog != null ) { reportProcessor.removeReportProgressListener( progressDialog ); } if ( statusListener != null ) { statusListener.setStatus( StatusType.INFORMATION, messages .getString( "HtmlStreamExportTask.USER_TASK_FINISHED" ), null ); } } catch ( ReportInterruptedException re ) { if ( statusListener != null ) { statusListener.setStatus( StatusType.INFORMATION, messages.getString( "HtmlStreamExportTask.USER_TASK_ABORTED" ), null ); } } catch ( Exception re ) { HtmlStreamExportTask.logger.error( "Exporting failed .", re ); if ( statusListener != null ) { statusListener.setStatus( StatusType.ERROR, messages.getString( "HtmlStreamExportTask.USER_TASK_ERROR" ), re ); } } if ( progressDialog != null ) { progressDialog.setVisible( false ); } } }
HtmlStreamExportTask implements Runnable { public void run() { try { if ( createParentFolder ) { final File directory = targetDirectory.getCanonicalFile(); if ( directory != null ) { if ( directory.exists() == false ) { if ( directory.mkdirs() == false ) { HtmlStreamExportTask.logger.warn( "Can't create directories." ); } } } } final FileRepository targetRepository = new FileRepository( targetDirectory ); final ContentLocation targetRoot = targetRepository.getRoot(); ReportProcessor reportProcessor; ReportStructureValidator validator = new ReportStructureValidator(); if ( validator.isValidForFastProcessing( report ) == false ) { final HtmlOutputProcessor outputProcessor = new StreamHtmlOutputProcessor( report.getConfiguration() ); final HtmlPrinter printer = new AllItemsHtmlPrinter( report.getResourceManager() ); printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, filename, suffix ) ); printer.setDataWriter( null, null ); printer.setUrlRewriter( new FileSystemURLRewriter() ); outputProcessor.setPrinter( printer ); reportProcessor = new StreamReportProcessor( report, outputProcessor ); } else { FastHtmlContentItems printer = new FastHtmlContentItems(); printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, filename, suffix ) ); printer.setDataWriter( null, null ); printer.setUrlRewriter( new FileSystemURLRewriter() ); reportProcessor = new FastHtmlExportProcessor( report, printer ); } if ( progressDialog != null ) { progressDialog.setModal( false ); progressDialog.setVisible( true ); reportProcessor.addReportProgressListener( progressDialog ); } reportProcessor.processReport(); if ( progressDialog != null ) { reportProcessor.removeReportProgressListener( progressDialog ); } if ( statusListener != null ) { statusListener.setStatus( StatusType.INFORMATION, messages .getString( "HtmlStreamExportTask.USER_TASK_FINISHED" ), null ); } } catch ( ReportInterruptedException re ) { if ( statusListener != null ) { statusListener.setStatus( StatusType.INFORMATION, messages.getString( "HtmlStreamExportTask.USER_TASK_ABORTED" ), null ); } } catch ( Exception re ) { HtmlStreamExportTask.logger.error( "Exporting failed .", re ); if ( statusListener != null ) { statusListener.setStatus( StatusType.ERROR, messages.getString( "HtmlStreamExportTask.USER_TASK_ERROR" ), re ); } } if ( progressDialog != null ) { progressDialog.setVisible( false ); } } HtmlStreamExportTask( final MasterReport report, final ReportProgressDialog dialog,
      final SwingGuiContext swingGuiContext ); }
HtmlStreamExportTask implements Runnable { public void run() { try { if ( createParentFolder ) { final File directory = targetDirectory.getCanonicalFile(); if ( directory != null ) { if ( directory.exists() == false ) { if ( directory.mkdirs() == false ) { HtmlStreamExportTask.logger.warn( "Can't create directories." ); } } } } final FileRepository targetRepository = new FileRepository( targetDirectory ); final ContentLocation targetRoot = targetRepository.getRoot(); ReportProcessor reportProcessor; ReportStructureValidator validator = new ReportStructureValidator(); if ( validator.isValidForFastProcessing( report ) == false ) { final HtmlOutputProcessor outputProcessor = new StreamHtmlOutputProcessor( report.getConfiguration() ); final HtmlPrinter printer = new AllItemsHtmlPrinter( report.getResourceManager() ); printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, filename, suffix ) ); printer.setDataWriter( null, null ); printer.setUrlRewriter( new FileSystemURLRewriter() ); outputProcessor.setPrinter( printer ); reportProcessor = new StreamReportProcessor( report, outputProcessor ); } else { FastHtmlContentItems printer = new FastHtmlContentItems(); printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, filename, suffix ) ); printer.setDataWriter( null, null ); printer.setUrlRewriter( new FileSystemURLRewriter() ); reportProcessor = new FastHtmlExportProcessor( report, printer ); } if ( progressDialog != null ) { progressDialog.setModal( false ); progressDialog.setVisible( true ); reportProcessor.addReportProgressListener( progressDialog ); } reportProcessor.processReport(); if ( progressDialog != null ) { reportProcessor.removeReportProgressListener( progressDialog ); } if ( statusListener != null ) { statusListener.setStatus( StatusType.INFORMATION, messages .getString( "HtmlStreamExportTask.USER_TASK_FINISHED" ), null ); } } catch ( ReportInterruptedException re ) { if ( statusListener != null ) { statusListener.setStatus( StatusType.INFORMATION, messages.getString( "HtmlStreamExportTask.USER_TASK_ABORTED" ), null ); } } catch ( Exception re ) { HtmlStreamExportTask.logger.error( "Exporting failed .", re ); if ( statusListener != null ) { statusListener.setStatus( StatusType.ERROR, messages.getString( "HtmlStreamExportTask.USER_TASK_ERROR" ), re ); } } if ( progressDialog != null ) { progressDialog.setVisible( false ); } } HtmlStreamExportTask( final MasterReport report, final ReportProgressDialog dialog,
      final SwingGuiContext swingGuiContext ); void run(); }
HtmlStreamExportTask implements Runnable { public void run() { try { if ( createParentFolder ) { final File directory = targetDirectory.getCanonicalFile(); if ( directory != null ) { if ( directory.exists() == false ) { if ( directory.mkdirs() == false ) { HtmlStreamExportTask.logger.warn( "Can't create directories." ); } } } } final FileRepository targetRepository = new FileRepository( targetDirectory ); final ContentLocation targetRoot = targetRepository.getRoot(); ReportProcessor reportProcessor; ReportStructureValidator validator = new ReportStructureValidator(); if ( validator.isValidForFastProcessing( report ) == false ) { final HtmlOutputProcessor outputProcessor = new StreamHtmlOutputProcessor( report.getConfiguration() ); final HtmlPrinter printer = new AllItemsHtmlPrinter( report.getResourceManager() ); printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, filename, suffix ) ); printer.setDataWriter( null, null ); printer.setUrlRewriter( new FileSystemURLRewriter() ); outputProcessor.setPrinter( printer ); reportProcessor = new StreamReportProcessor( report, outputProcessor ); } else { FastHtmlContentItems printer = new FastHtmlContentItems(); printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, filename, suffix ) ); printer.setDataWriter( null, null ); printer.setUrlRewriter( new FileSystemURLRewriter() ); reportProcessor = new FastHtmlExportProcessor( report, printer ); } if ( progressDialog != null ) { progressDialog.setModal( false ); progressDialog.setVisible( true ); reportProcessor.addReportProgressListener( progressDialog ); } reportProcessor.processReport(); if ( progressDialog != null ) { reportProcessor.removeReportProgressListener( progressDialog ); } if ( statusListener != null ) { statusListener.setStatus( StatusType.INFORMATION, messages .getString( "HtmlStreamExportTask.USER_TASK_FINISHED" ), null ); } } catch ( ReportInterruptedException re ) { if ( statusListener != null ) { statusListener.setStatus( StatusType.INFORMATION, messages.getString( "HtmlStreamExportTask.USER_TASK_ABORTED" ), null ); } } catch ( Exception re ) { HtmlStreamExportTask.logger.error( "Exporting failed .", re ); if ( statusListener != null ) { statusListener.setStatus( StatusType.ERROR, messages.getString( "HtmlStreamExportTask.USER_TASK_ERROR" ), re ); } } if ( progressDialog != null ) { progressDialog.setVisible( false ); } } HtmlStreamExportTask( final MasterReport report, final ReportProgressDialog dialog,
      final SwingGuiContext swingGuiContext ); void run();  }