Package adams.core.io.lister
Class SmbDirectoryLister
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.io.lister.AbstractDirectoryLister
-
- adams.core.io.lister.AbstractRecursiveDirectoryLister
-
- adams.core.io.lister.SmbDirectoryLister
-
- All Implemented Interfaces:
DirectoryLister,RecursiveDirectoryLister,LoggingLevelHandler,LoggingSupporter,PasswordSupporter,SizeOfHandler,Stoppable,StoppableWithFeedback,Serializable
public class SmbDirectoryLister extends AbstractRecursiveDirectoryLister implements PasswordSupporter
Lists files/dirs on a remote server using SMB. The authentication object takes precedence over domain/user/password.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected com.hierynomus.smbj.SMBClientm_Clientthe SMB client.protected com.hierynomus.smbj.connection.Connectionm_Connectionthe SMB connection.protected com.hierynomus.smbj.share.DiskSharem_DiskSharethe diskshare in use.protected Stringm_Domainthe SMB domain.protected Stringm_Hostthe SMB host.protected booleanm_ListHiddenwhether to show hidden files/dirs.protected BasePasswordm_Passwordthe SMB password to use.protected com.hierynomus.smbj.session.Sessionm_Sessionthe session to use.protected SMBSessionProviderm_SessionProviderthe session provider to use.protected Stringm_Sharethe share to access.protected Stringm_Userthe SMB user to use.-
Fields inherited from class adams.core.io.lister.AbstractRecursiveDirectoryLister
m_MaxDepth, m_Recursive
-
Fields inherited from class adams.core.io.lister.AbstractDirectoryLister
m_ListDirs, m_ListFiles, m_MaxItems, m_RegExp, m_SortDescending, m_Sorting, m_Stopped, m_WatchDir
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description SmbDirectoryLister()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcleanUpSmb()Cleans up the SMB components.protected com.hierynomus.smbj.share.DiskSharegetDiskShare()Obtains the share instance to use.StringgetDomain()Returns the domain to use.StringgetHost()Returns the host to connect to.booleangetListHidden()Returns whether to list hidden dirs/files.BasePasswordgetPassword()Returns the SMB password to use.SMBSessionProvidergetSessionProvider()Returns the session provider to use.StringgetShare()Returns the share to access.StringgetUser()Returns the SMB user name to use.booleanhasParentDirectory()Returns whether the watch directory has a parent directory.booleanisLocal()Returns whether the directory lister operates locally or remotely.String[]list()Returns the list of files/directories in the watched directory.SmbFileObject[]listObjects()Returns the list of files/directories in the watched directory.SmbFileObjectnewDirectory(String dir)Returns a new directory relative to the watch directory.SmbFileObjectnewDirectory(String parent, String dir)Returns a new directory relative to the parent directory.List<SmbFileObject>search(String dir)Returns the list of files/directories in the watched directory.protected voidsearch(String dir, List<SortContainer> files, int depth)Performs the recursive search.voidsetDomain(String value)Sets the domain to use.voidsetHost(String value)Sets the host to connect to.voidsetListHidden(boolean value)Sets whether to list hidden dirs/files.voidsetPassword(BasePassword value)Sets the SMB password to use.voidsetSessionProvider(SMBSessionProvider value)Sets the session provider to use.voidsetShare(String value)Sets the share to use.voidsetUser(String value)Sets the SMB user to use.-
Methods inherited from class adams.core.io.lister.AbstractRecursiveDirectoryLister
getMaxDepth, getRecursive, setMaxDepth, setRecursive, toString
-
Methods inherited from class adams.core.io.lister.AbstractDirectoryLister
getDebug, getListDirs, getListFiles, getMaxItems, getRegExp, getSortDescending, getSorting, getWatchDir, isStopped, setDebug, setListDirs, setListFiles, setMaxItems, setRegExp, setSortDescending, setSorting, setWatchDir, stopExecution
-
Methods inherited from class adams.core.logging.CustomLoggingLevelObject
setLoggingLevel
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.io.lister.DirectoryLister
getListDirs, getListFiles, getMaxItems, getRegExp, getSortDescending, getSorting, getWatchDir, setListDirs, setListFiles, setMaxItems, setRegExp, setSortDescending, setSorting, setWatchDir
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.Stoppable
stopExecution
-
Methods inherited from interface adams.core.StoppableWithFeedback
isStopped
-
-
-
-
Field Detail
-
m_Host
protected String m_Host
the SMB host.
-
m_Share
protected String m_Share
the share to access.
-
m_Domain
protected String m_Domain
the SMB domain.
-
m_User
protected String m_User
the SMB user to use.
-
m_Password
protected BasePassword m_Password
the SMB password to use.
-
m_ListHidden
protected boolean m_ListHidden
whether to show hidden files/dirs.
-
m_SessionProvider
protected SMBSessionProvider m_SessionProvider
the session provider to use.
-
m_Client
protected transient com.hierynomus.smbj.SMBClient m_Client
the SMB client.
-
m_Connection
protected transient com.hierynomus.smbj.connection.Connection m_Connection
the SMB connection.
-
m_Session
protected transient com.hierynomus.smbj.session.Session m_Session
the session to use.
-
m_DiskShare
protected transient com.hierynomus.smbj.share.DiskShare m_DiskShare
the diskshare in use.
-
-
Method Detail
-
setHost
public void setHost(String value)
Sets the host to connect to.- Parameters:
value- the host name/ip
-
getHost
public String getHost()
Returns the host to connect to.- Returns:
- the host name/ip
-
setDomain
public void setDomain(String value)
Sets the domain to use.- Parameters:
value- the domain
-
getDomain
public String getDomain()
Returns the domain to use.- Returns:
- the domain
-
setShare
public void setShare(String value)
Sets the share to use.- Parameters:
value- the share
-
getShare
public String getShare()
Returns the share to access.- Returns:
- the share
-
setUser
public void setUser(String value)
Sets the SMB user to use.- Parameters:
value- the user name
-
getUser
public String getUser()
Returns the SMB user name to use.- Returns:
- the user name
-
setPassword
public void setPassword(BasePassword value)
Sets the SMB password to use.- Specified by:
setPasswordin interfacePasswordSupporter- Parameters:
value- the password
-
getPassword
public BasePassword getPassword()
Returns the SMB password to use.- Specified by:
getPasswordin interfacePasswordSupporter- Returns:
- the password
-
setListHidden
public void setListHidden(boolean value)
Sets whether to list hidden dirs/files.- Parameters:
value- true if to list
-
getListHidden
public boolean getListHidden()
Returns whether to list hidden dirs/files.- Returns:
- true if to list
-
setSessionProvider
public void setSessionProvider(SMBSessionProvider value)
Sets the session provider to use.- Parameters:
value- the provider
-
getSessionProvider
public SMBSessionProvider getSessionProvider()
Returns the session provider to use.- Returns:
- the provider
-
getDiskShare
protected com.hierynomus.smbj.share.DiskShare getDiskShare()
Obtains the share instance to use.- Returns:
- the share
-
isLocal
public boolean isLocal()
Returns whether the directory lister operates locally or remotely.- Specified by:
isLocalin interfaceDirectoryLister- Returns:
- true if local lister
-
hasParentDirectory
public boolean hasParentDirectory()
Returns whether the watch directory has a parent directory.- Specified by:
hasParentDirectoryin interfaceDirectoryLister- Returns:
- true if parent directory available
-
newDirectory
public SmbFileObject newDirectory(String dir)
Returns a new directory relative to the watch directory.- Specified by:
newDirectoryin interfaceDirectoryLister- Parameters:
dir- the directory name- Returns:
- the new wrapper
-
newDirectory
public SmbFileObject newDirectory(String parent, String dir)
Returns a new directory relative to the parent directory.- Specified by:
newDirectoryin interfaceDirectoryLister- Parameters:
parent- the parent directorydir- the directory name- Returns:
- the new wrapper
-
search
protected void search(String dir, List<SortContainer> files, int depth) throws Exception
Performs the recursive search. Search goes deeper if != 0 (use -1 to start with for infinite search).- Parameters:
dir- the dir to searchfiles- the files collected so fardepth- the depth indicator (searched no deeper, if 0)- Throws:
Exception- if listing fails
-
search
public List<SmbFileObject> search(String dir) throws Exception
Returns the list of files/directories in the watched directory. In case the execution gets stopped, this method returns empty list.- Parameters:
dir- the directory to search- Returns:
- the list of absolute file/directory names
- Throws:
Exception- if listing fails
-
list
public String[] list()
Returns the list of files/directories in the watched directory. In case the execution gets stopped, this method returns a 0-length array.- Specified by:
listin interfaceDirectoryLister- Returns:
- the array of absolute file/directory names
-
listObjects
public SmbFileObject[] listObjects()
Returns the list of files/directories in the watched directory. In case the execution gets stopped, this method returns a 0-length array.- Specified by:
listObjectsin interfaceDirectoryLister- Returns:
- the array of file/directory wrappers
-
cleanUpSmb
protected void cleanUpSmb()
Cleans up the SMB components.
-
-