示例#1
0
  public void notifyAccountLock(Account account, String context) {
    PartnerCode partnerCode = account.getPartnerCode();
    String lockedOutMessageBody =
        SysConfigManager.instance()
            .getValue("lockedOutMessageBody", LOCKED_OUT_MESSAGE_BODY, partnerCode);
    String lockedOutMessageSubject =
        SysConfigManager.instance()
            .getValue("lockedOutMessageSubject", LOCKED_OUT_MESSAGE_SUBJECT, partnerCode);
    String lockedOutMessageFrom =
        SysConfigManager.instance()
            .getValue("lockedOutMessageFrom", LOCKED_OUT_MESSAGE_FROM, partnerCode);
    String lockedOutMessageAlias =
        SysConfigManager.instance()
            .getValue("lockedOutMessageAlias", LOCKED_OUT_MESSAGE_ALIAS, partnerCode);

    try {
      Email email = new Email();
      email.setSubject(lockedOutMessageSubject);

      email.setStatus("0");
      email.setUserId(account.getUser_id());
      email.setMessage_type("EMAIL");

      email.setFrom(lockedOutMessageFrom);
      email.setFrom_alias(lockedOutMessageAlias);
      email.setTo(account.getLoginName());
      email.setBodySize(lockedOutMessageBody.length());

      DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      email.setMaildate(dateFormat.format(new Date(System.currentTimeMillis()))); // ugh!

      email.setOriginal_account(account.getLoginName());

      // create the pojgo
      EmailPojo emailPojo = new EmailPojo();
      emailPojo.setEmail(email);

      Body body = new Body();
      body.setData(lockedOutMessageBody.getBytes());

      // note, the email will be encoded to prevent sql-injection. since this email is destined
      // directly for the
      // device, we need to reverse the encoding after the call to newSaveEmail
      new EmailRecievedService().newSaveEmail(account, email, body);

      // Added by Dan so we stop checking accounts that have incorrect passwords
      account.setStatus("0");

    } catch (Throwable t) {
      log.warn(String.format("failed to save locked out message for %s", context), t);
    }
  }