New Importer Architecture (2009)
Last modified by Vincent Massol on 2024/11/19 16:12
Description
The current importer is lacking some features:
- bad design and too complex to maintain
- cannot import HTML, plain text, etc
- cannot convert from one wiki syntax to another
Proposal
- A Importer interface to represent the different importers
- import(Converter converter, DocumentImportFactory factory)
- setFilter(ImportFilter filter) : to decide what document to import
- A Converter interface to convert original content before it's imported into a page
- OutputStream convert(InputStream originalContent)
- A DocumentImportFactory interface for delegating how pages are created. This is important as there are different strategies for finding out the following data from the original content:
- Language
- Target Space
- Target Page name
- Objects to attach
- Attachments
- Versions
- Author
- API:
- XWikiDocument createDocument(String originalFileName, InputStream contentAfterConversion)
- setMode(REPLACE || APPEND): whether to create a new version or replace any existing doc
Examples of implementations:
- For Importer: FileImporter, DirectoryImporter, ZIPImporter, ZipURLImporter, JARImporter
- For Converter: PlainTextConverter, HTMLConverter, TWikiConverter, ConfluenceConverter, XWikiXMLConverter (for converting documents in XWiki XML format)
- For DocumentImportFactory: XARDocumentImportFactory, ExpandedXARDocumentImportFactory, DefaultDocumentImportFactory (uses the file name as page name and parent directory as space, etc)
Examples of Use Cases
- A XAR file
- new ZipImporter(new File(".../.xar"), new XWikiXMLConverter(), new XARDocumentImportFactory(new File(".../.xar")))
- A single HTML file
- new FileImporter(new File(".../.html"), new HTMLConverter(), new DefaultDocumentImporterFactory())
- A zip file containing TWiki pages
- new ZipImporter(new File(".../.zip"), new TWikiConverter(), new DefaultDocumentImporterFactory())
- An expanded directory of HTML files
- new DirectoryImporter(new File(".../somedir"), new HTMLConverter(), new DefaultDocumentImporterFactory())
Questions
Put any question you have here:
- (question here)
Vincent Massol