4 Replies Latest reply: Apr 5, 2012 7:52 AM by 926976 RSS

    Unable to access template attributes in a RequestValidator plugin

    926976
      Hello everybody.
      I need to set up a DataSetValidator plugin that examines a template attribute to validate the request. According to the documentation, I should be able to access template-specific fields using the getTemplateAttributes() method of the RequestData object passed to my plugin. However, this method always seems to return NULL.

      Some additional info:
      - OIM version is 11.1.1.5.0
      - The request is created from a template configured with one additional attribute (type String);
      - The users is indeed presented with the additional field and inputs some text in it;
      - The plugin is able to access all Dataset-related fields, i.e. I get a non-null value from getBeneficiaries(), and from it I can successfully reach the EntityData.
      - other methods, namely getRequestTemplateName(), getExecutionDate(), getJustification(), return correct values;
      - getTargetEntities(), like getTemplateAttributes(), always returns NULL.

      It looks like the template attributes do not make it into the RequestData object, although they are supposed to.
      Am I missing something?
        • 1. Re: Unable to access template attributes in a RequestValidator plugin
          BikashBagaria
          Rpatri wrote:
          Hello everybody.
          I need to set up a DataSetValidator plugin that examines a template attribute to validate the request. According to the documentation, I should be able to access template-specific fields using the getTemplateAttributes() method of the RequestData object passed to my plugin. However, this method always seems to return NULL.

          Some additional info:
          - OIM version is 11.1.1.5.0
          - The request is created from a template configured with one additional attribute (type String);
          - The users is indeed presented with the additional field and inputs some text in it;
          - The plugin is able to access all Dataset-related fields, i.e. I get a non-null value from getBeneficiaries(), and from it I can successfully reach the EntityData.
          - other methods, namely getRequestTemplateName(), getExecutionDate(), getJustification(), return correct values;
          - getTargetEntities(), like getTemplateAttributes(), always returns NULL.
          I think this is the way it is designed, RequestData object is something after the targetEntities and Template (thus it does not have visibility before it's existence), so for example, if you select two resources and one user in the request, then your validation plugin will be called 2 times, once each time with request data for each resource. From use case prespective, instead of validating the template attributes in the validation plugin, you can allow the request to be submitted and then reject the request from SOA based on the template attribute data.
          Just my understanding and I might be wrong, but don't have an image to try out the APIs now.
          It looks like the template attributes do not make it into the RequestData object, although they are supposed to.
          Am I missing something?
          -Bikash
          • 2. Re: Unable to access template attributes in a RequestValidator plugin
            926976
            >
            I think this is the way it is designed, RequestData object is something after the targetEntities and Template (thus it does not have visibility before it's existence), so for example, if you select two resources and one user in the request, then your validation plugin will be called 2 times, once each time with request data for each resource. From use case prespective, instead of validating the template attributes in the validation plugin, you can allow the request to be submitted and then reject the request from SOA based on the template attribute data.
            Just my understanding and I might be wrong, but don't have an image to try out the APIs now.
            Hello Bikash, thanks for your reply.
            You might be right in thinking that this is the way a RequestValidator plugin is supposed to work. However, there are some clues against it:

            - the Request class exposes more methods than RequestData, because some operations only make sense for a fully submitted request and not for the very early stage. Thus, if getBeneficiaries(), getTargetEntities() and getTemplateAttributes() appear in both classes, it's because they are supposed to make sense for both.

            - getJustification() works fine for a RequestData, but the users enter the justification after they have submitted the Template attributes. Also, in your example scenario the justification would be the same for both invocations ot the validation plugin. So why can't Template attributes be the same, too?

            - if I understand correctly, the purpose of a RequestValidator plugin is giving an immediate feedback to the user about the data they have entered. A clue in favour of this assumption is that you can customize the message presented to the user in case of incorrect data using something like

            throw new InvalidRequestDataException("Note[ERROR_PASSWORDSDONOTMATCH].text");

            Moreover, rejecting the request at SOA level because of wrong data entered is somewhat annoying for the user. Think about receiving a notification that the password you chose does not meet the minimum criteria one hour after you entered it (SOA is asynchronous after all), and being forced to submit a whole new request for that reason.

            So, my opinion is that a RequestValidator plugin should have access to Template attributes, too, to do its job. Unfortunately it doesn't seem to be the case, and documentation does not clarify this point at all, and I could not find examples.
            Does anyone else have experience on writing RequestValidators?

            Thanks,
            RPatri

            Edited by: Rpatri on Mar 29, 2012 2:03 AM
            • 3. Re: Unable to access template attributes in a RequestValidator plugin
              ejani
              Hello,

              We are having this problem too, it seems very difficult to find information on writing RequestValidators. The information in "Developer's Guide" is incomplete.


              Please, let us know, if anyone find any useful information about these aspects.

              Best Regard,
              Eugert
              • 4. Re: Unable to access template attributes in a RequestValidator plugin
                926976
                >
                I think this is the way it is designed, RequestData object is something after the targetEntities and Template
                Apparently, it was a bug:

                Bug:13086296 : Template attributes are null inside a custom data validator's validate() method.

                This is supposed to have been fixed in 11g bundle patch 2, but I've yet to try it out.

                Regards,


                Patri