Class RuleServiceImpl

    • Constructor Detail

      • RuleServiceImpl

        public RuleServiceImpl()
    • Method Detail

      • setNodeService

        public void setNodeService​(NodeService nodeService)
        Set the permission-safe node service
      • setRuntimeNodeService

        public void setRuntimeNodeService​(NodeService runtimeNodeService)
        Set the direct node service
      • setCopyService

        public void setCopyService​(CopyService copyService)
        Set the service for locating copied nodes' originals
      • setActionService

        public void setActionService​(ActionService actionService)
        Set the action service
      • setRuntimeActionService

        public void setRuntimeActionService​(RuntimeActionService runtimeActionService)
        Set the runtime action service
      • setDictionaryService

        public void setDictionaryService​(DictionaryService dictionaryService)
        Set the dictionary service
      • setPolicyComponent

        public void setPolicyComponent​(PolicyComponent policyComponent)
        Set the policy component to listen for various events
      • setPermissionService

        public void setPermissionService​(PermissionService permissionService)
        Set the permission service
      • setNodeRulesCache

        public void setNodeRulesCache​(SimpleCache<NodeRef,​List<Rule>> nodeRulesCache)
        Set the cache to hold node's individual rules. This cache must not be shared across transactions.
        Parameters:
        nodeRulesCache - a cache of raw rules contained on a node
        See Also:
        NullCache
      • setRulesDisabled

        public void setRulesDisabled​(boolean rulesDisabled)
        Set the global rules disabled flag
        Parameters:
        rulesDisabled - true to disable allr ules, false otherwise
      • init

        public void init()
        Registers to listen for events of interest. For instance, the creation or deletion of a rule folder will affect the caching of rules.
      • getSavedRuleFolderRef

        protected NodeRef getSavedRuleFolderRef​(NodeRef nodeRef)
      • getRuleTypes

        public List<RuleType> getRuleTypes()
        Description copied from interface: RuleService
        Get the rule types currently defined in the repository.
        Specified by:
        getRuleTypes in interface RuleService
        Returns:
        a list of rule types
      • getRuleType

        public RuleType getRuleType​(String name)
        Description copied from interface: RuleService
        Gets a rule type by name.
        Specified by:
        getRuleType in interface RuleService
        Parameters:
        name - the name of the rule type
        Returns:
        the rule type, null if not found
      • rulesEnabled

        public boolean rulesEnabled​(NodeRef nodeRef)
        Description copied from interface: RuleService
        Indicates whether the rules for a given node are enabled or not. If the rules are not enabled then they will not be executed.
        Specified by:
        rulesEnabled in interface RuleService
        Parameters:
        nodeRef - the node reference
        Returns:
        true if the rules are enabled, false otherwise
      • disableRules

        public void disableRules​(NodeRef nodeRef)
        Description copied from interface: RuleService
        Disables the rules for a given node reference. When the rules are disabled they will not execute.
        Specified by:
        disableRules in interface RuleService
        Parameters:
        nodeRef - the node reference
      • enableRules

        public void enableRules​(NodeRef nodeRef)
        Description copied from interface: RuleService
        Enables the rules for a given node reference. When the rules are enabled they will execute as usual. By default all rules are enabled.
        Specified by:
        enableRules in interface RuleService
        Parameters:
        nodeRef - the node reference
      • disableRuleType

        public void disableRuleType​(String ruleType)
        Description copied from interface: RuleService
        Disables the rules of a given type.
        Specified by:
        disableRuleType in interface RuleService
        Parameters:
        ruleType - rule type
      • enableRuleType

        public void enableRuleType​(String ruleType)
        Description copied from interface: RuleService
        Enables rules of a given type.
        Specified by:
        enableRuleType in interface RuleService
        Parameters:
        ruleType - rule type
      • isRuleTypeEnabled

        public boolean isRuleTypeEnabled​(String ruleType)
        Description copied from interface: RuleService
        Indicates whether the rule is enabled or not
        Specified by:
        isRuleTypeEnabled in interface RuleService
        Parameters:
        ruleType - rule type
        Returns:
        boolean true if enabled false otherwise
      • hasRules

        public boolean hasRules​(NodeRef nodeRef)
        Description copied from interface: RuleService
        Indicates whether the node in question has any rules associated with it.
        Specified by:
        hasRules in interface RuleService
        Parameters:
        nodeRef - the node reference
        Returns:
        true if the node has rules associated, false otherwise
      • getRules

        public List<Rule> getRules​(NodeRef nodeRef)
        Description copied from interface: RuleService
        Get all the rules associated with an actionable node, including those inherited from parents.

        An exception is raised if the actionable aspect is not present on the passed node.

        Specified by:
        getRules in interface RuleService
        Parameters:
        nodeRef - the node reference
        Returns:
        a list of the rules associated with the node
      • getRules

        public List<Rule> getRules​(NodeRef nodeRef,
                                   boolean includeInherited)
        Description copied from interface: RuleService
        Get the rules associated with an actionable node.

        Optionally this list includes rules inherited from its parents.

        An exception is raised if the actionable aspect is not present on the passed node.

        Specified by:
        getRules in interface RuleService
        Parameters:
        nodeRef - the node reference
        includeInherited - indicates whether the inherited rules should be included in the result list or not
        Returns:
        a list of the rules associated with the node
      • getRules

        public List<Rule> getRules​(NodeRef nodeRef,
                                   boolean includeInherited,
                                   String ruleTypeName)
        Description copied from interface: RuleService
        Get the rules associated with an actionable node that are of a specific rule type.
        Specified by:
        getRules in interface RuleService
        Parameters:
        nodeRef - the node reference
        includeInherited - indicates whether the inherited rules should be included in the result list or not
        ruleTypeName - the name of the rule type, if null is passed all rule types are returned
        Returns:
        a list of the rules associated with the node
      • countRules

        public int countRules​(NodeRef nodeRef)
        Description copied from interface: RuleService
        Count the number of rules associated with an actionable node.
        Specified by:
        countRules in interface RuleService
        Parameters:
        nodeRef - the node reference
        Returns:
        a list of the rules associated with the node
      • getRule

        public Rule getRule​(NodeRef ruleNodeRef)
        Create the rule object from the rule node reference
        Specified by:
        getRule in interface RuleService
        Parameters:
        ruleNodeRef - the rule node reference
        Returns:
        the rule
      • saveRule

        public void saveRule​(NodeRef nodeRef,
                             Rule rule)
        Description copied from interface: RuleService
        Saves the details of the rule to the specified node reference.

        If the rule is already associated with the node, the details are updated with those specified.

        Specified by:
        saveRule in interface RuleService
        Parameters:
        nodeRef - NodeRef
        rule - Rule
      • saveRule

        public void saveRule​(NodeRef nodeRef,
                             Rule rule,
                             int index)
        Specified by:
        saveRule in interface RuleService
        Parameters:
        nodeRef - NodeRef
        rule - Rule
        index - int
      • setRulePosition

        public void setRulePosition​(NodeRef nodeRef,
                                    NodeRef ruleNodeRef,
                                    int index)
        Specified by:
        setRulePosition in interface RuleService
        Parameters:
        nodeRef - NodeRef
        ruleNodeRef - NodeRef
        index - int
      • setRulePosition

        public void setRulePosition​(NodeRef nodeRef,
                                    Rule rule,
                                    int index)
        Specified by:
        setRulePosition in interface RuleService
        Parameters:
        nodeRef - NodeRef
        rule - Rule
        index - int
      • removeRule

        public void removeRule​(NodeRef nodeRef,
                               Rule rule)
        Description copied from interface: RuleService
        Removes a rule from the given rule actionable node
        Specified by:
        removeRule in interface RuleService
        Parameters:
        nodeRef - the actionable node reference
      • removeAllRules

        public void removeAllRules​(NodeRef nodeRef)
        Description copied from interface: RuleService
        Removes all the rules associated with an actionable node
        Specified by:
        removeAllRules in interface RuleService
        Parameters:
        nodeRef - the actionable node reference
      • addRulePendingExecution

        public void addRulePendingExecution​(NodeRef actionableNodeRef,
                                            NodeRef actionedUponNodeRef,
                                            Rule rule)
        Description copied from interface: RuntimeRuleService
        Add a rule to the pending execution list
        Specified by:
        addRulePendingExecution in interface RuntimeRuleService
        Parameters:
        actionableNodeRef - actionable node reference
        actionedUponNodeRef - actioned upon node reference
        rule - rule
      • removeRulePendingExecution

        public void removeRulePendingExecution​(NodeRef actionedUponNodeRef)
        Description copied from interface: RuntimeRuleService
        Remove all pending rules that are actioning upon the given node reference
        Specified by:
        removeRulePendingExecution in interface RuntimeRuleService
        Parameters:
        actionedUponNodeRef - actioned upon node reference
      • addRulePendingExecution

        public void addRulePendingExecution​(NodeRef actionableNodeRef,
                                            NodeRef actionedUponNodeRef,
                                            Rule rule,
                                            boolean executeAtEnd)
        Description copied from interface: RuntimeRuleService
        Add a rule to the pending execution list
        Specified by:
        addRulePendingExecution in interface RuntimeRuleService
        Parameters:
        actionableNodeRef - actionable node reference
        actionedUponNodeRef - actioned upon node reference
        rule - rule
        executeAtEnd - true if execute rule at the end of the transaction, false otherwise
      • getOwningNodeRef

        public NodeRef getOwningNodeRef​(Rule rule)
        Description copied from interface: RuleService
        Returns the owning node reference for a rule.
        Specified by:
        getOwningNodeRef in interface RuleService
        Parameters:
        rule - the rule
        Returns:
        the owning node reference
      • getOwningNodeRef

        public NodeRef getOwningNodeRef​(Action action)
        Description copied from interface: RuleService
        Returns the owning node reference for an action. Returns null for an unsaved action or one that is not parented by a rule. NOTE: this method is temporary and will be removed in future versions. It should only be used with good reason.
        Specified by:
        getOwningNodeRef in interface RuleService
        Parameters:
        action - the action
        Returns:
        the owning node reference
      • isLinkedToRuleNode

        public boolean isLinkedToRuleNode​(NodeRef nodeRef)
        Description copied from interface: RuleService
        Indicates whether the passed rule node reference is linked to another rule node.
        Specified by:
        isLinkedToRuleNode in interface RuleService
        Parameters:
        nodeRef - rule node reference
        Returns:
        boolean true if linked, false otherwise
      • getLinkedToRuleNode

        public NodeRef getLinkedToRuleNode​(NodeRef nodeRef)
        Description copied from interface: RuleService
        Get the node reference to the rule node which the rule node links to. Returns null if rules are not linked.
        Specified by:
        getLinkedToRuleNode in interface RuleService
        Parameters:
        nodeRef - node reference of a rule node
        Returns:
        NodeRef reference to the
      • getLinkedFromRuleNodes

        public List<NodeRef> getLinkedFromRuleNodes​(NodeRef nodeRef)
        Description copied from interface: RuleService
        Get a list of the all the rule nodes that link to the passed rule node. Returns an empty list if none link.
        Specified by:
        getLinkedFromRuleNodes in interface RuleService
        Parameters:
        nodeRef - node reference of a rule node
        Returns:
        list of rule nodes that link to this passed rule node, empty if none