class UserController extends AbstractCrudController<User> {

    protected void updateUserGroups( String pvUid, User parsed, User currentUser )
    {
        User user = userService.getUser( pvUid );

        // current user may have been changed and detached and must become managed again
        // TODO: what is this doing? I don't understand how this is possible.
        if ( currentUser != null && currentUser.getId() == user.getId() )
        {
            currentUser = currentUserService.getCurrentUser();
        }

        userGroupService.updateUserGroups( user, IdentifiableObjectUtils.getUids( parsed.getGroups() ), currentUser );
    }

}