Package ds.pjftp.command.impl

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

/*
* 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.structure.Structure;
import ds.pjftp.structure.Structures;

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

public class Stru extends Command {

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

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

        final char type = param.charAt(0);
        final Structure structure = Structures.get(type);

        if (structure == null) {
            session.replyWithSpace(504, "Not implemented for this command.");
            return;
        }
        // We don't set structure parameter anywhere coz server supports
        // only file structure. Just send successfull response in case when
        // client requested file structure.
        session.replyWithSpace(200, "Structure was set to {}", structure);
    }
}
TOP

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

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.