call-preparser()
This function calls a preparser, passes input data to its stdin plus a config file and returns a string containing the output data of the preparser from its stdout.
The input data stream (stdin) and the output data stream (stdout) of any preparser are byte-oriented. If these bytes are to be interpreted as a character string, encoding is always relevant. The function opens the file labelled input path c, reads the bytes from the file and writes them byte by byte to the preparser's input data stream.
Value of parameter c |
Meaning |
|
No input data. |
<file path> |
Content of the specified file. It can be given as a relative or an absolute path. |
- |
Backup data received by the job. |
:text:<text> |
Given text after the colon. For alteration into a byte stream, input encoding specified in e is used. |
:list=<list name>: |
The values in the list are read as text lines separated by a Newline and processed as described in :text: |
The data result returned by the preparser is returned as a result string of this function. The bytes coming from the preparser are converted into characters with the profile encoding to be chosen in the profile's properties. An alternative encoding can be specified in parameter f.
In general, a preparser expects a path to a properties file as a configuration parameter. Therefore, the config parameter b is passed directly to the preparser which is responsible for reading this file. In case the configuration file is dynamically generated during the job as a temporary file, the function is responsible for the creation and subsequent deletion of the configuration file.
Parameters
Parameter |
Description |
a |
Please only use the PPP configuration for preparsers for newer profiles. In that case, the path to the .ppp file has to be set in parameter b. Old configuration method: The complete class name of the preparser with package, e.g. com.ebd.hub.datawizard.parser.URLDecoder. This parameter is mandatory unless the PPP configuration for preparsers is used. |
b |
(optional) Preparser config. Either the path to the config file, empty, :map=<map name>:, or :list=<list name>:. This parameter is mandatory only if the preparser expects a configuration. In general, the path to a local file is expected. This file will not be opened by this function but by the preparser itself. The configuration file can also be generated by the function as a temporary file at runtime. In this case, it gets deleted by the preparser after processing. If the preparser configuration expects a properties file, then the file can be dynamically created from a named map object within the profile mapping. In case the order of configuration lines is essential the temporary file must be created from a named list object. The temporary file always uses encoding 8859_1. The creation of the temporary file is performed with every function execution and, for performance reason, should be used only if a static configuration by a local file path is not possible. |
c |
(optional) Input file. Source of input data sent to the standard input of the preparser. Default: empty. |
d |
(optional) Max result size. The maximum allowed number of bytes the preparser can return. If exceeding the size the job will be aborted with an exception. The value can be a simple number meaning bytes or a number with a trailing M for megabytes, k for kilobytes or b for bytes. Default: 8388608 (corresponding to 8M). |
e |
(optional) Input encoding. Encoding to be used for the conversion of the input text. Is ignored if input source c is a file. Default: Utf8 |
f |
(optional) Result encoding. The character encoding used to convert the bytes from preparser result into a string. Default: Profile encoding. |
Note: If parameter c is configured with the placeholder for the backup file, this data will not be available in mapping tests. In this case, option Replacement values for functions should be used to skip this function while testing.
Examples
Decoding a GPG encrypted file by calling the GPG program with the SystemCallPreParser. The GPG program is installed locally on top of the operating system and keys were configured. The GPG-encrypted file is found as a local file on the hard drive with name encryptedfile.gpg.
Parameter a |
com.ebd.hub.datawizard.parser.SystemCallPreParser |
Parameter b |
./conf/GPG_decrypt.properties |
Parameter c |
encryptedfile.gpg |
Parameter d |
64M |
Parameter e |
|
Parameter f |
utf8 |
Result |
Content of the decrypted file. |
The config file ./conf/GPG_decrypt.properties contains following lines (properties).
command=C:/Programme/GNU/GnuPG/gpg.exe -d -o - -
timeout=300000
Calling the same preparsers with PPP configuration.
Parameter a |
Parameter b |
Parameter c |
Parameter d |
Parameter e |
Parameter f |
Result |
|
./conf/GPG_decrypt.ppp |
ecryptedfile.gpg |
64M |
|
Utf8 |
Content of the decrypted file. |
The config file ./conf/GPG_decrypt.ppp contains following lines.
preparser.class.name=com.ebd.hub.datawizard.parser.SystemCallPreParser
command = C:/Programme/GNU/GnuPG/gpg.exe -d -o - -
timeout = 300000