Class SmbSession
java.lang.Object
org.springframework.integration.smb.session.SmbSession
- All Implemented Interfaces:
 Closeable,AutoCloseable,Session<jcifs.smb.SmbFile>
Implementation of the 
Session interface for Server Message Block (SMB)
 also known as Common Internet File System (CIFS). The Samba project set out to
 create non-Windows implementations of SMB. Often Samba is thus used synonymously to SMB.
 SMB is an application-layer network protocol that manages shared access to files, printers and other networked resources.
See Server Message Block for more details.
- Since:
 - 6.0
 - Author:
 - Markus Spann, Mark Fisher, Oleg Zhurakousky, Artem Bilan, Prafull Kumar Soni, Gregory Bragg, Adam Jones, Paolo Fosser
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoidappend(InputStream inputStream, String destination) Append to a file.voidclose()jcifs.smb.SmbFilecreateSmbDirectoryObject(String _path) Create an SMB file object pointing to a remote directory.jcifs.smb.SmbFilecreateSmbFileObject(String _path) Create an SMB file object pointing to a remote file.booleanCheck whether the remote resource exists.booleanInvoke after closing the InputStream fromSession.readRaw(String).Get the underlying client library's client instance for this session.Return the host:port pair this session is connected to.booleanisDirectory(String _path) Check whether the remote resource is a directory.booleanCheck whether the remote resource is a file.booleanisOpen()Check whether this SMB session is open and ready for work by attempting to list remote files and checking for error conditions.jcifs.smb.SmbFile[]Return the content of the specified SMB resource as an array of SmbFile objects.String[]Return the contents of the specified SMB resource as an array of SmbFile filenames.booleanCreate the specified remote path if not yet exists.voidread(String _path, OutputStream _outputStream) Read the remote resource specified by path and copies its contents to the specifiedOutputStream.Retrieve a remote file as a rawInputStream.booleanDelete the file or directory at the specified path.voidbooleanRemove a remote directory.jcifs.smb.SmbFileConvenience method to write a byte array to a remote location.jcifs.smb.SmbFileConvenience method to write a local file object to a remote location.voidwrite(InputStream _inputStream, String _path) Write contents of the specifiedInputStreamto the remote resource specified by path. 
- 
Constructor Details
 - 
Method Details
- 
remove
Delete the file or directory at the specified path.- Specified by:
 removein interfaceSession<jcifs.smb.SmbFile>- Parameters:
 _path- path to a remote file or directory- Returns:
 - true if delete successful, false if resource is non-existent
 - Throws:
 IOException- on error conditions returned by a CIFS server
 - 
list
Return the content of the specified SMB resource as an array of SmbFile objects. In case the remote resource does not exist, an empty array is returned.- Specified by:
 listin interfaceSession<jcifs.smb.SmbFile>- Parameters:
 path- path to a remote directory or remote file path- Returns:
 - array of SmbFile objects
 - Throws:
 IOException- on error conditions returned by a CIFS server.
 - 
listNames
Return the contents of the specified SMB resource as an array of SmbFile filenames. In case the remote resource does not exist, an empty array is returned.- Specified by:
 listNamesin interfaceSession<jcifs.smb.SmbFile>- Parameters:
 _path- path to a remote directory- Returns:
 - array of SmbFile filenames
 - Throws:
 IOException- on error conditions returned by a CIFS server or if the remote resource is not a directory.
 - 
read
Read the remote resource specified by path and copies its contents to the specifiedOutputStream.- Specified by:
 readin interfaceSession<jcifs.smb.SmbFile>- Parameters:
 _path- path to a remote file_outputStream- output stream- Throws:
 IOException- on error conditions returned by a CIFS server or if the remote resource is not a file.
 - 
write
Write contents of the specifiedInputStreamto the remote resource specified by path. Remote directories are created implicitly as required.- Specified by:
 writein interfaceSession<jcifs.smb.SmbFile>- Parameters:
 _inputStream- input stream_path- remote path (of a file) to write to- Throws:
 IOException- on error conditions returned by a CIFS server
 - 
write
Convenience method to write a local file object to a remote location.- Parameters:
 _file- the local file_path- the remote path to write to- Returns:
 - the 
SmbFilefor remote file - Throws:
 IOException- the IO exception
 - 
write
Convenience method to write a byte array to a remote location.- Parameters:
 _contents- thebyte[]to write_path- the remote file to write to- Returns:
 - the 
SmbFilefor remote file - Throws:
 IOException- the IO exception
 - 
mkdir
Create the specified remote path if not yet exists. If the specified resource is a file rather than a path, creates all directories leading to that file.- Specified by:
 mkdirin interfaceSession<jcifs.smb.SmbFile>- Parameters:
 _path- remote path to create- Returns:
 - always true (error states are express by exceptions)
 - Throws:
 IOException- on error conditions returned by a CIFS server
 - 
exists
Check whether the remote resource exists.- Specified by:
 existsin interfaceSession<jcifs.smb.SmbFile>- Parameters:
 _path- remote path- Returns:
 - true if exists, false otherwise
 - Throws:
 IOException- on error conditions returned by a CIFS server
 - 
isFile
Check whether the remote resource is a file.- Parameters:
 _path- remote path- Returns:
 - true if resource is a file, false otherwise
 - Throws:
 IOException- on error conditions returned by a CIFS server
 - 
isDirectory
Check whether the remote resource is a directory.- Parameters:
 _path- remote path- Returns:
 - true if resource is a directory, false otherwise
 - Throws:
 IOException- on error conditions returned by a CIFS server
 - 
rename
- Specified by:
 renamein interfaceSession<jcifs.smb.SmbFile>- Throws:
 IOException
 - 
append
Description copied from interface:SessionAppend to a file.- Specified by:
 appendin interfaceSession<jcifs.smb.SmbFile>- Parameters:
 inputStream- the stream.destination- the destination.- Throws:
 IOException- an IO Exception.
 - 
rmdir
Description copied from interface:SessionRemove a remote directory.- Specified by:
 rmdirin interfaceSession<jcifs.smb.SmbFile>- Parameters:
 directory- The directory.- Returns:
 - True if the directory was removed.
 - Throws:
 IOException- an IO exception.
 - 
readRaw
Description copied from interface:SessionRetrieve a remote file as a rawInputStream.- Specified by:
 readRawin interfaceSession<jcifs.smb.SmbFile>- Parameters:
 source- The path of the remote file.- Returns:
 - The raw inputStream.
 - Throws:
 IOException- Any IOException.
 - 
finalizeRaw
public boolean finalizeRaw()Description copied from interface:SessionInvoke after closing the InputStream fromSession.readRaw(String). Required by some session providers.- Specified by:
 finalizeRawin interfaceSession<jcifs.smb.SmbFile>- Returns:
 - true if successful.
 
 - 
getClientInstance
Description copied from interface:SessionGet the underlying client library's client instance for this session. Returns anObjectto avoid significant changes to -file, -ftp, -sftp modules, which would be required if we added another generic parameter. Implementations should narrow the return type.- Specified by:
 getClientInstancein interfaceSession<jcifs.smb.SmbFile>- Returns:
 - The client instance.
 
 - 
close
 - 
isOpen
 - 
createSmbFileObject
Create an SMB file object pointing to a remote file.- Parameters:
 _path- the remote file path- Returns:
 - the 
SmbFilefor remote path - Throws:
 IOException- the IO exception
 - 
createSmbDirectoryObject
Create an SMB file object pointing to a remote directory.- Parameters:
 _path- the remote directory path- Returns:
 - the 
SmbFilefor remote path - Throws:
 IOException- the IO exception
 - 
getHostPort
Description copied from interface:SessionReturn the host:port pair this session is connected to.- Specified by:
 getHostPortin interfaceSession<jcifs.smb.SmbFile>- Returns:
 - the host:port pair this session is connected to.
 
 
 -