ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/client/alerters/EMail__Alerter.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/alerters/EMail__Alerter.java (file contents):
Revision 1.14 by tdb, Mon Mar 5 23:13:22 2001 UTC vs.
Revision 1.17 by tdb, Fri Mar 16 03:12:42 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 < package uk.ac.ukc.iscream.client.alerters;
2 > package uk.org.iscream.client.alerters;
3  
4   //---IMPORTS---
5 < import uk.ac.ukc.iscream.client.*;
6 < import uk.ac.ukc.iscream.core.*;
7 < import uk.ac.ukc.iscream.util.*;
8 < import uk.ac.ukc.iscream.componentmanager.*;
5 > import uk.org.iscream.client.*;
6 > import uk.org.iscream.core.*;
7 > import uk.org.iscream.util.*;
8 > import uk.org.iscream.componentmanager.*;
9  
10   import java.util.*;
11   import java.io.*;
12 + import java.text.*;
13  
14   /**
15   * This alerter delivers alerts using e-mail.
# Line 55 | Line 56 | public class EMail__Alerter implements PluginAlerter {
56          if(((alert.getLevel() == 0) && (alert.getLastLevel() >= level)) || (alert.getLevel() >= level)) {
57              String alertType = Alert.alertLevels[alert.getLevel()];
58              String thresholdType = Alert.thresholdLevels[alert.getThreshold()];
59 +            String timeFirstSince = DateUtils.formatTime((System.currentTimeMillis() - alert.getInitialAlertTime())/1000, "%DAYS% days, %HOURS% hours, %MINS% mins, and %SECS% secs");
60 +            String timeFirstOccured = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.UK).format(new Date(alert.getInitialAlertTime()));
61 +
62              // sort out the subject
63              String subject;
64              try {
# Line 70 | Line 74 | public class EMail__Alerter implements PluginAlerter {
74              subject = StringUtils.replaceText(subject, "%thresholdValue%", alert.getThresholdValue());
75              subject = StringUtils.replaceText(subject, "%attributeName%", alert.getAttributeName());
76              subject = StringUtils.replaceText(subject, "%timeTillNextAlert%",  getTimeString(Long.parseLong(alert.getTimeTillNextAlert())));
77 +            subject = StringUtils.replaceText(subject, "%timeSinceFirstAlert%", timeFirstSince);
78 +            subject = StringUtils.replaceText(subject, "%timeOfFirstAlert%", timeFirstOccured);
79                          
80              // sort out the message body
81              String message;
# Line 86 | Line 92 | public class EMail__Alerter implements PluginAlerter {
92              message = StringUtils.replaceText(message, "%thresholdValue%", alert.getThresholdValue());
93              message = StringUtils.replaceText(message, "%attributeName%", alert.getAttributeName());
94              message = StringUtils.replaceText(message, "%timeTillNextAlert%",  getTimeString(Long.parseLong(alert.getTimeTillNextAlert())));
95 +            message = StringUtils.replaceText(message, "%timeSinceFirstAlert%", timeFirstSince);
96 +            message = StringUtils.replaceText(message, "%timeOfFirstAlert%", timeFirstOccured);
97                          
98              try {
99                  // create SMTP message
# Line 93 | Line 101 | public class EMail__Alerter implements PluginAlerter {
101                  // set our sender
102                  smtp.setSender(cp.getProperty(_name, "Alerter.EMail.sender"));
103                  
104 <                // get the default destination list
97 <                String destList = cp.getProperty(_name, "Alerter.EMail.defaultDestList");
98 <                // check if the source we're alerting about has a specific destination
99 <                String sourceDestList = cp.getProperty("Host."+alert.getSource(), "Alerter.EMail.destList");
100 <                if(sourceDestList != null) {
101 <                    // if there is a source destination list, use it
102 <                    destList = sourceDestList;
103 <                }
104 >                String destList = cp.getProperty("Host."+alert.getSource(), "Alerter.EMail.destList");
105                  
106                  // set the to: list
107                  StringTokenizer st = new StringTokenizer(destList, ";");
# Line 132 | Line 133 | public class EMail__Alerter implements PluginAlerter {
133       * Overrides the {@link java.lang.Object#toString() Object.toString()}
134       * method to provide clean logging (every class should have this).
135       *
136 <     * This uses the uk.ac.ukc.iscream.util.NameFormat class
136 >     * This uses the uk.org.iscream.util.NameFormat class
137       * to format the toString()
138       *
139       * @return the name of this class and its CVS revision

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines