We focus here on the several tasks that are possible to run before a transfer starts (pre action), after a transfer is finished correctly (post action) or after an error occurs (either in pre or post action or during transfer: error action).
Those actions are defined in one rule. Each rule contains 2 parts:
Each action could be on pre, post or error step, each step can have several actions.
It is defined with a unified form of XML:
For instance, a Path in rule defined as
It will give:
Additionnaly, a task will use also the argument from the transfer itself (Transfer Information). It uses the
For instance :
This task logs or writes to an external file some info:
If first word of the log is one of , , or , this word will be used as the log level
Example:
This will log a "Warn" log as "warn information" to the file /path/logfile. If delay is 0, nothing is done. If delay is 1, only normal log (warning log) is made. If delay is 3, then both logs from 1 and 2 are made.
This task sends a SNMP trap or info according to snmp configuration with the info field:
If first word of the log is one of , , or , this word will be used as the log level
Example:
This will send a snmp trap/info as "information" plus TransferID. If the delay was 1, the same is sent with full Transfer information.
Copy the file to the path designed by Path argument without renaming the filename (same basename). The path obtained must be an absolute path (not a relative path).
Example:
This will copy the current file to /newpath/ as /newpath/currentfilename. The current file stays the previous one (not changed).
Copy the file to the path designed by Path and Transfer Information arguments.
Example:
Taking into consideration file transfer information to be "myinfoFromTransfer", this will copy the file as new file /newpath/newfilename_myinfoFromTransfer_transferid where transferid will be replaced by the unique id (as 123456789).
Move the file to the path designed by Path and Transfer Information arguments without renaming the filename (same basename).
Example:
This will move the file (not copying it) to the new directory /newpath/. The current file is now the moved file.
Move the file to the path designed by Path and Transfer Information arguments.
Example:
This will move the file (not copying it) to the new directory /newpath/ with the new name as /newpath/newfilename. The current file is now the moved file.
Create a link of the current file and make the file pointing to it.
Example:
This will try to link the file (if not possible, it performs a copy) to the new directory /newpath/ with name filenamelink.
This task rename the current file without really touching the real file, which means that the target is changed, while no other action is taken:
Example:
This will move the current file to the new path specified, but it does not touch the previous current file. This command allows to change dynamically the file to send/recv or on post operation, without touching the real file.
This task deletes the current file.
Example:
This command will simply delete the current file. Therefore no more file will be currently hold by the transfer task from this point. Note: if the file cannot be deleted, only a warning will be thrown.
Test if the current file is under one of the paths based on the Path and Transfer Information arguments.
Example:
This will check if the current file is under one of the directories specified, here /path1 or /path2. And it will log out the result of this check.
Test if the current file contains no virus against an ICAP server.
Example:
This will check the current file against the specified ICAP server. If there is an issue (virus), the file will be deleted. If the remote ICAP server is not reachable, the network error will be ignored and the file considered as safe however.
Get a remote S3 file that can be used as new current file based on the Path and Transfer Information arguments.
Example:
This will get the remote designated file using S3 service and store it within /destPath.
Get a remote S3 file that can be used as new current file based on the Path and Transfer Information arguments and delete remote file.
Example:
This will get the remote designated file using S3 service and store it within /destPath, then delete the remote S3 object file.
Delete a remote S3 file based on the Path and Transfer Information arguments.
Example:
This will delete the remote designated file using S3 service.
Put the current file as a remote S3 file, based on the Path and Transfer Information arguments.
Example:
This will put the current file as a new remote file using S3 service.
Put the current file as a remote S3 file, and delete the current file, based on the Path and Transfer Information arguments.
Example:
This will put the current file as a new remote file using S3 service, then deleting the current file.
This task checks some properties relative to the File according to the following argument:
SIZE LT/GT/LTE/GTE/EQ number: to check the file size according to a limit (less than, greater than, less than or equal, greater than or equal, equal)
DFCHECK: to check if the future received file size is compatible with the space left on both working and received directories (from general configuration or rule configuration)
For instance
SIZE LT 10000000 SIZE GT 1000 DFCHECKwill test that the current file size is less than 10 MB (base 10), and greater than 1000 bytes, and that the working and received directories have enough space to receive the file.
Example:
Allow to transcode a file from a Charset to another one.
After Path is transformed according to above dynamic replacements, it is then used as a String Format where Transfer Information is used as input (String.format(Path,Info)).
-from fromCharset
-to toCharset
-newfile filename
optional argument ; if not used, will be current filename.extension ; if used, extension is ignored-extension extension
optional argument ; if not used, will be filename.transcode-dos2unix
or -unix2dos
optional argument, but if present, "-from" and "-to" might me omitted ; it allows to add a dos2unix/unix2dos action at the end of the transcode. Note that this operation can be made even without "-from" or "-to" option setup, which means that only dos2unix or unix2dos will be done.fromCharset and toCharset are string representations of the official charsets in Java.
A convenient method (from Waarp Common) allows to list in html (-html), csv (-csv) or text format (-text) all the supported Charsets from your JVM. To use it, run the following command:
Example:
This will encode the current file using fromCharset as source charset code and using toCharset as target charset code, and the result will be placed into the file /path/file.
With R66, it is possible to transcode one file from one charset to another charset using the TRANSCODE task. This one takes 2 arguments: -from fromCharset and -to toCharset where fromCharset and toCharset are string representations of the official charsets in Java. Optional arguments -newfile newfilename and -extension extension could be added. If -newfile is specified, the target filename will be the one specified. If it is not specified, the target filename will be the source filename with as extension either the one specified, or if not specified, the extension “.transcode”.
For EBCDIC charsets, see:
In particular (but not limited to), one could consider the following charsets (from or to):
A convenient method (from Waarp Common) allows to list in html (-html), csv (-csv) or text format (-text) all the supported Charsets from your JVM. To use it, run the following command:
Create a TAR from the argument as source and destination or UNTAR files from a TAR file.
UNTAR PATH="sourceFile targetDirectory"
TAR PATH="targetFile sourceDirectory"
TAR PATH="targetFile sourceFile1 sourceFile2..."
Example:
This will launch a "tar/untar" command of tar file /path/sourcetarfile into directory /path/targetdirectory.
Create a ZIP from the argument as source and destination or UNZIP files from a ZIP file.
UNZIP PATH="sourceFile targetDirectory"
ZIP PATH="targetFile sourceDirectory"
ZIP PATH="targetFile sourceFile1 sourceFile2..."
Example:
This will launch a "zip/unzip" command of zip file /path/sourcetarfile into directory /path/targetdirectory.
Compress/Decompress the current file from the argument as source and destination will be as same filename with suffix ".zstd" / ".unzstd" accordingly.
COMPRESS using ZTSD algorithm from sourceFile to sourceFile.zstd
DECOMPRESS using ZTSD algorithm from sourceFile to sourceFile.unzstd
Example:
This will launch a "uncompress" command of ZSTD file /path/sourcezstdFile to /path/sourcezstdFile.unzstd .
This task add 1 byte to empty file if the current file is empty (0 length).
The task will be in error only if the file is of length 0 but cannot be unzeroed. If the path is filled (not empty), the content will be used as filler for the empty file. If empty, the 'blanck' character will be used instead.
delay >= 1 will make a log using info level for 1, warn level for 2.
Example:
This will run unzeroed task on current file, and print a LOG.INFO in case of no error, else LOG.ERROR.
This task allows to change the mode of the file (as in Unix CHMOD command) according to the following argument:
[ua][+-=][rwx]
where multiple elements could be specified, separated by blank characteru/a
meaning user(Waarp system user)/all (group and other do not exist in Java),+/-/=
meaning add/remove/set (set means all other values are removed),r/w/x
meaning Read/Write/Executeu=rwx a=r
ua+rw
u=rw a-wx
a+rw
Current access mode for the application will be applied as default "user" access mode, and no access mode (-rwx)
will be the default for "all" access mode.
If several access mode are set in sequence, the result will be the sum of the results, step by step.
a=r a+w a-r
will result in a=w
(first step is r--
, second step is rw-
, third step is -w-
)
Example:
Execute an external command given by Path and Transfer Information arguments.
The external command is supposed to behave as the following for its exiting value:
Example:
Taking into account that File transfer information could be "transferInformation", this will execute the command /path/command with the following arguments: "arguments transferId /path/currentFilename transferInformation".
Execute an external command given by Path and Transfer Information arguments.
The external command is supposed to behave as the following for its exiting value:
Example:
Taking into account that File transfer information could be "transferInformation", this will execute the command /path/command with the following arguments: "arguments transferId /path/currentFilename transferInformation". The last line returned by the execution will be the new file path (absolute) of the current file. Therefore the current file is changed to this new file path.
Execute an external command given by Path and Transfer Information arguments.
The external command is supposed to behave as the following for its exiting value:
Example:
Taking into account that File transfer information could be "transferInformation", this will execute the command /path/command with the following arguments: "arguments transferId /path/currentFilename transferInformation". If the execution is in error, the output will be bring back to the remote host through "#ERRORMSG# and "#ERRORCODE#". Moreover, in case of error, if the last line contains the prefix NEWFILENAME:, then the current file is move (logically) to this new one.
Execute an external Java class given by Path and Transfer Information arguments.
R66Runnable
or being an extend of AbstractExecJavaTask
, ignoring the extra validate/finalValidate/invalid
methods used only in Business tasks) is obtained from Path transformed according to above dynamic replacements, and after a String Format where Transfer Information is used as input (String.format(Path,Info)
). The first argument is this full classname. The allocation must be of the form new MyClass()
, so an empty constructor.Example:
This will execute the class named java.class.name with the following arguments: "arguments transferId /path/currentFilename".
Additional element: Usage of ExecJava class
In order to facilitate the integration in application modules, OpenR66 supports the ability to run specific Java Class through 3 ways. Note that this functionality is only valid starting in version 2.3.
R66Runnable
interface.AbstractExecJavaTask
abstract class that could be extended.R66BusinessInterface
) through a Business Factory (see R66BusinessFactoryInterface
) to each transfer that will run several methods in the various steps that could occur:
void checkAtStartup(R66Session session)
: launched at the very startup of the transfer and before the pre commandsvoid checkAfterPreCommand(R66Session session)
: launched after the pre commands and before the transfer startsvoid checkAfterTransfer(R66Session session)
: launched after the transfer is finished and before the post commandsvoid checkAfterPost(R66Session session)
: launched after the post commands and before the end of the requestvoid checkAtError(R66Session session)
: launched once an error occursvoid checkAtChangeFilename(R66Session session)
: launched if the filename is changed during the commands (pre or post)void releaseResources()
: launched at the very end, to release any internal resources that should be releasedString getInfo()
and void setInfo(String info)
: launched by programmatic (business code) to enable to set a special info (as String) and to retrieve it at any time.R66BusinessFactory
could be set through XML configuration file in This task allows to restart the Waarp R66 server. There is no special argument.
Example:
For instance, this could be used after upgrade of Waarp R66 server binaries through a rule to upload followed by untar, then restart.
Submit a new transfer based on the Path and Transfer Information arguments.
-file filepath -to requestedHost -rule rule [-md5] [-start yyyyMMddHHmmss or -delay (delay or +delay)] [-copyinfo] [-info transferInformation]
where each field is separated by blank character. Last field (transferInformation) may contain however blank character.Example:
This will create a new transfer request, using the current file (#TRUEFULLPATH#
), to send (or receive, depending on the rule way ruletouse) to (from) the remote host, using "transfer Information" as argument to the transfer.
Reschedule Transfer task to a time delayed by the specified number of milliseconds, if the error code is one of the specified codes and the optional intervals of date are compatible with the new time schedule.
Result of arguments will be as following options (the two first are mandatory):
"-delay ms"
where ms is the added number of ms on current time before retry on schedule"-case errorCode,errorCode,..."
where errorCode is one of the following error of the current transfer (either literal or code in 1 character):
ConnectionImpossible(C), ServerOverloaded(l), BadAuthent(A), ExternalOp(E), TransferError(T),
MD5Error(M), Disconnection(D), RemoteShutdown(r), FinalOp(F), Unimplemented(U), Shutdown(S),
RemoteError(R), Internal(I), StoppedTransfer(H), CanceledTransfer(K), Warning(W), Unknown(-),
QueryAlreadyFinished(Q), QueryStillRunning(s), NotKnownHost(N), QueryRemotelyUnknown(u),
FileNotFound(f), CommandNotFound(c), PassThroughMode(p)
"-between start;end"
and/or "-notbetween start;end"
(multiple times are allowed, start or end can be not set) and where start and stop are in the following format:
Yn:Mn:Dn:Hn:mn:Sn
where n is a number for each time specification, each specification is optional, as Y=Year, M=Month, D=Day, H=Hour, m=minute, s=second
.
X+n, X-n, X=n
or Xn
where X+-n
means adding/subtracting n to current date value, while X=n
or Xn
means setting exact value"-notbetween"
is specified, the planned date must not be in the area."-between"
is specified, the planned date must be found in any such specified areas (could be in any of the occurrence). If not specified, it only depends on "-notbetween"
."-count limit"
will be the limit of retry. The value limit is taken from the internal "information on transfer" and not from the rule.Each time this function is called, the limit value will be replaced as newlimit = limit - 1 in the "info of transfer".
To ensure correctness, the value must be in the "info of transfer" since this value will be changed statically in the "info of transfer". However, a value must be setup in the rule in order to reset the value when the count reach 0.
So in the rule, "-count resetlimit"
must be present, where resetlimit will be the new value set when the limit reach 0. If it is missing, the condition is not applied.
Note that if a previous called to a reschedule was done for this attempt and was successful, the following calls will be ignored.
Important note: any subsequent task will be ignored and not executed once the reschedule is accepted. On the contrary, if the reschedule is not accepted, the following tasks will be executed normally.
In case start is greater than end, end will be +1 day
In case start and end is less than current planned date, both will have +1 day.
Example:
This will mean a retry in case of error during initialization of connection in 1 hour if not between 7AM to 7PM and not between 1AM to 3AM and with a limit of 3 retries (retry will be reset to 1 in case of 3 attempts).
For each attempt, the file transfer information will be decreased.
This task FTP allows to have a synchronous file transfer using FTP in a task. It uses the following parameters:
The order of commands will be:
The current file is not touched and is not marked as moved.
Example:
This will send (put) the file /path/file to the ftp server remotehost on port port using for credential username and password.