public class RuleServiceImpl extends Object implements RuleService, RuntimeRuleService, NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateNodePolicy, NodeServicePolicies.OnUpdateNodePolicy, NodeServicePolicies.OnAddAspectPolicy
This service automatically binds to the transaction flush hooks. It will therefore participate in any flushes that occur during the transaction as well.
Modifier and Type | Class and Description |
---|---|
class |
RuleServiceImpl.ExecutedRuleData
Helper class to contain the information about a rule that is executed
|
Policy.Arg
QNAME
QNAME
QNAME
QNAME
Constructor and Description |
---|
RuleServiceImpl() |
Modifier and Type | Method and 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(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(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,
Set<RuleServiceImpl.ExecutedRuleData> executedRules)
Execute a rule
|
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
|
List<Rule> |
getRules(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Get all the rules associated with an actionable node, including those
inherited from parents.
|
List<Rule> |
getRules(org.alfresco.service.cmr.repository.NodeRef nodeRef,
boolean includeInherited)
Get the rules associated with an actionable node.
|
List<Rule> |
getRules(org.alfresco.service.cmr.repository.NodeRef nodeRef,
boolean includeInherited,
String ruleTypeName)
Get the rules associated with an actionable node that are of a specific rule type.
|
RuleType |
getRuleType(String name)
Gets a rule type by name.
|
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(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,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
|
public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
public void setRuntimeNodeService(org.alfresco.service.cmr.repository.NodeService runtimeNodeService)
public void setCopyService(CopyService copyService)
public void setActionService(ActionService actionService)
public void setRuntimeActionService(RuntimeActionService runtimeActionService)
public void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
public void setPolicyComponent(PolicyComponent policyComponent)
public void setPermissionService(org.alfresco.service.cmr.security.PermissionService permissionService)
public void setNodeRulesCache(org.alfresco.repo.cache.SimpleCache<org.alfresco.service.cmr.repository.NodeRef,List<Rule>> nodeRulesCache)
nodeRulesCache
- a cache of raw rules contained on a nodeNullCache
public void setRulesDisabled(boolean rulesDisabled)
rulesDisabled
- true to disable allr ules, false otherwisepublic void init()
public void onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef, boolean isNewNode)
onCreateChildAssociation
in interface NodeServicePolicies.OnCreateChildAssociationPolicy
childAssocRef
- the child association that has been createdisNewNode
- true if the node is new or false if the node is being linked inpublic void onUpdateNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
onUpdateNode
in interface NodeServicePolicies.OnUpdateNodePolicy
nodeRef
- reference to the updated nodepublic void onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
onCreateNode
in interface NodeServicePolicies.OnCreateNodePolicy
childAssocRef
- the created child association referencepublic void onAddAspect(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName aspectTypeQName)
onAddAspect
in interface NodeServicePolicies.OnAddAspectPolicy
nodeRef
- the node to which the aspect was addedaspectTypeQName
- the type of the aspectprotected org.alfresco.service.cmr.repository.NodeRef getSavedRuleFolderRef(org.alfresco.service.cmr.repository.NodeRef nodeRef)
public org.alfresco.service.cmr.repository.ChildAssociationRef getSavedRuleFolderAssoc(org.alfresco.service.cmr.repository.NodeRef nodeRef)
getSavedRuleFolderAssoc
in interface RuntimeRuleService
nodeRef
- the node referencepublic List<RuleType> getRuleTypes()
RuleService
getRuleTypes
in interface RuleService
public RuleType getRuleType(String name)
RuleService
getRuleType
in interface RuleService
name
- the name of the rule typepublic void enableRules()
RuleService
enableRules
in interface RuleService
RuleService.isEnabled()
,
RuleService.disableRules()
public void disableRules()
RuleService
disableRules
in interface RuleService
RuleService.enableRules()
,
RuleService.isEnabled()
public boolean isEnabled()
RuleService
isEnabled
in interface RuleService
RuleService.enableRules()
,
RuleService.disableRules()
public boolean rulesEnabled(org.alfresco.service.cmr.repository.NodeRef nodeRef)
RuleService
rulesEnabled
in interface RuleService
nodeRef
- the node referencepublic void disableRules(org.alfresco.service.cmr.repository.NodeRef nodeRef)
RuleService
disableRules
in interface RuleService
nodeRef
- the node referencepublic void enableRules(org.alfresco.service.cmr.repository.NodeRef nodeRef)
RuleService
enableRules
in interface RuleService
nodeRef
- the node referencepublic void disableRule(Rule rule)
RuleService
disableRule
in interface RuleService
rule
- the rule to disableRuleService.enableRule(Rule)
public void enableRule(Rule rule)
RuleService
enableRule
in interface RuleService
rule
- the rule to enableRuleService.disableRule(Rule)
public void disableRuleType(String ruleType)
RuleService
disableRuleType
in interface RuleService
ruleType
- rule typepublic void enableRuleType(String ruleType)
RuleService
enableRuleType
in interface RuleService
ruleType
- rule typepublic boolean isRuleTypeEnabled(String ruleType)
RuleService
isRuleTypeEnabled
in interface RuleService
ruleType
- rule typepublic boolean hasRules(org.alfresco.service.cmr.repository.NodeRef nodeRef)
RuleService
hasRules
in interface RuleService
nodeRef
- the node referencepublic List<Rule> getRules(org.alfresco.service.cmr.repository.NodeRef nodeRef)
RuleService
An exception is raised if the actionable aspect is not present on the passed node.
getRules
in interface RuleService
nodeRef
- the node referencepublic List<Rule> getRules(org.alfresco.service.cmr.repository.NodeRef nodeRef, boolean includeInherited)
RuleService
Optionally this list includes rules inherited from its parents.
An exception is raised if the actionable aspect is not present on the passed node.
getRules
in interface RuleService
nodeRef
- the node referenceincludeInherited
- indicates whether the inherited rules should be included in
the result list or notpublic List<Rule> getRules(org.alfresco.service.cmr.repository.NodeRef nodeRef, boolean includeInherited, String ruleTypeName)
RuleService
getRules
in interface RuleService
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 returnedpublic int countRules(org.alfresco.service.cmr.repository.NodeRef nodeRef)
RuleService
countRules
in interface RuleService
nodeRef
- the node referencepublic Rule getRule(org.alfresco.service.cmr.repository.NodeRef ruleNodeRef)
getRule
in interface RuleService
ruleNodeRef
- the rule node referencepublic void saveRule(org.alfresco.service.cmr.repository.NodeRef nodeRef, Rule rule)
RuleService
If the rule is already associated with the node, the details are updated with those specified.
saveRule
in interface RuleService
nodeRef
- NodeRefrule
- Rulepublic void saveRule(org.alfresco.service.cmr.repository.NodeRef nodeRef, Rule rule, int index)
saveRule
in interface RuleService
nodeRef
- NodeRefrule
- Ruleindex
- intpublic void setRulePosition(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.cmr.repository.NodeRef ruleNodeRef, int index)
setRulePosition
in interface RuleService
nodeRef
- NodeRefruleNodeRef
- NodeRefindex
- intpublic void setRulePosition(org.alfresco.service.cmr.repository.NodeRef nodeRef, Rule rule, int index)
setRulePosition
in interface RuleService
nodeRef
- NodeRefrule
- Ruleindex
- intpublic void removeRule(org.alfresco.service.cmr.repository.NodeRef nodeRef, Rule rule)
RuleService
removeRule
in interface RuleService
nodeRef
- the actionable node referencepublic void removeAllRules(org.alfresco.service.cmr.repository.NodeRef nodeRef)
RuleService
removeAllRules
in interface RuleService
nodeRef
- the actionable node referencepublic void addRulePendingExecution(org.alfresco.service.cmr.repository.NodeRef actionableNodeRef, org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef, Rule rule)
RuntimeRuleService
addRulePendingExecution
in interface RuntimeRuleService
actionableNodeRef
- actionable node referenceactionedUponNodeRef
- actioned upon node referencerule
- rulepublic void removeRulePendingExecution(org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef)
RuntimeRuleService
removeRulePendingExecution
in interface RuntimeRuleService
actionedUponNodeRef
- actioned upon node referencepublic void addRulePendingExecution(org.alfresco.service.cmr.repository.NodeRef actionableNodeRef, org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef, Rule rule, boolean executeAtEnd)
RuntimeRuleService
addRulePendingExecution
in interface RuntimeRuleService
actionableNodeRef
- actionable node referenceactionedUponNodeRef
- actioned upon node referencerule
- ruleexecuteAtEnd
- true if execute rule at the end of the transaction, false otherwisepublic void executePendingRules()
RuntimeRuleService
executePendingRules
in interface RuntimeRuleService
public void executeRule(Rule rule, org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef, Set<RuleServiceImpl.ExecutedRuleData> executedRules)
RuntimeRuleService
executeRule
in interface RuntimeRuleService
rule
- ruleactionedUponNodeRef
- actioned upon node referenceexecutedRules
- already executed rulespublic void registerRuleType(RuleType ruleType)
registerRuleType
in interface RuntimeRuleService
ruleType
- the rule type adapterpublic org.alfresco.service.cmr.repository.NodeRef getOwningNodeRef(Rule rule)
RuleService
getOwningNodeRef
in interface RuleService
rule
- the rulepublic org.alfresco.service.cmr.repository.NodeRef getOwningNodeRef(Action action)
RuleService
getOwningNodeRef
in interface RuleService
action
- the actionpublic boolean isLinkedToRuleNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
RuleService
isLinkedToRuleNode
in interface RuleService
nodeRef
- rule node referencepublic org.alfresco.service.cmr.repository.NodeRef getLinkedToRuleNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
RuleService
getLinkedToRuleNode
in interface RuleService
nodeRef
- node reference of a rule nodepublic List<org.alfresco.service.cmr.repository.NodeRef> getLinkedFromRuleNodes(org.alfresco.service.cmr.repository.NodeRef nodeRef)
RuleService
getLinkedFromRuleNodes
in interface RuleService
nodeRef
- node reference of a rule nodeCopyright © 2005–2017 Alfresco Software. All rights reserved.