Class CachingSpacePermissionManager
java.lang.Object
com.atlassian.confluence.impl.security.AbstractSpacePermissionManager
com.atlassian.confluence.impl.security.DefaultSpacePermissionManager
com.atlassian.confluence.impl.security.CachingSpacePermissionManager
- All Implemented Interfaces:
SpacePermissionManagerInternal
,SpacePermissionSaverInternal
,DefaultConfluenceAccessManager.AccessManagerPermissionChecker
,SpacePermissionManager
,SpacePermissionSaver
- Direct Known Subclasses:
RecoveryAwareCachingSpacePermissionManager
@Internal
@ParametersAreNonnullByDefault
public class CachingSpacePermissionManager
extends DefaultSpacePermissionManager
Implementation of SpacePermissionManager that implements caching before a SpacePermission is requested,
saved or removed from the SpacePermissionDao. This is designed to increase performance and reduce the
amount of hits on the database.
- Since:
- 7.16
-
Constructor Summary
ConstructorsConstructorDescriptionCachingSpacePermissionManager
(SpacePermissionDao spacePermissionDao, PermissionCheckExemptions permissionCheckExemptions, SpacePermissionDefaultsStoreFactory spacePermissionDefaultsStoreFactory, TransactionAwareCacheFactory cacheFactory, com.atlassian.event.api.EventPublisher eventPublisher, ConfluenceAccessManager confluenceAccessManager, SpacePermissionAccessMapper spacePermissionAccessMapper, com.atlassian.crowd.embedded.api.CrowdService crowdService, ConfluenceUserResolver userResolver, AccessModeManager accessModeManager, GlobalSettingsManager settingsManager, GroupResolver groupResolver, SpaceDaoInternal spaceDao) -
Method Summary
Modifier and TypeMethodDescriptionvoid
getGroupNamesWithPermission
(@Nullable Space targetSpace, String permissionType) boolean
hasPermissionNoExemptions
(String permissionType, @Nullable Space space, @Nullable ConfluenceUser remoteUser) Returns true if the user has the specified permission on the target space.boolean
hasPermissionNoExemptionsExceptViaNestedGroups
(String permissionType, @Nullable Space space, @Nullable ConfluenceUser remoteUser) Returns true if the user has the specified permission on the target space except if it gets it from some parent of its parent group.boolean
boolean
permissionExists
(SpacePermission permission) Looks up permission in the cache instance.protected void
removeAllPermissionsFromDao
(Space space, SpacePermissionContext context) protected void
removePermissionFromDao
(SpacePermission spacePermission) Removes realPermission from the DAO.protected void
savePermissionToDao
(SpacePermission spacePermission) Saves permission to the DAO.void
setLookAheadEnabled
(boolean lookAheadEnabled) Methods inherited from class com.atlassian.confluence.impl.security.DefaultSpacePermissionManager
createDefaultSpacePermissions, createPrivateSpacePermissions, getAllPermissionsForGroup, getAllPermissionsForUser, getGlobalPermissions, getGlobalPermissions, getGroupsForPermissionType, getGroupsWithPermissions, getPermissionsForAnonymousUsers, getPermissionsForGroup, getPermissionsForUser, getUsersForPermissionType, getUsersWithPermissions, removeAllPermissions, removeAllPermissions, removeAllPermissionsForGroup, removeAllPermissionsForGroup, removeAllUserPermissions, removeAllUserPermissions, removeGlobalPermissionForUser, removeGlobalPermissionForUser, removePermission, removePermission, removePermissions, saveGlobalPermissions, savePermission, savePermission, saveSpacePermissions
Methods inherited from class com.atlassian.confluence.impl.security.AbstractSpacePermissionManager
getDefaultGlobalPermissions, groupHasPermission, groupInheritsPermission, hasAllPermissions, hasGlobalPermissionViaGroups, hasPermission, hasPermissionForSpace, isPermittedInReadOnlyAccessMode
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.atlassian.confluence.security.access.DefaultConfluenceAccessManager.AccessManagerPermissionChecker
hasGlobalPermissionViaGroups
Methods inherited from interface com.atlassian.confluence.security.SpacePermissionManager
hasAllPermissions, hasPermission, hasPermissionForSpace, hasPermissionNoExemptions
-
Constructor Details
-
CachingSpacePermissionManager
public CachingSpacePermissionManager(SpacePermissionDao spacePermissionDao, PermissionCheckExemptions permissionCheckExemptions, SpacePermissionDefaultsStoreFactory spacePermissionDefaultsStoreFactory, TransactionAwareCacheFactory cacheFactory, com.atlassian.event.api.EventPublisher eventPublisher, ConfluenceAccessManager confluenceAccessManager, SpacePermissionAccessMapper spacePermissionAccessMapper, com.atlassian.crowd.embedded.api.CrowdService crowdService, ConfluenceUserResolver userResolver, AccessModeManager accessModeManager, GlobalSettingsManager settingsManager, GroupResolver groupResolver, SpaceDaoInternal spaceDao)
-
-
Method Details
-
permissionExists
Looks up permission in the cache instance. If it is not found, then it is looked up by the DAO and the result (true or false) is also recorded.If permission belongs to a space, it is looked up in the Space's own permissions list.
In addition, when lookAheadEnabled is true, #doLookAheadCache will be called and the results cached, provided permission does not belong to a space.
- Specified by:
permissionExists
in interfaceDefaultConfluenceAccessManager.AccessManagerPermissionChecker
- Specified by:
permissionExists
in interfaceSpacePermissionManager
- Overrides:
permissionExists
in classDefaultSpacePermissionManager
- Parameters:
permission
- the SpacePermission to look up- Returns:
- true if the permission exists, false otherwise
-
savePermissionToDao
Saves permission to the DAO. In addition, this method removes the permission from the cache, to prevent corruption of the cache when there is a transaction rollback (since the cache isn't transactional)- Overrides:
savePermissionToDao
in classDefaultSpacePermissionManager
- Parameters:
spacePermission
- the SpacePermission to save
-
removePermissionFromDao
Removes realPermission from the DAO. In addition, the permission is also removed from the cache.- Overrides:
removePermissionFromDao
in classDefaultSpacePermissionManager
- Parameters:
spacePermission
- the SpacePermission to remove
-
removeAllPermissionsFromDao
- Overrides:
removeAllPermissionsFromDao
in classDefaultSpacePermissionManager
-
flushCaches
public void flushCaches()- Specified by:
flushCaches
in interfaceSpacePermissionManager
- Overrides:
flushCaches
in classDefaultSpacePermissionManager
-
isLookAheadEnabled
public boolean isLookAheadEnabled() -
setLookAheadEnabled
public void setLookAheadEnabled(boolean lookAheadEnabled) -
hasPermissionNoExemptions
public boolean hasPermissionNoExemptions(String permissionType, @Nullable Space space, @Nullable ConfluenceUser remoteUser) Description copied from interface:SpacePermissionManager
Returns true if the user has the specified permission on the target space. This method does not allow exemptions for super-users likeSpacePermissionManager.hasPermission(String, Space, User)
does.For parameter and return value information, see
SpacePermissionManager.hasPermission(String, Space, User)
.- Specified by:
hasPermissionNoExemptions
in interfaceSpacePermissionManager
- Overrides:
hasPermissionNoExemptions
in classAbstractSpacePermissionManager
-
hasPermissionNoExemptionsExceptViaNestedGroups
public boolean hasPermissionNoExemptionsExceptViaNestedGroups(String permissionType, @Nullable Space space, @Nullable ConfluenceUser remoteUser) Description copied from interface:SpacePermissionManager
Returns true if the user has the specified permission on the target space except if it gets it from some parent of its parent group. This method does not allow exemptions for super-users likeSpacePermissionManager.hasPermission(String, Space, User)
does.For parameter and return value information, see
SpacePermissionManager.hasPermission(String, Space, User)
.- Specified by:
hasPermissionNoExemptionsExceptViaNestedGroups
in interfaceSpacePermissionManager
- Overrides:
hasPermissionNoExemptionsExceptViaNestedGroups
in classAbstractSpacePermissionManager
-
getGroupNamesWithPermission
protected Set<String> getGroupNamesWithPermission(@Nullable Space targetSpace, String permissionType) - Overrides:
getGroupNamesWithPermission
in classDefaultSpacePermissionManager
-