Package org.ametys.cms.content
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 aContent
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CMS_CONTENT_SAXER_ROLE
Avalon role.
-
Constructor Summary
Constructors Constructor Description ContentSaxer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAttributeIfNotNull(AttributesImpl attrs, String name, String value)
Add attribute if value is not nullprotected com.opensymphony.workflow.spi.Step
getCurrentStep(WorkflowAwareContent content, WorkflowProvider.AmetysObjectWorkflow workflow)
Get the current workflow step of the content.protected void
saxAttributes(Content content, ContentHandler contentHandler, Locale locale, View view, String tagName, String attributesTagName, boolean isEdition)
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)
Generates SAX events for the content data.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)
Generates SAX events representing aContent
.protected void
saxContentComments(CommentableContent content, ContentHandler contentHandler)
Generates SAX events for content's 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 Detail
-
CMS_CONTENT_SAXER_ROLE
public static final String CMS_CONTENT_SAXER_ROLE
Avalon role.
-
-
Constructor Detail
-
ContentSaxer
public ContentSaxer()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- 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) 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
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) 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
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.
-
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) 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
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
protected void saxLanguage(Content content, ContentHandler contentHandler) throws SAXException
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 receving SAX events.- Throws:
SAXException
- if an error occurs during the SAX events generation.
-
addAttributeIfNotNull
protected void addAttributeIfNotNull(AttributesImpl attrs, String name, String value)
Add attribute if value is not null- Parameters:
attrs
- The attributesname
- The name of attributevalue
- The value
-
-