/**
   * 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);
  }