h.xts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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, 2011
  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" xmlns:xts="http://developer.cognos.com/schemas/xts/">
  13. <!--
  14. * params for this morphlet :== r [caller-mode]
  15. * r :== getCapabilities | getObject | getContainer | search
  16. * getCapabilities :== <none>
  17. * getObject :== id
  18. * getContainer :== id | path paginations
  19. * paginations :== maxobjs skipobjs sort
  20. * maxobjs :== #
  21. * skipobjs :== #
  22. * sort :== n | n_d | d | d_d
  23. * id :== CM-id | NAV-id
  24. * path :== CM-searchpath
  25. * search :== text sscope sfield smethod smodified stype path paginations
  26. * text :== text to search
  27. * sscope :== fo | fb | p | m
  28. * sfield :== n | d | nd
  29. * smethod :== 1 | 2 | 3
  30. * smodified :== t | l3d | lw | lm | l3m | l6m | ly | l3y
  31. * stype :== object type
  32. * path :== starting path to search
  33. * paginations :== (see getContainer)
  34. * caller-mode :== custom
  35. -->
  36. <xts:block id="handleRequest" type="exec"
  37. dependency=""
  38. condition=".[true()]"
  39. mode="interpret" processor="XSLT" mandatory="false">
  40. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  41. <xsl:stylesheet version="1.0"
  42. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  43. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  44. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  45. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  46. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  47. xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
  48. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  49. xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
  50. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  51. exclude-result-prefixes="xts xos bus nav SOAP-ENV">
  52. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  53. <xsl:variable name="params" select="/root/env/param"/>
  54. <xsl:variable name="preferences" select="/root/bus:biBusHeader/bus:userPreferenceVars"/>
  55. <xsl:variable name="userPrefsDefault" select="/root/system/param[@name='defaultPortalPreferences']"/>
  56. <xsl:variable name="browser" select="'ie'"/>
  57. <xsl:variable name="request" select="$params[@name='r']"/>
  58. <xsl:template match="/">
  59. <xsl:choose>
  60. <xsl:when test="$request = 'getCapabilities'">
  61. <xsl:call-template name="do-getCapabilities"/>
  62. </xsl:when>
  63. <xsl:when test="$request = 'getContainer' or $request = 'getObject' or $request = 'search'">
  64. <xsl:call-template name="do-NAVRequest"/>
  65. </xsl:when>
  66. <xsl:otherwise>
  67. <xts:sequence>
  68. <xts:append select="/root">
  69. <request-result>
  70. <error><code>unsupported-request</code></error>
  71. </request-result>
  72. </xts:append>
  73. </xts:sequence>
  74. </xsl:otherwise>
  75. </xsl:choose>
  76. </xsl:template>
  77. <xsl:template name="do-getCapabilities">
  78. <xts:sequence>
  79. <xts:append>
  80. <send:request provider="cm">
  81. <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
  82. <cm:query>
  83. <cm:search>~</cm:search>
  84. <cm:properties>
  85. <cm:property name="defaultName"/>
  86. </cm:properties>
  87. </cm:query>
  88. </xts:transform>
  89. </send:request>
  90. </xts:append>
  91. <xts:append select="/root">
  92. <request-result>
  93. <xsl:element name="getCapabilitiesResponse">
  94. <session-capabilities>
  95. <xsl:copy-of select="/root/session/param[@name='capabilities']/*"/>
  96. </session-capabilities>
  97. <xsl:copy-of select="$params[@name='capabilities']/*"/>
  98. <browser-info>
  99. <xsl:copy-of select="/root/system/param[@name='capabilities']/*"/>
  100. </browser-info>
  101. </xsl:element>
  102. </request-result>
  103. </xts:append>
  104. </xts:sequence>
  105. </xsl:template>
  106. <xsl:template name="do-NAVRequest">
  107. <xsl:variable name="obj-path">
  108. <xsl:choose>
  109. <xsl:when test="string($params[@name='id']) != ''">
  110. <xsl:choose>
  111. <xsl:when test="starts-with($params[@name='id'], '_')">
  112. <xsl:value-of select="$params[@name='id']"/>
  113. </xsl:when>
  114. <xsl:otherwise>
  115. <xsl:text/>path:storeID("<xsl:value-of select="$params[@name='id']"/>")<xsl:text/>
  116. </xsl:otherwise>
  117. </xsl:choose>
  118. </xsl:when>
  119. <xsl:when test="string($params[@name='path']) != ''">
  120. <xsl:text/>path:<xsl:value-of select="$params[@name='path']"/>
  121. </xsl:when>
  122. <xsl:otherwise>
  123. <xsl:text/>systemDefault<xsl:text/>
  124. </xsl:otherwise>
  125. </xsl:choose>
  126. </xsl:variable>
  127. <xsl:variable name="navRequest">
  128. <xsl:choose>
  129. <xsl:when test="$request = 'getContainer'">
  130. <xsl:value-of select="'getContainer'"/>
  131. </xsl:when>
  132. <xsl:when test="$request = 'getObject'">
  133. <xsl:value-of select="'getItem'"/>
  134. </xsl:when>
  135. <xsl:when test="$request = 'search'">
  136. <xsl:value-of select="'search'"/>
  137. </xsl:when>
  138. </xsl:choose>
  139. </xsl:variable>
  140. <xts:sequence>
  141. <xts:append select="/root">
  142. <request-result>
  143. <xsl:if test="$navRequest != ''">
  144. <xts:request name="NAV" faultBlock="navRequestFault">
  145. <SOAP-ENV:Envelope>
  146. <SOAP-ENV:Header>
  147. <xsl:copy-of select="/root/header/bus:biBusHeader"/>
  148. </SOAP-ENV:Header>
  149. <SOAP-ENV:Body>
  150. <xsl:element name="{$navRequest}" namespace="http://developer.cognos.com/schemas/cps/navigation/1/">
  151. <nav:validateTag/>
  152. <xsl:choose>
  153. <xsl:when test="$navRequest = 'getItem'">
  154. <nav:id><xsl:value-of select="$obj-path"/></nav:id>
  155. </xsl:when>
  156. <xsl:when test="$navRequest = 'getContainer'">
  157. <nav:id><xsl:value-of select="$obj-path"/></nav:id>
  158. <nav:childObjects>all</nav:childObjects>
  159. <xsl:call-template name="build-pagination-params"/>
  160. </xsl:when>
  161. <xsl:when test="$navRequest = 'search'">
  162. <xsl:call-template name="build-search-params"/>
  163. <xsl:call-template name="build-pagination-params"/>
  164. </xsl:when>
  165. </xsl:choose>
  166. <nav:param name="postUrl"/>
  167. <nav:param name="backUrl">rewrite</nav:param>
  168. <nav:param name="browserAgent"><xsl:value-of select="$browser"/></nav:param>
  169. <!-- properties -->
  170. <nav:property name="screenTip"/>
  171. <nav:property name="description"/>
  172. <nav:property name="parentId"/>
  173. <nav:property name="fullPath"/>
  174. <nav:property name="lastModifiedDate"/>
  175. <nav:property name="status"/>
  176. <nav:property name="newState"/>
  177. <nav:property name="readState"/>
  178. <nav:property name="action"/>
  179. <nav:property name="actionsURL"/>
  180. <nav:property name="hidden"/>
  181. <nav:property name="icons"/>
  182. </xsl:element>
  183. </SOAP-ENV:Body>
  184. </SOAP-ENV:Envelope>
  185. </xts:request>
  186. </xsl:if>
  187. </request-result>
  188. </xts:append>
  189. </xts:sequence>
  190. </xsl:template>
  191. <xsl:template name="build-pagination-params">
  192. <xsl:variable name="skipobjs">
  193. <xsl:choose>
  194. <xsl:when test="string($params[@name='skipobjs']) != ''">
  195. <xsl:value-of select="$params[@name='skipobjs']"/>
  196. </xsl:when>
  197. <xsl:otherwise>0</xsl:otherwise>
  198. </xsl:choose>
  199. </xsl:variable>
  200. <xsl:variable name="maxObjects">
  201. <xsl:choose>
  202. <xsl:when test="$params[@name='maxobjs'] != ''">
  203. <xsl:value-of select="$params[@name='maxobjs']"/>
  204. </xsl:when>
  205. <xsl:when test="$preferences/item[name = 'linesPerPage']/value">
  206. <xsl:value-of select="$preferences/item[name = 'linesPerPage']/value"/>
  207. </xsl:when>
  208. <xsl:otherwise><xsl:value-of select="$userPrefsDefault/pref[@name='lines']"/></xsl:otherwise>
  209. </xsl:choose>
  210. </xsl:variable>
  211. <xsl:variable name="sort">
  212. <xsl:if test="$params[@name='sort'] != ''">
  213. <xsl:value-of select="$params[@name='sort']"/>
  214. </xsl:if>
  215. </xsl:variable>
  216. <nav:skipObjects>
  217. <xsl:choose>
  218. <xsl:when test="$skipobjs != '' ">
  219. <xsl:value-of select="$skipobjs"/>
  220. </xsl:when>
  221. <xsl:otherwise>0</xsl:otherwise>
  222. </xsl:choose>
  223. </nav:skipObjects>
  224. <nav:maxObjects><xsl:value-of select="$maxObjects"/></nav:maxObjects>
  225. <xsl:choose>
  226. <xsl:when test="starts-with(string($sort),'n')">
  227. <xsl:variable name="order">
  228. <xsl:choose>
  229. <xsl:when test="$sort = 'n_d'">
  230. <xsl:text>descending</xsl:text>
  231. </xsl:when>
  232. <xsl:otherwise>
  233. <xsl:text>ascending</xsl:text>
  234. </xsl:otherwise>
  235. </xsl:choose>
  236. </xsl:variable>
  237. <nav:sort order="{$order}">name</nav:sort>
  238. </xsl:when>
  239. <xsl:when test="starts-with(string($sort),'d')">
  240. <xsl:variable name="order">
  241. <xsl:choose>
  242. <xsl:when test="$sort = 'd_d'">
  243. <xsl:text>descending</xsl:text>
  244. </xsl:when>
  245. <xsl:otherwise>
  246. <xsl:text>ascending</xsl:text>
  247. </xsl:otherwise>
  248. </xsl:choose>
  249. </xsl:variable>
  250. <nav:sort order="{$order}">lastModifiedDate</nav:sort>
  251. </xsl:when>
  252. </xsl:choose>
  253. </xsl:template>
  254. <xsl:template name="build-search-params">
  255. <xsl:if test="string($params[@name='stext']) != ''">
  256. <nav:string><xsl:value-of select="$params[@name='stext']"/></nav:string>
  257. </xsl:if>
  258. <nav:searchType>normal</nav:searchType>
  259. <!-- scope -->
  260. <xsl:variable name="sscope" select="$params[@name='sscope']"/>
  261. <nav:scope>
  262. <xsl:variable name="path" select="$params[@name='path']"/>
  263. <xsl:choose>
  264. <xsl:when test="$sscope = 'p'">
  265. <xsl:value-of select="'systemDefault'"/>
  266. </xsl:when>
  267. <xsl:when test="$sscope = 'm'">
  268. <xsl:value-of select="'userDefault'"/>
  269. </xsl:when>
  270. <xsl:when test="$sscope = 'fo'">
  271. <xsl:value-of select="$path"/>
  272. </xsl:when>
  273. <xsl:when test="$sscope = 'fb'">
  274. <xsl:value-of select="$path"/>
  275. </xsl:when>
  276. <xsl:otherwise>
  277. <xsl:value-of select="'systemDefault'"/>
  278. </xsl:otherwise>
  279. </xsl:choose>
  280. </nav:scope>
  281. <!-- recursive scope: whether to search subfolders -->
  282. <nav:recursive>
  283. <xsl:choose>
  284. <xsl:when test="string($params[@name='sscope']) = 'fo'">
  285. <xsl:value-of select="'false'"/>
  286. </xsl:when>
  287. <xsl:otherwise>
  288. <xsl:value-of select="'true'"/>
  289. </xsl:otherwise>
  290. </xsl:choose>
  291. </nav:recursive>
  292. <!-- field -->
  293. <nav:fields>
  294. <xsl:choose>
  295. <xsl:when test="$params[@name = 'sfield'] = 'n'">
  296. <xsl:value-of select="'nf'"/>
  297. </xsl:when>
  298. <xsl:when test="$params[@name = 'sfield'] = 'd'">
  299. <xsl:value-of select="'df'"/>
  300. </xsl:when>
  301. <xsl:when test="$params[@name = 'sfield'] = 'nd'">
  302. <xsl:value-of select="'ndf'"/>
  303. </xsl:when>
  304. </xsl:choose>
  305. </nav:fields>
  306. <!-- match criteria -->
  307. <xsl:variable name="smethod" select="$params[@name='smethod']"/>
  308. <nav:match>
  309. <xsl:choose>
  310. <xsl:when test="$smethod = '1'">
  311. <xsl:value-of select="'contains'"/>
  312. </xsl:when>
  313. <xsl:when test="$smethod = '2'">
  314. <xsl:value-of select="'starts'"/>
  315. </xsl:when>
  316. <xsl:when test="$smethod = '3'">
  317. <xsl:value-of select="'exact'"/>
  318. </xsl:when>
  319. <xsl:otherwise>
  320. <xsl:value-of select="'contains'"/>
  321. </xsl:otherwise>
  322. </xsl:choose>
  323. </nav:match>
  324. <!-- modified since -->
  325. <xsl:variable name="smodified" select="$params[@name='smodified']"/>
  326. <xsl:if test="$smodified != 'any'">
  327. <nav:itemModified>
  328. <xsl:choose>
  329. <xsl:when test="$smodified = 't'">0</xsl:when>
  330. <xsl:when test="$smodified = 'l3d'">259200</xsl:when>
  331. <xsl:when test="$smodified = 'lw'">604800</xsl:when>
  332. <xsl:when test="$smodified = 'lm'">2629743</xsl:when>
  333. <xsl:when test="$smodified = 'l3m'">7889231</xsl:when>
  334. <xsl:when test="$smodified = 'l6m'">15778463</xsl:when>
  335. <xsl:when test="$smodified = 'ly'">31556926</xsl:when>
  336. <xsl:when test="$smodified = 'l3y'">94670777</xsl:when>
  337. </xsl:choose>
  338. </nav:itemModified>
  339. </xsl:if>
  340. <!-- item type(s) to restrict search to -->
  341. <xsl:variable name="stype" select="string($params[@name='stype'])"/>
  342. <xsl:if test="$stype != ''">
  343. <nav:itemType><xsl:value-of select="$stype"/></nav:itemType>
  344. </xsl:if>
  345. </xsl:template>
  346. </xsl:stylesheet>
  347. </xts:block>
  348. <xts:block id="output" type="exec"
  349. dependency="handleRequest"
  350. mode="interpret" processor="XSLT">
  351. <xsl:stylesheet version="1.0"
  352. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  353. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  354. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  355. xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
  356. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  357. xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
  358. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  359. exclude-result-prefixes="xts xos bus nav SOAP-ENV">
  360. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  361. <xsl:variable name="params" select="/root/env/param"/>
  362. <xsl:template match="/">
  363. <xts:sequence>
  364. <xts:append select="/root/output">
  365. <xos:part>
  366. <xos:entityHeader>
  367. <xos:param name="Content-Type">text/xml; charset=UTF-8</xos:param>
  368. </xos:entityHeader>
  369. <xos:entityBody>
  370. <response>
  371. <xsl:for-each select="/root/request-result">
  372. <xsl:copy-of select="./*"/>
  373. </xsl:for-each>
  374. </response>
  375. </xos:entityBody>
  376. </xos:part>
  377. </xts:append>
  378. </xts:sequence>
  379. </xsl:template>
  380. </xsl:stylesheet>
  381. </xts:block>
  382. <xts:block id="navRequestFault" type="fault" processor="XSLT">
  383. <xsl:stylesheet version="1.0"
  384. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  385. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  386. exclude-result-prefixes="xts">
  387. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  388. <xsl:variable name="params" select="/root/env/param"/>
  389. <xsl:template match="/">
  390. <xsl:variable name="xts-fault" select="/root/fault/xts:exception[last()]"/>
  391. <xsl:variable name="code" select="$xts-fault/xts:exceptionCode"/>
  392. <xsl:variable name="prefix" select="substring-before( string( $code ), ':' )"/>
  393. <xsl:variable name="local-code" select="substring-after( string( $code ), ':' )"/>
  394. <error>
  395. <xsl:choose>
  396. <xsl:when test="($prefix = 'nav') and ($local-code = 'InvalidCredentials')">
  397. <code>invalidCredentials</code>
  398. </xsl:when>
  399. <xsl:otherwise>
  400. <code xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/">
  401. <xsl:value-of select="$code"/>
  402. </code>
  403. </xsl:otherwise>
  404. </xsl:choose>
  405. <message>
  406. <xsl:value-of select="$xts-fault/xts:exceptionMsg"/>
  407. </message>
  408. <details>
  409. <xsl:value-of select="$xts-fault/xts:exceptionDetails"/>
  410. </details>
  411. </error>
  412. </xsl:template>
  413. </xsl:stylesheet>
  414. </xts:block>
  415. </xts:morphlet>