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 jcifs.smb.NtlmPasswordAuthentication
m_Authentication
the authentication to use.protected SMBAuthenticationProvider
m_AuthenticationProvider
the authentication provider to use.protected String
m_Domain
the SMB domain.protected String
m_Host
the SMB host.protected BasePassword
m_Password
the SMB password to use.protected String
m_User
the 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 SMBAuthenticationProvider
getAuthenticationProvider()
Returns the authentication provider to use.String
getDomain()
Returns the domain to use.String
getHost()
Returns the host to connect to.BasePassword
getPassword()
Returns the SMB password to use.String
getUser()
Returns the SMB user name to use.boolean
hasParentDirectory()
Returns whether the watch directory has a parent directory.boolean
isLocal()
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.SmbFileObject
newDirectory(String dir)
Returns a new directory relative to the watch directory.SmbFileObject
newDirectory(String parent, String dir)
Returns a new directory relative to the watch directory.List<SmbFileObject>
search(jcifs.smb.SmbFile context)
Returns the list of files/directories in the watched directory.protected void
search(jcifs.smb.SmbFile context, List<SortContainer> files, int depth)
Performs the recursive search.void
setAuthenticationProvider(SMBAuthenticationProvider value)
Sets the authentication provider to use.void
setDomain(String value)
Sets the domain to use.void
setHost(String value)
Sets the host to connect to.void
setPassword(BasePassword value)
Sets the SMB password to use.void
setUser(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_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_AuthenticationProvider
protected SMBAuthenticationProvider m_AuthenticationProvider
the authentication provider to use.
-
m_Authentication
protected transient jcifs.smb.NtlmPasswordAuthentication m_Authentication
the authentication to 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
-
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:
setPassword
in interfacePasswordSupporter
- Parameters:
value
- the password
-
getPassword
public BasePassword getPassword()
Returns the SMB password to use.- Specified by:
getPassword
in interfacePasswordSupporter
- Returns:
- the password
-
setAuthenticationProvider
public void setAuthenticationProvider(SMBAuthenticationProvider value)
Sets the authentication provider to use.- Parameters:
value
- the provider
-
getAuthenticationProvider
public SMBAuthenticationProvider getAuthenticationProvider()
Returns the authentication provider to use.- Returns:
- the provider
-
isLocal
public boolean isLocal()
Returns whether the directory lister operates locally or remotely.- Specified by:
isLocal
in interfaceDirectoryLister
- Returns:
- true if local lister
-
hasParentDirectory
public boolean hasParentDirectory()
Returns whether the watch directory has a parent directory.- Specified by:
hasParentDirectory
in interfaceDirectoryLister
- Returns:
- true if parent directory available
-
newDirectory
public SmbFileObject newDirectory(String dir)
Returns a new directory relative to the watch directory.- Specified by:
newDirectory
in 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 watch directory.- Specified by:
newDirectory
in interfaceDirectoryLister
- Parameters:
dir
- the directory nameparent
- the parent directory- Returns:
- the new wrapper
-
search
protected void search(jcifs.smb.SmbFile context, 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:
context
- the context to usefiles
- the files collected so fardepth
- the depth indicator (searched no deeper, if 0)- Throws:
Exception
- if listing fails
-
search
public List<SmbFileObject> search(jcifs.smb.SmbFile context) throws Exception
Returns the list of files/directories in the watched directory. In case the execution gets stopped, this method returns empty list.- Parameters:
context
- the context- 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:
list
in interfaceDirectoryLister
- Returns:
- the list 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:
listObjects
in interfaceDirectoryLister
- Returns:
- the list of file/directory wrappers
-
-