Package com.logicaldoc.importfolder.smb
Class SMBHelper
- java.lang.Object
-
- com.logicaldoc.importfolder.CrawlerHelper
-
- com.logicaldoc.importfolder.smb.SMBHelper
-
public class SMBHelper extends CrawlerHelper
Helper for SMB shares(it uses jCIFS and can work with SMB1 or SMB2).- Since:
- 4.5
- Author:
- Marco Meschieri - LogicalDOC
-
-
Constructor Summary
Constructors Constructor Description SMBHelper(ImportFolder importFolder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckinFile(Object file, long docId, com.logicaldoc.core.security.User owner)Imports a remote file into an existing document producing a new versionbooleandeleteFile(Object file)Delete the given referenced file after document import.static FiledownloadFile(jcifs.smb.SmbFile f)Downloads a remote file into a local copyFilegetContentFile(String path)Retrieves a file that contains the content referenced by pathDategetCreationDate(Object file)Computes remote file creation datejcifs.smb.SmbFilegetFile(String path)Gets the object representation of the given pathDategetLastModified(Object file)Computes remote file last modification timeStringgetName(Object file)Computes the name of the remote fileStringgetPath(Object file)Computes the path of the remote filestatic jcifs.CIFSContextgetSmbContext(ImportFolder importFolder)intimportDocumentsCount()The documents, referenced by a index file, that should be imported.com.logicaldoc.core.document.DocumentimportFile(Object file, com.logicaldoc.core.folder.Folder folder, com.logicaldoc.core.security.User owner, boolean timestamp)Imports a remote filevoidimportUsingIndex(ImportFolderCrawler crawler)Imports documents referenced by a index filevoidlist(Object parent, int depth, List<Object> folders, List<Object> files, long max, ImportFolderCache cache)Lists all files in a remote folderbooleantestConnection()Tests if the import folder can be accessed-
Methods inherited from class com.logicaldoc.importfolder.CrawlerHelper
getInstance, toBeImported
-
-
-
-
Constructor Detail
-
SMBHelper
public SMBHelper(ImportFolder importFolder) throws com.logicaldoc.core.PersistenceException
- Throws:
com.logicaldoc.core.PersistenceException
-
-
Method Detail
-
checkinFile
public void checkinFile(Object file, long docId, com.logicaldoc.core.security.User owner) throws Exception
Description copied from class:CrawlerHelperImports a remote file into an existing document producing a new version- Specified by:
checkinFilein classCrawlerHelper- Parameters:
file- The file to be loadeddocId- The document identifierowner- The owner user- Throws:
Exception- a generic error happened
-
importFile
public com.logicaldoc.core.document.Document importFile(Object file, com.logicaldoc.core.folder.Folder folder, com.logicaldoc.core.security.User owner, boolean timestamp) throws Exception
Description copied from class:CrawlerHelperImports a remote file- Specified by:
importFilein classCrawlerHelper- 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
-
list
public void list(Object parent, int depth, List<Object> folders, List<Object> files, long max, ImportFolderCache cache) throws Exception
Description copied from class:CrawlerHelperLists all files in a remote folder- Specified by:
listin classCrawlerHelper- 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
-
downloadFile
public static File downloadFile(jcifs.smb.SmbFile f) throws Exception
Downloads a remote file into a local copy- Parameters:
f- the remote file- Returns:
- The local file copy
- Throws:
Exception- a generic error happened
-
getContentFile
public File getContentFile(String path)
Description copied from class:CrawlerHelperRetrieves a file that contains the content referenced by path- Specified by:
getContentFilein classCrawlerHelper- Parameters:
path- the full path of a remote file- Returns:
- a local file containing the remote file's content
-
getFile
public jcifs.smb.SmbFile getFile(String path)
Description copied from class:CrawlerHelperGets the object representation of the given path- Specified by:
getFilein classCrawlerHelper- Parameters:
path- the full path of a remote file- Returns:
- the remote file at the specified path
-
getName
public String getName(Object file) throws Exception
Description copied from class:CrawlerHelperComputes the name of the remote file- Specified by:
getNamein classCrawlerHelper- Parameters:
file- The file to be considered- Returns:
- The name
- Throws:
Exception- a generic error happened
-
getPath
public String getPath(Object file) throws Exception
Description copied from class:CrawlerHelperComputes the path of the remote file- Specified by:
getPathin classCrawlerHelper- Parameters:
file- The file to be considered- Returns:
- The path
- Throws:
Exception- a generic error happened
-
getLastModified
public Date getLastModified(Object file)
Description copied from class:CrawlerHelperComputes remote file last modification time- Specified by:
getLastModifiedin classCrawlerHelper- Parameters:
file- The file to be considered- Returns:
- The last modification time
-
getCreationDate
public Date getCreationDate(Object file)
Description copied from class:CrawlerHelperComputes remote file creation date- Specified by:
getCreationDatein classCrawlerHelper- Parameters:
file- The file to be considered- Returns:
- The creation date
-
getSmbContext
public static jcifs.CIFSContext getSmbContext(ImportFolder importFolder)
-
importUsingIndex
public void importUsingIndex(ImportFolderCrawler crawler) throws Exception
Description copied from class:CrawlerHelperImports documents referenced by a index file- Specified by:
importUsingIndexin classCrawlerHelper- Parameters:
crawler- The current ImportFolderCrawler task- Throws:
Exception- a generic error happened
-
importDocumentsCount
public int importDocumentsCount() throws ExceptionDescription copied from class:CrawlerHelperThe documents, referenced by a index file, that should be imported. It returns -1 in case there is not index file- Specified by:
importDocumentsCountin classCrawlerHelper- Returns:
- number of documents references inside the index file
- Throws:
Exception- a generic error happened
-
deleteFile
public boolean deleteFile(Object file)
Description copied from class:CrawlerHelperDelete the given referenced file after document import.- Specified by:
deleteFilein classCrawlerHelper- Parameters:
file- The file that must be deleted- Returns:
- if the file has been successfully deleted
-
testConnection
public boolean testConnection()
Description copied from class:CrawlerHelperTests if the import folder can be accessed- Specified by:
testConnectionin classCrawlerHelper- Returns:
- true if the import folder is accessible
-
-