On Fri, 2010-02-26 at 06:58 -0600, Sai Pullabhotla wrote:

The first thing is to come up with a special syntax that hints the
FtpReplyTranslator that there is a variable in the message and it
needs to be expanded before sending the reply to the client. The
current syntax we use is something like:

{variable}

some of the example variables that we currently have are -

{client.ip} - evaluates to the IP address of the client
{request.cmd} - the command portion of the request excluding any arguments

I would recommend that we use variables that start with "session." to
get any attribute from the session. So, for example, if we have an
attribute named "bandwidthLimit" in the session (FtpIoSession), this
value can be sent in replies using the variable
{session.bandwidthLimit}. When the FtpReplyTranslator sees this
variable, it first checks the first part of the variable, which is
"session" in this case. Then it would call another utility method that
knows how to expand session variables. The new utility method would
simply do something like this:

return String.valueOf(session.getAttribute("bandwidthLimit"));

I think something like this should do the trick.

Regards,
Sai Pullabhotl


It does the trick:

However this requires writing to session, so I still need to overwrite
LIST command:

long time = System.currentTimeMillis();
                session.setAttribute("session.custom", "test " + time);

session.write(LocalizedDataTransferFtpReply.translate(session,
request, context,FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "LIST",
null, file, dirList.length()));

This would be ideal if I would find a way to write message to session
without overwrite command.

Any hints?

Reply via email to