blob: 420151661ace919a6cb03ab355f039d1dacccbe0 [file] [log] [blame]
chrismair00dc7bd2014-05-11 21:21:28 +00001/*
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.InvocationRecord;
20import org.mockftpserver.core.session.Session;
21
22/**
23 * Abstract superclass for CommandHandler for commands that store a file. Send back two replies on the
24 * control connection: a 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 #FILE_CONTENTS_KEY} ("fileContents") - the file contents (<code>byte[]</code>) sent on the data connection
29 * </ul>
30 *
31 * @author Chris Mair
32 * @version $Revision$ - $Date$
33 */
34public abstract class AbstractStorCommandHandler extends AbstractStubDataCommandHandler {
35
36 public static final String PATHNAME_KEY = "pathname";
37 public static final String FILE_CONTENTS_KEY = "filecontents";
38
39 /**
40 * @see AbstractStubDataCommandHandler#processData(org.mockftpserver.core.command.Command, org.mockftpserver.core.session.Session, org.mockftpserver.core.command.InvocationRecord)
41 */
42 protected void processData(Command command, Session session, InvocationRecord invocationRecord) {
43 byte[] data = session.readData();
44 LOG.info("Received " + data.length + " bytes");
45 LOG.trace("Received data [" + new String(data) + "]");
46 invocationRecord.set(FILE_CONTENTS_KEY, data);
47 }
48
49}