// get data connection
session.write(LocalizedFtpReply.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(LocalizedFtpReply.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());
FileFormater formater;
if (parsedArg.hasOption('l')) {
formater = LIST_FILE_FORMATER;
} else {
formater = NLST_FILE_FORMATER;
}
dataConnection.transferToClient(session.getFtpletSession(), directoryLister.listFiles(
parsedArg, session.getFileSystemView(), formater));
} catch (SocketException ex) {
LOG.debug("Socket exception during data transfer", ex);
failure = true;
session.write(LocalizedFtpReply.translate(session, request, context,