Package org.projectforge.core

Examples of org.projectforge.core.UserException


  void setParent(final TaskNode parent)
  {
    if (parent != null) {
      if (parent.getId().equals(getId()) == true || this.isParentOf(parent)) {
        log.error("Oups, cyclic reference detection: taskId = " + getId() + ", parentTaskId = " + parent.getId());
        throw new UserException(TaskDao.I18N_KEY_ERROR_CYCLIC_REFERENCE);
      }
      this.parent = parent;
      this.task.setParentTask(parent.getTask());
    }
  }
View Full Code Here


  public boolean send(final Mail composedMessage, final String icalContent, final Collection<? extends MailAttachment> attachments)
  {
    final String to = composedMessage.getTo();
    if (to == null || to.trim().length() == 0) {
      log.error("No to address given. Sending of mail cancelled: " + composedMessage.toString());
      throw new UserException("mail.error.missingToAddress");
    }
    if (StringUtils.isBlank(sendMailConfig.getHost()) == true) {
      log.error("No e-mail host configured. E-Mail not sent: " + composedMessage.toString());
      return false;
    }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Override
  protected void onSaveOrModify(final ContractDO obj)
  {
    if (obj.getNumber() == null) {
      throw new UserException("validation.required.valueNotPresent", new MessageParam("legalAffaires.contract.number",
          MessageParamType.I18N_KEY));
    }
    if (obj.getId() == null) {
      // New contract
      final Integer next = getNextNumber(obj);
      if (next.intValue() != obj.getNumber().intValue()) {
        throw new UserException("legalAffaires.contract.error.numberNotConsecutivelyNumbered");
      }
    } else {
      final List<RechnungDO> list = getHibernateTemplate().find("from ContractDO c where c.number = ? and c.id <> ?",
          new Object[] { obj.getNumber(), obj.getId()});
      if (list != null && list.size() > 0) {
        throw new UserException("legalAffaires.contract.error.numberAlreadyExists");
      }
    }
  }
View Full Code Here

   * Throws UserException if vollstaendigFakturiert is true and status is not ABGESCHLOSSEN.
   */
  public void checkVollstaendigFakturiert()
  {
    if (vollstaendigFakturiert == true && (status == null || status.isIn(AuftragsPositionsStatus.ABGESCHLOSSEN) == false)) {
      throw new UserException("fibu.auftrag.error.nurAbgeschlosseneAuftragsPositionenKoennenVollstaendigFakturiertSein");
    }
  }
View Full Code Here

  {
    if (task.getParentTaskId() == null) {
      // Root task or task without parent task.
      if (taskTree.isRootNode(task) == false) {
        // Task is not root task!
        throw new UserException(I18N_KEY_ERROR_PARENT_TASK_NOT_GIVEN);
      }
    } else {
      List<TaskDO> list;
      if (task.getId() != null) {
        list = getHibernateTemplate().find("from TaskDO t where t.parentTask.id = ? and t.title = ? and t.id != ?",
            new Object[] { task.getParentTaskId(), task.getTitle(), task.getId()});
      } else {
        list = getHibernateTemplate().find("from TaskDO t where t.parentTask.id = ? and t.title = ?",
            new Object[] { task.getParentTaskId(), task.getTitle()});
      }
      if (CollectionUtils.isNotEmpty(list) == true) {
        throw new UserException(I18N_KEY_ERROR_DUPLICATE_CHILD_TASKS);
      }
    }
  }
View Full Code Here

  {
    Validate.notNull(dbObj);
    Validate.notNull(obj);
    if (taskTree.isRootNode(obj) == true) {
      if (obj.getParentTaskId() != null) {
        throw new UserException(TaskDao.I18N_KEY_ERROR_CYCLIC_REFERENCE);
      }
      if (accessChecker.isUserMemberOfGroup(user, throwException, ProjectForgeGroup.ADMIN_GROUP, ProjectForgeGroup.FINANCE_GROUP) == false) {
        return false;
      }
      return true;
    }
    Validate.notNull(dbObj.getParentTaskId());
    if (obj.getParentTaskId() == null) {
      throw new UserException(I18N_KEY_ERROR_PARENT_TASK_NOT_GIVEN);
    }
    final TaskNode parent = taskTree.getTaskNodeById(obj.getParentTaskId());
    if (parent == null) {
      throw new UserException(I18N_KEY_ERROR_PARENT_TASK_NOT_FOUND);
    }
    // Checks cyclic and self reference. The parent task is not allowed to be a self reference.
    checkCyclicReference(obj);
    if (accessChecker.isUserMemberOfGroup(user, ProjectForgeGroup.ADMIN_GROUP, ProjectForgeGroup.FINANCE_GROUP) == true) {
      return true;
View Full Code Here

    final TaskNode parent = taskTree.getTaskNodeById(obj.getParentTaskId());
    if (parent == null) {
      if (taskTree.isRootNode(obj) == true && obj.isDeleted() == true) {
        // Oups, the user has deleted the root task!
      } else {
        throw new UserException(I18N_KEY_ERROR_PARENT_TASK_NOT_FOUND);
      }
    }
    if (accessChecker.isUserMemberOfGroup(user, ProjectForgeGroup.ADMIN_GROUP, ProjectForgeGroup.FINANCE_GROUP) == true) {
      return true;
    }
View Full Code Here

  private void checkCyclicReference(final TaskDO obj)
  {
    if (obj.getId().equals(obj.getParentTaskId()) == true) {
      // Self reference
      throw new UserException(I18N_KEY_ERROR_CYCLIC_REFERENCE);
    }
    final TaskNode parent = taskTree.getTaskNodeById(obj.getParentTaskId());
    if (parent == null) {
      // Task is orphan because it has no parent task.
      throw new UserException(I18N_KEY_ERROR_PARENT_TASK_NOT_FOUND);
    }
    final TaskNode node = taskTree.getTaskNodeById(obj.getId());
    if (node.isParentOf(parent) == true) {
      // Cyclic reference because task is ancestor of itself.
      throw new UserException(TaskDao.I18N_KEY_ERROR_CYCLIC_REFERENCE);
    }
  }
View Full Code Here

   */
  @Override
  protected void onDelete(final TaskDO obj)
  {
    if (taskTree.isRootNode(obj) == true) {
      throw new UserException("task.error.couldNotDeleteRootTask");
    }
  }
View Full Code Here

  public static String getExceptionMessage(final AbstractSecuredBasePage securedPage, final ProjectForgeException exception,
      final boolean doLog)
  {
    // Feedbackpanel!
    if (exception instanceof UserException) {
      final UserException ex = (UserException) exception;
      if (doLog == true) {
        log.info(ex.toString() + ExceptionHelper.getFilteredStackTrace(ex, ONLY4NAMESPACE));
      }
      return securedPage.translateParams(ex.getI18nKey(), ex.getMsgParams(), ex.getParams());
    } else if (exception instanceof InternalErrorException) {
      final InternalErrorException ex = (InternalErrorException) exception;
      if (doLog == true) {
        log.info(ex.toString() + ExceptionHelper.getFilteredStackTrace(ex, ONLY4NAMESPACE));
      }
      return securedPage.translateParams(ex.getI18nKey(), ex.getMsgParams(), ex.getParams());
    } else if (exception instanceof AccessException) {
      final AccessException ex = (AccessException) exception;
      if (doLog == true) {
        log.info(ex.toString() + ExceptionHelper.getFilteredStackTrace(ex, ONLY4NAMESPACE));
      }
      if (ex.getParams() != null) {
        return securedPage.getLocalizedMessage(ex.getI18nKey(), ex.getParams());
      } else {
        return securedPage.translateParams(ex.getI18nKey(), ex.getMessageArgs(), ex.getParams());
      }
    }
    throw new UnsupportedOperationException("For developer: Please add unknown ProjectForgeException here!", exception);
  }
View Full Code Here

TOP

Related Classes of org.projectforge.core.UserException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.