PingGateway 2024.9

FileAttributesFilter

Retrieves and exposes a record from a delimiter-separated file. PingGateway looks up the record with the keys specified in the fields setting.

PingGateway populates the FileAttributesContext and the optional target (deprecated) with key-value pairs from the record. If no matching record is found, the context and optional target are empty.

When the deprecated target setting is configured, PingGateway lazy loads the record on the first attempt to access one of its values. This defers the overhead of file operations and text processing until a value is first required. PingGateway doesn’t evaluate the value expression until the data is first accessed. PingGateway reads the file synchronously, potentially impacting performance.

When target isn’t set, PingGateway reads the file asynchronously when calling this filter. In this case, place this filter immediately before the entity reading the data from the context.

Usage

{
     "name": string,
     "type": "FileAttributesFilter",
     "config": {
         "file": configuration expression<string>,
         "charset": configuration expression<string>,
         "separator": configuration expression<enumeration>,
         "header": configuration expression<boolean>,
         "fields": [ configuration expression<string>, ... ],
         "target": lvalue-expression, // deprecated
         "key": configuration expression<string>,
         "value": runtime expression<string>,
         "executorService": ScheduledExectutorService reference
     }
}

For an example, refer to Password replay from a file.

Properties

"file": configuration expression<string>, required

The file containing the record to be read.

"charset": configuration expression<string>, optional

The character set in which the file is encoded.

Default: "UTF-8".

"separator": configuration expression<enumeration>, optional

The separator character, which is one of the following:

COLON

Unix-style colon-separated values, with backslash as the escape character.

COMMA

Comma-separated values, with support for quoted literal strings.

TAB

Tab-separated values, with support for quoted literal strings.

Default: COMMA

"header": configuration expression<boolean>, optional

A flag to treat the first row of the file as a header row.

When the first row of the file is treated as a header row, the data in that row is disregarded and cannot be returned by a lookup operation.

Default: true.

"fields": array of configuration expression<strings>, optional

A list of keys in the order they appear in a record.

If fields is not set, the keys are assigned automatically by the column numbers of the file.

"target": <lvalue-expression>, optional
This property is deprecated. Use the FileAttributesContext instead. For more information, refer to the Deprecated section of the Release Notes.

Expression that yields the target object to contain the record.

The target object is a Map<String, String>, where the fields are the keys. For example, if the target is ${attributes.file} and the record has username and password fields mentioned in the "fields" list, access the username as ${attributes.file.username} and the password as ${attributes.file.password}.

Also refer to Expressions.

"key": configuration expression<string>, required

The key used for the lookup operation.

"value": runtime expression<string>, required

The value to find in the file.

Also refer to Expressions.

"executorService": ScheduledExecutorService reference, optional

A ScheduledExecutorService to read the file.

Default: The default ScheduledExecutorService in the heap