handleCommand method

void handleCommand(
  1. String commandLine,
  2. FtpSession session
)

Implementation

void handleCommand(String commandLine, FtpSession session) {
  List<String> parts = commandLine.split(' ');
  String command = parts[0].toUpperCase();
  String argument = parts.length > 1 ? parts.sublist(1).join(' ').trim() : '';

  logger.logCommand(command, argument);

  switch (command) {
    case 'USER':
      handleUser(argument, session);
      break;
    case 'PASS':
      handlePass(argument, session);
      break;
    case 'QUIT':
      handleQuit(session);
      break;
    case 'PASV':
      handlePasv(session);
      break;
    case 'PORT':
      handlePort(argument, session);
      break;
    case 'LIST':
    case 'NLST':
      handleList(argument, session);
      break;
    case 'RETR':
      handleRetr(argument, session);
      break;
    case 'STOR':
      handleStor(argument, session);
      break;
    case 'CWD':
      handleCwd(argument, session);
      break;
    case 'CDUP':
      handleCdup(session);
      break;
    case 'MKD':
    case 'XMKD':
      handleMkd(argument, session);
      break;
    case 'RMD':
    case 'XRMD':
      handleRmd(argument, session);
      break;
    case 'DELE':
      handleDele(argument, session);
      break;
    case 'SYST':
      handleSyst(session);
      break;
    case 'NOOP':
      handleNoop(session);
      break;
    case 'TYPE':
      handleType(argument, session);
      break;
    case 'SIZE':
      handleSize(argument, session);
      break;
    case 'PWD':
    case 'XPWD':
      handleCurPath(session);
      break;
    case 'OPTS':
      handleOptions(argument, session);
      break;
    case 'FEAT':
      handleFeat(session);
      break;
    case 'EPSV':
      handleEpsv(session);
      break;
    case 'ABOR':
      handleAbort(session);
      break;
    case 'MLSD':
      handleMlsd(argument, session);
      break;
    case 'MDTM':
      handleMdtm(argument, session);
      break;
    default:
      session.sendResponse('502 Command not implemented $command $argument');
      break;
  }
}