mFTPClient = new FTPClient();
/*
* Connect to the FTP Server
*/
Configuration config = Configuration.getInstance();
mHost = config.getValue(CHAPTER_FTPCONNECTION, mName, "Host");
mPort = config.getValueAsIntOptional(CHAPTER_FTPCONNECTION, mName,
"Port");
try
{
if (mPort > 0)
{
mFTPClient.connect(mHost, mPort);
}
else
{
mFTPClient.connect(mHost);
}
int reply = getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
close();
Vector params = new Vector(2);
params.add(mHost);
params.add(getReplyString());
throw new XException(Constants.LOCATION_EXTERN,
Constants.LAYER_TECHNICAL,
Constants.PACKAGE_TECHNICAL_FTP, "1", params);
}
mOpen = true;
/*
* Login to the FTP server
*/
String user = config.getValue(CHAPTER_FTPCONNECTION, mName,
"User");
String password = config.getValueOptional(
CHAPTER_FTPCONNECTION, mName, "Password");
String account = config.getValueOptional(CHAPTER_FTPCONNECTION,
mName, "Account");
boolean successful = false;
if (account == null)
{
successful = mFTPClient.login(user, password);
}
else
{
successful = mFTPClient.login(user, password, account);
}
if (!successful)
{
close();
Vector params = new Vector(3);
params.add(mHost);
params.add(user);
if (account == null)
{
throw new XException(Constants.LOCATION_EXTERN,
Constants.LAYER_TECHNICAL,
Constants.PACKAGE_TECHNICAL_FTP, "2", params);
}
else
{
params.add(user);
throw new XException(Constants.LOCATION_EXTERN,
Constants.LAYER_TECHNICAL,
Constants.PACKAGE_TECHNICAL_FTP, "3", params);
}
}
/*
* Set the file type
*/
int fileTypeInt = 0;
String fileTypeString = config.getValueOptional(
CHAPTER_FTPCONNECTION, mName, "FileType");
if (fileTypeString == null)
{
fileTypeString = "ASCII";
}