public class MockApplicationRoleManager extends Object implements ApplicationRoleManager
Constructor and Description |
---|
MockApplicationRoleManager() |
Modifier and Type | Method and Description |
---|---|
MockApplicationRole |
createRole(com.atlassian.application.api.ApplicationKey key) |
Set<com.atlassian.application.api.ApplicationKey> |
getDefaultApplicationKeys()
Returns an immutable
Set of ApplicationKey s that are configured as the default applications for new users. |
Set<com.atlassian.crowd.embedded.api.Group> |
getDefaultGroups(com.atlassian.application.api.ApplicationKey key)
Get the default
Group s associated with the ApplicationRole
backed by a (potentially exceeded) license. |
Set<ApplicationRole> |
getDefaultRoles()
Returns an immutable
Set of ApplicationRole s that are configured be default for new users. |
Set<com.atlassian.crowd.embedded.api.Group> |
getGroupsForLicensedRoles()
Get the
Set of group names that have been associated with all the ApplicationRole s
that have a backing (but potentially exceeded) license. |
Set<ApplicationRole> |
getOccupiedLicenseRolesForUser(ApplicationUser user)
|
int |
getRemainingSeats(com.atlassian.application.api.ApplicationKey key)
Retrieve the number of available (unoccupied) user seats for the
ApplicationRole
backed by a (potentially exceeded) license. |
com.atlassian.fugue.Option<ApplicationRole> |
getRole(com.atlassian.application.api.ApplicationKey key)
Returns the
ApplicationRole identified by the given ApplicationKey ,
or Option.none() if no such ApplicationRole exists. |
Set<ApplicationRole> |
getRoles()
Returns an immutable
Set of all ApplicationRole s that are backed by a (potentially exceeded)
license. |
Set<ApplicationRole> |
getRolesForGroup(com.atlassian.crowd.embedded.api.Group group)
Returns the
Set of ApplicationRole s associated with the given Group , or groups for
which the given group is a nested group (sub-group). |
Set<ApplicationRole> |
getRolesForUser(ApplicationUser user)
|
int |
getUserCount(com.atlassian.application.api.ApplicationKey key)
Retrieve the number of active users for the given
ApplicationRole . |
boolean |
hasAnyRole(ApplicationUser user)
Returns true if the given user has been assigned to any
ApplicationRole that is backed by a
(potentially exceeded) license. |
boolean |
hasExceededAllRoles(ApplicationUser user)
Returns true if the user limits of all of the given user's assigned
ApplicationRole s have been exceeded. |
boolean |
hasSeatsAvailable(com.atlassian.application.api.ApplicationKey key,
int seatCount)
Determines whether the
ApplicationRole backed by a license
has the requested number of user seats available. |
boolean |
isAnyRoleLimitExceeded()
Returns true if the number of users assigned to any
ApplicationRole exceeds the number of seats granted
to that role by its license. |
boolean |
isRoleInstalledAndLicensed(com.atlassian.application.api.ApplicationKey key)
Determines whether an application identified by the given
ApplicationKey
is installed and running in this JIRA instance AND has a backing license key. |
boolean |
isRoleLimitExceeded(com.atlassian.application.api.ApplicationKey role)
Returns
true if the number of users assigned to the given ApplicationRole exceeds the
number of seats granted by its license. |
void |
removeGroupFromRoles(com.atlassian.crowd.embedded.api.Group group)
Removes any/all associations of the given group from all
ApplicationRole s
(irrespective of whether the ApplicationRole s is backed by a license). |
ApplicationRole |
setRole(ApplicationRole role)
Save the passed
ApplicationRole information to the database. |
boolean |
userHasRole(ApplicationUser user,
com.atlassian.application.api.ApplicationKey key)
Returns
true if the passed user belongs to the ApplicationRole associated with the given key. |
boolean |
userOccupiesRole(ApplicationUser user,
com.atlassian.application.api.ApplicationKey key)
Returns
true if the passed user occupies a seat in the ApplicationRole associated with the given key. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
rolesEnabled
@Nonnull public com.atlassian.fugue.Option<ApplicationRole> getRole(@Nonnull com.atlassian.application.api.ApplicationKey key)
ApplicationRoleManager
ApplicationRole
identified by the given ApplicationKey
,
or Option.none()
if no such ApplicationRole
exists.
Note: ApplicationRole
s returned by this method are guaranteed to be backed by a (potentially exceeded)
license, however the installation state of the plugin/product that uses this role may not necessarily
physically installed.
getRole
in interface ApplicationRoleManager
key
- the ApplicationKey
of the role to search for.ApplicationRole
associated with the passed role identifier, or Option.none()
.@Nonnull public Set<ApplicationRole> getRoles()
ApplicationRoleManager
Set
of all ApplicationRole
s that are backed by a (potentially exceeded)
license.getRoles
in interface ApplicationRoleManager
Set
of all ApplicationRole
s that are backed by a (potentially exceeded) license.@Nonnull public Set<ApplicationRole> getDefaultRoles()
ApplicationRoleManager
Set
of ApplicationRole
s that are configured be default for new users.getDefaultRoles
in interface ApplicationRoleManager
Set
of ApplicationRole
s that are configured be default for new users.@Nonnull public Set<com.atlassian.application.api.ApplicationKey> getDefaultApplicationKeys()
ApplicationRoleManager
Set
of ApplicationKey
s that are configured as the default applications for new users.getDefaultApplicationKeys
in interface ApplicationRoleManager
Set
of ApplicationKey
s that are configured as the default applications for new users.for defaul roles.
public boolean hasAnyRole(@Nullable ApplicationUser user)
ApplicationRoleManager
ApplicationRole
that is backed by a
(potentially exceeded) license.hasAnyRole
in interface ApplicationRoleManager
ApplicationRole
that is backed by a (potentially exceeded) license.public boolean userHasRole(@Nullable ApplicationUser user, com.atlassian.application.api.ApplicationKey key)
ApplicationRoleManager
true
if the passed user belongs to the ApplicationRole
associated with the given key.
NOTE: This does not check that the application is licensed with a valid license.userHasRole
in interface ApplicationRoleManager
user
- the user to check - if this is null, returns false
key
- the key corresponding to the ApplicationRole
public boolean userOccupiesRole(@Nullable ApplicationUser user, com.atlassian.application.api.ApplicationKey key)
ApplicationRoleManager
true
if the passed user occupies a seat in the ApplicationRole
associated with the given key.userOccupiesRole
in interface ApplicationRoleManager
user
- the user to check - if this is null, returns false
key
- the key corresponding to the ApplicationRole
public boolean hasExceededAllRoles(@Nonnull ApplicationUser user)
ApplicationRoleManager
ApplicationRole
s have been exceeded.
The user limit of an ApplicationRole
is exceeded when the combined number of users assigned to that role
(through assigned groups) exceeds the number of seats granted for that role in its license.
Note: this method does NOT take into account whether licenses for application roles are
expired
; this must be tested separately.
hasExceededAllRoles
in interface ApplicationRoleManager
user
- the user whose roles will be checked.true
if all of the user
's roles have user counts that exceed the number of seats
granted by licenses.public boolean isAnyRoleLimitExceeded()
ApplicationRoleManager
ApplicationRole
exceeds the number of seats granted
to that role by its license.
Note: this method does NOT take into account whether licenses for installed roles are
expired
; this must be tested separately.
isAnyRoleLimitExceeded
in interface ApplicationRoleManager
public boolean isRoleLimitExceeded(@Nonnull com.atlassian.application.api.ApplicationKey role)
ApplicationRoleManager
true
if the number of users assigned to the given ApplicationRole
exceeds the
number of seats granted by its license. This method unconditionally returns false
if the passed role
is not considered to be installed (ie: backed by a license).
Note: this method does NOT take into account whether licenses for installed roles are
expired
; this must be tested separately.
isRoleLimitExceeded
in interface ApplicationRoleManager
role
- the identifier of the ApplicationRole
.true
if the installed ApplicationRole
is exceeded or false
otherwise.public Set<ApplicationRole> getRolesForUser(@Nonnull ApplicationUser user)
ApplicationRoleManager
getRolesForUser
in interface ApplicationRoleManager
user
- the user whose roles will be checked.Set
of ApplicationRole
s for the given user
.public Set<ApplicationRole> getOccupiedLicenseRolesForUser(@Nonnull ApplicationUser user)
ApplicationRoleManager
Set
of ApplicationRole
s that the given ApplicationUser
occupies seats in.
ApplicationUser
has to actively take a seat in the returned ApplicationRole
s
eg. for an ApplicationUser
who has access to SOFTWARE and implicitly (or explicitly) CORE, they will only have SOFTWARE returned.
For an ApplicationUser
who has explicit access to SOFTWARE and CORE - with the SOFTWARE license exceeded,
this will return both as the user effectively occupies a seat in both CORE and SOFTWARE now.getOccupiedLicenseRolesForUser
in interface ApplicationRoleManager
user
- the user whose roles will be checked.Set
of ApplicationRole
s that the given user
is actively taking seats.public Set<ApplicationRole> getRolesForGroup(@Nonnull com.atlassian.crowd.embedded.api.Group group)
ApplicationRoleManager
Set
of ApplicationRole
s associated with the given Group
, or groups for
which the given group is a nested group (sub-group).getRolesForGroup
in interface ApplicationRoleManager
group
- the group which roles will be checked.Set
of ApplicationRole
s associated with the group or its super-groups.@Nonnull public Set<com.atlassian.crowd.embedded.api.Group> getGroupsForLicensedRoles()
ApplicationRoleManager
Set
of group names that have been associated with all the ApplicationRole
s
that have a backing (but potentially exceeded) license.getGroupsForLicensedRoles
in interface ApplicationRoleManager
ApplicationRole
s that have a backing (but potentially
exceeded) license.public void removeGroupFromRoles(@Nonnull com.atlassian.crowd.embedded.api.Group group)
ApplicationRoleManager
ApplicationRole
s
(irrespective of whether the ApplicationRole
s is backed by a license).removeGroupFromRoles
in interface ApplicationRoleManager
group
- the group to remove.public boolean isRoleInstalledAndLicensed(@Nonnull com.atlassian.application.api.ApplicationKey key)
ApplicationRoleManager
Determines whether an application identified by the given ApplicationKey
is installed and running in this JIRA instance AND has a backing license key.
isRoleInstalledAndLicensed
in interface ApplicationRoleManager
key
- the key that identifies the ApplicationRole
backed by a (potentially exceeded) license.true
when the ApplicationRole
backed by a (potentially exceeded) license
has an associated application installed and running in this JIRA instance.@Nonnull public ApplicationRole setRole(@Nonnull ApplicationRole role)
ApplicationRoleManager
ApplicationRole
information to the database.
This method will only accept the passed role if:
setRole
in interface ApplicationRoleManager
role
- the role to save.public int getUserCount(@Nonnull com.atlassian.application.api.ApplicationKey key)
ApplicationRoleManager
ApplicationRole
.
It will uniquely count all users who are found in the groups associated with the application.getUserCount
in interface ApplicationRoleManager
key
- the key that identifies the ApplicationRole
.ApplicationRole
, or zero if the
ApplicationRole
does not exist.public int getRemainingSeats(@Nonnull com.atlassian.application.api.ApplicationKey key)
ApplicationRoleManager
ApplicationRole
backed by a (potentially exceeded) license.getRemainingSeats
in interface ApplicationRoleManager
key
- the key that identifies the licensed ApplicationRole
.ApplicationRole
is not valid or there are as many active users as seats in the license.
When the license is unlimited, it will return minus one (-1)for finding occupied user seats.
public boolean hasSeatsAvailable(@Nonnull com.atlassian.application.api.ApplicationKey key, int seatCount)
ApplicationRoleManager
ApplicationRole
backed by a license
has the requested number of user seats available.hasSeatsAvailable
in interface ApplicationRoleManager
key
- the key that identifies the ApplicationRole
.seatCount
- the number of user seats that this ApplicationRole
should have capacity for.true
if the ApplicationRole
for the provided ApplicationKey
has the number of user seats available.
false
if the there are not enough seats available.@Nonnull public Set<com.atlassian.crowd.embedded.api.Group> getDefaultGroups(@Nonnull com.atlassian.application.api.ApplicationKey key)
ApplicationRoleManager
Group
s associated with the ApplicationRole
backed by a (potentially exceeded) license.getDefaultGroups
in interface ApplicationRoleManager
key
- the key that identifies the ApplicationRole
.Set
of default groups associated with the ApplicationRole
.public MockApplicationRole createRole(com.atlassian.application.api.ApplicationKey key)
Copyright © 2002-2015 Atlassian. All Rights Reserved.