Package ome.formats.importer.transfers
Class AbstractFileTransfer
- java.lang.Object
-
- ome.formats.importer.transfers.AbstractFileTransfer
-
- All Implemented Interfaces:
FileTransfer
- Direct Known Subclasses:
AbstractExecFileTransfer
,UploadFileTransfer
public abstract class AbstractFileTransfer extends java.lang.Object implements FileTransfer
BaseFileTransfer
implementation primarily providing thestart(TransferState)
andfinish(TransferState, long)
methods. Also used as the factory forFileTransfer
implementations viacreateTransfer(String)
.- Since:
- 5.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractFileTransfer.Transfers
Enum of well-knownFileTransfer
names.
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
log
-
Constructor Summary
Constructors Constructor Description AbstractFileTransfer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
cleanupUpload(RawFileStorePrx rawFileStore, java.io.FileInputStream stream)
Utility method for closing resources.static FileTransfer
createTransfer(java.lang.String arg)
Factory method for instantiatingFileTransfer
objects from a string.protected void
deleteTransferredFiles(int errors, java.util.List<java.lang.String> srcFiles)
Method used by subclasses duringFileTransfer.afterTransfer(int, List)
if they would like to remove all the files transferred in the set.protected java.lang.String
finish(TransferState state, long offset)
Save the current state to disk and finish all timing and logging.protected boolean
isWindows()
Uses os.name to determine whether or not this JVM is running under Windows.protected void
printLine()
protected RawFileStorePrx
start(TransferState state)
Minimal start method which logs the file, callsTransferState.start()
, and loads theRawFileStorePrx
which any implementation will need.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ome.formats.importer.transfers.FileTransfer
afterTransfer, transfer
-
-
-
-
Method Detail
-
createTransfer
public static FileTransfer createTransfer(java.lang.String arg)
Factory method for instantiatingFileTransfer
objects from a string. Supported values can be found in theAbstractFileTransfer.Transfers
enum. Otherwise, a FQN for a class on the classpath should be passed in.- Parameters:
arg
- a type ofFileTransfer
instance as named amongAbstractFileTransfer.Transfers
- Returns:
- the new
FileTransfer
instance of the requested type
-
start
protected RawFileStorePrx start(TransferState state) throws ServerError
Minimal start method which logs the file, callsTransferState.start()
, and loads theRawFileStorePrx
which any implementation will need.- Parameters:
state
- the transfer state- Returns:
- a raw file store proxy for the upload
- Throws:
ServerError
- if the uploader could not be obtained
-
finish
protected java.lang.String finish(TransferState state, long offset) throws ServerError
Save the current state to disk and finish all timing and logging.- Parameters:
state
- non-nulloffset
- total length transferred.- Returns:
- client-side digest string.
- Throws:
ServerError
- if the upload could not be completed and checksummed
-
cleanupUpload
protected void cleanupUpload(RawFileStorePrx rawFileStore, java.io.FileInputStream stream) throws ServerError
Utility method for closing resources.- Parameters:
rawFileStore
- possibly nullstream
- possibly null- Throws:
ServerError
- presently not at all as errors are simply logged, but possibly in the future
-
isWindows
protected boolean isWindows()
Uses os.name to determine whether or not this JVM is running under Windows. This is mostly used for determining which executables to run.
-
printLine
protected void printLine()
-
deleteTransferredFiles
protected void deleteTransferredFiles(int errors, java.util.List<java.lang.String> srcFiles) throws CleanupFailure
Method used by subclasses duringFileTransfer.afterTransfer(int, List)
if they would like to remove all the files transferred in the set.- Throws:
CleanupFailure
-
-