KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > xml > content > I_CmsXmlContentHandler


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/xml/content/I_CmsXmlContentHandler.java,v $
3  * Date : $Date: 2006/03/27 14:52:36 $
4  * Version: $Revision: 1.24 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.xml.content;
33
34 import org.opencms.file.CmsFile;
35 import org.opencms.file.CmsObject;
36 import org.opencms.file.CmsProperty;
37 import org.opencms.i18n.CmsMessages;
38 import org.opencms.main.CmsException;
39 import org.opencms.widgets.I_CmsWidget;
40 import org.opencms.xml.CmsXmlContentDefinition;
41 import org.opencms.xml.CmsXmlException;
42 import org.opencms.xml.types.I_CmsXmlContentValue;
43 import org.opencms.xml.types.I_CmsXmlSchemaType;
44
45 import java.util.Arrays JavaDoc;
46 import java.util.Collections JavaDoc;
47 import java.util.List JavaDoc;
48 import java.util.Locale JavaDoc;
49
50 import org.dom4j.Element;
51
52 /**
53  * Handles special XML content livetime events, and also provides XML content editor rendering hints.<p>
54  *
55  * @author Alexander Kandzior
56  *
57  * @version $Revision: 1.24 $
58  *
59  * @since 6.0.0
60  */

61 public interface I_CmsXmlContentHandler {
62
63     /** Array of all allowed attribute mapping names. */
64     String JavaDoc[] ATTRIBUTE_ARRAY = {"datereleased", "dateexpired"};
65
66     /** List of all allowed attribute mapping names, for fast lookup. */
67     List JavaDoc ATTRIBUTES = Collections.unmodifiableList(Arrays.asList(ATTRIBUTE_ARRAY));
68
69     /** Prefix for attribute mappings. */
70     String JavaDoc MAPTO_ATTRIBUTE = "attribute:";
71
72     /** Prefix for property mappings. */
73     String JavaDoc MAPTO_PROPERTY = "property:";
74
75     /** Prefix for property mappings. */
76     String JavaDoc MAPTO_PROPERTY_INDIVIDUAL = MAPTO_PROPERTY + CmsProperty.TYPE_INDIVIDUAL + ":";
77
78     /** Prefix for property list mappings. */
79     String JavaDoc MAPTO_PROPERTY_LIST = "propertyList:";
80
81     /** Prefix for property list mappings. */
82     String JavaDoc MAPTO_PROPERTY_LIST_INDIVIDUAL = MAPTO_PROPERTY_LIST + CmsProperty.TYPE_INDIVIDUAL + ":";
83
84     /** Prefix for property list mappings. */
85     String JavaDoc MAPTO_PROPERTY_LIST_SHARED = MAPTO_PROPERTY_LIST + CmsProperty.TYPE_SHARED + ":";
86
87     /** Prefix for property mappings. */
88     String JavaDoc MAPTO_PROPERTY_SHARED = MAPTO_PROPERTY + CmsProperty.TYPE_SHARED + ":";
89
90     /**
91      * Returns the configuration String value for the widget used to edit the given XML content schema type.<p>
92      *
93      * If no configuration value is available, this method must return <code>null</code>.
94      *
95      * @param type the value to get the widget configuration for
96      *
97      * @return the configuration String value for the widget used to edit the given XML content schema type
98      */

99     String JavaDoc getConfiguration(I_CmsXmlSchemaType type);
100
101     /**
102      * Returns the default String value for the given XML content schema type object in the given XML content.<p>
103      *
104      * If a schema type does not have a default value, this method must return <code>null</code>.
105      *
106      * @param cms the current users OpenCms context
107      * @param value the value to get the default for
108      * @param locale the currently selected locale for the value
109      *
110      * @return the default String value for the given XML content value object
111      *
112      * @see org.opencms.xml.types.I_CmsXmlSchemaType#getDefault(Locale)
113      */

114     String JavaDoc getDefault(CmsObject cms, I_CmsXmlContentValue value, Locale JavaDoc locale);
115
116     /**
117      * Returns the {@link CmsMessages} that are used to resolve localized keys
118      * for the given locale in this content handler.<p>
119      *
120      * If no localized messages are configured for this content handler,
121      * this method returns <code>null</code>.<p>
122      *
123      * @param locale the locale to get the messages for
124      *
125      * @return the {@link CmsMessages} that are used to resolve localized keys
126      * for the given locale in this content handler
127      */

128     CmsMessages getMessages(Locale JavaDoc locale);
129
130     /**
131      * Returns the preview URI for the given XML content value object to be displayed in the editor.<p>
132      *
133      * If <code>null</code> is returned, no preview is possible for contents using this handler.<p>
134      *
135      * @param cms the current OpenCms user context
136      * @param content the XML content to display the preview URI for
137      * @param resourcename the name in the VFS of the resource that is currently edited
138      *
139      * @return the preview URI for the given XML content value object to be displayed in the editor
140      */

141     String JavaDoc getPreview(CmsObject cms, CmsXmlContent content, String JavaDoc resourcename);
142
143     /**
144      * Returns the editor widget that should be used for the given XML content value.<p>
145      *
146      * The handler implementations should use the "appinfo" node of the XML content definition
147      * schema to define the mappings of elements to widgets.<p>
148      *
149      * @param value the XML content value to get the widget for
150      *
151      * @return the editor widget that should be used for the given XML content value
152      *
153      * @throws CmsXmlException if something goes wrong
154      */

155     I_CmsWidget getWidget(I_CmsXmlContentValue value) throws CmsXmlException;
156
157     /**
158      * Initializes this content handler for the given XML content definition by
159      * analyzing the "appinfo" node.<p>
160      *
161      * @param appInfoElement the "appinfo" element root node to analyze
162      * @param contentDefinition the XML content definition that XML content handler belongs to
163      *
164      * @throws CmsXmlException if something goes wrong
165      */

166     void initialize(Element appInfoElement, CmsXmlContentDefinition contentDefinition) throws CmsXmlException;
167
168     /**
169      * Prepares the given XML content to be written to the OpenCms VFS.<p>
170      *
171      * This method is alway called before any content gets written.
172      * It can be used to perform XML validation, pretty - printing
173      * or customized actions on the given XML content.<p>
174      *
175      * @param cms the current OpenCms user context
176      * @param content the XML content to be written
177      * @param file the resource the XML content in it's current state was unmarshalled from
178      *
179      * @return the file to write to the OpenCms VFS, this will be an updated vresion of the parameter file
180      *
181      * @throws CmsException in case something goes wrong
182      */

183     CmsFile prepareForWrite(CmsObject cms, CmsXmlContent content, CmsFile file) throws CmsException;
184
185     /**
186      * Resolves the value mappings of the given XML content value, according
187      * to the rules of this XML content handler.<p>
188      *
189      * @param cms the current OpenCms user context
190      * @param content the XML content to resolve the mappings for
191      * @param value the value to resolve the mappings for
192      *
193      * @throws CmsException if something goes wrong
194      */

195     void resolveMapping(CmsObject cms, CmsXmlContent content, I_CmsXmlContentValue value) throws CmsException;
196
197     /**
198      * Performs a validation of the given XML content value, and saves all errors or warnings found in
199      * the provided XML content error handler.<p>
200      *
201      * The errorHandler parameter is optional, if <code>null</code> is given a new error handler
202      * instance must be created.<p>
203      *
204      * @param cms the current OpenCms user context
205      * @param value the value to resolve the validation rules for
206      * @param errorHandler (optional) an error handler instance that contains previous error or warnings
207      *
208      * @return an error handler that contains all errors and warnings currently found
209      */

210     CmsXmlContentErrorHandler resolveValidation(
211         CmsObject cms,
212         I_CmsXmlContentValue value,
213         CmsXmlContentErrorHandler errorHandler);
214 }
Popular Tags