Class UserService

    • Constructor Detail

      • UserService

        @Autowired
        public UserService​(UserRepository repository)
        Constructor that instantiates a new User repository object.
        Parameters:
        repository - User repository object.
    • Method Detail

      • getOrCreate

        public User getOrCreate​(String oauthKey,
                                String displayName)
        Queries the database for a User object defined by Oauth key. If a User object doesn't exist it gets added to the database.
        Parameters:
        oauthKey - An OAuth key in the form of a string.
        displayName - A display name in the form of a string.
        Returns:
        A User object.
      • get

        public Optional<User> get​(UUID id)
        Returns a User object that matches the id.
        Parameters:
        id - Id in the form of a universally unique identifier.
        Returns:
        An optional User object.
      • getByExternalKey

        public Optional<User> getByExternalKey​(UUID externalKey)
        Returns a User that matches the external key.
        Parameters:
        externalKey - External key in the form of a universally unique identifier.
        Returns:
        An optional User object.
      • getAll

        public Iterable<User> getAll()
        Returns a list of User ordered by display name in ascending order.
        Returns:
        A list of User objects.
      • save

        public User save​(User user)
        Saves a User object to the database.
        Parameters:
        user - A User object.
        Returns:
        A User object.
      • delete

        public void delete​(User user)
        Deletes a User object that matches the parameter user from the database.
        Parameters:
        user - A User Object.
      • getCurrentUser

        public User getCurrentUser()
        Gets a current User object from the database.
        Returns:
        A User object.
      • update

        public User update​(User updateUser,
                           User user)
        Updates the current User object records from the provided updated User record, and saves the result to the database.
        Parameters:
        updateUser - User deserialized from body of request.
        user - Current requestor.
        Returns:
        Updated user instance.