* Pass on return values from FTPClient class. Fixes bug 469.
This commit is contained in:
parent
b3c82d5a06
commit
bd8b266fa9
1 changed files with 26 additions and 26 deletions
52
helma/Ftp.js
52
helma/Ftp.js
|
@ -8,10 +8,10 @@
|
||||||
*
|
*
|
||||||
* Copyright 1998-2006 Helma Software. All Rights Reserved.
|
* Copyright 1998-2006 Helma Software. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* $RCSfile: helma.Ftp.js,v $
|
* $RCSfile: Ftp.js,v $
|
||||||
* $Author: czv $
|
* $Author: czv $
|
||||||
* $Revision: 1.7 $
|
* $Revision: 1.2 $
|
||||||
* $Date: 2006/04/18 13:06:58 $
|
* $Date: 2006/04/24 07:02:17 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ helma.Ftp = function(server) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var debug = function(methName, msg) {
|
var debug = function(methName, msg) {
|
||||||
var msg = msg ? " " + msg : "";
|
msg = msg ? " " + msg : "";
|
||||||
app.debug(className + ":" + methName + msg);
|
app.debug(className + ":" + methName + msg);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -112,9 +112,9 @@ helma.Ftp = function(server) {
|
||||||
this.login = function(username, password) {
|
this.login = function(username, password) {
|
||||||
try {
|
try {
|
||||||
ftpclient.connect(this.server);
|
ftpclient.connect(this.server);
|
||||||
ftpclient.login(username, password);
|
var result = ftpclient.login(username, password);
|
||||||
debug("login", username + "@" + server);
|
debug("login", username + "@" + server);
|
||||||
return true;
|
return result;
|
||||||
} catch(x) {
|
} catch(x) {
|
||||||
error("login", x);
|
error("login", x);
|
||||||
setStatus(LOGIN);
|
setStatus(LOGIN);
|
||||||
|
@ -124,9 +124,9 @@ helma.Ftp = function(server) {
|
||||||
|
|
||||||
this.binary = function() {
|
this.binary = function() {
|
||||||
try {
|
try {
|
||||||
ftpclient.setFileType(FTP.BINARY_FILE_TYPE);
|
var result = ftpclient.setFileType(FTP.BINARY_FILE_TYPE);
|
||||||
debug("binary");
|
debug("binary");
|
||||||
return true;
|
return result;
|
||||||
} catch(x) {
|
} catch(x) {
|
||||||
error("binary", x);
|
error("binary", x);
|
||||||
setStatus(BINARY);
|
setStatus(BINARY);
|
||||||
|
@ -136,9 +136,9 @@ helma.Ftp = function(server) {
|
||||||
|
|
||||||
this.ascii = function() {
|
this.ascii = function() {
|
||||||
try {
|
try {
|
||||||
ftpclient.setFileType(FTP.ASCII_FILE_TYPE);
|
var result = ftpclient.setFileType(FTP.ASCII_FILE_TYPE);
|
||||||
debug("ascii");
|
debug("ascii");
|
||||||
return true;
|
return result;
|
||||||
} catch(x) {
|
} catch(x) {
|
||||||
error("ascii", x);
|
error("ascii", x);
|
||||||
setStatus(ASCII);
|
setStatus(ASCII);
|
||||||
|
@ -194,9 +194,9 @@ helma.Ftp = function(server) {
|
||||||
|
|
||||||
this.mkdir = function(dir) {
|
this.mkdir = function(dir) {
|
||||||
try {
|
try {
|
||||||
ftpclient.makeDirectory(dir);
|
var result = ftpclient.makeDirectory(dir);
|
||||||
debug("mkdir", dir);
|
debug("mkdir", dir);
|
||||||
return true;
|
return result;
|
||||||
} catch(x) {
|
} catch(x) {
|
||||||
error("mkdir", x);
|
error("mkdir", x);
|
||||||
setStatus(MKDIR);
|
setStatus(MKDIR);
|
||||||
|
@ -206,9 +206,9 @@ helma.Ftp = function(server) {
|
||||||
|
|
||||||
this.rmdir = function(dir) {
|
this.rmdir = function(dir) {
|
||||||
try {
|
try {
|
||||||
ftpclient.removeDirectory(dir);
|
var result = ftpclient.removeDirectory(dir);
|
||||||
debug("rmdir", dir);
|
debug("rmdir", dir);
|
||||||
return true;
|
return result;
|
||||||
} catch(x) {
|
} catch(x) {
|
||||||
error("rmdir", x);
|
error("rmdir", x);
|
||||||
setStatus(RMDIR);
|
setStatus(RMDIR);
|
||||||
|
@ -218,9 +218,9 @@ helma.Ftp = function(server) {
|
||||||
|
|
||||||
this.cd = function(path) {
|
this.cd = function(path) {
|
||||||
try {
|
try {
|
||||||
ftpclient.changeWorkingDirectory(path);
|
var result = ftpclient.changeWorkingDirectory(path);
|
||||||
debug("cd", path);
|
debug("cd", path);
|
||||||
return true;
|
return result;
|
||||||
} catch(x) {
|
} catch(x) {
|
||||||
error("cd", x);
|
error("cd", x);
|
||||||
setStatus(CD);
|
setStatus(CD);
|
||||||
|
@ -259,10 +259,10 @@ helma.Ftp = function(server) {
|
||||||
if (!remoteFile) {
|
if (!remoteFile) {
|
||||||
remoteFile = f.getName();
|
remoteFile = f.getName();
|
||||||
}
|
}
|
||||||
ftpclient.storeFile(remoteFile, stream);
|
var result = ftpclient.storeFile(remoteFile, stream);
|
||||||
stream.close();
|
stream.close();
|
||||||
debug("putFile", remoteFile);
|
debug("putFile", remoteFile);
|
||||||
return true;
|
return result;
|
||||||
} catch(x) {
|
} catch(x) {
|
||||||
error("putFile", x);
|
error("putFile", x);
|
||||||
setStatus(PUT);
|
setStatus(PUT);
|
||||||
|
@ -275,9 +275,9 @@ helma.Ftp = function(server) {
|
||||||
str = new java.lang.String(str);
|
str = new java.lang.String(str);
|
||||||
var bytes = charset ? str.getBytes(charset) : str.getBytes();
|
var bytes = charset ? str.getBytes(charset) : str.getBytes();
|
||||||
var stream = ByteArrayInputStream(bytes);
|
var stream = ByteArrayInputStream(bytes);
|
||||||
ftpclient.storeFile(remoteFile, stream);
|
var result = ftpclient.storeFile(remoteFile, stream);
|
||||||
debug("putString", remoteFile);
|
debug("putString", remoteFile);
|
||||||
return true;
|
return result;
|
||||||
} catch(x) {
|
} catch(x) {
|
||||||
error("putString", x);
|
error("putString", x);
|
||||||
setStatus(PUT);
|
setStatus(PUT);
|
||||||
|
@ -294,10 +294,10 @@ helma.Ftp = function(server) {
|
||||||
var stream = new BufferedOutputStream(
|
var stream = new BufferedOutputStream(
|
||||||
new FileOutputStream(f.getPath())
|
new FileOutputStream(f.getPath())
|
||||||
);
|
);
|
||||||
ftpclient.retrieveFile(remoteFile, stream);
|
var result = ftpclient.retrieveFile(remoteFile, stream);
|
||||||
stream.close();
|
stream.close();
|
||||||
debug("getFile", remoteFile);
|
debug("getFile", remoteFile);
|
||||||
return true;
|
return result;
|
||||||
} catch(x) {
|
} catch(x) {
|
||||||
error("getFile", x);
|
error("getFile", x);
|
||||||
setStatus(GET);
|
setStatus(GET);
|
||||||
|
@ -320,9 +320,9 @@ helma.Ftp = function(server) {
|
||||||
|
|
||||||
this.deleteFile = function(remoteFile) {
|
this.deleteFile = function(remoteFile) {
|
||||||
try {
|
try {
|
||||||
ftpclient.deleteFile(remoteFile);
|
var result = ftpclient.deleteFile(remoteFile);
|
||||||
debug("deleteFile", remoteFile);
|
debug("deleteFile", remoteFile);
|
||||||
return true;
|
return result;
|
||||||
} catch(x) {
|
} catch(x) {
|
||||||
error("deleteFile", x);
|
error("deleteFile", x);
|
||||||
setStatus(DELETE);
|
setStatus(DELETE);
|
||||||
|
@ -332,10 +332,10 @@ helma.Ftp = function(server) {
|
||||||
|
|
||||||
this.logout = function() {
|
this.logout = function() {
|
||||||
try {
|
try {
|
||||||
ftpclient.logout();
|
var result = ftpclient.logout();
|
||||||
ftpclient.disconnect();
|
ftpclient.disconnect();
|
||||||
debug("logout");
|
debug("logout");
|
||||||
return true;
|
return result;
|
||||||
} catch(x) {
|
} catch(x) {
|
||||||
error("logout", x);
|
error("logout", x);
|
||||||
setStatus(LOGOUT);
|
setStatus(LOGOUT);
|
||||||
|
|
Loading…
Add table
Reference in a new issue