mina-ftpserver-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sai Pullabhotla" <sai.pullabho...@jmethods.com>
Subject Re: Question on Ftplets
Date Fri, 14 Nov 2008 22:35:14 GMT
What do you think of the following change:

Change the signature of Ftplet.afterCommand to -

FtpletResult afterCommand(FtpSession session, FtpRequest request,
FtpReply reply)
            throws FtpException, IOException;

I know this breaks the existing applications that are using this
interface, but I'm not sure if there is a way to prevent this.

Implemntations can then check to see if reply.getCode() and see if it
is a Positive Completion Reply (2XX) which means, the requested action
was successful. A 4xx or 5xx message means that the requested action
has failed.

The implementations can then process the parameters of FtpRequest and
get any additional details such as file name that the command acted
on, its size etc.

This would be a good beginning. However, if we want to take it one
more step further, It is not a bad idea to create subclasses of
DefaultFtpReply to include some more additional information. For e.g.
create a new class FtpUploadReply as shown below:

public class FtpUploadReply extends DefaultFtpReply {
    private FileObject file = null;
    private long bytesReceived = 0L; //This may not be needed, as it
could be retrieved from the FileObject.
    private long transferStartTime = 0L;
    private long transferEndTime = 0L;
}

Provide accessor methods for the above instance variables.
Implementations of Ftplet interface can then check the type of
FtpReply first and typecast it to the real type and retrieve the
available information from the FtpReply.

Finally, update the DefaultFtplet to match up with the new interface.
Update the call to afterCommand to include the new parameter.

Hope this all makes sense. Let me know what you think and if you would
like me to work on this.

Thanks.

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




On Fri, Nov 14, 2008 at 3:32 PM, Niklas Gustavsson <niklas@protocol7.com> wrote:
> On Fri, Nov 14, 2008 at 10:16 PM, Sai Pullabhotla
> <sai.pullabhotla@jmethods.com> wrote:
>> Thanks for the quick reply. I apologize for not being very specific in
>> my previous post. I used the FileObserver interface which allows me to
>> receive notification of various file events such as download, upload,
>> mkdir etc. These notifications also contain the FtpIoSession which in
>> turn contains information of the user, remote address etc. which is
>> what I mainly need for the audit log. However, these notifications are
>> available only when the user requested action is successful. However,
>> I would like to log any unsuccessful requests as well. So, the
>> FileObserver alone cannot get me what I want.
>
> Right, I would say that your original idea of using an Ftplet is
> probably the best option, at least given that we could provide you the
> replies.
>
> /niklas
>

Mime
View raw message