Exemple #1
0
 private void sendMaybeEmail(String to) {
   String subject = "Processing is taking a long time";
   StringBuilder content = new StringBuilder();
   content.append("Your process is taking longer than expected.");
   content.append("  It might finish in a bit, but here is the status so far");
   content.append("\n\tUpload: ").append((uploadSuccessful) ? "success" : "waiting");
   content.append("\n\tParse: ").append((netcdfSuccessful) ? "success" : "waiting");
   content.append("\n\tStatistics: ").append((rStatsSuccessful) ? "success" : "waiting");
   content.append("\n\tMetadata: ").append((cswTransSuccessful) ? "success" : "waiting");
   content.append(
       "\n\nYou will receive another email if there is a success, but may not receive a failure notification.");
   List<String> bcc = new ArrayList<String>();
   String from = props.getProperty("watersmart.email.from");
   String bccAddr = props.getProperty("watersmart.email.tracker");
   if (!"".equals(bccAddr)) {
     bcc.add(bccAddr);
   }
   EmailMessage message = new EmailMessage(from, to, null, bcc, subject, content.toString());
   try {
     EmailHandler.sendMessage(message);
   } catch (AddressException ex) {
     log.error("Unable to send maybe e-mail:\n" + message, ex);
   } catch (MessagingException ex) {
     log.error("Unable to send maybe e-mail:\n" + message, ex);
   }
 }
Exemple #2
0
  private void sendFailedEmail(Exception ex, String to) {
    String subject = "WaterSMART processing failed";
    StringBuilder content = new StringBuilder();
    content.append("Your request unfortunately failed, we are looking into it.");
    content.append("\n\tUpload: ").append((uploadSuccessful) ? "success" : "failure");
    content.append("\n\tParse: ").append((netcdfSuccessful) ? "success" : "failure");
    content.append("\n\tStatistics: ").append((rStatsSuccessful) ? "success" : "failure");
    content.append("\n\tMetadata: ").append((cswTransSuccessful) ? "success" : "failure");

    RunMetadata metaObj = RunMetadata.getInstance(metadata);
    content.append("\n\n\tFile: ").append(metaObj.getFileName());
    content.append("\n\tModeler: ").append(metaObj.getName());
    content.append("\n\tComments: ").append(metaObj.getComments());
    content.append("\n\tDate: ").append(metaObj.getCreationDate());

    content.append("\n\nthe application failed with message: ").append(ex.getMessage());

    content.append("\n\nhere is the stack trace for troubleshooting:\n\n");
    for (StackTraceElement el : ex.getStackTrace()) {
      content.append(el.toString()).append("\n");
    }
    List<String> bcc = new ArrayList<String>();
    String from = props.getProperty("watersmart.email.from");
    String bccAddr = props.getProperty("watersmart.email.tracker");
    if (!"".equals(bccAddr)) {
      bcc.add(bccAddr);
    }
    EmailMessage message = new EmailMessage(from, to, null, bcc, subject, content.toString());
    try {
      EmailHandler.sendMessage(message);
    } catch (AddressException ex1) {
      log.error(
          "Unable to send failed e-mail:\n"
              + message
              + "\n\nOriginal Exception:\n"
              + ex.getMessage(),
          ex1);
    } catch (MessagingException ex1) {
      log.error(
          "Unable to send failed e-mail:\n"
              + message
              + "\n\nOriginal Exception:\n"
              + ex.getMessage(),
          ex1);
    }
  }
Exemple #3
0
  private void sendCompleteEmail(Map<String, String> outputs, String to) {
    String subject = "Processing Complete";
    StringBuilder content = new StringBuilder();
    content
        .append("Your upload has finished conversion and processing,")
        .append(" you may view the results of the processing by going to:\n");

    for (String alg : outputs.keySet()) {
      content.append("\t").append(alg).append(": ").append(outputs.get(alg)).append("\n");
    }

    content.append("\nor return to the application to view your upload.");

    content.append("\nJust to double check, here is what happened");
    content.append("\n\tUpload: ").append((uploadSuccessful) ? "success" : "failure");
    content.append("\n\tParse: ").append((netcdfSuccessful) ? "success" : "failure");
    content.append("\n\tStatistics: ").append((rStatsSuccessful) ? "success" : "failure");
    content.append("\n\tMetadata: ").append((cswTransSuccessful) ? "success" : "failure");

    RunMetadata metaObj = RunMetadata.getInstance(metadata);
    content.append("\n\n\tFile: ").append(metaObj.getFileName());
    content.append("\n\tModeler: ").append(metaObj.getName());
    content.append("\n\tComments: ").append(metaObj.getComments());
    content.append("\n\tDate: ").append(metaObj.getCreationDate());

    content.append("\n\nHave a nice day!");
    List<String> bcc = new ArrayList<String>();
    String from = props.getProperty("watersmart.email.from");
    String bccAddr = props.getProperty("watersmart.email.tracker");
    if (!"".equals(bccAddr)) {
      bcc.add(bccAddr);
    }

    EmailMessage message = new EmailMessage(from, to, null, bcc, subject, content.toString());
    try {
      EmailHandler.sendMessage(message);
    } catch (AddressException ex) {
      log.error("Unable to send completed e-mail:\n" + message, ex);
    } catch (MessagingException ex) {
      log.error("Unable to send completed e-mail:\n" + message, ex);
    }
  }