commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1081482 - in /commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp: FTP.java FTPCommand.java
Date Mon, 14 Mar 2011 17:19:47 GMT
Author: sebb
Date: Mon Mar 14 17:19:46 2011
New Revision: 1081482

URL: http://svn.apache.org/viewvc?rev=1081482&view=rev
Log:
NET-370 Add support for FTP commands MLSD, MLST
- create low-level command routines (still need to update FTPClient and add a parser)

Modified:
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPCommand.java

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java?rev=1081482&r1=1081481&r2=1081482&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java Mon Mar 14
17:19:46 2011
@@ -523,7 +523,7 @@ public class FTP extends SocketClient
     /**
      * Send a noop and get the reply without reporting to the command listener.
      * Intended for use with keep-alive.
-     * 
+     *
      * @throws IOException
      * @since 3.0
      */
@@ -1461,6 +1461,96 @@ public class FTP extends SocketClient
         return sendCommand(FTPCommand.LIST, pathname);
     }
 
+    /**
+     * A convenience method to send the FTP MLSD command to the server,
+     * receive the reply, and return the reply code.  Remember, it is up
+     * to you to manage the data connection.  If you don't need this low
+     * level of access, use {@link org.apache.commons.net.ftp.FTPClient}
+     * , which will handle all low level details for you.
+     * <p>
+     * @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.
+     * @since 3.0
+     */
+    public int mlsd() throws IOException
+    {
+        return sendCommand(FTPCommand.MLSD);
+    }
+
+    /**
+     * A convenience method to send the FTP MLSD command to the server,
+     * receive the reply, and return the reply code.  Remember, it is up
+     * to you to manage the data connection.  If you don't need this low
+     * level of access, use {@link org.apache.commons.net.ftp.FTPClient}
+     * , which will handle all low level details for you.
+     * <p>
+     * @param path the path to report on
+     * @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.
+     * @since 3.0
+     */
+    public int mlsd(String path) throws IOException
+    {
+        return sendCommand(FTPCommand.MLSD, path);
+    }
+
+    /**
+     * A convenience method to send the FTP MLST command to the server,
+     * receive the reply, and return the reply code.  Remember, it is up
+     * to you to manage the data connection.  If you don't need this low
+     * level of access, use {@link org.apache.commons.net.ftp.FTPClient}
+     * , which will handle all low level details for you.
+     * <p>
+     * @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.
+     * @since 3.0
+     */
+    public int mlst() throws IOException
+    {
+        return sendCommand(FTPCommand.MLST);
+    }
+
+    /**
+     * A convenience method to send the FTP MLST command to the server,
+     * receive the reply, and return the reply code.  Remember, it is up
+     * to you to manage the data connection.  If you don't need this low
+     * level of access, use {@link org.apache.commons.net.ftp.FTPClient}
+     * , which will handle all low level details for you.
+     * <p>
+     * @param path the path to report on
+     * @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.
+     * @since 3.0
+     */
+    public int mlst(String path) throws IOException
+    {
+        return sendCommand(FTPCommand.MLST, path);
+    }
+
     /***
      * A convenience method to send the FTP NLST command to the server,
      * receive the reply, and return the reply code.  Remember, it is up

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPCommand.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPCommand.java?rev=1081482&r1=1081481&r2=1081482&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPCommand.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPCommand.java Mon
Mar 14 17:19:46 2011
@@ -76,9 +76,14 @@ public final class FTPCommand
     /** @since 2.2 */
     public static final int EPRT = 37;
 
+    /** @since 3.0 */
+    public static final int MLSD = 38;
+    /** @since 3.0 */
+    public static final int MLST = 39;
+
     // Must agree with final entry above; used to check array size
-    private static final int LAST = EPRT;
-    
+    private static final int LAST = MLST;
+
     public static final int USERNAME = USER;
     public static final int PASSWORD = PASS;
     public static final int ACCOUNT = ACCT;
@@ -122,7 +127,7 @@ public final class FTPCommand
     public static final int GET_MOD_TIME = MDTM;
     /** @since 2.2 */
     public static final int SET_MOD_TIME = MFMT;
-    
+
     // Cannot be instantiated
     private FTPCommand()
     {}
@@ -132,10 +137,10 @@ public final class FTPCommand
                                           "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", "MFMT",
-                                          "EPSV", "EPRT" };
+                                          "EPSV", "EPRT", "MLSD", "MLST" };
+
+
 
-    
-    
     // default access needed for Unit test
     static void checkArray(){
         int expectedLength = LAST+1;



Mime
View raw message