onebox.xts 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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, 2019
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xts:morphlet version="1.0" messageBase="messages/portal.xml, messages/portalRL.xml" xmlns:xts="http://developer.cognos.com/schemas/xts/">
  13. <!--
  14. security - if (somehow) we got here without a passport, return an empty response.
  15. -->
  16. <xts:block id="security" processor="XML" type="exec" mode="interpret" mandatory="false"
  17. condition=".[ string(/root/credential/param/*/CAMPassport/id) = '' ]">
  18. <xts:sequence faultSelect="/root/output">
  19. <xts:append select="/root/output" option="part" faultBlock="error-part">
  20. <xts:transform processor="XSLT" src="onebox/gen-module.xslt" faultBlock="error-part">
  21. <xts:param name="logicsheet">logicsheets/portal.xsl</xts:param>
  22. <xts:param name="messageBase">messages/portal.xml</xts:param>
  23. <xts:param name="messageBase">messages/portalRL.xml</xts:param>
  24. <xts:param name="parameter">gw=<xts:queryValue select="/root/configProps/param[@name='cps']/property[@name='gateway']"/></xts:param>
  25. <root/>
  26. </xts:transform>
  27. </xts:append>
  28. </xts:sequence>
  29. </xts:block>
  30. <!--
  31. ===============================================================================================
  32. config - read in the map table if there is one.
  33. - also read in the capabilities for the user.
  34. ===============================================================================================
  35. -->
  36. <xts:block id="config" processor="XML" type="exec" mode="interpret" mandatory="false" dependency="security"
  37. condition=".[ string(/root/credential/param/*/CAMPassport/id) != '' ]">
  38. <xts:sequence>
  39. <xts:append faultBlock="ignore">
  40. <xts:request name="FILEREAD" target="onebox/map.xml" faultBlock="ignore" cache="false"/>
  41. </xts:append>
  42. </xts:sequence>
  43. <xts:sequence>
  44. <xts:append>
  45. <capabilities>
  46. <xts:request href="bus://cm" protocol="BUS" outputHeader="true" faultBlock="ignore"
  47. soapAction="http://www.ibm.com/xmlns/prod/cognos/contentManagerService/201904/">
  48. <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  49. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  50. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  51. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/">
  52. <SOAP-ENV:Header>
  53. <xts:queryNode select="/root/header/*[local-name()='biBusHeader']"/>
  54. </SOAP-ENV:Header>
  55. <SOAP-ENV:Body>
  56. <bus:query>
  57. <search xsi:type="xsd:string">~~</search>
  58. <properties xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="cm:propEnum[]">
  59. <item xsi:type="cm:propEnum">userCapabilities</item>
  60. </properties>
  61. </bus:query>
  62. </SOAP-ENV:Body>
  63. </SOAP-ENV:Envelope>
  64. </xts:request>
  65. </capabilities>
  66. </xts:append>
  67. </xts:sequence>
  68. </xts:block>
  69. <!--
  70. ===============================================================================================
  71. getObjects - get object class names
  72. ===============================================================================================
  73. -->
  74. <xts:block id="classNames" type="exec" mode="input" processor="XML" path="/portal/uiExtensions.xml"
  75. condition=".[ string(/root/credential/param/*/CAMPassport/id) != '' ]">
  76. <xts:logicsheet path="/logicsheets/uiobjects/uiobjects_names.xslt"/>
  77. </xts:block>
  78. <!--
  79. ===============================================================================================
  80. request - do the work
  81. ===============================================================================================
  82. -->
  83. <xts:block id="request" processor="XSLT" type="exec" mode="interpret" dependency="config classNames"
  84. condition=".[ string(/root/credential/param/*/CAMPassport/id) != '' ]">
  85. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  86. xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
  87. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  88. xmlns:string="java:java.lang.String"
  89. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  90. xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
  91. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  92. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  93. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  94. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  95. exclude-result-prefixes="xos xtsext string bus nav xsd xsi SOAP-ENC SOAP-ENV xts">
  96. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  97. <xsl:key name="env-param" match="/root/env/param" use="@name"/>
  98. <xsl:key name="http-param" match="/root/http/param" use="@name"/>
  99. <xsl:key name="system-param" match="/root/system/param" use="@name"/>
  100. <xsl:variable name="userCanUseIndexSearch" select="string(/root/configProps/param[@name='cc']/property[@name='portal.disableindexsearch']) != 'true' and
  101. string(/root/configProps/param[@name='cc']/property[@name='edition']) != 'mid-market'"/>
  102. <xsl:variable name="cm-cache-value">
  103. <xsl:if test="key('system-param', 'http-cache') = 'true' and key('http-param', 'CACHE-CONTROL') != 'no-cache'">
  104. <xsl:value-of select="key('http-param', 'IF-NONE-MATCH')"/>
  105. </xsl:if>
  106. </xsl:variable>
  107. <xsl:variable name="gw">
  108. <xsl:value-of select="/root/configProps/param[@name='cps']/property[@name='gateway']"/>
  109. </xsl:variable>
  110. <xsl:variable name="wc">
  111. <xsl:value-of select="substring-before(/root/configProps/param[@name='cps']/property[@name='gateway'], '/cgi-bin')"/>
  112. </xsl:variable>
  113. <xsl:variable name="url-prefix">
  114. <xsl:value-of select="$gw"/>
  115. <xsl:value-of select="xtsext:substringBeforeLast(key('http-param', 'PATH_INFO'), '/')"/>
  116. </xsl:variable>
  117. <xsl:variable name="matches"
  118. select="/root/onebox/module[@oneboxName=key('env-param', 'oneboxName')]/mapEntries/mapEntry/path[
  119. ../@provider = 'cm' and
  120. string:matches( string:new( key('env-param', 'query') ), ../regex )]"/>
  121. <xsl:variable name="cmm-matches"
  122. select="/root/onebox/module[@oneboxName=key('env-param', 'oneboxName')]/mapEntries/mapEntry[
  123. @provider = 'mm' and
  124. string:matches( string:new( key('env-param', 'query') ), regex )]"/>
  125. <xsl:variable name="path">
  126. <xsl:for-each select="$matches">
  127. <xsl:if test="position() > 1">
  128. <xsl:text/> | <xsl:text/>
  129. </xsl:if>
  130. <xsl:text/>defaultOutput(<xsl:text/>
  131. <xsl:value-of select="."/>
  132. <xsl:text/>)<xsl:text/>
  133. <xsl:if test="@type = 'image'">
  134. <xsl:text/>/graphic<xsl:text/>
  135. </xsl:if>
  136. </xsl:for-each>
  137. </xsl:variable>
  138. <xsl:variable name="nav-path">
  139. <xsl:for-each select="$matches">
  140. <xsl:if test="position() > 1">
  141. <xsl:text/> | <xsl:text/>
  142. </xsl:if>
  143. <xsl:value-of select="."/>
  144. </xsl:for-each>
  145. </xsl:variable>
  146. <xsl:template match="/">
  147. <xts:sequence faultSelect="/root/output">
  148. <xts:append select="/root/output" faultBlock="error-part">
  149. <xts:transform processor="XSLT" src="onebox/gen-module.xslt" faultBlock="error-part">
  150. <xts:param name="logicsheet">logicsheets/portal.xsl</xts:param>
  151. <xts:param name="messageBase">messages/portal.xml</xts:param>
  152. <xts:param name="messageBase">messages/portalRL.xml</xts:param>
  153. <xts:param name="parameter">gw=<xsl:value-of select="$gw"/></xts:param>
  154. <!-- Just in case we get XHTML, we need to define these entities -->
  155. <xsl:text disable-output-escaping="yes">
  156. &lt;!DOCTYPE blah [
  157. &lt;!ENTITY nbsp &quot;&amp;#160;&quot;>
  158. &lt;!ENTITY nl &quot;&amp;#10;&quot;>
  159. &lt;!ENTITY copy &quot;&amp;#169;&quot;>
  160. ]>
  161. </xsl:text>
  162. <root>
  163. <canuseindexsearch><xsl:value-of select="$userCanUseIndexSearch"/></canuseindexsearch>
  164. <xsl:choose>
  165. <xsl:when test=" $path != '' ">
  166. <!-- we got a match to one of the regex's for CM content -->
  167. <xts:transform src="onebox/get-output.xslt" processor="XSLT" faultBlock="error">
  168. <xts:request href="bus://cm" protocol="BUS" outputHeader="true" faultBlock="error"
  169. soapAction="http://www.ibm.com/xmlns/prod/cognos/contentManagerService/201904/">
  170. <SOAP-ENV:Envelope >
  171. <SOAP-ENV:Header>
  172. <xsl:copy-of select="/root/header/bus:biBusHeader"/>
  173. </SOAP-ENV:Header>
  174. <SOAP-ENV:Body>
  175. <bus:query>
  176. <requests xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="cm:queryRequest[]">
  177. <item xsi:type="cm:queryRequest">
  178. <search xsi:type="xsd:string">
  179. <xsl:value-of select="$nav-path"/>
  180. </search>
  181. <properties xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="cm:propEnum[]">
  182. <item xsi:type="cm:propEnum">defaultName</item>
  183. <item xsi:type="cm:propEnum">storeID</item>
  184. <item xsi:type="cm:propEnum">searchPath</item>
  185. </properties>
  186. </item>
  187. <item xsi:type="cm:queryRequest">
  188. <search xsi:type="xsd:string">
  189. <xsl:value-of select="$path"/>
  190. </search>
  191. <properties xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="cm:propEnum[]">
  192. <item xsi:type="cm:propEnum">storeID</item>
  193. <item xsi:type="cm:propEnum">format</item>
  194. <item xsi:type="cm:propEnum">dataType</item>
  195. <item xsi:type="cm:propEnum">data</item>
  196. <item xsi:type="cm:propEnum">dataSize</item>
  197. </properties>
  198. </item>
  199. </requests>
  200. </bus:query>
  201. </SOAP-ENV:Body>
  202. </SOAP-ENV:Envelope>
  203. </xts:request>
  204. </xts:transform>
  205. </xsl:when>
  206. <xsl:otherwise>
  207. <xsl:choose>
  208. <xsl:when test="$cmm-matches">
  209. <!-- got a match to a regex for CMM content -->
  210. <metrics>
  211. <packagePath><xsl:value-of select="$cmm-matches/path"/></packagePath>
  212. <xts:request protocol="GET" faultBlock="error">
  213. <xsl:attribute name="href">
  214. <xsl:choose>
  215. <xsl:when test="string($cmm-matches/url) != ''">
  216. <xsl:value-of select="$cmm-matches/url"/>
  217. </xsl:when>
  218. <xsl:otherwise>
  219. <xsl:value-of select="/root/configProps/param[@name='cps']/property[@name='internalDispatcher']"/>
  220. <xsl:text/>?b_action=mms.run&amp;path=/controller&amp;pid=ob_server<xsl:text/>
  221. </xsl:otherwise>
  222. </xsl:choose>
  223. <xsl:text/>&amp;ui.packageName=<xsl:value-of select="$cmm-matches/path"/>
  224. <xsl:text/>&amp;query=<xsl:value-of select="xtsext:urlencode(key('env-param', 'query'))"/>
  225. <xsl:text/>&amp;lang=<xsl:value-of select="xtsext:urlencode(key('env-param', 'lang'))"/>
  226. </xsl:attribute>
  227. <xts:param name="timeout">10000</xts:param>
  228. <xts:param name="header">Cookie=cam_passport=<xsl:value-of select="string(/root/cookies/cookie[@name='cam_passport'])"/>
  229. </xts:param>
  230. </xts:request>
  231. </metrics>
  232. </xsl:when>
  233. <xsl:otherwise>
  234. <!-- Just do a search. -->
  235. <xsl:choose>
  236. <xsl:when test="$userCanUseIndexSearch">
  237. <xsl:variable name="cs-doc">
  238. <cs:document xmlns:cs="http://developer.cognos.com/schemas/cs/">
  239. <cs:request>
  240. <cs:searchQuery>
  241. <cs:terms><xsl:value-of select="key('env-param', 'query')"/></cs:terms>
  242. <cs:requestParameters>
  243. <cs:searchType>standard</cs:searchType>
  244. <cs:pageSize>4</cs:pageSize>
  245. <cs:includeSearchQuery>false</cs:includeSearchQuery>
  246. <cs:includeSearchConversation>true</cs:includeSearchConversation>
  247. <cs:includeSecurityContext>false</cs:includeSecurityContext>
  248. <cs:typeList/>
  249. </cs:requestParameters>
  250. </cs:searchQuery>
  251. </cs:request>
  252. </cs:document>
  253. </xsl:variable>
  254. <burgundy>
  255. <xts:transform src="onebox/get-output.xslt" processor="XSLT" faultBlock="error">
  256. <xts:request href="bus://dispatcher" protocol="BUS" soapAction="indexSearchService" responseEnvelope="false" outputHeader="true" faultBlock="error">
  257. <SOAP-ENV:Envelope xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  258. <SOAP-ENV:Header>
  259. <xsl:copy-of select="/root/header/bus:biBusHeader"/>
  260. </SOAP-ENV:Header>
  261. <SOAP-ENV:Body>
  262. <ns:runSpecification xmlns:ns="http://developer.cognos.com/schemas/indexSearchService/1/">
  263. <specification xsi:type="bus:indexSearchServiceSpecification">
  264. <value xsi:type="bus:specification">
  265. <xts:transform name="XMLEncode">
  266. <xsl:copy-of select="$cs-doc"/>
  267. </xts:transform>
  268. </value>
  269. </specification>
  270. <options xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:option[3]">
  271. <item xsi:type="bus:asynchOptionInt">
  272. <name xsi:type="bus:asynchOptionEnum">primaryWaitThreshold</name>
  273. <value xsi:type="xsd:int">10000</value>
  274. </item>
  275. <item xsi:type="bus:asynchOptionInt">
  276. <name xsi:type="bus:asynchOptionEnum">secondaryWaitThreshold</name>
  277. <value xsi:type="xsd:int">10000</value>
  278. </item>
  279. </options>
  280. </ns:runSpecification>
  281. </SOAP-ENV:Body>
  282. </SOAP-ENV:Envelope>
  283. </xts:request>
  284. </xts:transform>
  285. </burgundy>
  286. </xsl:when>
  287. <xsl:otherwise>
  288. <xts:request href="bus://dispatcher" protocol="NAV" outputHeader="true" faultBlock="error">
  289. <SOAP-ENV:Envelope >
  290. <SOAP-ENV:Header>
  291. <xsl:copy-of select="/root/header/bus:biBusHeader"/>
  292. </SOAP-ENV:Header>
  293. <SOAP-ENV:Body>
  294. <nav:search>
  295. <nav:validateTag fault="true"/>
  296. <nav:string><xsl:value-of select="key('env-param', 'query')"/></nav:string>
  297. <nav:skipObjects>0</nav:skipObjects>
  298. <nav:maxObjects>4</nav:maxObjects>
  299. <nav:param name="backUrl">false</nav:param>
  300. <nav:property name="actionsURL"/>
  301. <nav:property name="description"/>
  302. <nav:param name="gatewayURL"><xsl:value-of select="$gw"/></nav:param>
  303. </nav:search>
  304. </SOAP-ENV:Body>
  305. </SOAP-ENV:Envelope>
  306. </xts:request>
  307. </xsl:otherwise>
  308. </xsl:choose>
  309. </xsl:otherwise>
  310. </xsl:choose>
  311. </xsl:otherwise>
  312. </xsl:choose>
  313. <xts:queryNode select="/root/http | /root/header | /root/system | /root/env | /root/onebox | /root/configProps | /root/objectClass | /root/credential | /root/debug"/>
  314. </root>
  315. </xts:transform>
  316. </xts:append>
  317. </xts:sequence>
  318. </xsl:template>
  319. </xsl:stylesheet>
  320. </xts:block>
  321. <xts:block id="ignore" processor="XML" type="fault">
  322. <ignore/>
  323. </xts:block>
  324. <xts:block id="error" processor="XSLT" type="fault">
  325. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" exclude-result-prefixes="xsl">
  326. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  327. <xsl:template match="/">
  328. <error>
  329. <xsl:copy-of select="/root/fault"/>
  330. </error>
  331. </xsl:template>
  332. </xsl:stylesheet>
  333. </xts:block>
  334. <xts:block id="error-part" processor="XSLT" type="fault">
  335. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" exclude-result-prefixes="xsl">
  336. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  337. <xsl:template match="/root">
  338. <xos:part xmlns:xos="http://developer.cognos.com/schemas/xts/output/">
  339. <xos:entityHeader>
  340. <xos:param name="Content-Type">text/xml;charset=utf-8</xos:param>
  341. </xos:entityHeader>
  342. <xos:entityBody>
  343. <OneBoxResults>
  344. <MODULE_RESULT resultCode="lookupFailure">
  345. <Diagnostics>
  346. <xsl:value-of select="concat(fault//messageString[1], fault//xts:exceptionMsg)"/>
  347. </Diagnostics>
  348. </MODULE_RESULT>
  349. </OneBoxResults>
  350. </xos:entityBody>
  351. </xos:part>
  352. </xsl:template>
  353. </xsl:stylesheet>
  354. </xts:block>
  355. </xts:morphlet>