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

Custom Endpoint Example: object request.patchOperations is wrong for Groovy scripts

    Details

      Description

      1) unzip OpenIDM

      2) copy the conf and script from example-configurations/custom-endpoint to default conf folder:

      cd openidm
      cp samples/example-configurations/custom-endpoint/conf/* conf/
      cp samples/example-configurations/custom-endpoint/script/* script
      

      The custom endpoint is configured in endpoint-echo.json to work with the Groovy Script:

      {
          "file" : "echo.groovy",
          "type" : "groovy",
          "_file" : "echo.js",
          "_type" : "text/javascript"
      }
      

      3) launch OpenIDM

      ./startup.sh
      

      4) launch a PATCH through the custom endpoint:

      curl --header "Content-Type: application/json" --header "X-OpenIDM-Password: openidm-admin" --header "X-OpenIDM-Username: openidm-admin" --data '[{"operation":"replace","field":"mail","value":"change@patch.com"}]' --request PATCH "http://localhost:8080/openidm/endpoint/echo/foo/bar"
      

      Response:

      {
        "_id": "bar",
        "method": "patch",
        "resourceName": "foo/bar",
        "revision": null,
        "patch": [
          {
            "field": {
              "empty": false  <==== this is not OK
            },
            "from": null,
            "operation": "replace",
            "value": "change@patch.com",
            "add": false,
            "replace": true,
            "remove": false,
            "increment": false,
            "move": false,
            "copy": false,
            "transform": false
          }
      }
      

      5) When we follow the same procedure but use the JavaScript script, then the response is OK:

      {
        "_id": "bar",
        "patch": [
          {
            "operation": "replace",
            "field": "mail",
            "value": "change@patch.com"
          }
        ],
      

      Note: the problem was identified and confirmed in OPENIDM-3139

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jbranch Jon Branch
                Reporter:
                laurent.bristiel Laurent Bristiel
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: