[
https://issues.apache.org/jira/browse/NET-498?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sebb updated NET-498:
---------------------
Description:
We are trying to list files from AS400 systems and retrieve the timestamps from
these files using the following code:
{code}
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.commons.net.PrintCommandListener;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPHTTPClient;
import org.apache.commons.net.ftp.FTPClientConfig;
import org.apache.commons.net.ftp.FTPConnectionClosedException;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.net.ftp.FTPSClient;
import org.apache.commons.net.io.CopyStreamEvent;
import org.apache.commons.net.io.CopyStreamListener;
import org.apache.commons.net.util.TrustManagerUtils;
public final class FTPAccess {
private String server;
private String username;
private String password;
private String path ;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public static void main(String[] args) throws UnknownHostException {
FTPAccess ftpAccess = new FTPAccess();
ftpAccess.setServer("X.X.X.X");
ftpAccess.setUsername("XXXXXX");
ftpAccess.setPassword(XXXXXXX");
ftpAccess.setPath("/reports");
ftpAccess.getFile();
}
public void getFile() throws UnknownHostException {
FTPClient ftpClient = new FTPClient();
try {
InetAddress serveIPAddress =
InetAddress.getByName(server);
ftpClient.setPassiveLocalIPAddress(serveIPAddress);
ftpClient.connect(serveIPAddress);
System.out.println("Connected to " + server + ".");
int reply = ftpClient.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
System.err.println("FTP server refused
connection.");
System.err.println(ftpClient.getReplyString());
ftpClient.disconnect();
} else {
}
if (!ftpClient.login(username, password)) {
System.out.println(ftpClient.getReplyString());
ftpClient.logout();
} else{
diplayContent(ftpClient, path);
}
} catch (IOException e) {
if (ftpClient.isConnected()) {
try {
ftpClient.disconnect();
} catch (IOException ioException) {
// do nothing
}
}
System.err.println("Could not connect to server.");
// e.printStackTrace();
System.exit(1);
}
// } catch (FTPConnectionClosedException e) {
// error = true;
// System.err.println("Server closed connection.");
// e.printStackTrace();
// } catch (IOException e) {
// error = true;
// e.printStackTrace();
// } finally {
// if (ftp.isConnected()) {
// try {
// ftp.disconnect();
// } catch (IOException f) {
// // do nothing
// }
// }
// }
} // end main
public String getServer() {
return server;
}
public void setServer(String server) {
this.server = server;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void diplayContent(FTPClient ftpClient, String path) throws
IOException {
System.out.println(path);
for (FTPFile ftpFile : ftpClient.listFiles(path)) {
if(ftpFile.isDirectory() ){
diplayContent(ftpClient,
path+"/"+ftpFile.getName());
} else{
System.out.println(path+"/"+ftpFile.getName());
System.out.println(ftpFile.getTimestamp());
}
}
}
}
{code}
The LIST command which is used internally in the FTPClient retrieves the
timestamps successfully. However after parsing the FTPFile has a null value for
the timestamp field.
The null value is returned just when a user place the file in the AS400 usint
the NetServer Servivice. This is used to share foldes between windows network
and the AS/400
Please help us fix this problem. It is not critical to us.
was:
We are trying to list files from AS400 systems and retrieve the timestamps from
these files using the following code:
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.commons.net.PrintCommandListener;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPHTTPClient;
import org.apache.commons.net.ftp.FTPClientConfig;
import org.apache.commons.net.ftp.FTPConnectionClosedException;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.net.ftp.FTPSClient;
import org.apache.commons.net.io.CopyStreamEvent;
import org.apache.commons.net.io.CopyStreamListener;
import org.apache.commons.net.util.TrustManagerUtils;
public final class FTPAccess {
private String server;
private String username;
private String password;
private String path ;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public static void main(String[] args) throws UnknownHostException {
FTPAccess ftpAccess = new FTPAccess();
ftpAccess.setServer("X.X.X.X");
ftpAccess.setUsername("XXXXXX");
ftpAccess.setPassword(XXXXXXX");
ftpAccess.setPath("/reports");
ftpAccess.getFile();
}
public void getFile() throws UnknownHostException {
FTPClient ftpClient = new FTPClient();
try {
InetAddress serveIPAddress =
InetAddress.getByName(server);
ftpClient.setPassiveLocalIPAddress(serveIPAddress);
ftpClient.connect(serveIPAddress);
System.out.println("Connected to " + server + ".");
int reply = ftpClient.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
System.err.println("FTP server refused
connection.");
System.err.println(ftpClient.getReplyString());
ftpClient.disconnect();
} else {
}
if (!ftpClient.login(username, password)) {
System.out.println(ftpClient.getReplyString());
ftpClient.logout();
} else{
diplayContent(ftpClient, path);
}
} catch (IOException e) {
if (ftpClient.isConnected()) {
try {
ftpClient.disconnect();
} catch (IOException ioException) {
// do nothing
}
}
System.err.println("Could not connect to server.");
// e.printStackTrace();
System.exit(1);
}
// } catch (FTPConnectionClosedException e) {
// error = true;
// System.err.println("Server closed connection.");
// e.printStackTrace();
// } catch (IOException e) {
// error = true;
// e.printStackTrace();
// } finally {
// if (ftp.isConnected()) {
// try {
// ftp.disconnect();
// } catch (IOException f) {
// // do nothing
// }
// }
// }
} // end main
public String getServer() {
return server;
}
public void setServer(String server) {
this.server = server;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void diplayContent(FTPClient ftpClient, String path) throws
IOException {
System.out.println(path);
for (FTPFile ftpFile : ftpClient.listFiles(path)) {
if(ftpFile.isDirectory() ){
diplayContent(ftpClient,
path+"/"+ftpFile.getName());
} else{
System.out.println(path+"/"+ftpFile.getName());
System.out.println(ftpFile.getTimestamp());
}
}
}
}
The LIST command which is used internally in the FTPClient retrieves the
timestamps successfully. However after parsing the FTPFile has a null value for
the timestamp field.
The null value is returned just when a user place the file in the AS400 usint
the NetServer Servivice. This is used to share foldes between windows network
and the AS/400
Please help us fix this problem. It is not critical to us.
> CLONE - Retrieving files from AS400 FTP systems returns null timestamps in
> FTPFile.getTimestamp
> -----------------------------------------------------------------------------------------------
>
> Key: NET-498
> URL: https://issues.apache.org/jira/browse/NET-498
> Project: Commons Net
> Issue Type: Bug
> Components: FTP
> Affects Versions: 3.2
> Environment: Commons Net 3.2
> FTP System: AS400 systems
> I5/OS Version 5 Release 4 Modification 0
> Reporter: Marco Slehiman
> Priority: Minor
>
> We are trying to list files from AS400 systems and retrieve the timestamps
> from these files using the following code:
> {code}
> import java.io.FileInputStream;
> import java.io.FileOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.OutputStream;
> import java.io.PrintWriter;
> import java.net.InetAddress;
> import java.net.UnknownHostException;
> import org.apache.commons.net.PrintCommandListener;
> import org.apache.commons.net.ftp.FTP;
> import org.apache.commons.net.ftp.FTPClient;
> import org.apache.commons.net.ftp.FTPHTTPClient;
> import org.apache.commons.net.ftp.FTPClientConfig;
> import org.apache.commons.net.ftp.FTPConnectionClosedException;
> import org.apache.commons.net.ftp.FTPFile;
> import org.apache.commons.net.ftp.FTPReply;
> import org.apache.commons.net.ftp.FTPSClient;
> import org.apache.commons.net.io.CopyStreamEvent;
> import org.apache.commons.net.io.CopyStreamListener;
> import org.apache.commons.net.util.TrustManagerUtils;
> public final class FTPAccess {
> private String server;
> private String username;
> private String password;
> private String path ;
> public String getPath() {
> return path;
> }
> public void setPath(String path) {
> this.path = path;
> }
> public static void main(String[] args) throws UnknownHostException {
> FTPAccess ftpAccess = new FTPAccess();
> ftpAccess.setServer("X.X.X.X");
> ftpAccess.setUsername("XXXXXX");
> ftpAccess.setPassword(XXXXXXX");
> ftpAccess.setPath("/reports");
> ftpAccess.getFile();
> }
> public void getFile() throws UnknownHostException {
>
> FTPClient ftpClient = new FTPClient();
>
> try {
> InetAddress serveIPAddress =
> InetAddress.getByName(server);
> ftpClient.setPassiveLocalIPAddress(serveIPAddress);
> ftpClient.connect(serveIPAddress);
> System.out.println("Connected to " + server + ".");
> int reply = ftpClient.getReplyCode();
> if (!FTPReply.isPositiveCompletion(reply)) {
> System.err.println("FTP server refused
> connection.");
> System.err.println(ftpClient.getReplyString());
> ftpClient.disconnect();
> } else {
> }
> if (!ftpClient.login(username, password)) {
> System.out.println(ftpClient.getReplyString());
> ftpClient.logout();
> } else{
> diplayContent(ftpClient, path);
> }
> } catch (IOException e) {
> if (ftpClient.isConnected()) {
> try {
> ftpClient.disconnect();
> } catch (IOException ioException) {
> // do nothing
> }
> }
> System.err.println("Could not connect to server.");
> // e.printStackTrace();
> System.exit(1);
> }
> // } catch (FTPConnectionClosedException e) {
> // error = true;
> // System.err.println("Server closed connection.");
> // e.printStackTrace();
> // } catch (IOException e) {
> // error = true;
> // e.printStackTrace();
> // } finally {
> // if (ftp.isConnected()) {
> // try {
> // ftp.disconnect();
> // } catch (IOException f) {
> // // do nothing
> // }
> // }
> // }
> } // end main
> public String getServer() {
> return server;
> }
> public void setServer(String server) {
> this.server = server;
> }
> public String getUsername() {
> return username;
> }
> public void setUsername(String username) {
> this.username = username;
> }
> public String getPassword() {
> return password;
> }
> public void setPassword(String password) {
> this.password = password;
> }
>
> public void diplayContent(FTPClient ftpClient, String path) throws
> IOException {
> System.out.println(path);
> for (FTPFile ftpFile : ftpClient.listFiles(path)) {
> if(ftpFile.isDirectory() ){
> diplayContent(ftpClient,
> path+"/"+ftpFile.getName());
> } else{
> System.out.println(path+"/"+ftpFile.getName());
> System.out.println(ftpFile.getTimestamp());
> }
> }
>
> }
> }
> {code}
> The LIST command which is used internally in the FTPClient retrieves the
> timestamps successfully. However after parsing the FTPFile has a null value
> for the timestamp field.
> The null value is returned just when a user place the file in the AS400 usint
> the NetServer Servivice. This is used to share foldes between windows network
> and the AS/400
> Please help us fix this problem. It is not critical to us.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira