When trying to update a task property (bpm:comment) with code run as system, the update is just not applied (but no exception thrown). When executing the code as the task assigned user, it works fine.
Any idea ?
The code:
try {
if (userIsProcessManager) {
AuthenticationUtil.setRunAsUserSystem();
logger.debug("Running as system user");
}
WorkflowTask task = this.services.getWorkflowService().getTaskById(taskId);
if (task == null){
logger.error(ERR_MSG_INCORRECT_TASKID);
throw new WebScriptException(ERR_CODE_BAD_REQUEST, ERR_MSG_INCORRECT_TASKID);
}
if ((!userIsProcessManager) &&
(AuthenticationUtil.getFullyAuthenticatedUser().compareToIgnoreCase((String) task.getProperties().get(ContentModel.PROP_OWNER)) !=0)){
logger.error(ERR_MSG_INCORRECT_TASK_ASSIGNEE);
throw new WebScriptException(ERR_CODE_BAD_REQUEST, ERR_MSG_INCORRECT_TASK_ASSIGNEE);
}
Map<QName, Serializable> props = this.getPropertyMap (...);
this.services.getWorkflowService().updateTask(taskId, props, null, null);
if (endTask) this.services.getWorkflowService().endTask(taskId, null);
}finally {
AuthenticationUtil.clearCurrentSecurityContext();
}