Examples of DefaultFtpReply


Examples of org.apache.ftpserver.ftplet.DefaultFtpReply

            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;
                }
            }
View Full Code Here

Examples of org.apache.ftpserver.ftplet.DefaultFtpReply

            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();

            String pathName = request.getArgument();

            // get filenames
            FtpFile file = null;
            try {
                String filePrefix;
                if (pathName == null) {
                    filePrefix = "ftp.dat";
                } else {
                    FtpFile dir = session.getFileSystemView().getFile(
                            pathName);
                    if (dir.isDirectory()) {
                        filePrefix = pathName + "/ftp.dat";
                    } else {
                        filePrefix = pathName;
                    }
                }

                file = session.getFileSystemView().getFile(filePrefix);
                if (file != null) {
                    file = getUniqueFile(session, file);
                }
            } catch (Exception ex) {
                LOG.debug("Exception getting file object", ex);
            }

            if (file == null) {
                session.write(LocalizedDataTransferFtpReply.translate(session, request, context,
                        FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "STOU",
                        null, null));
                return;
            }
            String fileName = file.getAbsolutePath();

            // check permission
            if (!file.isWritable()) {
                session.write(LocalizedDataTransferFtpReply.translate(session, request, context,
                        FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
                        "STOU.permission", fileName, file));
                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

Examples of org.apache.ftpserver.ftplet.DefaultFtpReply

            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;
                }
            }
View Full Code Here

Examples of org.apache.ftpserver.ftplet.DefaultFtpReply

    public void testLogin() throws Exception {
        MockFtplet.callback = new MockFtpletCallback() {
            @Override
            public FtpletResult onLogin(FtpSession session, FtpRequest request)
                    throws FtpException, IOException {
                session.write(new DefaultFtpReply(
                        FtpReply.REPLY_530_NOT_LOGGED_IN, "foo"));

                throwException();
                return mockReturnValue;
            }
View Full Code Here

Examples of org.apache.ftpserver.ftplet.DefaultFtpReply

        MockFtplet.callback = new MockFtpletCallback() {
            @Override
            public FtpletResult onDeleteStart(FtpSession session,
                    FtpRequest request) throws FtpException, IOException {

                session.write(new DefaultFtpReply(
                        FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN,
                        "foo"));
                throwException();
                return mockReturnValue;
            }
View Full Code Here

Examples of org.apache.ftpserver.ftplet.DefaultFtpReply

        MockFtplet.callback = new MockFtpletCallback() {
            @Override
            public FtpletResult onMkdirStart(FtpSession session,
                    FtpRequest request) throws FtpException, IOException {

                session.write(new DefaultFtpReply(
                        FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));
                throwException();
                return mockReturnValue;
            }
        };
View Full Code Here

Examples of org.apache.ftpserver.ftplet.DefaultFtpReply

    public void testExceptionDuringRmdirStart() throws Exception {
        MockFtplet.callback = new MockFtpletCallback() {
            @Override
            public FtpletResult onRmdirStart(FtpSession session,
                    FtpRequest request) throws FtpException, IOException {
                session.write(new DefaultFtpReply(
                        FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN,
                        "foo"));

                throwException();
                return mockReturnValue;
View Full Code Here

Examples of org.apache.ftpserver.ftplet.DefaultFtpReply

        MockFtplet.callback = new MockFtpletCallback() {
            @Override
            public FtpletResult onSite(FtpSession session, FtpRequest request)
                    throws FtpException, IOException {
                session
                .write(new DefaultFtpReply(
                        FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED,
                        "foo"));
               
                throwException();
                return mockReturnValue;
View Full Code Here

Examples of org.apache.ftpserver.ftplet.DefaultFtpReply

        MockFtplet.callback = new MockFtpletCallback() {
            @Override
            public FtpletResult onRenameStart(FtpSession session,
                    FtpRequest request) throws FtpException, IOException {
                session
                        .write(new DefaultFtpReply(
                                FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED,
                                "foo"));

                throwException();
                return mockReturnValue;
View Full Code Here

Examples of org.apache.ftpserver.ftplet.DefaultFtpReply

    public void testExceptionDuringDownloadStart() throws Exception {
        MockFtplet.callback = new MockFtpletCallback() {
            @Override
            public FtpletResult onDownloadStart(FtpSession session,
                    FtpRequest request) throws FtpException, IOException {
                session.write(new DefaultFtpReply(
                        FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));

                throwException();
                return mockReturnValue;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.