Package org.ametys.cms.content
Class ContentSaxer
java.lang.Object
org.ametys.cms.content.ContentSaxer
- All Implemented Interfaces:
Component
,Serviceable
- Direct Known Subclasses:
ContentSaxer
Component responsible for generating SAX events representing a
Content
.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAttributeIfNotNull
(AttributesImpl attrs, String name, String value) Add attribute if value is not nullgetContextualParameters
(Content content) Get the contextual parametersprotected com.opensymphony.workflow.spi.Step
getCurrentStep
(WorkflowAwareContent content, WorkflowProvider.AmetysObjectWorkflow workflow) Get the current workflow step of the content.static String
getEditionRevision
(VersionableAmetysObject versionableContent) Get the edition revision of a content.protected void
saxAttributes
(Content content, ContentHandler contentHandler, Locale locale, View view, String tagName, String attributesTagName, boolean isEdition, boolean renderDisableValues) Generates SAX events for actual content's data.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) Generates SAX events for the content data.protected void
saxComments
(List<Comment> comments, String commentsTagName, ContentHandler contentHandler, Map<String, Object> contextualParameters) Generates SAX events for content's comments.void
saxContent
(Content content, ContentHandler contentHandler, Locale locale, View view, String tagName, boolean saxWorkflowStep, boolean saxWorkflowInfo, boolean saxLanguageInfo, String attributesTagName) Generates SAX events representing aContent
.void
saxContent
(Content content, ContentHandler contentHandler, Locale locale, View view, String tagName, boolean saxWorkflowStep, boolean saxWorkflowInfo, boolean saxLanguageInfo, String attributesTagName, boolean isEdition, boolean renderDisableValues) Generates SAX events representing aContent
.protected void
saxContentComments
(CommentableContent content, ContentHandler contentHandler) Generates SAX events for content's comments.protected void
saxContentContributorComments
(ContributorCommentableContent content, ContentHandler contentHandler) Generates SAX events for content's contributor comments.protected void
saxContentTypes
(Content content, ContentHandler contentHandler, boolean saxMixins) Generates SAX events forcontent types
, and possiblymixin types
protected void
saxDublinCoreMetadata
(DublinCoreAwareAmetysObject dcObject, ContentHandler contentHandler) Generates SAX events for the DC metadata.protected void
saxIfNotNull
(String name, String[] values, ContentHandler contentHandler) Send values if not null.protected void
saxIfNotNull
(String name, String value, ContentHandler contentHandler) Send a value if not null.protected void
saxIfNotNull
(String name, Date value, ContentHandler contentHandler) Send a value if not null.protected void
saxLanguage
(Content content, ContentHandler contentHandler) Generates SAX events for the content's language.protected void
saxRootTag
(Content content, ContentHandler contentHandler, Locale locale, String tagName) Generates a surrounding tag, with content metadata.protected void
saxWorkflowStep
(Content content, ContentHandler contentHandler, boolean saxWorkflowInfo) Generates SAX events representing the current workflow step.void
service
(ServiceManager manager)
-
Field Details
-
CMS_CONTENT_SAXER_ROLE
Avalon role.
-
-
Constructor Details
-
ContentSaxer
public ContentSaxer()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- 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 aContent
.
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
- theContent
.contentHandler
- the ContentHandler receving SAX events.locale
- theLocale
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 aContent
.
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
- theContent
.contentHandler
- the ContentHandler receving SAX events.locale
- theLocale
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
otherwiserenderDisableValues
-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
- theContent
.contentHandler
- the ContentHandler receving SAX events.locale
- theLocale
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
otherwiserenderDisableValues
-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
- theContent
.contentHandler
- the ContentHandler receving SAX events.locale
- theLocale
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
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 forcontent types
, and possiblymixin types
- Parameters:
content
- theContent
.contentHandler
- the ContentHandler receving SAX events.saxMixins
- if true, also produces SAX events formixin 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
- theContent
.contentHandler
- the ContentHandler receving SAX events.locale
- theLocale
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
otherwiserenderDisableValues
-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
- theContent
.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
- theContent
.workflow
- the associated workflow.- Returns:
- the current step
- Throws:
com.opensymphony.workflow.WorkflowException
- if somethng got wrong processing workflow data.
-
saxLanguage
Generates SAX events for the content's language.- Parameters:
content
- theContent
.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
- theContent
.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
- theContent
.contentHandler
- the ContentHandler receiving SAX events.- Throws:
SAXException
- if an error occurs during the SAX events generation.
-
saxContentContributorComments
protected void saxContentContributorComments(ContributorCommentableContent content, ContentHandler contentHandler) throws SAXException Generates SAX events for content's contributor comments.- Parameters:
content
- theContent
.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 SAXExceptionGenerates SAX events for content's comments.- Parameters:
comments
- the content's commentscommentsTagName
- the tag name of the SAX event to generate for commentscontentHandler
- 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
Add attribute if value is not null- Parameters:
attrs
- The attributesname
- The name of attributevalue
- The value
-