Class CrawlerHelper
java.lang.Object
com.logicaldoc.importfolder.helper.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 SummaryModifier and TypeMethodDescriptionabstract voidcheckinFile(Object file, long docId, com.logicaldoc.core.security.user.User owner) Imports a remote file into an existing document producing a new versionabstract booleandeleteFile(Object file) Delete the given referenced file after document import.abstract FilegetContentFile(String path) Retrieves a file that contains the content referenced by pathabstract DategetCreationDate(Object file) Computes remote file creation dateabstract ObjectGets the object representation of the given pathstatic final CrawlerHelpergetInstance(ImportFolder importFolder, Crawler crawler) Factory method, the correct implementation is created depending on the provider code specifies in the importFolderabstract DategetLastModified(Object file) Computes remote file last modification timeabstract StringComputes the name of the remote fileabstract StringComputes the path of the remote fileabstract intThe documents, referenced by a index file, that should be imported.abstract com.logicaldoc.core.document.DocumentimportFile(Object file, com.logicaldoc.core.folder.Folder folder, com.logicaldoc.core.security.user.User owner, boolean timestamp) Imports a remote fileabstract voidimportUsingIndex(Crawler crawler) Imports documents referenced by a index fileabstract voidlist(Object parent, int depth, List<Object> folders, List<Object> files, long max, ImportFolderCache cache) Lists all files in a remote folderabstract booleanTests if the import folder can be accessedbooleantoBeImported(Object file, ImportFolderCache cache) Checks if a file needs to be imported
- 
Method Details- 
getInstancepublic static final CrawlerHelper getInstance(ImportFolder importFolder, Crawler 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
 
- 
testConnectionpublic abstract boolean testConnection()Tests if the import folder can be accessed- Returns:
- true if the import folder is accessible
 
- 
listpublic 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
 
- 
importFilepublic 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
 
- 
checkinFilepublic 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
 
- 
getPathComputes the path of the remote file- Parameters:
- file- The file to be considered
- Returns:
- The path
- Throws:
- IOException- I/O error
 
- 
getNameComputes the name of the remote file- Parameters:
- file- The file to be considered
- Returns:
- The name
 
- 
getLastModifiedComputes remote file last modification time- Parameters:
- file- The file to be considered
- Returns:
- The last modification time
 
- 
getCreationDateComputes remote file creation date- Parameters:
- file- The file to be considered
- Returns:
- The creation date
 
- 
toBeImportedChecks if a file needs 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
 
- 
importUsingIndexpublic abstract void importUsingIndex(Crawler crawler) throws com.logicaldoc.core.PersistenceException, IOException, ParserConfigurationException, SAXException Imports documents referenced by a index file- Parameters:
- crawler- The current task
- Throws:
- com.logicaldoc.core.PersistenceException- Error in the database layer
- IOException- I/O error
- SAXException- XML error
- ParserConfigurationException- XML error
 
- 
importDocumentsCountpublic 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 layer
- IOException- I/O error
- SAXException- XML error
- ParserConfigurationException- XML error
 
- 
deleteFileDelete the given referenced file after document import.- Parameters:
- file- The file that must be deleted
- Returns:
- if the file has been successfully deleted
 
- 
getFileGets the object representation of the given path- Parameters:
- path- the full path of a remote file
- Returns:
- the remote file at the specified path
 
- 
getContentFileRetrieves 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
 
 
-