}
final IApplicationContext ctx = PentahoSystem.getApplicationContext();
final URLRewriter rewriter;
final ContentLocation dataLocation;
final NameGenerator dataNameGenerator;
if ( ctx != null ) {
File dataDirectory = new File( ctx.getFileOutputPath( "system/tmp/" ) ); //$NON-NLS-1$
if ( dataDirectory.exists() && ( dataDirectory.isDirectory() == false ) ) {
dataDirectory = dataDirectory.getParentFile();
if ( dataDirectory.isDirectory() == false ) {
throw new ReportProcessingException( Messages.getInstance().getErrorString(
"JFreeReportDirectoryComponent.ERROR_0001_INVALID_DIR", dataDirectory.getPath() ) ); //$NON-NLS-1$
}
} else if ( dataDirectory.exists() == false ) {
dataDirectory.mkdirs();
}
final FileRepository dataRepository = new FileRepository( dataDirectory );
dataLocation = dataRepository.getRoot();
dataNameGenerator = new DefaultNameGenerator( dataLocation );
rewriter = new PentahoURLRewriter( htmlContentHandlerUrlPattern );
} else {
dataLocation = null;
dataNameGenerator = null;
rewriter = new PentahoURLRewriter( htmlContentHandlerUrlPattern );
}
final StreamRepository targetRepository = new StreamRepository( null, 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" ) ); //$NON-NLS-1$//$NON-NLS-2$
printer.setDataWriter( dataLocation, dataNameGenerator );