Class ContentRestrictedModelItemHelper
- java.lang.Object
-
- org.ametys.cms.model.restrictions.ContentRestrictedModelItemHelper
-
- All Implemented Interfaces:
Component
,Serviceable
public class ContentRestrictedModelItemHelper extends Object implements Component, Serviceable
Helper for definitions with restrictions on contents
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ContentRestrictedModelItemHelper.FirstRestrictionsChecksState
TODO NEWATTRIBUTEAPI_CONTENT: make this enum private when caller of_doFirstRestrictionsChecks(Content, Restrictions, boolean)
in DefaultContentType are removed
-
Constructor Summary
Constructors Constructor Description ContentRestrictedModelItemHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContentRestrictedModelItemHelper.FirstRestrictionsChecksState
_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 removedRestrictions
_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)
-
-
-
Constructor Detail
-
ContentRestrictedModelItemHelper
public ContentRestrictedModelItemHelper()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- 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
public Restrictions _parseRestrictions(Configuration configuration) throws ConfigurationException
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.
-
-