Class ImportFileSystem

java.lang.Object
de.elo.ix.client.imfs.ImportFileSystem

public class ImportFileSystem extends Object
Import files and folders from file system into an ELO archive. Example:
 
import java.util.Properties;

import byps.BSyncResult;
import de.elo.ix.client.IXConnFactory;
import de.elo.ix.client.IXConnection;

public class ImportFileSystemExample {

  public final static void main(String[] args) {
    
    // How to connect to IX
    String ixUrl = "http://srvtdev03:6020/ix-elo90/ix";
    String userName = "Administrator";
    String pwd = "elo";

    IXConnFactory connFact = null;
    IXConnection conn = null;
    
    try {
      
      // Initialize connection properties map. 
      // Allow 100 parallel requests. 
      Properties connProps = IXConnFactory.createConnProps(ixUrl);
      connProps.put(IXConnFactory.PROP_NB_OF_CNNS, "100");
      // Reverse connections (server push functionality) are not required.
      connProps.put(IXConnFactory.NB_OF_REVERSE_CNNS, "0");

      // Initialize session options with application name and version.
      Properties sessOpts = IXConnFactory.createSessionOptions("import-fs-example", "0.1");

      // Connect
      connFact = new IXConnFactory(connProps, sessOpts);
      conn = connFact.create(userName, pwd, "import-fs", "");

      // Initialize import options.
      ImportOptions options = new ImportOptions();
      options.setSource("H:/temp/mailablage/PSUPPORT/2008");
      options.setDestination("/ImportFS/2008-1");
      options.setHandleDuplicate(ImportOptions.CREATE_REFERENCE_FOR_DUPLICATE);

      AccessControlOptions accessControlOptions = new AccessControlOptions();
      accessControlOptions.setSkip(true);
      options.setAccessControlOptions(accessControlOptions);
      
      // Callback function (interface) to print import progress on stdout. 
      ProgressCallback progress = (ProgressInfo value) -> {
        System.out.println(value.toString());
      };

      // Create the importer object.
      ImportFileSystem importFS = new ImportFileSystem(ImportFileSystem.IMPORT, conn, options, progress);
      
      // Do import.
      BSyncResult<ImportResult> asyncResult = new BSyncResult<ImportResult>();
      importFS.doImport(asyncResult);
      
      // Await finished.
      ImportResult importResult = asyncResult.getResult();
      System.out.println("importResult=" + importResult);

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (conn != null) {
        conn.close();
      }
      if (connFact != null) {
        connFact.done();
      }
    }
  }
}

  • Field Details

    • log

      public static final org.slf4j.Logger log
    • IMPORT

      public static final boolean IMPORT
      Import mode.
      See Also:
    • ANALYZE

      public static final boolean ANALYZE
      Anaylze mode.
      See Also:
  • Constructor Details

    • ImportFileSystem

      public ImportFileSystem(boolean importNotAnalyze, IXConnection conn, ImportOptions options, ProgressCallback progress)
      Import or analyze file system.
      Parameters:
      importNotAnalyze - Either IMPORT or ANALYZE.
      conn - Indexserver connection.
      options - Import options.
      progress - Progress callback function.
  • Method Details

    • setMaximumThreadPoolSize

      public void setMaximumThreadPoolSize(int nbOfThreads)
      Set maximum number documents that are processed simultaneously. Default value is IXConnFactory.PROP_NB_OF_CNNS / 2.
      Parameters:
      nbOfThreads - Thread pool size, should be significantly less than IXConnFactory.PROP_NB_OF_CNNS. This value must be greater than 1.
    • getMaximumThreadPoolSize

      public int getMaximumThreadPoolSize()
      Get maximum number of documents that are processed simultaneously.
      Returns:
      Thread pool size.
    • doImport

      public void doImport(byps.BAsyncResult<ImportResult> importResult)
      Start import or analyze process.
      Parameters:
      importResult - This functional interface is called, when the process has finished.
    • pause

      public void pause(boolean pauseNotResume)
      Pause or resume process.
      Parameters:
      pauseNotResume - true, to pause process.
    • isPause

      public boolean isPause()
      Returns true, if the process is paused.
      Returns:
      true, if paused.
    • stop

      public void stop()
      Interrupt and stop the process.
      See Also:
    • importOrAnalyzeFolder

      protected int importOrAnalyzeFolder(File srcDir, int parentId, String destArcPath)
      Import or analyze given folder with all sub-items.
      Parameters:
      srcDir - File system folder to be imported.
      parentId - Destionation parent ID in ELO archive.
      destArcPath - Destination path in ELO archive releative to parentId.
      Returns:
      Object ID of imported folder.
    • importFolderSync

      protected int importFolderSync(File srcDir, int parentId, String destArcPath)
      Import folder.
      Parameters:
      srcDir - File system folder to be imported.
      parentId - Destionation parent ID in ELO archive.
      destArcPath - Destination path in ELO archive releative to parentId.
      Returns:
      Object ID of imported folder.
    • importFolderOrDocument

      protected void importFolderOrDocument(File file, int folderId) throws Exception
      Import one folder or one file.
      Parameters:
      file - File or folder to be imported.
      folderId - Parent ID of the destination folder in the ELO archive.
      Throws:
      Exception
    • importDocument

      protected boolean importDocument(File file, int parentId)
      Import document.
      Parameters:
      file -
      parentId -
      Returns:
      false, if function should be retried.
    • maybeCreateReferenceOnDuplicate

      protected boolean maybeCreateReferenceOnDuplicate(File file, int parentId, String internalName, String[] refMD5) throws Exception
      Create a reference if the given document is a duplicate.
      Parameters:
      file - Document file.
      parentId -
      refMD5 -
      Returns:
      true, if a reference was created or another duplicate is being imported at the same time.
      Throws:
      Exception
    • setOriginalFileName

      protected void setOriginalFileName(Sord sord, String fname)
      Store the file name in the ObjKey reserved for this purposse.
      Parameters:
      sord - Sord object.
      fname - File name.
    • readSordIfExists

      protected Sord readSordIfExists(String objId, SordZ sordZ) throws Exception
      Throws:
      Exception
    • checkSordExists

      protected int checkSordExists(int parentId, String name) throws Exception
      Check whether an object with the given name already exists.
      Parameters:
      parentId - Parent ID.
      name - File name.
      Returns:
      The ID of an existing Sord or 0, if the Sord does not exist.
      Throws:
      Exception
    • makeSordNameFromFileName

      protected String makeSordNameFromFileName(String fname)
      Replace whitespace characters in file name with ImportOptions.getBlankReplacement().
      Parameters:
      fname - File name or path
      Returns:
      Sord name or archive path
    • makeValidSordNameAndExt

      protected String[] makeValidSordNameAndExt(File file)
      Split file name and extension. Truncated name and extension to the maximum allowed characters.
      Parameters:
      file - File
      Returns:
      Name and extension (starts with a dot).
    • createFolder

      protected int createFolder(File srcDir, int parentId, String destArcPath) throws Exception
      Create a new folder in the ELO archive.
      Parameters:
      srcDir - Folder in the file system.
      parentId - Parent ID.
      destArcPath - Path relative to Parent ID to be created.
      Returns:
      ID of the last created folder.
      Throws:
      Exception
    • assignCustomMembers

      protected void assignCustomMembers(File srcFile, Sord sord, SordZ sordZ, DocVersion dv)
      Assign additional Members to Sord object. This function can be overwritten in a derived class in order to assign additional values to the Sord object before it is inserted. When importing a document, this function is called before checkinDocBegin. When importing a folder, this function is called before checkinSord.
      Parameters:
      srcFile - File or directory to be imported.
      sord - Sord object
      sordZ - Valid sord members. Set sordZ.setBset(sordZ.getBset() | SordC.mbElement) for changed members.
      dv - DocVersion object if sord is a document, otherwise null.
    • testFiltersMatchThisFile

      protected boolean testFiltersMatchThisFile(File file)
      Test whether file matches any include filter and does not match any exclude filter.
      Parameters:
      file - File object.
      Returns:
      true, if file should be imported
    • assignFileTimeToSord

      protected void assignFileTimeToSord(File sourceFile, Sord sord, SordZ sordZ, DocVersion dv) throws Exception
      Assing file time values of the given file to the Sord and DocVersion object.
      Parameters:
      sourceFile - File to read time properties from.
      sord - Sord object that receives the time values.
      sordZ - Modified Sord properties are added to this element selector.
      dv - DocVersion object that receives time values, can be null for folders.
      Throws:
      Exception
    • initFolderMaskId

      protected void initFolderMaskId() throws Exception
      Read the keywording form to be used for folders.
      Throws:
      Exception
    • getImportEvents

      public ImportEvents getImportEvents()
    • setImportEvents

      public void setImportEvents(ImportEvents importEvents)