commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1074720 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/ftp/FTPClient.java
Date Fri, 25 Feb 2011 22:20:51 GMT
Author: sebb
Date: Fri Feb 25 22:20:50 2011
New Revision: 1074720

URL: http://svn.apache.org/viewvc?rev=1074720&view=rev
Log:
NET-332 Commons net ftp cannot handle unknown type parser and should allow override of parser
through vm argument.

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java

Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1074720&r1=1074719&r2=1074720&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml (original)
+++ commons/proper/net/trunk/src/changes/changes.xml Fri Feb 25 22:20:50 2011
@@ -52,6 +52,10 @@ The <action> type attribute can be add,u
 
     <body>
         <release version="2.3" date="TBA" description="TBA">
+            <action issue="NET-332" dev="sebb" type="add">
+            Commons net ftp cannot handle unknown type parser and should allow override of
parser through vm argument.
+            The system property "org.apache.commons.net.ftp.systemType" can be used to provide
the system type.
+            </action>
             <action issue="NET-360" dev="sebb" type="fix">
             DefaultFTPFileEntryParserFactory.createFileEntryParser(String key) always tries
to load a class.
             </action>

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java?rev=1074720&r1=1074719&r2=1074720&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java Fri Feb
25 22:20:50 2011
@@ -237,6 +237,11 @@ import org.apache.commons.net.io.Util;
 public class FTPClient extends FTP
 implements Configurable
 {
+    /**
+     * The system property ({@value}) which can be used to override the system type. 
+     */
+    public static final String FTP_SYSTEM_TYPE = "org.apache.commons.net.ftp.systemType";
+
     /***
      * A constant indicating the FTP session is expecting all transfers
      * to occur between the client (local) and server and that the server
@@ -2538,8 +2543,9 @@ implements Configurable
      * @param parserKey A string representing a designated code or fully-qualified
      * class name of an  <code> FTPFileEntryParser </code> that should be
      *               used to parse each server file listing.
-     *               May be {@code null}, in which case the {@link #getSystemType()}
-     *               is used to provide the value.
+     *               May be {@code null}, in which case the code checks first
+     *               the system property {@link #FTP_SYSTEM_TYPE}, and if that is
+     *               not defined the SYST command is used to provide the value.
      *
      * @return A FTPListParseEngine object that holds the raw information and
      * is capable of providing parsed FTPFile objects, one for each file
@@ -2592,9 +2598,13 @@ implements Configurable
                     __entryParserKey = __configuration.getServerSystemKey();
                 } else {
                     // if a parserKey hasn't been supplied, and a configuration
-                    // hasn't been supplied, then autodetect by calling
+                    // hasn't been supplied, and the override property is not set
+                    // then autodetect by calling
                     // the SYST command and use that to choose the parser.
-                    final String systemType = getSystemType(); // cannot be null
+                    String systemType = System.getProperty(FTP_SYSTEM_TYPE);
+                    if (systemType == null) {
+                        systemType = getSystemType(); // cannot be null
+                    }
                     __entryParser =
                         __parserFactory.createFileEntryParser(systemType);
                     __entryParserKey = systemType;



Mime
View raw message