Package org.alfresco.repo.rule
Class RuleServiceImpl
java.lang.Object
org.alfresco.repo.rule.RuleServiceImpl
- All Implemented Interfaces:
NodeServicePolicies.OnAddAspectPolicy,NodeServicePolicies.OnCreateChildAssociationPolicy,NodeServicePolicies.OnCreateNodePolicy,NodeServicePolicies.OnUpdateNodePolicy,AssociationPolicy,ClassPolicy,Policy,RuntimeRuleService,RuleService
public class RuleServiceImpl
extends Object
implements RuleService, RuntimeRuleService, NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateNodePolicy, NodeServicePolicies.OnUpdateNodePolicy, NodeServicePolicies.OnAddAspectPolicy
Rule service implementation.
This service automatically binds to the transaction flush hooks. It will therefore participate in any flushes that occur during the transaction as well.
- Author:
- Roy Wetherall
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassHelper class to contain the information about a rule that is executedNested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy
Policy.Arg -
Field Summary
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnUpdateNodePolicy
QNAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule) Add a rule to the pending execution listvoidaddRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule, boolean executeAtEnd) Add a rule to the pending execution listintcountRules(NodeRef nodeRef) Count the number of rules associated with an actionable node.voiddisableRule(Rule rule) Disables a rule, preventing it from being fired.voidDisable rules for the current threadvoiddisableRules(NodeRef nodeRef) Disables the rules for a given node reference.voiddisableRuleType(String ruleType) Disables the rules of a given type.voidenableRule(Rule rule) Enables a rule previously disabled.voidEnable rules for the current threadvoidenableRules(NodeRef nodeRef) Enables the rules for a given node reference.voidenableRuleType(String ruleType) Enables rules of a given type.voidExecute all pending rulesvoidexecuteRule(Rule rule, NodeRef actionedUponNodeRef, Set<RuleServiceImpl.ExecutedRuleData> executedRules) Execute a rulegetFoldersInheritingRuleSet(NodeRef ruleSet, int maxFoldersToReturn) Get a list of folders inheriting the specified rule set.getFoldersLinkingToRuleSet(NodeRef ruleSet, int maxFoldersToReturn) Get a list of folders linking to the specified rule set.getLinkedFromRuleNodes(NodeRef nodeRef) Get a list of the all the rule nodes that link to the passed rule node.getLinkedToRuleNode(NodeRef nodeRef) Get the node reference to the rule node which the rule node links to.getNodesSupplyingRuleSets(NodeRef nodeRef) Traverse the folder hierarchy find all the folder nodes that could supply rules by inheritance.getOwningNodeRef(Action action) Returns the owning node reference for an action.getOwningNodeRef(NodeRef ruleSet) Returns the owning node reference for a rule.getOwningNodeRef(Rule rule) Returns the owning node reference for a rule.Create the rule object from the rule node referenceGet all the rules associated with an actionable node, including those inherited from parents.Get the rules associated with an actionable node.Get the rules associated with an actionable node that are of a specific rule type.getRuleSetNode(NodeRef folderNodeRef) Get rule set node associated with foldergetRuleType(String name) Gets a rule type by name.Get the rule types currently defined in the repository.getSavedRuleFolderAssoc(NodeRef nodeRef) Gets the saved rule folder referenceprotected NodeRefgetSavedRuleFolderRef(NodeRef nodeRef) booleanhasNonInheritedRules(NodeRef nodeRef) Indicates whether the node in question has any non-inherited rules associated with it.booleanIndicates whether the node in question has any rules associated with it.voidinit()Registers to listen for events of interest.booleanIndicates whether rules are currently enabled for the current thread or notbooleanisLinkedToRuleNode(NodeRef nodeRef) Indicates whether the passed rule node reference is linked to another rule node.booleanisRuleAssociatedWithRuleSet(NodeRef ruleNodeRef, NodeRef ruleSetNodeRef) Check if rule's associated parent matches rule set node.booleanisRuleSetAssociatedWithFolder(NodeRef ruleSetNodeRef, NodeRef folderNodeRef) Check if rule set is associated (owned/linked/inherited) with the given folder node.booleanisRuleSetShared(NodeRef ruleSetNodeRef) Check if other folders are linked to rule set.booleanisRuleTypeEnabled(String ruleType) Indicates whether the rule is enabled or notvoidonAddAspect(NodeRef nodeRef, QName aspectTypeQName) Cache invalidationvoidonCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode) Cache invalidationvoidonCreateNode(ChildAssociationRef childAssocRef) Cache invalidationvoidonUpdateNode(NodeRef nodeRef) Cache invalidationvoidregisterRuleType(RuleType ruleType) Register the rule typevoidremoveAllRules(NodeRef nodeRef) Removes all the rules associated with an actionable nodevoidremoveRule(NodeRef nodeRef, Rule rule) Removes a rule from the given rule actionable nodevoidremoveRulePendingExecution(NodeRef actionedUponNodeRef) Remove all pending rules that are actioning upon the given node referencebooleanrulesEnabled(NodeRef nodeRef) Indicates whether the rules for a given node are enabled or not.Saves the details of the rule to the specified node reference.voidvoidsetActionService(ActionService actionService) Set the action servicevoidsetCopyService(CopyService copyService) Set the service for locating copied nodes' originalsvoidsetDictionaryService(DictionaryService dictionaryService) Set the dictionary servicevoidsetNodeRulesCache(SimpleCache<NodeRef, List<Rule>> nodeRulesCache) Set the cache to hold node's individual rules.voidsetNodeService(NodeService nodeService) Set the permission-safe node servicevoidsetPermissionService(PermissionService permissionService) Set the permission servicevoidsetPolicyComponent(PolicyComponent policyComponent) Set the policy component to listen for various eventsvoidsetRulePosition(NodeRef nodeRef, NodeRef ruleNodeRef, int index) voidsetRulePosition(NodeRef nodeRef, Rule rule, int index) voidsetRulesDisabled(boolean rulesDisabled) Set the global rules disabled flagvoidsetRuntimeActionService(RuntimeActionService runtimeActionService) Set the runtime action servicevoidsetRuntimeNodeService(NodeService runtimeNodeService) Set the direct node service
-
Constructor Details
-
RuleServiceImpl
public RuleServiceImpl()
-
-
Method Details
-
setNodeService
Set the permission-safe node service -
setRuntimeNodeService
Set the direct node service -
setCopyService
Set the service for locating copied nodes' originals -
setActionService
Set the action service -
setRuntimeActionService
Set the runtime action service -
setDictionaryService
Set the dictionary service -
setPolicyComponent
Set the policy component to listen for various events -
setPermissionService
Set the permission service -
setNodeRulesCache
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:
-
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
Cache invalidation- Specified by:
onCreateChildAssociationin interfaceNodeServicePolicies.OnCreateChildAssociationPolicy- Parameters:
childAssocRef- the child association that has been createdisNewNode- true if the node is new or false if the node is being linked in
-
onUpdateNode
Cache invalidation- Specified by:
onUpdateNodein interfaceNodeServicePolicies.OnUpdateNodePolicy- Parameters:
nodeRef- reference to the updated node
-
onCreateNode
Cache invalidation- Specified by:
onCreateNodein interfaceNodeServicePolicies.OnCreateNodePolicy- Parameters:
childAssocRef- the created child association reference
-
onAddAspect
Cache invalidation- Specified by:
onAddAspectin interfaceNodeServicePolicies.OnAddAspectPolicy- Parameters:
nodeRef- the node to which the aspect was addedaspectTypeQName- the type of the aspect
-
getSavedRuleFolderRef
-
getSavedRuleFolderAssoc
Gets the saved rule folder reference- Specified by:
getSavedRuleFolderAssocin interfaceRuntimeRuleService- Parameters:
nodeRef- the node reference- Returns:
- the node reference
-
getRuleTypes
Description copied from interface:RuleServiceGet the rule types currently defined in the repository.- Specified by:
getRuleTypesin interfaceRuleService- Returns:
- a list of rule types
-
getRuleType
Description copied from interface:RuleServiceGets a rule type by name.- Specified by:
getRuleTypein interfaceRuleService- Parameters:
name- the name of the rule type- Returns:
- the rule type, null if not found
-
enableRules
public void enableRules()Description copied from interface:RuleServiceEnable rules for the current thread- Specified by:
enableRulesin interfaceRuleService- See Also:
-
disableRules
public void disableRules()Description copied from interface:RuleServiceDisable rules for the current thread- Specified by:
disableRulesin interfaceRuleService- See Also:
-
isEnabled
public boolean isEnabled()Description copied from interface:RuleServiceIndicates whether rules are currently enabled for the current thread or not- Specified by:
isEnabledin interfaceRuleService- Returns:
- true if rules are enabled for the current thread, false otherwise
- See Also:
-
rulesEnabled
Description copied from interface:RuleServiceIndicates 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:
rulesEnabledin interfaceRuleService- Parameters:
nodeRef- the node reference- Returns:
- true if the rules are enabled, false otherwise
-
disableRules
Description copied from interface:RuleServiceDisables the rules for a given node reference. When the rules are disabled they will not execute.- Specified by:
disableRulesin interfaceRuleService- Parameters:
nodeRef- the node reference
-
enableRules
Description copied from interface:RuleServiceEnables 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:
enableRulesin interfaceRuleService- Parameters:
nodeRef- the node reference
-
disableRule
Description copied from interface:RuleServiceDisables a rule, preventing it from being fired.- Specified by:
disableRulein interfaceRuleService- Parameters:
rule- the rule to disable- See Also:
-
enableRule
Description copied from interface:RuleServiceEnables a rule previously disabled.- Specified by:
enableRulein interfaceRuleService- Parameters:
rule- the rule to enable- See Also:
-
disableRuleType
Description copied from interface:RuleServiceDisables the rules of a given type.- Specified by:
disableRuleTypein interfaceRuleService- Parameters:
ruleType- rule type
-
enableRuleType
Description copied from interface:RuleServiceEnables rules of a given type.- Specified by:
enableRuleTypein interfaceRuleService- Parameters:
ruleType- rule type
-
isRuleTypeEnabled
Description copied from interface:RuleServiceIndicates whether the rule is enabled or not- Specified by:
isRuleTypeEnabledin interfaceRuleService- Parameters:
ruleType- rule type- Returns:
- boolean true if enabled false otherwise
-
hasRules
Description copied from interface:RuleServiceIndicates whether the node in question has any rules associated with it.- Specified by:
hasRulesin interfaceRuleService- Parameters:
nodeRef- the node reference- Returns:
- true if the node has rules associated, false otherwise
-
hasNonInheritedRules
Description copied from interface:RuleServiceIndicates whether the node in question has any non-inherited rules associated with it.- Specified by:
hasNonInheritedRulesin interfaceRuleService- Parameters:
nodeRef- the node reference- Returns:
- true if the node has rules associated, false otherwise
-
getRules
Description copied from interface:RuleServiceGet 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:
getRulesin interfaceRuleService- Parameters:
nodeRef- the node reference- Returns:
- a list of the rules associated with the node
-
getRules
Description copied from interface:RuleServiceGet 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:
getRulesin interfaceRuleService- Parameters:
nodeRef- the node referenceincludeInherited- 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
Description copied from interface:RuleServiceGet the rules associated with an actionable node that are of a specific rule type.- Specified by:
getRulesin interfaceRuleService- Parameters:
nodeRef- the node referenceincludeInherited- indicates whether the inherited rules should be included in the result list or notruleTypeName- 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
Description copied from interface:RuleServiceCount the number of rules associated with an actionable node.- Specified by:
countRulesin interfaceRuleService- Parameters:
nodeRef- the node reference- Returns:
- a list of the rules associated with the node
-
getNodesSupplyingRuleSets
Traverse the folder hierarchy find all the folder nodes that could supply rules by inheritance.- Specified by:
getNodesSupplyingRuleSetsin interfaceRuleService- Parameters:
nodeRef- The starting node ref.- Returns:
- A list of node refs, starting with the first parent of the first parent of ... and ending with the object generated by the given node ref.
-
getFoldersInheritingRuleSet
@Experimental public List<NodeRef> getFoldersInheritingRuleSet(NodeRef ruleSet, int maxFoldersToReturn) Get a list of folders inheriting the specified rule set.- Specified by:
getFoldersInheritingRuleSetin interfaceRuleService- Parameters:
ruleSet- The rule set node.maxFoldersToReturn- A limit on the number of folders to return (since otherwise this could traverse a very large proportion of the repository).- Returns:
- The list of the inheriting folders.
-
getFoldersLinkingToRuleSet
@Experimental public List<NodeRef> getFoldersLinkingToRuleSet(NodeRef ruleSet, int maxFoldersToReturn) Get a list of folders linking to the specified rule set.- Specified by:
getFoldersLinkingToRuleSetin interfaceRuleService- Parameters:
ruleSet- The rule set node.maxFoldersToReturn- A limit on the number of folders to return.- Returns:
- The list linking folders.
-
getRule
Create the rule object from the rule node reference- Specified by:
getRulein interfaceRuleService- Parameters:
ruleNodeRef- the rule node reference- Returns:
- the rule
-
saveRule
Description copied from interface:RuleServiceSaves 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:
saveRulein interfaceRuleService- Parameters:
nodeRef- NodeRefrule- Rule
-
saveRule
- Specified by:
saveRulein interfaceRuleService- Parameters:
nodeRef- NodeRefrule- Ruleindex- int
-
setRulePosition
- Specified by:
setRulePositionin interfaceRuleService- Parameters:
nodeRef- NodeRefruleNodeRef- NodeRefindex- int
-
setRulePosition
- Specified by:
setRulePositionin interfaceRuleService- Parameters:
nodeRef- NodeRefrule- Ruleindex- int
-
removeRule
Description copied from interface:RuleServiceRemoves a rule from the given rule actionable node- Specified by:
removeRulein interfaceRuleService- Parameters:
nodeRef- the actionable node reference
-
removeAllRules
Description copied from interface:RuleServiceRemoves all the rules associated with an actionable node- Specified by:
removeAllRulesin interfaceRuleService- Parameters:
nodeRef- the actionable node reference
-
addRulePendingExecution
public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule) Description copied from interface:RuntimeRuleServiceAdd a rule to the pending execution list- Specified by:
addRulePendingExecutionin interfaceRuntimeRuleService- Parameters:
actionableNodeRef- actionable node referenceactionedUponNodeRef- actioned upon node referencerule- rule
-
removeRulePendingExecution
Description copied from interface:RuntimeRuleServiceRemove all pending rules that are actioning upon the given node reference- Specified by:
removeRulePendingExecutionin interfaceRuntimeRuleService- Parameters:
actionedUponNodeRef- actioned upon node reference
-
addRulePendingExecution
public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule, boolean executeAtEnd) Description copied from interface:RuntimeRuleServiceAdd a rule to the pending execution list- Specified by:
addRulePendingExecutionin interfaceRuntimeRuleService- Parameters:
actionableNodeRef- actionable node referenceactionedUponNodeRef- actioned upon node referencerule- ruleexecuteAtEnd- true if execute rule at the end of the transaction, false otherwise
-
executePendingRules
public void executePendingRules()Description copied from interface:RuntimeRuleServiceExecute all pending rules- Specified by:
executePendingRulesin interfaceRuntimeRuleService
-
executeRule
public void executeRule(Rule rule, NodeRef actionedUponNodeRef, Set<RuleServiceImpl.ExecutedRuleData> executedRules) Description copied from interface:RuntimeRuleServiceExecute a rule- Specified by:
executeRulein interfaceRuntimeRuleService- Parameters:
rule- ruleactionedUponNodeRef- actioned upon node referenceexecutedRules- already executed rules
-
registerRuleType
Register the rule type- Specified by:
registerRuleTypein interfaceRuntimeRuleService- Parameters:
ruleType- the rule type adapter
-
getOwningNodeRef
Description copied from interface:RuleServiceReturns the owning node reference for a rule.- Specified by:
getOwningNodeRefin interfaceRuleService- Parameters:
rule- the rule- Returns:
- the owning node reference
-
getOwningNodeRef
Description copied from interface:RuleServiceReturns the owning node reference for a rule.- Specified by:
getOwningNodeRefin interfaceRuleService- Parameters:
ruleSet- The rule set node.- Returns:
- the owning node reference
-
getOwningNodeRef
Description copied from interface:RuleServiceReturns 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:
getOwningNodeRefin interfaceRuleService- Parameters:
action- the action- Returns:
- the owning node reference
-
isLinkedToRuleNode
Description copied from interface:RuleServiceIndicates whether the passed rule node reference is linked to another rule node.- Specified by:
isLinkedToRuleNodein interfaceRuleService- Parameters:
nodeRef- rule node reference- Returns:
- boolean true if linked, false otherwise
-
getLinkedToRuleNode
Description copied from interface:RuleServiceGet the node reference to the rule node which the rule node links to. Returns null if rules are not linked.- Specified by:
getLinkedToRuleNodein interfaceRuleService- Parameters:
nodeRef- node reference of a rule node- Returns:
- NodeRef reference to the
-
getLinkedFromRuleNodes
Description copied from interface:RuleServiceGet a list of the all the rule nodes that link to the passed rule node. Returns an empty list if none link.- Specified by:
getLinkedFromRuleNodesin interfaceRuleService- Parameters:
nodeRef- node reference of a rule node- Returns:
- list of rule nodes that link to this passed rule node, empty if none
-
getRuleSetNode
Description copied from interface:RuleServiceGet rule set node associated with folder- Specified by:
getRuleSetNodein interfaceRuleService- Parameters:
folderNodeRef- - folder node reference- Returns:
- node reference of a rule set
-
isRuleSetAssociatedWithFolder
@Experimental public boolean isRuleSetAssociatedWithFolder(NodeRef ruleSetNodeRef, NodeRef folderNodeRef) Description copied from interface:RuleServiceCheck if rule set is associated (owned/linked/inherited) with the given folder node.- Specified by:
isRuleSetAssociatedWithFolderin interfaceRuleService- Parameters:
ruleSetNodeRef- - node reference of a rule setfolderNodeRef- - node reference of a folder- Returns:
- true if rule set is associated with folder
-
isRuleAssociatedWithRuleSet
@Experimental public boolean isRuleAssociatedWithRuleSet(NodeRef ruleNodeRef, NodeRef ruleSetNodeRef) Description copied from interface:RuleServiceCheck if rule's associated parent matches rule set node.- Specified by:
isRuleAssociatedWithRuleSetin interfaceRuleService- Parameters:
ruleNodeRef- - node reference of a ruleruleSetNodeRef- - node reference of a rule set- Returns:
- true if rule is associated with rule set
-