public void event(UserRequest ureq, Controller source, Event event) {
    if (source == logFileChooserForm) {
      if (event == Event.DONE_EVENT) {
        final boolean logAdminChecked = logFileChooserForm.logAdminChecked();
        final boolean logUserChecked = logFileChooserForm.logUserChecked();
        final boolean logStatisticChecked = logFileChooserForm.logStatChecked();

        final Date begin = logFileChooserForm.getBeginDate();
        final Date end = logFileChooserForm.getEndDate();

        if (end != null) {
          // shift time from beginning to end of day
          end.setTime(end.getTime() + 24 * 60 * 60 * 1000);
        }

        UserManager um = UserManager.getInstance();
        final String charset = um.getUserCharset(ureq.getIdentity());

        ICourse course = CourseFactory.loadCourse(ores);
        final String courseTitle = course.getCourseTitle();
        final String targetDir =
            CourseFactory.getOrCreateDataExportDirectory(ureq.getIdentity(), courseTitle).getPath();

        final Long resId = ores.getResourceableId();
        final Locale theLocale = ureq.getLocale();
        final String email =
            ureq.getIdentity().getUser().getProperty(UserConstants.EMAIL, ureq.getLocale());

        AsyncExportManager.getInstance()
            .asyncArchiveCourseLogFiles(
                ureq.getIdentity(),
                new Runnable() {

                  @Override
                  public void run() {
                    showExportFinished();
                  }
                },
                resId,
                targetDir,
                begin,
                end,
                logAdminChecked,
                logUserChecked,
                logStatisticChecked,
                charset,
                theLocale,
                email);

        showExportOngoing(true);
      } else if (event == Event.DONE_EVENT) {
        myPanel.setContent(myContent);
      }
    }
  }
  /**
   * Constructor for the course logs archive controller
   *
   * @param ureq
   * @param wControl
   * @param course
   */
  public CourseLogsArchiveController(
      UserRequest ureq, WindowControl wControl, OLATResourceable ores) {
    super(ureq, wControl);
    this.ores = ores;
    this.myPanel = new Panel("myPanel");
    myPanel.addListener(this);

    myContent = createVelocityContainer("start_courselogs");

    Identity identity = ureq.getIdentity();
    Roles roles = ureq.getUserSession().getRoles();

    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(ores, false);
    boolean isOLATAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
    boolean isOresOwner = RepositoryManager.getInstance().isOwnerOfRepositoryEntry(identity, re);
    boolean isOresInstitutionalManager =
        RepositoryManager.getInstance().isInstitutionalRessourceManagerFor(identity, roles, re);
    boolean aLogV = isOresOwner || isOresInstitutionalManager;
    boolean uLogV = isOLATAdmin;
    boolean sLogV = isOresOwner || isOresInstitutionalManager;

    if (AsyncExportManager.getInstance().asyncArchiveCourseLogOngoingFor(ureq.getIdentity())) {
      // then show the ongoing feedback
      showExportOngoing(false);
    } else if (isOLATAdmin || aLogV || uLogV || sLogV) {
      myContent.contextPut("hasLogArchiveAccess", true);
      logFileChooserForm = new LogFileChooserForm(ureq, wControl, isOLATAdmin, aLogV, uLogV, sLogV);
      listenTo(logFileChooserForm);
      myContent.put("logfilechooserform", logFileChooserForm.getInitialComponent());
      ICourse course = CourseFactory.loadCourse(ores);
      myContent.contextPut(
          "body", translate("course.logs.existingarchiveintro", course.getCourseTitle()));
      showFileButton = LinkFactory.createButton("showfile", myContent, this);
      File exportDir =
          CourseFactory.getDataExportDirectory(ureq.getIdentity(), course.getCourseTitle());
      boolean exportDirExists = false;
      if (exportDir != null && exportDir.exists() && exportDir.isDirectory()) {
        exportDirExists = true;
      }
      myContent.contextPut("hascourselogarchive", new Boolean(exportDirExists));
      myPanel.setContent(myContent);
    } else {
      myContent.contextPut("hasLogArchiveAccess", new Boolean(false));
      myPanel.setContent(myContent);
    }

    putInitialPanel(myPanel);
  }