buslogic.xslt 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2021
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xsl:stylesheet version="1.0"
  9. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  10. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  11. xmlns:reqhelpers="http://developer.cognos.com/schemas/xts-cm/1/reqhelpers"
  12. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  13. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  14. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  15. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  16. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  17. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  18. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  19. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  20. xmlns:out="dummy-uri"
  21. exclude-result-prefixes="xsl send reqhelpers xts bus">
  22. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  23. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  24. <!--
  25. ===============================================================================================
  26. send:request - Builds an xts:request that contains a valid BIBus request. The caller can
  27. ignore the details of the SOAP:Header, and simply supply the contents of
  28. the bus:request.
  29. ===============================================================================================
  30. -->
  31. <xsl:variable name="soapaction-map">
  32. <entry name="$cm$">http://www.ibm.com/xmlns/prod/cognos/contentManagerService/202004/</entry>
  33. <entry name="$REPOSITORY$">http://www.ibm.com/xmlns/prod/cognos/contentManagerService/202004/</entry>
  34. <entry name="$cm2$">http://www.ibm.com/xmlns/prod/cognos/contentManagerService/202004/</entry>
  35. <entry name="$warp$">http://www.ibm.com/xmlns/prod/cognos/reportService/202004/</entry>
  36. <entry name="$xts$">xts.run</entry>
  37. <entry name="$dispatcher$">http://www.ibm.com/xmlns/prod/cognos/dispatcherService/202004/</entry>
  38. <entry name="$monitorService$">http://www.ibm.com/xmlns/prod/cognos/monitorService/202004/</entry>
  39. <entry name="$eventManagementService$">http://www.ibm.com/xmlns/prod/cognos/eventManagementService/202004/</entry>
  40. <entry name="$agentService$">http://www.ibm.com/xmlns/prod/cognos/agentService/202004/</entry>
  41. <entry name="$deliveryService$">http://www.ibm.com/xmlns/prod/cognos/deliveryService/202004/</entry>
  42. <entry name="$metadataService$">http://www.ibm.com/xmlns/prod/cognos/metadataService/202004/</entry>
  43. <entry name="$queryService$">http://www.ibm.com/xmlns/prod/cognos/queryService/202004/</entry>
  44. <entry name="$cmCache$">http://www.ibm.com/xmlns/prod/cognos/contentManagerCacheService/202004/</entry>
  45. <entry name="$indexDataService$">http://www.ibm.com/xmlns/prod/cognos/indexDataService/202004/</entry>
  46. <entry name="$cam$">http://www.ibm.com/xmlns/prod/cognos/sacamsrvc-auth/202004/</entry>
  47. <entry name="$cam-internal$">http://www.ibm.com/xmlns/prod/cognos/sacamsrvc-internal/202004/</entry>
  48. </xsl:variable>
  49. <xsl:template match="send:request">
  50. <xts:request>
  51. <xsl:choose>
  52. <xsl:when test="@provider='cam'">
  53. <xsl:variable name="key">
  54. <xsl:choose>
  55. <xsl:when test="@internal='true'">$cam-internal$</xsl:when>
  56. <xsl:otherwise>$cam$</xsl:otherwise>
  57. </xsl:choose>
  58. </xsl:variable>
  59. <xsl:attribute name="protocol">BUS</xsl:attribute>
  60. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  61. <xsl:attribute name="soapAction"><xsl:value-of select="$soapaction-map/entry[@name=$key]"/></xsl:attribute>
  62. <xsl:attribute name="outputHeader">true</xsl:attribute>
  63. </xsl:when>
  64. <xsl:when test="@provider='cm'">
  65. <xsl:attribute name="protocol">BUS</xsl:attribute>
  66. <xsl:attribute name="href">bus://cm</xsl:attribute>
  67. <xsl:attribute name="soapAction"><xsl:value-of select="$soapaction-map/entry[@name='$cm$']"/></xsl:attribute>
  68. <xsl:attribute name="outputHeader">true</xsl:attribute>
  69. </xsl:when>
  70. <xsl:when test="@provider='REPOSITORY'">
  71. <xsl:attribute name="protocol">REPOSITORY</xsl:attribute>
  72. <xsl:attribute name="href">bus://cm</xsl:attribute>
  73. <xsl:attribute name="soapAction"><xsl:value-of select="$soapaction-map/entry[@name='$REPOSITORY$']"/></xsl:attribute>
  74. <xsl:attribute name="outputHeader">true</xsl:attribute>
  75. <xsl:attribute name="command"><xsl:value-of select="@command"/></xsl:attribute>
  76. <xsl:attribute name="returnType"><xsl:value-of select="@returnType"/></xsl:attribute>
  77. </xsl:when>
  78. <xsl:when test="@provider='cm2'">
  79. <xsl:attribute name="protocol">CM</xsl:attribute>
  80. <xsl:attribute name="href">cm://cm</xsl:attribute>
  81. <xsl:attribute name="soapAction"><xsl:value-of select="$soapaction-map/entry[@name='$cm2$']"/></xsl:attribute>
  82. <xsl:attribute name="outputHeader">true</xsl:attribute>
  83. </xsl:when>
  84. <xsl:when test="@provider='warp'">
  85. <xsl:attribute name="protocol">BUS</xsl:attribute>
  86. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  87. <xsl:attribute name="soapAction">
  88. <xsl:choose>
  89. <xsl:when test="@soapAction and @soapAction!=''"><xsl:value-of select="@soapAction"/></xsl:when>
  90. <xsl:otherwise><xsl:value-of select="$soapaction-map/entry[@name='$warp$']"/></xsl:otherwise>
  91. </xsl:choose>
  92. <xsl:value-of select="@affinity"/>
  93. </xsl:attribute>
  94. <xsl:attribute name="outputHeader">true</xsl:attribute>
  95. </xsl:when>
  96. <xsl:when test="@provider='xts'">
  97. <xsl:attribute name="protocol">BUS</xsl:attribute>
  98. <xsl:attribute name="href">bus://xts</xsl:attribute>
  99. <xsl:attribute name="soapAction"><xsl:value-of select="$soapaction-map/entry[@name='$xts$']"/></xsl:attribute>
  100. <xsl:attribute name="outputHeader">true</xsl:attribute>
  101. </xsl:when>
  102. <xsl:when test="@provider='nav'">
  103. <xsl:attribute name="protocol">NAV</xsl:attribute>
  104. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  105. <xsl:attribute name="outputHeader">false</xsl:attribute>
  106. </xsl:when>
  107. <xsl:when test="@provider='dispatcher'">
  108. <xsl:attribute name="protocol">BUS</xsl:attribute>
  109. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  110. <xsl:attribute name="soapAction"><xsl:value-of select="$soapaction-map/entry[@name='$dispatcher$']"/></xsl:attribute>
  111. <xsl:attribute name="outputHeader">true</xsl:attribute>
  112. </xsl:when>
  113. <xsl:when test="@provider='monitorService'">
  114. <xsl:attribute name="protocol">BUS</xsl:attribute>
  115. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  116. <xsl:attribute name="soapAction">
  117. <xsl:value-of select="$soapaction-map/entry[@name='$monitorService$']"/>
  118. <xsl:if test="@affinity">
  119. <xsl:value-of select="concat('.', @affinity)"/>
  120. </xsl:if>
  121. </xsl:attribute>
  122. <xsl:attribute name="outputHeader">true</xsl:attribute>
  123. <xsl:attribute name="responseEnvelope">
  124. <xsl:choose>
  125. <xsl:when test="@responseEnvelope='true'">true</xsl:when>
  126. <xsl:otherwise>false</xsl:otherwise>
  127. </xsl:choose>
  128. </xsl:attribute>
  129. </xsl:when>
  130. <xsl:when test="@provider='eventManagementService'">
  131. <xsl:attribute name="protocol">BUS</xsl:attribute>
  132. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  133. <xsl:attribute name="soapAction">
  134. <xsl:value-of select="$soapaction-map/entry[@name='$eventManagementService$']"/>
  135. <xsl:if test="@affinity">
  136. <xsl:value-of select="concat('.', @affinity)"/>
  137. </xsl:if>
  138. </xsl:attribute>
  139. <xsl:attribute name="outputHeader">true</xsl:attribute>
  140. </xsl:when>
  141. <xsl:when test="@provider='agentService'">
  142. <xsl:attribute name="protocol">BUS</xsl:attribute>
  143. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  144. <xsl:attribute name="soapAction"><xsl:value-of select="$soapaction-map/entry[@name='$agentService$']"/></xsl:attribute>
  145. <xsl:attribute name="outputHeader">true</xsl:attribute>
  146. </xsl:when>
  147. <xsl:when test="@provider='deliveryService'">
  148. <xsl:attribute name="protocol">BUS</xsl:attribute>
  149. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  150. <xsl:attribute name="soapAction"><xsl:value-of select="$soapaction-map/entry[@name='$deliveryService$']"/></xsl:attribute>
  151. <xsl:attribute name="outputHeader">true</xsl:attribute>
  152. </xsl:when>
  153. <xsl:when test="@provider='metadataService'">
  154. <xsl:attribute name="protocol">BUS</xsl:attribute>
  155. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  156. <xsl:attribute name="soapAction">
  157. <xsl:value-of select="$soapaction-map/entry[@name='$metadataService$']"/>
  158. <xsl:value-of select="@affinity"/>
  159. </xsl:attribute>
  160. <xsl:attribute name="outputHeader">true</xsl:attribute>
  161. </xsl:when>
  162. <xsl:when test="@provider='queryService'">
  163. <xsl:attribute name="protocol">BUS</xsl:attribute>
  164. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  165. <xsl:attribute name="soapAction">
  166. <xsl:value-of select="$soapaction-map/entry[@name='$queryService$']"/>
  167. <xsl:value-of select="@affinity"/>
  168. </xsl:attribute>
  169. <xsl:attribute name="outputHeader">true</xsl:attribute>
  170. </xsl:when>
  171. <xsl:when test="@provider='cmCache'">
  172. <xsl:attribute name="protocol">BUS</xsl:attribute>
  173. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  174. <xsl:attribute name="soapAction"><xsl:value-of select="$soapaction-map/entry[@name='$cmCache$']"/></xsl:attribute>
  175. <xsl:attribute name="outputHeader">true</xsl:attribute>
  176. <xsl:attribute name="responseEnvelope">false</xsl:attribute>
  177. </xsl:when>
  178. </xsl:choose>
  179. <xsl:copy-of select="@*[name() != 'provider' and name() != 'affinity' and name() != 'directedRequest' and name()!='soapAction']"/>
  180. <!-- add pre/post-transformation stylesheet for cm2 -->
  181. <xsl:if test="@provider='cm2'">
  182. <xsl:if test="@prexslt">
  183. <xts:param name="prexslt"><xsl:value-of select="@prexslt"/></xts:param>
  184. </xsl:if>
  185. <xsl:if test="@postxslt">
  186. <xts:param name="postxslt"><xsl:value-of select="@postxslt"/></xts:param>
  187. </xsl:if>
  188. </xsl:if>
  189. <!-- copy any xts:output-param elements -->
  190. <xsl:copy-of select="*[local-name()='output-param']"/>
  191. <SOAP-ENV:Envelope>
  192. <SOAP-ENV:Header>
  193. <xsl:choose>
  194. <xsl:when test="@useQueryNodeHeader='true'">
  195. <xts:queryNode select="/root/header/*[local-name()='biBusHeader']"/>
  196. </xsl:when>
  197. <xsl:otherwise>
  198. <!--
  199. The attribute name says it all, the xs namespace is used in xsi:type checking. This is a kluge, it forces the xs namespace to be defined
  200. and without it can cause grief for come chained requests.
  201. This must be defined since there are services that do strong xsi:type namespaced value checking and when that namespace is
  202. ABSENT, errors will occur! THIS HAS NO IMPACT ON THE REQUEST ITSELF!
  203. -->
  204. <bus:biBusHeader xsi:type="bus:biBusHeader" xs:usedIn="xsi_type_checking">
  205. <out:choose>
  206. <out:when test="/root/header/*[local-name()='biBusHeader']">
  207. <!-- Handle tracking info passed in as m_tracking -->
  208. <xsl:choose>
  209. <!-- If the attribute directedRequest is present, then it's a xpath to a dispatcher. Make sure we add it's value as a child of trakking. -->
  210. <xsl:when test="string(@directedRequest) != ''">
  211. <bus:tracking xsi:type="bus:tracking">
  212. <out:copy-of select="/root/header/bus:biBusHeader/bus:tracking/*[local-name()!='conversationContext']"/>
  213. <bus:conversationContext xsi:type="bus:conversationContext">
  214. <out:copy-of select="/root/header/bus:biBusHeader/bus:tracking/bus:conversationContext/*[local-name()!='nodeID']"/>
  215. <nodeID xsi:type="xsd:string">
  216. <out:value-of select="{@directedRequest}"/>
  217. </nodeID>
  218. </bus:conversationContext>
  219. </bus:tracking>
  220. </xsl:when>
  221. <xsl:otherwise>
  222. <out:choose>
  223. <out:when test="/root/env/param[@name='m_tracking'] and /root/env/param[@name='m_tracking']!='' and ('{@affinity}'='.high' or '{@affinity}'='.absolute' or '{@affinity}'='.control')">
  224. <out:value-of select="xtsext:web64decode( xtsext:cafaction( 'sign_unwrap', string( /root/env/param[@name='m_tracking'] )), true() )" disable-output-escaping="yes"/>
  225. </out:when>
  226. <out:otherwise>
  227. <out:copy-of select="/root/header/bus:biBusHeader/bus:tracking"/>
  228. </out:otherwise>
  229. </out:choose>
  230. </xsl:otherwise>
  231. </xsl:choose>
  232. <!-- set up the rest of the header elements -->
  233. <out:for-each select="/root/header/bus:biBusHeader/*">
  234. <out:choose>
  235. <!-- if there is a specified ui.routingServerGroup - then wipe existing one, new routing possible -->
  236. <out:when test="local-name()='routing' and string(/root/env/param[@name='ui.routingServerGroup'])!=''"/>
  237. <out:when test="local-name()='tracking'"/>
  238. <out:when test="local-name()='hdrSession'">
  239. <xsl:choose>
  240. <xsl:when test="starts-with(@provider, 'cm')">
  241. <!-- trim the bus header before sending to cm -->
  242. <out:copy>
  243. <out:copy-of select="@*"/>
  244. <out:choose>
  245. <!-- We will only forward the for parameter if the advanced setting "forwardParamsToCM" is set to true -->
  246. <out:when test="not(/root/configProps/param[@name='cc']/property[@name='forwardURLParamsToCM'] = 'true')">
  247. <bus:formFieldVars xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:formFieldVar[]">
  248. <out:copy-of select="bus:formFieldVars/item[starts-with(name, 'CAM')]"/>
  249. </bus:formFieldVars>
  250. <out:copy-of select="*[local-name() != 'formFieldVars']"/>
  251. </out:when>
  252. <out:otherwise>
  253. <out:copy-of select="*"/>
  254. </out:otherwise>
  255. </out:choose>
  256. </out:copy>
  257. </xsl:when>
  258. <xsl:otherwise>
  259. <out:copy>
  260. <out:copy-of select="@*"/>
  261. <out:copy-of select="*"/>
  262. </out:copy>
  263. </xsl:otherwise>
  264. </xsl:choose>
  265. </out:when>
  266. <out:when test="local-name()='dispatcherTransportVars'">
  267. <xsl:choose>
  268. <xsl:when test="starts-with(@provider, 'cm')">
  269. <!-- add requester re:RTC story 37223 -->
  270. <out:copy>
  271. <out:copy-of select="@*"/>
  272. <item xsi:type="bus:dispatcherTransportVar">
  273. <name xsi:type="xsd:string">requester</name>
  274. <value xsi:type="xsd:string">
  275. <xsl:choose>
  276. <xsl:when test="@requester and string(@requester) != '' ">
  277. <xsl:value-of select="@requester"/>
  278. </xsl:when>
  279. <xsl:otherwise><xsl:text/>ps<xsl:text/></xsl:otherwise>
  280. </xsl:choose>
  281. </value>
  282. </item>
  283. <out:copy-of select="*"/>
  284. </out:copy>
  285. </xsl:when>
  286. <xsl:otherwise>
  287. <out:copy>
  288. <out:copy-of select="@*"/>
  289. <out:copy-of select="*"/>
  290. </out:copy>
  291. </xsl:otherwise>
  292. </xsl:choose>
  293. </out:when>
  294. <out:otherwise>
  295. <out:copy>
  296. <out:copy-of select="@*"/>
  297. <!-- copy child elements except the CAMCredentialPath -->
  298. <out:copy-of select="*[local-name() != 'CAMCredentialPath']"/>
  299. </out:copy>
  300. </out:otherwise>
  301. </out:choose>
  302. </out:for-each>
  303. </out:when>
  304. </out:choose>
  305. <!-- routing required, allow routing tag to be passed in request re:RTC 14922 bulk migration task-->
  306. <xsl:choose>
  307. <xsl:when test="@routing">
  308. <bus:routing xsi:type="bus:routingInfo">
  309. <routingServerGroup><xsl:value-of select="@routing"/></routingServerGroup>
  310. </bus:routing>
  311. </xsl:when>
  312. <xsl:otherwise>
  313. <out:if test="string(/root/env/param[@name='ui.routingServerGroup'])!=''">
  314. <bus:routing xsi:type="bus:routingInfo">
  315. <routingServerGroup>
  316. <out:value-of select="/root/env/param[@name='ui.routingServerGroup']"/>
  317. </routingServerGroup>
  318. </bus:routing>
  319. </out:if>
  320. </xsl:otherwise>
  321. </xsl:choose>
  322. </bus:biBusHeader>
  323. </xsl:otherwise>
  324. </xsl:choose>
  325. </SOAP-ENV:Header>
  326. <SOAP-ENV:Body>
  327. <xsl:apply-templates/>
  328. </SOAP-ENV:Body>
  329. </SOAP-ENV:Envelope>
  330. </xts:request>
  331. </xsl:template>
  332. <!--Request helpers begins-->
  333. <xsl:template match="reqhelpers:request">
  334. <xts:request>
  335. <xsl:for-each select="./@*">
  336. <xsl:choose>
  337. <xsl:when test="name() = 'soapAction'">
  338. <xsl:attribute name="soapAction">
  339. <xsl:call-template name="reqhelpers-expand-macros">
  340. <xsl:with-param name="map" select="$soapaction-map"/>
  341. <xsl:with-param name="value" select="."/>
  342. </xsl:call-template>
  343. </xsl:attribute>
  344. </xsl:when>
  345. <xsl:otherwise>
  346. <xsl:attribute name="{name()}">
  347. <xsl:value-of select="."/>
  348. </xsl:attribute>
  349. </xsl:otherwise>
  350. </xsl:choose>
  351. </xsl:for-each>
  352. <xsl:apply-templates/>
  353. </xts:request>
  354. </xsl:template>
  355. <xsl:template name="reqhelpers-expand-macros">
  356. <xsl:param name="map"/>
  357. <xsl:param name="value"/>
  358. <xsl:variable name="p">
  359. <xsl:if test="contains($value, '$')"><xsl:value-of select="substring-after($value, '$')"/></xsl:if>
  360. </xsl:variable>
  361. <xsl:variable name="q">
  362. <xsl:if test="contains($p, '$')"><xsl:value-of select="substring-before($p, '$')"/></xsl:if>
  363. </xsl:variable>
  364. <xsl:variable name="name" select="concat('$', $q, '$')"/>
  365. <xsl:choose>
  366. <xsl:when test="$map/entry[@name=$name]">
  367. <xsl:value-of select="xtsext:replace($value, $name, $map/entry[@name=$name])"/>
  368. </xsl:when>
  369. <xsl:otherwise>
  370. <xsl:value-of select="$value"/>
  371. </xsl:otherwise>
  372. </xsl:choose>
  373. </xsl:template>
  374. <!--Request helpers ends-->
  375. <xsl:template match="*[local-name()='output-param']"/>
  376. <xsl:template match="*">
  377. <xsl:copy>
  378. <xsl:copy-of select="@*"/>
  379. <xsl:apply-templates/>
  380. </xsl:copy>
  381. </xsl:template>
  382. </xsl:stylesheet>