Package org.ametys.odf.rights
Class ODFRightHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.odf.rights.ODFRightHelper
- All Implemented Interfaces:
LogEnabled
,Initializable
,Component
,Contextualizable
,Serviceable
- Direct Known Subclasses:
ODFRightHelper
public class ODFRightHelper
extends AbstractLogEnabled
implements Serviceable, Component, Contextualizable, Initializable
Helper for ODF right
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Class representing the permission context for parents computation.class
Expression for ODF role expression -
Field Summary
Modifier and TypeFieldDescriptionprotected AbstractCacheManager
The cache managerprotected Context
The avalon contextprotected ODFHelper
The ODF helperprotected AmetysObjectResolver
Ametys Object Resolverstatic final String
Attribute path for contributor rolestatic final String
Attribute path for manager rolestatic final String
The avalon role -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncomputeOrgUnits
(ProgramItem programItem, ODFRightHelper.PermissionContext permissionCtx) Get the orgunits of a program itemprotected List<ProgramItem>
computeParentProgramItem
(Course course, ODFRightHelper.PermissionContext permissionCtx) Get the parents of a course from a rights perspectiveprotected List<ProgramItem>
computeParentProgramItem
(ProgramItem programItem, ODFRightHelper.PermissionContext permissionCtx) Get the parents of a program item from a rights perspectiveprotected Set<AmetysObject>
computeParents
(Content content, ODFRightHelper.PermissionContext permissionCtx) Compute the parents of a ODF content from a rights perspectivevoid
contextualize
(Context context) Get the id of profile for contributorsgetContributors
(Content content) Get the contributors of aProgramItem
or aOrgUnit
getContributorsQuery
(UserIdentity... users) Build a user query on contributors fieldGet the id of profile for managersgetManagers
(Content content) Get the managers of aProgramItem
or aOrgUnit
getManagersQuery
(UserIdentity... users) Build a user query on managers fieldgetParents
(Content content, ODFRightHelper.PermissionContext permissionCtx) Get the parents of a ODF content from a rights perspectivegetProgramItemsWithUserAsRole
(UserIdentity user, String roleAttributePath) Get the programs items the user is set with a rolegetRolesQuery
(UserIdentity user) Get the query to search for contents for which the user has a rolevoid
void
service
(ServiceManager smanager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The avalon role -
CONTRIBUTORS_FIELD_PATH
Attribute path for contributor role- See Also:
-
MANAGERS_FIELD_PATH
Attribute path for manager role- See Also:
-
_odfHelper
The ODF helper -
_context
The avalon context -
_resolver
Ametys Object Resolver -
_cacheManager
The cache manager
-
-
Constructor Details
-
ODFRightHelper
public ODFRightHelper()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getContributorProfileId
Get the id of profile for contributors- Returns:
- the id of profile for contributors
-
getManagerProfileId
Get the id of profile for managers- Returns:
- the id of profile for managers
-
getContributors
Get the contributors of aProgramItem
or aOrgUnit
- Parameters:
content
- the program item or the orgunit- Returns:
- the contributors or null if not found
-
getContributorsQuery
Build a user query on contributors field- Parameters:
users
- The users to test.- Returns:
- the user query
-
getManagers
Get the managers of aProgramItem
or aOrgUnit
- Parameters:
content
- the program item or the orgunit- Returns:
- the managers or null if not found
-
getManagersQuery
Build a user query on managers field- Parameters:
users
- The users to test.- Returns:
- the user query
-
getRolesQuery
Get the query to search for contents for which the user has a role- Parameters:
user
- the user- Returns:
- the query to filter on user permission
-
getProgramItemsWithUserAsRole
public AmetysObjectIterable<ProgramItem> getProgramItemsWithUserAsRole(UserIdentity user, String roleAttributePath) Get the programs items the user is set with a role- Parameters:
user
- The userroleAttributePath
- the attribute path for role- Returns:
- the program items the user is set with a role
-
getParents
public Set<AmetysObject> getParents(Content content, ODFRightHelper.PermissionContext permissionCtx) Get the parents of a ODF content from a rights perspective- Parameters:
content
- the contentpermissionCtx
- The permission context to compute rights. The permission context allows to restrict parents to parents which are part of a given ancestor. See #withAncestor method ofODFRightHelper.PermissionContext
- Returns:
- the parents of the content for rights computing
-
computeParents
protected Set<AmetysObject> computeParents(Content content, ODFRightHelper.PermissionContext permissionCtx) Compute the parents of a ODF content from a rights perspective- Parameters:
content
- the contentpermissionCtx
- The permission context to compute rights.- Returns:
- the parents of the content for rights computing
-
computeParentProgramItem
protected List<ProgramItem> computeParentProgramItem(ProgramItem programItem, ODFRightHelper.PermissionContext permissionCtx) Get the parents of a program item from a rights perspective- Parameters:
programItem
- the program itempermissionCtx
- The permission context to compute rights.- Returns:
- the parent program items for rights computing
-
computeParentProgramItem
protected List<ProgramItem> computeParentProgramItem(Course course, ODFRightHelper.PermissionContext permissionCtx) Get the parents of a course from a rights perspective- Parameters:
course
- the coursepermissionCtx
- The permission context to compute rights.- Returns:
- the course parents for rights computing
-
computeOrgUnits
protected List<OrgUnit> computeOrgUnits(ProgramItem programItem, ODFRightHelper.PermissionContext permissionCtx) Get the orgunits of a program item- Parameters:
programItem
- the program itempermissionCtx
- The permission context to compute rights.- Returns:
- the orgunits
-