Class DefaultXmlContentImporter
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.contentio.AbstractContentImporter
-
- org.ametys.plugins.contentio.in.xml.AbstractXmlContentImporter
-
- org.ametys.plugins.contentio.in.xml.DefaultXmlContentImporter
-
- All Implemented Interfaces:
ContentImporter,XmlContentImporter,LogEnabled,Configurable,Serviceable
public class DefaultXmlContentImporter extends AbstractXmlContentImporter
Default implementation of an XML content importer.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.ametys.plugins.contentio.in.xml.AbstractXmlContentImporter
AbstractXmlContentImporter.DefaultPrefixResolver
-
Nested classes/interfaces inherited from class org.ametys.plugins.contentio.AbstractContentImporter
AbstractContentImporter.ContentReference
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentTypesHelper_cTypeHelperThe content type helper.protected static String_DEFAULT_CONTENT_LANG_KEYDefault content language key in the import map.protected static String_DEFAULT_CONTENT_MIXINS_KEYDefault content mixins key in the import map.protected static String_DEFAULT_CONTENT_TYPES_KEYDefault content types key in the import map.protected String_matchPathThe XPath expression to match.protected Pattern_matchRegexThe XPath value to match.protected String_matchValueThe XPath value to match.-
Fields inherited from class org.ametys.plugins.contentio.in.xml.AbstractXmlContentImporter
_domParser, _manager, _prefixResolver, _srcResolver, _xPathProcessor, _xsl, _xsltProcessor, _xslTransformerHandler
-
Fields inherited from class org.ametys.plugins.contentio.AbstractContentImporter
_CONTENT_ID_MAP_KEY, _CONTENT_LINK_MAP_KEY, _CONTENT_REPEATER_SIZE_MAP, _contentTypes, _contentWorkflowHelper, _editActionId, _extensions, _initialActionId, _language, _mixins, _priority, _resolver, _workflowName, DEFAULT_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description DefaultXmlContentImporter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(Configuration configuration)protected voidconfigureXmlMatch(Configuration configuration)Configure the matching value.protected ContentimportContent(Node contentNode, String[] defaultTypes, String[] defaultMixins, String defaultLang, Map<String,Object> params)Import a content from a XML node.protected Set<String>importContents(Document node, Map<String,Object> params)Import the contents from the XML DOMDocument.protected voidimportMetadata(ModifiableContent content, ModifiableCompositeMetadata meta, Node metaNode, MetadataDefinition metaDef, String metadataPath, Map<String,Object> params)Import metadata from a DOM node.protected voidimportMetadata(ModifiableContent content, Node contentNode, String prefix, Map<String,Object> params)Import metadata from a content node.protected ContentimportSubContent(ModifiableTraversableAmetysObject subContentMeta, Node contentNode, String parentContentId, String metadataPath, Map<String,Object> params)Import a sub-content.voidservice(ServiceManager serviceManager)protected voidsetComposite(ModifiableContent content, ModifiableCompositeMetadata meta, Node metaNode, MetadataDefinition metaDef, String name, String metadataPath, Map<String,Object> params)Set a composite metadata.protected voidsetContentReferences(ModifiableContent content, ModifiableCompositeMetadata meta, Node metaNode, String name, MetadataDefinition metaDef, String[] values, String metadataPath, Map<String,Object> params)Set a content metadata.protected voidsetMetadata(ModifiableContent content, ModifiableCompositeMetadata meta, Node metaNode, MetadataDefinition metaDef, String name, String[] values, String metadataPath, Map<String,Object> params)Set the values of a metadata.protected voidsetMultilingualString(ModifiableCompositeMetadata meta, Node metaNode, String name)Set a RichText metadata.protected voidsetRepeater(ModifiableContent content, ModifiableCompositeMetadata meta, Node metaNode, RepeaterDefinition repeaterDef, String name, String metadataPath, Map<String,Object> params)Set a repeater metadata.protected voidsetRichText(ModifiableCompositeMetadata meta, Node metaNode, String name)Set a RichText metadata.protected voidsetSubContents(ModifiableCompositeMetadata meta, Node metaNode, String name, String parentContentId, String metadataPath, Map<String,Object> params)Set a sub-content metadata.booleansupports(Document document)Tests if theXmlContentImporteris able to import the corresponding Document.-
Methods inherited from class org.ametys.plugins.contentio.in.xml.AbstractXmlContentImporter
configureContentCreation, configureNamespaces, configureXml, getAttributeValue, getAttributeValue, getPrefixResolver, getTextContent, getTextContent, importContents, initializeXslTransformerHandler, supports
-
Methods inherited from class org.ametys.plugins.contentio.AbstractContentImporter
addContentReference, addContentReference, addContentReferences, configureExtensions, configureWorkflow, createContent, createContent, createContent, createContent, createContent, getContentFromProperties, getContentIdMap, getContentRefMap, getContentRepeaterSizeMap, getContentTypes, getDefaultExtensions, getEditActionId, getInitialActionId, getLanguage, getMixins, getPriority, getReferencedContentId, getWorkflowName, isExtensionValid, parseDate, parseDate, restoreContentReferences, setBinaryMetadata, setBooleanMetadata, setDateMetadata, setDoubleMetadata, setGeocodeMetadata, setGeocodeMetadata, setLongMetadata, setReferenceMetadatas, setRepeaterSize, setRichText, setStringMetadata
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.plugins.contentio.ContentImporter
getPriority
-
-
-
-
Field Detail
-
_DEFAULT_CONTENT_TYPES_KEY
protected static final String _DEFAULT_CONTENT_TYPES_KEY
Default content types key in the import map.
-
_DEFAULT_CONTENT_MIXINS_KEY
protected static final String _DEFAULT_CONTENT_MIXINS_KEY
Default content mixins key in the import map.
-
_DEFAULT_CONTENT_LANG_KEY
protected static final String _DEFAULT_CONTENT_LANG_KEY
Default content language key in the import map.
-
_cTypeHelper
protected ContentTypesHelper _cTypeHelper
The content type helper.
-
_matchPath
protected String _matchPath
The XPath expression to match.
-
_matchValue
protected String _matchValue
The XPath value to match.
-
_matchRegex
protected Pattern _matchRegex
The XPath value to match.
-
-
Constructor Detail
-
DefaultXmlContentImporter
public DefaultXmlContentImporter()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classAbstractXmlContentImporter- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classAbstractXmlContentImporter- Throws:
ConfigurationException
-
configureXmlMatch
protected void configureXmlMatch(Configuration configuration) throws ConfigurationException
Configure the matching value.- Parameters:
configuration- the matching configuration.- Throws:
ConfigurationException- if an error occurs.
-
supports
public boolean supports(Document document) throws IOException
Description copied from interface:XmlContentImporterTests if theXmlContentImporteris able to import the corresponding Document.- Parameters:
document- the XMLDocumentto test.- Returns:
- true if the
XmlContentImportercan import the corresponding stream, false otherwise. - Throws:
IOException- if an error occurs.
-
importContents
protected Set<String> importContents(Document node, Map<String,Object> params) throws IOException
Description copied from class:AbstractXmlContentImporterImport the contents from the XML DOMDocument.- Specified by:
importContentsin classAbstractXmlContentImporter- Parameters:
node- the XML Document.params- the import parameters.- Returns:
- a Set of the imported content IDs.
- Throws:
IOException- if an error occurs importing the contents.
-
importContent
protected Content importContent(Node contentNode, String[] defaultTypes, String[] defaultMixins, String defaultLang, Map<String,Object> params) throws IOException, com.opensymphony.workflow.WorkflowException
Import a content from a XML node.- Parameters:
contentNode- the content XML node.defaultTypes- the default content types.defaultMixins- the default mixins.defaultLang- the default content language.params- the import parameters.- Returns:
- the Content or null if not created.
- Throws:
IOException- if an error occurs during the import.com.opensymphony.workflow.WorkflowException- if an error occurs creating the Content.
-
importMetadata
protected void importMetadata(ModifiableContent content, Node contentNode, String prefix, Map<String,Object> params) throws IOException
Import metadata from a content node.- Parameters:
content- the content to populate.contentNode- the content DOM node.prefix- the metadata prefix.params- the import parameters.- Throws:
IOException- if an error occurs.
-
importMetadata
protected void importMetadata(ModifiableContent content, ModifiableCompositeMetadata meta, Node metaNode, MetadataDefinition metaDef, String metadataPath, Map<String,Object> params) throws IOException
Import metadata from a DOM node.- Parameters:
content- The content being imported.meta- the metadata holder to populate.metaNode- the metadata DOM node.metaDef- the metadata definition.metadataPath- the metadata path.params- the import parameters.- Throws:
IOException- if an error occurs.
-
setMetadata
protected void setMetadata(ModifiableContent content, ModifiableCompositeMetadata meta, Node metaNode, MetadataDefinition metaDef, String name, String[] values, String metadataPath, Map<String,Object> params) throws IOException
Set the values of a metadata.- Parameters:
content- The content being imported.meta- the metadata holder.metaNode- the metadata DOM node.metaDef- the metadata definition.name- the metadata name.values- the metadata values.metadataPath- the metadata path.params- the import parameters.- Throws:
IOException- if an error occurs.
-
setComposite
protected void setComposite(ModifiableContent content, ModifiableCompositeMetadata meta, Node metaNode, MetadataDefinition metaDef, String name, String metadataPath, Map<String,Object> params) throws IOException
Set a composite metadata.- Parameters:
content- The content being imported.meta- the metadata holder.metaNode- the metadata DOM node.metaDef- the metadata definition.name- the metadata name.metadataPath- the metadata path.params- the import parameters.- Throws:
IOException- if an error occurs.
-
setMultilingualString
protected void setMultilingualString(ModifiableCompositeMetadata meta, Node metaNode, String name) throws IOException
Set a RichText metadata.- Parameters:
meta- the metadata holder.metaNode- the metadata node.name- the metadata name.- Throws:
IOException- if an error occurs.
-
setRichText
protected void setRichText(ModifiableCompositeMetadata meta, Node metaNode, String name) throws IOException
Set a RichText metadata.- Parameters:
meta- the metadata holder.metaNode- the metadata node.name- the metadata name.- Throws:
IOException- if an error occurs.
-
setRepeater
protected void setRepeater(ModifiableContent content, ModifiableCompositeMetadata meta, Node metaNode, RepeaterDefinition repeaterDef, String name, String metadataPath, Map<String,Object> params) throws IOException
Set a repeater metadata.- Parameters:
content- The content being imported.meta- the metadata holder.metaNode- the metadata DOM node.repeaterDef- the repeater definition.name- the metadata name.metadataPath- the metadata path.params- the import parameters.- Throws:
IOException- if an error occurs.
-
setContentReferences
protected void setContentReferences(ModifiableContent content, ModifiableCompositeMetadata meta, Node metaNode, String name, MetadataDefinition metaDef, String[] values, String metadataPath, Map<String,Object> params) throws IOException
Set a content metadata.- Parameters:
content- The content being imported.meta- the metadata holder.metaNode- the metadata DOM node.name- the metadata name.metaDef- the metadata definitionvalues- the values arraymetadataPath- the metadata path.params- the import parameters.- Throws:
IOException- if an error occurs.
-
setSubContents
protected void setSubContents(ModifiableCompositeMetadata meta, Node metaNode, String name, String parentContentId, String metadataPath, Map<String,Object> params) throws IOException
Set a sub-content metadata.- Parameters:
meta- the metadata holder.metaNode- the metadata DOM node.name- the metadata name.parentContentId- the parent content ID.metadataPath- the metadata path.params- the import parameters.- Throws:
IOException- if an error occurs.
-
importSubContent
protected Content importSubContent(ModifiableTraversableAmetysObject subContentMeta, Node contentNode, String parentContentId, String metadataPath, Map<String,Object> params) throws IOException
Import a sub-content.- Parameters:
subContentMeta- the content collection metadata.contentNode- the DOM node representing the sub-content.parentContentId- the parent content ID.metadataPath- the content collection metadata path.params- the import parameters.- Returns:
- the created Content.
- Throws:
IOException- if an error occurs.
-
-