Waarp R66-TaskOptions

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:

  1. Sender actions: A host is a Sender if it is the requester on a SEND rule or if it is the requested on a RECV rule. Those are split in Pre, Post transfer and in Error transfer.
  2. Receiver actions: A host is a Sender if it is the requester on a RECV rule or if it is the requested on a SEND rule. Those are split in Pre, Post transfer and in Error transfer.

Each action could be on pre, post or error step, each step can have several actions.





TaskFormat

It is defined with a unified form of XML:

<tasks> <task> <type>NAME</type> <path>path</path> <delay>x</delay> </task> <task> <type>NAME</type> <path>path</path> <delay>x</delay> </task> </tasks>

  • is the type of task to execute (see below the supported types)
  • is a fixed argument for the task to execute. On this argument, string replacements are done when the following patterns are found:
    • : Current full path of current FILENAME
    • : Current FILENAME (basename) (change in retrieval part)
    • : Original full path FILENAME (before changing in retrieval part)
    • : Original FILENAME (basename) (before changing in retrieval part)
    • : File size if it exists
    • : In (Receive) path
    • : Out (Send) path
    • : Working (while receiving) path
    • : Archive path (for export Log)
    • : Home path (to enable for instance relative path commands)
    • : Rule used during transfer
    • : Current Date in yyyyMMdd format
    • : Current Hour in HHmmss format
    • : Remote host id (if not the initiator of the call)
    • : Remote host IP (if not the initiator of the call)
    • : Local host Id
    • : Local host IP
    • : Transfer Id
    • : Requester host Id
    • : Requested host Id
    • : Full Transfer Id as TRANSFERID_REQUESTERHOST_REQUESTEDHOST
    • : Current or final RANK of block
    • : Block size used
    • : The current error message or NoError if no error occurs until this call
    • : The current error code or '-' (Unknown) if no error occurs until this call
    • : The current error code message or "Unknown" if no error occurs until this call
    • : Used by Exec type task to specify that the command will be executed in asynchronous mode, without waiting any result from it
    • : Used by Exec type task to specify that the command will be executed not locally (within the JVM) but outside using a LocalExec Daemon (specified in the global configuration)

    For instance, a Path in rule defined as

    some #DATE# some2 #TRANSFERID# some3 #REMOTEHOST# some4

    It will give:

    some 20130529 some2 123456789123 some3 remotehostid some4
  • is generally the delay (if any) for execution before the execution becomes out of time.
  • Additionnaly, a task will use also the argument from the transfer itself (Transfer Information). It uses the

    String.format(path from rule, info from transfer.split by " "). This enables a very adaptative argument passing to the various tasks.

    For instance :

    • if rule defines Path as some %s some2 %d some3 %s some4
    • and transfer information is info1 1 info2
    • it will give for the task: some info1 some2 1 some3 info2 some4

LOG

This task logs or writes to an external file some info:

  • if delay is 0, no echo at all will be done
  • if delay is 1, will echo some information in the normal log
  • if delay is 2, will echo some information in the file (last deduced argument will be the full path for the file output)
  • if delay is 3, will echo both in the normal log and in the file (last deduced argument will be the full path for the file output)

If first word of the log is one of , , or , this word will be used as the log level

Example:

<task> <type>LOG</type> <path>warn information /path/logfile</path> <delay>2</delay> </task>

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.

SNMP

This task sends a SNMP trap or info according to snmp configuration with the info field:

  • if delay is 0, only a warning trap/info is sent with the field info and the Transfer ID
  • if delay is 1, a trap/info with full transfer information plus the field info is sent

If first word of the log is one of , , or , this word will be used as the log level

Example:

<task> <type>SNMP</type> <path>information</path> <delay>0</delay> </task>

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

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).

  • Delay and Transfer Information are ignored.
  • The file is not marked as moved.

Example:

<task> <type>COPY</type> <path>/newpath/</path> </task>

This will copy the current file to /newpath/ as /newpath/currentfilename. The current file stays the previous one (not changed).

COPYRENAME

Copy the file to the path designed by Path and Transfer Information arguments.

  • 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)). The path obtained must be an absolute path (not a relative path).
  • Delay is ignored.
  • The file is not marked as moved.

Example:

<task> <type>COPYRENAME</type> <path>/newpath/newfilename_%s_#TRANSFERID#</path> </task>

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).

  • The current file is not changed and stays the same.

MOVE

Move the file to the path designed by Path and Transfer Information arguments without renaming the filename (same basename).

  • 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)). The path obtained must be an absolute path (not a relative path).
  • Delay is ignored.
  • The file is marked as moved.

Example:

<task> <type>MOVE</type> <path>/newpath/</path> </task>

This will move the file (not copying it) to the new directory /newpath/. The current file is now the moved file.

MOVERENAME

Move the file to the path designed by Path and Transfer Information arguments.

  • 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)). The path obtained must be an absolute path (not a relative path).
  • Delay is ignored.
  • The file is marked as moved.

Example:

<task> <type>MOVERENAME</type> <path>/newpath/newfilename</path> </task>

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.

LINKRENAME

Create a link of the current file and make the file pointing to it.

  • The link first tries to be a hard link, then a soft link, and if it is really not possible (not supported by the filesystem), it does a copy and rename task.
  • 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)). The path obtained must be an absolute path (not a relative path).
  • Delay is ignored.
  • The file is not marked as moved.

Example:

<task> <type>LINKRENAME</type> <path>/newpath/filenamelink</path> </task>

This will try to link the file (if not possible, it performs a copy) to the new directory /newpath/ with name filenamelink.

RENAME

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:

  • 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)). The path obtained must be an absolute path (not a relative path).
  • Delay is ignored.
  • The file is marked as moved.

Example:

<task> <type>RENAME</type> <path>/newpath/newfilename</path> </task>

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.

DELETE

This task deletes the current file.

  • The current file is no more valid.
  • No arguments are taken into account.

Example:

<task> <type>DELETE</type> </task>

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.

VALIDFILEPATH

Test if the current file is under one of the paths based on the Path and Transfer Information arguments.

  • The paths arguments are obtained from Path 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)).
  • The result should be as: "path1 path2 ..." where each path is separated by blank character.
  • If Delay is not 0, a log is printed out.
  • The file is not marked as moved.

Example:

<task> <type>VALIDFILEPATH</type> <path>/path1/ /path2/</path> <delay>1</delay> </task>

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.

ICAP

Test if the current file contains no virus against an ICAP server.

  • The paths arguments are obtained from Path 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)).
  • The result should be usig the following format:
    • -file filename
    • -to hostname
    • [-port port, default 1344]
    • -service name | -model name
    • [-previewSize size, default none]
    • [-blockSize size, default 8192]
    • [-receiveSize size, default 65536]
    • [-maxSize size, default MAX_INTEGER]
    • [-timeout in_ms, default equiv to 10 min]
    • [-keyPreview key -stringPreview string, default none]
    • [-key204 key -string204 string, default none]
    • [-key200 key -string200 string, default none]
    • [-stringHttp string, default none]
    • [-logger DEBUG|INFO|WARN|ERROR, default none]
    • [-errorMove path | -errorDelete | -sendOnError]
    • [-ignoreNetworkError]
    • [-ignoreTooBigFileError]
    Format is like r66send command in any order except "-info" which should be the last item, and "-copyinfo" will copy at first place the original transfer information as the new one, while still having the possibility to add new informations through "-info":
    "-file filepath -to requestedHost -rule rule [-md5] [-start yyyyMMddHHmmss or -delay (delay or +delay)] [-nofollow) [-copyinfo] [-info information]"
  • The Delay is ignored
  • The file is not marked as moved.

Example:

<task> <type>ICAP</type> <path>-file #TRUEFULLPATH# -to hostname -service name -logger WARN -errorDelete -ignoreNetworkError<br> </path> <delay>1</delay> </task>

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.

S3GET

Get a remote S3 file that can be used as new current file based on the Path and Transfer Information arguments.

  • The arguments are obtained from Path 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)).
  • The arguments are:
    • -URL url to specify the remote S3 url
    • -accessKey access Key for S3 service
    • -secretKey secret Key for S3 service
    • -bucketName bucket Name where to retrieve the object
    • -sourceName source Name from the bucket to select the final Object
    • -file final File path (absolute or relative from IN path)
    • [-getTags [* or list of tag names comma separated without space]]"
  • Delay is ignored.
  • The file is marked as moved (renamed).

Example:

<task> <type>S3GET</type> <path>-URL https://s3.service/ -accessKey access -secretKey secret -bucketName bucket -sourceName source -file /destPath</path> <delay>0</delay> </task>

This will get the remote designated file using S3 service and store it within /destPath.

S3GETDELETE

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.

  • The arguments are obtained from Path 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)).
  • The arguments are:
    • -URL url to specify the remote S3 url
    • -accessKey access Key for S3 service
    • -secretKey secret Key for S3 service
    • -bucketName bucket Name where to retrieve the object
    • -sourceName source Name from the bucket to select the final Object
    • -file final File path (absolute or relative from IN path)
    • [-getTags [* or list of tag names comma separated without space]]
  • Delay is ignored.
  • The file is marked as moved (renamed).

Example:

<task> <type>S3GETDELETE</type> <path>-URL https://s3.service/ -accessKey access -secretKey secret -bucketName bucket -sourceName source -file /destPath</path> <delay>0</delay> </task>

This will get the remote designated file using S3 service and store it within /destPath, then delete the remote S3 object file.

S3DELETE

Delete a remote S3 file based on the Path and Transfer Information arguments.

  • The arguments are obtained from Path 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)).
  • The arguments are:
    • -URL url to specify the remote S3 url
    • -accessKey access Key for S3 service
    • -secretKey secret Key for S3 service
    • -bucketName bucket Name where to retrieve the object
    • -sourceName source Name from the bucket to select the final Object
  • Delay is ignored.
  • The file is untouched.

Example:

<task> <type>S3DELETE</type> <path>-URL https://s3.service/ -accessKey access -secretKey secret -bucketName bucket -sourceName source</path> <delay>0</delay> </task>

This will delete the remote designated file using S3 service.

S3PUT

Put the current file as a remote S3 file, based on the Path and Transfer Information arguments.

  • The arguments are obtained from Path 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)).
  • The arguments are:
    • -URL url to specify the remote S3 url
    • -accessKey access Key for S3 service
    • -secretKey secret Key for S3 service
    • -bucketName bucket Name where to retrieve the object
    • -targetName source Name from the bucket to select the final Object
    • [-setTags 'name:value,...' without space]
  • Delay is ignored.
  • The file is untouched.

Example:

<task> <type>S3PUT</type> <path>-URL https://s3.service/ -accessKey access -secretKey secret -bucketName bucket -targetName target</path> <delay>0</delay> </task>

This will put the current file as a new remote file using S3 service.

S3PUTR66DELETE

Put the current file as a remote S3 file, and delete the current file, based on the Path and Transfer Information arguments.

  • The arguments are obtained from Path 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)).
  • The arguments are:
    • -URL url to specify the remote S3 url
    • -accessKey access Key for S3 service
    • -secretKey secret Key for S3 service
    • -bucketName bucket Name where to retrieve the object
    • -targetName source Name from the bucket to select the final Object
    • [-setTags 'name:value,...' without space]
  • Delay is ignored.
  • The file is deleted.

Example:

<task> <type>S3PUTR66DELETE</type> <path>-URL https://s3.service/ -accessKey access -secretKey secret -bucketName bucket -targetName target</path> <delay>0</delay> </task>

This will put the current file as a new remote file using S3 service, then deleting the current file.

CHKFILE

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 DFCHECK
will 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:

<task> <type>CHKFILE</type> <path>SIZE LT 1000000 SIZE GT 1000 DFCHECK</path> </task>

TRANSCODE

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:

java -cp WaarpCommon-1.2.7.jar org.waarp.common.transcode.CharsetsUtil [-csv | -html | -text ] It could also be used as a test of transcode outside R66: java -cp WaarpCommon-1.2.7.jar org.waarp.common.transcode.CharsetsUtil -from fromFilename fromCharset -to toFilename toCharset The current file is not touched and is not marked as moved.

Example:

<task> <type>TRANSCODE</type> <path>-from fromCharset -to toCharset -newfile /path/file</path> </task>

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.

Transcode support

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:

  • http://www-01.ibm.com/software/globalization/ccsid/ccsid_registered.html
  • http://publib.boulder.ibm.com/infocenter/pcomhelp/v5r9/topic/com.ibm.pcomm.doc/reference/html/hcp_reference.htm

In particular (but not limited to), one could consider the following charsets (from or to):

  • France: IBM297 or IBM01147
  • Italy: IBM280 or IBM01144
  • UK: IBM285 or IBM01146
  • International (Switzerland, Belgium): IBM500 or IBM01148
  • Austria/Germany: IBM273 or IBM01141
  • Spain and Latin America: IBM284 or IBM01145
  • Portugal, Brazil, USA, Canada, Netherlands: IBM037 or IBM01140
  • Central and Eastern Europe: IBM870
  • Cyrillic: x-IBM1025 (x-IBM1381?)
  • Turkey: IBM1026
  • Cyrillic Ukraine: x-IBM1123
  • Denmark, Norway: IBM277 or IBM01142
  • Finland or Sweden: IBM278 or IBM01143
  • Greece: x-IBM875 or x-IBM1124

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:

java -cp WaarpCommon-1.2.7.jar org.waarp.common.transcode.IdentifyCharsetsAvailable [-csv | -html | -text ] It could also be used as a test of transcode outside R66: java -cp WaarpCommon-1.2.7.jar org.waarp.common.transcode.CharsetsUtil -from fromFilename fromCharset -to toFilename toCharset

TAR

Create a TAR from the argument as source and destination or UNTAR files from a TAR file.

  • 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)).
  • Delay of 1 = UNTAR PATH="sourceFile targetDirectory"
  • Delay of 2 = TAR PATH="targetFile sourceDirectory"
  • Delay of 3 = TAR PATH="targetFile sourceFile1 sourceFile2..."
  • The current file is not touched.

Example:

<task> <type>TAR</type> <path>/path/sourcetarfile /path/targetdirectory/</path> <delay>1</delay> </task>

This will launch a "tar/untar" command of tar file /path/sourcetarfile into directory /path/targetdirectory.

ZIP

Create a ZIP from the argument as source and destination or UNZIP files from a ZIP file.

  • 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)).
  • Delay of 1 = UNZIP PATH="sourceFile targetDirectory"
  • Delay of 2 = ZIP PATH="targetFile sourceDirectory"
  • Delay of 3 = ZIP PATH="targetFile sourceFile1 sourceFile2..."
  • The current file is not touched.

Example:

<task> <type>ZIP</type> <path>/path/sourcetarfile /path/targetdirectory/</path> <delay>1</delay> </task>

This will launch a "zip/unzip" command of zip file /path/sourcetarfile into directory /path/targetdirectory.

COMPRESS

Compress/Decompress the current file from the argument as source and destination will be as same filename with suffix ".zstd" / ".unzstd" accordingly.

  • Delay of 0 = COMPRESS using ZTSD algorithm from sourceFile to sourceFile.zstd
  • Delay of 1 = DECOMPRESS using ZTSD algorithm from sourceFile to sourceFile.unzstd
  • The current file is deleted and replaced by the new one if OK.

Example:

<task> <type>COMPRESS</type> <path>ignored</path> <delay>1</delay> </task>

This will launch a "uncompress" command of ZSTD file /path/sourcezstdFile to /path/sourcezstdFile.unzstd .

UNZEROED

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:

<task> <type>UNZEROED</type> <path>optional</path> <delay>1</delay> </task>

This will run unzeroed task on current file, and print a LOG.INFO in case of no error, else LOG.ERROR.

CHMOD

This task allows to change the mode of the file (as in Unix CHMOD command) according to the following argument:

  • the full path is get from the current file
  • the arg path is transformed as usual (static and dynamic from information transfer)
  • this final path arg should be of the form [ua][+-=][rwx] where multiple elements could be specified, separated by blank character
    • u/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/Execute
    For instance, the final path arg could be:
    • u=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:

<task> <type>CHMOD</type> <path>a=r a+w a-r</path> </task>

EXEC

Execute an external command given by Path and Transfer Information arguments.

  • The Delay is the maximum amount of time in milliseconds before the task should be considered as over time and so in error.
  • The command path 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 path obtained must be an absolute path (not a relative path).
  • The file is not marked as moved.

The external command is supposed to behave as the following for its exiting value:

  • exit 0, for a correct execution
  • exit 1, for a warned execution (but however correct)
  • other exit values for a failed execution

Example:

<task> <type>EXEC</type> <path>/path/command arguments #TRANSFERID# #TRUEFULLPATH# %s</path> <delay>10000</delay> </task>

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".

EXECMOVE

Execute an external command given by Path and Transfer Information arguments.

  • The Delay is the maximum amount of time in milliseconds before the task should be considered as over time and so in error.
  • The command path 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 path obtained must be an absolute path (not a relative path).
  • The last line returned by the external command is interpreted as the new full absolute file path. The external command is responsible to really move the previous file to the new one.
  • The file is not marked as moved.

The external command is supposed to behave as the following for its exiting value:

  • exit 0, for a correct execution
  • exit 1, for a warned execution (but however correct)
  • other exit values for a failed execution

Example:

<task> <type>EXECMOVE</type> <path>/path/command arguments #TRANSFERID# #TRUEFULLPATH# %s</path> <delay>10000</delay> </task>

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.

EXECOUTPUT

Execute an external command given by Path and Transfer Information arguments.

  • The Delay is the maximum amount of time in milliseconds before the task should be considered as over time and so in error.
  • The command path 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 path obtained must be an absolute path (not a relative path).
  • All lines returned by the external command (normal output) is interpreted as the possible error message in case of error.
  • If no error (0 or 1 as exit value), the output is ignored (no file move is done).
  • The file is not marked as moved, except in case of error (and if NEWFILENAME: is used as a prefix to the filename).

The external command is supposed to behave as the following for its exiting value:

  • exit 0, for a correct execution
  • exit 1, for a warned execution (but however correct)
  • other exit values for a failed execution, for which the output (stdout) lines are used as error message, bring back to the remote host as #ERRORMSG# and #ERRORCODE# / #ERRORSTRCODE#, and NEWFINALNAME: is used to find the new filename (if any)

Example:

<task> <type>EXECOUTPUT</type> <path>/path/command arguments #TRANSFERID# #TRUEFULLPATH# %s</path> <delay>10000</delay> </task>

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.

EXECJAVA

Execute an external Java class given by Path and Transfer Information arguments.

  • The Delay is the maximum amount of time in milliseconds before the task should be considered as over time and so in error.
  • The class name (which must implement 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.
  • The file is not marked as moved.

Example:

<task> <type>EXECJAVA</type> <path>java.class.name #TRANSFERID# #TRUEFULLPATH#</path> <delay>10000</delay> </task>

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.

  • One is through pre or post or error tasks using the EXECJAVA keyword, following by the full class name which must implement the R66Runnable interface.
  • Another one is through specific R66Business command, which will also execute an R66Runnable implementation, through for instance the AbstractExecJavaTask abstract class that could be extended.
  • Finally, there is the possibility to associate a Business Class (see 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 commands
    • void checkAfterPreCommand(R66Session session): launched after the pre commands and before the transfer starts
    • void checkAfterTransfer(R66Session session): launched after the transfer is finished and before the post commands
    • void checkAfterPost(R66Session session): launched after the post commands and before the end of the request
    • void checkAtError(R66Session session): launched once an error occurs
    • void 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 released
    • String 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.
    Note that the R66BusinessFactory could be set through XML configuration file in <businessfactory> field in <server> or <client> part, but is limited to empty constructor form.
  • Note that to allow a host to call a Business Request, it has to be added in the configuration file as <business><businessid>hostname</businessid>...</business> If not set, the host will not be allow. On EXECJAVA, the security is first that the rule is only local to the host, and second the rule has the possibility to limit the allowed hosts to be partner of it.

RESTART

This task allows to restart the Waarp R66 server. There is no special argument.

Example:

<task> <type>RESTART</type> <path></path> <delay>0</delay> </task>

For instance, this could be used after upgrade of Waarp R66 server binaries through a rule to upload followed by untar, then restart.

TRANSFER

Submit a new transfer based on the Path and Transfer Information arguments.

  • The transfer arguments are obtained from Path 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)).
  • The result should be as r66send command except "-info" must be the last item, and "-copyinfo" will copy at first place the original transfer information as the new one, while still having the possibility to add new informations through "-info": -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.
  • Delay is ignored.
  • The file is not marked as moved.

Example:

<task> <type>TRANSFER</type> <path>-file #TRUEFULLPATH# -to remotehost -rule ruletouse -info transfer Information</path> </task>

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

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.
    • Format can be 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
    • If one time specification is not set, it is based on the current date.
    • If "-notbetween" is specified, the planned date must not be in the area.
    • If "-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".
    • If none is specified, the planned date is always valid.
  • "-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:

<task> <type>RESCHEDULE</type> <path>-delay 3600000 -case ConnectionImpossible,ServerOverloaded,Shutdown -notbetween H7:m0:S0;H19:m0:S0 -notbetween H1:m0:S0;H=3:m0:S0 -count 1</path> </task>

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.

FTP

This task FTP allows to have a synchronous file transfer using FTP in a task. It uses the following parameters:

-file filepath -to requestedHost -port port -user user -pwd pwd [-account account] [-mode active/passive] [-ssl no/implicit/explicit] [-cwd remotepath] [-digest (crc,md5,sha1)] [-pre extraCommand1 with ',' as separator of arguments] -command command from (get,put,append) [-post extraCommand2 with ',' as separator of arguments]

The order of commands will be:

1- connection to requestHost on port (if ssl native => using native ssl link) 2- User user 3- PASS pwd 4- if account => ACCT account 5- if -ssl & auth => AUTH, PBSZ 0, PROT P 6- if passive => PASV 7- CWD remotepath; if error => MKD remotepath then CWD remotepath (and ignoring any error) 8- if pre => extraCommand1 with ',' replaced by ' ' (note: do not use standard commands from FTP like ACCT,PASS,REIN,USER,APPE,STOR,STOU,RETR,RMD,RNFR,RNTO,ABOR,CWD,CDUP,MODE,PASV, PORT,STRU,TYPE,MDTM,MLSD,MLST,SIZE,AUTH) 9- BINARY (binary format) 10- if get => RETR filepath.basename ; if put => STOR filepath ; if append => APPE filepath.basename 11- if digest & get/put/append & remote site compatible with XCRC,XMD5,XSHA1 => FEAT (parsing if found corresponding XCRC,XMD5,XSHA1) ; then XCRC/XMD5/XSHA1 filepath.basename ; then locally comparing this XCRC/XMD5/XSHA1 with the local file 12- if post => extraCommand2 with ',' replaced by ' ' (note: do not use standard commands from FTP like ACCT,PASS,REIN,USER,APPE,STOR,STOU,RETR,RMD,RNFR,RNTO,ABOR,CWD,CDUP,MODE,PASV, PORT,STRU,TYPE,MDTM,MLSD,MLST,SIZE,AUTH) 13- QUIT

The current file is not touched and is not marked as moved.

Example:

<task> <type>FTP</type> <path>-file /path/file -to remotehost -port port -user username -pwd password -command put</path> </task>

This will send (put) the file /path/file to the ftp server remotehost on port port using for credential username and password.