Package org.apache.ftpserver

Examples of org.apache.ftpserver.DefaultFtpReply


          // 24-10-2007 - added check if PORT or PASV is issued, see https://issues.apache.org/jira/browse/FTPSERVER-110
            DataConnectionFactory connFactory = session.getDataConnection();
            if (connFactory instanceof IODataConnectionFactory) {
                InetAddress address = ((IODataConnectionFactory)connFactory).getInetAddress();
                if (address == null) {
                    session.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
                    return;
                }
            }
       
            // reset state variables
            session.resetState();
           
            // call Ftplet.onUploadUniqueStart() method
            Ftplet ftpletContainer = context.getFtpletContainer();
            FtpletEnum ftpletRet;
            try {
                ftpletRet = ftpletContainer.onUploadUniqueStart(session.getFtpletSession(), request);
            } catch(Exception e) {
                LOG.debug("Ftplet container threw exception", e);
                ftpletRet = FtpletEnum.RET_DISCONNECT;
            }
            if(ftpletRet == FtpletEnum.RET_SKIP) {
                return;
            }
            else if(ftpletRet == FtpletEnum.RET_DISCONNECT) {
                session.closeOnFlush().awaitUninterruptibly(10000);
                return;
            }
           
            String pathName = request.getArgument();
           
            // get filenames
            FileObject file = null;
            try {
              String filePrefix;
                if(pathName == null) {
                  filePrefix = "ftp.dat";
              } else {
                FileObject dir = session.getFileSystemView().getFileObject(pathName);
                if(dir.isDirectory()) {
                  filePrefix = pathName + "/ftp.dat";
                } else {
                  filePrefix = pathName;
                }
              }
           
                file = session.getFileSystemView().getFileObject(filePrefix);
                if(file != null) {
                    file = getUniqueFile(session, file);
                }
            }
            catch(Exception ex) {
                LOG.debug("Exception getting file object", ex);
            }
           
            if(file == null) {
                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "STOU", null));
                return;
            }
            String fileName = file.getFullName();
           
            // check permission
            if(!file.hasWritePermission()) {
                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "STOU.permission", fileName));
                return;
            }
           
            // get data connection
            session.write(new DefaultFtpReply(FtpReply.REPLY_150_FILE_STATUS_OKAY, "FILE: " + fileName));

            // get data from client
            boolean failure = false;
            OutputStream os = null;
           
View Full Code Here


            sb.append( StringUtils.pad(DateUtils.getISO8601Date(managedSession.getLoginTime().getTime()), ' ', true, 20) );
            sb.append( StringUtils.pad(DateUtils.getISO8601Date(managedSession.getLastAccessTime().getTime()), ' ', true, 20) );
            sb.append('\n');
        }
        sb.append('\n');
        session.write(new DefaultFtpReply(FtpReply.REPLY_200_COMMAND_OKAY, sb.toString()));
    }
View Full Code Here

TOP

Related Classes of org.apache.ftpserver.DefaultFtpReply

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.