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 StringCMS_CONTENT_SAXER_ROLEAvalon role.
-
Constructor Summary
Constructors Constructor Description ContentSaxer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAttributeIfNotNull(AttributesImpl attrs, String name, String value)Add attribute if value is not nullprotected com.opensymphony.workflow.spi.StepgetCurrentStep(WorkflowAwareContent content, WorkflowProvider.AmetysObjectWorkflow workflow)Get the current workflow step of the content.protected voidsaxAttributes(Content content, ContentHandler contentHandler, Locale locale, View view, String tagName, String attributesTagName, boolean isEdition)Generates SAX events for actual content's data.protected voidsaxBody(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.voidsaxContent(Content content, ContentHandler contentHandler, Locale locale, View view, String tagName, boolean saxWorkflowStep, boolean saxWorkflowInfo, boolean saxLanguageInfo, String attributesTagName)Generates SAX events representing aContent.voidsaxContent(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 voidsaxContentComments(CommentableContent content, ContentHandler contentHandler)Generates SAX events for content's comments.protected voidsaxContentTypes(Content content, ContentHandler contentHandler, boolean saxMixins)Generates SAX events forcontent types, and possiblymixin typesprotected voidsaxDublinCoreMetadata(DublinCoreAwareAmetysObject dcObject, ContentHandler contentHandler)Generates SAX events for the DC metadata.protected voidsaxIfNotNull(String name, String[] values, ContentHandler contentHandler)Send values if not null.protected voidsaxIfNotNull(String name, String value, ContentHandler contentHandler)Send a value if not null.protected voidsaxIfNotNull(String name, Date value, ContentHandler contentHandler)Send a value if not null.protected voidsaxLanguage(Content content, ContentHandler contentHandler)Generates SAX events for the content's language.protected voidsaxRootTag(Content content, ContentHandler contentHandler, Locale locale, String tagName)Generates a surrounding tag, with content metadata.protected voidsaxWorkflowStep(Content content, ContentHandler contentHandler, boolean saxWorkflowInfo)Generates SAX events representing the current workflow step.voidservice(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:
servicein 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- theLocaleto 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- theLocaleto 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-trueif SAX events are generated in edition mode,falseotherwise- 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- theLocaleto 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-trueif SAX events are generated in edition mode,falseotherwise- 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- theLocaleto 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- theLocaleto 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-trueif SAX events are generated in edition mode,falseotherwise- 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
-
-