Ejemplo n.º 1
0
  private void mail(JobExecutionContext jec, Set emails, String subject, String mail) {
    try {
      log.info("Sending mail to service admins: " + Arrays.toString(emails.toArray()));

      for (String email : (Set<String>) emails) {
        if (isInterrupted()) {
          log.info("Interrupted, ending monitoring job");
          return;
        }

        try {
          Mailer.sendMail(
              (String) jec.getJobDetail().getJobDataMap().get("from.name"),
              (String) jec.getJobDetail().getJobDataMap().get("from.email"),
              email,
              subject,
              mail);
        } catch (Exception e) {
          log.error("Error sending mail to service admin " + email, e);
        }
      }
    } catch (Exception e) {
      log.error("Error sending mail to service admins", e);
    }
  }
Ejemplo n.º 2
0
  public Object getValueAt(int row, int column) {
    try {
      Message message = getMessage(row);
      switch (column) {
        case 0:
          // Answered?
          return (message.isSet(Flags.Flag.ANSWERED) ? "R" : "");

        case 1:
          // From.
          Address[] addresses = message.getFrom();
          if (addresses == null || addresses.length == 0) {
            return "(No sender)";
          }
          // Given "Personal Name <*****@*****.**>", choose "Personal Name" if it's available, and
          // "*****@*****.**" if not.
          InternetAddress address = (InternetAddress) addresses[0];
          String name = address.getPersonal();
          return (name != null) ? name : address.getAddress();

        case 2:
          // Subject.
          String subject = message.getSubject();
          return (subject != null) ? subject : "(No subject)";

        case 3:
          // Date.
          Date date = message.getReceivedDate();
          return (date != null) ? Mailer.dateToIsoString(date) : "Unknown";

        default:
          return "<no-column-" + column + ">";
      }
    } catch (MessagingException ex) {
      ex.printStackTrace();
      return "<error>";
    }
  }