Vice Admiral
Vice Admiral
527 views

Add / Remove Operation Data to Current Operation context

Jump to solution

Hello

I have a local variable which holds current-operation as  "XDS" document

 

<do-set-local-variable name="local.EventCaptured" scope="policy">
<arg-node-set>
<token-local-variable name="current-op"/>
</arg-node-set>
</do-set-local-variable>

 

I want to to perform  add and remove "operation-data" from and into it this XDS document into local variable.

This xds document in node-set local variable could hold a previous "operation-data" already which needs to be replaced in case of  add.

Anyone can assist?

 

/Maqsood.

1 Solution

Accepted Solutions
Vice Admiral
Vice Admiral

to share with someone if anyone wants to know: (how to strip away operation-data from events)

 

<do-strip-xpath expression="./operation-data"/>

 

 /Maqsood.

View solution in original post

6 Replies
Knowledge Partner Knowledge Partner
Knowledge Partner

You simply use your variable instead of the document node it is referencing.

But why do you want to do this in a custom variable in the first place? Your variable is not a copy of $current-op, it is a reference to it. And $current-op is just a reference to to the current operation, which is also the context node. So it does not make any difference if you change the operation-data via tokens, in your custom variable, in $current-op or via xpath(.):

<?xml version="1.0" encoding="UTF-8"?><nds dtdversion="4.0" ndsversion="8.x">
	<source>
		<product version="4.8.2.0">DirXML</product>
		<contact>NetIQ Corporation</contact>
	</source>
	<input>
		<sync class-name="User"/>
	</input>
</nds>
Test :Applying policy: %+C%14Ctest%-C.
Test :  Applying to sync #1.
Test :    Evaluating selection criteria for rule 'by ref vs. by copy'.
Test :    Rule selected.
Test :    Applying rule 'by ref vs. by copy'.
Test :      Action: do-set-local-variable("my-ref-to-current-op",scope="policy",arg-node-set(token-local-variable("current-op"))).
Test :        arg-node-set(token-local-variable("current-op"))
Test :          token-local-variable("current-op")
Test :          Token Value: {<sync> @class-name = "User"}.
Test :          Arg Value: {<sync> @class-name = "User"}.
Test :      Action: do-set-op-property("via-token","true").
Test :        arg-string("true")
Test :          token-text("true")
Test :          Arg Value: "true".
Test :      Action: do-set-xml-attr("via-xpath","operation-data","true").
Test :        arg-string("true")
Test :          token-text("true")
Test :          Arg Value: "true".
Test :      Action: do-set-xml-attr("via-current-op","$current-op/operation-data","true").
Test :        arg-string("true")
Test :          token-text("true")
Test :          Arg Value: "true".
Test :      Action: do-set-xml-attr("via-my-ref-to-current-op","$my-ref-to-current-op/operation-data","true").
Test :        arg-string("true")
Test :          token-text("true")
Test :          Arg Value: "true".
Test :      Action: do-trace-message(token-xml-serialize(notrace="true",token-local-variable("my-ref-to-current-op"))).
Test :        arg-string(token-xml-serialize(notrace="true",token-local-variable("my-ref-to-current-op")))
Test :          token-xml-serialize(notrace="true",token-local-variable("my-ref-to-current-op"))
Test :            -- trace suppressed --
Test :          Arg Value: "<sync class-name="User">
	<operation-data via-current-op="true" via-my-ref-to-current-op="true" via-token="true" via-xpath="true"/>
</sync>".
Test :<sync class-name="User">
	<operation-data via-current-op="true" via-my-ref-to-current-op="true" via-token="true" via-xpath="true"/>
</sync>
Test :Policy returned:
Test :
<nds dtdversion="4.0" ndsversion="8.x">
  <source>
    <product version="4.8.2.0">DirXML</product>
    <contact>NetIQ Corporation</contact>
  </source>
  <input>
    <sync class-name="User">
      <operation-data via-current-op="true" via-my-ref-to-current-op="true" via-token="true" via-xpath="true"/>
    </sync>
  </input>
</nds>

 

If you want to obtain a copy of the current operation, you'd need to clone it by xpath or do something like xml-parse(xml-serialize($current-op)):

 

<?xml version="1.0" encoding="UTF-8"?><nds dtdversion="4.0" ndsversion="8.x">
	<source>
		<product version="4.8.2.0">DirXML</product>
		<contact>NetIQ Corporation</contact>
	</source>
	<input>
		<sync class-name="User"/>
	</input>
</nds>
Test :Applying policy: %+C%14Ctest%-C.
Test :  Applying to sync #1.
Test :    Evaluating selection criteria for rule 'by ref vs. by copy'.
Test :    Rule selected.
Test :    Applying rule 'by ref vs. by copy'.
Test :      Action: do-set-local-variable("my-copy-of-current-op",scope="policy",arg-node-set(token-xml-parse(token-xml-serialize(token-local-variable("current-op"))))).
Test :        arg-node-set(token-xml-parse(token-xml-serialize(token-local-variable("current-op"))))
Test :          token-xml-parse(token-xml-serialize(token-local-variable("current-op")))
Test :            token-xml-parse(token-xml-serialize(token-local-variable("current-op")))
Test :              token-xml-serialize(token-local-variable("current-op"))
Test :                token-xml-serialize(token-local-variable("current-op"))
Test :                  token-local-variable("current-op")
Test :                  Token Value: {<sync> @class-name = "User"}.
Test :                  Arg Value: {<sync> @class-name = "User"}.
Test :                Token Value: "<sync class-name="User"/>".
Test :              Arg Value: "<sync class-name="User"/>".
Test :          Token Value: {/}.
Test :          Arg Value: {/}.
Test :      Action: do-set-op-property("via-token-once-more","true").
Test :        arg-string("true")
Test :          token-text("true")
Test :          Arg Value: "true".
Test :      Action: do-trace-message(token-xml-serialize(notrace="true",token-local-variable("my-copy-of-current-op"))).
Test :        arg-string(token-xml-serialize(notrace="true",token-local-variable("my-copy-of-current-op")))
Test :          token-xml-serialize(notrace="true",token-local-variable("my-copy-of-current-op"))
Test :            -- trace suppressed --
Test :          Arg Value: "<sync class-name="User"/>".
Test :<sync class-name="User"/>
Test :Policy returned:
Test :
<nds dtdversion="4.0" ndsversion="8.x">
  <source>
    <product version="4.8.2.0">DirXML</product>
    <contact>NetIQ Corporation</contact>
  </source>
  <input>
    <sync class-name="User">
      <operation-data via-token-once-more="true"/>
    </sync>
  </input>
</nds>

 

______________________________________________
https://www.is4it.de/identity-access-management
Vice Admiral
Vice Admiral

@lhaeger  Thank you, i am actually designing  retry solution for "failed event" using your ECMAScript version  of DxQueue. That needs a XDS document as input.

 

What i am trying to do is:

/Producer:

1) When event is failed (which  i decide what a failed event is), i create a XML document and serialize (write to a text/xml file,  the content of xml files is my own with lots of metadata and  where  XDS  (based64Encoded) version is just a small parameter of it.

/Consumer:

2) I have written a Delimited Text driver which reads these input xml files,  parse xml file, and reads a XDS (decodes based64) version of XDS and  i want to add operation-data to it before i use your ECMAScript to Queue it the driver where from it generated the failed event. Operation Data will be used by Producer to decide retry logic and used for logging and debugging etc.

 

/Maqsood.

Vice Admiral
Vice Admiral

So I solved this way:

 

 

<do-append-xml-element expression="$local.sub.etp.EventtoXds/modify[last()]|add[last()]" name="operation-data"/>
			<do-set-xml-attr expression="$local.sub.etp.EventtoXds//operation-data" name="prop.retried.Event">
				<arg-string>
					<token-text xml:space="preserve">true</token-text>
				</arg-string>
			</do-set-xml-attr>
			<do-append-xml-element expression="$local.sub.etp.EventtoXds//operation-data" name="retry"/>
			<do-append-xml-element expression="$local.sub.etp.EventtoXds//operation-data/retry" name="idmserver"/>
			<do-append-xml-text expression="$local.sub.etp.EventtoXds//operation-data/retry/idmserver">
				<arg-string>
					<token-local-variable name="local.sub.etp.IDMServer"/>
				</arg-string>
			</do-append-xml-text>

 

but @lhaeger  do you know how to strip all the operation-data from the current-operation?

0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

______________________________________________
https://www.is4it.de/identity-access-management
Vice Admiral
Vice Admiral

to share with someone if anyone wants to know: (how to strip away operation-data from events)

 

<do-strip-xpath expression="./operation-data"/>

 

 /Maqsood.

View solution in original post

Knowledge Partner Knowledge Partner
Knowledge Partner

@maqsood wrote:

@lhaeger  ... using your ECMAScript version  of DxQueue.

Just a small comment so nobody gets confused: the Java version was developed by Peter Lambrechtsen and the ECMA version by Alex McHugh. Honor where honor is due...

______________________________________________
https://www.is4it.de/identity-access-management
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.