1e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair/*
2e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * Copyright 2007 the original author or authors.
3e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair *
4e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * Licensed under the Apache License, Version 2.0 (the "License");
5e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * you may not use this file except in compliance with the License.
6e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * You may obtain a copy of the License at
7e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair *
8e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair *      http://www.apache.org/licenses/LICENSE-2.0
9e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair *
10e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * Unless required by applicable law or agreed to in writing, software
11e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * distributed under the License is distributed on an "AS IS" BASIS,
12e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * See the License for the specific language governing permissions and
14e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * limitations under the License.
15e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair */
16e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismairpackage org.mockftpserver.stub.command;
17e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair
18e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismairimport org.mockftpserver.core.command.Command;
19e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismairimport org.mockftpserver.core.command.CommandHandler;
20e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismairimport org.mockftpserver.core.command.InvocationRecord;
21e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismairimport org.mockftpserver.core.command.ReplyCodes;
22e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismairimport org.mockftpserver.core.session.Session;
23e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair
24e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair/**
25e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * CommandHandler for the SITE (Site Parameters) command. Send back a reply code of 200.
26e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * <p>
27e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * Each invocation record stored by this CommandHandler includes the following data element key/values:
28e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * <ul>
29e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair *    <li>{@link #PARAMETERS_KEY} ("parameters") - the site parameters submitted on the invocation (the first command parameter)
30e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * </ul>
31e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair *
32e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * @version $Revision$ - $Date$
33e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair *
34e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair * @author Chris Mair
35e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair */
36e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismairpublic final class SiteCommandHandler extends AbstractStubCommandHandler implements CommandHandler {
37e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair
38e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair    public static final String PARAMETERS_KEY = "parameters";
39e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair
40e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair    /**
41e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair     * Constructor. Initiate the replyCode.
42e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair     */
43e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair    public SiteCommandHandler() {
44e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair        setReplyCode(ReplyCodes.SITE_OK);
45e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair    }
46e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair
47e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair    /**
48e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair     * @see org.mockftpserver.core.command.CommandHandler#handleCommand(Command, Session, InvocationRecord)
49e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair     */
50e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair    public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) {
51e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair        invocationRecord.set(PARAMETERS_KEY, command.getRequiredString(0));
52e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair        sendReply(session);
53e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair    }
54e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair
55e47352fb2508e2b25f003b8df12fa79c3215b4b1chrismair}
56