use of edu.uiuc.ncsa.security.core.exceptions.ServerRedirectException in project OA4MP by ncsa.
the class Monitor method sendNotification.
public void sendNotification(Throwable t) {
if (!mailNotificationsOn())
return;
try {
HashMap<String, String> replacements = new HashMap<String, String>();
replacements.put("name", getClientEnvironment().getInitializeUri().toString());
replacements.put("message", t.getMessage());
replacements.put("host", InetAddress.getLocalHost().getCanonicalHostName());
String st = null;
if (t instanceof ServerRedirectException) {
st = ((ServerRedirectException) t).getWebpage();
} else {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(baos);
t.printStackTrace(pw);
pw.flush();
st = new String(baos.toByteArray());
pw.close();
}
replacements.put("stacktrace", st);
MailUtil mailUtil = mup.get();
// log it all to the right place.
mailUtil.setMyLogger(getMyLogger());
mailUtil.sendMessage(replacements);
} catch (Throwable throwable) {
info("Could not send notification: " + t.getMessage());
if (isVerbose()) {
throwable.printStackTrace();
}
}
}
Aggregations