Package org.apache.ftpserver.command

Examples of org.apache.ftpserver.command.Command


        }
        argument = argument.toUpperCase();

        // call appropriate command method
        String optsRequest = "OPTS_" + argument;
        Command command = COMMAND_MAP.get(optsRequest);
        try {
            if (command != null) {
                command.execute(session, context, request);
            } else {
                session.resetState();
                session.write(LocalizedFtpReply.translate(session, request, context,
                        FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED,
                        "OPTS.not.implemented", argument));
View Full Code Here


        try {
            session.updateLastAccessTime();
           
            String commandName = request.getCommand();
            CommandFactory commandFactory = context.getCommandFactory();
            Command command = commandFactory.getCommand(commandName);

            // make sure the user is authenticated before he issues commands
            if (!session.isLoggedIn()
                    && !isCommandOkWithoutAuthentication(commandName)) {
                session.write(LocalizedFtpReply.translate(session, request,
                        context, FtpReply.REPLY_530_NOT_LOGGED_IN,
                        "permission", null));
                return;
            }

            FtpletContainer ftplets = context.getFtpletContainer();

            FtpletResult ftpletRet;
            try {
                ftpletRet = ftplets.beforeCommand(session.getFtpletSession(),
                        request);
            } catch (Exception e) {
                LOG.debug("Ftplet container threw exception", e);
                ftpletRet = FtpletResult.DISCONNECT;
            }
            if (ftpletRet == FtpletResult.DISCONNECT) {
                LOG.debug("Ftplet returned DISCONNECT, session will be closed");
                session.close(false).awaitUninterruptibly(10000);
                return;
            } else if (ftpletRet != FtpletResult.SKIP) {

                if (command != null) {
                    synchronized (session) {
                        command.execute(session, context, request);
                    }
                } else {
                    session.write(LocalizedFtpReply.translate(session, request,
                            context,
                            FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED,
View Full Code Here

            return;
        }

        // call appropriate command method
        String siteRequest = "SITE_" + argument;
        Command command = context.getCommandFactory().getCommand(siteRequest);
        try {
            if (command != null) {
                command.execute(session, context, request);
            } else {
                session.resetState();
                session.write(LocalizedFtpReply.translate(session, request, context,
                        FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "SITE",
                        argument));
View Full Code Here

*/
public class DefaultCommandFactoryTest extends TestCase {

    public void testReturnFromDefaultUpper() {
        CommandFactory factory = new CommandFactoryFactory().createCommandFactory();
        Command command = factory.getCommand("STOR");

        assertNotNull(command);
        assertTrue(command instanceof STOR);
    }
View Full Code Here

        assertTrue(command instanceof STOR);
    }

    public void testReturnFromDefaultLower() {
        CommandFactory factory = new CommandFactoryFactory().createCommandFactory();
        Command command = factory.getCommand("stor");

        assertNotNull(command);
        assertTrue(command instanceof STOR);
    }
View Full Code Here

        assertTrue(command instanceof STOR);
    }

    public void testReturnFromDefaultUnknown() {
        CommandFactory factory = new CommandFactoryFactory().createCommandFactory();
        Command command = factory.getCommand("dummy");

        assertNull(command);
    }
View Full Code Here

        CommandFactoryFactory factoryFactory = new CommandFactoryFactory();
        factoryFactory.addCommand("stor", new NOOP());

        CommandFactory factory = factoryFactory.createCommandFactory();

        Command command = factory.getCommand("Stor");

        assertTrue(command instanceof NOOP);
    }
View Full Code Here

*/
public class DefaultCommandFactoryTest extends TestCase {

    public void testReturnFromDefaultUpper() {
        CommandFactory factory = new CommandFactoryFactory().createCommandFactory();
        Command command = factory.getCommand("STOR");

        assertNotNull(command);
        assertTrue(command instanceof STOR);
    }
View Full Code Here

        assertTrue(command instanceof STOR);
    }

    public void testReturnFromDefaultLower() {
        CommandFactory factory = new CommandFactoryFactory().createCommandFactory();
        Command command = factory.getCommand("stor");

        assertNotNull(command);
        assertTrue(command instanceof STOR);
    }
View Full Code Here

        assertTrue(command instanceof STOR);
    }

    public void testReturnFromDefaultUnknown() {
        CommandFactory factory = new CommandFactoryFactory().createCommandFactory();
        Command command = factory.getCommand("dummy");

        assertNull(command);
    }
View Full Code Here

TOP

Related Classes of org.apache.ftpserver.command.Command

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.