commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dale Lee (JIRA)" <j...@apache.org>
Subject [jira] [Created] (NET-573) CLONE - Retrieving files from AS400 FTP systems returns null timestamps in FTPFile.getTimestamp
Date Thu, 21 May 2015 03:03:59 GMT
Dale Lee created NET-573:
----------------------------

             Summary: 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: 3.2
         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