public class DefaultApplicationRoleManager extends Object implements ApplicationRoleManager, CachingComponent, LicenseCountService, com.atlassian.application.host.ApplicationConfigurationManager
ApplicationRoleManager.| Constructor and Description |
|---|
DefaultApplicationRoleManager(com.atlassian.cache.CacheManager cacheManager,
ApplicationRoleStore store,
ApplicationRoleDefinitions definitions,
GroupManager groupManager,
JiraLicenseManager licenseManager,
RecoveryMode recoveryMode,
com.atlassian.crowd.embedded.api.CrowdService crowdService,
com.atlassian.event.api.EventPublisher eventPublisher,
InternalMembershipDao internalMembershipDao,
com.atlassian.crowd.embedded.spi.DirectoryDao directoryDao,
ExtendedUserDao ofBizUserDao,
OfBizTransactionManager ofBizTransactionManager,
com.atlassian.crowd.manager.directory.SynchronisationStatusManager crowdSyncStatusManager,
FeatureManager featureManager) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearCache()
Clear the cache within the component.
|
void |
clearConfiguration(com.atlassian.application.api.ApplicationKey key) |
void |
flush()
Clear the billable users cache.
|
void |
flushBillableUsersCache()
Clear the cache for billable users.
|
Set<com.atlassian.application.api.ApplicationKey> |
getDefaultApplicationKeys()
Returns an immutable
Set of ApplicationKeys 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
Groups associated with the ApplicationRole
backed by a (potentially exceeded) license. |
Set<ApplicationRole> |
getDefaultRoles()
Deprecated.
|
Set<com.atlassian.crowd.embedded.api.Group> |
getGroupsForLicensedRoles()
Get the
Set of group names that have been associated with all the ApplicationRoles
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 role)
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 ApplicationRoles that are backed by a (potentially exceeded)
license. |
Set<ApplicationRole> |
getRolesForGroup(com.atlassian.crowd.embedded.api.Group group)
Returns the
Set of ApplicationRoles 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
ApplicationRoles 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 applicationKey)
Returns
true if the number of users assigned to the given ApplicationRole exceeds the
number of seats granted by its license. |
void |
onApplicationDefined(com.atlassian.application.host.events.ApplicationDefinedEvent event) |
void |
onApplicationUndefined(com.atlassian.application.host.events.ApplicationUndefinedEvent event) |
void |
onClearCache(ClearCacheEvent event) |
void |
onComponentManagerShutdown(ComponentManagerShutdownEvent shutdownEvent) |
void |
onDirectoryReorder(com.atlassian.crowd.event.application.ApplicationDirectoryOrderUpdatedEvent event) |
void |
onDirectoryUpdated(com.atlassian.crowd.event.directory.DirectoryUpdatedEvent event) |
void |
onGroupCreated(com.atlassian.crowd.event.group.GroupCreatedEvent createdEvent) |
void |
onGroupDeleted(com.atlassian.crowd.event.group.GroupDeletedEvent deletedEvent) |
void |
onGroupMembershipDeleted(com.atlassian.crowd.event.group.GroupMembershipDeletedEvent e) |
void |
onGroupMembershipsCreated(com.atlassian.crowd.event.group.GroupMembershipsCreatedEvent e) |
void |
onGroupUpdated(com.atlassian.crowd.event.group.GroupUpdatedEvent updatedEvent) |
void |
onLicenseChanged(LicenseChangedEvent event) |
void |
onSyncFinished(com.atlassian.crowd.event.directory.RemoteDirectorySynchronisationFinishedEvent e) |
void |
onUserDeleted(com.atlassian.crowd.event.user.UserDeletedEvent e) |
void |
onUserUpdated(com.atlassian.crowd.event.user.AutoUserUpdatedEvent event) |
void |
onUserUpdated(com.atlassian.crowd.event.user.UserEditedEvent event) |
void |
removeGroupFromRoles(com.atlassian.crowd.embedded.api.Group group)
Removes any/all associations of the given group from all
ApplicationRoles
(irrespective of whether the ApplicationRoles is backed by a license). |
boolean |
rolesEnabled()
Determines whether
ApplicationRoles are enabled. |
ApplicationRole |
setRole(ApplicationRole role)
Save the passed
ApplicationRole information to the database. |
int |
totalBillableUsers()
Gets the number of active users who currently count towards the license and should be charged for.
|
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. |
protected void |
waitForActiveUsersCacheLoader() |
public DefaultApplicationRoleManager(@Nonnull com.atlassian.cache.CacheManager cacheManager, @Nonnull ApplicationRoleStore store, @Nonnull ApplicationRoleDefinitions definitions, @Nonnull GroupManager groupManager, @Nonnull JiraLicenseManager licenseManager, @Nonnull RecoveryMode recoveryMode, @Nonnull com.atlassian.crowd.embedded.api.CrowdService crowdService, @Nonnull com.atlassian.event.api.EventPublisher eventPublisher, @Nonnull InternalMembershipDao internalMembershipDao, @Nonnull com.atlassian.crowd.embedded.spi.DirectoryDao directoryDao, @Nonnull ExtendedUserDao ofBizUserDao, @Nonnull OfBizTransactionManager ofBizTransactionManager, @Nonnull com.atlassian.crowd.manager.directory.SynchronisationStatusManager crowdSyncStatusManager, @Nonnull FeatureManager featureManager)
protected void waitForActiveUsersCacheLoader()
@Nonnull public com.atlassian.fugue.Option<ApplicationRole> getRole(@Nonnull com.atlassian.application.api.ApplicationKey role)
ApplicationRoleManagerApplicationRole identified by the given ApplicationKey,
or Option.none() if no such ApplicationRole exists.
Note: ApplicationRoles 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 ApplicationRoleManagerrole - the ApplicationKey of the role to search for.ApplicationRole associated with the passed role identifier, or Option.none().@Nonnull public Set<ApplicationRole> getRoles()
ApplicationRoleManagerSet of all ApplicationRoles that are backed by a (potentially exceeded)
license.getRoles in interface ApplicationRoleManagerSet of all ApplicationRoles that are backed by a (potentially exceeded) license.@Nonnull @Deprecated public Set<ApplicationRole> getDefaultRoles()
ApplicationRoleManagerSet of ApplicationRoles that are configured be default for new users.getDefaultRoles in interface ApplicationRoleManagerSet of ApplicationRoles that are configured be default for new users.@Nonnull public Set<com.atlassian.application.api.ApplicationKey> getDefaultApplicationKeys()
ApplicationRoleManagerSet of ApplicationKeys that are configured as the default applications for new users.getDefaultApplicationKeys in interface ApplicationRoleManagerSet of ApplicationKeys that are configured as the default applications for new users.for defaul roles.public boolean hasAnyRole(@Nullable ApplicationUser user)
ApplicationRoleManagerApplicationRole that is backed by a
(potentially exceeded) license.hasAnyRole in interface ApplicationRoleManagerApplicationRole
that is backed by a (potentially exceeded) license.public boolean userHasRole(@Nullable ApplicationUser user, com.atlassian.application.api.ApplicationKey key)
ApplicationRoleManagertrue 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 ApplicationRoleManageruser - the user to check - if this is null, returns falsekey - the key corresponding to the ApplicationRolepublic boolean userOccupiesRole(@Nullable ApplicationUser user, com.atlassian.application.api.ApplicationKey key)
ApplicationRoleManagertrue if the passed user occupies a seat in the ApplicationRole associated with the given key.userOccupiesRole in interface ApplicationRoleManageruser - the user to check - if this is null, returns falsekey - the key corresponding to the ApplicationRolepublic boolean isAnyRoleLimitExceeded()
ApplicationRoleManagerApplicationRole 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 ApplicationRoleManagerpublic boolean isRoleLimitExceeded(@Nonnull com.atlassian.application.api.ApplicationKey applicationKey)
ApplicationRoleManagertrue 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 ApplicationRoleManagerapplicationKey - the identifier of the ApplicationRole.true if the installed ApplicationRole is exceeded or false otherwise.public boolean hasExceededAllRoles(@Nonnull ApplicationUser user)
ApplicationRoleManagerApplicationRoles 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 ApplicationRoleManageruser - 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 Set<ApplicationRole> getRolesForUser(@Nonnull ApplicationUser user)
ApplicationRoleManagergetRolesForUser in interface ApplicationRoleManageruser - the user whose roles will be checked.Set of ApplicationRoles for the given user.public Set<ApplicationRole> getOccupiedLicenseRolesForUser(@Nonnull ApplicationUser user)
ApplicationRoleManagerSet of ApplicationRoles that the given ApplicationUser occupies seats in.
ApplicationUser has to actively take a seat in the returned ApplicationRoles
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 ApplicationRoleManageruser - the user whose roles will be checked.Set of ApplicationRoles that the given user is actively taking seats.public Set<ApplicationRole> getRolesForGroup(@Nonnull com.atlassian.crowd.embedded.api.Group group)
ApplicationRoleManagerSet of ApplicationRoles associated with the given Group, or groups for
which the given group is a nested group (sub-group).getRolesForGroup in interface ApplicationRoleManagergroup - the group which roles will be checked.Set of ApplicationRoles associated with the group or its super-groups.@Nonnull public Set<com.atlassian.crowd.embedded.api.Group> getGroupsForLicensedRoles()
ApplicationRoleManagerSet of group names that have been associated with all the ApplicationRoles
that have a backing (but potentially exceeded) license.getGroupsForLicensedRoles in interface ApplicationRoleManagerApplicationRoles that have a backing (but potentially
exceeded) license.public void removeGroupFromRoles(@Nonnull com.atlassian.crowd.embedded.api.Group group)
ApplicationRoleManagerApplicationRoles
(irrespective of whether the ApplicationRoles is backed by a license).removeGroupFromRoles in interface ApplicationRoleManagergroup - 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 ApplicationRoleManagerkey - 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)
ApplicationRoleManagerApplicationRole information to the database.
This method will only accept the passed role if:
setRole in interface ApplicationRoleManagerrole - the role to save.public void clearConfiguration(com.atlassian.application.api.ApplicationKey key)
clearConfiguration in interface com.atlassian.application.host.ApplicationConfigurationManagerpublic int getUserCount(@Nonnull com.atlassian.application.api.ApplicationKey key)
ApplicationRoleManagerApplicationRole.
It will uniquely count all users who are found in the groups associated with the application.getUserCount in interface ApplicationRoleManagerkey - 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)
ApplicationRoleManagerApplicationRole
backed by a (potentially exceeded) license.getRemainingSeats in interface ApplicationRoleManagerkey - 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)
ApplicationRoleManagerApplicationRole backed by a license
has the requested number of user seats available.hasSeatsAvailable in interface ApplicationRoleManagerkey - 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)
ApplicationRoleManagerGroups associated with the ApplicationRole
backed by a (potentially exceeded) license.getDefaultGroups in interface ApplicationRoleManagerkey - the key that identifies the ApplicationRole.Set of default groups associated with the ApplicationRole.public boolean rolesEnabled()
ApplicationRoleManagerApplicationRoles are enabled.rolesEnabled in interface ApplicationRoleManagertrue when ApplicationRole are enabled, false otherwise.@EventListener public void onClearCache(ClearCacheEvent event)
@EventListener public void onApplicationDefined(com.atlassian.application.host.events.ApplicationDefinedEvent event)
@EventListener public void onApplicationUndefined(com.atlassian.application.host.events.ApplicationUndefinedEvent event)
@EventListener public void onLicenseChanged(LicenseChangedEvent event)
@EventListener public void onGroupCreated(com.atlassian.crowd.event.group.GroupCreatedEvent createdEvent)
@EventListener public void onGroupDeleted(com.atlassian.crowd.event.group.GroupDeletedEvent deletedEvent)
@EventListener public void onGroupUpdated(com.atlassian.crowd.event.group.GroupUpdatedEvent updatedEvent)
@EventListener public void onDirectoryReorder(com.atlassian.crowd.event.application.ApplicationDirectoryOrderUpdatedEvent event)
@EventListener public void onDirectoryUpdated(com.atlassian.crowd.event.directory.DirectoryUpdatedEvent event)
@EventListener public void onGroupMembershipsCreated(com.atlassian.crowd.event.group.GroupMembershipsCreatedEvent e)
@EventListener public void onGroupMembershipDeleted(com.atlassian.crowd.event.group.GroupMembershipDeletedEvent e)
@EventListener public void onUserDeleted(com.atlassian.crowd.event.user.UserDeletedEvent e)
@EventListener public void onUserUpdated(com.atlassian.crowd.event.user.UserEditedEvent event)
@EventListener public void onUserUpdated(com.atlassian.crowd.event.user.AutoUserUpdatedEvent event)
@EventListener public void onSyncFinished(com.atlassian.crowd.event.directory.RemoteDirectorySynchronisationFinishedEvent e)
@EventListener public void onComponentManagerShutdown(ComponentManagerShutdownEvent shutdownEvent)
@Internal public void clearCache()
CachingComponentclearCache in interface CachingComponentpublic int totalBillableUsers()
LicenseCountService
Implementations of this method should take performance into consideration, and ensure that the value is cached.
Use LicenseCountService.flush() to clear the cache.
totalBillableUsers in interface LicenseCountServiceGlobalPermissionKeypublic void flush()
LicenseCountServiceflush in interface LicenseCountServicepublic void flushBillableUsersCache()
LicenseCountServiceflushBillableUsersCache in interface LicenseCountServiceCopyright © 2002-2018 Atlassian. All Rights Reserved.