185efb15529d45e32fea8de03c38a968c157c8262chrismair/*
285efb15529d45e32fea8de03c38a968c157c8262chrismair * Copyright 2007 the original author or authors.
385efb15529d45e32fea8de03c38a968c157c8262chrismair *
485efb15529d45e32fea8de03c38a968c157c8262chrismair * Licensed under the Apache License, Version 2.0 (the "License");
585efb15529d45e32fea8de03c38a968c157c8262chrismair * you may not use this file except in compliance with the License.
685efb15529d45e32fea8de03c38a968c157c8262chrismair * You may obtain a copy of the License at
785efb15529d45e32fea8de03c38a968c157c8262chrismair *
885efb15529d45e32fea8de03c38a968c157c8262chrismair *      http://www.apache.org/licenses/LICENSE-2.0
985efb15529d45e32fea8de03c38a968c157c8262chrismair *
1085efb15529d45e32fea8de03c38a968c157c8262chrismair * Unless required by applicable law or agreed to in writing, software
1185efb15529d45e32fea8de03c38a968c157c8262chrismair * distributed under the License is distributed on an "AS IS" BASIS,
1285efb15529d45e32fea8de03c38a968c157c8262chrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1385efb15529d45e32fea8de03c38a968c157c8262chrismair * See the License for the specific language governing permissions and
1485efb15529d45e32fea8de03c38a968c157c8262chrismair * limitations under the License.
1585efb15529d45e32fea8de03c38a968c157c8262chrismair */
1685efb15529d45e32fea8de03c38a968c157c8262chrismairpackage org.mockftpserver.stub.command;
1785efb15529d45e32fea8de03c38a968c157c8262chrismair
1885efb15529d45e32fea8de03c38a968c157c8262chrismairimport org.mockftpserver.core.command.Command;
1985efb15529d45e32fea8de03c38a968c157c8262chrismairimport org.mockftpserver.core.command.CommandHandler;
2085efb15529d45e32fea8de03c38a968c157c8262chrismairimport org.mockftpserver.core.command.InvocationRecord;
2185efb15529d45e32fea8de03c38a968c157c8262chrismairimport org.mockftpserver.core.command.ReplyCodes;
2285efb15529d45e32fea8de03c38a968c157c8262chrismairimport org.mockftpserver.core.session.Session;
2385efb15529d45e32fea8de03c38a968c157c8262chrismair
2485efb15529d45e32fea8de03c38a968c157c8262chrismair/**
2585efb15529d45e32fea8de03c38a968c157c8262chrismair * CommandHandler for the REST (Restart of interrupted transfer) command. Send back a reply code of 350.
2685efb15529d45e32fea8de03c38a968c157c8262chrismair * <p>
2785efb15529d45e32fea8de03c38a968c157c8262chrismair * Each invocation record stored by this CommandHandler includes the following data element key/values:
2885efb15529d45e32fea8de03c38a968c157c8262chrismair * <ul>
2985efb15529d45e32fea8de03c38a968c157c8262chrismair *    <li>{@link #MARKER_KEY} ("marker") - the server marker submitted on the invocation (the first command parameter)
3085efb15529d45e32fea8de03c38a968c157c8262chrismair * </ul>
3185efb15529d45e32fea8de03c38a968c157c8262chrismair *
3285efb15529d45e32fea8de03c38a968c157c8262chrismair * @version $Revision$ - $Date$
3385efb15529d45e32fea8de03c38a968c157c8262chrismair *
3485efb15529d45e32fea8de03c38a968c157c8262chrismair * @author Chris Mair
3585efb15529d45e32fea8de03c38a968c157c8262chrismair */
3685efb15529d45e32fea8de03c38a968c157c8262chrismairpublic final class RestCommandHandler extends AbstractStubCommandHandler implements CommandHandler {
3785efb15529d45e32fea8de03c38a968c157c8262chrismair
3885efb15529d45e32fea8de03c38a968c157c8262chrismair    public static final String MARKER_KEY = "marker";
3985efb15529d45e32fea8de03c38a968c157c8262chrismair
4085efb15529d45e32fea8de03c38a968c157c8262chrismair    /**
4185efb15529d45e32fea8de03c38a968c157c8262chrismair     * Constructor. Initialize the replyCode.
4285efb15529d45e32fea8de03c38a968c157c8262chrismair     */
4385efb15529d45e32fea8de03c38a968c157c8262chrismair    public RestCommandHandler() {
4485efb15529d45e32fea8de03c38a968c157c8262chrismair        setReplyCode(ReplyCodes.REST_OK);
4585efb15529d45e32fea8de03c38a968c157c8262chrismair    }
4685efb15529d45e32fea8de03c38a968c157c8262chrismair
4785efb15529d45e32fea8de03c38a968c157c8262chrismair    /**
4885efb15529d45e32fea8de03c38a968c157c8262chrismair     * @see org.mockftpserver.core.command.CommandHandler#handleCommand(Command, Session, InvocationRecord)
4985efb15529d45e32fea8de03c38a968c157c8262chrismair     */
5085efb15529d45e32fea8de03c38a968c157c8262chrismair    public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) {
5185efb15529d45e32fea8de03c38a968c157c8262chrismair        String marker = command.getRequiredString(0);
5285efb15529d45e32fea8de03c38a968c157c8262chrismair        invocationRecord.set(MARKER_KEY, marker);
5385efb15529d45e32fea8de03c38a968c157c8262chrismair        sendReply(session, marker);
5485efb15529d45e32fea8de03c38a968c157c8262chrismair    }
5585efb15529d45e32fea8de03c38a968c157c8262chrismair
5685efb15529d45e32fea8de03c38a968c157c8262chrismair}
57