14531116f8e675a208710e987bfe3b58faeb12db2chrismair/* 24531116f8e675a208710e987bfe3b58faeb12db2chrismair * Copyright 2007 the original author or authors. 34531116f8e675a208710e987bfe3b58faeb12db2chrismair * 44531116f8e675a208710e987bfe3b58faeb12db2chrismair * Licensed under the Apache License, Version 2.0 (the "License"); 54531116f8e675a208710e987bfe3b58faeb12db2chrismair * you may not use this file except in compliance with the License. 64531116f8e675a208710e987bfe3b58faeb12db2chrismair * You may obtain a copy of the License at 74531116f8e675a208710e987bfe3b58faeb12db2chrismair * 84531116f8e675a208710e987bfe3b58faeb12db2chrismair * http://www.apache.org/licenses/LICENSE-2.0 94531116f8e675a208710e987bfe3b58faeb12db2chrismair * 104531116f8e675a208710e987bfe3b58faeb12db2chrismair * Unless required by applicable law or agreed to in writing, software 114531116f8e675a208710e987bfe3b58faeb12db2chrismair * distributed under the License is distributed on an "AS IS" BASIS, 124531116f8e675a208710e987bfe3b58faeb12db2chrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134531116f8e675a208710e987bfe3b58faeb12db2chrismair * See the License for the specific language governing permissions and 144531116f8e675a208710e987bfe3b58faeb12db2chrismair * limitations under the License. 154531116f8e675a208710e987bfe3b58faeb12db2chrismair */ 164531116f8e675a208710e987bfe3b58faeb12db2chrismairpackage org.mockftpserver.stub.command; 174531116f8e675a208710e987bfe3b58faeb12db2chrismair 184531116f8e675a208710e987bfe3b58faeb12db2chrismairimport org.mockftpserver.core.command.Command; 194531116f8e675a208710e987bfe3b58faeb12db2chrismairimport org.mockftpserver.core.command.CommandHandler; 204531116f8e675a208710e987bfe3b58faeb12db2chrismairimport org.mockftpserver.core.command.InvocationRecord; 214531116f8e675a208710e987bfe3b58faeb12db2chrismairimport org.mockftpserver.core.command.ReplyCodes; 224531116f8e675a208710e987bfe3b58faeb12db2chrismairimport org.mockftpserver.core.session.Session; 234531116f8e675a208710e987bfe3b58faeb12db2chrismair 244531116f8e675a208710e987bfe3b58faeb12db2chrismair/** 254531116f8e675a208710e987bfe3b58faeb12db2chrismair * CommandHandler for the MKD (Make Directory) command. Send back a reply code of 257. 264531116f8e675a208710e987bfe3b58faeb12db2chrismair * <p> 274531116f8e675a208710e987bfe3b58faeb12db2chrismair * Each invocation record stored by this CommandHandler includes the following data element key/values: 284531116f8e675a208710e987bfe3b58faeb12db2chrismair * <ul> 294531116f8e675a208710e987bfe3b58faeb12db2chrismair * <li>{@link #PATHNAME_KEY} ("pathname") - the pathname of the directory submitted on the invocation (the first command parameter) 304531116f8e675a208710e987bfe3b58faeb12db2chrismair * </ul> 314531116f8e675a208710e987bfe3b58faeb12db2chrismair * 324531116f8e675a208710e987bfe3b58faeb12db2chrismair * @version $Revision$ - $Date$ 334531116f8e675a208710e987bfe3b58faeb12db2chrismair * 344531116f8e675a208710e987bfe3b58faeb12db2chrismair * @author Chris Mair 354531116f8e675a208710e987bfe3b58faeb12db2chrismair */ 364531116f8e675a208710e987bfe3b58faeb12db2chrismairpublic final class MkdCommandHandler extends AbstractStubCommandHandler implements CommandHandler { 374531116f8e675a208710e987bfe3b58faeb12db2chrismair 384531116f8e675a208710e987bfe3b58faeb12db2chrismair public static final String PATHNAME_KEY = "pathname"; 394531116f8e675a208710e987bfe3b58faeb12db2chrismair 404531116f8e675a208710e987bfe3b58faeb12db2chrismair /** 414531116f8e675a208710e987bfe3b58faeb12db2chrismair * Constructor. Initialize the replyCode. 424531116f8e675a208710e987bfe3b58faeb12db2chrismair */ 434531116f8e675a208710e987bfe3b58faeb12db2chrismair public MkdCommandHandler() { 444531116f8e675a208710e987bfe3b58faeb12db2chrismair setReplyCode(ReplyCodes.MKD_OK); 454531116f8e675a208710e987bfe3b58faeb12db2chrismair } 464531116f8e675a208710e987bfe3b58faeb12db2chrismair 474531116f8e675a208710e987bfe3b58faeb12db2chrismair /** 484531116f8e675a208710e987bfe3b58faeb12db2chrismair * @see org.mockftpserver.core.command.CommandHandler#handleCommand(Command, Session, InvocationRecord) 494531116f8e675a208710e987bfe3b58faeb12db2chrismair */ 504531116f8e675a208710e987bfe3b58faeb12db2chrismair public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) { 514531116f8e675a208710e987bfe3b58faeb12db2chrismair String pathname = command.getRequiredString(0); 524531116f8e675a208710e987bfe3b58faeb12db2chrismair invocationRecord.set(PATHNAME_KEY, pathname); 534531116f8e675a208710e987bfe3b58faeb12db2chrismair sendReply(session, pathname); 544531116f8e675a208710e987bfe3b58faeb12db2chrismair } 554531116f8e675a208710e987bfe3b58faeb12db2chrismair 564531116f8e675a208710e987bfe3b58faeb12db2chrismair} 57