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
BaseFileTransferimplementation primarily providing thestart(TransferState)andfinish(TransferState, long)methods. Also used as the factory forFileTransferimplementations viacreateTransfer(String).- Since:
- 5.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractFileTransfer.TransfersEnum of well-knownFileTransfernames.
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Loggerlog
-
Constructor Summary
Constructors Constructor Description AbstractFileTransfer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcleanupUpload(RawFileStorePrx rawFileStore, java.io.FileInputStream stream)Utility method for closing resources.static FileTransfercreateTransfer(java.lang.String arg)Factory method for instantiatingFileTransferobjects from a string.protected voiddeleteTransferredFiles(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.Stringfinish(TransferState state, long offset)Save the current state to disk and finish all timing and logging.protected booleanisWindows()Uses os.name to determine whether or not this JVM is running under Windows.protected voidprintLine()protected RawFileStorePrxstart(TransferState state)Minimal start method which logs the file, callsTransferState.start(), and loads theRawFileStorePrxwhich 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 instantiatingFileTransferobjects from a string. Supported values can be found in theAbstractFileTransfer.Transfersenum. Otherwise, a FQN for a class on the classpath should be passed in.- Parameters:
arg- a type ofFileTransferinstance as named amongAbstractFileTransfer.Transfers- Returns:
- the new
FileTransferinstance of the requested type
-
start
protected RawFileStorePrx start(TransferState state) throws ServerError
Minimal start method which logs the file, callsTransferState.start(), and loads theRawFileStorePrxwhich 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 CleanupFailureMethod used by subclasses duringFileTransfer.afterTransfer(int, List)if they would like to remove all the files transferred in the set.- Throws:
CleanupFailure
-
-