biz.chitec.quarterback.gjsa.server
Class FileUploadExecutor
java.lang.Object
biz.chitec.quarterback.gjsa.server.CommandExecutor
biz.chitec.quarterback.gjsa.server.FileUploadExecutor
- public class FileUploadExecutor
- extends CommandExecutor
Executor which can be used as base for an upload scheme. It implements the
basic scheme of receiving the file to be uploaded part by part using the
FILEPART command. The transmission must be ended by sending the FILECOMPLETE
command after everything has been transmitted.
FileUploadExecutor should be added in its own server state. On successful
file transfer, it leaves the new state automatically after the FILECOMPLETE
command, or after the FILEABORT command has been sent.
This executor does not control the permission of the client to upload a file.
It gets the filename in the executor and starts immediately by opening it.
The constructor can be given two Runnables as callbacks for upload success or
failure.
- Version:
- $Id: 5b7c84a37920c3569be9546258719df34571b9a1 $
- Author:
- cantamen/Dirk Hillbrecht 2004. Distributed under the terms of the
GNU LGPL.
Nested Class Summary |
static interface |
FileUploadExecutor.ReturnValueRunnable
Special interface for successful callback
If the callback given to the executor's constructor implements this interface,
the executor will call the runWithReturnValue() method instead of the standard run()
and return the result in the command answer |
Constructor Summary |
FileUploadExecutor(ServerThreadBase thethreadbase,
java.io.File targetx,
java.lang.Runnable succrunx,
java.lang.Runnable failrunx)
Constructor for the FileUploadExecutor |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
targetfile
private java.io.File targetfile
targetstream
private java.io.OutputStream targetstream
successful
private boolean successful
succrun
private java.lang.Runnable succrun
failrun
private java.lang.Runnable failrun
FileUploadExecutor
public FileUploadExecutor(ServerThreadBase thethreadbase,
java.io.File targetx,
java.lang.Runnable succrunx,
java.lang.Runnable failrunx)
throws java.io.IOException
- Constructor for the FileUploadExecutor
- Parameters:
thethreadbase
- thread base object to be linked intargetx
- File to write transferred data in, will be overwrittensuccrunx
- Runnable to call if upload was successful, may be nullfailrunx
- Runnable to call if upload failed, may be null
query
public ServerReply query(ServerRequest sq)
- Main query method
- Overrides:
query
in class CommandExecutor
- Parameters:
sq
- The query to handle
- Returns:
- ServerReply of the executed command, null if command could not be handled
leavingActions
public void leavingActions()
- Closes the file, deletes it on any failure, runs callback Runnables.
- Overrides:
leavingActions
in class CommandExecutor