public abstract class FileCopierBase extends java.lang.Object
Whether the copy operation would by default overwrite existing files depends on the actual protocol used for file copy. Optional command line options may be used to override the default behavior in some cases depending on the protocol used. Refer to the documentation of specific sub class for details.
When both source and destination machines are local hosts, the protocol specified is ignored and file copy is done using Java.
When both source and destination are the same machine a simple cp command is used instead of any specific protocol
Modifier and Type | Class and Description |
---|---|
class |
FileCopierBase.CopyResult
Object that contains the exit code and (error) message associated with the
copy operation.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
cmdLineOptions |
protected boolean |
forcedCleanup |
protected java.lang.String |
protocolPathDest |
protected java.lang.String |
protocolPathSrc |
protected int |
timeout |
Constructor and Description |
---|
FileCopierBase() |
Modifier and Type | Method and Description |
---|---|
protected FileCopierBase.CopyResult |
copy(ConnectionDetails srcDetails,
java.lang.String srcFile,
ConnectionDetails destDetails,
java.lang.String destFile,
boolean recursive)
Generic copy method that does the initial input validation and calls the
copyTo, copyFrom or copyRemote of the appropriate FileCopier subclass.
|
protected abstract FileCopierBase.CopyResult |
copyFrom(ConnectionDetails srcDetails,
java.lang.String srcFile,
java.lang.String destFile,
boolean recursive)
Copies file from a remote host to local machine
|
protected FileCopierBase.CopyResult |
copyLocal(java.lang.String sourceFile,
java.lang.String destinationFile,
boolean recursive)
Copies files to destination path on the same machine.
|
protected FileCopierBase.CopyResult |
copyLocalOnRemoteMachine(ConnectionDetails srcDetails,
java.lang.String srcFile,
ConnectionDetails destDetails,
java.lang.String destFile,
boolean recursive)
Connects to the remote machines and execute a 'cp' command to copy files
to destination dir on the same remote machine
|
protected abstract FileCopierBase.CopyResult |
copyRemote(ConnectionDetails srcDetails,
java.lang.String srcFile,
ConnectionDetails destDetails,
java.lang.String destFile,
boolean recursive)
Copies files between two remote machines.
|
protected abstract FileCopierBase.CopyResult |
copyTo(java.lang.String srcFile,
ConnectionDetails destDetails,
java.lang.String destFile,
boolean recursive)
Copies files from local machine to a remote host
|
java.lang.String |
getCmdLineOptions() |
protected java.lang.String |
getCmdWithDefaultPath(java.lang.StringBuffer cmd)
This is used to set the users PATH variable, if the user has not specified
the path where the protocol is installed.
|
protected abstract int |
getDefaultPort()
default port for the file transfer protocol.
|
java.lang.String |
getProtocolPathDest() |
java.lang.String |
getProtocolPathSrc() |
int |
getTimeout() |
boolean |
isForcedCleanup() |
void |
setCleanup(boolean cleanup) |
void |
setCmdLineOptions(java.lang.String cmdLineOptions) |
void |
setProtocolPathDest(java.lang.String protocolPathDest) |
void |
setProtocolPathSrc(java.lang.String protocolPathSrc) |
void |
setTimeout(int timeout) |
protected boolean forcedCleanup
protected int timeout
protected java.lang.String cmdLineOptions
protected java.lang.String protocolPathSrc
protected java.lang.String protocolPathDest
public FileCopierBase()
protected FileCopierBase.CopyResult copyLocal(java.lang.String sourceFile, java.lang.String destinationFile, boolean recursive)
srcFile
- - source file to be copieddestFile
- - local path into which source should be copiedrecursive
- - flag to indicate if directories should be copied recursivelyprotected FileCopierBase.CopyResult copyLocalOnRemoteMachine(ConnectionDetails srcDetails, java.lang.String srcFile, ConnectionDetails destDetails, java.lang.String destFile, boolean recursive) throws ExecException
srcFile
- - source file to be copieddestFile
- - local path into which source should be copiedrecursive
- - flag to indicate if directories should be copied recursivelyExecException
protected abstract FileCopierBase.CopyResult copyFrom(ConnectionDetails srcDetails, java.lang.String srcFile, java.lang.String destFile, boolean recursive) throws ExecException
srcDetails
- - object containing the source machine connection detailssrcFile
- - source file to be copieddestFile
- - local path into which source should be copiedrecursive
- - flag to indicate if directories should be copied recursivelyExecException
protected abstract FileCopierBase.CopyResult copyTo(java.lang.String srcFile, ConnectionDetails destDetails, java.lang.String destFile, boolean recursive) throws ExecException
srcFile
- - local source file to be copieddestDetails
- - object containing the destination machine connection detailsdestFile
- - path into which source should be copiedrecursive
- - flag to indicate if directories should be copied recursivelyExecException
protected abstract FileCopierBase.CopyResult copyRemote(ConnectionDetails srcDetails, java.lang.String srcFile, ConnectionDetails destDetails, java.lang.String destFile, boolean recursive) throws ExecException
srcDetails
- - object containing the source machine connection detailssrcFile
- - source file to be copieddestDetails
- - object containing the destination machine connection detailsdestFile
- - path into which source should be copiedrecursive
- - flag to indicate if directory should be copied recursivelyExecException
protected FileCopierBase.CopyResult copy(ConnectionDetails srcDetails, java.lang.String srcFile, ConnectionDetails destDetails, java.lang.String destFile, boolean recursive) throws IllegalActionException, ExecException
srcDetails
- - ConnectionDetails object with source machine detailssrcFile
- - File to be copieddestDetails
- - ConnectionDetails object with destination machine detailsdestFile
- - Destination file or directoryrecursive
- - whether directory should be copied recursivelyIllegalActionException
ExecException
protected java.lang.String getCmdWithDefaultPath(java.lang.StringBuffer cmd)
cmd
- - command to execute for file copyprotected abstract int getDefaultPort()
public boolean isForcedCleanup()
public void setCleanup(boolean cleanup)
public int getTimeout()
public void setTimeout(int timeout)
public java.lang.String getCmdLineOptions()
public void setCmdLineOptions(java.lang.String cmdLineOptions)
public java.lang.String getProtocolPathSrc()
public void setProtocolPathSrc(java.lang.String protocolPathSrc)
public java.lang.String getProtocolPathDest()
public void setProtocolPathDest(java.lang.String protocolPathDest)