160b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair/*
260b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * Copyright 2008 the original author or authors.
360b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair *
460b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * Licensed under the Apache License, Version 2.0 (the "License");
560b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * you may not use this file except in compliance with the License.
660b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * You may obtain a copy of the License at
760b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair *
860b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair *      http://www.apache.org/licenses/LICENSE-2.0
960b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair *
1060b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * Unless required by applicable law or agreed to in writing, software
1160b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * distributed under the License is distributed on an "AS IS" BASIS,
1260b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1360b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * See the License for the specific language governing permissions and
1460b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * limitations under the License.
1560b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair */
1660b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismairpackage org.mockftpserver.core.command;
1760b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair
1860b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismairimport org.mockftpserver.core.session.Session;
1960b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair
2060b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair/**
2160b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * CommandHandler that encapsulates the sending of the reply when a requested command is not
2260b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * recognized/supported. Send back a reply code of 502, indicating command not implemented.
2360b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * <p>
2460b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * Note that this is a "special" CommandHandler, in that it handles any unrecognized command,
2560b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * rather than an explicit FTP command.
2660b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * <p>
2760b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * Each invocation record stored by this CommandHandler contains no data elements.
2860b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair *
2960b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * @author Chris Mair
3060b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair * @version $Revision$ - $Date$
3160b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair */
3260b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismairpublic final class UnsupportedCommandHandler extends AbstractStaticReplyCommandHandler implements CommandHandler {
3360b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair
3460b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair    /**
3560b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair     * Constructor. Initiate the replyCode.
3660b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair     */
3760b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair    public UnsupportedCommandHandler() {
3860b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair        setReplyCode(ReplyCodes.COMMAND_NOT_SUPPORTED);
3960b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair    }
4060b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair
4160b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair    /**
4260b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair     * @see org.mockftpserver.core.command.AbstractTrackingCommandHandler#handleCommand(org.mockftpserver.core.command.Command, org.mockftpserver.core.session.Session, org.mockftpserver.core.command.InvocationRecord)
4360b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair     */
4460b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair    public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) {
4560b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair        LOG.warn("No CommandHandler is defined for command [" + command.getName() + "]");
4660b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair        sendReply(session, command.getName());
4760b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair    }
4860b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair
4960b81e2faf8511148f0d1e8f296e0b40ce9c7971chrismair}