Skip to content

Commit

Permalink
Fix for MID-1920.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jul 16, 2014
1 parent 58b31d9 commit 3f56244
Showing 1 changed file with 14 additions and 0 deletions.
Expand Up @@ -481,6 +481,7 @@ public void resumeTask(Task task, OperationResult parentResult) throws ObjectNot
result.recordFatalError(message);
return;
}
clearTaskOperationResult(task, parentResult); // see a note on scheduleTaskNow
resumeOrUnpauseTask(task, result);
}

Expand Down Expand Up @@ -1350,9 +1351,16 @@ public void deleteNode(String nodeOid, OperationResult result) throws SchemaExce

@Override
public void scheduleTaskNow(Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException {
/*
* Note: we clear task operation result because this is what a user would generally expect when re-running a task
* (MID-1920). We do NOT do that on each task run e.g. to have an ability to see last task execution status
* during a next task run. (When the interval between task runs is too short, e.g. for live sync tasks.)
*/
if (task.isClosed()) {
clearTaskOperationResult(task, parentResult);
executionManager.reRunClosedTask(task, parentResult);
} else if (task.getExecutionStatus() == TaskExecutionStatus.RUNNABLE) {
clearTaskOperationResult(task, parentResult);
scheduleRunnableTaskNow(task, parentResult);
} else {
String message = "Task " + task + " cannot be run now, because it is not in RUNNABLE nor CLOSED state.";
Expand All @@ -1362,6 +1370,12 @@ public void scheduleTaskNow(Task task, OperationResult parentResult) throws Sche
}
}

private void clearTaskOperationResult(Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException {
OperationResult emptyTaskResult = new OperationResult("run");
emptyTaskResult.setStatus(OperationResultStatus.IN_PROGRESS);
task.setResultImmediate(emptyTaskResult, parentResult);
}

public void scheduleRunnableTaskNow(Task task, OperationResult parentResult) {
executionManager.scheduleRunnableTaskNow(task, parentResult);
}
Expand Down

0 comments on commit 3f56244

Please sign in to comment.