KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > action > executer > ActionExecuterAbstractBase


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.action.executer;
18
19 import org.alfresco.repo.action.ActionDefinitionImpl;
20 import org.alfresco.repo.action.ParameterizedItemAbstractBase;
21 import org.alfresco.service.cmr.action.Action;
22 import org.alfresco.service.cmr.action.ActionDefinition;
23 import org.alfresco.service.cmr.repository.NodeRef;
24
25 /**
26  * Rule action executor abstract base.
27  *
28  * @author Roy Wetherall
29  */

30 public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstractBase implements ActionExecuter
31 {
32     /**
33      * Action definition
34      */

35     protected ActionDefinition actionDefinition;
36     
37     /**
38      * Indicated whether the action is public or internal
39      */

40     protected boolean publicAction = true;
41     
42     /**
43      * Init method
44      */

45     public void init()
46     {
47         if (this.publicAction == true)
48         {
49             this.runtimeActionService.registerActionExecuter(this);
50         }
51     }
52     
53     /**
54      * Set whether the action is public or not.
55      *
56      * @param publicAction true if the action is public, false otherwise
57      */

58     public void setPublicAction(boolean publicAction)
59     {
60         this.publicAction = publicAction;
61     }
62     
63     /**
64      * Get rule action definition
65      *
66      * @return the action definition object
67      */

68     public ActionDefinition getActionDefinition()
69     {
70         if (this.actionDefinition == null)
71         {
72             this.actionDefinition = new ActionDefinitionImpl(this.name);
73             ((ActionDefinitionImpl)this.actionDefinition).setTitleKey(getTitleKey());
74             ((ActionDefinitionImpl)this.actionDefinition).setDescriptionKey(getDescriptionKey());
75             ((ActionDefinitionImpl)this.actionDefinition).setAdhocPropertiesAllowed(getAdhocPropertiesAllowed());
76             ((ActionDefinitionImpl)this.actionDefinition).setRuleActionExecutor(this.name);
77             ((ActionDefinitionImpl)this.actionDefinition).setParameterDefinitions(getParameterDefintions());
78         }
79         return this.actionDefinition;
80     }
81     
82     /**
83      * @see org.alfresco.repo.action.executer.ActionExecuter#execute(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
84      */

85     public void execute(Action action, NodeRef actionedUponNodeRef)
86     {
87         // Check the mandatory properties
88
checkMandatoryProperties(action, getActionDefinition());
89         
90         // Execute the implementation
91
executeImpl(action, actionedUponNodeRef);
92     }
93     
94     /**
95      * Execute the action implementation
96      *
97      * @param action the action
98      * @param actionedUponNodeRef the actioned upon node
99      */

100     protected abstract void executeImpl(Action action, NodeRef actionedUponNodeRef);
101
102      
103 }
104
Popular Tags