Class CrawlerHelper

java.lang.Object
com.logicaldoc.importfolder.CrawlerHelper
Direct Known Subclasses:
FSHelper, FTPHelper, SFTPHelper, SMB3Helper, SMBHelper

public abstract class CrawlerHelper extends Object
Abstract class for helpers used to retrieve data from various sources. Each concrete extension is specialized for a single protocol.
Since:
4.5
Author:
Marco Meschieri - LogicalDOC
  • Method Details

    • getInstance

      public static final CrawlerHelper getInstance(ImportFolder importFolder, ImportFolderCrawler crawler) throws com.logicaldoc.core.PersistenceException
      Factory method, the correct implementation is created depending on the provider code specifies in the importFolder
      Parameters:
      importFolder - an import folder
      crawler - a crawler
      Returns:
      the helper to be used
      Throws:
      com.logicaldoc.core.PersistenceException - error at data layer
    • testConnection

      public abstract boolean testConnection()
      Tests if the import folder can be accessed
      Returns:
      true if the import folder is accessible
    • list

      public abstract void list(Object parent, int depth, List<Object> folders, List<Object> files, long max, ImportFolderCache cache) throws IOException
      Lists all files in a remote folder
      Parameters:
      parent - The parent directory
      depth - The maximum depth
      folders - The list that will contain all allowed folders
      files - The list that will contain all allowed files
      max - The maximum number of elements in files
      cache - Cache of imported documents
      Throws:
      IOException - I/O error
    • importFile

      public abstract com.logicaldoc.core.document.Document importFile(Object file, com.logicaldoc.core.folder.Folder folder, com.logicaldoc.core.security.user.User owner, boolean timestamp) throws com.logicaldoc.core.PersistenceException, IOException
      Imports a remote file
      Parameters:
      file - The file to be loaded
      folder - The target folder
      owner - The owner user
      timestamp - If the timestamp has to be included in filename and title
      Returns:
      The newly created document
      Throws:
      com.logicaldoc.core.PersistenceException - Error in the data layer
      IOException - I/O exception
    • checkinFile

      public abstract void checkinFile(Object file, long docId, com.logicaldoc.core.security.user.User owner) throws IOException, com.logicaldoc.core.PersistenceException
      Imports a remote file into an existing document producing a new version
      Parameters:
      file - The file to be loaded
      docId - The document identifier
      owner - The owner user
      Throws:
      com.logicaldoc.core.PersistenceException - Error in the database layer
      IOException - I/O error
    • getPath

      public abstract String getPath(Object file) throws IOException
      Computes the path of the remote file
      Parameters:
      file - The file to be considered
      Returns:
      The path
      Throws:
      IOException - I/O error
    • getName

      public abstract String getName(Object file)
      Computes the name of the remote file
      Parameters:
      file - The file to be considered
      Returns:
      The name
    • getLastModified

      public abstract Date getLastModified(Object file)
      Computes remote file last modification time
      Parameters:
      file - The file to be considered
      Returns:
      The last modification time
    • getCreationDate

      public abstract Date getCreationDate(Object file)
      Computes remote file creation date
      Parameters:
      file - The file to be considered
      Returns:
      The creation date
    • toBeImported

      public boolean toBeImported(Object file, ImportFolderCache cache) throws IOException
      Checks if a file need to be imported
      Parameters:
      file - The file to be considered
      cache - The cache of the import folder
      Returns:
      True if the file is to be imported
      Throws:
      IOException - I/O Error
    • importUsingIndex

      public abstract void importUsingIndex(ImportFolderCrawler crawler) throws com.logicaldoc.core.PersistenceException, IOException, ParserConfigurationException, SAXException
      Imports documents referenced by a index file
      Parameters:
      crawler - The current ImportFolderCrawler task
      Throws:
      com.logicaldoc.core.PersistenceException - Error in the database layer
      IOException - I/O error
      SAXException - XML error
      ParserConfigurationException - XML error
    • importDocumentsCount

      public abstract int importDocumentsCount() throws IOException, com.logicaldoc.core.PersistenceException, ParserConfigurationException, SAXException
      The documents, referenced by a index file, that should be imported. It returns -1 in case there is not index file
      Returns:
      number of documents references inside the index file
      Throws:
      com.logicaldoc.core.PersistenceException - Error in the data layer
      IOException - I/O error
      SAXException - XML error
      ParserConfigurationException - XML error
    • deleteFile

      public abstract boolean deleteFile(Object file)
      Delete the given referenced file after document import.
      Parameters:
      file - The file that must be deleted
      Returns:
      if the file has been successfully deleted
    • getFile

      public abstract Object getFile(String path)
      Gets the object representation of the given path
      Parameters:
      path - the full path of a remote file
      Returns:
      the remote file at the specified path
    • getContentFile

      public abstract File getContentFile(String path)
      Retrieves a file that contains the content referenced by path
      Parameters:
      path - the full path of a remote file
      Returns:
      a local file containing the remote file's content