ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stuart Roebuck ...@adolos.com>
Subject [PATCH] Add passive-mode transfer to FTP Task
Date Wed, 15 Nov 2000 16:22:02 GMT
Having just add a firewall to our location I noticed that the current FTP task doesn't have
a passive mode option.

Here are the patches to add it in.  I've also included patches to the index.html doc to include
the additional documentation.  Apologies, my HTML editor was a little bit stricter and forced
me to fix the odd out of order </p> etc.

Stuart.


Index: FTP.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Attic/FTP.java,v
retrieving revision 1.3
diff -u -r1.3 FTP.java
--- FTP.java	2000/09/07 09:50:57	1.3
+++ FTP.java	2000/11/15 16:00:01
@@ -88,6 +88,7 @@
     private String password;
     private File listing;
     private boolean binary = true;
+    private boolean passive = false;
     private boolean verbose = false;
     private boolean newerOnly = false;
     private int action = SEND_FILES;
@@ -251,6 +252,16 @@
     }
 
     /**
+     * Specifies whether to use passive mode.  Set to true if you
+     * are behind a firewall and cannot connect without it.  Passive mode
+     * is disabled by default.
+     */
+    public void setPassive(boolean passive)
+    {
+        this.passive = passive;
+    }
+
+    /**
      * Set to true to receive notification about each file as it is
      * transferred.
      */
@@ -743,6 +754,18 @@
                 {
                     throw new BuildException(
                         "could not set transfer type: " +
+                        ftp.getReplyString());
+                }
+            }
+            
+            if (passive)
+            {
+                log("entering passive mode", Project.MSG_VERBOSE);
+                ftp.enterLocalPassiveMode();
+                if (!FTPReply.isPositiveCompletion(ftp.getReplyCode()))
+                {
+                    throw new BuildException(
+                        "could not enter into passive mode: " +
                         ftp.getReplyString());
                 }
             }




Index: index.html
===================================================================
RCS file: /home/cvspublic/jakarta-ant/docs/index.html,v
retrieving revision 1.146
diff -u -r1.146 index.html
--- index.html	2000/11/06 14:10:56	1.146
+++ index.html	2000/11/15 16:13:46
@@ -105,7 +105,7 @@
   Once installed make sure the &quot;jaxp.jar&quot; and &quot;parser.jar&quot;
files are in your classpath.
   <p>
   You will also need the JDK installed on your system, version 1.1 or later. 
-
+  </p>
 <hr>  
 <h2><a name="buildingant">Building Ant</a></h2>
 <p>Go to the directory <code>jakarta-ant</code>.</p>
@@ -734,7 +734,7 @@
         &quot;**/.cvsignore&quot;
 </pre>
 If you do not want these default excludes applied, you may disable them with the 
-<code>defaultexcludes=&quot;no&quot;</code> attribute.</p>
+<code>defaultexcludes=&quot;no&quot;</code> attribute.
 <h3><a name="patternset">PatternSets</a></h3>
 <p>Patterns can be grouped to sets and later be referenced by their id
 attribute. They are defined via a <code>patternset</code> element -
@@ -1883,7 +1883,7 @@
 
 build.xml:4: No message
 </pre>
-</p>
+
 <pre>  &lt;fail message=&quot;Something wrong here.&quot;/&gt;</pre>
 <p>will exit the current build and print something like the following to whereever
 your output goes:
@@ -1892,7 +1892,7 @@
 
 build.xml:4: Something wrong here.
 </pre>
-</p>
+
 <hr>
 <h2><a name="filter">Filter</a></h2>
 <h3>Description</h3>
@@ -2344,6 +2344,7 @@
 If <code>create</code> (the default), the JAR is created anyway with only a manifest.
 If <code>skip</code>, the JAR is not created and a warning is issued.
 If <code>fail</code>, the JAR is not created and the build is halted with an
error.
+</p>
 <h3>Parameters</h3>
 <table border="1" cellpadding="2" cellspacing="0">
   <tr>
@@ -3377,7 +3378,7 @@
 <hr>
 <h2><a name="patch">Patch</a></h2>
 <h3>Description</h3>
-<p>Applies a diff file to originals.
+<p>Applies a diff file to originals.</p>
 <h3>Parameters</h3>
 <table border="1" cellpadding="2" cellspacing="0">
   <tr>
@@ -3517,7 +3518,7 @@
 to be your home directory.  This technique is more appropriate for Unix than 
 Windows since the notion of a home directory doesn't exist on Windows.  On the
 JVM that I tested, the home directory on Windows is &quot;C:\&quot;.  Different JVM
-implementations may use other values for the home directory on Windows.
+implementations may use other values for the home directory on Windows.</p>
 <hr>
 <h2><a name="rename">Rename</a></h2>
 <h3><i>Deprecated</i></h3>
@@ -3938,7 +3939,7 @@
   <p><pre>
 &lt;style basedir=&quot;doc&quot; destdir=&quot;build/doc&quot;
        extension=&quot;html&quot; style=&quot;style/apache.xml&quot;/&gt;
-</pre></p>
+</pre>
 </blockquote>
 <hr>
 <h2><a name="tar">Tar</a></h2>
@@ -4406,7 +4407,7 @@
 </pre>
 using Ant's default manifest file. The content of
 <code>WEB-INF/web.xml</code> is identical to
-<code>src/metadata/myapp.xml</code>.</p>
+<code>src/metadata/myapp.xml</code>.
 <hr>
 <h2><a name="zip">Zip</a></h2>
 <h3>Description</h3>
@@ -4721,6 +4722,12 @@
     <td valign="top" align="center">No</td>
   </tr>
   <tr>
+    <td valign="top">passive</td>
+    <td valign="top">selects passive-mode (&quot;yes&quot;) transfers.  
+                     Defaults to &quot;no&quot;</td>
+    <td valign="top" align="center">No</td>
+  </tr>
+  <tr>
     <td valign="top">verbose</td>
     <td valign="top">displays information on each file transferred if set 
                      to &quot;yes&quot;. Defaults to &quot;no&quot;.</td>
@@ -4789,20 +4796,19 @@
 <p>Logs in to <code>ftp.apache.org</code> at port <code>2121</code>
as 
 <code>coder</code> with password <code>java1</code> and uploads all
new or 
 changed HTML files in the <code>htdocs/manual</code> directory to the 
-<code>/pub/incoming</code> directory.  The files are transferred in text
-mode.</p>
+<code>/pub/incoming</code> directory. The files are transferred in text mode.
Passive mode has been switched on to send files from behind a firewall.</p>
 <pre>  &lt;ftp server=&quot;ftp.nt.org&quot;
        remotedir=&quot;c:\uploads&quot;
        userid=&quot;coder&quot;
        password=&quot;java1&quot;
        separator=&quot;\&quot;
-       verbose=&quot;yes&quot;
+       verbose=&quot;yes&quot;</pre>
+<PRE>
   &gt;
     &lt;fileset dir=&quot;htdocs/manual&quot;&gt;
       &lt;include name=&quot;**/*.html&quot; /&gt;
     &lt;/fileset&gt;
-  &lt;/ftp&gt;</pre>
-<p>Logs in to the Windows-based <code>ftp.nt.org</code> as 
+  &lt;/ftp&gt;</PRE><p>Logs in to the Windows-based <code>ftp.nt.org</code>
as 
 <code>coder</code> with password <code>java1</code> and uploads all

 HTML files in the <code>htdocs/manual</code> directory to the 
 <code>c:\uploads</code> directory.  Progress messages are displayed as each



Mime
View raw message