com.sshtools.sftp.subsystem
Class SftpClientImpl

java.lang.Object
  extended by com.sshtools.sftp.AbstractSftpClient
      extended by com.sshtools.sftp.subsystem.SftpClientImpl
All Implemented Interfaces:
Client, SftpClient

public class SftpClientImpl
extends AbstractSftpClient


Field Summary
 
Fields inherited from class com.sshtools.sftp.AbstractSftpClient
ssh, umask
 
Fields inherited from interface com.sshtools.sftp.SftpClient
EOL_CR, EOL_CRLF, EOL_LF, GlobSyntax, MODE_BINARY, MODE_TEXT, NoSyntax, Perl5Syntax
 
Constructor Summary
SftpClientImpl(SshClient ssh, int maxVersion)
           
 
Method Summary
protected  void changeGroup(String gid, String path)
           
protected  void changeOwner(String uid, String path)
           
protected  void changePermissions(String filename, int permissions)
           
protected  void close()
           
protected  void createSymbolicLink(String path, String link)
           
protected  SftpFileAttributes getAttributes(String file)
           
protected  byte[] getCanonicalNewline()
           
 SftpSubsystemChannel getChannel()
           
 String getDefaultDirectory()
           Get the default directory (or HOME directory)
 SftpFile getFile(String path)
           
 InputStream getInputStream(String remotefile, long position)
          Create an InputStream for reading a remote file.
 OutputStream getOutputStream(String remotefile)
          Create an OutputStream for writing to a remote file.
protected  String getRealPath(String path)
           
 int getVersion()
           
 boolean isClosed()
           Returns the state of the SFTP client.
 SftpFile[] ls(String path)
           List the contents remote directory.
protected  void makeDirectory(String dir, SftpFileAttributes attrs)
           
protected  void onInit(int maxVersion)
           
protected  SftpFileAttributes performDownload(String remote, OutputStream local, FileTransferProgress progress, long position)
           
protected  void performUpload(InputStream in, String path, FileTransferProgress progress, long position)
           
protected  void removeDirectory(String filename)
           
protected  void removeFile(String filename)
           
protected  void renameFile(String from, String to)
           
 void setAttributes(String file, SftpFileAttributes attrs)
           Updates a file's attributes.
 
Methods inherited from class com.sshtools.sftp.AbstractSftpClient
addCustomRoot, cd, cdup, chgrp, chmod, chown, copyLocalDirectory, copyRemoteDirectory, exit, formatLongname, formatLongname, get, get, get, get, get, get, get, get, get, get, get, get, getAbsolutePath, getCharsetEncoding, getFiles, getFiles, getFiles, getFiles, getFiles, getFiles, getFiles, getFiles, getFiles, getFiles, getFiles, getFiles, getInputStream, getTransferMode, isDirectoryOrLinkedDirectory, lcd, lpwd, ls, mkdir, mkdirs, put, put, put, put, put, put, put, put, put, put, put, put, putFiles, putFiles, putFiles, putFiles, putFiles, putFiles, putFiles, putFiles, putFiles, putFiles, putFiles, putFiles, pwd, quit, removeCustomRoot, rename, resolveRemotePath, rm, rm, setRegularExpressionSyntax, setRemoteEOL, setTransferMode, stat, symlink, umask, umask, verifyConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SftpClientImpl

public SftpClientImpl(SshClient ssh,
                      int maxVersion)
               throws SshException,
                      ChannelOpenException,
                      SftpStatusException
Throws:
SshException
ChannelOpenException
SftpStatusException
Method Detail

onInit

protected void onInit(int maxVersion)
               throws SshException,
                      ChannelOpenException,
                      SftpStatusException
Specified by:
onInit in class AbstractSftpClient
Throws:
SshException
ChannelOpenException
SftpStatusException

getDefaultDirectory

public String getDefaultDirectory()
                           throws SftpStatusException,
                                  SshException
Description copied from interface: SftpClient

Get the default directory (or HOME directory)

Returns:
String
Throws:
SftpStatusException
SshException

makeDirectory

protected void makeDirectory(String dir,
                             SftpFileAttributes attrs)
                      throws SftpStatusException,
                             SshException
Specified by:
makeDirectory in class AbstractSftpClient
Throws:
SftpStatusException
SshException

ls

public SftpFile[] ls(String path)
              throws SftpStatusException,
                     SshException
Description copied from interface: SftpClient

List the contents remote directory.

Returns a list of SftpFile instances for the remote directory.

Parameters:
path - the path on the remote server to list
Returns:
a list of SftpFile for the remote directory
Throws:
SftpStatusException
SshException

getChannel

public SftpSubsystemChannel getChannel()

getInputStream

public InputStream getInputStream(String remotefile,
                                  long position)
                           throws SftpStatusException,
                                  SshException
Description copied from interface: SftpClient
Create an InputStream for reading a remote file.

Returns:
InputStream
Throws:
SftpStatusException
SshException

getOutputStream

public OutputStream getOutputStream(String remotefile)
                             throws SftpStatusException,
                                    SshException
Description copied from interface: SftpClient
Create an OutputStream for writing to a remote file.

Returns:
OutputStream
Throws:
SftpStatusException
SshException

getAttributes

protected SftpFileAttributes getAttributes(String file)
                                    throws SftpStatusException,
                                           SshException
Specified by:
getAttributes in class AbstractSftpClient
Throws:
SftpStatusException
SshException

getCanonicalNewline

protected byte[] getCanonicalNewline()
                              throws SftpStatusException
Specified by:
getCanonicalNewline in class AbstractSftpClient
Throws:
SftpStatusException

performDownload

protected SftpFileAttributes performDownload(String remote,
                                             OutputStream local,
                                             FileTransferProgress progress,
                                             long position)
                                      throws SftpStatusException,
                                             TransferCancelledException,
                                             SshException
Specified by:
performDownload in class AbstractSftpClient
Throws:
SftpStatusException
TransferCancelledException
SshException

isClosed

public boolean isClosed()
Description copied from interface: SftpClient

Returns the state of the SFTP client. The client is closed if the underlying session channel is closed. Invoking the quit method of this object will close the underlying session channel.

Specified by:
isClosed in interface SftpClient
Specified by:
isClosed in class AbstractSftpClient
Returns:
true if the client is still connected, otherwise false

getFile

public SftpFile getFile(String path)
                 throws SshException,
                        SftpStatusException
Specified by:
getFile in interface SftpClient
Overrides:
getFile in class AbstractSftpClient
Throws:
SshException
SftpStatusException

performUpload

protected void performUpload(InputStream in,
                             String path,
                             FileTransferProgress progress,
                             long position)
                      throws SftpStatusException,
                             SshException,
                             TransferCancelledException
Specified by:
performUpload in class AbstractSftpClient
Throws:
SftpStatusException
SshException
TransferCancelledException

setAttributes

public void setAttributes(String file,
                          SftpFileAttributes attrs)
                   throws SftpStatusException,
                          SshException
Description copied from interface: SftpClient

Updates a file's attributes. Note, this may not be supported by the implementation (e.g. if the SCP fallback is in use), so clients should catch the UnsupportedOperationException and react accordingly.

Parameters:
file - the path of the file
attrs - the attributes to set
Throws:
SftpStatusException
SshException
See Also:
SftpClient.stat(String)

changePermissions

protected void changePermissions(String filename,
                                 int permissions)
                          throws SftpStatusException,
                                 SshException
Specified by:
changePermissions in class AbstractSftpClient
Throws:
SftpStatusException
SshException

renameFile

protected void renameFile(String from,
                          String to)
                   throws SftpStatusException,
                          SshException
Specified by:
renameFile in class AbstractSftpClient
Throws:
SftpStatusException
SshException

removeDirectory

protected void removeDirectory(String filename)
                        throws SftpStatusException,
                               SshException
Specified by:
removeDirectory in class AbstractSftpClient
Throws:
SftpStatusException
SshException

removeFile

protected void removeFile(String filename)
                   throws SftpStatusException,
                          SshException
Specified by:
removeFile in class AbstractSftpClient
Throws:
SftpStatusException
SshException

createSymbolicLink

protected void createSymbolicLink(String path,
                                  String link)
                           throws SftpStatusException,
                                  SshException
Specified by:
createSymbolicLink in class AbstractSftpClient
Throws:
SftpStatusException
SshException

getRealPath

protected String getRealPath(String path)
                      throws SftpStatusException,
                             SshException
Specified by:
getRealPath in class AbstractSftpClient
Throws:
SftpStatusException
SshException

close

protected void close()
              throws SshIOException,
                     IOException
Specified by:
close in class AbstractSftpClient
Throws:
SshIOException
IOException

getVersion

public int getVersion()

changeGroup

protected void changeGroup(String gid,
                           String path)
                    throws SftpStatusException,
                           SshException
Specified by:
changeGroup in class AbstractSftpClient
Throws:
SftpStatusException
SshException

changeOwner

protected void changeOwner(String uid,
                           String path)
                    throws SftpStatusException,
                           SshException
Specified by:
changeOwner in class AbstractSftpClient
Throws:
SftpStatusException
SshException


Copyright © 2012. All Rights Reserved.