Class DefaultRestriction
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.model.restrictions.DefaultRestriction
- All Implemented Interfaces:
Restriction
,LogEnabled
,Component
,Configurable
,Serviceable
- Direct Known Subclasses:
RepeaterWithEducationalPathRestriction
public class DefaultRestriction
extends AbstractLogEnabled
implements Restriction, Configurable, Serviceable, Component
Default implementation for restrictions on content attributes.
Restrictions can be on read or write direction, based on rights and/or workflow step ids, according its XML configuration:
Restrictions can be on read or write direction, based on rights and/or workflow step ids, according its XML configuration:
<cannot read-write-direction="read|write"/> <right read-write-direction="read|write" id="RightId"/> <workflow read-write-direction="read|write" step="3"/>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ametys.cms.model.restrictions.Restriction
Restriction.RestrictionResult
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CurrentUserProvider
Current user provider.protected RightManager
The rights manager.protected WorkflowProvider
The workflow provider -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
_hasRights
(Content content, Set<String> rightLimitations) Check if current user has the given rights.protected boolean
_isInWorkflowStep
(WorkflowAwareContent content, Set<Integer> workflowLimitations) Check if content is on given workflow stepscanRead
(Content content, RestrictedModelItem modelItem) Determine whether a model item can be read at this time.canWrite
(Content content, RestrictedModelItem modelItem) Determine whether a model item can be written at this time.void
configure
(Configuration configuration) void
service
(ServiceManager manager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
_rightManager
The rights manager. -
_currentUserProvider
Current user provider. -
_workflowProvider
The workflow provider
-
-
Constructor Details
-
DefaultRestriction
public DefaultRestriction()
-
-
Method Details
-
configure
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
canRead
Description copied from interface:Restriction
Determine whether a model item can be read at this time.- Specified by:
canRead
in interfaceRestriction
- Parameters:
content
- The content where item is to be written on. Can be null, on content creation.modelItem
- the model item on which check the restrictions- Returns:
- The restriction result
-
canWrite
Description copied from interface:Restriction
Determine whether a model item can be written at this time.- Specified by:
canWrite
in interfaceRestriction
- Parameters:
content
- The content where item is to be written on. Can be null, on content creation.modelItem
- the model item on which check the restrictions- Returns:
- The restriction result
-
_hasRights
Check if current user has the given rights.- Parameters:
content
- the content.rightLimitations
- the right limitations.- Returns:
true
if user has at least one right,false
otherwise.
-
_isInWorkflowStep
protected boolean _isInWorkflowStep(WorkflowAwareContent content, Set<Integer> workflowLimitations) throws AmetysRepositoryException Check if content is on given workflow steps- Parameters:
content
- the content.workflowLimitations
- the workflow step ids- Returns:
true
if it is on at least one step,false
otherwise.- Throws:
AmetysRepositoryException
- if failed to get content's workflow current step
-