Home | History | Annotate | Download | only in command
      1 /*
      2  * Copyright 2008 the original author or authors.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package org.mockftpserver.core.command;
     17 
     18 import org.mockftpserver.core.session.Session;
     19 
     20 /**
     21  * CommandHandler that encapsulates the sending of the reply when a requested command is not
     22  * recognized/supported. Send back a reply code of 502, indicating command not implemented.
     23  * <p>
     24  * Note that this is a "special" CommandHandler, in that it handles any unrecognized command,
     25  * rather than an explicit FTP command.
     26  * <p>
     27  * Each invocation record stored by this CommandHandler contains no data elements.
     28  *
     29  * @author Chris Mair
     30  * @version $Revision$ - $Date$
     31  */
     32 public final class UnsupportedCommandHandler extends AbstractStaticReplyCommandHandler implements CommandHandler {
     33 
     34     /**
     35      * Constructor. Initiate the replyCode.
     36      */
     37     public UnsupportedCommandHandler() {
     38         setReplyCode(ReplyCodes.COMMAND_NOT_SUPPORTED);
     39     }
     40 
     41     /**
     42      * @see org.mockftpserver.core.command.AbstractTrackingCommandHandler#handleCommand(org.mockftpserver.core.command.Command, org.mockftpserver.core.session.Session, org.mockftpserver.core.command.InvocationRecord)
     43      */
     44     public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) {
     45         LOG.warn("No CommandHandler is defined for command [" + command.getName() + "]");
     46         sendReply(session, command.getName());
     47     }
     48 
     49 }