protected boolean validateFormLogic(UserRequest ureq) {
    // validate event dates
    for (Project.EventType eventType : eventStartElementList.keySet()) {
      Date startDate = eventStartElementList.get(eventType).getDate();
      Date endDate = eventEndElementList.get(eventType).getDate();
      getLogger().debug("validate startDate=" + startDate + " enddate=" + endDate);
      if ((startDate != null) && (endDate != null) && startDate.after(endDate)) {
        eventStartElementList.get(eventType).setErrorKey("from.error.date.start.after.end", null);
        return false;
      }
    }
    if (!project.getTitle().equals(projectTitle.getValue())
        && ProjectBrokerManagerFactory.getProjectBrokerManager()
            .existProjectName(project.getProjectBroker().getKey(), projectTitle.getValue())) {
      projectTitle.setErrorKey("form.error.project.title.already.exist", null);
      return false;
    }
    if (projectTitle.getValue().trim().isEmpty()) {
      projectTitle.setErrorKey("form.error.project.title.is.empty", null);
      return false;
    }

    // http://jira.openolat.org/browse/OO-131  check for too long filename
    if (attachmentFileName.getUploadFileName() != null
        && attachmentFileName.getUploadFileName().length() > 99) {
      attachmentFileName.setErrorKey("form.error.project.filenametoolong", null);
      return false;
    }
    return true;
  }
  @Override
  protected void formOK(UserRequest ureq) {
    if (importKeys.isVisible() && importKeys.getSelectedKeys().size() > 0) {
      Collection<String> importLangKeys = importKeys.getSelectedKeys();
      Set<String> alreadyInstalledLangs = new HashSet<String>();
      for (String langKey : importLangKeys) {
        if (I18nModule.getAvailableLanguageKeys().contains(langKey)) {
          alreadyInstalledLangs.add(langKey);
        }
      }
      if (I18nModule.isTransToolEnabled()) {
        // In translation mode importing will copy the language package
        // over an existing language or create a new language
        File tmpJar = importFile.getUploadFile();
        I18nManager.getInstance().copyLanguagesFromJar(tmpJar, importLangKeys);
        logAudit("Uploaded languages from jar::" + importFile.getUploadFileName(), null);
        showInfo("configuration.management.package.import.success", importLangKeys.toString());

      } else {
        // In language adaption mode: import is copied to user managed i18n package space in
        // olatdata
        if (alreadyInstalledLangs.size() == importLangKeys.size()) {
          showError("configuration.management.package.import.failure.installed");
          return;
        }
        // Ok, contains at least one language, copy to lang pack dir
        importFile.moveUploadFileTo(I18nModule.LANG_PACKS_DIRECTORY);
        logAudit("Uploaded language pack::" + importFile.getUploadFileName(), null);

        if (alreadyInstalledLangs.size() > 0) {
          getWindowControl()
              .setWarning(
                  getTranslator()
                      .translate(
                          "configuration.management.package.import.success.with.existing",
                          new String[] {
                            importLangKeys.toString(), alreadyInstalledLangs.toString()
                          }));
        } else {
          showInfo("configuration.management.package.import.success", importLangKeys.toString());
        }
      }
      // Reset i18n system
      I18nModule.reInitializeAndFlushCache();
      fireEvent(ureq, Event.DONE_EVENT);
    }
  }
 private void uploadFiles(FileElement attachmentFileElement) {
   VFSLeaf uploadedItem = new LocalFileImpl(attachmentFileElement.getUploadFile());
   ProjectBrokerManagerFactory.getProjectBrokerManager()
       .saveAttachedFile(
           project,
           attachmentFileElement.getUploadFileName(),
           uploadedItem,
           courseEnv,
           courseNode);
 }
 @Override
 protected void formOK(UserRequest ureq) {
   boolean projectChanged = false;
   if (!project.getTitle().equals(projectTitle.getValue())) {
     // title has been changed => change project-group name too
     String newProjectGroupName = translate("project.member.groupname", projectTitle.getValue());
     String newProjectGroupDescription =
         translate("project.member.groupdescription", projectTitle.getValue());
     OLATResource courseResource = courseEnv.getCourseGroupManager().getCourseResource();
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .changeProjectGroupName(
             getIdentity(),
             project.getProjectGroup(),
             newProjectGroupName,
             newProjectGroupDescription,
             courseResource);
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .sendGroupChangeEvent(project, courseEnv.getCourseResourceableId(), ureq.getIdentity());
     projectChanged = true;
   }
   if (!project.getTitle().equals(projectTitle.getValue())) {
     project.setTitle(projectTitle.getValue());
     projectChanged = true;
   }
   if (!project.getDescription().equals(projectDescription.getValue())) {
     project.setDescription(projectDescription.getValue());
     projectChanged = true;
   }
   if (projectState.isSelected(0)) {
     if (!project.getState().equals(stateKeys[0])) {
       project.setState(stateKeys[0]);
       projectChanged = true;
     }
   } else {
     if (!project.getState().equals(stateKeys[1])) {
       project.setState(stateKeys[1]);
       projectChanged = true;
     }
   }
   if (project.getMaxMembers() != maxMembers.getIntValue()) {
     project.setMaxMembers(maxMembers.getIntValue());
     projectChanged = true;
   }
   if (attachmentFileName.getUploadFileName() != null
       && !attachmentFileName.getUploadFileName().equals("")) {
     project.setAttachedFileName(attachmentFileName.getUploadFileName());
     uploadFiles(attachmentFileName);
   }
   // store customfields
   int index = 0;
   for (Iterator iterator = customfieldElementList.iterator(); iterator.hasNext(); ) {
     Object element = iterator.next();
     String value = "";
     if (element instanceof TextElement) {
       TextElement textElement = (TextElement) element;
       value = textElement.getValue();
     } else if (element instanceof SingleSelection) {
       SingleSelection selectionElement = (SingleSelection) element;
       if (!selectionElement.getSelectedKey().equals(DROPDOWN_NO_SELECETION)) {
         value = selectionElement.getSelectedKey();
       } else {
         value = "";
       }
     }
     if (!project.getCustomFieldValue(index).equals(value)) {
       project.setCustomFieldValue(index, value);
       projectChanged = true;
     }
     index++;
   }
   // store events
   for (Project.EventType eventType : eventStartElementList.keySet()) {
     Date startDate = eventStartElementList.get(eventType).getDate();
     Date endDate = eventEndElementList.get(eventType).getDate();
     if (!project.getProjectEvent(eventType).getStartDate().equals(startDate)
         || !project.getProjectEvent(eventType).getEndDate().equals(endDate)) {
       project.setProjectEvent(new ProjectEvent(eventType, startDate, endDate));
       projectChanged = true;
     }
   }
   if (projectChanged) {
     ProjectBrokerManagerFactory.getProjectBrokerManager().updateProject(project);
     ProjectBrokerManagerFactory.getProjectBrokerEmailer()
         .sendProjectChangedEmailToParticipants(ureq.getIdentity(), project, this.getTranslator());
     fireEvent(ureq, Event.DONE_EVENT);
   }
 }
 @Override
 protected void formOK(UserRequest ureq) {
   boolean projectChanged = false;
   if (!project.getTitle().equals(projectTitle.getValue())) {
     // title has been changed => change project-group name too
     String newProjectGroupName = translate("project.member.groupname", projectTitle.getValue());
     String newProjectGroupDescription =
         translate("project.member.groupdescription", projectTitle.getValue());
     OLATResource courseResource = courseEnv.getCourseGroupManager().getCourseResource();
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .changeProjectGroupName(
             getIdentity(),
             project.getProjectGroup(),
             newProjectGroupName,
             newProjectGroupDescription,
             courseResource);
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .sendGroupChangeEvent(project, courseEnv.getCourseResourceableId(), ureq.getIdentity());
     projectChanged = true;
   }
   if (!project.getTitle().equals(projectTitle.getValue())) {
     project.setTitle(projectTitle.getValue());
     projectChanged = true;
   }
   if (!project.getDescription().equals(projectDescription.getValue())) {
     project.setDescription(projectDescription.getValue());
     projectChanged = true;
   }
   if (project.getMaxMembers() != maxMembers.getIntValue()) {
     project.setMaxMembers(maxMembers.getIntValue());
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .setProjectGroupMaxMembers(
             getIdentity(), project.getProjectGroup(), maxMembers.getIntValue());
     projectChanged = true;
   }
   if (attachmentFileName.getUploadFileName() != null
       && !attachmentFileName.getUploadFileName().equals("")) {
     // First call uploadFiles than setAttachedFileName because uploadFiles needs old attachment
     // name
     uploadFiles(attachmentFileName);
     project.setAttachedFileName(attachmentFileName.getUploadFileName());
     projectChanged = true;
   } else if (project.getAttachmentFileName() != null
       && !project.getAttachmentFileName().equals("")) {
     // Attachment file has been removed
     project.setAttachedFileName("");
     projectChanged = true;
   }
   // store customfields
   int index = 0;
   for (Iterator iterator = customfieldElementList.iterator(); iterator.hasNext(); ) {
     Object element = iterator.next();
     String value = "";
     if (element instanceof TextElement) {
       TextElement textElement = (TextElement) element;
       value = textElement.getValue();
     } else if (element instanceof SingleSelection) {
       SingleSelection selectionElement = (SingleSelection) element;
       if (!selectionElement.getSelectedKey().equals(DROPDOWN_NO_SELECETION)) {
         value = selectionElement.getValue(selectionElement.getSelected());
       } else {
         value = "";
       }
     }
     getLogger()
         .debug(
             "customfield index="
                 + index
                 + " value="
                 + value
                 + " project.getCustomFieldValue(index)="
                 + project.getCustomFieldValue(index));
     if (!project.getCustomFieldValue(index).equals(value)) {
       project.setCustomFieldValue(index, value);
       projectChanged = true;
     }
     index++;
   }
   // store events
   for (Project.EventType eventType : eventStartElementList.keySet()) {
     Date startDate = eventStartElementList.get(eventType).getDate();
     Date endDate = eventEndElementList.get(eventType).getDate();
     // First handle startdate
     if (hasBeenChanged(project.getProjectEvent(eventType).getStartDate(), startDate)
         || hasBeenChanged(project.getProjectEvent(eventType).getEndDate(), endDate)) {
       project.setProjectEvent(new ProjectEvent(eventType, startDate, endDate));
       projectChanged = true;
     }
   }
   if (mailNotification.isSelected(0) != project.isMailNotificationEnabled()) {
     project.setMailNotificationEnabled(mailNotification.isSelected(0));
     projectChanged = true;
   }
   if (projectChanged) {
     if (ProjectBrokerManagerFactory.getProjectBrokerManager().existsProject(project.getKey())) {
       ProjectBrokerManagerFactory.getProjectBrokerManager().updateProject(project);
       ProjectBrokerManagerFactory.getProjectBrokerEmailer()
           .sendProjectChangedEmailToParticipants(
               ureq.getIdentity(), project, this.getTranslator());
     } else {
       this.showInfo("info.project.nolonger.exist", project.getTitle());
     }
   }
   fireEvent(ureq, Event.DONE_EVENT);
 }