Package ds.pjftp.command.impl

Source Code of ds.pjftp.command.impl.Mode

/*
* pjftp FTP server.
* Copyright (C) 2012 Dmitriy Simbiriatin <dmitriy.simbiriatin@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

package ds.pjftp.command.impl;

import ds.pjftp.utils.NotNull;

import ds.pjftp.transmission.TransmissionModes;
import ds.pjftp.transmission.TransmissionMode;

import ds.pjftp.command.Command;
import ds.pjftp.main.ClientSession;

public class Mode extends Command {

    /**
     * Handles MODE command.
     */
    @Override
    public void invoke(@NotNull final ClientSession session, @NotNull final String param) {

        if (param.length() != 1) {
            session.replyWithSpace(501, "Syntax error.");
            return;
        }

        final char type = param.charAt(0);
        final TransmissionMode mode = TransmissionModes.get(type);

        if (mode == null) {
            session.replyWithSpace(504, "Not implemented for this command.");
            return;
        }
        session.getDtp().setTransmissionMode(mode);
        session.replyWithSpace(200, "Transmission mode was set to {}", mode);
    }
}
TOP

Related Classes of ds.pjftp.command.impl.Mode

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.