From a0c742dc589e56e8b1a7498de1d165e039f58aac Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Mon, 30 Jul 2007 23:30:38 +0000
Subject: [PATCH] Update the task backend to provide a mechanism for sending e-mail messages to notify administrators whenever a given task has been completed. It is possible to specify a set of administrators that should be notified only if the task does not complete successfully, and/or a set of administrators that should be notified regardless of the task's success or failure. The basic framework for this capability has always been in place, and this change only provides the final implementation that actually generates and sends the e-mail message.
---
opendj-sdk/opends/src/server/org/opends/server/backends/task/TaskBackend.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/task/TaskBackend.java b/opendj-sdk/opends/src/server/org/opends/server/backends/task/TaskBackend.java
index a9e9986..305685b 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/task/TaskBackend.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/task/TaskBackend.java
@@ -29,6 +29,7 @@
import java.io.File;
+import java.net.InetAddress;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -116,6 +117,9 @@
// removed from the set of scheduled tasks.
private long retentionTime;
+ // The e-mail address to use for the sender from notification messages.
+ private String notificationSenderAddress;
+
// The path to the task backing file.
private String taskBackingFile;
@@ -226,6 +230,22 @@
retentionTime = cfg.getTaskRetentionTime();
+ // Get the notification sender address.
+ notificationSenderAddress = cfg.getNotificationSenderAddress();
+ if (notificationSenderAddress == null)
+ {
+ try
+ {
+ notificationSenderAddress = "opends-task-notification@" +
+ InetAddress.getLocalHost().getCanonicalHostName();
+ }
+ catch (Exception e)
+ {
+ notificationSenderAddress = "opends-task-notification@opends.org";
+ }
+ }
+
+
// Get the path to the task data backing file.
taskBackingFile = cfg.getTaskBackingFile();
@@ -1285,6 +1305,22 @@
}
+ String tmpNotificationAddress = configEntry.getNotificationSenderAddress();
+ if (tmpNotificationAddress == null)
+ {
+ try
+ {
+ tmpNotificationAddress = "opends-task-notification@" +
+ InetAddress.getLocalHost().getCanonicalHostName();
+ }
+ catch (Exception e)
+ {
+ tmpNotificationAddress = "opends-task-notification@opends.org";
+ }
+ }
+ notificationSenderAddress = tmpNotificationAddress;
+
+
currentConfig = configEntry;
return new ConfigChangeResult(resultCode, adminActionRequired, messages);
}
@@ -1319,6 +1355,20 @@
/**
+ * Retrieves the sender address that should be used for e-mail notifications
+ * of task completion.
+ *
+ * @return The sender address that should be used for e-mail notifications of
+ * task completion.
+ */
+ public String getNotificationSenderAddress()
+ {
+ return notificationSenderAddress;
+ }
+
+
+
+ /**
* Retrieves the length of time in seconds that information for a task should
* be retained after processing on it has completed.
*
--
Gitblit v1.10.0