if (moreVariables != null && !moreVariables.isEmpty()) {
variables.putAll(moreVariables);
}
if (StringUtils.isBlank(user.getWorkflowId())) {
throw new WorkflowException(new NotFoundException("Empty workflow id for " + user));
}
List<Task> tasks = taskService.createTaskQuery().processInstanceId(user.getWorkflowId()).list();
if (tasks.size() == 1) {
try {
taskService.complete(tasks.get(0).getId(), variables);
} catch (ActivitiException e) {
throw new WorkflowException("While completing task '" + tasks.get(0).getName() + "' for " + user, e);
}
} else {
LOG.warn("Expected a single task, found {}", tasks.size());
}