chrismair | 00dc7bd | 2014-05-11 21:21:28 +0000 | [diff] [blame] | 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 | */
|
| 16 | package org.mockftpserver.stub.command;
|
| 17 |
|
| 18 | import org.mockftpserver.core.command.Command;
|
| 19 | import org.mockftpserver.core.command.InvocationRecord;
|
| 20 | import org.mockftpserver.core.session.Session;
|
| 21 |
|
| 22 | /**
|
| 23 | * CommandHandler for the STOR (Store) command. Send back two replies on the control connection: a
|
| 24 | * reply code of 150 and another of 226.
|
| 25 | * <p/>
|
| 26 | * Each invocation record stored by this CommandHandler includes the following data element key/values:
|
| 27 | * <ul>
|
| 28 | * <li>{@link #PATHNAME_KEY} ("pathname") - the pathname of the directory submitted on the invocation (the first command parameter)
|
| 29 | * <li>{@link #FILE_CONTENTS_KEY} ("fileContents") - the file contents (<code>byte[]</code>) sent on the data connection
|
| 30 | * </ul>
|
| 31 | *
|
| 32 | * @author Chris Mair
|
| 33 | * @version $Revision$ - $Date$
|
| 34 | */
|
| 35 | public class StorCommandHandler extends AbstractStorCommandHandler {
|
| 36 |
|
| 37 | /**
|
| 38 | * @see org.mockftpserver.stub.command.AbstractStubDataCommandHandler#beforeProcessData(org.mockftpserver.core.command.Command, org.mockftpserver.core.session.Session, org.mockftpserver.core.command.InvocationRecord)
|
| 39 | */
|
| 40 | protected void beforeProcessData(Command command, Session session, InvocationRecord invocationRecord) throws Exception {
|
| 41 | String filename = command.getRequiredParameter(0);
|
| 42 | invocationRecord.set(PATHNAME_KEY, filename);
|
| 43 | }
|
| 44 |
|
| 45 | }
|