示例#1
0
  public ActionForward generate(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ExecutionCourse executionCourse = getExecutionCourse(request);
    if (executionCourse == null) {
      return mapping.findForward("fallback");
    }

    ArchiveOptions options = getOptions(request);
    if (options == null) {
      return prepare(mapping, actionForm, request, response);
    }

    String name = getArchiveName(executionCourse);
    // NOTE: Using a DiskZipArchive instead of a ZipArchive because a
    // ZipArchive
    // writes directly to the response during the entire process and
    // prevents
    // the server from showing an error page when something goes wrong. This
    // leaves the user with a corrupt Zip file and no other information.
    Archive archive = new DiskZipArchive(response, name);
    Fetcher fetcher = new Fetcher(archive, request, response);

    queueResources(request, executionCourse, options, fetcher);

    List<Content> contents = new ArrayList<Content>();
    contents.add(MetaDomainObject.getMeta(ExecutionCourseSite.class).getAssociatedPortal());
    contents.add(executionCourse.getSite());
    FilterFunctionalityContext context = new FilterFunctionalityContext(request, contents);

    fetcher.process(context);
    archive.finish();

    return null;
  }