Class RuleServiceImpl

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  RuleServiceImpl.ExecutedRuleData
      Helper class to contain the information about a rule that is executed
      • Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy

        Policy.Arg
    • Constructor Summary

      Constructors 
      Constructor Description
      RuleServiceImpl()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addRulePendingExecution​(org.alfresco.service.cmr.repository.NodeRef actionableNodeRef, org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef, Rule rule)
      Add a rule to the pending execution list
      void addRulePendingExecution​(org.alfresco.service.cmr.repository.NodeRef actionableNodeRef, org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef, Rule rule, boolean executeAtEnd)
      Add a rule to the pending execution list
      int countRules​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Count the number of rules associated with an actionable node.
      void disableRule​(Rule rule)
      Disables a rule, preventing it from being fired.
      void disableRules()
      Disable rules for the current thread
      void disableRules​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Disables the rules for a given node reference.
      void disableRuleType​(java.lang.String ruleType)
      Disables the rules of a given type.
      void enableRule​(Rule rule)
      Enables a rule previously disabled.
      void enableRules()
      Enable rules for the current thread
      void enableRules​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Enables the rules for a given node reference.
      void enableRuleType​(java.lang.String ruleType)
      Enables rules of a given type.
      void executePendingRules()
      Execute all pending rules
      void executeRule​(Rule rule, org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef, java.util.Set<RuleServiceImpl.ExecutedRuleData> executedRules)
      Execute a rule
      java.util.List<org.alfresco.service.cmr.repository.NodeRef> getLinkedFromRuleNodes​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Get a list of the all the rule nodes that link to the passed rule node.
      org.alfresco.service.cmr.repository.NodeRef getLinkedToRuleNode​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Get the node reference to the rule node which the rule node links to.
      org.alfresco.service.cmr.repository.NodeRef getOwningNodeRef​(Action action)
      Returns the owning node reference for an action.
      org.alfresco.service.cmr.repository.NodeRef getOwningNodeRef​(Rule rule)
      Returns the owning node reference for a rule.
      Rule getRule​(org.alfresco.service.cmr.repository.NodeRef ruleNodeRef)
      Create the rule object from the rule node reference
      java.util.List<Rule> getRules​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Get all the rules associated with an actionable node, including those inherited from parents.
      java.util.List<Rule> getRules​(org.alfresco.service.cmr.repository.NodeRef nodeRef, boolean includeInherited)
      Get the rules associated with an actionable node.
      java.util.List<Rule> getRules​(org.alfresco.service.cmr.repository.NodeRef nodeRef, boolean includeInherited, java.lang.String ruleTypeName)
      Get the rules associated with an actionable node that are of a specific rule type.
      RuleType getRuleType​(java.lang.String name)
      Gets a rule type by name.
      java.util.List<RuleType> getRuleTypes()
      Get the rule types currently defined in the repository.
      org.alfresco.service.cmr.repository.ChildAssociationRef getSavedRuleFolderAssoc​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Gets the saved rule folder reference
      protected org.alfresco.service.cmr.repository.NodeRef getSavedRuleFolderRef​(org.alfresco.service.cmr.repository.NodeRef nodeRef)  
      boolean hasRules​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Indicates whether the node in question has any rules associated with it.
      void init()
      Registers to listen for events of interest.
      boolean isEnabled()
      Indicates whether rules are currently enabled for the current thread or not
      boolean isLinkedToRuleNode​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Indicates whether the passed rule node reference is linked to another rule node.
      boolean isRuleTypeEnabled​(java.lang.String ruleType)
      Indicates whether the rule is enabled or not
      void onAddAspect​(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName aspectTypeQName)
      Cache invalidation
      void onCreateChildAssociation​(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef, boolean isNewNode)
      Cache invalidation
      void onCreateNode​(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
      Cache invalidation
      void onUpdateNode​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Cache invalidation
      void registerRuleType​(RuleType ruleType)
      Register the rule type
      void removeAllRules​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Removes all the rules associated with an actionable node
      void removeRule​(org.alfresco.service.cmr.repository.NodeRef nodeRef, Rule rule)
      Removes a rule from the given rule actionable node
      void removeRulePendingExecution​(org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef)
      Remove all pending rules that are actioning upon the given node reference
      boolean rulesEnabled​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Indicates whether the rules for a given node are enabled or not.
      void saveRule​(org.alfresco.service.cmr.repository.NodeRef nodeRef, Rule rule)
      Saves the details of the rule to the specified node reference.
      void saveRule​(org.alfresco.service.cmr.repository.NodeRef nodeRef, Rule rule, int index)  
      void setActionService​(ActionService actionService)
      Set the action service
      void setCopyService​(CopyService copyService)
      Set the service for locating copied nodes' originals
      void setDictionaryService​(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
      Set the dictionary service
      void setNodeRulesCache​(org.alfresco.repo.cache.SimpleCache<org.alfresco.service.cmr.repository.NodeRef,​java.util.List<Rule>> nodeRulesCache)
      Set the cache to hold node's individual rules.
      void setNodeService​(org.alfresco.service.cmr.repository.NodeService nodeService)
      Set the permission-safe node service
      void setPermissionService​(org.alfresco.service.cmr.security.PermissionService permissionService)
      Set the permission service
      void setPolicyComponent​(PolicyComponent policyComponent)
      Set the policy component to listen for various events
      void setRulePosition​(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.cmr.repository.NodeRef ruleNodeRef, int index)  
      void setRulePosition​(org.alfresco.service.cmr.repository.NodeRef nodeRef, Rule rule, int index)  
      void setRulesDisabled​(boolean rulesDisabled)
      Set the global rules disabled flag
      void setRuntimeActionService​(RuntimeActionService runtimeActionService)
      Set the runtime action service
      void setRuntimeNodeService​(org.alfresco.service.cmr.repository.NodeService runtimeNodeService)
      Set the direct node service
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RuleServiceImpl

        public RuleServiceImpl()
    • Method Detail

      • setNodeService

        public void setNodeService​(org.alfresco.service.cmr.repository.NodeService nodeService)
        Set the permission-safe node service
      • setRuntimeNodeService

        public void setRuntimeNodeService​(org.alfresco.service.cmr.repository.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​(org.alfresco.service.cmr.dictionary.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​(org.alfresco.service.cmr.security.PermissionService permissionService)
        Set the permission service
      • setNodeRulesCache

        public void setNodeRulesCache​(org.alfresco.repo.cache.SimpleCache<org.alfresco.service.cmr.repository.NodeRef,​java.util.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.
      • onCreateChildAssociation

        public void onCreateChildAssociation​(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef,
                                             boolean isNewNode)
        Cache invalidation
        Specified by:
        onCreateChildAssociation in interface NodeServicePolicies.OnCreateChildAssociationPolicy
        Parameters:
        childAssocRef - the child association that has been created
        isNewNode - true if the node is new or false if the node is being linked in
      • onUpdateNode

        public void onUpdateNode​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
        Cache invalidation
        Specified by:
        onUpdateNode in interface NodeServicePolicies.OnUpdateNodePolicy
        Parameters:
        nodeRef - reference to the updated node
      • onCreateNode

        public void onCreateNode​(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
        Cache invalidation
        Specified by:
        onCreateNode in interface NodeServicePolicies.OnCreateNodePolicy
        Parameters:
        childAssocRef - the created child association reference
      • onAddAspect

        public void onAddAspect​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                org.alfresco.service.namespace.QName aspectTypeQName)
        Cache invalidation
        Specified by:
        onAddAspect in interface NodeServicePolicies.OnAddAspectPolicy
        Parameters:
        nodeRef - the node to which the aspect was added
        aspectTypeQName - the type of the aspect
      • getSavedRuleFolderRef

        protected org.alfresco.service.cmr.repository.NodeRef getSavedRuleFolderRef​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      • getSavedRuleFolderAssoc

        public org.alfresco.service.cmr.repository.ChildAssociationRef getSavedRuleFolderAssoc​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
        Gets the saved rule folder reference
        Specified by:
        getSavedRuleFolderAssoc in interface RuntimeRuleService
        Parameters:
        nodeRef - the node reference
        Returns:
        the node reference
      • getRuleTypes

        public java.util.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​(java.lang.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​(org.alfresco.service.cmr.repository.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​(org.alfresco.service.cmr.repository.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​(org.alfresco.service.cmr.repository.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​(java.lang.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​(java.lang.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​(java.lang.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​(org.alfresco.service.cmr.repository.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 java.util.List<Rule> getRules​(org.alfresco.service.cmr.repository.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 java.util.List<Rule> getRules​(org.alfresco.service.cmr.repository.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 java.util.List<Rule> getRules​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                             boolean includeInherited,
                                             java.lang.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​(org.alfresco.service.cmr.repository.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​(org.alfresco.service.cmr.repository.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​(org.alfresco.service.cmr.repository.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​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                             Rule rule,
                             int index)
        Specified by:
        saveRule in interface RuleService
        Parameters:
        nodeRef - NodeRef
        rule - Rule
        index - int
      • setRulePosition

        public void setRulePosition​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                    org.alfresco.service.cmr.repository.NodeRef ruleNodeRef,
                                    int index)
        Specified by:
        setRulePosition in interface RuleService
        Parameters:
        nodeRef - NodeRef
        ruleNodeRef - NodeRef
        index - int
      • setRulePosition

        public void setRulePosition​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                    Rule rule,
                                    int index)
        Specified by:
        setRulePosition in interface RuleService
        Parameters:
        nodeRef - NodeRef
        rule - Rule
        index - int
      • removeRule

        public void removeRule​(org.alfresco.service.cmr.repository.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​(org.alfresco.service.cmr.repository.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​(org.alfresco.service.cmr.repository.NodeRef actionableNodeRef,
                                            org.alfresco.service.cmr.repository.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​(org.alfresco.service.cmr.repository.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​(org.alfresco.service.cmr.repository.NodeRef actionableNodeRef,
                                            org.alfresco.service.cmr.repository.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
      • executeRule

        public void executeRule​(Rule rule,
                                org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef,
                                java.util.Set<RuleServiceImpl.ExecutedRuleData> executedRules)
        Description copied from interface: RuntimeRuleService
        Execute a rule
        Specified by:
        executeRule in interface RuntimeRuleService
        Parameters:
        rule - rule
        actionedUponNodeRef - actioned upon node reference
        executedRules - already executed rules
      • getOwningNodeRef

        public org.alfresco.service.cmr.repository.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 org.alfresco.service.cmr.repository.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​(org.alfresco.service.cmr.repository.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 org.alfresco.service.cmr.repository.NodeRef getLinkedToRuleNode​(org.alfresco.service.cmr.repository.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 java.util.List<org.alfresco.service.cmr.repository.NodeRef> getLinkedFromRuleNodes​(org.alfresco.service.cmr.repository.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