Interface UserFactory


@PublicApi @ParametersAreNullableByDefault public interface UserFactory
Factory to handle conversions between SDUser and JIRA ApplicationUser classes.

For most APIs in Jira Service Management we only allow the usage for logged in users. As ApplicationUser is null for anonymous users the usage of SDUser and its subclasses is mandatory for these APIs. This allows APIs to be more specific that they need a logged in user.

This factory provides an easy way to convert ApplicationUser to subclasses

  • Method Details

    • wrap

      @Nonnull CheckedUser wrap(com.atlassian.jira.user.ApplicationUser appUser)
      Returns a CheckedUser from the application user or an error if an internal error occurred, or the ApplicationUser was null.
      Parameters:
      appUser - the application user
      Returns:
      a checked user
      Throws:
      ServiceDeskServiceException - on error
    • wrapUnchecked

      @Nonnull UncheckedUser wrapUnchecked(com.atlassian.jira.user.ApplicationUser appUser)
      Returns a UncheckedUser from the application user.
      Parameters:
      appUser - the application user
      Returns:
      returns a user
    • wrap

      @Nonnull List<CheckedUser> wrap(@Nonnull Collection<com.atlassian.jira.user.ApplicationUser> appUsers)
      Map a list of ApplicationUser to a list of CheckedUser. Return an error if any ApplicationUser can't be mapped. Reverse of unwrap(Collection).
      Parameters:
      appUsers - collection of ApplicationUser to map
      Returns:
      a list of CheckedUser
      Throws:
      ServiceDeskServiceException - if any of the ApplicationUser supplied can't be mapped
    • wrapUsername

      @Nonnull CheckedUser wrapUsername(String username)
      This turns a username into a JIRA Application User and then wraps it up.
      Parameters:
      username - the username to be pimped up
      Returns:
      a CheckedUser with useful stuff attached
    • wrapUsernames

      @Nonnull List<CheckedUser> wrapUsernames(@Nonnull Collection<String> usernames)
      This turns usernames into a JIRA Application User and then wraps them to CheckedUser.
      Parameters:
      usernames - the username to be wrap
      Returns:
      list of CheckedUser
    • wrapUserKey

      @Nonnull CheckedUser wrapUserKey(String userkey)
      This turns a user key into a JIRA Application User and then wraps it up.
      Parameters:
      userkey - find the user by their key, to be pimped up
      Returns:
      an SDUser with useful stuff attached
    • getCheckedUser

      @Nonnull CheckedUser getCheckedUser()
      Helper method to wrap getCurrentUserByType[CheckedUser].
      Returns:
      the current CheckedUser
    • getUncheckedUser

      @Nonnull UncheckedUser getUncheckedUser()
      Helper method to wrap getCurrentUserByType[UncheckedUser].
      Returns:
      the current UncheckedUser
    • unwrap

      @Nonnull List<com.atlassian.jira.user.ApplicationUser> unwrap(@Nonnull Collection<CheckedUser> checkedUsers)
      Map a list of CheckedUser to a list of ApplicationUser. Return an error if any CheckedUser can't be mapped. Reverse of wrap(Collection).
      Parameters:
      checkedUsers - collection of CheckedUser to map
      Returns:
      a list of ApplicationUser
      Throws:
      ServiceDeskServiceException - if any CheckedUser can't be mapped