if (!checked.getKey().getOwner().equals(username)) {
throw new WorkflowException(new RuntimeException("Task " + form.getTaskId() + " assigned to "
+ checked.getKey().getOwner() + " but submited by " + username));
}
SyncopeUser user = userDAO.findByWorkflowId(checked.getKey().getProcessInstanceId());
if (user == null) {
throw new NotFoundException("User with workflow id " + checked.getKey().getProcessInstanceId());
}
Set<String> preTasks = getPerformedTasks(user);
try {
formService.submitTaskFormData(form.getTaskId(), form.getPropertiesForSubmit());
} catch (ActivitiException e) {
throw new WorkflowException(e);
}
Set<String> postTasks = getPerformedTasks(user);
postTasks.removeAll(preTasks);
postTasks.add(form.getTaskId());
updateStatus(user);
SyncopeUser updated = userDAO.save(user);
// see if there is any propagation to be done
PropagationByResource propByRes = (PropagationByResource) runtimeService.getVariable(user.getWorkflowId(),
PROP_BY_RESOURCE);
// fetch - if available - the encrpted password
String clearPassword = null;
String encryptedPwd = (String) runtimeService.getVariable(user.getWorkflowId(), ENCRYPTED_PWD);
if (StringUtils.isNotBlank(encryptedPwd)) {
clearPassword = decrypt(encryptedPwd);
}
return new WorkflowResult<Map.Entry<Long, String>>(new DefaultMapEntry(updated.getId(), clearPassword),
propByRes, postTasks);
}