Class Importer

java.lang.Object
org.apache.jackrabbit.vault.fs.io.Importer

public class Importer extends Object
Imports an Archive into a repository. file/directory combinations
  1. plain file
        + foo
          - test.gif
  2. plain files + special folder
        + foo
          - .content.xml
          + bar
            - test.gif
  3. special file
        + foo
          - test.gif
          - test.gif.dir
            - .content.xml
  4. special file + sub files
        + foo
          - test.gif
          - test.gif.dir
            - .content.xml
            + _jcr_content
              - thumbnail.gif
  5. special file + sub special files
        + foo
          - test.gif
          - test.gif.dir
            - .content.xml
            + _jcr_content
              - thumbnail.gif
              + thumbnail.gif.dir
                - .content.xml
  6. file/folder structure
        + foo
          + en
            - .content.xml
            + _cq_content
              - thumbnail.gif
            + company
              - .content.xml
  • Constructor Details

    • Importer

      public Importer()
      Default constructor neither setting specific import options nor defaults.
    • Importer

      public Importer(ImportOptions opts)
      Constructor which is not setting default options.
      Parameters:
      opts -
      See Also:
    • Importer

      public Importer(ImportOptions opts, boolean isStrictByDefault)
      Shortcut for Importer(ImportOptions, boolean, boolean, IdConflictPolicy) with no default id conflict policy. Also primary types of existing nodes are always overwritten.
      Parameters:
      opts - the import options to use during run(Archive, Node) or run(Archive, Session, String)
      isStrictByDefault - is true if packages should be installed in strict mode by default (if not set otherwise in opts)
    • Importer

      public Importer(ImportOptions opts, boolean isStrictByDefault, boolean overwritePrimaryTypesOfFoldersByDefault)
      Shortcut for Importer(ImportOptions, boolean, boolean, IdConflictPolicy) with no default id conflict policy.
      Parameters:
      opts - the import options to use during run(Archive, Node) or run(Archive, Session, String)
      isStrictByDefault - is true if packages should be installed in strict mode by default (if not set otherwise in opts)
      overwritePrimaryTypesOfFoldersByDefault - if folder aggregates' JCR primary type should be changed if the node is already existing or not
    • Importer

      public Importer(ImportOptions opts, boolean isStrictByDefault, boolean overwritePrimaryTypesOfFoldersByDefault, IdConflictPolicy defaultIdConflictPolicy)
      Constructor setting both specific import options as well as some defaults for options not set.
      Parameters:
      opts - the import options to use during run(Archive, Node) or run(Archive, Session, String)
      isStrictByDefault - is true if packages should be installed in strict mode by default (if not set otherwise in opts)
      overwritePrimaryTypesOfFoldersByDefault - if folder aggregates' JCR primary type should be changed if the node is already existing or not
      defaultIdConflictPolicy - the default IdConflictPolicy to use if no policy is set in opts. May be null.
  • Method Details

    • getOptions

      public ImportOptions getOptions()
    • getSubPackages

      public List<String> getSubPackages()
    • isStrictByDefault

      public boolean isStrictByDefault()
    • setDebugFailAfterSave

      public void setDebugFailAfterSave(int failAfterEach)
      Debug settings to allows to produce failures after each failAfterEach save.
      Parameters:
      failAfterEach - cardinal indicating when to fail
    • track

      protected void track(String action, String path)
    • track

      protected void track(Exception e, String path)
    • run

      public void run(Archive archive, Node importRoot) throws IOException, RepositoryException, ConfigurationException
      Runs the importer from the given root node. Shortcut for run(Archive, Session, String) with the session and path from the given node.
      Parameters:
      archive - the archive to import
      importRoot - the root node to import
      Throws:
      ConfigurationException - if the importer is not properly configured
      IOException - if an I/O error occurs
      RepositoryException - if an repository error occurs
      Since:
      2.3.20
    • run

      public void run(Archive archive, Session session, String parentPath) throws IOException, RepositoryException, ConfigurationException
      Runs the importer with the given session. Session.save() and potentially Session.refresh(boolean) are automatically called during the import in the given session, except when ImportOptions.setAutoSaveThreshold(int) with value Integer.MAX_VALUE has been set. In all other cases the changes are automatically persisted (potentially in batches) potentially after advanced retry mechanisms.
      Parameters:
      archive - the archive to import
      session - the session importing the archive
      parentPath - the repository parent path where the archive will be imported
      Throws:
      IOException - if an I/O error occurs
      RepositoryException - if a repository error occurs
      ConfigurationException - if the importer is not properly configured
      Since:
      2.7.0
    • hasErrors

      public boolean hasErrors()
    • getSettings

      protected VaultSettings getSettings()
    • isExcluded

      protected boolean isExcluded(String fileName)
      Checks if the given file name is excluded
      Parameters:
      fileName - the file name
      Returns:
      true if excluded
    • checkinNodes

      public void checkinNodes(Session session)
    • applyMemberships

      public void applyMemberships(Session session)