com.ibm.di.protocols
Class FTPBean

java.lang.Object
  extended by com.ibm.di.protocols.FTPBean

public class FTPBean
extends Object

This class helps to expose the functionality of the FTP Client through the scripting environment.


Nested Class Summary
static class FTPBean.DirectoryContents
          This class is a container in which the contents of a directory can be saved.
 
Constructor Summary
FTPBean()
          Constructor creating the FTP client object.
 
Method Summary
 boolean cd(String path)
          Changes the working directory.
 boolean close()
          Closes the connection of the FTP client to the server.
 boolean connect(String host, String username, String password)
          Connects to the specified FTP server using the given credentials to login.
 boolean connect(String host, String username, String password, boolean useSSLonCommandChannel, boolean useSSLonDataChannel)
          Connects to the specified FTP server using the given credentials to login.
 Object dir()
          Returns an object representing the contents of the current working directory on the FTP server.
 boolean get(String remoteFile, String localFile)
          Gets a file from the FTP server.
 boolean getDebug()
          Gets the debug level that has been set.
 Exception getLastError()
          Returns the last exception occurred.
 boolean put(String localFile, String remoteFile)
          Puts a local file on the FTP server.
 boolean remove(String path)
          Deletes the given file/directory from the FTP server.
 boolean rename(String fromPath, String toPath)
          Renames the given file/directory on the FTP server.
 void setAscii()
          Sets ASCII transfer mode.
 void setBinary()
          Sets binary transfer mode.
 void setDebug(boolean debug)
          Sets the debug level of the FTP client.
 boolean setLastErr(Exception e)
          Sets the passed as parameter exception as the last exception of the FTP client so far.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FTPBean

public FTPBean()
Constructor creating the FTP client object.

Method Detail

connect

public boolean connect(String host,
                       String username,
                       String password)
Connects to the specified FTP server using the given credentials to login. No SSL security is used for the data and control channels created.

Parameters:
host - the host of the FTP server.
username - the username used to login.
password - the password used to login.
Returns:
true if no exception occurs, otherwise false.

connect

public boolean connect(String host,
                       String username,
                       String password,
                       boolean useSSLonCommandChannel,
                       boolean useSSLonDataChannel)
Connects to the specified FTP server using the given credentials to login. The usage of SSL on the data and control channels is specified by the last two parameters.

Parameters:
host - the host of the FTP server.
username - the username used to login.
password - the password used to login.
useSSLonCommandChannel - whether to use SSL on the control channel.
useSSLonDataChannel - whether to use SSL on the data channel.
Returns:
true if no exception occurs, otherwise false.

close

public boolean close()
Closes the connection of the FTP client to the server.

Returns:
true if no exception occurred, otherwise false.

setBinary

public void setBinary()
Sets binary transfer mode.


setAscii

public void setAscii()
Sets ASCII transfer mode.


get

public boolean get(String remoteFile,
                   String localFile)
Gets a file from the FTP server.

Parameters:
remoteFile - the file to be retrieved from the server.
localFile - the name used to save the file on the local machine.
Returns:
true if no exception occurs, otherwise false.

put

public boolean put(String localFile,
                   String remoteFile)
Puts a local file on the FTP server.

Parameters:
localFile - the local file to be sent to the server.
remoteFile - the name used for saving the file on the server.
Returns:
true if no exception occurs, otherwise false.

cd

public boolean cd(String path)
Changes the working directory.

Parameters:
path - the new working directory.
Returns:
true if no exception occurs, otherwise false.

dir

public Object dir()
Returns an object representing the contents of the current working directory on the FTP server.

Returns:
the current working directory contents.

remove

public boolean remove(String path)
Deletes the given file/directory from the FTP server.

Parameters:
path - the path of the file/directory to be removed.
Returns:
true if no exception occurs, otherwise false.

rename

public boolean rename(String fromPath,
                      String toPath)
Renames the given file/directory on the FTP server.

Parameters:
fromPath - old name.
toPath - new name.
Returns:
true if no exception occurs, otherwise false.

setLastErr

public boolean setLastErr(Exception e)
Sets the passed as parameter exception as the last exception of the FTP client so far.

Parameters:
e - an exception.
Returns:
true if the given exception is null, otherwise false.

getLastError

public Exception getLastError()
Returns the last exception occurred.

Returns:
the last occurred exception.

setDebug

public void setDebug(boolean debug)
Sets the debug level of the FTP client.

Parameters:
debug - if true detailed logging will be used, otherwise no.

getDebug

public boolean getDebug()
Gets the debug level that has been set.

Returns:
true if detailed logging is used, otherwise false.