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 ofCheckedUser
to a list ofApplicationUser
.wrap
(com.atlassian.jira.user.ApplicationUser appUser) Returns aCheckedUser
from 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 ofApplicationUser
to a list ofCheckedUser
.wrapUnchecked
(com.atlassian.jira.user.ApplicationUser appUser) Returns aUncheckedUser
from 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 turnsusernames
into a JIRA Application User and then wraps them toCheckedUser
.
-
Method Details
-
wrap
Returns aCheckedUser
from 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 aUncheckedUser
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 ofApplicationUser
to a list ofCheckedUser
. Return an error if anyApplicationUser
can't be mapped. Reverse ofunwrap(Collection)
.- Parameters:
appUsers
- collection ofApplicationUser
to map- Returns:
- a list of
CheckedUser
- Throws:
ServiceDeskServiceException
- if any of theApplicationUser
supplied 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
CheckedUser
with useful stuff attached
-
wrapUsernames
This turnsusernames
into 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 ofCheckedUser
to a list ofApplicationUser
. Return an error if anyCheckedUser
can't be mapped. Reverse ofwrap(Collection)
.- Parameters:
checkedUsers
- collection ofCheckedUser
to map- Returns:
- a list of
ApplicationUser
- Throws:
ServiceDeskServiceException
- if anyCheckedUser
can't be mapped
-