KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > rule > ruletrigger > RuleTriggerAbstractBase


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.rule.ruletrigger;
18
19 import java.util.HashSet JavaDoc;
20 import java.util.Set JavaDoc;
21
22 import org.alfresco.repo.policy.PolicyComponent;
23 import org.alfresco.repo.security.authentication.AuthenticationComponent;
24 import org.alfresco.service.cmr.repository.NodeRef;
25 import org.alfresco.service.cmr.repository.NodeService;
26 import org.alfresco.service.cmr.rule.RuleType;
27
28 /**
29  * Rule trigger abstract base
30  *
31  * @author Roy Wetherall
32  */

33 public abstract class RuleTriggerAbstractBase implements RuleTrigger
34 {
35     /**
36      * A list of the rule types that are interested in this trigger
37      */

38     private Set JavaDoc<RuleType> ruleTypes = new HashSet JavaDoc<RuleType>();
39
40     /**
41      * The policy component
42      */

43     protected PolicyComponent policyComponent;
44
45     /**
46      * The node service
47      */

48     protected NodeService nodeService;
49
50     /**
51      * The authentication Component
52      */

53
54     protected AuthenticationComponent authenticationComponent;
55
56     /**
57      * Set the policy component
58      *
59      * @param policyComponent
60      * the policy component
61      */

62     public void setPolicyComponent(PolicyComponent policyComponent)
63     {
64         this.policyComponent = policyComponent;
65     }
66
67     /**
68      * Set the node service
69      *
70      * @param nodeService
71      * the node service
72      */

73     public void setNodeService(NodeService nodeService)
74     {
75         this.nodeService = nodeService;
76     }
77
78     /**
79      * Set the authenticationComponent
80      */

81
82     public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
83     {
84         this.authenticationComponent = authenticationComponent;
85     }
86
87     /**
88      * Registration of an interested rule type
89      */

90     public void registerRuleType(RuleType ruleType)
91     {
92         this.ruleTypes.add(ruleType);
93     }
94
95     /**
96      * Trigger the rules that relate to any interested rule types for the node
97      * references passed.
98      *
99      * @param nodeRef
100      * the node reference who rules are to be triggered
101      * @param actionedUponNodeRef
102      * the node reference that will be actioned upon by the rules
103      */

104     protected void triggerRules(NodeRef nodeRef, NodeRef actionedUponNodeRef)
105     {
106         for (RuleType ruleType : this.ruleTypes)
107         {
108             ruleType.triggerRuleType(nodeRef, actionedUponNodeRef);
109         }
110     }
111 }
112
Popular Tags