Hier der Code


Methode connectFTP_Server


Public boolean connectFTP_Server() {
boolean boolConnectFTP_Server = false;
String strCurrentMethod = "connectFTP_Server()";
sbErrorDescription = new StringBuffer();
if (as400 == null) {
return false;
}
this.ftpClient = new AS400FTP(getAs400());
this.ftpClient.addFTPListener(new MyFTPListener());
try {
this.ftpClient.setPort(System_i5_config_Static
.getSystem_i5_FTP_Port());
appendSessionLogEntry_fromFTPServer(this.ftpClient .getLastMessage());
sbErrorDescription.append(this.ftpClient.getLastMe ssage());
} catch (PropertyVetoException e1) {
Exc.excInfo_Sun.getInfo(e1, CLASSNAME, strCurrentMethod,
sbErrorDescription);
return false;
}
try {
boolConnectFTP_Server = this.ftpClient.connect();
appendSessionLogEntry_fromFTPServer(this.ftpClient .getLastMessage());
} catch (UnknownHostException e) {
sbErrorDescription.append("Der Hostname: "
+ getAs400().getSystemName());
sbErrorDescription.append(SEP + "ist ungültig");
Exc.excInfo_Sun.getInfo(e, CLASSNAME, strCurrentMethod,
sbErrorDescription);
return false;

Klasse MyFTPListener


class MyFTPListener extends java.lang.Object implements FTPListener {
String strCurrentMethod = "connected(FTPEvent fe)";

public void connected(FTPEvent fe) {
try {
appendSessionLogEntry_fromFTPServer("Testanfrage an FTP-Server: "
+ ftpClient.issueCommand("NOOP"));
appendSessionLogEntry_fromFTPServer(ftpClient
.issueCommand("SYSTEM"));
ftpClient.setDataTransferType(AS400FTP.BINARY);
appendSessionLogEntry_fromFTPServer(ftpClient.getL astMessage());
ftpClient.issueCommand("SITE NAMEFMT 1");
appendSessionLogEntry_fromInstall_i5("---------------------------------------");

} catch (IOException ioe) {
Exc.excInfo_Sun.getInfo(ioe, CLASSNAME, strCurrentMethod, null);
return;
}
}

public void disconnected(FTPEvent fe) {
appendSessionLogEntry_fromFTPServer(ftpClient.getL astMessage());
}

public void listed(FTPEvent fe) {
}

public void put(FTPEvent fe) {
appendSessionLogEntry_fromFTPServer(ftpClient.getL astMessage());
}

public void retrieved(FTPEvent fe) {
}


Methode puInstallFile:


public boolean putInstallFile(String strSourceFileName) {
boolean boolPut = false;
String strCurrentMethod = "putInstallFile()";
sbErrorDescription = new StringBuffer();
if (this.ftpClient == null || strSourceFileName == null) {
return false;
}
if (quitFTP_Server() == false){
return false;
}
if (connectFTP_Server() == false) {
return false;
}
strSourceFileName = Transform_StringValue
.setStringVariable(strSourceFileName);
QSYSObjectPathName targetPath = null;
try {
targetPath = build_INSTALL_SAVF_TargetPath(strSourceFileName);
if (targetPath == null) {
return false;
}
} catch (ExtendedIllegalArgumentException exc) {
Exc.excInfo_IBM
.getInfo(exc, getClassInfo(), strCurrentMethod, null);
return false;
}
//
String strTargetFileName = targetPath.getPath();
try {
appendSessionLogEntry_fromInstall_i5(SEP);
String strNewInst = "=================================";
appendSessionLogEntry_fromInstall_i5(strNewInst);
String strLogEnty = "Start Datenübertragung für Datei:";
appendSessionLogEntry_fromInstall_i5(strLogEnty);
appendSessionLogEntry_fromInstall_i5(strSourceFile Name);

Hier fällt die Anwendung auf die Nase

boolPut = this.ftpClient.put(strSourceFileName, strTargetFileName);

appendSessionLogEntry_fromFTPServer(ftpClient.getL astMessage());
sbErrorDescription.append(strLogEnty + " fehlgeschlagen:");
sbErrorDescription.append(this.ftpClient.getLastMe ssage());
} catch (IOException e)