Class ContentRestrictedModelItemHelper
java.lang.Object
org.ametys.cms.model.restrictions.ContentRestrictedModelItemHelper
- All Implemented Interfaces:
Component
,Serviceable
Helper for definitions with restrictions on contents
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
TODO NEWATTRIBUTEAPI_CONTENT: make this enum private when caller of_doFirstRestrictionsChecks(Content, Restrictions, boolean)
in DefaultContentType are removed -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription_doFirstRestrictionsChecks
(Content content, Restrictions restrictions, boolean forReading) Does the first checks on restrictions TODO NEWATTRIBUTEAPI_CONTENT: make this method private when caller in DefaultContentType are removed_parseRestrictions
(Configuration configuration) Parses the attribute definition's restrictions.boolean
canRead
(Content content, ModelItem item, Restrictions restrictions) Determine whether a model item can be read at this time.boolean
canWrite
(Content content, ModelItem item, Restrictions restrictions) Determine whether a model item can be written at this time.void
populateRestrictions
(Configuration attributeConfiguration, Restrictions restrictions) Parses the attribute definition's restrictions.void
service
(ServiceManager manager)
-
Field Details
-
ROLE
The Avalon role name
-
-
Constructor Details
-
ContentRestrictedModelItemHelper
public ContentRestrictedModelItemHelper()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
canRead
public boolean canRead(Content content, ModelItem item, Restrictions restrictions) throws AmetysRepositoryException Determine whether a model item can be read at this time.- Parameters:
item
- the model item on which check the restrictionscontent
- The content where item is to be written on. Can be null, on content creation.restrictions
- the restrictions to check- Returns:
true
if the current user is allowed to write the model item of this content.- Throws:
AmetysRepositoryException
- if an error occurs while accessing the content workflow.
-
canWrite
public boolean canWrite(Content content, ModelItem item, Restrictions restrictions) throws AmetysRepositoryException Determine whether a model item can be written at this time.- Parameters:
item
- the model item on which check the restrictionscontent
- The content where item is to be written on. Can be null, on content creation.restrictions
- the restrictions to check- Returns:
true
if the current user is allowed to write the model item of this content.- Throws:
AmetysRepositoryException
- if an error occurs while accessing the content workflow.
-
_doFirstRestrictionsChecks
public ContentRestrictedModelItemHelper.FirstRestrictionsChecksState _doFirstRestrictionsChecks(Content content, Restrictions restrictions, boolean forReading) throws AmetysRepositoryException Does the first checks on restrictions TODO NEWATTRIBUTEAPI_CONTENT: make this method private when caller in DefaultContentType are removed- Parameters:
content
- The content where item is to be read / written on. Can be null, on content creation.restrictions
- The restrictions to applyforReading
-true
for reading checks,false
for writing checks.- Returns:
- the state of the first checks
- Throws:
AmetysRepositoryException
- if an error occurs while accessing the content workflow.
-
_parseRestrictions
Parses the attribute definition's restrictions.- Parameters:
configuration
- the configuration of the element that have content restrictions- Returns:
- the parsed restrictions.
- Throws:
ConfigurationException
- if the configuration is not valid.
-
populateRestrictions
public void populateRestrictions(Configuration attributeConfiguration, Restrictions restrictions) throws ConfigurationException Parses the attribute definition's restrictions. TODO NEWATTRIBUTEAPI_CONTENT: This method is public to be used in MetadataAndRepeaterDefinitionParser fromDefaultContentType
. Make this method private when it is deleted- Parameters:
attributeConfiguration
- the attribute configuration to use.restrictions
- the restrictions.- Throws:
ConfigurationException
- if the configuration is not valid.
-