| | |
| | | // If there is an existing task with the same id |
| | | // and it is in completed state, take its place. |
| | | Task t = tasks.get(task.getTaskID()); |
| | | if ((t != null) && TaskState.isDone(t.getTaskState())) |
| | | if (t != null && TaskState.isDone(t.getTaskState())) |
| | | { |
| | | removeCompletedTask(t.getTaskID()); |
| | | } |
| | |
| | | for (Task t : tasks.values()) |
| | | { |
| | | // Find any existing task iterations and try to cancel them. |
| | | if ((t.getRecurringTaskID() != null) && |
| | | (t.getRecurringTaskID().equals(recurringTaskID))) |
| | | if (t.getRecurringTaskID() != null && |
| | | t.getRecurringTaskID().equals(recurringTaskID)) |
| | | { |
| | | TaskState state = t.getTaskState(); |
| | | if (!TaskState.isDone(state) && !TaskState.isCancelled(state)) |
| | |
| | | } |
| | | else if (TaskState.isDone(state)) |
| | | { |
| | | if ((state == TaskState.CANCELED_BEFORE_STARTING) && |
| | | task.isRecurring()) |
| | | if (state == TaskState.CANCELED_BEFORE_STARTING && task.isRecurring()) |
| | | { |
| | | pendingTasks.add(task); |
| | | } |
| | |
| | | // If there is an existing task with the same id |
| | | // and it is in completed state, take its place. |
| | | Task t = tasks.get(newIteration.getTaskID()); |
| | | if ((t != null) && TaskState.isDone(t.getTaskState())) |
| | | if (t != null && TaskState.isDone(t.getTaskState())) |
| | | { |
| | | removeCompletedTask(t.getTaskID()); |
| | | } |
| | |
| | | } |
| | | // Recurring task iteration has to spawn the next one |
| | | // even if the current iteration has been canceled. |
| | | else if ((state == TaskState.CANCELED_BEFORE_STARTING) && |
| | | t.isRecurring()) |
| | | else if (state == TaskState.CANCELED_BEFORE_STARTING && t.isRecurring()) |
| | | { |
| | | if (t.getScheduledStartTime() > TimeThread.getTime()) { |
| | | // If we're waiting for the start time to arrive, |
| | | // then see if that will come before the next |
| | | // sleep time is up. |
| | | // then see if that will come before the next sleep time is up. |
| | | long waitTime = |
| | | t.getScheduledStartTime() - TimeThread.getTime(); |
| | | sleepTime = Math.min(sleepTime, waitTime); |
| | |
| | | state = null; |
| | | } |
| | | |
| | | if ((state != null) && TaskState.isDone(state)) |
| | | if (state != null && TaskState.isDone(state)) |
| | | { |
| | | return state; |
| | | } |
| | |
| | | // Get the name of the class that implements the task logic. |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_CLASS.toLowerCase(), ATTR_TASK_CLASS); |
| | | List<Attribute> attrList = entry.getAttribute(attrType); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_TASKSCHED_NO_CLASS_ATTRIBUTE.get(ATTR_TASK_ID); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |