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 theContentImportermultiple extension point.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classContentImportManager.ImportResultClass representing a content import result.
-
Field Summary
Fields Modifier and Type Field Description protected ContentImporterExtensionPoint_contentImportEPThe content importer extension point.protected DOMParser_domParserA DOM parser.static StringROLEThe avalon role.
-
Constructor Summary
Constructors Constructor Description ContentImportManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ContentImportergetImporter(File file)Get theContentImportersupporting the file.ContentImportManager.ImportResultimportContents(File file)Import contents from a given file.ContentImportManager.ImportResultimportContents(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 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:
servicein 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 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 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 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.
-
-