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
Local-only file transfer mechanism which makes use of soft-linking. This is only useful where the command "ln -s source target" will work.- 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 Abstract Methods Concrete 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 abstract java.lang.ProcessBuildercreateProcessBuilder(java.io.File file, java.io.File location)Creates aProcessBuilderinstance ready to haveProcessBuilder.start()called on it.protected voidexec(java.io.File file, java.io.File location)Executes a local command 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".protected voidprintLine()java.lang.Stringtransfer(TransferState state)"Transfer" files by soft-linking them into place.-
Methods inherited from class ome.formats.importer.transfers.AbstractFileTransfer
cleanupUpload, createTransfer, deleteTransferredFiles, finish, isWindows, 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 by soft-linking them into place. This method is likely re-usable for other general "linking" strategies by overridingcreateProcessBuilder(File, File)and the other protected methods here.- 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.IOExceptionExecutes a local command and fails on non-0 return codes.- 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
protected abstract java.lang.ProcessBuilder createProcessBuilder(java.io.File file, java.io.File location)Creates 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
-
printLine
protected void printLine()
- Overrides:
printLinein classAbstractFileTransfer
-
-