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:
SharedOnlyRestriction
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 CurrentUserProviderCurrent user provider.protected RightManagerThe rights manager.protected WorkflowProviderThe workflow providerRead workflow step ids. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean_hasRights(Content content, RestrictedModelItem modelItem, 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.voidconfigure(Configuration configuration) voidservice(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 -
_writeRightIds
Read workflow step ids.
-
-
Constructor Details
-
DefaultRestriction
public DefaultRestriction()
-
-
Method Details
-
configure
- Specified by:
configurein interfaceConfigurable- Throws:
ConfigurationException
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
canRead
Description copied from interface:RestrictionDetermine whether a model item can be read at this time.- Specified by:
canReadin 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:RestrictionDetermine whether a model item can be written at this time.- Specified by:
canWritein 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
protected boolean _hasRights(Content content, RestrictedModelItem modelItem, Set<String> rightLimitations) Check if current user has the given rights.- Parameters:
content- the content.modelItem- the model item on which check the restrictionsrightLimitations- the right limitations.- Returns:
trueif user has at least one right,falseotherwise.
-
_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:
trueif it is on at least one step,falseotherwise.- Throws:
AmetysRepositoryException- if failed to get content's workflow current step
-