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.metadata;
18
19 import java.util.List;
20
21 import javax.jcr.Node;
22 import javax.jcr.RepositoryException;
23 import javax.jcr.nodetype.NodeType;
24
25
26 /**
27 * Author : Hung Nguyen Quang
28 * nguyenkequanghung@yahoo.com
29 * Process with meta data for system
30 */
31
32 public interface MetadataService {
33
34 /**
35 * Get name of all NodeType in current repository
36 * @return ArrayList of name
37 * @see #getAllMetadatasNodeType()
38 */
39 public List<String> getMetadataList() throws Exception;
40
41 /**
42 * Get all NodeType in current repository with NodeType = exo:metadata
43 * @return ArrayList of NodeType
44 */
45 public List<NodeType> getAllMetadatasNodeType() throws Exception;
46
47 /**
48 * Add new nodetype and set property EXO_ROLES_PROP, EXO_TEMPLATE_FILE_PROP
49 * for dialog template node or view template node if node doesn't exist
50 * Set property EXO_ROLES_PROP, EXO_TEMPLATE_FILE_PROP
51 * for dialog template node or view template node if node exists
52 * @param nodetype Node name for processing
53 * @param isDialog true for dialog template
54 * @param role permission
55 * @param content content of template
56 * @param isAddNew false if nodetype exist in repository, true if not
57 * @return path to node if node exist, otherwise return null
58 * @throws Exception
59 */
60 public String addMetadata(String nodetype,
61 boolean isDialog,
62 String role,
63 String content,
64 boolean isAddNew) throws Exception;
65
66 /**
67 * Add new nodetype and set property EXO_ROLES_PROP, EXO_TEMPLATE_FILE_PROP
68 * for dialog template node or view template node if node doesn't exist
69 * Set property EXO_ROLES_PROP, EXO_TEMPLATE_FILE_PROP
70 * for dialog template node or view template node if node exists
71 * @param nodetype Node name for processing
72 * @param isDialog true for dialog template
73 * @param role permission
74 * @param content content of template
75 * @param label lable of metadata
76 * @param isAddNew false if nodetype exist in repository, true if not
77 * @return path to node if node exist, otherwise return null
78 * @throws Exception
79 */
80 public String addMetadata(String nodetype,
81 boolean isDialog,
82 String role,
83 String content,
84 String label,
85 boolean isAddNew) throws Exception;
86
87 /**
88 * Remove node named nodetype below baseMetadataPath_
89 * @param nodetype name of node
90 */
91 public void removeMetadata(String nodetype) throws Exception;
92
93 /**
94 * Get all NodeType name that contains property that is not autocreated
95 * and name of NodeType differs from exo:metadata
96 * @return ArrayList of metadata type
97 */
98 public List<String> getExternalMetadataType() throws Exception;
99
100 /**
101 * Get content of dialog template node or view template in current repository
102 * @param name Node name
103 * @param isDialog true: Get dialog template content
104 * false: Get view template content
105 * @return content of template
106 */
107 public String getMetadataTemplate(String name, boolean isDialog) throws Exception;
108
109 /**
110 * Get path to dialog template or view tempate node
111 * @param name Node name
112 * @param isDialog true: Get dialog template content
113 * false: Get view template content
114 * @return path to template node
115 */
116 public String getMetadataPath(String name, boolean isDialog) throws Exception;
117
118 /**
119 * Get permission of template node
120 * @param name Node name
121 * @param isDialog true: Get dialog template content
122 * false: Get view template content
123 * @return String of permission
124 */
125 public String getMetadataRoles(String name, boolean isDialog) throws Exception;
126
127 /**
128 * Check node with given name exists or not below baseMetadataPath_ path in repository
129 * @param name Node name
130 * @return true : Exist this node name<br>
131 * false: Not exist this node name
132 */
133 public boolean hasMetadata(String name) throws Exception;
134
135 /**
136 * Call all available in list of TemplatePlugin to
137 * add some predefine template to current repository.
138 * @throws Exception
139 */
140 public void init() throws Exception ;
141
142 /**
143 * Get the metadata node based on its name
144 * @param metaName Name of metadata
145 * @return Node instance of give metadata
146 * @throws Exception
147 */
148 public Node getMetadata(String metaName) throws Exception;
149
150 /**
151 * Get metadata label based on its name
152 * @param metaName Name of metadata
153 * @return Label of given metadata
154 * @throws Exception
155 */
156 public String getMetadataLabel(String metaName) throws Exception;
157
158 }