Package com.logicaldoc.importfolder
Class CrawlerHelper
java.lang.Object
com.logicaldoc.importfolder.CrawlerHelper
- Direct Known Subclasses:
FSHelper
,FTPHelper
,SFTPHelper
,SMB3Helper
,SMBHelper
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 Summary
Modifier and TypeMethodDescriptionabstract void
checkinFile
(Object file, long docId, com.logicaldoc.core.security.user.User owner) Imports a remote file into an existing document producing a new versionabstract boolean
deleteFile
(Object file) Delete the given referenced file after document import.abstract File
getContentFile
(String path) Retrieves a file that contains the content referenced by pathabstract Date
getCreationDate
(Object file) Computes remote file creation dateabstract Object
Gets the object representation of the given pathstatic final CrawlerHelper
getInstance
(ImportFolder importFolder, ImportFolderCrawler crawler) Factory method, the correct implementation is created depending on the provider code specifies in the importFolderabstract Date
getLastModified
(Object file) Computes remote file last modification timeabstract String
Computes the name of the remote fileabstract String
Computes the path of the remote fileabstract int
The documents, referenced by a index file, that should be imported.abstract com.logicaldoc.core.document.Document
importFile
(Object file, com.logicaldoc.core.folder.Folder folder, com.logicaldoc.core.security.user.User owner, boolean timestamp) Imports a remote fileabstract void
importUsingIndex
(ImportFolderCrawler crawler) Imports documents referenced by a index fileabstract void
list
(Object parent, int depth, List<Object> folders, List<Object> files, long max, ImportFolderCache cache) Lists all files in a remote folderabstract boolean
Tests if the import folder can be accessedboolean
toBeImported
(Object file, ImportFolderCache cache) Checks if a file needs to be imported
-
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 foldercrawler
- 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 directorydepth
- The maximum depthfolders
- The list that will contain all allowed foldersfiles
- The list that will contain all allowed filesmax
- The maximum number of elements in filescache
- 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 loadedfolder
- The target folderowner
- The owner usertimestamp
- 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 layerIOException
- 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 loadeddocId
- The document identifierowner
- The owner user- Throws:
com.logicaldoc.core.PersistenceException
- Error in the database layerIOException
- I/O error
-
getPath
Computes the path of the remote file- Parameters:
file
- The file to be considered- Returns:
- The path
- Throws:
IOException
- I/O error
-
getName
Computes the name of the remote file- Parameters:
file
- The file to be considered- Returns:
- The name
-
getLastModified
Computes remote file last modification time- Parameters:
file
- The file to be considered- Returns:
- The last modification time
-
getCreationDate
Computes remote file creation date- Parameters:
file
- The file to be considered- Returns:
- The creation date
-
toBeImported
Checks if a file needs to be imported- Parameters:
file
- The file to be consideredcache
- 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 layerIOException
- I/O errorSAXException
- XML errorParserConfigurationException
- XML error
-
importDocumentsCount
public abstract int importDocumentsCount() throws IOException, com.logicaldoc.core.PersistenceException, ParserConfigurationException, SAXExceptionThe 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 layerIOException
- I/O errorSAXException
- XML errorParserConfigurationException
- XML error
-
deleteFile
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
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
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
-