Package org.forgerock.openig.filter
Class FileAttributesFilter
java.lang.Object
org.forgerock.openig.filter.FileAttributesFilter
- All Implemented Interfaces:
Filter
Retrieves and exposes a record from a delimiter-separated file. Lookup of the record is
performed using a specified key, whose value is derived from an expression.
The resulting record is exposed in a
FileAttributesContext or in a Map object, at a
location is specified by the target expression (but this second option is deprecated).
If a matching record cannot be found, then the resulting map will be empty.
Two behaviors are currently available for the filter:
- (deprecated) The retrieval of the record is performed lazily by default and stored at the target location;
The data retrieval does not occur until the first attempt to access a value in the target. This defers the
overhead of file operations and text processing until a value is first required. This also means that the
valueexpression will not be evaluated until the map is first accessed. In this case, the reading of the file is done synchronously and may have performance impacts. - The retrieval of the record is done asynchronously within this filter and stored in a
FileAttributesContext; This means the file reading operation is always performed, and thus this filter must be placed right before the entity using these data.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCreates and initializes a separated values file attribute provider in a heap environment. -
Constructor Summary
ConstructorsConstructorDescriptionFileAttributesFilter(SeparatedValuesFile file, String key, Expression<String> value, LeftValueExpression<Map> target) Deprecated, for removal: This API element is subject to removal in a future version.use the other constructor instead. -
Method Summary
-
Constructor Details
-
FileAttributesFilter
@Deprecated(since="2024.9", forRemoval=true) public FileAttributesFilter(SeparatedValuesFile file, String key, Expression<String> value, LeftValueExpression<Map> target) Deprecated, for removal: This API element is subject to removal in a future version.use the other constructor instead.Builds a new FileAttributesFilter extracting values from the given separated values file.- Parameters:
file- The file to read separated values from (csv file)key- The name of the field in the file to perform the lookup onvalue- Expression that yields the value to be looked-up within the filetarget- Expression that yields the target object that will contain the record
-
-
Method Details
-
filter
public Promise<Response,NeverThrowsException> filter(Context context, Request request, Handler next) Description copied from interface:FilterFilters the request and/or response of an exchange. To pass the request to the next filter or handler in the chain, the filter callsnext.handle(context, request).This method may elect not to pass the request to the next filter or handler, and instead handle the request itself. It can achieve this by merely avoiding a call to
next.handle(context, request)and creating its own response object. The filter is also at liberty to replace a response with another of its own by intercepting the response returned by the next handler.
-