/**
   * @param rundata
   * @param context
   * @return
   */
  private SelectQuery<TurbineUser> getSelectQuery(RunData rundata, Context context) {
    SelectQuery<TurbineUser> query = null;
    String word = searchWord.getValue();
    String transWord =
        ALStringUtil.convertHiragana2Katakana(ALStringUtil.convertH2ZKana(searchWord.getValue()));

    query = Database.query(TurbineUser.class);

    Expression exp_exclude_my_group =
        ExpressionFactory.matchExp(
            TurbineUser.TURBINE_USER_GROUP_ROLE_PROPERTY
                + "."
                + TurbineUserGroupRole.TURBINE_GROUP_PROPERTY
                + "."
                + TurbineGroup.OWNER_ID_PROPERTY,
            1);

    Expression exp01 = ExpressionFactory.matchExp(TurbineUser.DISABLED_PROPERTY, "F");
    query.setQualifier(exp01);

    Expression exp02 =
        ExpressionFactory.noMatchDbExp(TurbineUser.USER_ID_PK_COLUMN, Integer.valueOf(1));
    Expression exp03 =
        ExpressionFactory.noMatchDbExp(TurbineUser.USER_ID_PK_COLUMN, Integer.valueOf(2));
    Expression exp04 =
        ExpressionFactory.noMatchDbExp(TurbineUser.USER_ID_PK_COLUMN, Integer.valueOf(3));
    query.andQualifier(exp02.andExp(exp03).andExp(exp04));

    Expression exp11 = ExpressionFactory.likeExp(TurbineUser.FIRST_NAME_PROPERTY, "%" + word + "%");
    Expression exp12 = ExpressionFactory.likeExp(TurbineUser.LAST_NAME_PROPERTY, "%" + word + "%");
    Expression exp13 =
        ExpressionFactory.likeExp(TurbineUser.FIRST_NAME_KANA_PROPERTY, "%" + word + "%");
    Expression exp14 =
        ExpressionFactory.likeExp(TurbineUser.LAST_NAME_KANA_PROPERTY, "%" + word + "%");
    Expression exp15 = ExpressionFactory.likeExp(TurbineUser.EMAIL_PROPERTY, "%" + word + "%");
    Expression exp16 =
        ExpressionFactory.likeExp(
            TurbineUser.TURBINE_USER_GROUP_ROLE_PROPERTY
                + "."
                + TurbineUserGroupRole.TURBINE_GROUP_PROPERTY
                + "."
                + TurbineGroup.GROUP_ALIAS_NAME_PROPERTY,
            "%" + word + "%");
    exp16 = exp16.andExp(exp_exclude_my_group);
    Expression exp21 =
        ExpressionFactory.likeExp(TurbineUser.OUT_TELEPHONE_PROPERTY, "%" + word + "%");
    Expression exp22 =
        ExpressionFactory.likeExp(TurbineUser.IN_TELEPHONE_PROPERTY, "%" + word + "%");
    Expression exp23 =
        ExpressionFactory.likeExp(TurbineUser.CELLULAR_PHONE_PROPERTY, "%" + word + "%");

    Expression exp31 =
        ExpressionFactory.likeExp(TurbineUser.FIRST_NAME_PROPERTY, "%" + transWord + "%");
    Expression exp32 =
        ExpressionFactory.likeExp(TurbineUser.LAST_NAME_PROPERTY, "%" + transWord + "%");
    Expression exp33 =
        ExpressionFactory.likeExp(TurbineUser.FIRST_NAME_KANA_PROPERTY, "%" + transWord + "%");
    Expression exp34 =
        ExpressionFactory.likeExp(TurbineUser.LAST_NAME_KANA_PROPERTY, "%" + transWord + "%");
    Expression exp35 =
        ExpressionFactory.likeExp(
            TurbineUser.TURBINE_USER_GROUP_ROLE_PROPERTY
                + "."
                + TurbineUserGroupRole.TURBINE_GROUP_PROPERTY
                + "."
                + TurbineGroup.GROUP_ALIAS_NAME_PROPERTY,
            "%" + transWord + "%");
    exp35 = exp35.andExp(exp_exclude_my_group);
    Expression exp36 = ExpressionFactory.likeExp(TurbineUser.CODE_PROPERTY, "%" + transWord + "%");
    if (word != null && !"".equals(word)) {
      query.andQualifier(
          exp11
              .orExp(exp12)
              .orExp(exp13)
              .orExp(exp14)
              .orExp(exp15)
              .orExp(exp16)
              .orExp(exp21)
              .orExp(exp22)
              .orExp(exp23)
              .orExp(exp31)
              .orExp(exp32)
              .orExp(exp33)
              .orExp(exp34)
              .orExp(exp35)
              .orExp(exp36));
    }
    query.distinct();
    return query;
  }
예제 #2
0
 /** 入力フィールド値の文字列表現を取得します。 */
 @Override
 public String toString() {
   return ALStringUtil.sanitizing(value);
 }
예제 #3
0
  /**
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean insertFormData(RunData rundata, Context context, List<String> msgList) {

    String[] attachmentFilepaths = null;
    try {
      FileuploadLiteBean filebean = null;
      boolean hasAttachments = (fileuploadList != null && fileuploadList.size() > 0);
      if (hasAttachments) {
        int size = fileuploadList.size();
        attachmentFilepaths = new String[size];
        for (int i = 0; i < size; i++) {
          filebean = fileuploadList.get(i);
          attachmentFilepaths[i] =
              ALStorageService.getDocumentPath(
                      FileuploadUtils.FOLDER_TMP_FOR_ATTACHMENT_FILES,
                      userId + ALStorageService.separator() + folderName)
                  + ALStorageService.separator()
                  + filebean.getFileId();
        }
      }

      // 件名の値を検証
      if (subject.getValue() == null || subject.getValue().equals("")) {
        subject.setValue("無題");
      }

      // 返信メールの場合は,ヘッダを追加する.
      Map<String, String> map = null;
      if (getMailType().getValue() == TYPE_REPLY_MAIL
          || getMailType().getValue() == TYPE_REPLY_ALL_MAIL) {
        ALLocalMailMessage msg = null;
        try {
          msg =
              (ALLocalMailMessage)
                  WebMailUtils.getSelectedLocalMailMessage(
                      rundata, context, (int) getMailType().getValue());
          if (msg == null) {
            return false;
          }
        } catch (Exception e) {
          return false;
        }
        String in_reply_tos = msg.getMessageID();
        StringBuffer reference = new StringBuffer();
        String[] references = msg.getHeader("References");
        map = new LinkedHashMap<String, String>();
        if (references != null && references.length > 0) {
          reference.append(ALMailUtils.getOneString(references, " "));
        }
        if (in_reply_tos != null && (!in_reply_tos.equals(""))) {
          map.put("In-Reply-To", in_reply_tos);
          reference.append(" ").append(in_reply_tos);
        }

        map.put("References", reference.toString());
      }

      if (map != null && map.size() == 0) {
        map = null;
      }

      String delim = ",;";

      // オブジェクトモデルを取得
      EipMMailAccount account = ALMailUtils.getMailAccount(userId, accountId);

      ALMailHandler handler = ALMailFactoryService.getInstance().getMailHandler();
      // 送信サーバ情報
      ALMailSenderContext scontext = ALMailUtils.getALSmtpMailSenderContext(orgId, account);

      // 送信メッセージのコンテキスト
      ALSmtpMailContext mailcontext =
          ALMailUtils.getALSmtpMailContext(
              ALMailUtils.getTokens(ALStringUtil.unsanitizing(to.getValue()), delim),
              ALMailUtils.getTokens(ALStringUtil.unsanitizing(cc.getValue()), delim),
              ALMailUtils.getTokens(ALStringUtil.unsanitizing(bcc.getValue()), delim),
              account.getMailAddress(),
              ALStringUtil.unsanitizing(account.getMailUserName()),
              ALStringUtil.unsanitizing(subject.getValue()),
              ALStringUtil.unsanitizing(body.getValue()),
              attachmentFilepaths,
              map);

      int success_send = handler.send(scontext, mailcontext);

      if (success_send == ALSmtpMailSender.SEND_MSG_SUCCESS) {
        if (hasAttachments) {
          // 添付ファイル保存先のフォルダを削除
          ALStorageService.deleteTmpFolder(userId, folderName);
        }
      } else {
        if (success_send == ALSmtpMailSender.SEND_MSG_FAIL) {
          msgList.add("メールを送信できませんでした。アカウント設定が間違っている可能性があります。");
        } else if (success_send == ALSmtpMailSender.SEND_MSG_OVER_MAIL_MAX_SIZE) {
          msgList.add(
              String.valueOf(FileuploadUtils.getMaxFileSize()).concat("MB を超えるサイズのメールは送信できません。"));
        } else if (success_send == ALSmtpMailSender.SEND_MSG_FAIL_SMTP_AUTH) {
          msgList.add("メールを送信できませんでした。SMTP認証の認証に失敗しました。");
        }

        return false;
      }
    } catch (Exception e) {
      logger.error("webmail", e);
      msgList.add("メールを送信できませんでした。アカウント設定が間違っている可能性があります。");
      return false;
    }
    return true;
  }
예제 #4
0
  /**
   * 検索条件を設定した SelectQuery を返します。 <br>
   *
   * @param rundata
   * @param context
   * @return
   */
  protected SelectQuery<TurbineUser> getSelectQuery(RunData rundata, Context context) {

    ObjectId oid = new ObjectId("TurbineUser", TurbineUser.USER_ID_PK_COLUMN, 3);

    Expression exp_base =
        ExpressionFactory.matchAllDbExp(oid.getIdSnapshot(), Expression.GREATER_THAN);

    SelectQuery<TurbineUser> query =
        Database.query(TurbineUser.class, exp_base)
            .where(
                Operations.eq(TurbineUser.COMPANY_ID_PROPERTY, Integer.valueOf(1)),
                Operations.ne(TurbineUser.DISABLED_PROPERTY, "T"));

    String filter = ALEipUtils.getTemp(rundata, context, LIST_FILTER_STR);
    String filter_role = ALEipUtils.getTemp(rundata, context, LIST_FILTER_ROLE_STR);
    currentPost = filter;
    currentRole = filter_role;

    if (target_keyword != null && !target_keyword.getValue().equals("")) {
      String transWord =
          ALStringUtil.convertHiragana2Katakana(
              ALStringUtil.convertH2ZKana(target_keyword.getValue()));
      transWord = transWord.replace(" ", "").replace(" ", ""); // 全角/半角スペースを削除
      String[] transWords = transWord.split(""); // 1文字ずつに分解

      for (int i = 0; i < transWords.length; i++) {
        Expression exp11 =
            ExpressionFactory.likeExp(
                TurbineUser.FIRST_NAME_PROPERTY, "%" + target_keyword.getValue() + "%");
        Expression exp12 =
            ExpressionFactory.likeExp(
                TurbineUser.LAST_NAME_PROPERTY, "%" + target_keyword.getValue() + "%");
        Expression exp13 =
            ExpressionFactory.likeExp(
                TurbineUser.FIRST_NAME_KANA_PROPERTY, "%" + target_keyword.getValue() + "%");
        Expression exp14 =
            ExpressionFactory.likeExp(
                TurbineUser.LAST_NAME_KANA_PROPERTY, "%" + target_keyword.getValue() + "%");
        Expression exp15 =
            ExpressionFactory.likeExp(
                TurbineUser.EMAIL_PROPERTY, "%" + target_keyword.getValue() + "%");
        Expression exp16 =
            ExpressionFactory.likeExp(
                TurbineUser.TURBINE_USER_GROUP_ROLE_PROPERTY
                    + "."
                    + TurbineUserGroupRole.TURBINE_GROUP_PROPERTY
                    + "."
                    + TurbineGroup.GROUP_ALIAS_NAME_PROPERTY,
                "%" + target_keyword.getValue() + "%");
        Expression exp17 =
            ExpressionFactory.likeExp(
                TurbineUser.LOGIN_NAME_PROPERTY, "%" + target_keyword.getValue() + "%");
        Expression exp21 =
            ExpressionFactory.likeExp(
                TurbineUser.OUT_TELEPHONE_PROPERTY, "%" + target_keyword.getValue() + "%");
        Expression exp22 =
            ExpressionFactory.likeExp(
                TurbineUser.IN_TELEPHONE_PROPERTY, "%" + target_keyword.getValue() + "%");
        Expression exp23 =
            ExpressionFactory.likeExp(
                TurbineUser.CELLULAR_PHONE_PROPERTY, "%" + target_keyword.getValue() + "%");
        Expression exp31 =
            ExpressionFactory.likeExp(TurbineUser.FIRST_NAME_PROPERTY, "%" + transWords[i] + "%");
        Expression exp32 =
            ExpressionFactory.likeExp(TurbineUser.LAST_NAME_PROPERTY, "%" + transWords[i] + "%");
        Expression exp33 =
            ExpressionFactory.likeExp(
                TurbineUser.FIRST_NAME_KANA_PROPERTY, "%" + transWords[i] + "%");
        Expression exp34 =
            ExpressionFactory.likeExp(
                TurbineUser.LAST_NAME_KANA_PROPERTY, "%" + transWords[i] + "%");
        Expression exp35 =
            ExpressionFactory.likeExp(
                TurbineUser.TURBINE_USER_GROUP_ROLE_PROPERTY
                    + "."
                    + TurbineUserGroupRole.TURBINE_GROUP_PROPERTY
                    + "."
                    + TurbineGroup.GROUP_ALIAS_NAME_PROPERTY,
                "%" + transWords[i] + "%");

        query.andQualifier(
            exp11
                .orExp(exp12)
                .orExp(exp13)
                .orExp(exp14)
                .orExp(exp15)
                .orExp(exp16)
                .orExp(exp17)
                .orExp(exp21)
                .orExp(exp22)
                .orExp(exp23)
                .orExp(exp31)
                .orExp(exp32)
                .orExp(exp33)
                .orExp(exp34)
                .orExp(exp35));
      }
    }

    // ユーザーの状態によるフィルターが指定されている場合。
    if (filter_role != null && !filter_role.equals("")) {

      // 管理者かどうか
      if (filter_role.equals(AccountUtils.ROLE_ADMIN.toString())) {
        try {
          Group group = JetspeedSecurity.getGroup("LoginUser");
          Role adminrole = JetspeedSecurity.getRole("admin");
          List<TurbineUserGroupRole> admins =
              Database.query(TurbineUserGroupRole.class)
                  .where(
                      Operations.eq(TurbineUserGroupRole.TURBINE_ROLE_PROPERTY, adminrole.getId()),
                      Operations.eq(TurbineUserGroupRole.TURBINE_GROUP_PROPERTY, group.getId()),
                      Operations.ne(TurbineUserGroupRole.TURBINE_USER_PROPERTY, 1))
                  .distinct(true)
                  .fetchList();
          List<Integer> admin_ids = new ArrayList<Integer>();
          admin_ids.add(Integer.valueOf(1));
          for (TurbineUserGroupRole tugr : admins) {
            admin_ids.add(tugr.getTurbineUser().getUserId());
          }
          query.andQualifier(ExpressionFactory.inDbExp(TurbineUser.USER_ID_PK_COLUMN, admin_ids));

        } catch (Exception ex) {
          logger.error("AccountUserSelectData.getSelectQuery", ex);
        }
      }

      // 有効ユーザーかどうか
      if (filter_role.equals(AccountUtils.ROLE_ACTIVE.toString())) {
        query.andQualifier(ExpressionFactory.matchExp(TurbineUser.DISABLED_PROPERTY, "F"));
      }

      // 有効ユーザーかどうか
      if (filter_role.equals(AccountUtils.ROLE_IN_ACTIVE.toString())) {
        query.andQualifier(ExpressionFactory.matchExp(TurbineUser.DISABLED_PROPERTY, "N"));
      }
    }

    // 部署によるフィルターが指定されている場合。
    if (filter != null && !filter.equals("")) {

      String groupName =
          (ALEipManager.getInstance().getPostMap().get(Integer.valueOf(filter)))
              .getGroupName()
              .getValue();

      query.where(
          Operations.eq(
              TurbineUser.TURBINE_USER_GROUP_ROLE_PROPERTY
                  + "."
                  + TurbineUserGroupRole.TURBINE_GROUP_PROPERTY
                  + "."
                  + TurbineGroup.GROUP_NAME_PROPERTY,
              groupName));
    }

    query.distinct();

    return query;
  }