1 /*
2 * Copyright (C) 2003-2008 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.PortletTemplatePlugin.PortletTemplateConfig;
25 import org.exoplatform.services.jcr.ext.common.SessionProvider;
26
27 /**
28 * Manages dynamic Groovy templates for the WCM-based products.
29 * All templates created by this service need to be stored in hierarchical context.<br>
30 * For example:<br>
31 * application 1 <br>
32 * /category 1 <br>
33 * /template 1 <br>
34 * /template 2 <br>
35 * /category 2
36 *
37 * @LevelAPI Experimental
38 */
39 public interface ApplicationTemplateManagerService {
40
41 public final static String CLV_PAGINATOR_TEMPLATE_CATEGORY = "paginators";
42
43 public final static String CLV_NAVIGATION_TEMPLATE_CATEGORY = "navigation";
44
45 public final static String CLV_LIST_TEMPLATE_CATEGORY = "list";
46
47 public final static String CLV_TEMPLATE_STORAGE_FOLDER = "content-list-viewer";
48
49 /**
50 * Adds a plugin.
51 *
52 * @param portletTemplatePlugin The portlet template plugin to be added.
53 * @throws Exception The exception
54 */
55 public void addPlugin(PortletTemplatePlugin portletTemplatePlugin) throws Exception;
56
57 /**
58 * Gets all portlet names that have dynamic Groovy templates managed by the service.
59 *
60 * @param repository Name of the repository.
61 * @return All managed portlet names.
62 * @throws Exception The exception
63 */
64 public List<String> getAllManagedPortletName(String repository) throws Exception;
65
66 /**
67 * Gets templates under a given category.
68 *
69 * @param portletName Name of the portet that contains the given category.
70 * @param category The given category.
71 * @param sessionProvider The session provider.
72 * @return The templates.
73 * @throws Exception The exception
74 */
75 public List<Node> getTemplatesByCategory(String portletName,
76 String category,
77 SessionProvider sessionProvider) throws Exception;
78
79 /**
80 * Gets a template by its name under a given category.
81 *
82 * @param portletName Name of the portet that contains the given category.
83 * @param category The given category.
84 * @param templateName Name of the template.
85 * @param sessionProvider The session provider.
86 * @return The template.
87 * @throws Exception The exception
88 */
89 public Node getTemplateByName(String portletName,
90 String category,
91 String templateName,
92 SessionProvider sessionProvider) throws Exception;
93
94 /**
95 * Gets a template by its path under a given category.
96 *
97 * @param templatePath Path of the template.
98 * @param sessionProvider The session provider.
99 * @return The template.
100 * @throws Exception The exception
101 */
102 public Node getTemplateByPath(String templatePath, SessionProvider sessionProvider) throws Exception;
103
104 /**
105 * Adds a template to the portlet template home.
106 *
107 * @param portletTemplateHome The portlet template home.
108 * @param config Configuration of the portlet template.
109 * @throws Exception The exception
110 */
111 public void addTemplate(Node portletTemplateHome, PortletTemplateConfig config) throws Exception;
112
113 /**
114 * Removes a template from a given portlet.
115 *
116 * @param portletName Name of the given portlet.
117 * @param catgory Category of the template which needs to be removed.
118 * @param templateName Name of the removed template.
119 * @param sessionProvider The session provider.
120 * @throws Exception The exception
121 */
122 public void removeTemplate(String portletName,
123 String catgory,
124 String templateName,
125 SessionProvider sessionProvider) throws Exception;
126
127 /**
128 * Gets the application template home.
129 *
130 * @param portletName Name of the portlet.
131 * @param provider The session provider.
132 * @return The application template home.
133 * @throws Exception The exception
134 */
135 public Node getApplicationTemplateHome(String portletName, SessionProvider provider) throws Exception;
136
137 /**
138 * Gets all configured templates of a given portlet.
139 *
140 * @param portletName Name of the given portlet.
141 * @return Set of configured templates.
142 */
143 public Set<String> getConfiguredAppTemplateMap(String portletName);
144
145 }