1/* 2 * Copyright 2007 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 */ 16package org.mockftpserver.stub.command; 17 18import org.mockftpserver.core.command.Command; 19import org.mockftpserver.core.command.CommandHandler; 20import org.mockftpserver.core.command.InvocationRecord; 21import org.mockftpserver.core.command.ReplyCodes; 22import org.mockftpserver.core.session.Session; 23import org.mockftpserver.core.util.Assert; 24 25/** 26 * CommandHandler for the SYST (System) command. Send back a reply code of 215. By default, 27 * return "WINDOWS" as the system name. You can customize the returned name by 28 * setting the <code>systemName</code> property. 29 * <p/> 30 * See the available system names listed in the Assigned Numbers document 31 * (<a href="http://www.ietf.org/rfc/rfc943">RFC 943</a>). 32 * <p/> 33 * Each invocation record stored by this CommandHandler contains no data elements. 34 * 35 * @author Chris Mair 36 * @version $Revision$ - $Date$ 37 */ 38public class SystCommandHandler extends AbstractStubCommandHandler implements CommandHandler { 39 40 private String systemName = "WINDOWS"; 41 42 /** 43 * Constructor. Initialize the replyCode. 44 */ 45 public SystCommandHandler() { 46 setReplyCode(ReplyCodes.SYST_OK); 47 } 48 49 public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) { 50 sendReply(session, quotes(systemName)); 51 } 52 53 /** 54 * Set the systemName String to be returned by this command 55 * 56 * @param systemName - the systemName 57 */ 58 public void setSystemName(String systemName) { 59 Assert.notNull(systemName, "systemName"); 60 this.systemName = systemName; 61 } 62 63} 64