You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Stuart Roebuck <sr...@adolos.com> on 2000/11/15 17:22:02 UTC
[PATCH] Add passive-mode transfer to FTP Task
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 "jaxp.jar" and "parser.jar" 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 @@
"**/.cvsignore"
</pre>
If you do not want these default excludes applied, you may disable them with the
-<code>defaultexcludes="no"</code> attribute.</p>
+<code>defaultexcludes="no"</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> <fail message="Something wrong here."/></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 "C:\". 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>
<style basedir="doc" destdir="build/doc"
extension="html" style="style/apache.xml"/>
-</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 ("yes") transfers.
+ Defaults to "no"</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 "yes". Defaults to "no".</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> <ftp server="ftp.nt.org"
remotedir="c:\uploads"
userid="coder"
password="java1"
separator="\"
- verbose="yes"
+ verbose="yes"</pre>
+<PRE>
>
<fileset dir="htdocs/manual">
<include name="**/*.html" />
</fileset>
- </ftp></pre>
-<p>Logs in to the Windows-based <code>ftp.nt.org</code> as
+ </ftp></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
Re: [PATCH] Add passive-mode transfer to FTP Task
Posted by Stefan Bodewig <bo...@bost.de>.
Stuart Roebuck <sr...@adolos.com> wrote:
> Having just add a firewall to our location I noticed that the
> current FTP task doesn't have a passive mode option.
Going to check it in in a few minutes.
> /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Attic/FTP.java,v
please use the version in the net subdirectory, not the deleted one in
the Attic next time 8-)
Stefan