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
Nested ClassesModifier and TypeClassDescriptionclassClass representing a content import result. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ContentImporterExtensionPointThe content importer extension point.protected DOMParserA DOM parser.static final StringThe avalon role. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ContentImportergetImporter(File file) Get theContentImportersupporting the file.importContents(File file) Import contents from a given file.importContents(InputStream is, String name) Import contents from an input stream.voidservice(ServiceManager serviceManager) protected booleansupports(ContentImporter importer, BufferedInputStream in, String name, Map<String, Object> importContext) Test if an importer supports the file.protected booleansupportsXml(XmlContentImporter importer, BufferedInputStream in, Map<String, Object> importContext) Test if anXmlContentImportersupports 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:
servicein 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 theContentImportersupporting the file.- Parameters:
file- the file- Returns:
- the
ContentImportercorresponding 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 anXmlContentImportersupports 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.
-