brahms.io
Class CopyFileActivity
java.lang.Object
gov.nasa.arc.brahms.vm.api.jac.AbstractExternalActivity
brahms.io.CopyFileActivity
- All Implemented Interfaces:
- IExternalActivity
public class CopyFileActivity
- extends AbstractExternalActivity
The CopyFileActivity allows a modeler to copy a file.
The file to be copied must be an absolute path to the file. The
destination file must also be an absolute path. The activity will
verify that the destination directory exists, if it does not exist
then by default the copy operation will fail unless the createDirs
flag is set to true in which case the activity will attempts to
create the destination directory and only report an error if the
directory creation fails. The modeler has the option of overwriting
the destination file if it exists, by default if the destination file
already exists the copy will fail and an error will be generated.
The modeler can choose to have the copy verified by setting the
verifyCopy flag to true (default is false), either by providing a
CRC-32 checksum value or if this value is not specified the activity
will generate the CRC-32 checksum value for the source file and
generate a CRC-32 checksum for the file in its destination
directory and compare the checksum values. If the checksum of the
copied file is not equal to the provided checksum or generated
checksum of the source file an error will be generated.
This activity requires three parameters and supports up to eight parameters
in the Brahms java activity declaration:
- string srcFile (the absolute path of the file to be copied)
- string destFile (the absolute path of the destination file)
- boolean createDirs (optional, true to create the destination directory
if it does not exist, false to generate an error if the destination
directory does not exist - default: false)
- boolean overwrite (optional, true to overwrite the destination file if it
exists already, false to generate an errror if the destination file
already exists - default: false)
- boolean verifyCopy (optional, true to verify the copy operation, false
not to verify the copy operation - default: false)
- long crc32Checksum (optional, the CRC-32 checksum to compare the
checksum of the copied file with if verifyCopy is true, if not
provided or if -1 and verifyCopy is true a CRC-32 checksum is first generated
for the source file)
- boolean success (return value indicating whether the copy succeeded)
- string errorMessage (optional, return value specifying the reason for the failure,
possible values:
FileNotFound - if the source file could not be found
NoSuchDirectory - if the destination directory does not exist or if it is a file and not a directory,
CreateDirectoryFailed - if the destination directory could not be created,
FileExists - if the destination file already exists and overwrite is set to false
SourceChecksumFailed - if the checksum for the source file could not be created,
DestinationChecksumFailed - if the checksum for the destination file could not be created,
VerificationFailed - if the checksum comparison failed,
CopyFailure - if there was a problem copying the file,
UnexpectedFailure - if there was an unexpected failure)
- Version:
- $Revision: 1.3 $ $Date: 2008/06/30 23:02:30 $ $Author: rvhoof $
- Author:
- Ron van Hoof
|
Method Summary |
static long |
copyFile(java.io.File srcFile,
java.io.File destFile,
boolean createChecksum)
Copies the specified source file to the specified destination file. |
void |
doActivity()
Executes the java activity action. |
| Methods inherited from class gov.nasa.arc.brahms.vm.api.jac.AbstractExternalActivity |
assertBelief, assertFact, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, conclude, getContext, getModel, getName, getParameter, getParameterCount, getPerformedBy, getVMController, getWorldState, isValidTruthValue, retractBelief, retractFact, send, send, send, send, setActivity, setProperties, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
CopyFileActivity
public CopyFileActivity()
copyFile
public static long copyFile(java.io.File srcFile,
java.io.File destFile,
boolean createChecksum)
throws java.io.IOException
- Copies the specified source file to the specified destination file.
If createChecksum is true a CRC-32 checksum is generated for the
source file and returned, if createChecksum is false -1 is returned.
- Parameters:
srcFile - the file to be copieddestFile - the file copycreateChecksum - true to have a checksum of the source file generated,
false not to create the checksum
- Returns:
- long the checksum of createChecksum is true, -1 if createChecksum is false
- Throws:
java.io.IOException - if there is a problem copying the file
doActivity
public void doActivity()
throws ExternalException
- Executes the java activity action.
- Specified by:
doActivity in interface IExternalActivity- Specified by:
doActivity in class AbstractExternalActivity
- Throws:
ExternalException - if an unrecoverable error occurs.- See Also:
AbstractExternalActivity.doActivity()
Copyright © 1997-2008 NASA. All Rights Reserved.