Пример #1
0
  /**
   * update public mail server
   *
   * @param ms PublicMailServer
   * @return int
   * @throws EntityException
   */
  public int updatePubMailServer(MailServer ms) throws EntityException {

    int result = 0;

    try {

      if (ms.getMailServerId() == null || ms.getMailServerId().equals("")) {

        throw new EntityException("Error: Mail Server ID is null in an update operation");

      } else {

        // check serverType
        if (ms.getMailServerType() == null
            || ms.getMailServerType().equals("")
            || ms.getMailServerType().equals("null")) {
          ms.setMailServerType(Def.SERVER_TYPE_OTHER);
        }

        // check description
        if (ms.getDescription() == null
            || ms.getDescription().equals("")
            || ms.getDescription().equals("null")) {
          ms.setDescription(Def.SERVER_TYPE_OTHER);
        }

        // check folder names
        if (ms.getOutboxPath() == null
            || ms.getOutboxPath().equals("")
            || ms.getOutboxPath().equals("null")) {
          ms.setOutboxPath(Def.FOLDER_OUTBOX_ENG);
          ms.setOutboxActivation(true);
        }
        if (ms.getSentPath() == null
            || ms.getSentPath().equals("")
            || ms.getSentPath().equals("null")) {
          if (ms.getMailServerType().equals(Def.SERVER_TYPE_EXCHANGE)) {
            ms.setSentPath(Def.FOLDER_SENT_ENG_EXC);
          } else {
            ms.setSentPath(Def.FOLDER_SENT_ENG);
          }
        }

        if (ms.getDraftsPath() == null
            || ms.getDraftsPath().equals("")
            || ms.getDraftsPath().equals("null")) {
          ms.setDraftsPath(Def.FOLDER_DRAFTS_ENG);
        }

        if (ms.getTrashPath() == null
            || ms.getTrashPath().equals("")
            || ms.getTrashPath().equals("null")) {
          if (ms.getMailServerType().equals(Def.SERVER_TYPE_EXCHANGE)) {
            ms.setTrashPath(Def.FOLDER_TRASH_ENG_EXC);
          } else {
            ms.setTrashPath(Def.FOLDER_TRASH_ENG);
          }
        }
      }

      result = cdao.updatePubMailServer(ms);

    } catch (DBAccessException ee) {
      throw new EntityException("Error updating Mail Server ", ee);
    }
    return result;
  }