@PreAuthorize("hasRole('ROLE_UPDATE')")
@RequestMapping(method = RequestMethod.POST, value = "/update")
public RoleTO update(@RequestBody final RoleMod roleMod) {
LOG.debug("Role update called with {}", roleMod);
SyncopeRole role = binder.getRoleFromId(roleMod.getId());
WorkflowResult<Long> updated = rwfAdapter.update(roleMod);
List<PropagationTask> tasks = propagationManager.getRoleUpdateTaskIds(updated,
roleMod.getVirtualAttributesToBeRemoved(), roleMod.getVirtualAttributesToBeUpdated());
final List<PropagationStatusTO> propagations = new ArrayList<PropagationStatusTO>();
final DefaultPropagationHandler propHanlder = new DefaultPropagationHandler(connObjectUtil, propagations);
try {
taskExecutor.execute(tasks, new DefaultPropagationHandler(connObjectUtil, propagations));
} catch (PropagationException e) {
LOG.error("Error propagation primary resource", e);
propHanlder.completeWhenPrimaryResourceErrored(propagations, tasks);
}
final RoleTO updatedTO = binder.getRoleTO(updated.getResult());
updatedTO.setPropagationStatusTOs(propagations);
auditManager.audit(Category.role, RoleSubCategory.update, Result.success,
"Successfully updated role: " + role.getId());
LOG.debug("About to return updated role\n{}", updatedTO);
return updatedTO;
}