@Override
  protected boolean performExport(final MasterReport report) {
    try {
      final File targetFile =
          getInputFileValue(AbstractJFreeReportComponent.REPORTDIRECTORYHTML_TARGETFILE);
      if (targetFile == null) {
        return false;
      }

      File dataDirectory =
          getInputFileValue(AbstractJFreeReportComponent.REPORTDIRECTORYHTML_DATADIR);
      if (dataDirectory == null) {
        dataDirectory = new File(targetFile, "data/"); // $NON-NLS-1$
      }

      final File targetDirectory = targetFile.getParentFile();
      if (dataDirectory.exists() && (dataDirectory.isDirectory() == false)) {
        dataDirectory = dataDirectory.getParentFile();
        if (dataDirectory.isDirectory() == false) {
          String msg =
              Messages.getInstance()
                  .getErrorString(
                      "JFreeReportDirectoryComponent.ERROR_0001_INVALID_DIR", //$NON-NLS-1$
                      dataDirectory.getPath());
          throw new ReportProcessingException(msg);
        }
      } else if (dataDirectory.exists() == false) {
        dataDirectory.mkdirs();
      }

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

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

      final FlowHtmlOutputProcessor outputProcessor = new FlowHtmlOutputProcessor();

      final HtmlPrinter printer = new AllItemsHtmlPrinter(report.getResourceManager());
      printer.setContentWriter(
          targetRoot, new DefaultNameGenerator(targetRoot, targetFile.getName()));
      printer.setDataWriter(
          dataRoot, new DefaultNameGenerator(targetRoot, "content")); // $NON-NLS-1$
      printer.setUrlRewriter(new FileSystemURLRewriter());
      outputProcessor.setPrinter(printer);

      final FlowReportProcessor sp = new FlowReportProcessor(report, outputProcessor);
      final int yieldRate = getYieldRate();
      if (yieldRate > 0) {
        sp.addReportProgressListener(new YieldReportListener(yieldRate));
      }
      sp.processReport();
      sp.close();
      return true;
    } catch (ReportProcessingException e) {
      return false;
    } catch (ContentIOException e) {
      return false;
    }
  }
  protected void reinitOutputTarget() throws ReportProcessingException, ContentIOException {
    final IApplicationContext ctx = PentahoSystem.getApplicationContext();

    final ContentLocation dataLocation;
    final PentahoNameGenerator 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("Dead " + dataDirectory.getPath()); // $NON-NLS-1$
        }
      } else if (dataDirectory.exists() == false) {
        dataDirectory.mkdirs();
      }

      final FileRepository dataRepository = new FileRepository(dataDirectory);
      dataLocation = dataRepository.getRoot();
      dataNameGenerator = PentahoSystem.get(PentahoNameGenerator.class);
      if (dataNameGenerator == null) {
        throw new IllegalStateException(
            Messages.getInstance()
                .getString("ReportPlugin.errorNameGeneratorMissingConfiguration"));
      }
      dataNameGenerator.initialize(dataLocation, true);
    } else {
      dataLocation = null;
      dataNameGenerator = null;
    }

    final StreamRepository targetRepository =
        new StreamRepository(null, proxyOutputStream, "report"); // $NON-NLS-1$
    final ContentLocation targetRoot = targetRepository.getRoot();

    printer.setContentWriter(
        targetRoot,
        new DefaultNameGenerator(targetRoot, "index", "html")); // $NON-NLS-1$ //$NON-NLS-2$
    printer.setDataWriter(dataLocation, dataNameGenerator);
  }
  @SuppressWarnings("deprecation")
  @Override
  protected boolean performExport(final MasterReport report, final OutputStream outputStream) {
    try {
      IContentRepository contentRepository = null;
      try {
        contentRepository = PentahoSystem.get(IContentRepository.class, getSession());
      } catch (Throwable t) {
        debug(
            Messages.getInstance()
                .getString("JFreeReportHtmlComponent.DEBUG_0044_PROCESSING_WITHOUT_CONTENT_REPOS"),
            t); //$NON-NLS-1$
      }

      String contentHandlerPattern =
          getInputStringValue(AbstractJFreeReportComponent.REPORTHTML_CONTENTHANDLER);
      if (contentHandlerPattern == null) {
        final Configuration globalConfig = ClassicEngineBoot.getInstance().getGlobalConfig();
        contentHandlerPattern =
            globalConfig.getConfigProperty("org.pentaho.web.ContentHandler"); // $NON-NLS-1$
      }

      final IApplicationContext ctx = PentahoSystem.getApplicationContext();

      final URLRewriter rewriter;
      final ContentLocation dataLocation;
      final NameGenerator dataNameGenerator;
      if ((contentRepository == null)
          || JFreeReportHtmlComponent.DO_NOT_USE_THE_CONTENT_REPOSITORY) {
        debug(
            Messages.getInstance()
                .getString(
                    "JFreeReportHtmlComponent.DEBUG_0044_PROCESSING_WITHOUT_CONTENT_REPOS")); //$NON-NLS-1$
        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(contentHandlerPattern);
        } else {
          dataLocation = null;
          dataNameGenerator = null;
          rewriter = new PentahoURLRewriter(contentHandlerPattern);
        }
      } else {
        debug(
            Messages.getInstance()
                .getString(
                    "JFreeReportHtmlComponent.DEBUG_045_PROCESSING_WITH_CONTENT_REPOS")); //$NON-NLS-1$
        final String thePath =
            getSolutionName()
                + "/"
                + getSolutionPath()
                + "/"
                + getSession().getId(); // $NON-NLS-1$//$NON-NLS-2$
        final IContentLocation pentahoContentLocation =
            contentRepository.newContentLocation(
                thePath, getActionName(), getActionTitle(), getSolutionPath(), true);
        // todo
        final ReportContentRepository repository =
            new ReportContentRepository(pentahoContentLocation, getActionName());
        dataLocation = repository.getRoot();
        dataNameGenerator = new DefaultNameGenerator(dataLocation);
        rewriter = new PentahoURLRewriter(contentHandlerPattern);
      }

      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);
      printer.setUrlRewriter(rewriter);
      outputProcessor.setPrinter(printer);

      final StreamReportProcessor sp = new StreamReportProcessor(report, outputProcessor);
      final int yieldRate = getYieldRate();
      if (yieldRate > 0) {
        sp.addReportProgressListener(new YieldReportListener(yieldRate));
      }
      sp.processReport();
      sp.close();

      outputStream.flush();
      close();
      return true;
    } catch (ReportProcessingException e) {
      error(
          Messages.getInstance()
              .getString("JFreeReportHtmlComponent.ERROR_0046_FAILED_TO_PROCESS_REPORT"),
          e); //$NON-NLS-1$
      return false;
    } catch (IOException e) {
      error(
          Messages.getInstance()
              .getString("JFreeReportHtmlComponent.ERROR_0046_FAILED_TO_PROCESS_REPORT"),
          e); //$NON-NLS-1$
      return false;
    } catch (ContentIOException e) {
      error(
          Messages.getInstance()
              .getString("JFreeReportHtmlComponent.ERROR_0046_FAILED_TO_PROCESS_REPORT"),
          e); //$NON-NLS-1$
      return false;
    }
  }