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

"onSync" script for managed objects is not called for both vertices when a relationship is created between them

    Details

      Description

      Steps to reproduce :
      1) Before you start OpenIDM add the line below to the following file after 'var _ = require('lib/lodash');' openidm/bin/defaults/script/roles/onSync-roles.js to log that this "onSync" script was executed.

      console.log("Calling onSync-Roles.js");
      

      2) Start OpenIDM.
      3) Navigate to the 'Managed Objects' page via the UI.
      4) Select the 'User' managed object.
      5) In the Managed Object > user view click on the scripts tab. We are going to create an "onSync" hook script to log that onSync was triggered for a managed/user.
      6) Create a new Script inline with something like, console.log("Managed/User onSync script triggered");
      7) Create a new managed/user

      curl --header "X-OpenIDM-Username: openidm-admin" --header "X-OpenIDM-Password: openidm-admin" --header "If-None-Match: *" --header "Content-Type: application/json" --request PUT --data '{"userName":"phill","givenName":"phill","sn":"doctor","telephoneNumber":"12345678","mail":"phill@relationshiprefactor.com","password":"Th3Password","roles" : []}' http://localhost:8080/openidm/managed/user/phill | jq .
      

      8) Look at OSGI console and see that the onSync script from the Managed/User object has logged 'Managed/User onSync script triggered'
      9) Create a new managed/role

      curl --header "X-OpenIDM-Username: openidm-admin" --header "X-OpenIDM-Password: openidm-admin" --header "If-None-Match: *" --header "Content-Type: application/json" --request PUT --data '{
          "name" : "Super Star Role",
          "description" : "Role designated for an employee that is a super star."
      }' http://localhost:8080/openidm/managed/role/SuperStarRole | jq .
      

      10) Look at OSGI console and see that the onSync script from the Managed/User object has logged 'Calling onSync-Roles.js'
      11) Now create a new edge between Managed/User/phill and Managed/Role/SuperStarRole

      curl --header "X-OpenIDM-Username: openidm-admin" --header "X-OpenIDM-Password: openidm-admin" --header "If-Match: *" --header "Content-Type: application/json" --request PATCH --data '[
         {
             "operation" : "add",
             "field" : "/roles/-",
             "value" : { "_ref": "managed/role/SuperStarRole" }
         }
      ]' http://localhost:8080/openidm/managed/user/phill | jq .
      

      12) Notice that now the only thing that shows up in the console is 'Managed/User onSync script triggered' which is the onSync for the managed/user object and the one for managed/role never got triggered.

        Attachments

          Activity

            People

            • Assignee:
              alin Alin Brici
              Reporter:
              alin Alin Brici
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: