Java Code Examples for org.pentaho.reporting.engine.classic.core.MasterReport#getResourceManager()

The following examples show how to use org.pentaho.reporting.engine.classic.core.MasterReport#getResourceManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HtmlReportUtil.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void createStreamHTML( final MasterReport report, final OutputStream outputStream )
  throws ReportProcessingException {
  if ( report == null ) {
    throw new NullPointerException();
  }
  if ( outputStream == null ) {
    throw new NullPointerException();
  }
  final StreamRepository targetRepository = new StreamRepository( outputStream );
  final ContentLocation targetRoot = targetRepository.getRoot();

  final HtmlOutputProcessor outputProcessor = new StreamHtmlOutputProcessor( report.getConfiguration() );
  final HtmlPrinter printer = new AllItemsHtmlPrinter( report.getResourceManager() );
  printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, "index", "html" ) );
  printer.setDataWriter( null, null );
  printer.setUrlRewriter( new FileSystemURLRewriter() );
  outputProcessor.setPrinter( printer );

  final StreamReportProcessor sp = new StreamReportProcessor( report, outputProcessor );
  sp.processReport();
  sp.close();
}
 
Example 2
Source File: AbstractReportProcessor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected DefaultProcessingContext createProcessingContext() throws ReportProcessingException {
  final OutputProcessorMetaData metaData = getOutputProcessorMetaData();
  final MasterReport report = getReport();
  final DocumentMetaData documentMetaData;
  final DocumentBundle bundle = report.getBundle();
  if ( bundle != null ) {
    documentMetaData = bundle.getMetaData();
  } else {
    documentMetaData = new MemoryDocumentMetaData();
  }
  final Integer compatibilityLevel = report.getCompatibilityLevel();
  final int cLevel;
  if ( compatibilityLevel == null ) {
    cLevel = -1;
  } else {
    cLevel = compatibilityLevel;
  }
  return new DefaultProcessingContext( metaData, report.getResourceBundleFactory(), report.getConfiguration(), report
      .getResourceManager(), report.getContentBase(), documentMetaData, report.getReportEnvironment(), cLevel );
}
 
Example 3
Source File: ExcelReportUtil.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void processFlowXlsx( final MasterReport report, OutputStream fout )
  throws ReportProcessingException, IOException {
  try {
    final FlowExcelOutputProcessor target =
      new FlowExcelOutputProcessor( report.getConfiguration(), fout, report.getResourceManager() );
    target.setUseXlsxFormat( true );
    final FlowReportProcessor reportProcessor = new FlowReportProcessor( report, target );
    reportProcessor.processReport();
    reportProcessor.close();
    fout.close();
    fout = null;
  } finally {
    if ( fout != null ) {
      try {
        fout.close();
      } catch ( Exception e ) {
        // ignore
      }
    }
  }
}
 
Example 4
Source File: BiServer11651Test.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void processSlowStreamHtml( final MasterReport report,
                                          final OutputStream outputStream )
  throws ReportProcessingException, ContentIOException {
  if ( report == null ) {
    throw new NullPointerException();
  }
  if ( outputStream == null ) {
    throw new NullPointerException();
  }

  final ZipRepository zipRepository = new ZipRepository();
  final StreamRepository targetRepository = new StreamRepository( outputStream );
  final ContentLocation targetRoot = targetRepository.getRoot();

  final HtmlOutputProcessor outputProcessor = new StreamHtmlOutputProcessor( report.getConfiguration() );
  final HtmlPrinter printer = new AllItemsHtmlPrinter( report.getResourceManager() );
  printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, "index", "html" ) );
  printer.setDataWriter( zipRepository.getRoot(), new DefaultNameGenerator( targetRoot, "data", "bin" ) );
  printer.setUrlRewriter( new StaticURLRewriter( "http://localhost:12345/content/{0}" ) );
  outputProcessor.setPrinter( printer );

  final StreamReportProcessor sp = new StreamReportProcessor( report, outputProcessor );
  sp.processReport();
  sp.close();
}
 
Example 5
Source File: FlowExcelReportProcessTask.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @noinspection ThrowableInstanceNeverThrown
 */
public void run() {
  if ( isValid() == false ) {
    setError( new ReportProcessingException( "Error: The task is not configured properly." ) );
    return;
  }

  setError( null );
  try {
    final MasterReport masterReport = getReport();
    final Configuration configuration = masterReport.getConfiguration();

    final ContentLocation contentLocation = getBodyContentLocation();
    final NameGenerator nameGenerator = getBodyNameGenerator();
    final ContentItem contentItem =
        contentLocation.createItem( nameGenerator.generateName( null, "application/vnd.ms-excel" ) );
    final OutputStream outputStream = contentItem.getOutputStream();

    try {
      final FlowExcelOutputProcessor outputProcessor =
          new FlowExcelOutputProcessor( configuration, outputStream, masterReport.getResourceManager() );
      outputProcessor.setUseXlsxFormat( false );
      final FlowReportProcessor streamReportProcessor = new FlowReportProcessor( masterReport, outputProcessor );
      try {
        final ReportProgressListener[] progressListeners = getReportProgressListeners();
        for ( int i = 0; i < progressListeners.length; i++ ) {
          final ReportProgressListener listener = progressListeners[i];
          streamReportProcessor.addReportProgressListener( listener );
        }
        streamReportProcessor.processReport();
      } finally {
        streamReportProcessor.close();
      }
    } finally {
      outputStream.close();
    }
  } catch ( Throwable e ) {
    setError( e );
  }
}
 
Example 6
Source File: FlowHtmlReportProcessTask.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @noinspection ThrowableInstanceNeverThrown
 */
public void run() {
  if ( isValid() == false ) {
    setError( new ReportProcessingException( "Error: The task is not configured properly." ) );
    return;
  }

  setError( null );
  try {
    final MasterReport masterReport = getReport();
    final Configuration configuration = masterReport.getConfiguration();

    final HtmlPrinter printer = new AllItemsHtmlPrinter( masterReport.getResourceManager() );
    printer.setContentWriter( getBodyContentLocation(), getBodyNameGenerator() );
    printer.setDataWriter( getBulkLocation(), getBulkNameGenerator() );
    printer.setUrlRewriter( computeUrlRewriter() );

    final FlowHtmlOutputProcessor outputProcessor = new FlowHtmlOutputProcessor();

    final FlowReportProcessor streamReportProcessor = new FlowReportProcessor( masterReport, outputProcessor );
    try {
      final ReportProgressListener[] progressListeners = getReportProgressListeners();
      for ( int i = 0; i < progressListeners.length; i++ ) {
        final ReportProgressListener listener = progressListeners[i];
        streamReportProcessor.addReportProgressListener( listener );
      }
      streamReportProcessor.processReport();
    } finally {
      streamReportProcessor.close();
    }
  } catch ( Throwable e ) {
    setError( e );
  }
}
 
Example 7
Source File: PageableHtmlReportProcessTask.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @noinspection ThrowableInstanceNeverThrown
 */
public void run() {
  if ( isValid() == false ) {
    setError( new ReportProcessingException( "Error: The task is not configured properly." ) );
    return;
  }

  setError( null );
  try {
    final MasterReport masterReport = getReport();
    final Configuration configuration = masterReport.getConfiguration();

    final HtmlPrinter printer = new AllItemsHtmlPrinter( masterReport.getResourceManager() );
    printer.setContentWriter( getBodyContentLocation(), getBodyNameGenerator() );
    printer.setDataWriter( getBulkLocation(), getBulkNameGenerator() );
    printer.setUrlRewriter( computeUrlRewriter() );

    final PageableHtmlOutputProcessor outputProcessor = new PageableHtmlOutputProcessor( configuration );
    final PageableReportProcessor streamReportProcessor = new PageableReportProcessor( masterReport, outputProcessor );
    try {
      final ReportProgressListener[] progressListeners = getReportProgressListeners();
      for ( int i = 0; i < progressListeners.length; i++ ) {
        final ReportProgressListener listener = progressListeners[i];
        streamReportProcessor.addReportProgressListener( listener );
      }
      streamReportProcessor.processReport();
    } finally {
      streamReportProcessor.close();
    }
  } catch ( Throwable e ) {
    setError( e );
  }
}
 
Example 8
Source File: StreamRTFReportProcessTask.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @noinspection ThrowableInstanceNeverThrown
 */
public void run() {
  if ( isValid() == false ) {
    setError( new ReportProcessingException( "Error: The task is not configured properly." ) );
    return;
  }

  setError( null );
  try {
    final MasterReport masterReport = getReport();
    final Configuration configuration = masterReport.getConfiguration();

    final ContentLocation contentLocation = getBodyContentLocation();
    final NameGenerator nameGenerator = getBodyNameGenerator();
    final ContentItem contentItem =
        contentLocation.createItem( nameGenerator.generateName( null, "application/rtf" ) );
    final OutputStream outputStream = contentItem.getOutputStream();

    try {
      final StreamRTFOutputProcessor outputProcessor =
          new StreamRTFOutputProcessor( configuration, outputStream, masterReport.getResourceManager() );
      final StreamReportProcessor streamReportProcessor = new StreamReportProcessor( masterReport, outputProcessor );
      try {
        final ReportProgressListener[] progressListeners = getReportProgressListeners();
        for ( int i = 0; i < progressListeners.length; i++ ) {
          final ReportProgressListener listener = progressListeners[i];
          streamReportProcessor.addReportProgressListener( listener );
        }
        streamReportProcessor.processReport();
      } finally {
        streamReportProcessor.close();
      }
    } finally {
      outputStream.close();
    }
  } catch ( Throwable e ) {
    setError( e );
  }
}
 
Example 9
Source File: Prd3795IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * This method does what the report designer does on save.
 */
private void saveReport( final MasterReport report, final File file ) throws Exception {
  BundleWriter.writeReportToZipFile( report, file );
  final ResourceManager resourceManager = report.getResourceManager();
  final Resource bundleResource = resourceManager.createDirectly( file, DocumentBundle.class );
  final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource();
  final ResourceKey bundleKey = bundle.getBundleKey();

  final MemoryDocumentBundle mem = new MemoryDocumentBundle();
  BundleUtilities.copyStickyInto( mem, bundle );
  BundleUtilities.copyMetaData( mem, bundle );
  report.setBundle( mem );
  report.setContentBase( mem.getBundleMainKey() );
  report.setDefinitionSource( bundleKey );
}
 
Example 10
Source File: Prd3159IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * This method does what the report designer does on save.
 *
 * @param report
 * @param file
 * @throws Exception
 */
private void saveReport( final MasterReport report, final File file ) throws Exception {
  BundleWriter.writeReportToZipFile( report, file );
  final ResourceManager resourceManager = report.getResourceManager();
  final Resource bundleResource = resourceManager.createDirectly( file, DocumentBundle.class );
  final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource();
  final ResourceKey bundleKey = bundle.getBundleKey();

  final MemoryDocumentBundle mem = new MemoryDocumentBundle();
  BundleUtilities.copyStickyInto( mem, bundle );
  BundleUtilities.copyMetaData( mem, bundle );
  report.setBundle( mem );
  report.setContentBase( mem.getBundleMainKey() );
  report.setDefinitionSource( bundleKey );
}
 
Example 11
Source File: Prd4069IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testFlowTableExport() throws ReportProcessingException {
  if ( DebugReportRunner.isSkipLongRunTest() ) {
    return;
  }
  final MasterReport report = createTestReport();
  final FlowExcelOutputProcessor target =
      new ValidatingFlowExcelOutputProcessor( report.getConfiguration(), new NullOutputStream(), report
          .getResourceManager() );
  target.setUseXlsxFormat( true );
  final FlowReportProcessor reportProcessor = new FlowReportProcessor( report, target );
  reportProcessor.processReport();
  reportProcessor.close();

}
 
Example 12
Source File: Prd3319IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * This method does what the report designer does on save.
 *
 * @param report
 * @param file
 * @throws Exception
 */
private void saveReport( final MasterReport report, final File file ) throws Exception {
  BundleWriter.writeReportToZipFile( report, file );
  final ResourceManager resourceManager = report.getResourceManager();
  final Resource bundleResource = resourceManager.createDirectly( file, DocumentBundle.class );
  final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource();
  final ResourceKey bundleKey = bundle.getBundleKey();

  final MemoryDocumentBundle mem = new MemoryDocumentBundle();
  BundleUtilities.copyStickyInto( mem, bundle );
  BundleUtilities.copyMetaData( mem, bundle );
  report.setBundle( mem );
  report.setContentBase( mem.getBundleMainKey() );
  report.setDefinitionSource( bundleKey );
}
 
Example 13
Source File: SimpleMondrianDataSourceEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String lookupSchemaName() {
  final AbstractReportDefinition report = context.getReport();
  final MasterReport masterReport = DesignTimeUtil.getMasterReport( report );

  final ResourceManager resourceManager = masterReport.getResourceManager();
  final ResourceKey contextKey = masterReport.getContentBase();
  final String designTimeFile = filenameField.getText();
  return MondrianUtil.parseSchemaName( resourceManager, contextKey, designTimeFile );
}
 
Example 14
Source File: MondrianDataSourceEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String lookupSchemaName() {
  final AbstractReportDefinition report = context.getReport();
  final MasterReport masterReport = DesignTimeUtil.getMasterReport( report );

  final ResourceManager resourceManager = masterReport.getResourceManager();
  final ResourceKey contextKey = masterReport.getContentBase();
  final String designTimeFile = filenameField.getText();
  return MondrianUtil.parseSchemaName( resourceManager, contextKey, designTimeFile );
}
 
Example 15
Source File: ReportWriter.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Builds a default configuration from a given report definition object.
 * <p/>
 * This will only create a valid definition, if the report has a valid content base object set.
 *
 * @param report
 *          the report for which to create the writer configuration.
 * @return the generated configuration.
 */
public static Configuration createDefaultConfiguration( final MasterReport report ) {
  final ModifiableConfiguration repConf = new HierarchicalConfiguration( report.getReportConfiguration() );
  final ResourceKey contentBase = report.getContentBase();
  if ( contentBase != null ) {
    final ResourceManager resourceManager = report.getResourceManager();
    final URL value = resourceManager.toURL( contentBase );
    if ( value != null ) {
      repConf.setConfigProperty( AbstractXmlResourceFactory.CONTENTBASE_KEY, value.toExternalForm() );
    }
  }

  return repConf;
}
 
Example 16
Source File: PageableExcelReportProcessTask.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * @noinspection ThrowableInstanceNeverThrown
 */
public void run() {
  if ( isValid() == false ) {
    setError( new ReportProcessingException( "Error: The task is not configured properly." ) );
    return;
  }

  setError( null );
  try {
    final MasterReport masterReport = getReport();
    final Configuration configuration = masterReport.getConfiguration();

    final ContentLocation contentLocation = getBodyContentLocation();
    final NameGenerator nameGenerator = getBodyNameGenerator();
    final ContentItem contentItem =
        contentLocation.createItem( nameGenerator.generateName( null, "application/vnd.ms-excel" ) );
    final OutputStream outputStream = contentItem.getOutputStream();

    try {
      final PageableExcelOutputProcessor outputProcessor =
          new PageableExcelOutputProcessor( configuration, outputStream, masterReport.getResourceManager() );
      outputProcessor.setUseXlsxFormat( false );
      final PageableReportProcessor streamReportProcessor =
          new PageableReportProcessor( masterReport, outputProcessor );
      try {
        final ReportProgressListener[] progressListeners = getReportProgressListeners();
        for ( int i = 0; i < progressListeners.length; i++ ) {
          final ReportProgressListener listener = progressListeners[i];
          streamReportProcessor.addReportProgressListener( listener );
        }
        streamReportProcessor.processReport();
      } finally {
        streamReportProcessor.close();
      }
    } finally {
      outputStream.close();
    }
  } catch ( Throwable e ) {
    setError( e );
  }
}
 
Example 17
Source File: Graphics2DReportProcessTask.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * @noinspection ThrowableInstanceNeverThrown
 */
public void run() {
  if ( isValid() == false ) {
    setError( new ReportProcessingException( "Error: The task is not configured properly." ) );
    return;
  }

  setError( null );
  try {
    final MasterReport masterReport = getReport();
    final Configuration configuration = masterReport.getConfiguration();
    final boolean alphaChannel =
        "true"
            .equals( configuration
                .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.pageable.graphics.AlphaChannel" ) );
    final String mimeType = computeMimeType( configuration );
    final float quality =
        ParserUtil
            .parseFloat(
                configuration
                    .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.pageable.graphics.Quality" ),
                0.9f );

    final GraphicsOutputProcessor outputProcessor =
        new GraphicsOutputProcessor( new StreamGraphicsOutputProcessorMetaData(), masterReport.getResourceManager() );
    final StreamReportProcessor streamReportProcessor = new StreamReportProcessor( masterReport, outputProcessor );
    final ReportProgressListener[] progressListeners = getReportProgressListeners();
    for ( int i = 0; i < progressListeners.length; i++ ) {
      final ReportProgressListener listener = progressListeners[i];
      streamReportProcessor.addReportProgressListener( listener );
    }

    final ImageGeneratorInterceptor interceptor = new ImageGeneratorInterceptor();
    outputProcessor.setInterceptor( interceptor );
    streamReportProcessor.processReport();
    streamReportProcessor.close();

    final ContentLocation contentLocation = getBodyContentLocation();
    final NameGenerator nameGenerator = getBodyNameGenerator();
    final ContentItem contentItem = contentLocation.createItem( nameGenerator.generateName( null, mimeType ) );
    final BufferedImage image = interceptor.getImage();
    final ImageEncoder imageEncoder = ImageEncoderRegistry.getInstance().createEncoder( mimeType );
    final OutputStream outputStream = contentItem.getOutputStream();
    imageEncoder.encodeImage( image, outputStream, quality, alphaChannel );
    outputStream.close();
  } catch ( Throwable e ) {
    setError( e );
  }
}
 
Example 18
Source File: ZipHtmlReportProcessTask.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void run() {
  if ( isValid() == false ) {
    setError( new ReportProcessingException( "Error: The task is not configured properly." ) );
    return;
  }

  setError( null );
  try {
    final MasterReport report = getReport();
    final ContentLocation contentLocation = getBodyContentLocation();
    final NameGenerator nameGenerator = getBodyNameGenerator();
    final ContentItem contentItem =
        contentLocation.createItem( nameGenerator.generateName( null, "application/zip" ) );
    final OutputStream out = contentItem.getOutputStream();

    try {
      final ZipRepository zipRepository = new ZipRepository( out );
      try {
        final ContentLocation root = zipRepository.getRoot();
        final ContentLocation data =
            RepositoryUtilities.createLocation( zipRepository, RepositoryUtilities.splitPath( "data", "/" ) );

        final FlowHtmlOutputProcessor outputProcessor = new FlowHtmlOutputProcessor();

        final HtmlPrinter printer = new AllItemsHtmlPrinter( report.getResourceManager() );
        printer.setContentWriter( root, new DefaultNameGenerator( root, "report" ) );
        printer.setDataWriter( data, new DefaultNameGenerator( data, "content" ) );
        printer.setUrlRewriter( new SingleRepositoryURLRewriter() );
        outputProcessor.setPrinter( printer );

        final FlowReportProcessor sp = new FlowReportProcessor( report, outputProcessor );
        try {
          final ReportProgressListener[] progressListeners = getReportProgressListeners();
          for ( int i = 0; i < progressListeners.length; i++ ) {
            final ReportProgressListener listener = progressListeners[i];
            sp.addReportProgressListener( listener );
          }
          sp.processReport();
        } finally {
          sp.close();
        }
      } finally {
        zipRepository.close();
      }
    } finally {
      out.close();
    }
  } catch ( Throwable e ) {
    setError( e );
  }

}
 
Example 19
Source File: StreamXExcelReportProcessTask.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * @noinspection ThrowableInstanceNeverThrown
 */
public void run() {
  if ( isValid() == false ) {
    setError( new ReportProcessingException( "Error: The task is not configured properly." ) );
    return;
  }

  setError( null );
  try {
    final MasterReport masterReport = getReport();
    final Configuration configuration = masterReport.getConfiguration();

    final ContentLocation contentLocation = getBodyContentLocation();
    final NameGenerator nameGenerator = getBodyNameGenerator();
    final ContentItem contentItem =
        contentLocation.createItem( nameGenerator.generateName( null,
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ) );
    final OutputStream outputStream = contentItem.getOutputStream();

    try {
      final StreamExcelOutputProcessor outputProcessor =
          new StreamExcelOutputProcessor( configuration, outputStream, masterReport.getResourceManager() );
      outputProcessor.setUseXlsxFormat( true );
      final StreamReportProcessor streamReportProcessor = new StreamReportProcessor( masterReport, outputProcessor );
      try {
        final ReportProgressListener[] progressListeners = getReportProgressListeners();
        for ( int i = 0; i < progressListeners.length; i++ ) {
          final ReportProgressListener listener = progressListeners[i];
          streamReportProcessor.addReportProgressListener( listener );
        }
        streamReportProcessor.processReport();
      } finally {
        streamReportProcessor.close();
      }
    } finally {
      outputStream.close();
    }
  } catch ( Throwable e ) {
    setError( e );
  }
}
 
Example 20
Source File: HtmlReportUtil.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Saves a report to HTML. The HTML file is stored in a directory; all other content goes into the same directory as
 * the specified html file. The parent directories for both the TargetFilename and the DataDirectoryName will be
 * created if necessary.
 * <p/>
 * When exporting a report with manual pagebreaks, the directory of the target-filename will contain more than one
 * result-HTML files after the export is complete.
 *
 * @param report
 *          the report.
 * @param targetFileName
 *          target file name.
 * @throws ReportProcessingException
 *           if the report processing failed.
 * @throws IOException
 *           if there was an IOerror while processing the report.
 */
public static void createDirectoryHTML( final MasterReport report, final String targetFileName,
    final String dataDirectoryName ) throws IOException, ReportProcessingException {
  if ( report == null ) {
    throw new NullPointerException();
  }
  if ( targetFileName == null ) {
    throw new NullPointerException();
  }
  if ( dataDirectoryName == null ) {
    throw new NullPointerException();
  }
  try {
    final File targetFile = new File( targetFileName );
    if ( targetFile.exists() ) {
      // try to delete it ..
      if ( targetFile.delete() == false ) {
        throw new IOException( "Unable to remove the already existing target-file." );
      }
    }

    final File targetDirectory = targetFile.getParentFile().getCanonicalFile();
    if ( targetDirectory.exists() == false ) {
      if ( targetDirectory.mkdirs() == false ) {
        throw new IOException( "Unable to create the target-directory." );
      }
    }

    final File tempDataDir = new File( dataDirectoryName ).getCanonicalFile();
    File dataDirectory;
    if ( 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( "DataDirectory is invalid: " + dataDirectory );
      }
    } else if ( dataDirectory.exists() == false ) {
      if ( dataDirectory.mkdirs() == false ) {
        throw new IOException( "Unable to create the data-directory." );
      }
    }

    final FileRepository targetRepository = new FileRepository( targetDirectory );
    final ContentLocation targetRoot = targetRepository.getRoot();

    final FileRepository dataRepository = new FileRepository( dataDirectory );
    final ContentLocation dataRoot = dataRepository.getRoot();

    final String suffix = getSuffix( targetFileName );
    final String filename = IOUtils.getInstance().stripFileExtension( targetFile.getName() );

    final FlowHtmlOutputProcessor outputProcessor = new FlowHtmlOutputProcessor();

    final HtmlPrinter printer = new AllItemsHtmlPrinter( report.getResourceManager() );
    printer.setContentWriter( targetRoot, new DefaultNameGenerator( targetRoot, filename, suffix ) );
    printer.setDataWriter( dataRoot, new DefaultNameGenerator( dataRoot, "content" ) );
    printer.setUrlRewriter( new FileSystemURLRewriter() );
    outputProcessor.setPrinter( printer );

    final FlowReportProcessor sp = new FlowReportProcessor( report, outputProcessor );
    sp.processReport();
    sp.close();
  } catch ( ContentIOException e ) {
    throw new IOException( "Failed to get repository-root." );
  }
}