Package com.atlassian.confluence.core
Class DefaultContentPermissionManager
java.lang.Object
com.atlassian.confluence.core.DefaultContentPermissionManager
- All Implemented Interfaces:
ContentPermissionManager
,ContentPermissionManagerInternal
,org.springframework.beans.factory.DisposableBean
public class DefaultContentPermissionManager
extends Object
implements ContentPermissionManagerInternal, org.springframework.beans.factory.DisposableBean
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ContentPermissionDao
static final boolean
Deprecated, for removal: This API element is subject to removal in a future version.since 8.1. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addContentPermission
(ContentPermission permission, ContentEntityObject content) Adds a new current content permission to the CEO if it doesn't have it already.void
Copies all content permissions from one content entity to another.void
copyContentPermissions
(AbstractPage from, AbstractPage to) Copies all content permissions from one page to another.void
destroy()
getContentPermissionSets
(ContentEntityObject ceo, String type) Get the ContentPermissionSets that affect this ceo, both inherited and directly.getContentPermissionSetsIncludingInherited
(Collection<Long> contentIds) Return inherited permission for particular content.getInheritedContentPermissionSets
(ContentEntityObject contentEntityObject) getInheritedContentPermissionSets
(ContentEntityObject contentEntityObject, boolean includeEditPermissions) Get the inherited ContentPermissionSets that affect this ceo.getInheritedContentUserPermissions
(ContentEntityObject contentEntityObject) Filters the inherited content permission sets of a page for a list of inherited user permissions (of typeContentPermission.VIEW_PERMISSION
)getPermissionSets
(ConfluenceUser user, Space space) Retrieves the configured permissions regarding whether the specified user can view the pages inside a space.getPermittedChildren
(Page page, ConfluenceUser user) Returns a list ofPage
objects that are direct children of the passed in page.Gets the list of child pages under the given page that are visible to the given user.getPermittedPagesIgnoreInheritedPermissions
(List<Page> contentList, ConfluenceUser user, String permission) Check permissions for a collection of objects without checking permissions of ancestors and spaces.getRelevantViewRestrictionsForContent
(LimitedRequest pageRequest, Map<Long, Long> contentIdToParentIdMap) Return RelevantViewRestrictions per content where it will contain the direct and inherited permission set required to view the contentDeprecated.since 5.8.boolean
hasContentLevelPermission
(ConfluenceUser user, String permissionType, ContentEntityObject contentEntityObject) fetches the inherited and explicit content level permissions for this content object and determines whether the user has access.hasContentLevelPermission
(ConfluenceUser user, String permissionType, Collection<Long> contentIds) Check permission for a collection of content at once.boolean
Does the given page have children visible to the given user.boolean
hasVisibleChildren
(Page page, ConfluenceUser user) Returns true if at least one child is visible This method does not check all children, it stops working when the first visible children is foundboolean
isPermissionInherited
(Page childPage) Does the child page get its permissions from any ancestor?boolean
isSharedAccessAllowed
(ConfluenceUser user, ContentEntityObject contentEntity) Checks if this draft can be accessed by users other than the creator (shared access)void
onContentPermissionEvent
(ContentPermissionEvent contentPermissionEvent) void
removeAllGroupPermissions
(String groupName) Remove all content permission associated with a given group.void
Remove all content permission associated with a given user.void
removeContentPermission
(ContentPermission contentPermission) void
setAuditingContext
(AuditingContext auditingContext) void
setBackgroundJobService
(BackgroundJobService backgroundJobService) void
setChangeIndexer
(ChangeIndexer changeIndexer) Deprecated.since 7.5void
setContentPermissionDao
(ContentPermissionDao contentPermissionDao) void
setContentPermissions
(@NonNull Map<String, Collection<ContentPermission>> requiredPermissionsMap, ContentEntityObject content) Set the Content Permissions on the CEO to be the list ofContentPermission
s passed.void
setContentPermissions
(Collection<ContentPermission> requiredPermissions, ContentEntityObject content, String type) Set the Content Permissions on the CEO to be the list ofContentPermission
s passed.void
setContentPermissionSetDao
(ContentPermissionSetDao contentPermissionSetDao) void
setDefaultPermissionOverrideExtensionProvider
(DefaultPermissionOverrideExtensionProvider defaultPermissionOverrideExtensionProvider) void
setEventListenerRegistrar
(com.atlassian.event.api.EventListenerRegistrar eventListenerRegistrar) void
setEventPublisher
(com.atlassian.event.api.EventPublisher eventPublisher) void
setIndexer
(ConfluenceIndexer indexer) Deprecated.since 7.5 indexing performed via eventsvoid
setInheritedContentPermissionManager
(InheritedContentPermissionManager inheritedContentPermissionManager) void
setPageDao
(PageDaoInternal pageDao) void
setPageDao
(PageDao pageDao) Deprecated, for removal: This API element is subject to removal in a future version.since 8.7void
setPermissionsTester
(ContentPermissionTester permissionsTester) void
setScopesRequestCacheDelegate
(ScopesRequestCacheDelegate scopesRequestCacheDelegate) 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.core.ContentPermissionManager
getPermissionSets, getPermittedChildren, getPermittedChildrenIgnoreInheritedPermissions, hasContentLevelPermission, hasPermittedChildrenIgnoreInheritedPermissions
-
Field Details
-
DISABLE_EFFICIENT_CONTENT_PERMISSIONS_CHANGE
@Deprecated(since="8.1", forRemoval=true) public static final boolean DISABLE_EFFICIENT_CONTENT_PERMISSIONS_CHANGEDeprecated, for removal: This API element is subject to removal in a future version.since 8.1. No replacement -
contentPermissionDao
-
-
Constructor Details
-
DefaultContentPermissionManager
public DefaultContentPermissionManager()
-
-
Method Details
-
onContentPermissionEvent
-
getInheritedContentUserPermissions
public List<ContentPermission> getInheritedContentUserPermissions(ContentEntityObject contentEntityObject) Filters the inherited content permission sets of a page for a list of inherited user permissions (of typeContentPermission.VIEW_PERMISSION
)- Specified by:
getInheritedContentUserPermissions
in interfaceContentPermissionManager
-
getInheritedContentPermissionSets
public List<ContentPermissionSet> getInheritedContentPermissionSets(ContentEntityObject contentEntityObject) - Specified by:
getInheritedContentPermissionSets
in interfaceContentPermissionManager
- Returns:
- a list of
ContentPermissionSet
s of typeContentPermission.VIEW_PERMISSION
of all ancestors of contentEntityObject
-
getInheritedContentPermissionSets
public List<ContentPermissionSet> getInheritedContentPermissionSets(ContentEntityObject contentEntityObject, boolean includeEditPermissions) Description copied from interface:ContentPermissionManager
Get the inherited ContentPermissionSets that affect this ceo. Note that EDIT Permissions are not currently inherited, however edit permissions are treated as view permissions when considering inheritance, unless the boolean 'includeEditPermissions' is set to false.- Specified by:
getInheritedContentPermissionSets
in interfaceContentPermissionManager
- Parameters:
contentEntityObject
- whose permissions will be returned. Not null.includeEditPermissions
- which specifies whether or not edit permissions should be additionally treated as view permissions.- Returns:
- a list of
ContentPermissionSet
s. Not null, but can be empty.
-
getContentPermissionSets
Description copied from interface:ContentPermissionManager
Get the ContentPermissionSets that affect this ceo, both inherited and directly. Note that EDIT Permissions are not currently inherited, so calling this method with EDIT will return only the direct ContentPermissionSet.- Specified by:
getContentPermissionSets
in interfaceContentPermissionManager
- Parameters:
ceo
- whose permissions will be returned. Not null.type
- one ofContentPermission.VIEW_PERMISSION
orContentPermission.EDIT_PERMISSION
- Returns:
- a list of
ContentPermissionSet
s. Not null, but can be empty.
-
hasContentLevelPermission
public boolean hasContentLevelPermission(ConfluenceUser user, String permissionType, ContentEntityObject contentEntityObject) Description copied from interface:ContentPermissionManager
fetches the inherited and explicit content level permissions for this content object and determines whether the user has access.- Specified by:
hasContentLevelPermission
in interfaceContentPermissionManager
permissionType
-ContentPermission.VIEW_PERMISSION
orContentPermission.EDIT_PERMISSION
- Returns:
- true if the user has the specified type of permission on the given content
-
removeContentPermission
- Specified by:
removeContentPermission
in interfaceContentPermissionManager
-
removeAllGroupPermissions
Description copied from interface:ContentPermissionManager
Remove all content permission associated with a given group.- Specified by:
removeAllGroupPermissions
in interfaceContentPermissionManager
-
removeAllUserPermissions
Description copied from interface:ContentPermissionManager
Remove all content permission associated with a given user.- Specified by:
removeAllUserPermissions
in interfaceContentPermissionManager
-
addContentPermission
Adds a new current content permission to the CEO if it doesn't have it already.- Specified by:
addContentPermission
in interfaceContentPermissionManager
- Throws:
IllegalArgumentException
- ifcontent
object does not correspond to the latest version of the content. Permissions can only be added to the latest version of a ContentEntityObject.
-
setContentPermissions
public void setContentPermissions(@NonNull Map<String, Collection<ContentPermission>> requiredPermissionsMap, ContentEntityObject content) Description copied from interface:ContentPermissionManager
Set the Content Permissions on the CEO to be the list ofContentPermission
s passed. Passing an empty list removes all permissions. Passing a list containing just the existing permissions does nothing. It is recommended to use this method for setting different types of content permissions in a batch, because it performs more smart and performant caching updates thanContentPermissionManager.setContentPermissions(java.util.Collection, ContentEntityObject, String)
does- Specified by:
setContentPermissions
in interfaceContentPermissionManager
- Parameters:
requiredPermissionsMap
- - map ofContentPermission
s for each type
-
setContentPermissions
public void setContentPermissions(Collection<ContentPermission> requiredPermissions, ContentEntityObject content, String type) Description copied from interface:ContentPermissionManager
Set the Content Permissions on the CEO to be the list ofContentPermission
s passed. Passing an empty list removes all permissions. Passing a list containing just the existing permissions does nothing.- Specified by:
setContentPermissions
in interfaceContentPermissionManager
- Parameters:
requiredPermissions
- set ofContentPermission
s
-
getPermittedChildren
Returns a list ofPage
objects that are direct children of the passed in page. This method will only return the children the passed in user has permission to view.- Specified by:
getPermittedChildren
in interfaceContentPermissionManager
-
getPermittedChildrenIgnoreInheritedPermissions
Description copied from interface:ContentPermissionManager
Gets the list of child pages under the given page that are visible to the given user. This method assumes that the given page is already visible to the given user and does not check the inherited permissions.- Specified by:
getPermittedChildrenIgnoreInheritedPermissions
in interfaceContentPermissionManager
-
hasPermittedChildrenIgnoreInheritedPermissions
Description copied from interface:ContentPermissionManager
Does the given page have children visible to the given user. This method assumes that the given page is already visible to the given user and does not check the inherited permissions.- Specified by:
hasPermittedChildrenIgnoreInheritedPermissions
in interfaceContentPermissionManager
-
getViewContentPermissions
Deprecated.since 5.8. usegetContentPermissionSets(ContentEntityObject, String)
passing permission typeContentPermission.VIEW_PERMISSION
Get view permissions on this page and its ancestors.- Specified by:
getViewContentPermissions
in interfaceContentPermissionManager
- Returns:
- a list of ContentPermission instances
-
setAuditingContext
-
setContentPermissionDao
-
setPageDao
Deprecated, for removal: This API element is subject to removal in a future version.since 8.7 -
setPageDao
- Since:
- 8.7
-
setContentPermissionSetDao
-
setIndexer
Deprecated.since 7.5 indexing performed via events -
setEventPublisher
public void setEventPublisher(com.atlassian.event.api.EventPublisher eventPublisher) -
setInheritedContentPermissionManager
public void setInheritedContentPermissionManager(InheritedContentPermissionManager inheritedContentPermissionManager) -
setScopesRequestCacheDelegate
-
setChangeIndexer
Deprecated.since 7.5 -
setEventListenerRegistrar
public void setEventListenerRegistrar(com.atlassian.event.api.EventListenerRegistrar eventListenerRegistrar) -
destroy
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
-
getAttachmentManager
-
isPermissionInherited
Description copied from interface:ContentPermissionManager
Does the child page get its permissions from any ancestor?- Specified by:
isPermissionInherited
in interfaceContentPermissionManager
- Returns:
- boolean True if the child page does not have a view permission set, and an ancestor does.
-
copyContentPermissions
Description copied from interface:ContentPermissionManager
Copies all content permissions from one page to another.- Specified by:
copyContentPermissions
in interfaceContentPermissionManager
-
copyContentPermissions
Description copied from interface:ContentPermissionManager
Copies all content permissions from one content entity to another.- Specified by:
copyContentPermissions
in interfaceContentPermissionManager
-
getPermissionSets
Description copied from interface:ContentPermissionManager
Retrieves the configured permissions regarding whether the specified user can view the pages inside a space. If a page is not configured in the tables - CONTENT_PERM_SET and CONTENT_PERM, then the permission of that page will not be included here. Note: the permission returned here does not consider the inherited permission from parent page.- Specified by:
getPermissionSets
in interfaceContentPermissionManager
- Parameters:
user
- - confluence user to be checkedspace
- - confluence space- Returns:
- a Map where the key is the page id and the value indicates the view permission.
-
hasContentLevelPermission
public Map<Long,ValidationResult> hasContentLevelPermission(ConfluenceUser user, String permissionType, Collection<Long> contentIds) Description copied from interface:ContentPermissionManagerInternal
Check permission for a collection of content at once.- if contentIds belong to same page hierarchy then it will base on the permission set of that hierarchy to check permisssion for all hierarchy => Best performance
- if contentIds does not belong to same page hierarchy then it will load page list (at once) and call permission check for each page => better performance
- Specified by:
hasContentLevelPermission
in interfaceContentPermissionManagerInternal
permissionType
- string needs to be one of the permission constants in ContentPermission- Returns:
- a map of validation result
-
getPermittedPagesIgnoreInheritedPermissions
public List<Page> getPermittedPagesIgnoreInheritedPermissions(List<Page> contentList, ConfluenceUser user, String permission) Check permissions for a collection of objects without checking permissions of ancestors and spaces.- Specified by:
getPermittedPagesIgnoreInheritedPermissions
in interfaceContentPermissionManagerInternal
- Returns:
- a list of permitted objects
-
hasVisibleChildren
Returns true if at least one child is visible This method does not check all children, it stops working when the first visible children is found- Specified by:
hasVisibleChildren
in interfaceContentPermissionManagerInternal
- Returns:
- false if 0 children visible, true of at least one child is visible
-
getContentPermissionSetsIncludingInherited
public Map<Long,InheritedContentPermissionSet> getContentPermissionSetsIncludingInherited(Collection<Long> contentIds) Description copied from interface:ContentPermissionManagerInternal
Return inherited permission for particular content. This will include permission from current content and permission from ancestor- Specified by:
getContentPermissionSetsIncludingInherited
in interfaceContentPermissionManagerInternal
-
getRelevantViewRestrictionsForContent
public Map<ContentId,PageResponse<ContentPermissionSet>> getRelevantViewRestrictionsForContent(LimitedRequest pageRequest, Map<Long, Long> contentIdToParentIdMap) Description copied from interface:ContentPermissionManagerInternal
Return RelevantViewRestrictions per content where it will contain the direct and inherited permission set required to view the content- Specified by:
getRelevantViewRestrictionsForContent
in interfaceContentPermissionManagerInternal
contentIdToParentIdMap
- map from contentId to parent contentId- Returns:
- a map between content Id and it's RelevantViewRestrictions
-
setBackgroundJobService
-
setPermissionsTester
-
setDefaultPermissionOverrideExtensionProvider
public void setDefaultPermissionOverrideExtensionProvider(DefaultPermissionOverrideExtensionProvider defaultPermissionOverrideExtensionProvider)
-