Class CheckRightsCondition

java.lang.Object
org.ametys.plugins.workflow.AbstractWorkflowComponent
org.ametys.plugins.workflow.component.CheckRightsCondition
All Implemented Interfaces:
com.opensymphony.workflow.Condition, EnhancedCondition, Disposable, Initializable, LogEnabled, Serviceable
Direct Known Subclasses:
AmetysObjectCheckRightsCondition, ContentCheckRightsCondition, CreateContentRightCondition, ExplorerNodeCheckRightsCondition

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 Details

  • Constructor Details

  • Method Details

    • initialize

      public void initialize() throws Exception
      Specified by:
      initialize in interface Initializable
      Throws:
      Exception
    • passesCondition

      public boolean passesCondition(Map transientVars, Map args, com.opensymphony.module.propertyset.PropertySet ps) throws com.opensymphony.workflow.WorkflowException
      Specified by:
      passesCondition in interface com.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:
      true if the user has the right, false otherwise.
      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 user
      right - 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:
      dispose in interface Disposable
    • getArguments

      Description copied from interface: EnhancedCondition
      Get the list of accepted arguments for this condition
      Specified by:
      getArguments in interface EnhancedCondition
      Returns:
      a List of argument names and associated description
    • _getRightsEnumerator

      Get the rights enumerator
      Returns:
      the rights enumerator
    • getLabel

      Description copied from interface: EnhancedCondition
      Get the label for this condition
      Specified by:
      getLabel in interface EnhancedCondition
      Returns:
      the label
    • _getMultipleConditionsDescriptionKey

      Get condition description when there are multiple rights involved
      Parameters:
      parameters - list of rights
      Returns:
      the description
    • _getSingleConditionDescriptionKey

      Get condition description when there is one right
      Parameters:
      parameters - the right label as a List
      Returns:
      the description
    • getFullLabel

      public I18nizableText getFullLabel(Map<String,String> argumentsValues)
      Description copied from interface: EnhancedCondition
      Get the condition label depending on arguments values
      Specified by:
      getFullLabel in interface EnhancedCondition
      Parameters:
      argumentsValues - a map of the arguments with their values in current workflow
      Returns:
      a label to display in workflow editor vue