From 0d1131524cfbba81cafaab90ffcda86af50c1682 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Tue, 02 Oct 2007 16:38:40 +0000
Subject: [PATCH] Partially addressed issues 2335 and 2336 which call for support of task notifications and dependencies in client task scheduling tools.

---
 opends/src/server/org/opends/server/tools/tasks/TaskClient.java |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/tasks/TaskClient.java b/opends/src/server/org/opends/server/tools/tasks/TaskClient.java
index e3ca663..455df9d 100644
--- a/opends/src/server/org/opends/server/tools/tasks/TaskClient.java
+++ b/opends/src/server/org/opends/server/tools/tasks/TaskClient.java
@@ -59,6 +59,7 @@
 import org.opends.server.types.SearchScope;
 import static org.opends.server.types.ResultCode.*;
 import org.opends.server.backends.task.TaskState;
+import org.opends.server.backends.task.FailedDependencyAction;
 import static org.opends.server.util.ServerConstants.*;
 import org.opends.server.util.StaticUtils;
 
@@ -149,6 +150,55 @@
               startDateValues));
     }
 
+    // add dependency IDs
+    List<String> dependencyIds = information.getDependencyIds();
+    if (dependencyIds != null && dependencyIds.size() > 0) {
+      ArrayList<ASN1OctetString> dependencyIdValues =
+              new ArrayList<ASN1OctetString>(dependencyIds.size());
+      for (String dependencyId : dependencyIds) {
+        dependencyIdValues.add(new ASN1OctetString(dependencyId));
+      }
+      attributes.add(new LDAPAttribute(ATTR_TASK_DEPENDENCY_IDS,
+              dependencyIdValues));
+
+      // add the dependency action
+      FailedDependencyAction fda = information.getFailedDependencyAction();
+      if (fda == null) {
+        fda = FailedDependencyAction.defaultValue();
+      }
+      ArrayList<ASN1OctetString> fdaValues =
+              new ArrayList<ASN1OctetString>(1);
+      fdaValues.add(new ASN1OctetString(fda.name()));
+      attributes.add(new LDAPAttribute(ATTR_TASK_FAILED_DEPENDENCY_ACTION,
+              fdaValues));
+    }
+
+    // add completion notification email addresses
+    List<String> compNotifEmailAddresss =
+            information.getNotifyUponCompletionEmailAddresses();
+    if (compNotifEmailAddresss != null && compNotifEmailAddresss.size() > 0) {
+      ArrayList<ASN1OctetString> compNotifEmailAddrValues =
+              new ArrayList<ASN1OctetString>(compNotifEmailAddresss.size());
+      for (String emailAddr : compNotifEmailAddresss) {
+        compNotifEmailAddrValues.add(new ASN1OctetString(emailAddr));
+      }
+      attributes.add(new LDAPAttribute(ATTR_TASK_NOTIFY_ON_COMPLETION,
+              compNotifEmailAddrValues));
+    }
+
+    // add error notification email addresses
+    List<String> errNotifEmailAddresss =
+            information.getNotifyUponErrorEmailAddresses();
+    if (errNotifEmailAddresss != null && errNotifEmailAddresss.size() > 0) {
+      ArrayList<ASN1OctetString> errNotifEmailAddrValues =
+              new ArrayList<ASN1OctetString>(errNotifEmailAddresss.size());
+      for (String emailAddr : errNotifEmailAddresss) {
+        errNotifEmailAddrValues.add(new ASN1OctetString(emailAddr));
+      }
+      attributes.add(new LDAPAttribute(ATTR_TASK_NOTIFY_ON_ERROR,
+              errNotifEmailAddrValues));
+    }
+
     information.addTaskAttributes(attributes);
 
     AddRequestProtocolOp addRequest = new AddRequestProtocolOp(entryDN,

--
Gitblit v1.10.0