From 29be609adb8377a6535926fc33c9f5906a4ec696 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Mon, 17 Sep 2007 15:27:39 +0000
Subject: [PATCH] This commit is for supporting of task scheduling in the future (right now tasks can only be scheduled to start immediately) for tasks that support scheduling. Start time is specified by including -t/--startTime along with a date string of format 'YYYYMMDDhhmmss'.
---
opends/src/server/org/opends/server/tools/tasks/TaskClient.java | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 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 b9972a1..e3ca663 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,8 @@
import org.opends.server.types.SearchScope;
import static org.opends.server.types.ResultCode.*;
import org.opends.server.backends.task.TaskState;
+import static org.opends.server.util.ServerConstants.*;
+import org.opends.server.util.StaticUtils;
import java.io.IOException;
import java.text.SimpleDateFormat;
@@ -102,9 +104,10 @@
* @throws LDAPException if there is a problem getting information
* out to the directory
* @throws ASN1Exception if there is a problem with the encoding
+ * @throws TaskClientException if there is a problem with the task entry
*/
- public synchronized String schedule(TaskScheduleInformation information)
- throws LDAPException, IOException, ASN1Exception
+ public synchronized TaskEntry schedule(TaskScheduleInformation information)
+ throws LDAPException, IOException, ASN1Exception, TaskClientException
{
LDAPReader reader = connection.getLDAPReader();
LDAPWriter writer = connection.getLDAPWriter();
@@ -135,6 +138,17 @@
classValues.add(new ASN1OctetString(information.getTaskClass().getName()));
attributes.add(new LDAPAttribute(ATTR_TASK_CLASS, classValues));
+ // add the start time if necessary
+ Date startDate = information.getStartDateTime();
+ if (startDate != null) {
+ String startTimeString = StaticUtils.formatDateTimeString(startDate);
+ ArrayList<ASN1OctetString> startDateValues =
+ new ArrayList<ASN1OctetString>(1);
+ startDateValues.add(new ASN1OctetString(startTimeString));
+ attributes.add(new LDAPAttribute(ATTR_TASK_SCHEDULED_START_TIME,
+ startDateValues));
+ }
+
information.addTaskAttributes(attributes);
AddRequestProtocolOp addRequest = new AddRequestProtocolOp(entryDN,
@@ -171,7 +185,7 @@
LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR,
errorMessage);
}
- return taskID;
+ return getTaskEntry(taskID);
}
/**
--
Gitblit v1.10.0