Author: sebb
Date: Fri Mar 18 01:51:54 2011
New Revision: 1082789
URL: http://svn.apache.org/viewvc?rev=1082789&view=rev
Log:
NET-379 FTPClient - support for processing arbitrary commands that only use the
control channel
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=1082789&r1=1082788&r2=1082789&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml (original)
+++ commons/proper/net/trunk/src/changes/changes.xml Fri Mar 18 01:51:54 2011
@@ -57,6 +57,9 @@ The <action> type attribute can be add,u
<body>
<release version="3.0" date="TBA" description="TBA">
+ <action issue="NET-379" dev="sebb" type="add">
+ FTPClient - support for processing arbitrary commands that only
use the control channel
+ </action>
<action issue="NET-378" dev="sebb" type="add">
FTP listing should support MLST and MLSD.
</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=1082789&r1=1082788&r2=1082789&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 Mar 18 01:51:54 2011
@@ -1955,6 +1955,53 @@ implements Configurable
/**
+ * Issue a command and wait for the reply.
+ * <p>
+ * Should only be used with commands that return replies on the
+ * command channel - do not use for LIST, NLST, MLSD etc.
+ * <p>
+ * @param command The command to invoke
+ * @param params The parameters string, may be {@code null}
+ * @return True if successfully completed, false if not, in which case
+ * call {@link #getReplyCode()} or {@link #getReplyString()}
+ * to get the reason.
+ *
+ * @exception IOException If an I/O error occurs while either sending a
+ * command to the server or receiving a reply from the server.
+ * @since 3.0
+ */
+ public boolean doCommand(String command, String params) throws IOException
+ {
+ return FTPReply.isPositiveCompletion(sendCommand(command, params));
+ }
+
+ /**
+ * Issue a command and wait for the reply, returning it as an array of
strings.
+ * <p>
+ * Should only be used with commands that return replies on the
+ * command channel - do not use for LIST, NLST, MLSD etc.
+ * <p>
+ * @param command The command to invoke
+ * @param params The parameters string, may be {@code null}
+ * @return The array of replies, or {@code null} if the command failed, in
which case
+ * call {@link #getReplyCode()} or {@link #getReplyString()}
+ * to get the reason.
+ *
+ * @exception IOException If an I/O error occurs while either sending a
+ * command to the server or receiving a reply from the server.
+ * @since 3.0
+ */
+ public String[] doCommandAsStrings(String command, String params) throws
IOException
+ {
+ boolean success = FTPReply.isPositiveCompletion(sendCommand(command,
params));
+ if (success){
+ return getReplyStrings();
+ } else {
+ return null;
+ }
+ }
+
+ /**
* Get file details using the MLST command
*
* @param pathname the file or directory to list, may be {@code} null