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.i18n;
18  
19  import java.util.List;
20  import java.util.Map;
21  
22  import javax.jcr.Node;
23  import javax.jcr.Value;
24  
25  
26  /**
27   * Author : Hung Nguyen Quang
28   *          nguyenkequanghung@yahoo.com
29   */
30  
31  public interface MultiLanguageService {
32  
33    /**
34     * Node name as LANGUAGES
35     */
36    final static public String LANGUAGES    = "languages";
37  
38    /**
39     * Property name as EXO_LANGUAGE
40     */
41    final static public String EXO_LANGUAGE = "exo:language";
42  
43    /**
44     * Node name as COMMENTS
45     */
46    final static public String COMMENTS     = "comments";
47  
48    /**
49     * Get list of value in exo:language property in child node of current node
50     * @param node    current node
51     * @return value of exo:language property
52     */
53    public List<String> getSupportedLanguages(Node node) throws Exception;
54  
55    /**
56     * Set data for current node
57     * @param node              current node
58     * @param language          language name
59     * @param repositoryName    repository name
60     * @throws Exception
61     */
62    public void setDefault(Node node, String language, String repositoryName) throws Exception;
63  
64    /**
65     * Add new language for current node
66     * Set value of property in inputs Map to new language node
67     * @param node            current node
68     * @param inputs          Map includes key and value of property
69     * @param language        language name
70     * @param isDefault       flag to define default language is used or not
71     * @throws Exception
72     */
73    public void addLanguage(Node node, Map inputs, String language, boolean isDefault) throws Exception;
74  
75    /**
76     * Add new language for current node
77     * Processing for some new added node
78     * Set value of property in inputs Map to new language node
79     * Processing for nodeType in child node of current node and some new added node
80     * @param node            current node
81     * @param inputs          Map includes key and value of property
82     * @param language        language name
83     * @param isDefault       flag to define default language is used or not
84     * @param nodeType        node name
85     * @throws Exception
86     */
87    public void addLanguage(Node node, Map inputs, String language, boolean isDefault, String nodeType) throws Exception;
88  
89    /**
90     * Add newLanguageNode node, then add new file to newLanguageNode
91     * @param node              current node
92     * @param fileName          name of file
93     * @param value             value of file
94     * @param mimeType          mimiType
95     * @param language          language name
96     * @param repositoryName    repository name
97     * @param isDefault         flag to use new language or default language
98     * @throws Exception
99     */
100   public void addFileLanguage(Node node,
101                               String fileName,
102                               Value value,
103                               String mimeType,
104                               String language,
105                               String repositoryName,
106                               boolean isDefault) throws Exception;
107 
108   /**
109    * Add newLanguageNode node, then set property in mapping to newLanguageNode
110    * @param node              current node
111    * @param language          language name
112    * @param mappings          Map includes property and value
113    * @param isDefault         flag to use new language or default language
114    * @throws Exception
115    */
116   public void addFileLanguage(Node node, String language, Map mappings, boolean isDefault) throws Exception;
117 
118 
119   /**
120    * Add newLanguageNode node with a symlink, based on exo:language targetNode property
121    * @param node              current node
122    * @param translationNode   target translation node
123    * @throws Exception
124    */
125   public void addLinkedLanguage(Node node, Node translationNode) throws Exception;
126   
127   /**
128    * Add newLanguageNode node with a symlink, based on exo:language targetNode property
129    * @param node              current node
130    * @param translationNode   target translation node
131    * @param overrideExistence   true if override existing symlink pointing to other translation, else throw ItemExistsException 
132    * @throws Exception
133    */
134   public void addLinkedLanguage(Node node, Node translationNode, boolean overrideExistence) throws Exception;
135 
136   /**
137    * Add new translation for one node and synchronize all related translation nodes.
138    * 
139    * @param selectedNode Selected Node
140    * @param newTranslationNode New Translation Node
141    * @throws Exception
142    */
143   public void addSynchronizedLinkedLanguage(Node selectedNode, Node newTranslationNode) throws Exception;
144   
145   /**
146    * Add new language node as a folder
147    * @param node
148    * @param inputs
149    * @param language
150    * @param isDefault
151    * @param nodeType
152    * @param repositoryName
153    * @throws Exception
154    */
155   public void addFolderLanguage(Node node,
156                                 Map inputs,
157                                 String language,
158                                 boolean isDefault,
159                                 String nodeType,
160                                 String repositoryName) throws Exception;
161 
162   /**
163    * Get value of property exo:language in current node
164    * @param node    current node
165    * @return value of exo:language property
166    */
167   public String getDefault(Node node) throws Exception;
168 
169   /**
170    * Get node following relative path = "languages/" + language
171    * @param node
172    * @param language
173    * @return node if exist node with relative path = "languages/" + language with current node
174    *         null if not exist
175    */
176   public Node getLanguage(Node node, String language) throws Exception;
177 
178 
179 }