private Map.Entry<Task, TaskFormData> checkTask(final String taskId, final String username) {
Task task;
try {
task = taskService.createTaskQuery().taskId(taskId).singleResult();
} catch (ActivitiException e) {
throw new NotFoundException("Activiti Task " + taskId, e);
}
TaskFormData formData;
try {
formData = formService.getTaskFormData(task.getId());
} catch (ActivitiException e) {
throw new NotFoundException("Form for Activiti Task " + taskId, e);
}
if (!adminUser.equals(username)) {
SyncopeUser user = userDAO.find(username);
if (user == null) {
throw new NotFoundException("Syncope User " + username);
}
}
return new SimpleEntry<Task, TaskFormData>(task, formData);
}