public UserEntity safelyUpdateUserEntity(UserEntity userEntity, Command command) {
    return safelyUpdateUserEntity(userEntity, command, MAX_RETRIES);
  }
Attempts to update the specified {@link UserEntity} while handling {@link OptimisticLockException}s
by obtaining the latest version of the {@link UserEntity} and retrying the operation.

If the maximum number of retries is exceeded (see {@link #MAX_RETRIES}), then the operation
will fail by rethrowing the last exception encountered.


@param userEntity the user entity
@param command  a command to perform on the user entity object that changes it state thus needing
                to be persisted
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/Users.java