Package org.ametys.plugins.contentio
Class ContentImportManager
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.contentio.ContentImportManager
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class ContentImportManager extends AbstractLogEnabled implements Serviceable, Component
Component handling the import of contents, based on theContentImporter
multiple extension point.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ContentImportManager.ImportResult
Class representing a content import result.
-
Field Summary
Fields Modifier and Type Field Description protected ContentImporterExtensionPoint
_contentImportEP
The content importer extension point.protected DOMParser
_domParser
A DOM parser.static String
ROLE
The avalon role.
-
Constructor Summary
Constructors Constructor Description ContentImportManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ContentImporter
getImporter(File file)
Get theContentImporter
supporting the file.ContentImportManager.ImportResult
importContents(File file)
Import contents from a given file.ContentImportManager.ImportResult
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 Detail
-
_contentImportEP
protected ContentImporterExtensionPoint _contentImportEP
The content importer extension point.
-
_domParser
protected DOMParser _domParser
A DOM parser.
-
-
Constructor Detail
-
ContentImportManager
public ContentImportManager()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
importContents
public ContentImportManager.ImportResult importContents(File file) throws ContentImportException
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
protected ContentImporter getImporter(File file) throws IOException
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 IOException
Test 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 IOException
Test 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.
-
-