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 Summary
Modifier and TypeMethodDescriptionHelper method to wrap getCurrentUserByType[CheckedUser].Helper method to wrap getCurrentUserByType[UncheckedUser].List<com.atlassian.jira.user.ApplicationUser>unwrap(Collection<CheckedUser> checkedUsers) Map a list ofCheckedUserto a list ofApplicationUser.wrap(com.atlassian.jira.user.ApplicationUser appUser) Returns aCheckedUserfrom the application user or an error if an internal error occurred, or the ApplicationUser wasnull.wrap(Collection<com.atlassian.jira.user.ApplicationUser> appUsers) Map a list ofApplicationUserto a list ofCheckedUser.wrapUnchecked(com.atlassian.jira.user.ApplicationUser appUser) Returns aUncheckedUserfrom the application user.wrapUserKey(String userkey) This turns a user key into a JIRA Application User and then wraps it up.wrapUsername(String username) This turns a username into a JIRA Application User and then wraps it up.wrapUsernames(Collection<String> usernames) This turnsusernamesinto a JIRA Application User and then wraps them toCheckedUser.
-
Method Details
-
wrap
Returns aCheckedUserfrom the application user or an error if an internal error occurred, or the ApplicationUser wasnull.- Parameters:
appUser- the application user- Returns:
- a checked user
- Throws:
ServiceDeskServiceException- on error
-
wrapUnchecked
Returns aUncheckedUserfrom 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 ofApplicationUserto a list ofCheckedUser. Return an error if anyApplicationUsercan't be mapped. Reverse ofunwrap(Collection).- Parameters:
appUsers- collection ofApplicationUserto map- Returns:
- a list of
CheckedUser - Throws:
ServiceDeskServiceException- if any of theApplicationUsersupplied can't be mapped
-
wrapUsername
This turns a username into a JIRA Application User and then wraps it up.- Parameters:
username- the username to be pimped up- Returns:
- a
CheckedUserwith useful stuff attached
-
wrapUsernames
This turnsusernamesinto a JIRA Application User and then wraps them toCheckedUser.- Parameters:
usernames- the username to be wrap- Returns:
- list of
CheckedUser
-
wrapUserKey
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
Helper method to wrap getCurrentUserByType[CheckedUser].- Returns:
- the current
CheckedUser
-
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 ofCheckedUserto a list ofApplicationUser. Return an error if anyCheckedUsercan't be mapped. Reverse ofwrap(Collection).- Parameters:
checkedUsers- collection ofCheckedUserto map- Returns:
- a list of
ApplicationUser - Throws:
ServiceDeskServiceException- if anyCheckedUsercan't be mapped
-