Class CheckRightsCondition
- java.lang.Object
-
- org.ametys.plugins.workflow.AbstractWorkflowComponent
-
- org.ametys.plugins.workflow.component.CheckRightsCondition
-
- All Implemented Interfaces:
com.opensymphony.workflow.Condition,Disposable,Initializable,LogEnabled,Serviceable
- Direct Known Subclasses:
ContentCheckRightsCondition,CreateContentRightCondition,ExplorerNodeCheckRightsCondition
public class CheckRightsCondition extends AbstractWorkflowComponent implements com.opensymphony.workflow.Condition, Initializable, Disposable
Condition for checking rights of an user for the current action.The following configuration can be used for checking rights:
<condition type="avalon"> <arg name="role">org.ametys.plugins.workflow.component.CheckRightsCondition</arg> <arg name="right">Right_Edition</arg> [ <arg name="context">/cms</arg>] </condition>
-
-
Field Summary
Fields Modifier and Type Field Description protected static String__CONTEXT_KEYKey for getting the context to use.protected static String__DEFAULT_CONTEXTDefault context to use.protected static String__RIGHT_KEYKey for getting the right to check.protected RightManager_rightManagerRights manager available to subclasses.static StringFORCEBoolean to force the CheckRightsCondition to returns ok.-
Fields inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
_logger, _manager, CONTEXT_PARAMETERS_KEY, FAIL_CONDITIONS_KEY, RESULT_MAP_KEY, WORKFLOW_ERRORS_KEY, WORKFLOW_WARNS_KEY
-
-
Constructor Summary
Constructors Constructor Description CheckRightsCondition()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean_checkRights(Map transientVars, Map args, UserIdentity user, String rightNeeded)Check if the current user has the needed right.protected Object_computeContext(Map transientVars, Map args, UserIdentity user, String right)Compute the context to use.
Default implementation uses standard context"/cms".protected booleancheckMultipleAndRights(UserIdentity user, String[] rights, Object context)Check that a user has all the given rights on a context (AND condition).protected booleancheckMultipleOrRights(UserIdentity user, String[] rights, Object context)Check that a user has at least one of the given rights on a context (OR condition).voiddispose()protected booleanhasRight(UserIdentity user, String right, Object context)Test if a user has a right on a context.voidinitialize()booleanpassesCondition(Map transientVars, Map args, com.opensymphony.module.propertyset.PropertySet ps)-
Methods inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
addWorkflowError, addWorkflowWarning, enableLogging, getConditionFailures, getContextParameters, getResultsMap, getUser, service
-
-
-
-
Field Detail
-
__DEFAULT_CONTEXT
protected static final String __DEFAULT_CONTEXT
Default context to use.- See Also:
- Constant Field Values
-
__RIGHT_KEY
protected static final String __RIGHT_KEY
Key for getting the right to check.- See Also:
- Constant Field Values
-
__CONTEXT_KEY
protected static final String __CONTEXT_KEY
Key for getting the context to use.- See Also:
- Constant Field Values
-
_rightManager
protected RightManager _rightManager
Rights manager available to subclasses.
-
-
Constructor Detail
-
CheckRightsCondition
public CheckRightsCondition()
-
-
Method Detail
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
passesCondition
public boolean passesCondition(Map transientVars, Map args, com.opensymphony.module.propertyset.PropertySet ps) throws com.opensymphony.workflow.WorkflowException
- Specified by:
passesConditionin interfacecom.opensymphony.workflow.Condition- Throws:
com.opensymphony.workflow.WorkflowException
-
_checkRights
protected boolean _checkRights(Map transientVars, Map args, UserIdentity user, String rightNeeded) throws com.opensymphony.workflow.WorkflowException
Check if the current user has the needed right.- Parameters:
transientVars- variables that will not be persisted.args- the properties for this function invocation.user- the current user.rightNeeded- the needed right.- Returns:
trueif the user has the right,falseotherwise.- Throws:
com.opensymphony.workflow.WorkflowException- if an error occurs.
-
checkMultipleAndRights
protected boolean checkMultipleAndRights(UserIdentity user, String[] rights, Object context)
Check that a user has all the given rights on a context (AND condition).- Parameters:
user- the user.rights- the rights to check.context- the right context.- Returns:
- true if the user has all the rights, false otherwise.
-
checkMultipleOrRights
protected boolean checkMultipleOrRights(UserIdentity user, String[] rights, Object context)
Check that a user has at least one of the given rights on a context (OR condition).- Parameters:
user- the user.rights- the rights to check.context- the right context.- Returns:
- true if the user has at least one right, false otherwise.
-
hasRight
protected boolean hasRight(UserIdentity user, String right, Object context)
Test if a user has a right on a context.- Parameters:
user- the userright- the right to check.context- the right context.- Returns:
- true if the user has the right, false otherwise.
-
_computeContext
protected Object _computeContext(Map transientVars, Map args, UserIdentity user, String right) throws com.opensymphony.workflow.WorkflowException
Compute the context to use.
Default implementation uses standard context"/cms".- Parameters:
transientVars- variables that will not be persisted.args- the properties for this function invocation.user- the current user.right- the needed right.- Returns:
- the computed context.
- Throws:
com.opensymphony.workflow.WorkflowException- if an error occurs.
-
dispose
public void dispose()
- Specified by:
disposein interfaceDisposable
-
-