Class Importer


  • public class Importer
    extends Object
    Import a set of XWiki documents into an existing database.
    Version:
    $Id: 5ef61c167985aeaeb98e1b9c25c8e2aca3f17d7d $
    • Constructor Detail

      • Importer

        public Importer​(OldCoreHelper oldCoreHelper)
        Parameters:
        oldCoreHelper - various tools to manipulate oldcore APIs
    • Method Detail

      • importDocuments

        public void importDocuments​(File sourceDirectory,
                                    String wikiId)
                             throws Exception
        Import documents defined in an XML file located in the passed document definition directory into a database defined by its passed name and by an Hibernate configuration file.

        Note: I would have liked to call this method "import" but it's a reserved keyword... Strange that it's not allowed for method names though.

        Parameters:
        sourceDirectory - the directory where the package.xml file is located and where the documents to import are located
        wikiId - id of the wiki into which to import the documents (e.g. xwiki)
        Throws:
        Exception - if the import failed for any reason
      • importDocuments

        public void importDocuments​(File sourceDirectory,
                                    String wikiId,
                                    String importUser)
                             throws Exception
        Import documents defined in an XML file located in the passed document definition directory into a database defined by its passed name and by an Hibernate configuration file.

        Note: I would have liked to call this method "import" but it's a reserved keyword... Strange that it's not allowed for method names though.

        Parameters:
        sourceDirectory - the directory where the package.xml file is located and where the documents to import are located
        wikiId - id of the wiki into which to import the documents (e.g. xwiki)
        importUser - optionally the user under which to perform the import (useful for example when importing pages that need to have Programming Rights and the page author is not the same as the importing user)
        Throws:
        Exception - if the import failed for any reason
      • importXAR

        public int importXAR​(File file,
                             String importUser,
                             XWikiContext context)
                      throws XWikiException,
                             IOException
        Parameters:
        file - the XAR file to import
        importUser - optionally the user under which to perform the import (useful for example when importing pages that need to have Programming Rights and the page author is not the same as the importing user)
        context - the XWiki context
        Returns:
        the number of imported documents
        Throws:
        XWikiException - failed to import the XAR file
        IOException - failed to parse the XAR file