Class 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 Detail

      • getInstance

        public static final CrawlerHelper getInstance​(ImportFolder importFolder)
                                               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
        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 Exception
        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:
        Exception - a generic error happened
      • importFile

        public abstract com.logicaldoc.core.document.Document importFile​(Object file,
                                                                         com.logicaldoc.core.folder.Folder folder,
                                                                         com.logicaldoc.core.security.User owner,
                                                                         boolean timestamp)
                                                                  throws Exception
        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:
        Exception - a generic error happened
      • checkinFile

        public abstract void checkinFile​(Object file,
                                         long docId,
                                         com.logicaldoc.core.security.User owner)
                                  throws Exception
        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:
        Exception - a generic error happened
      • getPath

        public abstract String getPath​(Object file)
                                throws Exception
        Computes the path of the remote file
        Parameters:
        file - The file to be considered
        Returns:
        The path
        Throws:
        Exception - a generic error happened
      • getName

        public abstract String getName​(Object file)
                                throws Exception
        Computes the name of the remote file
        Parameters:
        file - The file to be considered
        Returns:
        The name
        Throws:
        Exception - a generic error happened
      • 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 Exception
        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:
        Exception - a generic error happened
      • importUsingIndex

        public abstract void importUsingIndex​(ImportFolderCrawler crawler)
                                       throws Exception
        Imports documents referenced by a index file
        Parameters:
        crawler - The current ImportFolderCrawler task
        Throws:
        Exception - a generic error happened
      • importDocumentsCount

        public abstract int importDocumentsCount()
                                          throws Exception
        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:
        Exception - a generic error happened
      • 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