Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 14997 invoked from network); 9 Apr 2009 23:36:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Apr 2009 23:36:45 -0000 Received: (qmail 76710 invoked by uid 500); 9 Apr 2009 23:36:44 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 76612 invoked by uid 500); 9 Apr 2009 23:36:44 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 76602 invoked by uid 99); 9 Apr 2009 23:36:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Apr 2009 23:36:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Apr 2009 23:36:33 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id ED84E234C051 for ; Thu, 9 Apr 2009 16:36:12 -0700 (PDT) Message-ID: <1537519088.1239320172958.JavaMail.jira@brutus> Date: Thu, 9 Apr 2009 16:36:12 -0700 (PDT) From: "Shikhar Bhushan (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (NET-245) FTP: MFMT support In-Reply-To: <703043150.1228140644228.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/NET-245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12697687#action_12697687 ] Shikhar Bhushan commented on NET-245: ------------------------------------- This is a patch for adding support for the MFMT command. I tested this against proftpd which supports the feature. Index: FTPClient.java =================================================================== --- FTPClient.java (revision 763793) +++ FTPClient.java (working copy) @@ -2402,7 +2402,29 @@ return null; } + + /** + * Issue the FTP MFMT command (not supported by all servers) which sets the last + * modified time of a file. + * + * The timestamp should be in the form YYYYMMDDhhmmss. It should also + * be in GMT, but not all servers honour this. + * + * An FTP server would indicate its support of this feature by including "MFMT" + * in its response to the FEAT command, which may be retrieved by FTPClient.features() + * + * @param pathname The file path for which last modified time is to be changed. + * @param timeval The timestamp to set to, in YYYYMMDDhhmmss format. + * @return true if successfully set, false if not + * @throws IOException if an I/O error occurs. + * @see http://tools.ietf.org/html/draft-somers-ftp-mfxx-04 + */ + public boolean setModificationTime(String pathname, String timeval) throws IOException { + return (FTPReply.isPositiveCompletion(mdtm(pathname)) + && getReplyString().contains(timeval)); + } + /** * Set the internal buffer size. * Index: FTPCommand.java =================================================================== --- FTPCommand.java (revision 763793) +++ FTPCommand.java (working copy) @@ -70,6 +70,7 @@ public static final int MDTM = 33; /** @since 2.1 */ public static final int FEAT = 34; + public static final int MFMT = 35; public static final int USERNAME = USER; public static final int PASSWORD = PASS; @@ -105,9 +106,10 @@ //public static final int HELP = HELP; //public static final int NOOP = NOOP; /** @since 2.0 */ - public static final int MOD_TIME = MDTM; + public static final int GET_MOD_TIME = MDTM; /** @since 2.1 */ public static final int FEATURES = FEAT; + public static final int SET_MOD_TIME = MFMT; // Cannot be instantiated private FTPCommand() @@ -117,7 +119,7 @@ "USER", "PASS", "ACCT", "CWD", "CDUP", "SMNT", "REIN", "QUIT", "PORT", "PASV", "TYPE", "STRU", "MODE", "RETR", "STOR", "STOU", "APPE", "ALLO", "REST", "RNFR", "RNTO", "ABOR", "DELE", "RMD", "MKD", "PWD", "LIST", - "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "FEAT" + "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "FEAT", "MFMT" }; /** Index: FTP.java =================================================================== --- FTP.java (revision 763793) +++ FTP.java (working copy) @@ -1162,7 +1162,30 @@ { return sendCommand(FTPCommand.MDTM, file); } - + + + /** + * A convenience method to send the FTP MFMT command to the server, + * receive the reply, and return the reply code. + *

+ * @param pathname The pathname for which mtime is to be changed + * @param timeval Timestamp in YYYYMMDDhhmmss format + * @return The reply code received from the server. + * @exception FTPConnectionClosedException + * If the FTP server prematurely closes the connection as a result + * of the client being idle or some other reason causing the server + * to send FTP reply code 421. This exception may be caught either + * as an IOException or independently as itself. + * @exception IOException If an I/O error occurs while either sending the + * command or receiving the server reply. + * @see http://tools.ietf.org/html/draft-somers-ftp-mfxx-04 + **/ + public int mfmt(String pathname, String timeval) throws IOException + { + return sendCommand(FTPCommand.MFMT, timeval + " " + pathname); + } + + /*** * A convenience method to send the FTP RNFR command to the server, * receive the reply, and return the reply code. Index: FTPClient.java =================================================================== --- FTPClient.java (revision 763793) +++ FTPClient.java (working copy) @@ -2402,8 +2402,30 @@ return null; } - + /** + * Issue the FTP MFMT command (not supported by all servers) which sets the last + * modified time of a file. + * + * The timestamp should be in the form YYYYMMDDhhmmss. It should also + * be in GMT, but not all servers honour this. + * + * An FTP server would indicate its support of this feature by including "MFMT" + * in its response to the FEAT command, which may be retrieved by FTPClient.features() + * + * @param pathname The file path for which last modified time is to be changed. + * @param timeval The timestamp to set to, in YYYYMMDDhhmmss format. + * @return true if successfully set, false if not + * @throws IOException if an I/O error occurs. + * @see http://tools.ietf.org/html/draft-somers-ftp-mfxx-04 + */ + public boolean setModificationTime(String pathname, String timeval) throws IOException { + return (FTPReply.isPositiveCompletion(mfmt(pathname, timeval)) + && getReplyString().contains(timeval)); + } + + + /** * Set the internal buffer size. * * @param bufSize The size of the buffer Index: FTPCommand.java =================================================================== --- FTPCommand.java (revision 763793) +++ FTPCommand.java (working copy) @@ -70,6 +70,7 @@ public static final int MDTM = 33; /** @since 2.1 */ public static final int FEAT = 34; + public static final int MFMT = 35; public static final int USERNAME = USER; public static final int PASSWORD = PASS; @@ -105,9 +106,10 @@ //public static final int HELP = HELP; //public static final int NOOP = NOOP; /** @since 2.0 */ - public static final int MOD_TIME = MDTM; + public static final int GET_MOD_TIME = MDTM; /** @since 2.1 */ public static final int FEATURES = FEAT; + public static final int SET_MOD_TIME = MFMT; // Cannot be instantiated private FTPCommand() @@ -117,7 +119,7 @@ "USER", "PASS", "ACCT", "CWD", "CDUP", "SMNT", "REIN", "QUIT", "PORT", "PASV", "TYPE", "STRU", "MODE", "RETR", "STOR", "STOU", "APPE", "ALLO", "REST", "RNFR", "RNTO", "ABOR", "DELE", "RMD", "MKD", "PWD", "LIST", - "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "FEAT" + "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "FEAT", "MFMT" }; /** Index: FTP.java =================================================================== --- FTP.java (revision 763793) +++ FTP.java (working copy) @@ -1162,7 +1162,30 @@ { return sendCommand(FTPCommand.MDTM, file); } - + + + /** + * A convenience method to send the FTP MFMT command to the server, + * receive the reply, and return the reply code. + *

+ * @param pathname The pathname for which mtime is to be changed + * @param timeval Timestamp in YYYYMMDDhhmmss format + * @return The reply code received from the server. + * @exception FTPConnectionClosedException + * If the FTP server prematurely closes the connection as a result + * of the client being idle or some other reason causing the server + * to send FTP reply code 421. This exception may be caught either + * as an IOException or independently as itself. + * @exception IOException If an I/O error occurs while either sending the + * command or receiving the server reply. + * @see http://tools.ietf.org/html/draft-somers-ftp-mfxx-04 + **/ + public int mfmt(String pathname, String timeval) throws IOException + { + return sendCommand(FTPCommand.MFMT, timeval + " " + pathname); + } + + /*** * A convenience method to send the FTP RNFR command to the server, * receive the reply, and return the reply code. Index: FTPClient.java =================================================================== --- FTPClient.java (revision 763793) +++ FTPClient.java (working copy) @@ -2402,8 +2402,30 @@ return null; } - + /** + * Issue the FTP MFMT command (not supported by all servers) which sets the last + * modified time of a file. + * + * The timestamp should be in the form YYYYMMDDhhmmss. It should also + * be in GMT, but not all servers honour this. + * + * An FTP server would indicate its support of this feature by including "MFMT" + * in its response to the FEAT command, which may be retrieved by FTPClient.features() + * + * @param pathname The file path for which last modified time is to be changed. + * @param timeval The timestamp to set to, in YYYYMMDDhhmmss format. + * @return true if successfully set, false if not + * @throws IOException if an I/O error occurs. + * @see http://tools.ietf.org/html/draft-somers-ftp-mfxx-04 + */ + public boolean setModificationTime(String pathname, String timeval) throws IOException { + return (FTPReply.isPositiveCompletion(mfmt(pathname, timeval)) + && getReplyString().contains(timeval)); + } + + + /** * Set the internal buffer size. * * @param bufSize The size of the buffer Index: FTPCommand.java =================================================================== --- FTPCommand.java (revision 763793) +++ FTPCommand.java (working copy) @@ -70,6 +70,7 @@ public static final int MDTM = 33; /** @since 2.1 */ public static final int FEAT = 34; + public static final int MFMT = 35; public static final int USERNAME = USER; public static final int PASSWORD = PASS; @@ -105,9 +106,10 @@ //public static final int HELP = HELP; //public static final int NOOP = NOOP; /** @since 2.0 */ - public static final int MOD_TIME = MDTM; + public static final int GET_MOD_TIME = MDTM; /** @since 2.1 */ public static final int FEATURES = FEAT; + public static final int SET_MOD_TIME = MFMT; // Cannot be instantiated private FTPCommand() @@ -117,7 +119,7 @@ "USER", "PASS", "ACCT", "CWD", "CDUP", "SMNT", "REIN", "QUIT", "PORT", "PASV", "TYPE", "STRU", "MODE", "RETR", "STOR", "STOU", "APPE", "ALLO", "REST", "RNFR", "RNTO", "ABOR", "DELE", "RMD", "MKD", "PWD", "LIST", - "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "FEAT" + "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "FEAT", "MFMT" }; /** Index: FTP.java =================================================================== --- FTP.java (revision 763793) +++ FTP.java (working copy) @@ -1162,7 +1162,30 @@ { return sendCommand(FTPCommand.MDTM, file); } - + + + /** + * A convenience method to send the FTP MFMT command to the server, + * receive the reply, and return the reply code. + *

+ * @param pathname The pathname for which mtime is to be changed + * @param timeval Timestamp in YYYYMMDDhhmmss format + * @return The reply code received from the server. + * @exception FTPConnectionClosedException + * If the FTP server prematurely closes the connection as a result + * of the client being idle or some other reason causing the server + * to send FTP reply code 421. This exception may be caught either + * as an IOException or independently as itself. + * @exception IOException If an I/O error occurs while either sending the + * command or receiving the server reply. + * @see http://tools.ietf.org/html/draft-somers-ftp-mfxx-04 + **/ + public int mfmt(String pathname, String timeval) throws IOException + { + return sendCommand(FTPCommand.MFMT, timeval + " " + pathname); + } + + /*** * A convenience method to send the FTP RNFR command to the server, * receive the reply, and return the reply code. > FTP: MFMT support > ----------------- > > Key: NET-245 > URL: https://issues.apache.org/jira/browse/NET-245 > Project: Commons Net > Issue Type: Wish > Affects Versions: Nightly Builds, 2.1 > Reporter: ArtemGr > > A lot of modern FTP servers support time modification via MFMT. > This is especially useful for file synchronization. > http://www.omz13.com/downloads/draft-somers-ftp-mfxx-00.html#anchor8 > http://forum.filezilla-project.org/viewtopic.php?f=6&t=6115 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.