001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.xml.content;
029
030import org.opencms.file.CmsFile;
031import org.opencms.file.CmsObject;
032import org.opencms.file.CmsProperty;
033import org.opencms.file.CmsResource;
034import org.opencms.i18n.CmsMessages;
035import org.opencms.i18n.CmsMultiMessages.I_KeyFallbackHandler;
036import org.opencms.main.CmsException;
037import org.opencms.relations.CmsRelationType;
038import org.opencms.search.fields.CmsSearchField;
039import org.opencms.util.CmsDefaultSet;
040import org.opencms.widgets.I_CmsComplexWidget;
041import org.opencms.widgets.I_CmsWidget;
042import org.opencms.workplace.editors.directedit.I_CmsEditHandler;
043import org.opencms.xml.CmsXmlContentDefinition;
044import org.opencms.xml.CmsXmlException;
045import org.opencms.xml.containerpage.CmsFormatterConfiguration;
046import org.opencms.xml.content.CmsDefaultXmlContentHandler.InvalidRelationAction;
047import org.opencms.xml.types.I_CmsXmlContentValue;
048import org.opencms.xml.types.I_CmsXmlContentValue.SearchContentType;
049import org.opencms.xml.types.I_CmsXmlSchemaType;
050
051import java.util.Arrays;
052import java.util.Collections;
053import java.util.List;
054import java.util.Locale;
055import java.util.Map;
056import java.util.Objects;
057import java.util.Set;
058
059import javax.servlet.ServletRequest;
060
061import org.dom4j.Element;
062
063/**
064 * Handles special XML content livetime events, and also provides XML content editor rendering hints.<p>
065 *
066 * @since 6.0.0
067 */
068public interface I_CmsXmlContentHandler {
069
070    /**
071     * The available display types for element widgets.
072     */
073    public static enum DisplayType {
074        /** The two column type. */
075        column,
076
077        /** The default display type. */
078        none,
079
080        /** The single line type. */
081        singleline,
082
083        /** The default wide display type. */
084        wide
085    }
086
087    /**
088     * Settings for a JSON renderer.
089     */
090    public static class JsonRendererSettings {
091
092        /** The renderer class name. */
093        private String m_className;
094
095        /** The parameters for the renderer. */
096        private Map<String, String> m_params;
097
098        /**
099         * Creates a new instance.
100         *
101         * @param className the class name
102         * @param params the parameters
103         */
104        public JsonRendererSettings(String className, Map<String, String> params) {
105
106            m_className = className;
107            m_params = params;
108        }
109
110        /**
111         * Gets the class name.
112         *
113         * @return the class name
114         */
115        public String getClassName() {
116
117            return m_className;
118        }
119
120        /**
121         * Gets the parameters.
122         *
123         * @return the parameters
124         */
125        public Map<String, String> getParameters() {
126
127            if (m_params == null) {
128                return Collections.emptyMap();
129            }
130            return Collections.unmodifiableMap(m_params);
131        }
132
133    }
134
135    /**
136     * The available mapping types. Currently only available for searchsettings (using the "addto" attribute in the node &lt;solrfield&gt;).
137     */
138    public static enum MappingType {
139        /** Map for the content's resource. */
140        ELEMENT,
141
142        /** Map for all container pages the content is placed on. */
143        PAGE
144    }
145
146    /** Represents how values should be handled with regard to synchronization across locales in the editor. */
147    public static enum SynchronizationMode {
148        /** No synchronization. */
149        none,
150        /** Normal synchronization. */
151        standard,
152        /** Strong synchronization - a value will be synchronized even if the parent nodes are missing in the target locale. */
153        strong;
154    }
155
156    /** Mapping name for the 'date expired' mapping. */
157    String ATTRIBUTE_DATEEXPIRED = "dateexpired";
158
159    /** Mapping name for the 'date released' mapping. */
160    String ATTRIBUTE_DATERELEASED = "datereleased";
161
162    /** List of all allowed attribute mapping names, for fast lookup. */
163    List<String> ATTRIBUTES = Collections.unmodifiableList(
164        Arrays.asList(new String[] {ATTRIBUTE_DATERELEASED, ATTRIBUTE_DATEEXPIRED}));
165
166    /** Prefix for attribute mappings. */
167    String MAPTO_ATTRIBUTE = "attribute:";
168
169    /** Prefix for permission mappings. */
170    String MAPTO_PERMISSION = "permission:";
171
172    /** Prefix for property mappings. */
173    String MAPTO_PROPERTY = "property:";
174
175    /** Prefix for property mappings. */
176    String MAPTO_PROPERTY_INDIVIDUAL = MAPTO_PROPERTY + CmsProperty.TYPE_INDIVIDUAL + ":";
177
178    /** Prefix for property list mappings. */
179    String MAPTO_PROPERTY_LIST = "propertyList:";
180
181    /** Prefix for property list mappings. */
182    String MAPTO_PROPERTY_LIST_INDIVIDUAL = MAPTO_PROPERTY_LIST + CmsProperty.TYPE_INDIVIDUAL + ":";
183
184    /** Prefix for property list mappings. */
185    String MAPTO_PROPERTY_LIST_SHARED = MAPTO_PROPERTY_LIST + CmsProperty.TYPE_SHARED + ":";
186
187    /** Prefix for property mappings. */
188    String MAPTO_PROPERTY_SHARED = MAPTO_PROPERTY + CmsProperty.TYPE_SHARED + ":";
189
190    /** Prefix for URL name mappings. */
191    String MAPTO_URLNAME = "urlName";
192
193    /**
194     * Writes an availability date back to the content, if a mapping is defined for it.
195     *
196     * @param cms the CMS context
197     * @param content the content to write to
198     * @param attr the attribute to write
199     * @param locales the locales of the resource
200     * @param value the value to write
201     *
202     * @throws CmsException if something goes wrong
203     */
204    boolean applyReverseAvailabilityMapping(
205        CmsObject cms,
206        CmsXmlContent content,
207        CmsMappingResolutionContext.AttributeType attr,
208        List<Locale> locales,
209        long value)
210    throws CmsException;
211
212    /**
213     * Checks if an availability attribute should be written back to the content if the availability is changed through the availability dialog.
214     *
215     * @param attr the attribute to check
216     * @return true if the attribute should be written to the content
217     */
218    boolean canUseReverseAvailabilityMapping(CmsMappingResolutionContext.AttributeType attr);
219
220    /**
221     * Gets the list of allowed template context names.<p>
222     *
223     * @return the list of allowed template context names
224     */
225    CmsDefaultSet<String> getAllowedTemplates();
226
227    /**
228     * Gets the list of change handler configurations.
229     *
230     * @return the list of change handler configurations
231     */
232    List<CmsChangeHandlerConfig> getChangeHandlerConfigs();
233
234    /**
235     * Gets the unconfigured complex widget defined for the given path.<p>
236     *
237     * @param cms the CMS context
238     * @param path the value path
239     * @return the complex widget
240     */
241    I_CmsComplexWidget getComplexWidget(CmsObject cms, String path);
242
243    /**
244     * Returns the configuration String value for the widget used to edit the given XML content schema type.<p>
245     *
246     * If no configuration value is available, this method must return <code>null</code>.
247     *
248     * @param type the value to get the widget configuration for
249     *
250     * @return the configuration String value for the widget used to edit the given XML content schema type
251     */
252    String getConfiguration(I_CmsXmlSchemaType type);
253
254    /**
255     * Gets the widget configuration for the given sub-path.<p>
256     *
257     * @param remainingPath a sub-path
258     * @return the widget configuration for the given sub-path
259     */
260    String getConfiguration(String remainingPath);
261
262    /**
263     * Gets the configured display type for a given path.<p>
264     *
265     * @param path the path
266     * @param defaultVal the value to return if no configured display type is found
267     *
268     * @return the configured display type (or the default value)
269     */
270    DisplayType getConfiguredDisplayType(String path, DisplayType defaultVal);
271
272    /**
273     * Returns the resource-independent CSS resources to include into the html-page head.<p>
274     *
275     * @return the CSS resources to include into the html-page head
276     */
277    Set<String> getCSSHeadIncludes();
278
279    /**
280     * Returns all the CSS resources to include into the html-page head.<p>
281     *
282     * @param cms the current CMS context
283     * @param resource the resource from which to get the head includes
284     *
285     * @throws CmsException if something goes wrong
286     *
287     * @return the CSS resources to include into the html-page head
288     */
289    Set<String> getCSSHeadIncludes(CmsObject cms, CmsResource resource) throws CmsException;
290
291    /**
292     * Returns the default String value for the given XML content schema type object in the given XML content.<p>
293     *
294     * If a schema type does not have a default value, this method must return <code>null</code>.
295     *
296     * @param cms the current users OpenCms context
297     * @param resource the content resource
298     * @param type the type to get the default for
299     * @param path the element path
300     * @param locale the currently selected locale for the value
301     *
302     * @return the default String value for the given XML content value object
303     *
304     * @see org.opencms.xml.types.I_CmsXmlSchemaType#getDefault(Locale)
305     */
306    String getDefault(CmsObject cms, CmsResource resource, I_CmsXmlSchemaType type, String path, Locale locale);
307
308    /**
309     * Returns the default String value for the given XML content schema type object in the given XML content.<p>
310     *
311     * If a schema type does not have a default value, this method must return <code>null</code>.
312     *
313     * @param cms the current users OpenCms context
314     * @param value the value to get the default for
315     * @param locale the currently selected locale for the value
316     *
317     * @return the default String value for the given XML content value object
318     *
319     * @see org.opencms.xml.types.I_CmsXmlSchemaType#getDefault(Locale)
320     */
321    String getDefault(CmsObject cms, I_CmsXmlContentValue value, Locale locale);
322
323    /**
324     * Gets the default complex widget to be used for this type.<p>
325     *
326     * @return the default complex widget for this type
327     */
328    I_CmsComplexWidget getDefaultComplexWidget();
329
330    /**
331     * Gets the default complex widget class name configured for this type.<p>
332     *
333     * @return the default complex widget class name
334     */
335    String getDefaultComplexWidgetClass();
336
337    /**
338     * Gets the default complex widget configuration string configured for this type.<p>
339     *
340     * @return the default complex widget configuration string
341     */
342    String getDefaultComplexWidgetConfiguration();
343
344    /**
345     * Returns if the widget for this type should be displayed in compact view.<p>
346     *
347     * @param type the value to check the view mode for
348     *
349     * @return the widgets display type
350     */
351    DisplayType getDisplayType(I_CmsXmlSchemaType type);
352
353    /**
354     * Returns the edit handler if configured.<p>
355     *
356     * @return the edit handler
357     */
358    I_CmsEditHandler getEditHandler();
359
360    /**
361     * Returns the editor change handlers.<p>
362     *
363     * @param selfOnly if true, only return editor change handlers configured directly for this content handler
364     * @return the editor change handlers
365     */
366    List<I_CmsXmlContentEditorChangeHandler> getEditorChangeHandlers(boolean selfOnly);
367
368    /**
369     * Returns the container page element formatter configuration for a given resource.<p>
370     *
371     * @param cms the current users OpenCms context, used for selecting the right project
372     * @param res the resource for which the formatter configuration should be retrieved
373     *
374     * @return the container page element formatter configuration for this handler
375     */
376    CmsFormatterConfiguration getFormatterConfiguration(CmsObject cms, CmsResource res);
377
378    /**
379     * Gets the geo-coordinate mapping configuration.
380     *
381     * @return the geo-coordinate mapping configuration
382     */
383    CmsGeoMappingConfiguration getGeoMappingConfiguration();
384
385    /**
386     * Gets the action to perform if the given name refers to a link field which refers to a VFS file that no longer exists.
387     *
388     * @param name the field name
389     * @return the action
390     */
391    default InvalidRelationAction getInvalidRelationAction(String name) {
392
393        return null;
394    }
395
396    /**
397     * Returns the resource-independent javascript resources to include into the html-page head.<p>
398     *
399     * @return the javascript resources to include into the html-page head
400     */
401    Set<String> getJSHeadIncludes();
402
403    /**
404     * Returns all the javascript resources to include into the html-page head.<p>
405     *
406     * @param cms the current CMS context
407     * @param resource the resource for which the head includes should be retrieved
408     *
409     * @return the javascript resources to include into the html-page head
410     *
411     * @throws CmsException if something goes wrong
412     */
413    Set<String> getJSHeadIncludes(CmsObject cms, CmsResource resource) throws CmsException;
414
415    /**
416     * Gets the JSON renderer settings.
417     *
418     * @return the JSON renderer settings
419     */
420    JsonRendererSettings getJsonRendererSettings();
421
422    /**
423     * Gets the mappings defined in the schema.
424     *
425     * @return the mappings
426     */
427    Map<String, List<String>> getMappings();
428
429    /**
430     * Returns the all mappings defined for the given element xpath.<p>
431     *
432     * @param elementName the element xpath to look up the mapping for
433     *
434     * @return the mapping defined for the given element xpath
435     */
436    List<String> getMappings(String elementName);
437
438    /**
439     * Gets the message key fallback handler.<p>
440     *
441     * This is used to automatically provide fallbacks for missing message keys in the editor.<p>
442     *
443     * @return the message key fallback handler
444     */
445    I_KeyFallbackHandler getMessageKeyHandler();
446
447    /**
448     * Returns the {@link CmsMessages} that are used to resolve localized keys
449     * for the given locale in this content handler.<p>
450     *
451     * If no localized messages are configured for this content handler,
452     * this method returns <code>null</code>.<p>
453     *
454     * @param locale the locale to get the messages for
455     *
456     * @return the {@link CmsMessages} that are used to resolve localized keys
457     * for the given locale in this content handler
458     */
459    CmsMessages getMessages(Locale locale);
460
461    /**
462     * Returns the folder name that contains eventual XML content model files to use for this resource type.<p>
463     *
464     * @return the folder name containing eventual XML content master files
465     */
466    String getModelFolder();
467
468    /**
469     * Returns the nested formatters for the given resource.<p>
470     *
471     * @param cms the cms context
472     * @param res the resource
473     * @param locale the content locale
474     * @param req the request if available
475     *
476     * @return the nested formatter ids
477     */
478    List<String> getNestedFormatters(CmsObject cms, CmsResource res, Locale locale, ServletRequest req);
479
480    /**
481    * Gets the parameter with the given name..<p>
482    *
483    * @param param the parameter name
484    * @return the parameter value
485    */
486    String getParameter(String param);
487
488    /**
489     * Returns the preview URI for the given XML content value object to be displayed in the editor.<p>
490     *
491     * If <code>null</code> is returned, no preview is possible for contents using this handler.<p>
492     *
493     * @param cms the current OpenCms user context
494     * @param content the XML content to display the preview URI for
495     * @param resourcename the name in the VFS of the resource that is currently edited
496     *
497     * @return the preview URI for the given XML content value object to be displayed in the editor
498     */
499    String getPreview(CmsObject cms, CmsXmlContent content, String resourcename);
500
501    /**
502     * Returns the relation type for the given value.<p>
503     *
504     * @param value the value to get the relation type for
505     *
506     * @return the relation type for the given value
507     *
508     * @deprecated use {@link #getRelationType(String)} with {@link I_CmsXmlContentValue#getPath()} instead
509     */
510    @Deprecated
511    CmsRelationType getRelationType(I_CmsXmlContentValue value);
512
513    /**
514     * Returns the relation type for the given path.<p>
515     *
516     * @param path the path to get the relation type for
517     *
518     * @return the relation type for the given path
519     */
520    CmsRelationType getRelationType(String path);
521
522    /**
523     * Returns the relation type for the given path.<p>
524     *
525     * @param xpath the path to get the relation type for
526     * @param defaultType the default type if none is set
527     *
528     * @return the relation type for the given path
529     */
530    CmsRelationType getRelationType(String xpath, CmsRelationType defaultType);
531
532    /**
533     * Returns the search content type, ie., the way how to integrate the value into full text search.<p>
534     *
535     * For the full text search, the value of all elements in one locale of the XML content are combined
536     * to one big text, which is referred to as the "content" in the context of the full text search.
537     * With this option, it is possible to hide certain elements from this "content" that does not make sense
538     * to include in the full text search.<p>
539     *
540     * Moreover, if the value contains a link to another resource, the content of that other resource can be added.
541     *
542     * @param value the XML content value to check
543     *
544     * @return the search content type, indicating how the element should be added to the content for the full text search
545     */
546    SearchContentType getSearchContentType(I_CmsXmlContentValue value);
547
548    /**
549     * Returns all configured Search fields for this XML content.<p>
550     *
551     * @return the Search fields for this XMl content
552     */
553    Set<CmsSearchField> getSearchFields();
554
555    /**
556     * Returns all configured Search fields for this XML content that should be attached to container pages the content is placed on.<p>
557     *
558     * @return the Search fields for this XMl content
559     */
560    Set<CmsSearchField> getSearchFieldsForPage();
561
562    /**
563     * Returns the search content settings defined in the annotation node of this XML content.<p>
564     *
565     * A search setting defined within the xsd:annotaion node of an XML schema definition can look like:<p>
566     * <code>&lt;searchsetting element="Image/Align" searchContent="false"/&gt;</code><p>
567     *
568     * The returned map contains the 'element' attribute value as keys and the 'searchContent'
569     * attribute value as values.<p>
570     *
571     * @return the search field settings for this XML content schema
572     */
573    Map<String, SearchContentType> getSearchSettings();
574
575    /**
576     * Returns the element settings defined for the container page formatters.<p>
577     *
578     * @param cms the current CMS context
579     * @param resource the resource for which to get the setting definitions
580     *
581     * @return the element settings defined for the container page formatters
582     */
583    Map<String, CmsXmlContentProperty> getSettings(CmsObject cms, CmsResource resource);
584
585    /**
586     * Returns the configuration for elements that require a synchronization across all locales.<p>
587     *
588     * @param recursive if true, recursively combines all synchronization information from nested schemas, otherwise only returns the synchronizations for this schema
589     * @return the synchronization information
590     */
591    CmsSynchronizationSpec getSynchronizations(boolean recursive);
592
593    /**
594     * Returns the tabs to be displayed in the editor.<p>
595     *
596     * @return the tabs to be displayed in the editor
597     */
598    List<CmsXmlContentTab> getTabs();
599
600    /**
601     * Returns the "Title" mapping set for the given XML content document in the given Locale.<p>
602     *
603     * @param cms the current OpenCms user context
604     * @param document the XML content to get the title mapping for (this must be of a type that uses this handler)
605     * @param locale the locale to get the title mapping for
606     *
607     * @return the "Title" mapping set for the given XML content document in the given Locale
608     */
609    String getTitleMapping(CmsObject cms, CmsXmlContent document, Locale locale);
610
611    /**
612     * Gets the version transformation VFS path.
613     *
614     * <p>If schema versions are used, the the XSLT transformation read from this VFS path is used to transform contents
615     * of older versions into the current version.
616     *
617     * @return the VFS path to read an XSLT file for version transformation from
618     */
619    String getVersionTransformation();
620
621    /**
622     * Gets the widget for the given path and CMS context.
623     *
624     * @param cms the current CMS context
625     * @param path the XML value path
626     * @return the widget for the path
627     */
628    I_CmsWidget getWidget(CmsObject cms, String path);
629
630    /**
631     * Returns the editor widget that should be used for the given XML content value.<p>
632     *
633     * The handler implementations should use the "appinfo" node of the XML content definition
634     * schema to define the mappings of elements to widgets.<p>
635     *
636     * @param value the XML content value to get the widget for
637     *
638     * @return the editor widget that should be used for the given XML content value
639     *
640     * @throws CmsXmlException if something goes wrong
641     */
642    @Deprecated
643    I_CmsWidget getWidget(I_CmsXmlSchemaType value) throws CmsXmlException;
644
645    /**
646     * Returns true if the contents for this content handler have schema-based formatters which can be disabled or enabled.<p>
647     *
648     * @return true if the contents for this content handler have schema-based formatters which can be disabled or enabled
649     */
650    boolean hasModifiableFormatters();
651
652    /**
653     * Returns whether there are nested formatters configured for this content type.<p>
654     *
655     * @return <code>true</code> if there are nested formatters configured for this content type
656     */
657    boolean hasNestedFormatters();
658
659    /**
660     * Returns if there are locale synchronized elements configured.<p>
661     *
662     * @return <code>true</code> if there are locale synchronized elements configured
663     */
664    boolean hasSynchronizedElements();
665
666    /**
667     * Returns if there are visibility handlers configured for this content type.<p>
668     *
669     * @return <code>true</code> if there are visibility handlers configured for this content type
670     */
671    boolean hasVisibilityHandlers();
672
673    /**
674     * Initializes this content handler for the given XML content definition by
675     * analyzing the "appinfo" node.<p>
676     *
677     * @param appInfoElement the "appinfo" element root node to analyze
678     * @param contentDefinition the XML content definition that XML content handler belongs to
679     *
680     * @throws CmsXmlException if something goes wrong
681     */
682    void initialize(Element appInfoElement, CmsXmlContentDefinition contentDefinition) throws CmsXmlException;
683
684    /**
685     * Performs a check of the given XML document.<p>
686     *
687     * The main difference to the {@link #resolveValidation(CmsObject, I_CmsXmlContentValue, CmsXmlContentErrorHandler)}
688     * method is that this method may silently remove some values, for instance, for broken links.<p>
689     *
690     * @param cms the current OpenCms user context
691     * @param document the document to resolve the check rules for
692     */
693    void invalidateBrokenLinks(CmsObject cms, CmsXmlContent document);
694
695    /**
696     * Checks whether the Acacia editor is disabled for this type.<p>
697     *
698     * @return true if the Acacia editor is disabled
699     */
700    boolean isAcaciaEditorDisabled();
701
702    /**
703     * Returns <code>true</code> if the XML content should be indexed when it is dropped in a container page,
704     * and returns <code>false</code> if this XML content should be indexed as 'stand-alone' document.<p>
705     *
706     * This flag is intended by excluding XML contents from the search index that are not used as detail pages,
707     * but to index those extraction result when they are part of a container page.<p>
708     *
709     * In order to set this falg add an attribute <code>containerpageOnly="true"</code> to the
710     * <code>'&lt;searchsettings&gt;-node'</code> of the XSD of the resource type you want to be indexed only
711     * when it is part of a container page.<p>
712     *
713     * @return the container page only flag
714     */
715    boolean isContainerPageOnly();
716
717    /**
718     * Returns <code>true</code> in case the given value should be searchable with
719     * the integrated full text search.<p>
720     *
721     * For the full text search, the value of all elements in one locale of the XML content are combined
722     * to one big text, which is referred to as the "content" in the context of the full text search.
723     * With this option, it is possible to hide certain elements from this "content" that does not make sense
724     * to include in the full text search.<p>
725     *
726     * @param value the XML content value to check
727     *
728     * @return <code>true</code> in case the given value should be searchable
729     *
730     * @deprecated use {@link #getSearchContentType(I_CmsXmlContentValue)} instead. Will be removed if plain lucene search is removed.
731     */
732    @Deprecated
733    default boolean isSearchable(I_CmsXmlContentValue value) {
734
735        return Objects.equals(getSearchContentType(value), SearchContentType.TRUE);
736    }
737
738    /**
739     * Returns if the given content field should be visible to the current user.<p>
740     *
741     * @param cms the cms context
742     * @param schemaType the content value type
743     * @param valuePath the value path
744     * @param resource the edited resource
745     * @param contentLocale the content locale
746     *
747     * @return <code>true</code> if the given content field should be visible to the current user
748     */
749    boolean isVisible(
750        CmsObject cms,
751        I_CmsXmlSchemaType schemaType,
752        String valuePath,
753        CmsResource resource,
754        Locale contentLocale);
755
756    /**
757     * Prepares the given XML content to be used after it was read from the OpenCms VFS.<p>
758     *
759     * This method is always called after any content is unmarshalled.
760     * It can be used to perform customized actions on the given XML content.<p>
761     *
762     * @param cms the current OpenCms user context
763     * @param content the XML content to be used as read from the VFS
764     *
765     * @return the prepared content to be used
766     */
767    CmsXmlContent prepareForUse(CmsObject cms, CmsXmlContent content);
768
769    /**
770     * Prepares the given XML content to be written to the OpenCms VFS.<p>
771     *
772     * This method is always called before any content gets written.
773     * It can be used to perform XML validation, pretty - printing
774     * or customized actions on the given XML content.<p>
775     *
776     * @param cms the current OpenCms user context
777     * @param content the XML content to be written
778     * @param file the resource the XML content in it's current state was unmarshalled from
779     *
780     * @return the file to write to the OpenCms VFS, this will be an updated version of the parameter file
781     *
782     * @throws CmsException in case something goes wrong
783     */
784    CmsFile prepareForWrite(CmsObject cms, CmsXmlContent content, CmsFile file) throws CmsException;
785
786    /**
787     * Resolves the value mappings of the given XML content value, according
788     * to the rules of this XML content handler.<p>
789     *
790     * @param cms the current OpenCms user context
791     * @param content the XML content to resolve the mappings for
792     * @param value the value to resolve the mappings for
793     *
794     * @throws CmsException if something goes wrong
795     */
796    void resolveMapping(CmsObject cms, CmsXmlContent content, I_CmsXmlContentValue value) throws CmsException;
797
798    /**
799     * Performs a validation of the given XML content value, and saves all errors or warnings found in
800     * the provided XML content error handler.<p>
801     *
802     * The errorHandler parameter is optional, if <code>null</code> is given a new error handler
803     * instance must be created.<p>
804     *
805     * @param cms the current OpenCms user context
806     * @param value the value to resolve the validation rules for
807     * @param errorHandler (optional) an error handler instance that contains previous error or warnings
808     *
809     * @return an error handler that contains all errors and warnings currently found
810     */
811    CmsXmlContentErrorHandler resolveValidation(
812        CmsObject cms,
813        I_CmsXmlContentValue value,
814        CmsXmlContentErrorHandler errorHandler);
815
816}