Skip to content

Commit

Permalink
MID-6209 NPE when deleting work state of 0 tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Apr 14, 2020
1 parent 0914325 commit c4e60a6
Showing 1 changed file with 11 additions and 3 deletions.
Expand Up @@ -633,7 +633,7 @@ public InlineMenuItemAction initAction() {

@Override
public void onClick(AjaxRequestTarget target) {
deleteWorkState(target, getRowModel());
deleteWorkStatePerformed(target, getRowModel());
}
};
}
Expand Down Expand Up @@ -905,11 +905,19 @@ private void deleteWorkersAndWorkState(AjaxRequestTarget target, @NotNull IModel
refreshTable(TaskType.class, target);
}

private void deleteWorkState(AjaxRequestTarget target, @NotNull IModel<SelectableBean<TaskType>> task) {
private void deleteWorkStatePerformed(AjaxRequestTarget target, IModel<SelectableBean<TaskType>> task) {
List<TaskType> selectedTasks = getSelectedTasks(target, task);
if (selectedTasks == null) {
return;
}
selectedTasks.forEach(selectedTask -> deleteWorkState(target, selectedTask));
}

private void deleteWorkState(AjaxRequestTarget target, @NotNull TaskType task) {
Task opTask = createSimpleTask(OPERATION_DELETE_WORK_STATE);
OperationResult result = opTask.getResult();
try {
getTaskService().deleteWorkersAndWorkState(task.getObject().getValue().getOid(), false, WAIT_FOR_TASK_STOP, opTask, result);
getTaskService().deleteWorkersAndWorkState(task.getOid(), false, WAIT_FOR_TASK_STOP, opTask, result);
result.computeStatus();
} catch (ObjectNotFoundException | SchemaException | SecurityViolationException | ExpressionEvaluationException
| RuntimeException | CommunicationException | ConfigurationException e) {
Expand Down

0 comments on commit c4e60a6

Please sign in to comment.