You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2008/08/17 21:52:49 UTC
svn commit: r686637 [3/16] - in /mina/ftpserver/trunk:
core/src/main/java/org/apache/ftpserver/
core/src/main/java/org/apache/ftpserver/command/
core/src/main/java/org/apache/ftpserver/config/spring/
core/src/main/java/org/apache/ftpserver/filesystem/ ...
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/EPRT.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/EPRT.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/EPRT.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/EPRT.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -34,42 +34,47 @@
import org.slf4j.LoggerFactory;
/**
- * The EPRT command allows for the specification of an extended address
- * for the data connection. The extended address MUST consist of the
- * network protocol as well as the network and transport addresses. The
- * format of EPRT is:
- *
+ * The EPRT command allows for the specification of an extended address for the
+ * data connection. The extended address MUST consist of the network protocol as
+ * well as the network and transport addresses. The format of EPRT is:
+ *
* EPRT<space><d><net-prt><d><net-addr><d><tcp-port><d>
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class EPRT extends AbstractCommand {
+public class EPRT extends AbstractCommand {
private final Logger LOG = LoggerFactory.getLogger(EPRT.class);
-
+
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException {
+
// reset state variables
session.resetState();
-
+
// argument check
String arg = request.getArgument();
- if(arg == null) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "EPRT", null));
- return;
+ if (arg == null) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "EPRT", null));
+ return;
}
-
+
// is port enabled
- DataConnectionConfiguration dataCfg = session.getListener().getDataConnectionConfiguration();
- if(!dataCfg.isActiveEnabled()) {
- session.write(FtpReplyUtil.translate(session, request, context, 510, "EPRT.disabled", null));
+ DataConnectionConfiguration dataCfg = session.getListener()
+ .getDataConnectionConfiguration();
+ if (!dataCfg.isActiveEnabled()) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ 510, "EPRT.disabled", null));
return;
}
-
+
// parse argument
String host = null;
String port = null;
@@ -77,48 +82,64 @@
char delim = arg.charAt(0);
int lastDelimIdx = arg.indexOf(delim, 3);
host = arg.substring(3, lastDelimIdx);
- port = arg.substring(lastDelimIdx+1, arg.length() - 1);
- }
- catch(Exception ex) {
+ port = arg.substring(lastDelimIdx + 1, arg.length() - 1);
+ } catch (Exception ex) {
LOG.debug("Exception parsing host and port: " + arg, ex);
- session.write(FtpReplyUtil.translate(session, request, context, 510, "EPRT", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ 510, "EPRT", null));
return;
}
-
+
// get data server
InetAddress dataAddr = null;
try {
dataAddr = InetAddress.getByName(host);
- }
- catch(UnknownHostException ex) {
+ } catch (UnknownHostException ex) {
LOG.debug("Unknown host: " + host, ex);
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED, "EPRT.host", null));
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED,
+ "EPRT.host", null));
return;
}
-
+
// check IP
- if(dataCfg.isActiveIpCheck()) {
- if(session.getRemoteAddress() instanceof InetSocketAddress) {
- InetAddress clientAddr = ((InetSocketAddress)session.getRemoteAddress()).getAddress();
- if(!dataAddr.equals(clientAddr)) {
- session.write(FtpReplyUtil.translate(session, request, context, 510, "EPRT.mismatch", null));
- return;
- }
- }
+ if (dataCfg.isActiveIpCheck()) {
+ if (session.getRemoteAddress() instanceof InetSocketAddress) {
+ InetAddress clientAddr = ((InetSocketAddress) session
+ .getRemoteAddress()).getAddress();
+ if (!dataAddr.equals(clientAddr)) {
+ session.write(FtpReplyUtil.translate(session, request,
+ context, 510, "EPRT.mismatch", null));
+ return;
+ }
+ }
}
-
+
// get data server port
int dataPort = 0;
try {
- dataPort = Integer.parseInt(port);
- }
- catch(NumberFormatException ex) {
+ dataPort = Integer.parseInt(port);
+ } catch (NumberFormatException ex) {
LOG.debug("Invalid port: " + port, ex);
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_552_REQUESTED_FILE_ACTION_ABORTED_EXCEEDED_STORAGE, "EPRT.invalid", null));
- return;
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_552_REQUESTED_FILE_ACTION_ABORTED_EXCEEDED_STORAGE,
+ "EPRT.invalid", null));
+ return;
}
-
- session.getDataConnection().initActiveDataConnection(new InetSocketAddress(dataAddr, dataPort));
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "EPRT", null));
+
+ session.getDataConnection().initActiveDataConnection(
+ new InetSocketAddress(dataAddr, dataPort));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_200_COMMAND_OKAY, "EPRT", null));
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/EPSV.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/EPSV.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/EPSV.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/EPSV.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -31,45 +31,51 @@
import org.apache.ftpserver.util.FtpReplyUtil;
/**
- * The EPSV command requests that a server listen on a data port and
- * wait for a connection. The EPSV command takes an optional argument.
- * The response to this command includes only the TCP port number of the
- * listening connection. The format of the response, however, is
- * similar to the argument of the EPRT command. This allows the same
- * parsing routines to be used for both commands. In addition, the
- * format leaves a place holder for the network protocol and/or network
- * address, which may be needed in the EPSV response in the future. The
- * response code for entering passive mode using an extended address
- * MUST be 229.
+ * The EPSV command requests that a server listen on a data port and wait for a
+ * connection. The EPSV command takes an optional argument. The response to this
+ * command includes only the TCP port number of the listening connection. The
+ * format of the response, however, is similar to the argument of the EPRT
+ * command. This allows the same parsing routines to be used for both commands.
+ * In addition, the format leaves a place holder for the network protocol and/or
+ * network address, which may be needed in the EPSV response in the future. The
+ * response code for entering passive mode using an extended address MUST be
+ * 229.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class EPSV extends AbstractCommand {
+public class EPSV extends AbstractCommand {
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException {
+
// reset state variables
session.resetState();
-
+
// set data connection
ServerDataConnectionFactory dataCon = session.getDataConnection();
-
+
try {
- InetSocketAddress dataConAddress = dataCon.initPassiveDataConnection();
+ InetSocketAddress dataConAddress = dataCon
+ .initPassiveDataConnection();
// get connection info
int servPort = dataConAddress.getPort();
-
+
// send connection info to client
String portStr = "|||" + servPort + '|';
- session.write(FtpReplyUtil.translate(session, request, context, 229, "EPSV", portStr));
-
- } catch(DataConnectionException e) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "EPSV", null));
- return;
+ session.write(FtpReplyUtil.translate(session, request, context,
+ 229, "EPSV", portStr));
+
+ } catch (DataConnectionException e) {
+ session
+ .write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION,
+ "EPSV", null));
+ return;
}
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/FEAT.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/FEAT.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/FEAT.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/FEAT.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -29,21 +29,24 @@
import org.apache.ftpserver.util.FtpReplyUtil;
/**
- * The FEAT command (introduced in [RFC-2389]) allows servers with
- * additional features to advertise these to a client by responding to
- * the FEAT command. If a server supports the FEAT command then it MUST
- * advertise supported AUTH, PBSZ and PROT commands in the reply.
+ * The FEAT command (introduced in [RFC-2389]) allows servers with additional
+ * features to advertise these to a client by responding to the FEAT command. If
+ * a server supports the FEAT command then it MUST advertise supported AUTH,
+ * PBSZ and PROT commands in the reply.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class FEAT extends AbstractCommand {
+public class FEAT extends AbstractCommand {
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
// reset state variables
session.resetState();
-
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_211_SYSTEM_STATUS_REPLY, "FEAT", null));
+
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_211_SYSTEM_STATUS_REPLY, "FEAT", null));
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/HELP.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/HELP.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/HELP.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/HELP.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -30,38 +30,42 @@
/**
* <code>HELP [<SP> <string>] <CRLF></code><br>
- *
- * This command shall cause the server to send helpful
- * information regarding its implementation status over the
- * control connection to the user. The command may take an
- * argument (e.g., any command name) and return more specific
+ *
+ * This command shall cause the server to send helpful information regarding its
+ * implementation status over the control connection to the user. The command
+ * may take an argument (e.g., any command name) and return more specific
* information as a response.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class HELP extends AbstractCommand {
-
+public class HELP extends AbstractCommand {
+
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException {
+
// reset state variables
session.resetState();
-
+
// print global help
- if(!request.hasArgument()) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_214_HELP_MESSAGE, null, null));
+ if (!request.hasArgument()) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_214_HELP_MESSAGE, null, null));
return;
}
-
+
// print command specific help if available
String ftpCmd = request.getArgument().toUpperCase();
MessageResource resource = context.getMessageResource();
- if(resource.getMessage(FtpReply.REPLY_214_HELP_MESSAGE, ftpCmd, session.getLanguage()) == null) {
+ if (resource.getMessage(FtpReply.REPLY_214_HELP_MESSAGE, ftpCmd,
+ session.getLanguage()) == null) {
ftpCmd = null;
}
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_214_HELP_MESSAGE, ftpCmd, null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_214_HELP_MESSAGE, ftpCmd, null));
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LANG.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LANG.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LANG.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LANG.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -30,46 +30,53 @@
import org.apache.ftpserver.util.FtpReplyUtil;
/**
- * A new command "LANG" is added to the FTP command set to allow
- * server-FTP process to determine in which language to present server
- * greetings and the textual part of command responses.
+ * A new command "LANG" is added to the FTP command set to allow server-FTP
+ * process to determine in which language to present server greetings and the
+ * textual part of command responses.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class LANG extends AbstractCommand {
+public class LANG extends AbstractCommand {
/**
* Execute command.
*/
- public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ public void execute(final FtpIoSession session,
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
// reset state
session.resetState();
-
+
// default language
String language = request.getArgument();
- if(language == null) {
+ if (language == null) {
session.setLanguage(null);
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "LANG", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_200_COMMAND_OKAY, "LANG", null));
return;
}
-
+
// check and set language
language = language.toLowerCase();
MessageResource msgResource = context.getMessageResource();
String[] availableLanguages = msgResource.getAvailableLanguages();
- if(availableLanguages != null) {
- for(int i=0; i<availableLanguages.length; ++i) {
- if(availableLanguages[i].equals(language)) {
+ if (availableLanguages != null) {
+ for (int i = 0; i < availableLanguages.length; ++i) {
+ if (availableLanguages[i].equals(language)) {
session.setLanguage(language);
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "LANG", null));
+ session.write(FtpReplyUtil.translate(session, request,
+ context, FtpReply.REPLY_200_COMMAND_OKAY, "LANG",
+ null));
return;
}
}
}
-
+
// not found - send error message
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "LANG", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER,
+ "LANG", null));
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LIST.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LIST.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LIST.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LIST.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -42,89 +42,114 @@
/**
* <code>LIST [<SP> <pathname>] <CRLF></code><br>
+ *
+ * This command causes a list to be sent from the server to the passive DTP. If
+ * the pathname specifies a directory or other group of files, the server should
+ * transfer a list of files in the specified directory. If the pathname
+ * specifies a file then the server should send current information on the file.
+ * A null argument implies the user's current working or default directory. The
+ * data transfer is over the data connection.
*
- * This command causes a list to be sent from the server to the
- * passive DTP. If the pathname specifies a directory or other
- * group of files, the server should transfer a list of files
- * in the specified directory. If the pathname specifies a
- * file then the server should send current information on the
- * file. A null argument implies the user's current working or
- * default directory. The data transfer is over the data
- * connection.
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class LIST extends AbstractCommand {
-
+public class LIST extends AbstractCommand {
+
private final Logger LOG = LoggerFactory.getLogger(LIST.class);
-
+
private static final LISTFileFormater LIST_FILE_FORMATER = new LISTFileFormater();
+
private DirectoryLister directoryLister = new DirectoryLister();
-
+
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
try {
-
+
// reset state variables
session.resetState();
-
- // 24-10-2007 - added check if PORT or PASV is issued, see https://issues.apache.org/jira/browse/FTPSERVER-110
+
+ // 24-10-2007 - added check if PORT or PASV is issued, see
+ // https://issues.apache.org/jira/browse/FTPSERVER-110
DataConnectionFactory connFactory = session.getDataConnection();
if (connFactory instanceof IODataConnectionFactory) {
- InetAddress address = ((IODataConnectionFactory)connFactory).getInetAddress();
+ InetAddress address = ((IODataConnectionFactory) connFactory)
+ .getInetAddress();
if (address == null) {
- session.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
+ session.write(new DefaultFtpReply(
+ FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS,
+ "PORT or PASV must be issued first"));
return;
}
}
-
+
// get data connection
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_150_FILE_STATUS_OKAY, "LIST", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_150_FILE_STATUS_OKAY, "LIST", null));
DataConnection dataConnection;
try {
dataConnection = session.getDataConnection().openConnection();
} catch (Exception e) {
LOG.debug("Exception getting the output data stream", e);
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "LIST", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "LIST",
+ null));
return;
}
-
-
+
// transfer listing data
boolean failure = false;
-
+
try {
// parse argument
- ListArgument parsedArg = ListArgumentParser.parse(request.getArgument());
-
- dataConnection.transferToClient(directoryLister.listFiles(parsedArg, session.getFileSystemView(), LIST_FILE_FORMATER));
- }
- catch(SocketException ex) {
+ ListArgument parsedArg = ListArgumentParser.parse(request
+ .getArgument());
+
+ dataConnection.transferToClient(directoryLister.listFiles(
+ parsedArg, session.getFileSystemView(),
+ LIST_FILE_FORMATER));
+ } catch (SocketException ex) {
LOG.debug("Socket exception during list transfer", ex);
failure = true;
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "LIST", null));
- }
- catch(IOException ex) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED,
+ "LIST", null));
+ } catch (IOException ex) {
LOG.debug("IOException during list transfer", ex);
failure = true;
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "LIST", null));
- } catch(IllegalArgumentException e) {
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN,
+ "LIST", null));
+ } catch (IllegalArgumentException e) {
LOG.debug("Illegal list syntax: " + request.getArgument(), e);
// if listing syntax error - send message
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "LIST", null));
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "LIST", null));
}
-
+
// if data transfer ok - send transfer complete message
- if(!failure) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "LIST", null));
+ if (!failure) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "LIST",
+ null));
}
- }
- finally {
+ } finally {
session.getDataConnection().closeDataConnection();
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MD5.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MD5.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MD5.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MD5.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -38,106 +38,133 @@
/**
* <code>MD5 <SP> <pathname> <CRLF></code><br>
* <code>MMD5 <SP> <pathnames> <CRLF></code><br>
- *
- * Returns the MD5 value for a file or multiple files according to
- * draft-twine-ftpmd5-00.txt.
*
+ * Returns the MD5 value for a file or multiple files according to
+ * draft-twine-ftpmd5-00.txt.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class MD5 extends AbstractCommand {
+public class MD5 extends AbstractCommand {
private final Logger LOG = LoggerFactory.getLogger(MD5.class);
-
+
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException {
+
// reset state variables
session.resetState();
boolean isMMD5 = false;
-
- if("MMD5".equals(request.getCommand())) {
+
+ if ("MMD5".equals(request.getCommand())) {
isMMD5 = true;
}
-
+
// print file information
String argument = request.getArgument();
-
- if(argument == null || argument.trim().length() == 0) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", null));
+
+ if (argument == null || argument.trim().length() == 0) {
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER,
+ "MD5.invalid", null));
return;
}
String[] fileNames = null;
- if(isMMD5) {
+ if (isMMD5) {
fileNames = argument.split(",");
} else {
- fileNames = new String[]{argument};
+ fileNames = new String[] { argument };
}
StringBuffer sb = new StringBuffer();
- for(int i = 0; i<fileNames.length; i++) {
+ for (int i = 0; i < fileNames.length; i++) {
String fileName = fileNames[i].trim();
-
+
// get file object
FileObject file = null;
-
+
try {
file = session.getFileSystemView().getFileObject(fileName);
- }
- catch(Exception ex) {
+ } catch (Exception ex) {
LOG.debug("Exception getting the file object: " + fileName, ex);
}
-
- if(file == null) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", fileName));
+
+ if (file == null) {
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER,
+ "MD5.invalid", fileName));
return;
}
-
+
// check file
- if(!file.isFile()) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", fileName));
+ if (!file.isFile()) {
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER,
+ "MD5.invalid", fileName));
return;
}
-
+
InputStream is = null;
- try{
+ try {
is = file.createInputStream(0);
String md5Hash = md5(is);
- if(i > 0) {
+ if (i > 0) {
sb.append(", ");
}
sb.append(fileName);
sb.append(' ');
sb.append(md5Hash);
-
- } catch(NoSuchAlgorithmException e) {
+
+ } catch (NoSuchAlgorithmException e) {
LOG.debug("MD5 algorithm not available", e);
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "MD5.notimplemened", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED,
+ "MD5.notimplemened", null));
} finally {
IoUtils.close(is);
}
}
- if(isMMD5) {
- session.write(FtpReplyUtil.translate(session, request, context, 252, "MMD5", sb.toString()));
+ if (isMMD5) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ 252, "MMD5", sb.toString()));
} else {
- session.write(FtpReplyUtil.translate(session, request, context, 251, "MD5", sb.toString()));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ 251, "MD5", sb.toString()));
}
}
/**
- * @param is InputStream for which the MD5 hash is calculated
+ * @param is
+ * InputStream for which the MD5 hash is calculated
* @return The hash of the content in the input stream
* @throws IOException
- * @throws NoSuchAlgorithmException
+ * @throws NoSuchAlgorithmException
*/
- private String md5(InputStream is) throws IOException, NoSuchAlgorithmException {
+ private String md5(InputStream is) throws IOException,
+ NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("MD5");
DigestInputStream dis = new DigestInputStream(is, digest);
@@ -149,8 +176,8 @@
}
return new String(encodeHex(dis.getMessageDigest().digest()));
- }
-
+ }
+
/**
* Converts an array of bytes into an array of characters representing the
* hexidecimal values of each byte in order. The returned array will be
@@ -179,7 +206,7 @@
/**
* Used to build output as Hex
*/
- private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6',
- '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+ private static final char[] DIGITS = { '0', '1', '2', '3', '4', '5', '6',
+ '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MDTM.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MDTM.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MDTM.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MDTM.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -36,50 +36,57 @@
* <code>MDTM <SP> <pathname> <CRLF></code><br>
*
* Returns the date and time of when a file was modified.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class MDTM extends AbstractCommand {
+public class MDTM extends AbstractCommand {
private final Logger LOG = LoggerFactory.getLogger(MDTM.class);
-
+
/**
* Execute command
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
// reset state
session.resetState();
-
+
// argument check
String fileName = request.getArgument();
- if(fileName == null) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MDTM", null));
- return;
+ if (fileName == null) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "MDTM", null));
+ return;
}
-
+
// get file object
FileObject file = null;
try {
file = session.getFileSystemView().getFileObject(fileName);
- }
- catch(Exception ex) {
+ } catch (Exception ex) {
LOG.debug("Exception getting file object", ex);
}
- if(file == null) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MDTM", fileName));
+ if (file == null) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MDTM",
+ fileName));
return;
}
-
+
// now print date
fileName = file.getFullName();
- if(file.doesExist()) {
- String dateStr = DateUtils.getFtpDate( file.getLastModified() );
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_213_FILE_STATUS, "MDTM", dateStr));
- }
- else {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MDTM", fileName));
+ if (file.doesExist()) {
+ String dateStr = DateUtils.getFtpDate(file.getLastModified());
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_213_FILE_STATUS, "MDTM", dateStr));
+ } else {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MDTM",
+ fileName));
}
- }
+ }
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MKD.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MKD.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MKD.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MKD.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -35,74 +35,86 @@
/**
* <code>MKD <SP> <pathname> <CRLF></code><br>
+ *
+ * This command causes the directory specified in the pathname to be created as
+ * a directory (if the pathname is absolute) or as a subdirectory of the current
+ * working directory (if the pathname is relative).
*
- * This command causes the directory specified in the pathname
- * to be created as a directory (if the pathname is absolute)
- * or as a subdirectory of the current working directory (if
- * the pathname is relative).
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class MKD extends AbstractCommand {
-
+public class MKD extends AbstractCommand {
+
private final Logger LOG = LoggerFactory.getLogger(MKD.class);
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
// reset state
- session.resetState();
-
+ session.resetState();
+
// argument check
String fileName = request.getArgument();
- if(fileName == null || fileName.indexOf(File.pathSeparatorChar) > -1) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MKD", null));
- return;
+ if (fileName == null || fileName.indexOf(File.pathSeparatorChar) > -1) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "MKD", null));
+ return;
}
-
+
// get file object
FileObject file = null;
try {
file = session.getFileSystemView().getFileObject(fileName);
- }
- catch(Exception ex) {
+ } catch (Exception ex) {
LOG.debug("Exception getting file object", ex);
}
- if(file == null) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.invalid", fileName));
+ if (file == null) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
+ "MKD.invalid", fileName));
return;
}
-
+
// check permission
fileName = file.getFullName();
- if( !file.hasWritePermission() ) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.permission", fileName));
+ if (!file.hasWritePermission()) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
+ "MKD.permission", fileName));
return;
}
-
+
// check file existance
- if(file.doesExist()) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.exists", fileName));
+ if (file.doesExist()) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
+ "MKD.exists", fileName));
return;
}
-
+
// now create directory
- if(file.mkdir()) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_257_PATHNAME_CREATED, "MKD", fileName));
-
+ if (file.mkdir()) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_257_PATHNAME_CREATED, "MKD", fileName));
+
// write log message
String userName = session.getUser().getName();
LOG.info("Directory create : " + userName + " - " + fileName);
-
+
// notify statistics object
- ServerFtpStatistics ftpStat = (ServerFtpStatistics)context.getFtpStatistics();
+ ServerFtpStatistics ftpStat = (ServerFtpStatistics) context
+ .getFtpStatistics();
ftpStat.setMkdir(session, file);
-
+
} else {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD", fileName));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD",
+ fileName));
}
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLSD.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLSD.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLSD.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLSD.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -43,86 +43,113 @@
/**
* <code>MLSD [<SP> <pathname>] <CRLF></code><br>
+ *
+ * This command causes a list to be sent from the server to the passive DTP. The
+ * pathname must specify a directory and the server should transfer a list of
+ * files in the specified directory. A null argument implies the user's current
+ * working or default directory. The data transfer is over the data connection
*
- * This command causes a list to be sent from the server to the
- * passive DTP. The pathname must specify a directory and the
- * server should transfer a list of files in the specified directory.
- * A null argument implies the user's current working or default directory.
- * The data transfer is over the data connection
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class MLSD extends AbstractCommand {
-
+public class MLSD extends AbstractCommand {
+
private final Logger LOG = LoggerFactory.getLogger(MLSD.class);
-
+
private DirectoryLister directoryLister = new DirectoryLister();
-
+
/**
* Execute command.
*/
- public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ public void execute(final FtpIoSession session,
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
try {
-
+
// reset state
session.resetState();
- // 24-10-2007 - added check if PORT or PASV is issued, see https://issues.apache.org/jira/browse/FTPSERVER-110
+ // 24-10-2007 - added check if PORT or PASV is issued, see
+ // https://issues.apache.org/jira/browse/FTPSERVER-110
DataConnectionFactory connFactory = session.getDataConnection();
if (connFactory instanceof IODataConnectionFactory) {
- InetAddress address = ((IODataConnectionFactory)connFactory).getInetAddress();
+ InetAddress address = ((IODataConnectionFactory) connFactory)
+ .getInetAddress();
if (address == null) {
- session.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
+ session.write(new DefaultFtpReply(
+ FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS,
+ "PORT or PASV must be issued first"));
return;
}
}
-
+
// get data connection
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_150_FILE_STATUS_OKAY, "MLSD", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_150_FILE_STATUS_OKAY, "MLSD", null));
-
// print listing data
DataConnection dataConnection;
try {
dataConnection = session.getDataConnection().openConnection();
} catch (Exception e) {
LOG.debug("Exception getting the output data stream", e);
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "MLSD", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "MLSD",
+ null));
return;
}
-
+
boolean failure = false;
try {
// parse argument
- ListArgument parsedArg = ListArgumentParser.parse(request.getArgument());
-
- FileFormater formater = new MLSTFileFormater((String[])session.getAttribute("MLST.types"));
-
- dataConnection.transferToClient(directoryLister.listFiles(parsedArg, session.getFileSystemView(), formater));
- }
- catch(SocketException ex) {
+ ListArgument parsedArg = ListArgumentParser.parse(request
+ .getArgument());
+
+ FileFormater formater = new MLSTFileFormater((String[]) session
+ .getAttribute("MLST.types"));
+
+ dataConnection.transferToClient(directoryLister.listFiles(
+ parsedArg, session.getFileSystemView(), formater));
+ } catch (SocketException ex) {
LOG.debug("Socket exception during data transfer", ex);
failure = true;
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "MLSD", null));
- }
- catch(IOException ex) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED,
+ "MLSD", null));
+ } catch (IOException ex) {
LOG.debug("IOException during data transfer", ex);
failure = true;
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "MLSD", null));
- } catch(IllegalArgumentException e) {
- LOG.debug("Illegal listing syntax: " + request.getArgument(), e);
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN,
+ "MLSD", null));
+ } catch (IllegalArgumentException e) {
+ LOG
+ .debug("Illegal listing syntax: "
+ + request.getArgument(), e);
// if listing syntax error - send message
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLSD", null));
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "MLSD", null));
}
-
+
// if data transfer ok - send transfer complete message
- if(!failure) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "MLSD", null));
+ if (!failure) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "MLSD",
+ null));
}
- }
- finally {
+ } finally {
session.getDataConnection().closeDataConnection();
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLST.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLST.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLST.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLST.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -37,40 +37,55 @@
/**
* <code>MLST <SP> <pathname> <CRLF></code><br>
- *
+ *
* Returns info on the file over the control connection.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class MLST extends AbstractCommand {
+public class MLST extends AbstractCommand {
private final Logger LOG = LoggerFactory.getLogger(MLST.class);
-
+
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException {
+
// reset state variables
session.resetState();
-
-// parse argument
- ListArgument parsedArg = ListArgumentParser.parse(request.getArgument());
-
+
+ // parse argument
+ ListArgument parsedArg = ListArgumentParser
+ .parse(request.getArgument());
+
FileObject file = null;
try {
- file = session.getFileSystemView().getFileObject(parsedArg.getFile());
- if(file != null && file.doesExist()) {
- FileFormater formater = new MLSTFileFormater((String[])session.getAttribute("MLST.types"));
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "MLST", formater.format(file)));
- } else {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLST", null));
+ file = session.getFileSystemView().getFileObject(
+ parsedArg.getFile());
+ if (file != null && file.doesExist()) {
+ FileFormater formater = new MLSTFileFormater((String[]) session
+ .getAttribute("MLST.types"));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "MLST",
+ formater.format(file)));
+ } else {
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "MLST", null));
}
- }
- catch(FtpException ex) {
+ } catch (FtpException ex) {
LOG.debug("Exception sending the file listing", ex);
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLST", null));
- }
- }
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "MLST", null));
+ }
+ }
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MODE.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MODE.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MODE.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MODE.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -29,43 +29,53 @@
/**
* <code>MODE <SP> <mode-code> <CRLF></code><br>
+ *
+ * The argument is a single Telnet character code specifying the data transfer
+ * modes described in the Section on Transmission Modes.
*
- * The argument is a single Telnet character code specifying
- * the data transfer modes described in the Section on
- * Transmission Modes.
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class MODE extends AbstractCommand {
-
+public class MODE extends AbstractCommand {
+
/**
* Execute command
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException {
+
// reset state
session.resetState();
-
+
// argument check
- if(!request.hasArgument()) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MODE", null));
- return;
+ if (!request.hasArgument()) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "MODE", null));
+ return;
}
-
+
// set mode
char md = request.getArgument().charAt(0);
md = Character.toUpperCase(md);
- if(md == 'S') {
+ if (md == 'S') {
session.getDataConnection().setZipMode(false);
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "MODE", "S"));
- }
- else if(md == 'Z') {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_200_COMMAND_OKAY, "MODE", "S"));
+ } else if (md == 'Z') {
session.getDataConnection().setZipMode(true);
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "MODE", "Z"));
- }
- else {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MODE", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_200_COMMAND_OKAY, "MODE", "Z"));
+ } else {
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER,
+ "MODE", null));
}
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NLST.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NLST.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NLST.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NLST.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -44,94 +44,121 @@
/**
* <code>NLST [<SP> <pathname>] <CRLF></code><br>
+ *
+ * This command causes a directory listing to be sent from server to user site.
+ * The pathname should specify a directory or other system-specific file group
+ * descriptor; a null argument implies the current directory. The server will
+ * return a stream of names of files and no other information.
*
- * This command causes a directory listing to be sent from
- * server to user site. The pathname should specify a
- * directory or other system-specific file group descriptor; a
- * null argument implies the current directory. The server
- * will return a stream of names of files and no other
- * information.
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class NLST extends AbstractCommand {
+public class NLST extends AbstractCommand {
private final Logger LOG = LoggerFactory.getLogger(NLST.class);
-
+
private static final NLSTFileFormater NLST_FILE_FORMATER = new NLSTFileFormater();
+
private static final LISTFileFormater LIST_FILE_FORMATER = new LISTFileFormater();
+
private DirectoryLister directoryLister = new DirectoryLister();
-
+
/**
* Execute command
*/
- public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ public void execute(final FtpIoSession session,
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
try {
-
+
// reset state
session.resetState();
- // 24-10-2007 - added check if PORT or PASV is issued, see https://issues.apache.org/jira/browse/FTPSERVER-110
+ // 24-10-2007 - added check if PORT or PASV is issued, see
+ // https://issues.apache.org/jira/browse/FTPSERVER-110
DataConnectionFactory connFactory = session.getDataConnection();
if (connFactory instanceof IODataConnectionFactory) {
- InetAddress address = ((IODataConnectionFactory)connFactory).getInetAddress();
+ InetAddress address = ((IODataConnectionFactory) connFactory)
+ .getInetAddress();
if (address == null) {
- session.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
+ session.write(new DefaultFtpReply(
+ FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS,
+ "PORT or PASV must be issued first"));
return;
}
}
-
+
// get data connection
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_150_FILE_STATUS_OKAY, "NLST", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_150_FILE_STATUS_OKAY, "NLST", null));
-
// print listing data
DataConnection dataConnection;
try {
dataConnection = session.getDataConnection().openConnection();
} catch (Exception e) {
LOG.debug("Exception getting the output data stream", e);
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "NLST", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "NLST",
+ null));
return;
}
-
+
boolean failure = false;
try {
// parse argument
- ListArgument parsedArg = ListArgumentParser.parse(request.getArgument());
-
+ ListArgument parsedArg = ListArgumentParser.parse(request
+ .getArgument());
+
FileFormater formater;
- if(parsedArg.hasOption('l')) {
+ if (parsedArg.hasOption('l')) {
formater = LIST_FILE_FORMATER;
} else {
formater = NLST_FILE_FORMATER;
}
-
- dataConnection.transferToClient(directoryLister.listFiles(parsedArg, session.getFileSystemView(), formater));
- }
- catch(SocketException ex) {
+
+ dataConnection.transferToClient(directoryLister.listFiles(
+ parsedArg, session.getFileSystemView(), formater));
+ } catch (SocketException ex) {
LOG.debug("Socket exception during data transfer", ex);
failure = true;
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "NLST", null));
- }
- catch(IOException ex) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED,
+ "NLST", null));
+ } catch (IOException ex) {
LOG.debug("IOException during data transfer", ex);
failure = true;
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "NLST", null));
- } catch(IllegalArgumentException e) {
- LOG.debug("Illegal listing syntax: " + request.getArgument(), e);
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN,
+ "NLST", null));
+ } catch (IllegalArgumentException e) {
+ LOG
+ .debug("Illegal listing syntax: "
+ + request.getArgument(), e);
// if listing syntax error - send message
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "LIST", null));
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "LIST", null));
}
-
+
// if data transfer ok - send transfer complete message
- if(!failure) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "NLST", null));
+ if (!failure) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "NLST",
+ null));
}
- }
- finally {
+ } finally {
session.getDataConnection().closeDataConnection();
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NOOP.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NOOP.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NOOP.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NOOP.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -30,22 +30,24 @@
/**
* <code>NOOP <CRLF></code><br>
+ *
+ * This command does not affect any parameters or previously entered commands.
+ * It specifies no action other than that the server send an OK reply.
*
- * This command does not affect any parameters or previously
- * entered commands. It specifies no action other than that the
- * server send an OK reply.
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class NOOP extends AbstractCommand {
+public class NOOP extends AbstractCommand {
/**
* Execute command
*/
- public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ public void execute(final FtpIoSession session,
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
session.resetState();
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "NOOP", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_200_COMMAND_OKAY, "NOOP", null));
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NotSupportedCommand.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NotSupportedCommand.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NotSupportedCommand.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NotSupportedCommand.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -28,23 +28,27 @@
import org.apache.ftpserver.util.FtpReplyUtil;
/**
- * A command used primarily for overriding already
- * installed commands when one wants to disable the command.
+ * A command used primarily for overriding already installed commands when one
+ * wants to disable the command.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class NotSupportedCommand extends AbstractCommand {
+public class NotSupportedCommand extends AbstractCommand {
/**
* Execute command
*/
- public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException {
-
+ public void execute(final FtpIoSession session,
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException {
+
// reset state variables
session.resetState();
-
+
// We do not support this command
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "Not supported", null));
- }
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "Not supported",
+ null));
+ }
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -32,67 +32,74 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
/**
- * <code>OPTS<SP> <commandt> <SP> <option> <CRLF></code><br>
+ * <code>OPTS<SP> <command> <SP> <option> <CRLF></code><br>
+ *
+ * This command shall cause the server use optional features for the command
+ * specified.
*
- * This command shall cause the server use optional features for the
- * command specified.
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class OPTS extends AbstractCommand {
+public class OPTS extends AbstractCommand {
private final Logger LOG = LoggerFactory.getLogger(OPTS.class);
-
- private static final HashMap<String, Command> COMMAND_MAP = new HashMap<String, Command>(16);
-
-
+
+ private static final HashMap<String, Command> COMMAND_MAP = new HashMap<String, Command>(
+ 16);
+
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
// reset state
session.resetState();
-
+
// no params
String argument = request.getArgument();
- if(argument == null) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "OPTS", null));
+ if (argument == null) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "OPTS", null));
return;
}
-
+
// get request name
int spaceIndex = argument.indexOf(' ');
- if(spaceIndex != -1) {
+ if (spaceIndex != -1) {
argument = argument.substring(0, spaceIndex);
}
argument = argument.toUpperCase();
-
+
// call appropriate command method
- String optsRequest = "OPTS_" + argument;
- Command command = (Command)COMMAND_MAP.get( optsRequest );
+ String optsRequest = "OPTS_" + argument;
+ Command command = (Command) COMMAND_MAP.get(optsRequest);
try {
- if(command != null) {
+ if (command != null) {
command.execute(session, context, request);
- }
- else {
+ } else {
session.resetState();
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "OPTS.not.implemented", argument));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED,
+ "OPTS.not.implemented", argument));
}
- }
- catch(Exception ex) {
+ } catch (Exception ex) {
LOG.warn("OPTS.execute()", ex);
session.resetState();
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_500_SYNTAX_ERROR_COMMAND_UNRECOGNIZED, "OPTS", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_500_SYNTAX_ERROR_COMMAND_UNRECOGNIZED,
+ "OPTS", null));
}
}
-
+
// initialize all the OPTS command handlers
static {
- COMMAND_MAP.put("OPTS_MLST", new org.apache.ftpserver.command.OPTS_MLST());
- COMMAND_MAP.put("OPTS_UTF8", new org.apache.ftpserver.command.OPTS_UTF8());
+ COMMAND_MAP.put("OPTS_MLST",
+ new org.apache.ftpserver.command.OPTS_MLST());
+ COMMAND_MAP.put("OPTS_UTF8",
+ new org.apache.ftpserver.command.OPTS_UTF8());
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_MLST.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_MLST.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_MLST.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_MLST.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -30,78 +30,79 @@
import org.apache.ftpserver.util.FtpReplyUtil;
/**
- * Client-Server listing negotation.
- * Instruct the server what listing types to include in
- * machine directory/file listings.
+ * Client-Server listing negotation. Instruct the server what listing types to
+ * include in machine directory/file listings.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class OPTS_MLST extends AbstractCommand {
-
- private final static String[] AVAILABLE_TYPES = {
- "Size",
- "Modify",
- "Type",
- "Perm"
- };
-
+public class OPTS_MLST extends AbstractCommand {
+
+ private final static String[] AVAILABLE_TYPES = { "Size", "Modify", "Type",
+ "Perm" };
+
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
// reset state
session.resetState();
-
+
// get the listing types
String argument = request.getArgument();
int spIndex = argument.indexOf(' ');
- if(spIndex == -1) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "OPTS.MLST", null));
+ if (spIndex == -1) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "OPTS.MLST",
+ null));
return;
}
String listTypes = argument.substring(spIndex + 1);
-
+
// parse all the type tokens
StringTokenizer st = new StringTokenizer(listTypes, ";");
String types[] = new String[st.countTokens()];
- for(int i=0; i<types.length; ++i) {
+ for (int i = 0; i < types.length; ++i) {
types[i] = st.nextToken();
}
-
+
// set the list types
String[] validatedTypes = validateSelectedTypes(types);
- if(validatedTypes != null) {
+ if (validatedTypes != null) {
session.setAttribute("MLST.types", validatedTypes);
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "OPTS.MLST", listTypes));
- }
- else {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "OPTS.MLST", listTypes));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_200_COMMAND_OKAY, "OPTS.MLST", listTypes));
+ } else {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "OPTS.MLST", listTypes));
}
}
-
+
private String[] validateSelectedTypes(final String types[]) {
-
+
// ignore null types
- if(types == null) {
+ if (types == null) {
return null;
}
-
+
// check all the types
- for(int i=0; i<types.length; ++i) {
+ for (int i = 0; i < types.length; ++i) {
boolean bMatch = false;
- for(int j=0; j<AVAILABLE_TYPES.length; ++j) {
- if(AVAILABLE_TYPES[j].equals(types[i])) {
+ for (int j = 0; j < AVAILABLE_TYPES.length; ++j) {
+ if (AVAILABLE_TYPES[j].equals(types[i])) {
bMatch = true;
break;
}
}
- if(!bMatch) {
+ if (!bMatch) {
return null;
}
}
-
+
// set the user types
String[] selectedTypes = new String[types.length];
System.arraycopy(types, 0, selectedTypes, 0, types.length);
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_UTF8.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_UTF8.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_UTF8.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_UTF8.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -28,27 +28,28 @@
import org.apache.ftpserver.interfaces.FtpServerContext;
import org.apache.ftpserver.util.FtpReplyUtil;
-
/**
- * Client-Server encoding negotiation.
- * Force server from default encoding to UTF-8 and back.
- * Note that the servers default encoding is UTF-8.
- * So this command has no effect.
+ * Client-Server encoding negotiation. Force server from default encoding to
+ * UTF-8 and back. Note that the servers default encoding is UTF-8. So this
+ * command has no effect.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class OPTS_UTF8 extends AbstractCommand {
-
+public class OPTS_UTF8 extends AbstractCommand {
+
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
// reset state
session.resetState();
-
+
// send default message
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "OPTS.UTF8", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_200_COMMAND_OKAY, "OPTS.UTF8", null));
}
}