Class ContentSaxer

java.lang.Object
org.ametys.cms.content.ContentSaxer
All Implemented Interfaces:
Component, Serviceable
Direct Known Subclasses:
ContentSaxer

public class ContentSaxer extends Object implements Serviceable, Component
Component responsible for generating SAX events representing a Content.
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • saxContent

      public void saxContent(Content content, ContentHandler contentHandler, Locale locale, View view, String tagName, boolean saxWorkflowStep, boolean saxWorkflowInfo, boolean saxLanguageInfo, String attributesTagName) throws SAXException
      Generates SAX events representing a Content.
      When called with a non null tag name, a surrounding element will be generated, along with XML attributes representing the content's metadata (creation/modification/validation dates and authors, ...).
      Parameters:
      content - the Content.
      contentHandler - the ContentHandler receving SAX events.
      locale - the Locale to use for eg. multilingual attributes.
      view - the View or null to select all attributes.
      tagName - the surrounding tag name or null to SAX events without root tag.
      saxWorkflowStep - if true, also produces SAX events for the current workflow step.
      saxWorkflowInfo - if true, also produces SAX events for detailed information about the current workflow step.
      saxLanguageInfo - if true, also produces SAX events for detailed information about the content language.
      attributesTagName - the name of the tag surrounding attributes. Used for legacy purposes.
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • saxContent

      public void saxContent(Content content, ContentHandler contentHandler, Locale locale, View view, String tagName, boolean saxWorkflowStep, boolean saxWorkflowInfo, boolean saxLanguageInfo, String attributesTagName, boolean isEdition, boolean renderDisableValues) throws SAXException
      Generates SAX events representing a Content.
      When called with a non null tag name, a surrounding element will be generated, along with XML attributes representing the content's metadata (creation/modification/validation dates and authors, ...).
      Parameters:
      content - the Content.
      contentHandler - the ContentHandler receving SAX events.
      locale - the Locale to use for eg. multilingual attributes.
      view - the View or null to select all attributes.
      tagName - the surrounding tag name or null to SAX events without root tag.
      saxWorkflowStep - if true, also produces SAX events for the current workflow step.
      saxWorkflowInfo - if true, also produces SAX events for detailed information about the current workflow step.
      saxLanguageInfo - if true, also produces SAX events for detailed information about the content language.
      attributesTagName - the name of the tag surrounding attributes. Used for legacy purposes.
      isEdition - true if SAX events are generated in edition mode, false otherwise
      renderDisableValues - true to render disabled values, false otherwise
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • saxBody

      protected void saxBody(Content content, ContentHandler contentHandler, Locale locale, View view, String tagName, boolean saxWorkflowStep, boolean saxWorkflowInfo, boolean saxLanguageInfo, String attributesTagName, boolean isEdition, boolean renderDisableValues) throws SAXException
      Generates SAX events for the content data.
      Parameters:
      content - the Content.
      contentHandler - the ContentHandler receving SAX events.
      locale - the Locale to use for eg. multilingual attributes.
      view - the View or null to select all attributes.
      tagName - the surrounding tag name or null to SAX events without root tag.
      saxWorkflowStep - if true, also produces SAX events for the current workflow step.
      saxWorkflowInfo - if true, also produces SAX events for detailed information about the current workflow step.
      saxLanguageInfo - if true, also produces SAX events for detailed information about the content language.
      attributesTagName - the name of the tag surrounding attributes. Used for legacy purposes.
      isEdition - true if SAX events are generated in edition mode, false otherwise
      renderDisableValues - true to render disabled values, false otherwise
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • saxRootTag

      protected void saxRootTag(Content content, ContentHandler contentHandler, Locale locale, String tagName) throws SAXException
      Generates a surrounding tag, with content metadata.
      Parameters:
      content - the Content.
      contentHandler - the ContentHandler receving SAX events.
      locale - the Locale to use for eg. multilingual attributes.
      tagName - the surrounding tag name or null to SAX events without root tag.
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • getEditionRevision

      public static String getEditionRevision(VersionableAmetysObject versionableContent)
      Get the edition revision of a content.
      Parameters:
      versionableContent - The content
      Returns:
      The current revision, or the last one if editing the head version. Can be null if editing a 0 versions content
    • saxContentTypes

      protected void saxContentTypes(Content content, ContentHandler contentHandler, boolean saxMixins) throws SAXException
      Generates SAX events for content types, and possibly mixin types
      Parameters:
      content - the Content.
      contentHandler - the ContentHandler receving SAX events.
      saxMixins - if true, also produces SAX events for mixin types.
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • saxAttributes

      protected void saxAttributes(Content content, ContentHandler contentHandler, Locale locale, View view, String tagName, String attributesTagName, boolean isEdition, boolean renderDisableValues) throws SAXException
      Generates SAX events for actual content's data.
      Parameters:
      content - the Content.
      contentHandler - the ContentHandler receving SAX events.
      locale - the Locale to use for eg. multilingual attributes.
      view - the View or null to select all attributes.
      tagName - the surrounding tag name or null to SAX events without root tag.
      attributesTagName - the name of the tag surrounding attributes. Used for legacy purposes.
      isEdition - true if SAX events are generated in edition mode, false otherwise
      renderDisableValues - true to render disabled values, false otherwise
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • saxWorkflowStep

      protected void saxWorkflowStep(Content content, ContentHandler contentHandler, boolean saxWorkflowInfo) throws SAXException
      Generates SAX events representing the current workflow step.
      Parameters:
      content - the Content.
      contentHandler - the ContentHandler receiving SAX events.
      saxWorkflowInfo - if true, also produces SAX events for detailed information about the current workflow step.
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • getCurrentStep

      protected com.opensymphony.workflow.spi.Step getCurrentStep(WorkflowAwareContent content, WorkflowProvider.AmetysObjectWorkflow workflow) throws com.opensymphony.workflow.WorkflowException
      Get the current workflow step of the content.
      Parameters:
      content - the Content.
      workflow - the associated workflow.
      Returns:
      the current step
      Throws:
      com.opensymphony.workflow.WorkflowException - if somethng got wrong processing workflow data.
    • saxLanguage

      protected void saxLanguage(Content content, ContentHandler contentHandler) throws SAXException
      Generates SAX events for the content's language.
      Parameters:
      content - the Content.
      contentHandler - the ContentHandler receving SAX events.
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • saxDublinCoreMetadata

      protected void saxDublinCoreMetadata(DublinCoreAwareAmetysObject dcObject, ContentHandler contentHandler) throws SAXException
      Generates SAX events for the DC metadata.
      Parameters:
      dcObject - the Content.
      contentHandler - the ContentHandler receving SAX events.
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • saxIfNotNull

      protected void saxIfNotNull(String name, String value, ContentHandler contentHandler) throws SAXException
      Send a value if not null.
      Parameters:
      name - the tag name.
      value - the value.
      contentHandler - the ContentHandler receving SAX events.
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • saxIfNotNull

      protected void saxIfNotNull(String name, String[] values, ContentHandler contentHandler) throws SAXException
      Send values if not null.
      Parameters:
      name - the tag name.
      values - the values.
      contentHandler - the ContentHandler receving SAX events.
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • saxIfNotNull

      protected void saxIfNotNull(String name, Date value, ContentHandler contentHandler) throws SAXException
      Send a value if not null.
      Parameters:
      name - the tag name.
      value - the value.
      contentHandler - the ContentHandler receving SAX events.
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • saxContentComments

      protected void saxContentComments(CommentableContent content, ContentHandler contentHandler) throws SAXException
      Generates SAX events for content's comments.
      Parameters:
      content - the Content.
      contentHandler - the ContentHandler receiving SAX events.
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • saxContentContributorComments

      Generates SAX events for content's contributor comments.
      Parameters:
      content - the Content.
      contentHandler - the ContentHandler receiving SAX events.
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • saxComments

      protected void saxComments(List<Comment> comments, String commentsTagName, ContentHandler contentHandler, Map<String,Object> contextualParameters) throws SAXException
      Generates SAX events for content's comments.
      Parameters:
      comments - the content's comments
      commentsTagName - the tag name of the SAX event to generate for comments
      contentHandler - the ContentHandler receiving SAX events.
      contextualParameters - the contextual parameters
      Throws:
      SAXException - if an error occurs during the SAX events generation.
    • getContextualParameters

      Get the contextual parameters
      Parameters:
      content - the content being saxed
      Returns:
      the contextual parameters
    • addAttributeIfNotNull

      protected void addAttributeIfNotNull(AttributesImpl attrs, String name, String value)
      Add attribute if value is not null
      Parameters:
      attrs - The attributes
      name - The name of attribute
      value - The value