@com.adaptavist.hapi.platform.analytics.Tracked class Users extends java.lang.Object
Constructor and description |
---|
Users() |
Type Params | Return Type | Name and description |
---|---|---|
|
static com.atlassian.user.User |
getByKey(com.atlassian.sal.api.user.UserKey userKey) Retrieves a User by userKey |
|
static com.atlassian.user.User |
getByKey(java.lang.String userKey) Retrieves a User by string corresponding to the user's userKey Users.getByKey('ff8080818b0052d3018b006f216d0000') |
|
static com.atlassian.user.User |
getByName(java.lang.String username) Retrieves a User by name Users.getByName('username') |
|
static UserIterator |
getInactiveUsers(java.time.Duration durationSinceLastLogin) Get users who have been inactive for a specified amount of time, example usage: Users.getInactiveUsers(Duration.of(90, ChronoUnit.DAYS)) |
|
static com.atlassian.confluence.user.ConfluenceUser |
getLoggedInUser() Get the current logged in user, may be null if the logged in user is anonymous, example usage: Users.getLoggedInUser() |
<T> |
static T |
runAnonymously(java.util.concurrent.Callable<T> callable) Run an action with no logged in user, returning the result, example usage: def pages = Users.runAnonymously { Pages.search('space = ds') } |
<T> |
static T |
runAs(java.lang.String username, java.util.concurrent.Callable<T> callable) Run an action as a different user, returning the result, example usage: def pages = Users.runAs('username') { Pages.search('space = ds') } |
<T> |
static T |
runAs(com.atlassian.confluence.user.ConfluenceUser user, java.util.concurrent.Callable<T> callable) Run an action as a different user, returning the result, example usage: def pages = Users.runAs(Users.getByName('username')) { Pages.search('space = ds') } |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Retrieves a User by userKey
userKey
- the userKey of the user to retrieveRetrieves a User by string corresponding to the user's userKey
Users.getByKey('ff8080818b0052d3018b006f216d0000')
userKey
- the string corresponding to the userKey of the user to retrieveRetrieves a User by name
Users.getByName('username')
username
- the name of the user to retrieveGet users who have been inactive for a specified amount of time, example usage:
Users.getInactiveUsers(Duration.of(90, ChronoUnit.DAYS))
durationSinceLastLogin
- Duration representing the maximum duration of time since a user's last login in order to be considered activeGet the current logged in user, may be null if the logged in user is anonymous, example usage:
Users.getLoggedInUser()
Run an action with no logged in user, returning the result, example usage:
def pages = Users.runAnonymously { Pages.search('space = ds') }
callable
- the action to run, which returns a resultRun an action as a different user, returning the result, example usage:
def pages = Users.runAs('username') { Pages.search('space = ds') }
username
- user to run the action ascallable
- the action to run, which returns a resultRun an action as a different user, returning the result, example usage:
def pages = Users.runAs(Users.getByName('username')) { Pages.search('space = ds') }
user
- user to run the action ascallable
- the action to run, which returns a result