Package ome.formats.importer.transfers
Class AbstractExecFileTransfer
- java.lang.Object
-
- ome.formats.importer.transfers.AbstractFileTransfer
-
- ome.formats.importer.transfers.AbstractExecFileTransfer
-
- All Implemented Interfaces:
FileTransfer
- Direct Known Subclasses:
CopyFileTransfer,HardlinkFileTransfer,SymlinkFileTransfer
public abstract class AbstractExecFileTransfer extends AbstractFileTransfer
Abstract base class for file transfer implementations that link or copy files.- Since:
- 5.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ome.formats.importer.transfers.AbstractFileTransfer
AbstractFileTransfer.Transfers
-
-
Field Summary
-
Fields inherited from class ome.formats.importer.transfers.AbstractFileTransfer
log
-
-
Constructor Summary
Constructors Constructor Description AbstractExecFileTransfer()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcheckLocation(java.io.File location, RawFileStorePrx rawFileStore)Check that the target location: 1) doesn't exist and 2) is properly written to by the server.protected voidcheckTarget(java.io.File location, TransferState state)Check that the server can properly read the copied file.protected java.lang.ProcessBuildercreateProcessBuilder(java.io.File file, java.io.File location)Deprecated.overrideexec(File, File)insteadprotected voidexec(java.io.File file, java.io.File location)IfcreateProcessBuilder(java.io.File,java.io.File)returns non-null, executes a local command corresponding to the ProcessBuilder and fails on non-0 return codes.protected java.lang.RuntimeExceptionfailLocationCheck(java.io.File location, java.lang.String msg)protected java.io.FilegetLocalLocation(OriginalFile root, OriginalFile ofile)Build a path of the form "root.path/root.name/file.path/file.name".java.lang.Stringtransfer(TransferState state)Transfer files as specified by theexec(File, File)implementation.-
Methods inherited from class ome.formats.importer.transfers.AbstractFileTransfer
cleanupUpload, createTransfer, deleteTransferredFiles, finish, isWindows, printLine, start
-
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
-
-
-
-
Method Detail
-
transfer
public java.lang.String transfer(TransferState state) throws java.io.IOException, ServerError
Transfer files as specified by theexec(File, File)implementation.- Throws:
java.io.IOExceptionServerError
-
getLocalLocation
protected java.io.File getLocalLocation(OriginalFile root, OriginalFile ofile)
Build a path of the form "root.path/root.name/file.path/file.name".- Parameters:
root- the root directoryofile- a path relative to the root- Returns:
- the assembled path with separators suitable for the local filesystem
-
checkLocation
protected void checkLocation(java.io.File location, RawFileStorePrx rawFileStore) throws ServerError, java.io.IOExceptionCheck that the target location: 1) doesn't exist and 2) is properly written to by the server. If either condition fails, no linking takes place.- Parameters:
location- the source filerawFileStore- the target on the server- Throws:
ServerError- if the raw file store could not be usedjava.io.IOException- for problems with the source file
-
failLocationCheck
protected java.lang.RuntimeException failLocationCheck(java.io.File location, java.lang.String msg)
-
exec
protected void exec(java.io.File file, java.io.File location) throws java.io.IOExceptionIfcreateProcessBuilder(java.io.File,java.io.File)returns non-null, executes a local command corresponding to the ProcessBuilder and fails on non-0 return codes. If the ProcessBuilder is null, this method does nothing by default. This method should be overridden by subclasses, see for exampleCopyFileTransfer.- Parameters:
file- the source filelocation- the target on the server- Throws:
java.io.IOException- for problems with the source file
-
checkTarget
protected void checkTarget(java.io.File location, TransferState state) throws ServerErrorCheck that the server can properly read the copied file. LikecheckLocation(File, RawFileStorePrx)but after the invocation ofexec(File, File), there is some chance, likely due to file permissions, that the server will not be able to read the transfered file. If so, raise an exception and leave the user to cleanup and modifications.- Throws:
ServerError
-
createProcessBuilder
@Deprecated protected java.lang.ProcessBuilder createProcessBuilder(java.io.File file, java.io.File location)Deprecated.overrideexec(File, File)insteadCreates aProcessBuilderinstance ready to haveProcessBuilder.start()called on it. The only critical piece of information should be the return code.- Parameters:
file- File to be copied.location- Location to copy to.- Returns:
- an instance ready for performing the transfer
-
-