@Override public User delegate(UserManager um) { return um.removeRole(user, roleName); } });
@Override public void execute(InstallContext ctx) throws TaskExecutionException { UserManager userManager = Components.getComponent(SecuritySupport.class).getUserManager(); User user = userManager.getUser(username); if (user == null) { ctx.warn(String.format("User \"%s\" not found, can't add the \"%s\" role.", username, rolename)); } else { // TODO this "might" save at node level, thus breaking the "save once per module install/update" rule :( // (copied from AddRoleToUserTask) try { userManager.removeRole(user, rolename); } catch (UnsupportedOperationException e) { ctx.warn(String.format("Can't remove role \"%s\" from user \"%s\" due to an unsupported operation exception. This is most likely the case if the users are managed externally.", rolename, username)); } } } }