[OPENIDM-12552] Unable to sort by '_id' when querying Scripted Connectors Created: 06/Feb/19  Updated: 17/Jul/19  Resolved: 17/Jul/19

Status: Closed
Project: OpenIDM
Component/s: _Connectors, _Samples, Module - Provisioner framework
Affects Version/s: 7.0.0
Fix Version/s: 7.0.0

Type: Bug Priority: Major
Reporter: Chris Drake Assignee: Jon Branch
Resolution: Cannot Reproduce Votes: 0
Labels: CLARK
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Target Version/s:
Story Points: 2
Sprint: 2019.10 - IDM


When executing a querying against a Scripted ICF connector and specifying the _id attribute as a _sortKey, OpenIDM's ICF Provisioner service does not translate _id into Uid.NAME before setting the sort key within the connector OperationOptions.

Our OOTB scripted connector sample contain code to translate between native ICF attributes (__UID__ and __NAME__) and the attributes use on the target system. As a result of the OpenIDM ICF Provisioner not translating _id into the ICF __UID__ attribute the existing code within our samples fails to perform the necessary conversion to the attribute name in used by the external system.

This can be reproduced by executing the following request using the scripted-sql-with-mysql sample:

--header "X-OpenIDM-Username: openidm-admin" \
--header "X-OpenIDM-Password: openidm-admin" \
--request GET \

To resolve the issue, ObjectClassResourceProvider.getSanitizedSortKeys() should convert ResourceResponse.FIELD_CONTENT_ID to Uid.NAME. For example:

private List<SortKey> getSanitizedSortKeys(List<org.forgerock.json.resource.SortKey> sortKeys)
        throws BadRequestException {
    List<SortKey> sanitizedSortKeys = new ArrayList<>(sortKeys.size());
    for (org.forgerock.json.resource.SortKey s: sortKeys) {
        // Validate the sortKey against the schema
        final String attrName = objectClassInfoHelper.getAttributeName(s.getField());
        if (attrName != null) {
            sanitizedSortKeys.add(new SortKey(attrName, s.isAscendingOrder()));
        } else if (s.getField().leaf().equals(ResourceResponse.FIELD_CONTENT_ID)) {
            sanitizedSortKeys.add(new SortKey(Uid.NAME, s.isAscendingOrder()));
        } else {
            throw new BadRequestException("Unsupported _sortKey: " + s.getField().leaf());
    return sanitizedSortKeys;

Comment by Jon Branch [ 17/Jul/19 ]

This is no longer reproducible, likely fixed by another jira.  Using the scripted-sql-with-mysql sample I can sort by UID or any other attribute.

Generated at Tue Mar 31 20:30:49 UTC 2020 using Jira 7.13.12#713012-sha1:6e07c38070d5191bbf7353952ed38f111754533a.