Package org.ametys.plugins.contentio.in
Class ContentImportManager
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.contentio.in.ContentImportManager
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
Component handling the import of contents, based on the
ContentImporter
multiple extension point.-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Class representing a content import result. -
Field Summary
Modifier and TypeFieldDescriptionprotected ContentImporterExtensionPoint
The content importer extension point.protected DOMParser
A DOM parser.static final String
The avalon role. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ContentImporter
getImporter
(File file) Get theContentImporter
supporting the file.importContents
(File file) Import contents from a given file.importContents
(InputStream is, String name) Import contents from an input stream.void
service
(ServiceManager serviceManager) protected boolean
supports
(ContentImporter importer, BufferedInputStream in, String name, Map<String, Object> importContext) Test if an importer supports the file.protected boolean
supportsXml
(XmlContentImporter importer, BufferedInputStream in, Map<String, Object> importContext) Test if anXmlContentImporter
supports the file.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The avalon role. -
_contentImportEP
The content importer extension point. -
_domParser
A DOM parser.
-
-
Constructor Details
-
ContentImportManager
public ContentImportManager()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
importContents
Import contents from a given file.- Parameters:
file
- the file describing the contents to import.- Returns:
- a Set of imported content IDs.
- Throws:
ContentImportException
- if an exception occurs while importing the contents from the file.
-
importContents
public ContentImportManager.ImportResult importContents(InputStream is, String name) throws ContentImportException Import contents from an input stream.- Parameters:
is
- an input stream on the data describing the contents to import.name
- the "file" name, can be null. If it's null, some importers may not be able to identify the stream.- Returns:
- a Set of imported content IDs.
- Throws:
ContentImportException
- if an exception occurs while importing the contents from the file.
-
getImporter
Get theContentImporter
supporting the file.- Parameters:
file
- the file- Returns:
- the
ContentImporter
corresponding to a - Throws:
IOException
- if an exception occurs when manipulating the file
-
supports
protected boolean supports(ContentImporter importer, BufferedInputStream in, String name, Map<String, Object> importContext) throws IOExceptionTest if an importer supports the file.- Parameters:
importer
- the importer to test.in
- an InputStream on the file.name
- the file name, can be null.importContext
- the import context map.- Returns:
- true if the importer supports the file, false otherwise.
- Throws:
IOException
- if an error occurs testing the importer.
-
supportsXml
protected boolean supportsXml(XmlContentImporter importer, BufferedInputStream in, Map<String, Object> importContext) throws IOExceptionTest if anXmlContentImporter
supports the file.- Parameters:
importer
- the XML content importer to test.in
- an InputStream on the file.importContext
- the import context map.- Returns:
- true if the importer supports the file, false otherwise.
- Throws:
IOException
- if an error occurs testing the importer.
-