mina-ftpserver-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hiran Chaudhuri <hiran.chaudh...@amadeus.com>
Subject Re: Enrich error messages
Date Thu, 24 Jun 2010 14:02:37 GMT
Well, my code is not rocket science. I just created a class that 
implements FTPlet and uses log4j. to write out the events. Return values 
are always null, as documented for the DefaultFTPlet.
Then I used curl to upload a file. Curl reports success. I can see the 
file arriving in the user's home directory, so I confirm the transfer is 

So there are two questions for me:
- How would I code onUploadStart to deny an upload if some conditions are 
not met (including a verbose message why it was denied)?
- How can I ensure both onUploadStart and onUploadEnd are called at all?


This is the log I see:
INFO: 5515 [http-thread-pool-4848-(1)] DEBUG 
rmspilot.ftpreceiver.RMSFTPlet  - 
INFO: 135884 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
INFO: 135931 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
beforeCommand(org.apache.ftpserver.impl.DefaultFtpSession@1ad0af1, USER 
INFO: 136134 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
afterCommand(org.apache.ftpserver.impl.DefaultFtpSession@ec0fb, USER 
p01nosc, 331 User name okay, need password for p01nosc.
INFO: 136884 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
beforeCommand(org.apache.ftpserver.impl.DefaultFtpSession@cbb203, PASS 
INFO: 137900 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
afterCommand(org.apache.ftpserver.impl.DefaultFtpSession@ec3ee8, PASS 
p01nosc, 230 User logged in, proceed.
INFO: 137900 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
beforeCommand(org.apache.ftpserver.impl.DefaultFtpSession@15f3de, PWD)
INFO: 137900 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
afterCommand(org.apache.ftpserver.impl.DefaultFtpSession@13d8d82, PWD, 257 
"/" is current directory.
INFO: 137915 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
beforeCommand(org.apache.ftpserver.impl.DefaultFtpSession@15723d, EPSV)
INFO: 137931 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
afterCommand(org.apache.ftpserver.impl.DefaultFtpSession@1f734ba, EPSV, 
229 Entering Passive Mode (|||1137|)
INFO: 138900 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
beforeCommand(org.apache.ftpserver.impl.DefaultFtpSession@a6a67f, TYPE I)
INFO: 138915 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
afterCommand(org.apache.ftpserver.impl.DefaultFtpSession@fd0d6b, TYPE I, 
200 Command TYPE okay.
INFO: 138915 [pool-79-thread-2] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
beforeCommand(org.apache.ftpserver.impl.DefaultFtpSession@f1234c, STOR 
INFO: 140931 [pool-79-thread-2] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
afterCommand(org.apache.ftpserver.impl.DefaultFtpSession@1014023, STOR 
FOhotel_20100623_20100624142800_hiran.dat.gz, 226 Transfer complete.
INFO: 140931 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
beforeCommand(org.apache.ftpserver.impl.DefaultFtpSession@119c6a8, QUIT)
INFO: 141915 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 
afterCommand(org.apache.ftpserver.impl.DefaultFtpSession@1415092, QUIT, 
221 Goodbye.
INFO: 141915 [pool-79-thread-1] DEBUG rmspilot.ftpreceiver.RMSFTPlet  - 

Here is the source of my FTPlet:
package rmspilot.ftpreceiver;

 * To change this template, choose Tools | Templates
 * and open the template in the editor.

import java.io.IOException;
import org.apache.ftpserver.ftplet.FtpException;
import org.apache.ftpserver.ftplet.FtpReply;
import org.apache.ftpserver.ftplet.FtpRequest;
import org.apache.ftpserver.ftplet.FtpSession;
import org.apache.ftpserver.ftplet.Ftplet;
import org.apache.ftpserver.ftplet.FtpletContext;
import org.apache.ftpserver.ftplet.FtpletResult;
import org.apache.log4j.Logger;

 * @author hiran
 * @version $Id$
public class RMSFTPlet implements Ftplet {

    private static final Logger log = Logger.getLogger(RMSFTPlet.class);

    public FtpletResult onLogin(FtpSession session, FtpRequest request) 
throws FtpException, IOException {
        return null;

    public FtpletResult onUploadStart(FtpSession session, FtpRequest 
request) throws FtpException, IOException {
        // here we can check whether the user may send us the file at all
        return null;

    public FtpletResult onUploadEnd(FtpSession session, FtpRequest 
request) throws FtpException, IOException {
        log.debug("onUploadEnd(" + session + ", " + request + ")");
        return null;

    public void init(FtpletContext fc) throws FtpException {

    public void destroy() {

    public FtpletResult beforeCommand(FtpSession fs, FtpRequest fr) throws 
FtpException, IOException {
        log.debug("beforeCommand("+fs+", "+fr+")");
        return null;

    public FtpletResult afterCommand(FtpSession ftpSession, FtpRequest 
ftpRequest, FtpReply ftpReply) throws FtpException, IOException {
        log.debug("afterCommand("+ftpSession+", "+ftpRequest+", 
        return null;

    public FtpletResult onConnect(FtpSession fs) throws FtpException, 
IOException {
        return null;

    public FtpletResult onDisconnect(FtpSession fs) throws FtpException, 
IOException {
        return null;

Hiran Chaudhuri
System Support Programmer / Analyst
IT Service Assurance
Hosting & Regional Services (IH)
Amadeus Data Processing GmbH
Berghamer Strasse 6
85435 Erding
T: +49-8122-43x3662

From:   Niklas Gustavsson <niklas@protocol7.com>
To:     ftpserver-users@mina.apache.org
Date:   24-06-10 15:38
Subject:        Re: Enrich error messages

On Thu, Jun 24, 2010 at 3:21 PM, Hiran Chaudhuri
<hiran.chaudhuri@amadeus.com> wrote:
> So how would I do it from the FTPlet (probably in methods 
> And how come I can upload files and see onUploadEnd being not called at 

Yes, onUploadStart() would be a good place to start.

If the upload is successful, you should definitely see onUploadEnd
being called if the Ftplet is set up correctly. If not, please share
your code and test case and we'll have a look at the details.


  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message