public void messageReceived(final FtpIoSession session,
final FtpRequest request) throws Exception {
try {
String commandName = request.getCommand();
CommandFactory commandFactory = context.getCommandFactory();
Command command = commandFactory.getCommand(commandName);
// make sure the user is authenticated before he issues commands
if (!session.isLoggedIn()
&& !isCommandOkWithoutAuthentication(commandName)) {
session.write(FtpReplyUtil.translate(session, request, context,
FtpReply.REPLY_530_NOT_LOGGED_IN, "permission", null));
return;
}
FtpletContainer ftplets = context.getFtpletContainer();
FtpletResult ftpletRet;
try {
ftpletRet = ftplets.beforeCommand(session.getFtpletSession(),
request);
} catch (Exception e) {
LOG.debug("Ftplet container threw exception", e);
ftpletRet = FtpletResult.DISCONNECT;
}
if (ftpletRet == FtpletResult.DISCONNECT) {
session.closeOnFlush().awaitUninterruptibly(10000);
return;
} else if (ftpletRet != FtpletResult.SKIP) {
if (command != null) {
synchronized (session) {
command.execute(session, context, request);
}
} else {
session.write(FtpReplyUtil.translate(session, request,
context,
FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED,