Class IncludeDescriptorsProcessor

java.lang.Object
org.craftercms.core.processors.impl.IncludeDescriptorsProcessor
All Implemented Interfaces:
ItemProcessor
Direct Known Subclasses:
PageAwareIncludeDescriptorsProcessor

public class IncludeDescriptorsProcessor extends Object implements ItemProcessor
ItemProcessor that finds special "include" tags found in a descriptor document and inserts there the document tree of descriptors specified in these "include" tags.
Author:
Sumer Jabri, Alfonso Vásquez
  • Field Details

    • includedItemsStack

      protected static final ThreadLocal<Stack<String>> includedItemsStack
    • includeElementXPathQuery

      protected String includeElementXPathQuery
      XPath query for the include element.
    • removeIncludeElement

      protected boolean removeIncludeElement
      Flag to indicate if the include element should be removed (false by default).
    • disabledIncludeNodeXPathQuery

      protected String disabledIncludeNodeXPathQuery
      XPath query relative to include elements for nodes tha specify if the include is disabled or not.
    • contentStoreService

      protected ContentStoreService contentStoreService
      The content store service, used to retrieve the descriptors to include.
    • includedItemsProcessor

      protected ItemProcessor includedItemsProcessor
      Processor to use for included items.
    • localeCodeXPathQuery

      protected String localeCodeXPathQuery
      XPath query for the locale code element
  • Constructor Details

    • IncludeDescriptorsProcessor

      public IncludeDescriptorsProcessor()
  • Method Details

    • setIncludeElementXPathQuery

      public void setIncludeElementXPathQuery(String includeElementXPathQuery)
      Sets the XPath query used to retrieve the include elements.
    • setRemoveIncludeElement

      public void setRemoveIncludeElement(boolean removeIncludeElement)
      Sets the flag to indicate if the include element should be removed (false by default).
    • setDisabledIncludeNodeXPathQuery

      public void setDisabledIncludeNodeXPathQuery(String disabledIncludeNodeXPathQuery)
      Sets the XPath query relative to include elements for nodes tha specify if the include is disabled or not.
    • setContentStoreService

      public void setContentStoreService(ContentStoreService contentStoreService)
      Sets the content store service, used to retrieve the descriptors to include.
    • setIncludedItemsProcessor

      public void setIncludedItemsProcessor(ItemProcessor includedItemsProcessor)
      Sets the processor to use for included items.
    • setLocaleCodeXPathQuery

      public void setLocaleCodeXPathQuery(String localeCodeXPathQuery)
    • process

      public Item process(Context context, CachingOptions cachingOptions, Item item) throws ItemProcessingException
      Replaces special include tags found in a descriptor document with the document tree of descriptors specified in these include tags. If the include tag specifies a XPath query expression (through the select attribute), only the elements returned by the query will be included.
      Specified by:
      process in interface ItemProcessor
      Parameters:
      context - the current context
      cachingOptions - caching options in case you need access to items
      item - the item to process
      Returns:
      the modified item or a new item.
      Throws:
      ItemProcessingException - if there was an error while trying to perform an include
    • includeDescriptors

      protected void includeDescriptors(Context context, CachingOptions cachingOptions, Item item) throws ItemProcessingException
      Throws:
      ItemProcessingException
    • isIncludeDisabled

      protected boolean isIncludeDisabled(org.dom4j.Element includeElement)
    • getItemToInclude

      protected Item getItemToInclude(Context context, CachingOptions cachingOptions, String includeSrcPath) throws ItemProcessingException
      Throws:
      ItemProcessingException
    • doInclude

      protected void doInclude(Item item, org.dom4j.Element includeElement, Item itemToInclude) throws ItemProcessingException
      Throws:
      ItemProcessingException
    • equals

      public boolean equals(Object o)
      Returns true if the specified IncludeDescriptorsProcessor's and this instance's fields are equal.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns the hash code for this instance, which is basically the combination of the hash code of each field. As with any other ItemProcessor, this method is defined because any processor which is passed in the method call of a ContentStoreService can be used as part of a key for caching.
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object