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.views;
18  
19  import java.util.List;
20  import java.util.Set;
21  
22  import javax.jcr.Node;
23  
24  import org.exoplatform.services.cms.views.impl.ManageViewPlugin;
25  import org.exoplatform.services.jcr.ext.common.SessionProvider;
26  import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
27  
28  /**
29   * Manages views, including adding, editing, deleting and getting.
30   *
31   * @LevelAPI Experimental
32   */
33  public interface ManageViewService {
34  
35    /** The type of extension related to this service. */
36    public static final String EXTENSION_TYPE = "org.exoplatform.ecm.dms.UIActionBar";
37  
38    /**
39     * Adds a new view to the system by giving the following params.
40     * 
41     * @param name Name of the view.
42     * @param permissions Who can access the view.
43     * @param template Name of the templated used by the added view.
44     * @param tabs Tabs of the added view.
45     * @throws Exception The exception
46     */
47    public void addView(String name, String permissions, String template, List<?> tabs) throws Exception;
48    
49    /**
50     * Adds a new view to the system by giving the following params.
51     *
52     * @param name Name of the view.
53     * @param permissions Who can access the view.
54     * @param hideExplorerPanel If "true", the explorer panel is hidden. If "false", the explorer panel is shown.
55     * @param template Name of the templated used by the added view.
56     * @param tabs Tabs of the added view.
57     * @throws Exception The exception
58     */
59    public void addView(String name, String permissions, boolean hideExplorerPanel, String template, List<?> tabs) throws Exception;
60  
61    /**
62     * Gets a view by its name.
63     *
64     * @param viewName Name of the view.
65     * @param provider The session provider.
66     * @return The view.
67     * @throws Exception The exception
68     */
69    public Node getViewByName(String viewName, SessionProvider provider) throws Exception;  
70  
71    /**
72     * Gets all strings of buttons.
73     *
74     * @return The list of buttons.
75     * @throws Exception The exception
76     */
77    public List<?> getButtons() throws Exception;
78  
79    /**
80     * Removes a view from the views list in the system.
81     *
82     * @param viewName Name of the removed view.
83     * @throws Exception The exception
84     */
85    public void removeView(String viewName) throws Exception;  
86  
87    /**
88     * Gets all views.
89     *
90     * @return The list of views.
91     * @throws Exception The exception
92     */
93    public List<ViewConfig> getAllViews() throws Exception;  
94  
95    /**
96     * Checks if a given view exists.
97     *
98     * @param name Name of the given view.
99     * @return "True" if the given view exists. Otherwise, it returns "false".
100    * @throws Exception The exception
101    */
102   public boolean hasView(String name) throws Exception;  
103 
104   /**
105    * Gets the template home that contains all templates.
106    *
107    * @param homeAlias Alias of the template home.
108    * @param provider The session provider.
109    * @return The template home.
110    * @throws Exception The exception
111    */
112   public Node getTemplateHome(String homeAlias, SessionProvider provider) throws Exception;  
113 
114   /**
115    * Gets all templates.
116    *
117    * @param homeAlias Alias of the template home.
118    * @param provider The session provider.
119    * @return The list of templates.
120    * @throws Exception The exception
121    */
122   public List<Node> getAllTemplates(String homeAlias,SessionProvider provider) throws Exception;  
123   
124   /**
125    * Gets a template by a given path.
126    *
127    * @param path The given path.
128    * @param provider The session provider.
129    * @return The template.
130    * @throws Exception The exception
131    */
132   public Node getTemplate(String path, SessionProvider provider) throws Exception;  
133 
134   /**
135    * Adds a new template to a place with the given path.
136    *
137    * @param name Name of the new template.
138    * @param content Content of the template.
139    * @param homePath The given path.
140    * @return The new template.
141    * @throws Exception The exception
142    */
143   public String addTemplate(String name, String content, String homePath) throws Exception;
144   
145   /**
146    * Adds a new template to a place with the given path.
147    *
148    * @param name Name of the new template.
149    * @param content Content of the template.
150    * @param homePath The given path.
151    * @param provider The session provider.
152    * @return The new template.
153    * @throws Exception The exception
154    */
155   public String addTemplate(String name, String content, String homePath, SessionProvider provider) throws Exception;
156   
157   /**
158    * Updates a template at the given path.
159    *
160    * @param name Name of the updated template.
161    * @param content Content of the template.
162    * @param homePath The given path.
163    * @return The template.
164    * @throws Exception The exception
165    */
166   public String updateTemplate(String name, String content, String homePath) throws Exception;
167   
168   /**
169    * Updates a template at the given path.
170    *
171    * @param name Name of the updated template.
172    * @param content Content of the template.
173    * @param homePath The given path.
174    * @param provider The session provider.
175    * @return The template.
176    * @throws Exception The exception
177    */
178   public String updateTemplate(String name,
179                                String content,
180                                String homePath,
181                                SessionProvider provider) throws Exception;
182 
183   /**
184    * Removes a template by a given path. 
185    *
186    * @param templatePath The template path.
187    * @throws Exception The exception
188    */
189   public void removeTemplate(String templatePath) throws Exception;  
190   
191   /**
192    * Removes a template by a given path.
193    * 
194    * @param templatePath The template path.
195    * @param provider The session provider.
196    * @throws Exception The exception
197    */
198   public void removeTemplate(String templatePath, SessionProvider provider) throws Exception;
199 
200   /**
201    * Adds a new tab to the given view.
202    *
203    * @param view The given view.
204    * @param name Name of the added tab.
205    * @param buttons Buttons of the added tab.
206    * @throws Exception The exception
207    */
208   public void addTab(Node view, String name, String buttons) throws Exception ;
209 
210   /**
211    * Initializes all templates that are set in the configuration file.
212    *
213    * @throws Exception The exception
214    */
215   public void init() throws Exception ;
216   
217   /**
218    * Gets all configured templates.
219    *
220    * @return Set of configured templates.
221    */
222   public Set<String> getConfiguredTemplates();
223   
224   /**
225    * Gets all configured views.
226    *
227    * @return Set of configured views.
228    */
229   public Set<String> getConfiguredViews();
230 
231 }