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

    int result = 0;

    try {

      ms.setMailServerId("" + this.idMailServerSpace.next());

      // 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.insertPubMailServer(ms);

    } catch (DBIDGeneratorException ee) {
      throw new EntityException("Error handling ID ", ee);
    } catch (DBAccessException ee) {
      throw new EntityException("Error inserting Mail Server ", ee);
    }
    return result;
  }