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
Nested ClassesModifier and TypeClassDescriptionstatic classClass representing the permission context for parents computation.classExpression for ODF role expression -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AbstractCacheManagerThe cache managerprotected ContextThe avalon contextprotected ODFHelperThe ODF helperprotected AmetysObjectResolverAmetys Object Resolverstatic final StringAttribute path for contributor rolestatic final StringAttribute path for manager rolestatic final StringThe avalon role -
Constructor Summary
Constructors -
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 perspectivevoidcontextualize(Context context) Get the id of profile for contributorsgetContributors(Content content) Get the contributors of aProgramItemor aOrgUnitgetContributorsQuery(UserIdentity... users) Build a user query on contributors fieldGet the id of profile for managersgetManagers(Content content) Get the managers of aProgramItemor aOrgUnitgetManagersQuery(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 rolevoidvoidservice(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:
contextualizein interfaceContextualizable- Throws:
ContextException
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
- Specified by:
initializein 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 aProgramItemor 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 aProgramItemor 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
-