Package com.logicaldoc.importfolder
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 Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
checkinFile(Object file, long docId, com.logicaldoc.core.security.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
getFile(String path)
Gets the object representation of the given pathstatic CrawlerHelper
getInstance(ImportFolder importFolder)
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
getName(Object file)
Computes the name of the remote fileabstract String
getPath(Object file)
Computes the path of the remote fileabstract int
importDocumentsCount()
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 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
testConnection()
Tests if the import folder can be accessedboolean
toBeImported(Object file, ImportFolderCache cache)
Checks if a file need to be imported
-
-
-
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 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:
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 loadedfolder
- The target folderowner
- The owner usertimestamp
- 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 loadeddocId
- The document identifierowner
- 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 consideredcache
- 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
-
-