Highlighted
Super Contributor.
Super Contributor.
699 views

direct operation with REST driver

Hello,

I have an application were a users org needs to exist before they can be created. I have a rule to create query for and create the org via a direct operation, but that rule doesn't appear to do anything. The trace doesn't show it and the remote loader doesn't show any POST operations.

Here is the rule:
<do-if>
<arg-conditions>
<and>
<if-local-variable mode="regex" name="orgID" op="not-equal">.+</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-add-dest-object class-name="org" direct="true">
<arg-dn>
<token-op-attr name="vmEnterpriseID"/>
</arg-dn>
</do-add-dest-object>
<do-set-local-variable name="querynodeset" scope="policy">
<arg-string>
<token-query class-name="org">
<arg-match-attr name="name">
<arg-value type="string">
<token-text xml:space="preserve">$axwayOrgName$</token-text>
</arg-value>
</arg-match-attr>
<arg-string>
<token-text xml:space="preserve">id</token-text>
</arg-string>
</token-query>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="orgID" scope="policy">
<arg-string>
<token-xpath expression='$querynodeset/attr[@attr-name="id"]/value'/>
</arg-string>
</do-set-local-variable>
</arg-actions>
<arg-actions/>
</do-if>


Here is a snip of the trace:
[09/18/18 08:22:58.802]:Axway ST:        Evaluating conditions.
[09/18/18 08:22:58.802]:Axway ST: (if-local-variable 'orgID' not-match ".+") = TRUE.
[09/18/18 08:22:58.803]:Axway ST: Performing if actions.
[09/18/18 08:22:58.804]:Axway ST: Action: do-add-dest-object(class-name="org",direct="true",arg-dn(token-op-attr("vmEnterpriseID"))).
[09/18/18 08:22:58.806]:Axway ST: arg-dn(token-op-attr("vmEnterpriseID"))
[09/18/18 08:22:58.807]:Axway ST: token-op-attr("vmEnterpriseID")
[09/18/18 08:22:58.807]:Axway ST: Token Value: "1777806".
[09/18/18 08:22:58.808]:Axway ST: Arg Value: "1777806".
[09/18/18 08:22:58.809]:Axway ST: Action: do-set-local-variable("querynodeset",scope="policy",token-query(class-name="org",arg-match-attr("name","$axwayOrgName$"),"id")).


Full trace: https://justpaste.it/70np3
Remote Loader: https://justpaste.it/4mgrg

Any help would be appreciated.
Thanks,
Jeremiah
Labels (1)
0 Likes
6 Replies
Knowledge Partner
Knowledge Partner

Re: direct operation with REST driver

jrmhscht;2487734 wrote:
Hello,

I have an application were a users org needs to exist before they can be created. I have a rule to create query for and create the org via a direct operation, but that rule doesn't appear to do anything. The trace doesn't show it and the remote loader doesn't show any POST operations.

Here is the rule:
<do-if>
<arg-conditions>
<and>
<if-local-variable mode="regex" name="orgID" op="not-equal">.+</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-add-dest-object class-name="org" direct="true">
<arg-dn>
<token-op-attr name="vmEnterpriseID"/>
</arg-dn>
</do-add-dest-object>
<do-set-local-variable name="querynodeset" scope="policy">
<arg-string>
<token-query class-name="org">
<arg-match-attr name="name">
<arg-value type="string">
<token-text xml:space="preserve">$axwayOrgName$</token-text>
</arg-value>
</arg-match-attr>
<arg-string>
<token-text xml:space="preserve">id</token-text>
</arg-string>
</token-query>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="orgID" scope="policy">
<arg-string>
<token-xpath expression='$querynodeset/attr[@attr-name="id"]/value'/>
</arg-string>
</do-set-local-variable>
</arg-actions>
<arg-actions/>
</do-if>


Here is a snip of the trace:
[09/18/18 08:22:58.802]:Axway ST:        Evaluating conditions.
[09/18/18 08:22:58.802]:Axway ST: (if-local-variable 'orgID' not-match ".+") = TRUE.
[09/18/18 08:22:58.803]:Axway ST: Performing if actions.
[09/18/18 08:22:58.804]:Axway ST: Action: do-add-dest-object(class-name="org",direct="true",arg-dn(token-op-attr("vmEnterpriseID"))).
[09/18/18 08:22:58.806]:Axway ST: arg-dn(token-op-attr("vmEnterpriseID"))
[09/18/18 08:22:58.807]:Axway ST: token-op-attr("vmEnterpriseID")
[09/18/18 08:22:58.807]:Axway ST: Token Value: "1777806".
[09/18/18 08:22:58.808]:Axway ST: Arg Value: "1777806".
[09/18/18 08:22:58.809]:Axway ST: Action: do-set-local-variable("querynodeset",scope="policy",token-query(class-name="org",arg-match-attr("name","$axwayOrgName$"),"id")).


Full trace: https://justpaste.it/70np3
Remote Loader: https://justpaste.it/4mgrg

Any help would be appreciated.
Thanks,
Jeremiah


Your first do-set-local-variable ends in an error, so probably that's why you're not seeing anything else from this policy. The query goes out and comes back, so the other system is at least doing something with it, but it looks like the query didn't return anything useful.

But it's not clear to me what you're trying to do here. You have the do-add-dest-object followed by two do-set-local-variable that then aren't used anywhere.
0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: direct operation with REST driver

I'll try explain more. The application requires an organization to exist before a user can be created. The user has to have the organization id attribute set when it is created. I have the organization name (vmEnterpriseID), but not the ID stored in the vault.

I am doing a query against the application (class = org) to get the organizationID if the organization name exists. This gets stored in the variable orgID and I later do a set destination attribute value with that. If the org exists, this works fine.

I just added error handling so the first query does not have errors when the org is missing. It now gets to the do-add-dest-object without any errors. After it should have created the org I query again (<do-set-local-variable name="querynodeset" scope="policy">) and use that to grab the orgID. This second query is again empty (so the xpath to set orgID fails) because the do-add-dest-object did not do anything:

[09/18/18 16:25:42.873]:Axway ST: Performing if actions.
[09/18/18 16:25:42.873]:Axway ST: Action: do-add-dest-object(class-name="org",direct="true",arg-dn(token-op-attr("vmEnterpriseID"))).
[09/18/18 16:25:42.873]:Axway ST: arg-dn(token-op-attr("vmEnterpriseID"))
[09/18/18 16:25:42.873]:Axway ST: token-op-attr("vmEnterpriseID")
[09/18/18 16:25:42.873]:Axway ST: Token Value: "1777806".
[09/18/18 16:25:42.873]:Axway ST: Arg Value: "1777806".

How can I get this to actually generate the POST to create the org?

Here is the complete rule if that helps:

<rule>
<description>Set organizationId for dealers</description>
<conditions>
<and>
<if-class-name mode="nocase" op="equal">user</if-class-name>
<if-src-dn op="in-subtree">data\users\Dealers</if-src-dn>
<if-op-attr name="vmEnterpriseID" op="available"/>
</and>
</conditions>
<actions>
<do-set-local-variable name="axwayOrgName" scope="policy">
<arg-string>
<token-op-attr name="vmEnterpriseID"/>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="querynodeset" scope="policy">
<arg-node-set>
<token-query class-name="org">
<arg-match-attr name="name">
<arg-value type="string">
<token-text xml:space="preserve">$axwayOrgName$</token-text>
</arg-value>
</arg-match-attr>
<arg-string>
<token-text xml:space="preserve">id</token-text>
</arg-string>
</token-query>
</arg-node-set>
</do-set-local-variable>
<do-if>
<arg-conditions>
<and>
<if-local-variable mode="regex" name="querynodeset" op="equal">.+</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-set-local-variable name="orgID" scope="policy">
<arg-string>
<token-xpath expression='$querynodeset/attr[@attr-name="id"]/value'/>
</arg-string>
</do-set-local-variable>
</arg-actions>
<arg-actions/>
</do-if>
<do-if>
<arg-conditions>
<and>
<if-local-variable mode="regex" name="orgID" op="not-equal">.+</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-add-dest-object class-name="org" direct="true">
<arg-dn>
<token-op-attr name="vmEnterpriseID"/>
</arg-dn>
</do-add-dest-object>
<do-set-local-variable name="querynodeset" scope="policy">
<arg-string>
<token-query class-name="org">
<arg-match-attr name="name">
<arg-value type="string">
<token-text xml:space="preserve">$axwayOrgName$</token-text>
</arg-value>
</arg-match-attr>
<arg-string>
<token-text xml:space="preserve">id</token-text>
</arg-string>
</token-query>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="orgID" scope="policy">
<arg-string>
<token-xpath expression='$querynodeset/attr[@attr-name="id"]/value'/>
</arg-string>
</do-set-local-variable>
</arg-actions>
<arg-actions/>
</do-if>
<do-if>
<arg-conditions>
<and>
<if-local-variable mode="regex" name="orgID" op="equal">.+</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-set-dest-attr-value name="organizationId">
<arg-value type="string">
<token-local-variable name="orgID"/>
</arg-value>
</do-set-dest-attr-value>
</arg-actions>
<arg-actions/>
</do-if>
</actions>
</rule>
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: direct operation with REST driver

On 2018-09-18 23:54, jrmhscht wrote:
> I just added error handling so the first query does not have errors when
> the org is missing. It now gets to the do-add-dest-object without any
> errors. After it should have created the org I query again
> (<do-set-local-variable name="querynodeset" scope="policy">) and use
> that to grab the orgID. This second query is again empty (so the xpath
> to set orgID fails) because the do-add-dest-object did not do anything:


Direct writes are only executed at the end of a policy. But the engine
never gets to that point because your query happens before that and
parsing its response gives an error:

[09/18/18 08:22:59.274]:Axway ST:
DirXML Log Event -------------------
Driver: \IDVDEV\system\driverset1\Axway
Channel: Subscriber
Object: \IDVDEV\data\users\Dealers\O26648
Status: Error
Message: Code(-9131) Error in
vnd.nds.stream://IDVDEV/system/driverset1/Axway/Subscriber/Company-sub-ctp-org#XmlData:64
: Error evaluating XPATH expression
'token-xpath("$querynodeset/attr[@attr-name="id"]/value")' :
com.novell.xml.xpath.XPathConversionException: no type may be converted
to a node-set.
[09/18/18 08:22:59.282]:Axway ST:End transaction.



See
https://www.netiq.com/communities/cool-solutions/delving-into-and-beyond-the-current-op-part-3/



--
Norbert
--
Norbert
Highlighted
Super Contributor.
Super Contributor.

Re: direct operation with REST driver

klasen;2487763 wrote:
Direct writes are only executed at the end of a policy.


Thanks for this. I'll make multiple policies and give it a try. The query that is failing depends on the direct write succeeding.
0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: direct operation with REST driver

Thanks for the help learning how direct policies work. This is working as I need it to now.
0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Re: direct operation with REST driver

> https://www.netiq.com/communities/cool-solutions/delving-into-and-beyond-the-current-op-part-3/

This article is when you let an Australian into Norway to work on IDM
projects. One of the better, more detailed, low level details of how the
engine works. I think we need more people like him!
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.