org.ow2.petals.bc.sftp.connection
Class WrappedSftpClient

java.lang.Object
  extended by com.sshtools.j2ssh.SshClient
      extended by org.ow2.petals.bc.sftp.connection.WrappedSftpClient

public class WrappedSftpClient
extends com.sshtools.j2ssh.SshClient

This class handle a connection to the SFTP server with the specified configuration parameter

Author:
”Mathieu CARROLLE - mathieu.carrolle@petalslink.com”

Field Summary
 
Fields inherited from class com.sshtools.j2ssh.SshClient
activeChannelListener, activeChannels, authentication, authenticationState, connection, eventHandler, forwarding, socketTimeout, transport, useDefaultForwarding
 
Constructor Summary
WrappedSftpClient(SFTPConnectionInfo connectionConfiguration, java.util.logging.Logger logger)
           
 
Method Summary
 void configure()
          Change the path on the remote server.
 void connectAndLog()
          Open a ssh connection on the remote server and open a sftpclient.
 void del(java.lang.String filePattern)
           
 org.w3c.dom.Document get(java.lang.String filePattern)
          Retrieve the file given by its filename on the SFTP server.
 javax.activation.DataHandler getAsAttachment(java.lang.String filePattern)
          Retrieve the file given by its filename on the SFTP server.
 SFTPConnectionInfo getInfo()
           
 java.util.List<java.lang.String> list()
          List the content of the directory specified in the SFTPConfigurationInfo used to build an instance of this object.
 java.util.Map<java.lang.String,javax.activation.DataHandler> mGet(java.util.List<java.lang.String> fileFilterList)
          Retrieve the specified files from the SSH server.
 boolean mput(java.util.Map<java.lang.String,javax.activation.DataHandler> attachments)
          Sends a set of files to a SFTP server.
 boolean putString(java.lang.String fileName, java.lang.String content)
          Create a new file - using the given filename - on the SFTP server, with the given content.
 
Methods inherited from class com.sshtools.j2ssh.SshClient
acceptsKey, addEventHandler, allowChannelOpen, authenticate, connect, connect, connect, connect, connect, connect, denyChannelOpen, disconnect, getActiveChannelCount, getActiveChannels, getActiveSession, getActiveSftpClient, getAuthenticationBanner, getAvailableAuthMethods, getConnectionProperties, getConnectionState, getForwardingClient, getIncomingByteCount, getOutgoingByteCount, getRemoteEOL, getRemoteEOLString, getServerHostKey, getServerId, hasActiveSession, hasActiveSftpClient, isActiveChannel, isAuthenticated, isConnected, openChannel, openScpClient, openScpClient, openSessionChannel, openSessionChannel, openSftpChannel, openSftpChannel, openSftpClient, openSftpClient, sendGlobalRequest, setKexTimeout, setKexTransferLimit, setSendIgnore, setSocketTimeout, setUseDefaultForwarding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WrappedSftpClient

public WrappedSftpClient(SFTPConnectionInfo connectionConfiguration,
                         java.util.logging.Logger logger)
Method Detail

configure

public void configure()
               throws java.io.IOException
Change the path on the remote server.

Throws:
java.io.IOException

connectAndLog

public void connectAndLog()
                   throws java.io.IOException
Open a ssh connection on the remote server and open a sftpclient.

Throws:
SshAuthenticationException
java.io.IOException

del

public void del(java.lang.String filePattern)
         throws java.io.IOException
Parameters:
filePattern -
Throws:
SshAuthenticationException
SftpClientPoolException
java.io.IOException

get

public org.w3c.dom.Document get(java.lang.String filePattern)
                         throws java.io.IOException
Retrieve the file given by its filename on the SFTP server.

Parameters:
filePattern - name of the file to get from the SFTP server
Returns:
the retrieved file, streamed
Throws:
SftpClientPoolException - if a problem on the client pool occur while performing this operation
SshAuthenticationException - if the given authentication information are not valid
java.io.IOException - if any IO problem occur while sending file or connecting to server

getAsAttachment

public javax.activation.DataHandler getAsAttachment(java.lang.String filePattern)
                                             throws java.io.IOException
Retrieve the file given by its filename on the SFTP server.

Parameters:
filePattern - name of the file to get from the SFTP server
Returns:
the retrieved file
Throws:
SftpClientPoolException - if a problem on the client pool occur while performing this operation
SshAuthenticationException - if the given authentication information are not valid
java.io.IOException - if any IO problem occur while sending file or connecting to server

getInfo

public SFTPConnectionInfo getInfo()

list

public java.util.List<java.lang.String> list()
                                      throws java.io.IOException
List the content of the directory specified in the SFTPConfigurationInfo used to build an instance of this object. Only the file are returned, directories are ignored, because this is not relevant since this component does not allow the user to swich from a directory to another.

Returns:
the list of the files found in the "working directory" specified the SFTPConnectionInfo object which configures this connection
Throws:
java.io.IOException - if any IO problem occur while sending file or connecting to server

mGet

public java.util.Map<java.lang.String,javax.activation.DataHandler> mGet(java.util.List<java.lang.String> fileFilterList)
                                                                  throws java.io.IOException
Retrieve the specified files from the SSH server.

Parameters:
fileFilterList - the list of files to get from the SFTP server
Returns:
fhe files specified in the list
Throws:
SftpClientPoolException - if a problem on the client pool occur while performing this operation
SshAuthenticationException - if the given authentication information are not valid
java.io.IOException - if any IO problem occur while sending file or connecting to server

mput

public boolean mput(java.util.Map<java.lang.String,javax.activation.DataHandler> attachments)
             throws java.io.IOException
Sends a set of files to a SFTP server.

Parameters:
attachments - the file to be send
Returns:
true if success
Throws:
SftpClientPoolException - if a problem on the client pool occur while performing this operation
SshAuthenticationException - if the given authentication information are not valid
java.io.IOException - if any IO problem occur while sending file or connecting to server

putString

public boolean putString(java.lang.String fileName,
                         java.lang.String content)
                  throws java.io.IOException
Create a new file - using the given filename - on the SFTP server, with the given content.

Parameters:
fileName - name of the file to write onto the SFTP server
content - file content, as String
Returns:
true if everything seems to be OK
Throws:
SftpClientPoolException - if a problem on the client pool occur while performing this operation
SshAuthenticationException - if the given authentication information are not valid
java.io.IOException - if any IO problem occur while sending file or connecting to server


Copyright © 2005-2011 Petals Link (EBM Websourcing). All Rights Reserved.