100dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair/*
200dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * Copyright 2007 the original author or authors.
300dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair *
400dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * Licensed under the Apache License, Version 2.0 (the "License");
500dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * you may not use this file except in compliance with the License.
600dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * You may obtain a copy of the License at
700dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair *
800dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair *      http://www.apache.org/licenses/LICENSE-2.0
900dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair *
1000dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * Unless required by applicable law or agreed to in writing, software
1100dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * distributed under the License is distributed on an "AS IS" BASIS,
1200dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1300dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * See the License for the specific language governing permissions and
1400dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * limitations under the License.
1500dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair */
1600dc7bdcf1df9e86789d963984dfc6912a8854c6chrismairpackage org.mockftpserver.stub.command;
1700dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair
1800dc7bdcf1df9e86789d963984dfc6912a8854c6chrismairimport org.mockftpserver.core.command.Command;
1900dc7bdcf1df9e86789d963984dfc6912a8854c6chrismairimport org.mockftpserver.core.command.InvocationRecord;
2000dc7bdcf1df9e86789d963984dfc6912a8854c6chrismairimport org.mockftpserver.core.session.Session;
2100dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair
2200dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair/**
2300dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * CommandHandler for the STOR (Store) command. Send back two replies on the control connection: a
2400dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * reply code of 150 and another of 226.
2500dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * <p/>
2600dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * Each invocation record stored by this CommandHandler includes the following data element key/values:
2700dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * <ul>
2800dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * <li>{@link #PATHNAME_KEY} ("pathname") - the pathname of the directory submitted on the invocation (the first command parameter)
2900dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * <li>{@link #FILE_CONTENTS_KEY} ("fileContents") - the file contents (<code>byte[]</code>) sent on the data connection
3000dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * </ul>
3100dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair *
3200dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * @author Chris Mair
3300dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * @version $Revision$ - $Date$
3400dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair */
3500dc7bdcf1df9e86789d963984dfc6912a8854c6chrismairpublic class StorCommandHandler extends AbstractStorCommandHandler {
3600dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair
3700dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair    /**
3800dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair     * @see org.mockftpserver.stub.command.AbstractStubDataCommandHandler#beforeProcessData(org.mockftpserver.core.command.Command, org.mockftpserver.core.session.Session, org.mockftpserver.core.command.InvocationRecord)
3900dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair     */
4000dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair    protected void beforeProcessData(Command command, Session session, InvocationRecord invocationRecord) throws Exception {
4100dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair        String filename = command.getRequiredParameter(0);
4200dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair        invocationRecord.set(PATHNAME_KEY, filename);
4300dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair    }
4400dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair
4500dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair}
46