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