You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ftpserver-users@mina.apache.org by Raphael Bauduin <rb...@gmail.com> on 2009/03/11 11:22:52 UTC

appending text to reply message

Hi,

I'd like to add a small information text in each reply message, and I
tried to do that in the afterCommand method:
session.write(new DefaultFtpReply(reply.code(), reply.message()+" my
text appended))
return FtpletResult.DEFAULT

But I get an error. On the client when logging in:
421 Service not available, remote server has closed connection
Login failed.
No control connection for command: Transport endpoint is not connected

The problem comes from writing the ftp reply to the session. But how
can I append some text to the reply message then?

Thanks in advance

Raphaël

PS: I've also just seen that when I have my afterCommand just
returning FtpletResult/DEFAULT,
the actions in my onLogin method are not executed or have no effect (I
change the workingDirectory of the fsview in that mehod)



-- 
Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org

Re: appending text to reply message

Posted by Raphael Bauduin <rb...@gmail.com>.
On Wed, Mar 11, 2009 at 7:13 PM, Niklas Gustavsson <ni...@protocol7.com> wrote:
> On Wed, Mar 11, 2009 at 5:42 PM, Sai Pullabhotla
> <sa...@jmethods.com> wrote:
>> However, by looking at the
>> code, it does not seem to have a way to retrieve an arbitrary value that is
>> bound to the FtpSession. May be the main developers of the project can
>> confirm this and if it is not, I think it would be a good enhancement for
>> the next release.
>
> That's right. Feel free to register a JIRA issue and I'll be happy to
> add this in 1.1.

I added it here:
https://issues.apache.org/jira/browse/FTPSERVER-280

>
> /niklas
>



-- 
Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org

Re: appending text to reply message

Posted by Niklas Gustavsson <ni...@protocol7.com>.
On Wed, Mar 11, 2009 at 5:42 PM, Sai Pullabhotla
<sa...@jmethods.com> wrote:
> However, by looking at the
> code, it does not seem to have a way to retrieve an arbitrary value that is
> bound to the FtpSession. May be the main developers of the project can
> confirm this and if it is not, I think it would be a good enhancement for
> the next release.

That's right. Feel free to register a JIRA issue and I'll be happy to
add this in 1.1.

/niklas

Re: appending text to reply message

Posted by Sai Pullabhotla <sa...@jmethods.com>.
There are several pre-defined variables that you can use as part of the
replies, which are documented at
http://mina.apache.org/ftpserver/messages.html. However, by looking at the
code, it does not seem to have a way to retrieve an arbitrary value that is
bound to the FtpSession. May be the main developers of the project can
confirm this and if it is not, I think it would be a good enhancement for
the next release.

Sai Pullabhotla
Phone: (402) 408-5753
Fax: (402) 408-6861
www.jMethods.com



On Wed, Mar 11, 2009 at 11:22 AM, Raphael Bauduin <rb...@gmail.com> wrote:

> On Wed, Mar 11, 2009 at 4:28 PM, Raphael Bauduin <rb...@gmail.com>
> wrote:
> > On Wed, Mar 11, 2009 at 12:35 PM, Sai Pullabhotla
> > <sa...@jmethods.com> wrote:
> >> By the time your Ftplet's afterCommand is called, it is too late. The
> server
> >> would have already sent the reply to the last command. So, you trying to
> >> send another reply would definitely mess up what the clients are
> expecting.
> >>
> >> What I recommend is -
> >>
> >> The messages are stored in a simple properties file. You should be able
> to
> >> make a copy of it and specify the new file in your FTPServer
> configuration
> >> (spring configuration). Modify the messages to what ever you like. I
> belive
> >> that this page in the documentation should help you in settingup custom
> >> messages.
> >>
> >> http://mina.apache.org/ftpserver/messages.html
> >>
> >> If you are running the Server in Embedded mode, you should be able to
> change
> >> the messages file programatically.
> >>
> >> Hope this helps.
> >
> > Interesting!  I have found the file in the sources at
> >
>  apache-ftpserver-1.0.0/src/core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties
> > Thanks for the tip!
>
> Btw, is there a way to put a dynamic part in the translated string?
> The text I want to add comes from the session object, and is unique
> for each session.
>
> Thanks
>
> Raphaël
>
> >
> > Raphaël
> >
> >>
> >> Sai Pullabhotla
> >> Phone: (402) 408-5753
> >> Fax: (402) 408-6861
> >> www.jMethods.com
> >>
> >>
> >>
> >> On Wed, Mar 11, 2009 at 5:22 AM, Raphael Bauduin <rb...@gmail.com>
> wrote:
> >>
> >>> Hi,
> >>>
> >>> I'd like to add a small information text in each reply message, and I
> >>> tried to do that in the afterCommand method:
> >>> session.write(new DefaultFtpReply(reply.code(), reply.message()+" my
> >>> text appended))
> >>> return FtpletResult.DEFAULT
> >>>
> >>> But I get an error. On the client when logging in:
> >>> 421 Service not available, remote server has closed connection
> >>> Login failed.
> >>> No control connection for command: Transport endpoint is not connected
> >>>
> >>> The problem comes from writing the ftp reply to the session. But how
> >>> can I append some text to the reply message then?
> >>>
> >>> Thanks in advance
> >>>
> >>> Raphaël
> >>>
> >>> PS: I've also just seen that when I have my afterCommand just
> >>> returning FtpletResult/DEFAULT,
> >>> the actions in my onLogin method are not executed or have no effect (I
> >>> change the workingDirectory of the fsview in that mehod)
> >>>
> >>>
> >>>
> >>> --
> >>> Web database: http://www.myowndb.com
> >>> Free Software Developers Meeting: http://www.fosdem.org
> >>>
> >>
> >
> >
> >
> > --
> > Web database: http://www.myowndb.com
> > Free Software Developers Meeting: http://www.fosdem.org
> >
>
>
>
> --
> Web database: http://www.myowndb.com
> Free Software Developers Meeting: http://www.fosdem.org
>

Re: appending text to reply message

Posted by Raphael Bauduin <rb...@gmail.com>.
On Wed, Mar 11, 2009 at 4:28 PM, Raphael Bauduin <rb...@gmail.com> wrote:
> On Wed, Mar 11, 2009 at 12:35 PM, Sai Pullabhotla
> <sa...@jmethods.com> wrote:
>> By the time your Ftplet's afterCommand is called, it is too late. The server
>> would have already sent the reply to the last command. So, you trying to
>> send another reply would definitely mess up what the clients are expecting.
>>
>> What I recommend is -
>>
>> The messages are stored in a simple properties file. You should be able to
>> make a copy of it and specify the new file in your FTPServer configuration
>> (spring configuration). Modify the messages to what ever you like. I belive
>> that this page in the documentation should help you in settingup custom
>> messages.
>>
>> http://mina.apache.org/ftpserver/messages.html
>>
>> If you are running the Server in Embedded mode, you should be able to change
>> the messages file programatically.
>>
>> Hope this helps.
>
> Interesting!  I have found the file in the sources at
>  apache-ftpserver-1.0.0/src/core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties
> Thanks for the tip!

Btw, is there a way to put a dynamic part in the translated string?
The text I want to add comes from the session object, and is unique
for each session.

Thanks

Raphaël

>
> Raphaël
>
>>
>> Sai Pullabhotla
>> Phone: (402) 408-5753
>> Fax: (402) 408-6861
>> www.jMethods.com
>>
>>
>>
>> On Wed, Mar 11, 2009 at 5:22 AM, Raphael Bauduin <rb...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I'd like to add a small information text in each reply message, and I
>>> tried to do that in the afterCommand method:
>>> session.write(new DefaultFtpReply(reply.code(), reply.message()+" my
>>> text appended))
>>> return FtpletResult.DEFAULT
>>>
>>> But I get an error. On the client when logging in:
>>> 421 Service not available, remote server has closed connection
>>> Login failed.
>>> No control connection for command: Transport endpoint is not connected
>>>
>>> The problem comes from writing the ftp reply to the session. But how
>>> can I append some text to the reply message then?
>>>
>>> Thanks in advance
>>>
>>> Raphaël
>>>
>>> PS: I've also just seen that when I have my afterCommand just
>>> returning FtpletResult/DEFAULT,
>>> the actions in my onLogin method are not executed or have no effect (I
>>> change the workingDirectory of the fsview in that mehod)
>>>
>>>
>>>
>>> --
>>> Web database: http://www.myowndb.com
>>> Free Software Developers Meeting: http://www.fosdem.org
>>>
>>
>
>
>
> --
> Web database: http://www.myowndb.com
> Free Software Developers Meeting: http://www.fosdem.org
>



-- 
Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org

Re: appending text to reply message

Posted by Raphael Bauduin <rb...@gmail.com>.
On Wed, Mar 11, 2009 at 12:35 PM, Sai Pullabhotla
<sa...@jmethods.com> wrote:
> By the time your Ftplet's afterCommand is called, it is too late. The server
> would have already sent the reply to the last command. So, you trying to
> send another reply would definitely mess up what the clients are expecting.
>
> What I recommend is -
>
> The messages are stored in a simple properties file. You should be able to
> make a copy of it and specify the new file in your FTPServer configuration
> (spring configuration). Modify the messages to what ever you like. I belive
> that this page in the documentation should help you in settingup custom
> messages.
>
> http://mina.apache.org/ftpserver/messages.html
>
> If you are running the Server in Embedded mode, you should be able to change
> the messages file programatically.
>
> Hope this helps.

Interesting!  I have found the file in the sources at
  apache-ftpserver-1.0.0/src/core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties
Thanks for the tip!

Raphaël

>
> Sai Pullabhotla
> Phone: (402) 408-5753
> Fax: (402) 408-6861
> www.jMethods.com
>
>
>
> On Wed, Mar 11, 2009 at 5:22 AM, Raphael Bauduin <rb...@gmail.com> wrote:
>
>> Hi,
>>
>> I'd like to add a small information text in each reply message, and I
>> tried to do that in the afterCommand method:
>> session.write(new DefaultFtpReply(reply.code(), reply.message()+" my
>> text appended))
>> return FtpletResult.DEFAULT
>>
>> But I get an error. On the client when logging in:
>> 421 Service not available, remote server has closed connection
>> Login failed.
>> No control connection for command: Transport endpoint is not connected
>>
>> The problem comes from writing the ftp reply to the session. But how
>> can I append some text to the reply message then?
>>
>> Thanks in advance
>>
>> Raphaël
>>
>> PS: I've also just seen that when I have my afterCommand just
>> returning FtpletResult/DEFAULT,
>> the actions in my onLogin method are not executed or have no effect (I
>> change the workingDirectory of the fsview in that mehod)
>>
>>
>>
>> --
>> Web database: http://www.myowndb.com
>> Free Software Developers Meeting: http://www.fosdem.org
>>
>



-- 
Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org

Re: appending text to reply message

Posted by Sai Pullabhotla <sa...@jmethods.com>.
By the time your Ftplet's afterCommand is called, it is too late. The server
would have already sent the reply to the last command. So, you trying to
send another reply would definitely mess up what the clients are expecting.

What I recommend is -

The messages are stored in a simple properties file. You should be able to
make a copy of it and specify the new file in your FTPServer configuration
(spring configuration). Modify the messages to what ever you like. I belive
that this page in the documentation should help you in settingup custom
messages.

http://mina.apache.org/ftpserver/messages.html

If you are running the Server in Embedded mode, you should be able to change
the messages file programatically.

Hope this helps.

Sai Pullabhotla
Phone: (402) 408-5753
Fax: (402) 408-6861
www.jMethods.com



On Wed, Mar 11, 2009 at 5:22 AM, Raphael Bauduin <rb...@gmail.com> wrote:

> Hi,
>
> I'd like to add a small information text in each reply message, and I
> tried to do that in the afterCommand method:
> session.write(new DefaultFtpReply(reply.code(), reply.message()+" my
> text appended))
> return FtpletResult.DEFAULT
>
> But I get an error. On the client when logging in:
> 421 Service not available, remote server has closed connection
> Login failed.
> No control connection for command: Transport endpoint is not connected
>
> The problem comes from writing the ftp reply to the session. But how
> can I append some text to the reply message then?
>
> Thanks in advance
>
> Raphaël
>
> PS: I've also just seen that when I have my afterCommand just
> returning FtpletResult/DEFAULT,
> the actions in my onLogin method are not executed or have no effect (I
> change the workingDirectory of the fsview in that mehod)
>
>
>
> --
> Web database: http://www.myowndb.com
> Free Software Developers Meeting: http://www.fosdem.org
>