Example #1
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;
  }
Example #2
0
 public static String getEscapedStringForMysql(String text) {
   if (StringUtils.isEmpty(text)) {
     return text;
   }
   StringBuffer buf = new StringBuffer();
   for (int i = 0; i < text.length(); i++) {
     char c = text.charAt(i);
     switch (c) {
       case 0: /* Must be escaped for 'mysql' */
         buf.append('\\');
         buf.append('0');
         break;
       case '\n': /* Must be escaped for logs */
         buf.append('\\');
         buf.append('n');
         break;
       case '\r':
         buf.append('\\');
         buf.append('r');
         break;
       case '\\':
         buf.append('\\');
         buf.append('\\');
         break;
       case '\'':
         buf.append('\\');
         buf.append('\'');
         break;
       case '"': /* Better safe than sorry */
         buf.append('\\');
         buf.append('"');
         break;
       case '\032': /* This gives problems on Win32 */
         buf.append('\\');
         buf.append('Z');
         break;
       default:
         buf.append(c);
     }
   }
   return buf.toString();
 }