Class DefaultXmlContentImporter
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.contentio.in.AbstractContentImporter
-
- org.ametys.plugins.contentio.in.xml.AbstractXmlContentImporter
-
- org.ametys.plugins.contentio.in.xml.DefaultXmlContentImporter
-
- All Implemented Interfaces:
ContentImporter
,XmlContentImporter
,LogEnabled
,Prioritizable
,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.in.AbstractContentImporter
AbstractContentImporter.ContentReference
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentTypesHelper
_cTypeHelper
The content type helper.protected static String
_DEFAULT_CONTENT_LANG_KEY
Default content language key in the import map.protected static String
_DEFAULT_CONTENT_MIXINS_KEY
Default content mixins key in the import map.protected static String
_DEFAULT_CONTENT_TYPES_KEY
Default content types key in the import map.protected String
_matchPath
The XPath expression to match.protected Pattern
_matchRegex
The XPath value to match.protected String
_matchValue
The 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.in.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 void
configure(Configuration configuration)
protected void
configureXmlMatch(Configuration configuration)
Configure the matching value.protected Content
importContent(Element contentElement, 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
.void
service(ServiceManager serviceManager)
boolean
supports(Document document)
Tests if theXmlContentImporter
is 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.in.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, restoreContentReferences, setReferenceMetadatas, setRepeaterSize
-
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.runtime.plugin.component.Prioritizable
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:
service
in interfaceServiceable
- Overrides:
service
in classAbstractXmlContentImporter
- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in 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:XmlContentImporter
Tests if theXmlContentImporter
is able to import the corresponding Document.- Parameters:
document
- the XMLDocument
to test.- Returns:
- true if the
XmlContentImporter
can 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:AbstractXmlContentImporter
Import the contents from the XML DOMDocument
.- Specified by:
importContents
in 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(Element contentElement, String[] defaultTypes, String[] defaultMixins, String defaultLang, Map<String,Object> params) throws Exception
Import a content from a XML node.- Parameters:
contentElement
- 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:
Exception
- if an error occurs creating the Content.
-
-