public class ContentRestrictedModelItemHelper extends Object implements Component, Serviceable
Modifier and Type | Class and Description |
---|---|
static class |
ContentRestrictedModelItemHelper.FirstRestrictionsChecksState
TODO NEWATTRIBUTEAPI_CONTENT: make this enum private when caller of
_doFirstRestrictionsChecks(Content, Restrictions, boolean) in DefaultContentType are removed |
Modifier and Type | Field and Description |
---|---|
private CurrentUserProvider |
_currentUserProvider
Current user provider.
|
private RightManager |
_rightManager
The rights manager.
|
private WorkflowProvider |
_workflowProvider
The workflow provider
|
static String |
ROLE
The Avalon role name
|
Constructor and Description |
---|
ContentRestrictedModelItemHelper() |
Modifier and Type | Method and 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 removed
|
private boolean |
_hasRights(Content content,
Set<String> rightLimitations)
Check if current user has the given rights.
|
private boolean |
_isInWorkflowStep(WorkflowAwareContent content,
Set<Integer> workflowLimitations)
Check if the workflow of the content is in a given current step.
|
private boolean |
_parseAccessType(Configuration configuration)
Parses type attribute from a configuration.
|
Restrictions |
_parseRestrictions(Configuration configuration)
Parses the attribute definition's restrictions.
|
private void |
_populateNegativeRestrictions(Configuration restrictionsConfig,
Restrictions restrictions)
Populates the negative restrictions.
|
private void |
_populateRightRestrictions(Configuration restrictionsConfig,
Restrictions restrictions)
Populates the rights restrictions.
|
private void |
_populateWorkflowRestrictions(Configuration restrictionsConfig,
Restrictions restrictions)
Populates the workflows 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) |
private RightManager _rightManager
private CurrentUserProvider _currentUserProvider
private WorkflowProvider _workflowProvider
public ContentRestrictedModelItemHelper()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public boolean canRead(Content content, ModelItem item, Restrictions restrictions) throws AmetysRepositoryException
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 checktrue
if the current user is allowed to write the model item of this content.AmetysRepositoryException
- if an error occurs while accessing the content.public boolean canWrite(Content content, ModelItem item, Restrictions restrictions) throws AmetysRepositoryException
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 checktrue
if the current user is allowed to write the model item of this content.AmetysRepositoryException
- if an error occurs while accessing the content.public ContentRestrictedModelItemHelper.FirstRestrictionsChecksState _doFirstRestrictionsChecks(Content content, Restrictions restrictions, boolean forReading)
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 writting checks.private boolean _hasRights(Content content, Set<String> rightLimitations)
rightLimitations
- the right limitations.content
- the content.true
if it is on at least one step,
false
otherwise.private boolean _isInWorkflowStep(WorkflowAwareContent content, Set<Integer> workflowLimitations) throws AmetysRepositoryException
workflowLimitations
- the workflow limitations.content
- the content.true
if it is on at least one step,
false
otherwise.AmetysRepositoryException
- if an error occurs.public Restrictions _parseRestrictions(Configuration configuration) throws ConfigurationException
configuration
- the configuration of the element that have content restrictionsConfigurationException
- if the configuration is not valid.public void populateRestrictions(Configuration attributeConfiguration, Restrictions restrictions) throws ConfigurationException
DefaultContentType
. Make this method private when it is deletedattributeConfiguration
- the attribute configuration to use.restrictions
- the restrictions.ConfigurationException
- if the configuration is not valid.private void _populateNegativeRestrictions(Configuration restrictionsConfig, Restrictions restrictions) throws ConfigurationException
restrictionsConfig
- the restrictions configuration to use.restrictions
- the restrictions.ConfigurationException
- if the configuration is not valid.private void _populateRightRestrictions(Configuration restrictionsConfig, Restrictions restrictions) throws ConfigurationException
restrictionsConfig
- the restrictions configuration to use.restrictions
- the restrictions.ConfigurationException
- if the configuration is not valid.private void _populateWorkflowRestrictions(Configuration restrictionsConfig, Restrictions restrictions) throws ConfigurationException
restrictionsConfig
- the restrictions configuration to use.restrictions
- the restrictions.ConfigurationException
- if the configuration is not valid.private boolean _parseAccessType(Configuration configuration) throws ConfigurationException
configuration
- the configuration.true
for read
type,
false
for write
type.ConfigurationException
- if the configuration is not valid.