commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (NET-573) CLONE - Retrieving files from AS400 FTP systems returns null timestamps in FTPFile.getTimestamp
Date Thu, 18 Jun 2015 22:08:00 GMT

    [ https://issues.apache.org/jira/browse/NET-573?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14592624#comment-14592624
] 

Sebb commented on NET-573:
--------------------------

There  are a couple of issues here.

1) FTPClientExample in 3.3 does not allow the server type or the default date format string
to be defined. The server type is determined from the response to the SYST command. However
the default date format for AS/400 is "yy/MM/dd HH:mm:ss", which cannot be used to parse the
date as MM cannot be 20. So the example is bound to fail.

2) I have tried to reproduce the problem with the code snippet. However that works fine when
tried with a dummy server using the StubFtpServer [1]. So long as the code sets the default
date string correctly, the timestamp is parsed correctly. 

3) The code snippet calls ftpClient.listFiles twice; this does not seem to affect the result,
but should be avoided.

My plan of action is to update the FTPClientExample so that the default date format can be
specified. Hopefully the 3.4-SNAPSHOT code can then be used to help debug the problem.

Is there a publicly accessible server that can be used for testing?

[1] http://mockftpserver.sourceforge.net/stubftpserver-getting-started.html

> CLONE - Retrieving files from AS400 FTP systems returns null timestamps in FTPFile.getTimestamp
> -----------------------------------------------------------------------------------------------
>
>                 Key: NET-573
>                 URL: https://issues.apache.org/jira/browse/NET-573
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 2.2, 3.2, 3.3
>         Environment: Commons Net 3.2
> FTP System: AS400 systems
> I5/OS Version 5 Release 4 Modification 0
>            Reporter: Dale Lee
>            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 was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message