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