View Javadoc
1   /*
2    * Copyright (C) 2003-2007 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.services.cms.actions;
18  
19  import java.util.Collection;
20  import java.util.List;
21  import java.util.Map;
22  
23  import javax.jcr.Node;
24  import javax.jcr.nodetype.NodeType;
25  
26  /**
27   *
28   * @author exo
29   *
30   */
31  public interface ActionServiceContainer {
32  
33    /**
34     * Collection of String
35     * @return collection of ActionPlugin namess
36     */
37    public Collection<String> getActionPluginNames();
38  
39    /**
40     * Get ActionPlugin following ActionSeriveName
41     * @param actionServiceName name of action service
42     * @return ActionPlugin
43     */
44    public ActionPlugin getActionPlugin(String actionServiceName);
45  
46    /**
47     * Get ActionPlugin following action type name
48     * @param actionTypeName  name of action type
49     * @return ActionPlugin
50     */
51    public ActionPlugin getActionPluginForActionType(String actionTypeName);
52  
53    /**
54     * Create NodeTypeValue is in kind of ActionType following action type name
55     * @param actionTypeName        name of action type
56     * @param parentActionTypeName  name of parent action
57     * @param executable            String value of executable
58     * @param actionLabel           Label of action type
59     * @param variableNames         List name of variable
60     * @param isMoveType            is moved or not
61     * @param isUpdate              True if the action type is updating
62     * @throws Exception
63     */
64    public void createActionType(String actionTypeName,
65                                 String parentActionTypeName,
66                                 String executable,
67                                 String actionLabel,
68                                 List<String> variableNames,
69                                 boolean isMoveType,
70                                 boolean isUpdate) throws Exception;
71  
72    /**
73     * Get all created node with nodetype = "exo:action
74     * @param repository  repository name
75     * @return Collection of NodeType
76     * @throws Exception
77     */
78    public Collection<NodeType> getCreatedActionTypes(String repository) throws Exception;
79  
80    /**
81     * get node by using actionName as relative path with current node
82     * @param node        current processing node
83     * @param actionName  name of action
84     * @return  Node
85     * @throws Exception
86     */
87    public Node getAction(Node node, String actionName) throws Exception;
88  
89    /**
90     * Check node type is exo:actionable or not
91     * @param node
92     * @return true: NodeType is exo:actionable
93     *         false NodeType is not exo:actionable
94     * @throws Exception
95     */
96    public boolean hasActions(Node node) throws Exception;
97  
98    /**
99     * Get list of child node with NodeType = exo:action
100    * @param node  current node
101    * @return list of node
102    * @throws Exception
103    */
104   public List<Node> getActions(Node node) throws Exception;
105 
106   /**
107    * Get list of node that have same level with current node, exo:lifecyclePhase = lifecyclePhase
108    * @param node            current node
109    * @param lifecyclePhase  exo:lifecyclePhase value
110    * @return list of node
111    * @throws Exception
112    */
113   public List<Node> getCustomActionsNode(Node node, String lifecyclePhase) throws Exception;
114 
115   /**
116    * Get list of child node with exo:lifecyclePhase = lifecyclePhase
117    * @param node            current node
118    * @param lifecyclePhase  exo:lifecyclePhase value
119    * @return list of node
120    * @throws Exception
121    */
122   public List<Node> getActions(Node node, String lifecyclePhase) throws Exception;
123 
124   /**
125    * Remove all action registered in node
126    * @param node
127    * @param repository
128    * @throws Exception
129    */
130   public void removeAction(Node node, String repository) throws Exception;
131   
132   /**
133    * Remove all relative node of current node with node type = exo:actionable
134    * @param node        current node
135    * @param actionName  relative path = exo:actionable / actionName
136    * @param repository  repository name
137    * @throws Exception
138    */
139   public void removeAction(Node node, String actionName, String repository) throws Exception;
140 
141   /**
142    * Add mixintype = exo:actionable to current node
143    * Add new node to current node with nodetype = type
144    * @param node        current node
145    * @param type        nodetype name
146    * @param mappings    value of property for adding to new node
147    * @throws Exception
148    */
149   public void addAction(Node node, String type, Map mappings) throws Exception;  
150 
151   /**
152    * Add mixintype = exo:actionable to current node
153    * Add new node to current node with nodetype = type
154    * @param node        current node
155    * @param type        nodetype name
156    * @param isDeep      affect to child node of node
157    * @param uuid        affect only to parent node of event having given uuid
158    * @param nodeTypeNames        affect to parent node of event having nodetype in nodeTypeNames
159    * @param mappings    value of property for adding to new node
160    * @throws Exception
161    */
162   public void addAction(Node node,
163                         String type,
164                         boolean isDeep,
165                         String[] uuid,
166                         String[] nodeTypeNames,
167                         Map mappings) throws Exception;  
168 
169   /**
170    * Execute action following userId, node, variables, repository
171    * @param userId      user identify
172    * @param node        current node
173    * @param actionName  name of action
174    * @param variables   Map with variables and value
175    * @throws Exception
176    */
177   public void executeAction(String userId,
178                             Node node,
179                             String actionName,
180                             Map variables) throws Exception;
181 
182   /**
183    * Execute action following userId, node, repository, initiated variables
184    * @param userId user identify
185    * @param node current node
186    * @param actionName name of action
187    * @throws Exception
188    * @see #executeAction(String, Node, String, Map)
189    */
190   public void executeAction(String userId, Node node, String actionName) throws Exception;
191 
192   /**
193    * Add action listener for all action child node of current node in current repository
194    * @param node        current node
195    * @throws Exception
196    */
197   public void initiateObservation(Node node) throws Exception;
198   
199   /**
200    * Init all available action plugins. 
201    * @throws Exception
202    */
203   public void init() throws Exception;  
204 
205 }