Example #1
0
  /**
   * タスク担当者へ通知メールを送る
   *
   * @param taskId タスクID
   * @return 成否
   */
  public static boolean sendMailForTaskMembers(
      RunData rundata,
      Context context,
      EipTProjectTask task,
      EipTProject project,
      List<ProjectTaskMemberResultData> mailUserList) {

    String orgId = Database.getDomainName();
    String subject =
        "["
            + ALOrgUtilsService.getAlias()
            + "]"
            + ALLocalizationUtils.getl10n("PROJECT_MAIL_TITLE");

    try {
      List<ALEipUser> memberList = new ArrayList<ALEipUser>();
      for (ProjectTaskMemberResultData rd : mailUserList) {
        memberList.add(ALEipUtils.getALEipUser(rd.getUserId().getValueWithInt()));
      }

      List<ALEipUserAddr> destMemberList =
          ALMailUtils.getALEipUserAddrs(memberList, ALEipUtils.getUserId(rundata), false);

      List<ALAdminMailMessage> messageList = new ArrayList<ALAdminMailMessage>();
      for (ALEipUserAddr destMember : destMemberList) {
        ALAdminMailMessage message = new ALAdminMailMessage(destMember);
        message.setPcSubject(subject);
        message.setCellularSubject(subject);
        message.setPcBody(createTaskMemberMsg(rundata, message.getPcMailAddr(), task, project));
        message.setCellularBody(
            createTaskMemberMsg(rundata, message.getCellMailAddr(), task, project));
        messageList.add(message);
      }

      ALMailService.sendAdminMailAsync(
          new ALAdminMailContext(
              orgId,
              ALEipUtils.getUserId(rundata),
              messageList,
              ALMailUtils.getSendDestType(ALMailUtils.KEY_MSGTYPE_WORKFLOW)));

    } catch (Exception ex) {
      logger.error("project", ex);
      return false;
    }
    return true;
  }
Example #2
0
  /**
   * 送信するメールの内容を作成する.
   *
   * @return
   */
  public static String createTaskMemberMsg(
      RunData rundata, String addr, EipTProjectTask task, EipTProject project) {
    VelocityContext context = new VelocityContext();
    boolean enableAsp = JetspeedResources.getBoolean("aipo.asp", false);
    String CR = ALMailUtils.CR;

    context.put("user_email", addr);

    // (さんの申請は承認されました。など)
    StringBuffer message = new StringBuffer("");
    message.append(CR);
    message
        .append(getl10nFormat("PROJECT_MAIL_TEXT", project.getProjectName(), task.getTaskName()))
        .append(CR);
    context.put("message", message);

    // サービス
    context.put("serviceAlias", ALOrgUtilsService.getAlias());
    // サービス(Aipo)へのアクセス
    context.put("enableAsp", enableAsp);
    context.put("globalurl", ALMailUtils.getGlobalurl());
    context.put("localurl", ALMailUtils.getLocalurl());
    CustomLocalizationService locService =
        (CustomLocalizationService) ServiceUtil.getServiceByName(LocalizationService.SERVICE_NAME);
    String lang = locService.getLocale(rundata).getLanguage();
    StringWriter writer = new StringWriter();
    try {
      if (lang != null && lang.equals("ja")) {
        Template template =
            Velocity.getTemplate(
                "portlets/mail/" + lang + "/project-notification-mail.vm", "utf-8");
        template.merge(context, writer);
      } else {
        Template template =
            Velocity.getTemplate("portlets/mail/project-notification-mail.vm", "utf-8");
        template.merge(context, writer);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    writer.flush();
    String ret = writer.getBuffer().toString();
    return ret;
  }