public class SmbSession
extends java.lang.Object
implements org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>
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.| Constructor and Description |
|---|
SmbSession(SmbShare _smbShare)
Constructor for an SMB session.
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(java.io.InputStream inputStream,
java.lang.String destination) |
void |
close() |
jcifs.smb.SmbFile |
createSmbDirectoryObject(java.lang.String _path)
Creates an SMB file object pointing to a remote directory.
|
jcifs.smb.SmbFile |
createSmbFileObject(java.lang.String _path)
Creates an SMB file object pointing to a remote file.
|
boolean |
exists(java.lang.String _path)
Checks whether the remote resource exists.
|
boolean |
finalizeRaw() |
java.lang.Object |
getClientInstance() |
boolean |
isDirectory(java.lang.String _path)
Checks whether the remote resource is a directory.
|
boolean |
isFile(java.lang.String _path)
Checks whether the remote resource is a file.
|
boolean |
isOpen()
Checks with this SMB session is open and ready for work by attempting
to list remote files and checking for error conditions..
|
jcifs.smb.SmbFile[] |
list(java.lang.String _path)
Returns the contents of the specified SMB resource as an array of SmbFile objects.
|
java.lang.String[] |
listNames(java.lang.String path) |
boolean |
mkdir(java.lang.String _path)
Creates the specified remote path if not yet exists.
|
void |
read(java.lang.String _path,
java.io.OutputStream _outputStream)
Reads the remote resource specified by path and copies its contents to the specified
OutputStream. |
java.io.InputStream |
readRaw(java.lang.String source) |
boolean |
remove(java.lang.String _path)
Deletes the file or directory at the specified path.
|
void |
rename(java.lang.String _pathFrom,
java.lang.String _pathTo) |
boolean |
rmdir(java.lang.String directory) |
jcifs.smb.SmbFile |
write(byte[] _contents,
java.lang.String _path)
Convenience method to write a byte array to a remote location.
|
jcifs.smb.SmbFile |
write(java.io.File _file,
java.lang.String _path)
Convenience method to write a local file object to a remote location.
|
void |
write(java.io.InputStream _inputStream,
java.lang.String _path)
Writes contents of the specified
InputStream to the remote resource
specified by path. |
public SmbSession(SmbShare _smbShare)
_smbShare - SMB share resourcepublic boolean remove(java.lang.String _path)
throws java.io.IOException
remove in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>_path - path to a remote file or directoryjava.io.IOException - on error conditions returned by a CIFS serverpublic jcifs.smb.SmbFile[] list(java.lang.String _path)
throws java.io.IOException
list in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>_path - path to a remote directoryjava.io.IOException - on error conditions returned by a CIFS server or if the remote resource is not a directory.public void read(java.lang.String _path,
java.io.OutputStream _outputStream)
throws java.io.IOException
OutputStream.read in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>_path - path to a remote file_outputStream - output streamjava.io.IOException - on error conditions returned by a CIFS server or if the remote resource is not a file.public void write(java.io.InputStream _inputStream,
java.lang.String _path)
throws java.io.IOException
InputStream to the remote resource
specified by path. Remote directories are created implicitly as required.write in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>_inputStream - input stream_path - remote path (of a file) to write tojava.io.IOException - on error conditions returned by a CIFS serverpublic jcifs.smb.SmbFile write(java.io.File _file,
java.lang.String _path)
throws java.io.IOException
_file - the local file_path - the remote path to write toSmbFile for remote filejava.io.IOException - the IO exceptionpublic jcifs.smb.SmbFile write(byte[] _contents,
java.lang.String _path)
throws java.io.IOException
_contents - the byte[] to write_path - the remote file to write toSmbFile for remote filejava.io.IOException - the IO exceptionpublic boolean mkdir(java.lang.String _path)
throws java.io.IOException
mkdir in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>_path - remote path to createjava.io.IOException - on error conditions returned by a CIFS serverpublic boolean exists(java.lang.String _path)
throws java.io.IOException
exists in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>_path - remote pathjava.io.IOException - on error conditions returned by a CIFS serverpublic boolean isFile(java.lang.String _path)
throws java.io.IOException
_path - remote pathjava.io.IOException - on error conditions returned by a CIFS serverpublic boolean isDirectory(java.lang.String _path)
throws java.io.IOException
_path - remote pathjava.io.IOException - on error conditions returned by a CIFS serverpublic void rename(java.lang.String _pathFrom,
java.lang.String _pathTo)
throws java.io.IOException
rename in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>java.io.IOExceptionpublic void append(java.io.InputStream inputStream,
java.lang.String destination)
throws java.io.IOException
append in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>java.io.IOExceptionpublic boolean rmdir(java.lang.String directory)
throws java.io.IOException
rmdir in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>java.io.IOExceptionpublic java.io.InputStream readRaw(java.lang.String source)
throws java.io.IOException
readRaw in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>java.io.IOExceptionpublic boolean finalizeRaw()
finalizeRaw in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>public java.lang.Object getClientInstance()
getClientInstance in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>public void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>public boolean isOpen()
isOpen in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>public jcifs.smb.SmbFile createSmbFileObject(java.lang.String _path)
throws java.io.IOException
_path - the remote file pathSmbFile for remote pathjava.io.IOException - the IO exceptionpublic jcifs.smb.SmbFile createSmbDirectoryObject(java.lang.String _path)
throws java.io.IOException
_path - the remote directory pathSmbFile for remote pathjava.io.IOException - the IO exceptionpublic java.lang.String[] listNames(java.lang.String path)
listNames in interface org.springframework.integration.file.remote.session.Session<jcifs.smb.SmbFile>