View Javadoc

1   /**
2    * This file is part of Waarp Project.
3    * 
4    * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the
5    * COPYRIGHT.txt in the distribution for a full listing of individual contributors.
6    * 
7    * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of
8    * the GNU General Public License as published by the Free Software Foundation, either version 3 of
9    * the License, or (at your option) any later version.
10   * 
11   * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
12   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13   * Public License for more details.
14   * 
15   * You should have received a copy of the GNU General Public License along with Waarp . If not, see
16   * <http://www.gnu.org/licenses/>.
17   */
18  package org.waarp.ftp.core.command.internal;
19  
20  import org.waarp.common.command.ReplyCode;
21  import org.waarp.common.command.exception.Reply500Exception;
22  import org.waarp.common.logging.WaarpLogger;
23  import org.waarp.common.logging.WaarpLoggerFactory;
24  import org.waarp.ftp.core.command.AbstractCommand;
25  
26  /**
27   * Unrecognized command (unknown command)
28   * 
29   * @author Frederic Bregier
30   * 
31   */
32  public class UnknownCommand extends AbstractCommand {
33      /**
34       * Internal Logger
35       */
36      private static final WaarpLogger logger = WaarpLoggerFactory
37              .getLogger(UnknownCommand.class);
38  
39      @Override
40      public void exec() throws Reply500Exception {
41          getSession().setReplyCode(
42                  ReplyCode.REPLY_500_SYNTAX_ERROR_COMMAND_UNRECOGNIZED,
43                  "Unknown Command: " + getCommand() + " with argument: " +
44                          getArg());
45          logger.warn(getSession().getAnswer());
46          invalidCurrentCommand();
47          throw new Reply500Exception(getSession().getReplyCode().getMesg());
48      }
49  }