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 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()
Deprecated.
|
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. |
io.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 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 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
ApplicationRole s
(irrespective of whether the ApplicationRole s is backed by a license). |
boolean |
rolesEnabled()
Determines whether
ApplicationRole s 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 io.atlassian.fugue.Option<ApplicationRole> getRole(@Nonnull com.atlassian.application.api.ApplicationKey role)
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
role
- 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 @Deprecated 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 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 applicationKey)
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
applicationKey
- the identifier of the ApplicationRole
.true
if the installed ApplicationRole
is exceeded or false
otherwise.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 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 void clearConfiguration(com.atlassian.application.api.ApplicationKey key)
clearConfiguration
in interface com.atlassian.application.host.ApplicationConfigurationManager
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 boolean rolesEnabled()
ApplicationRoleManager
ApplicationRole
s are enabled.rolesEnabled
in interface ApplicationRoleManager
true
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()
CachingComponent
clearCache
in interface CachingComponent
public 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 LicenseCountService
GlobalPermissionKey
public void flush()
LicenseCountService
flush
in interface LicenseCountService
public void flushBillableUsersCache()
LicenseCountService
flushBillableUsersCache
in interface LicenseCountService
Copyright © 2002-2019 Atlassian. All Rights Reserved.