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
Constructors Constructor Description 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, ScopesRequestCacheDelegate scopesRequestCacheDelegate, GlobalSettingsManager settingsManager, GroupResolver groupResolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flushCaches()
protected Set<String>
getGroupNamesWithPermission(@Nullable Space targetSpace, String permissionType)
boolean
hasPermissionNoExemptions(String permissionType, @Nullable Space space, @Nullable com.atlassian.user.User remoteUser)
Returns true if the user has the specified permission on the target space.boolean
isLookAheadEnabled()
boolean
permissionExists(SpacePermission permission)
Looks up permission in the cache instance.protected void
removeAllPermissionsFromDao(Space space)
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, getUsersForPermissionType, getUsersWithPermissions, removeAllPermissions, removeAllPermissions, removeAllPermissionsForGroup, removeAllPermissionsForGroup, removeAllUserPermissions, removeAllUserPermissions, removeGlobalPermissionForUser, removeGlobalPermissionForUser, removePermission, removePermission, savePermission, savePermission
-
Methods inherited from class com.atlassian.confluence.impl.security.AbstractSpacePermissionManager
getDefaultGlobalPermissions, groupHasPermission, hasAllPermissions, hasGlobalPermissionViaGroups, hasPermission, hasPermissionForSpace, isPermittedInReadOnlyAccessMode
-
-
-
-
Constructor Detail
-
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, ScopesRequestCacheDelegate scopesRequestCacheDelegate, GlobalSettingsManager settingsManager, GroupResolver groupResolver)
-
-
Method Detail
-
permissionExists
public boolean permissionExists(SpacePermission permission)
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
protected void savePermissionToDao(SpacePermission spacePermission)
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
protected void removePermissionFromDao(SpacePermission spacePermission)
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
protected void removeAllPermissionsFromDao(Space space)
- 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 com.atlassian.user.User 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
-
getGroupNamesWithPermission
protected Set<String> getGroupNamesWithPermission(@Nullable Space targetSpace, String permissionType)
- Overrides:
getGroupNamesWithPermission
in classDefaultSpacePermissionManager
-
-