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 ContentPermissionDaostatic final booleanDeprecated, for removal: This API element is subject to removal in a future version.since 8.1. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContentPermission(ContentPermission permission, ContentEntityObject content) Adds a new current content permission to the CEO if it doesn't have it already.voidCopies all content permissions from one content entity to another.voidcopyContentPermissions(AbstractPage from, AbstractPage to) Copies all content permissions from one page to another.voiddestroy()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 ofPageobjects 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.booleanhasContentLevelPermission(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.booleanDoes the given page have children visible to the given user.booleanhasVisibleChildren(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 foundbooleanisPermissionInherited(Page childPage) Does the child page get its permissions from any ancestor?booleanisSharedAccessAllowed(ConfluenceUser user, ContentEntityObject contentEntity) Checks if this draft can be accessed by users other than the creator (shared access)voidonContentPermissionEvent(ContentPermissionEvent contentPermissionEvent) voidremoveAllGroupPermissions(String groupName) Remove all content permission associated with a given group.voidRemove all content permission associated with a given user.voidremoveContentPermission(ContentPermission contentPermission) voidsetAuditingContext(AuditingContext auditingContext) voidsetBackgroundJobService(BackgroundJobService backgroundJobService) voidsetChangeIndexer(ChangeIndexer changeIndexer) Deprecated.since 7.5voidsetContentPermissionDao(ContentPermissionDao contentPermissionDao) voidsetContentPermissions(@NonNull Map<String, Collection<ContentPermission>> requiredPermissionsMap, ContentEntityObject content) Set the Content Permissions on the CEO to be the list ofContentPermissions passed.voidsetContentPermissions(Collection<ContentPermission> requiredPermissions, ContentEntityObject content, String type) Set the Content Permissions on the CEO to be the list ofContentPermissions passed.voidsetContentPermissionSetDao(ContentPermissionSetDao contentPermissionSetDao) voidsetDefaultPermissionOverrideExtensionProvider(DefaultPermissionOverrideExtensionProvider defaultPermissionOverrideExtensionProvider) voidsetEventListenerRegistrar(com.atlassian.event.api.EventListenerRegistrar eventListenerRegistrar) voidsetEventPublisher(com.atlassian.event.api.EventPublisher eventPublisher) voidsetIndexer(ConfluenceIndexer indexer) Deprecated.since 7.5 indexing performed via eventsvoidsetInheritedContentPermissionManager(InheritedContentPermissionManager inheritedContentPermissionManager) voidsetPageDao(PageDaoInternal pageDao) voidsetPageDao(PageDao pageDao) Deprecated, for removal: This API element is subject to removal in a future version.since 8.7voidsetPermissionsTester(ContentPermissionTester permissionsTester) voidsetScopesRequestCacheDelegate(ScopesRequestCacheDelegate scopesRequestCacheDelegate) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
getInheritedContentUserPermissionsin interfaceContentPermissionManager
-
getInheritedContentPermissionSets
public List<ContentPermissionSet> getInheritedContentPermissionSets(ContentEntityObject contentEntityObject) - Specified by:
getInheritedContentPermissionSetsin interfaceContentPermissionManager- Returns:
- a list of
ContentPermissionSets of typeContentPermission.VIEW_PERMISSIONof all ancestors of contentEntityObject
-
getInheritedContentPermissionSets
public List<ContentPermissionSet> getInheritedContentPermissionSets(ContentEntityObject contentEntityObject, boolean includeEditPermissions) Description copied from interface:ContentPermissionManagerGet 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:
getInheritedContentPermissionSetsin 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
ContentPermissionSets. Not null, but can be empty.
-
getContentPermissionSets
Description copied from interface:ContentPermissionManagerGet 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:
getContentPermissionSetsin interfaceContentPermissionManager- Parameters:
ceo- whose permissions will be returned. Not null.type- one ofContentPermission.VIEW_PERMISSIONorContentPermission.EDIT_PERMISSION- Returns:
- a list of
ContentPermissionSets. Not null, but can be empty.
-
hasContentLevelPermission
public boolean hasContentLevelPermission(ConfluenceUser user, String permissionType, ContentEntityObject contentEntityObject) Description copied from interface:ContentPermissionManagerfetches the inherited and explicit content level permissions for this content object and determines whether the user has access.- Specified by:
hasContentLevelPermissionin interfaceContentPermissionManagerpermissionType-ContentPermission.VIEW_PERMISSIONorContentPermission.EDIT_PERMISSION- Returns:
- true if the user has the specified type of permission on the given content
-
removeContentPermission
- Specified by:
removeContentPermissionin interfaceContentPermissionManager
-
removeAllGroupPermissions
Description copied from interface:ContentPermissionManagerRemove all content permission associated with a given group.- Specified by:
removeAllGroupPermissionsin interfaceContentPermissionManager
-
removeAllUserPermissions
Description copied from interface:ContentPermissionManagerRemove all content permission associated with a given user.- Specified by:
removeAllUserPermissionsin interfaceContentPermissionManager
-
addContentPermission
Adds a new current content permission to the CEO if it doesn't have it already.- Specified by:
addContentPermissionin interfaceContentPermissionManager- Throws:
IllegalArgumentException- ifcontentobject 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:ContentPermissionManagerSet the Content Permissions on the CEO to be the list ofContentPermissions 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:
setContentPermissionsin interfaceContentPermissionManager- Parameters:
requiredPermissionsMap- - map ofContentPermissions for each type
-
setContentPermissions
public void setContentPermissions(Collection<ContentPermission> requiredPermissions, ContentEntityObject content, String type) Description copied from interface:ContentPermissionManagerSet the Content Permissions on the CEO to be the list ofContentPermissions passed. Passing an empty list removes all permissions. Passing a list containing just the existing permissions does nothing.- Specified by:
setContentPermissionsin interfaceContentPermissionManager- Parameters:
requiredPermissions- set ofContentPermissions
-
getPermittedChildren
Returns a list ofPageobjects 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:
getPermittedChildrenin interfaceContentPermissionManager
-
getPermittedChildrenIgnoreInheritedPermissions
Description copied from interface:ContentPermissionManagerGets 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:
getPermittedChildrenIgnoreInheritedPermissionsin interfaceContentPermissionManager
-
hasPermittedChildrenIgnoreInheritedPermissions
Description copied from interface:ContentPermissionManagerDoes 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:
hasPermittedChildrenIgnoreInheritedPermissionsin interfaceContentPermissionManager
-
getViewContentPermissions
Deprecated.since 5.8. usegetContentPermissionSets(ContentEntityObject, String)passing permission typeContentPermission.VIEW_PERMISSIONGet view permissions on this page and its ancestors.- Specified by:
getViewContentPermissionsin 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:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
Exception
-
getAttachmentManager
-
isPermissionInherited
Description copied from interface:ContentPermissionManagerDoes the child page get its permissions from any ancestor?- Specified by:
isPermissionInheritedin interfaceContentPermissionManager- Returns:
- boolean True if the child page does not have a view permission set, and an ancestor does.
-
copyContentPermissions
Description copied from interface:ContentPermissionManagerCopies all content permissions from one page to another.- Specified by:
copyContentPermissionsin interfaceContentPermissionManager
-
copyContentPermissions
Description copied from interface:ContentPermissionManagerCopies all content permissions from one content entity to another.- Specified by:
copyContentPermissionsin interfaceContentPermissionManager
-
getPermissionSets
Description copied from interface:ContentPermissionManagerRetrieves 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:
getPermissionSetsin 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:ContentPermissionManagerInternalCheck 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:
hasContentLevelPermissionin interfaceContentPermissionManagerInternalpermissionType- 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:
getPermittedPagesIgnoreInheritedPermissionsin 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:
hasVisibleChildrenin 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:ContentPermissionManagerInternalReturn inherited permission for particular content. This will include permission from current content and permission from ancestor- Specified by:
getContentPermissionSetsIncludingInheritedin interfaceContentPermissionManagerInternal
-
getRelevantViewRestrictionsForContent
public Map<ContentId,PageResponse<ContentPermissionSet>> getRelevantViewRestrictionsForContent(LimitedRequest pageRequest, Map<Long, Long> contentIdToParentIdMap) Description copied from interface:ContentPermissionManagerInternalReturn RelevantViewRestrictions per content where it will contain the direct and inherited permission set required to view the content- Specified by:
getRelevantViewRestrictionsForContentin interfaceContentPermissionManagerInternalcontentIdToParentIdMap- map from contentId to parent contentId- Returns:
- a map between content Id and it's RelevantViewRestrictions
-
setBackgroundJobService
-
setPermissionsTester
-
setDefaultPermissionOverrideExtensionProvider
public void setDefaultPermissionOverrideExtensionProvider(DefaultPermissionOverrideExtensionProvider defaultPermissionOverrideExtensionProvider)
-