Uploaded image for project: 'OpenIDM'
  1. OpenIDM
  2. OPENIDM-9964

No content and NullPointerException returned when creating a relationship using the source managed object's attribute within the URI and specifying a _fields parameter

    Details

      Description

      When creating a relationship directly against a managed object's attribute and specifying a _fields parameter, no content is returned in the response payload.

      Re-production:

      • Current IDM Master (rev: 13e8bf8)
      • Add the following to managed.json
              {
                  "name" : "Group",
                  "schema" : {
                      "$schema" : "http://forgerock.org/json-schema#",
                      "type" : "object",
                      "title" : "Group",
                      "description" : "User Group",
                      "icon" : "fa-group",
                      "properties" : {
                          "name" : {
                              "description" : "Group Name",
                              "title" : "Name",
                              "viewable" : true,
                              "searchable" : true,
                              "userEditable" : true,
                              "policies" : [
                                  {
                                      "policyId" : "unique",
                                      "params" : { }
                                  }
                              ],
                              "returnByDefault" : true,
                              "minLength" : null,
                              "pattern" : "",
                              "type" : "string"
                          },
                          "groupMembers" : {
                              "description" : "List of groups, which are members of the owning (this) group",
                              "title" : "Group Members",
                              "viewable" : true,
                              "searchable" : false,
                              "userEditable" : false,
                              "policies" : [ ],
                              "returnByDefault" : true,
                              "minLength" : null,
                              "pattern" : "",
                              "type" : "array",
                              "items" : {
                                  "type" : "relationship",
                                  "reverseRelationship" : true,
                                  "reversePropertyName" : "groupMembership",
                                  "validate" : true,
                                  "properties" : {
                                      "_ref" : {
                                          "type" : "string"
                                      },
                                      "_refProperties" : {
                                          "type" : "object",
                                          "properties" : {
                                              "_id" : {
                                                  "type" : "string",
                                                  "label" : ""
                                              },
                                              "status" : {
                                                  "type" : "string",
                                                  "label" : "Status"
                                              },
                                              "lastModifiedBy" : {
                                                  "type" : "string",
                                                  "label" : "Last Modified By"
                                              }
                                          }
                                      }
                                  },
                                  "resourceCollection" : [
                                      {
                                          "path" : "managed/Group",
                                          "label" : "Group",
                                          "query" : {
                                              "queryFilter" : "",
                                              "fields" : [
                                                  "name"
                                              ],
                                              "sortKeys" : [
                                                  "name"
                                              ]
                                          }
                                      }
                                  ]
                              }
                          },
                          "groupMembership" : {
                              "description" : "List of groups, in which the owning (this) group is member of",
                              "title" : "Member in Groups",
                              "viewable" : true,
                              "searchable" : false,
                              "userEditable" : false,
                              "policies" : [ ],
                              "returnByDefault" : true,
                              "minLength" : null,
                              "pattern" : "",
                              "type" : "array",
                              "items" : {
                                  "type" : "relationship",
                                  "reverseRelationship" : true,
                                  "reversePropertyName" : "groupMembers",
                                  "validate" : true,
                                  "properties" : {
                                      "_ref" : {
                                          "type" : "string"
                                      },
                                      "_refProperties" : {
                                          "type" : "object",
                                          "properties" : {
                                              "_id" : {
                                                  "type" : "string",
                                                  "label" : ""
                                              },
                                              "status" : {
                                                  "type" : "string",
                                                  "label" : "Status"
                                              },
                                              "lastModifiedBy" : {
                                                  "type" : "string",
                                                  "label" : "Last Modified By"
                                              }
                                          }
                                      }
                                  },
                                  "resourceCollection" : [
                                      {
                                          "path" : "managed/Group",
                                          "label" : "Group",
                                          "query" : {
                                              "queryFilter" : "",
                                              "fields" : [
                                                  "name"
                                              ],
                                              "sortKeys" : [
                                                  "name"
                                              ]
                                          }
                                      }
                                  ]
                              }
                          }
                      },
                      "required" : [ ],
                      "order" : [
                          "name",
                          "groupMembers",
                          "groupMembership"
                        ]
                  },
                  "iconClass" : "fa fa-database",
                  "type" : "Managed Object"
              }
      
      • Start IDM (No Samples, Any repo)
      • Create two new groups, 'firstGroup' and 'secondGroup'
      • Perform the following REST request and substitute the _id value for firstGroup in to the URI and secondGroup in to the payload:
      POST http://localhost:8080/openidm/managed/Group/d8637ac4-ac38-43c4-b992-288c74d7d3d3/groupMembers?_action=create&_fields=_ref
      
      {"_ref":"managed/Group/4db42703-215f-4fc7-a663-724c9b740733"}
      
      • An empty response will be received
      • Confirm that the relationship has been created:
      {
          "result": [
              {
                  "_id": "d8637ac4-ac38-43c4-b992-288c74d7d3d3",
                  "_rev": "00000000b2065046",
                  "name": "firstGroup",
                  "groupMembers": [
                      {
                          "_ref": "managed/Group/4db42703-215f-4fc7-a663-724c9b740733",
                          "_refProperties": {
                              "_id": "5621ce7a-dae1-4679-952b-d4ddfb569868",
                              "_rev": "0000000074419681"
                          }
                      }
                  ],
                  "groupMembership": []
              },
              {
                  "_id": "4db42703-215f-4fc7-a663-724c9b740733",
                  "_rev": "00000000be1850db",
                  "name": "secondGroup",
                  "groupMembers": [],
                  "groupMembership": [
                      {
                          "_ref": "managed/Group/d8637ac4-ac38-43c4-b992-288c74d7d3d3",
                          "_refProperties": {
                              "_id": "5621ce7a-dae1-4679-952b-d4ddfb569868",
                              "_rev": "0000000074419681"
                          }
                      }
                  ]
              }
          ],
          "resultCount": 2,
          "pagedResultsCookie": null,
          "totalPagedResultsPolicy": "NONE",
          "totalPagedResults": -1,
          "remainingPagedResults": -1
      }
      

      Performing the same request without specifying the _fields parameter in the URL completes as expected:

      POST http://localhost:8080/openidm/managed/Group/d8637ac4-ac38-43c4-b992-288c74d7d3d3/groupMembers?_action=create
      
      {"_ref":"managed/Group/4db42703-215f-4fc7-a663-724c9b740733"}
      
      {
        "_id": "ca1ffc50-6e36-43dc-b57a-75a1b6ded0e8",
        "_rev": "00000000d4289719",
        "_ref": "managed/Group/4db42703-215f-4fc7-a663-724c9b740733",
        "_refProperties": {
          "_id": "ca1ffc50-6e36-43dc-b57a-75a1b6ded0e8",
          "_rev": "00000000d4289719"
        }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alin Alin Brici
                Reporter:
                tom.wood Tom Wood
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: