| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AbstractStorCommandHandler |
|
| 1.0;1 |
| 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 | * 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: 194 $ - $Date: 2008-12-07 08:53:58 -0500 (Sun, 07 Dec 2008) $ | |
| 33 | */ | |
| 34 | 179 | public 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 | 7 | byte[] data = session.readData(); |
| 44 | 7 | LOG.info("Received " + data.length + " bytes"); |
| 45 | 7 | LOG.trace("Received data [" + new String(data) + "]"); |
| 46 | 7 | invocationRecord.set(FILE_CONTENTS_KEY, data); |
| 47 | 7 | } |
| 48 | ||
| 49 | } |