serverContent.xts 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Copyright (C) 2008 Cognos Incorporated. All rights reserved.
  4. Cognos (R) is a trademark of Cognos Incorporated.
  5. -->
  6. <xts:morphlet xmlns:xts="http://developer.cognos.com/schemas/xts/">
  7. <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
  8. <xts:block id="openNavTree" type="exec" mode="interpret" processor="XSLT"
  9. xmlns:pf="http://developer.cognos.com/schemas/xts/pf" >
  10. <!-- This block requests NavigationTree from chosen TM1 server for the first time.
  11. This request is expected to fail with HTTP 302 (Found) and the same location as given.
  12. It also returns one to many cookies that are required in subsequent requests.
  13. -->
  14. <xts:logicsheet path="logicsheets/portal.xsl"/>
  15. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" exclude-result-prefixes="xts xtsext xsl pf bus">
  16. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  17. <pf:variables/>
  18. <xsl:variable name="timeout" select="'200'"/>
  19. <xsl:template match="/">
  20. <xts:sequence>
  21. <xts:update select="/root/openNavTree">
  22. <openNavTree>
  23. <xts:request protocol="GET" faultBlock="handleNavTreeFault" protocolHeader="true" >
  24. <xsl:attribute name="href">
  25. <xsl:choose>
  26. <xsl:when test="key('env-param','TM1WebURL')">
  27. <xsl:value-of select="key('env-param','TM1WebURL')"/>
  28. </xsl:when>
  29. <xsl:otherwise>
  30. <xsl:choose>
  31. <xsl:when test="key('env-param','https') and key('env-param','https') != '0' ">
  32. <xsl:text>https://</xsl:text>
  33. </xsl:when>
  34. <xsl:otherwise>
  35. <xsl:text>http://</xsl:text>
  36. </xsl:otherwise>
  37. </xsl:choose>
  38. <xsl:value-of select="key('env-param','TM1WebHost')"/>
  39. </xsl:otherwise>
  40. </xsl:choose>
  41. <xsl:choose>
  42. <xsl:when test="key('env-param','ASPSessionId') and key('env-param','ASPSessionId') != '' ">
  43. <xsl:text>/</xsl:text>
  44. <xsl:value-of select="key('env-param','TM1WebVirtualDirectory')"/>
  45. <xsl:text>/TM1WebNavigationTreeXml.aspx</xsl:text>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <xsl:text>/</xsl:text>
  49. <xsl:value-of select="key('env-param','TM1WebVirtualDirectory')"/>
  50. <xsl:text>/TM1WebMain.aspx</xsl:text>
  51. <xsl:text>?action=OpenObject&amp;type=NavigationTree&amp;ContentType=xml</xsl:text>
  52. <xsl:text>&amp;AdminHost=</xsl:text>
  53. <xsl:value-of select="key('env-param','TM1Host')"/>
  54. <xsl:text>&amp;TM1Server=</xsl:text>
  55. <xsl:value-of select="key('env-param','TM1DataServer')"/>
  56. <xsl:choose>
  57. <xsl:when test="key('env-param','TM1username') and key('env-param','TM1username') != '' ">
  58. <xsl:text>&amp;username=</xsl:text>
  59. <xsl:value-of select="key('env-param','TM1username')"/>
  60. <xsl:text>&amp;password=</xsl:text>
  61. <xsl:value-of select="key('env-param','TM1pass')"/>
  62. </xsl:when>
  63. <xsl:otherwise>
  64. <xsl:text>&amp;cam_passport=</xsl:text>
  65. <xsl:value-of select="xtsext:urlencode($passport)"/>
  66. </xsl:otherwise>
  67. </xsl:choose>
  68. <xsl:choose>
  69. <xsl:when test="key('env-param','TM1Toolbar') and key('env-param','TM1Toolbar') != '' ">
  70. <xsl:text>&amp;TM1Toolbar=</xsl:text>
  71. <xsl:value-of select="key('env-param','TM1Toolbar')"/>
  72. </xsl:when>
  73. </xsl:choose>
  74. <xsl:choose>
  75. <xsl:when test="key('env-param','ASPSessionId') and key('env-param','ASPSessionId') != '' ">
  76. <xsl:text>&amp;ASPSessionId=</xsl:text>
  77. <xsl:value-of select="key('env-param','ASPSessionId')"/>
  78. </xsl:when>
  79. </xsl:choose>
  80. </xsl:otherwise>
  81. </xsl:choose>
  82. </xsl:attribute>
  83. <xsl:if test="$timeout">
  84. <xts:param name="timeout">
  85. <xsl:value-of select="number($timeout) * 1000 "/>
  86. </xts:param>
  87. </xsl:if>
  88. <xsl:choose>
  89. <xsl:when test="key('env-param','ASPSessionId') and key('env-param','ASPSessionId') != '' ">
  90. <xts:param name="header">
  91. <xsl:value-of select="concat('Cookie=',key('env-param','ASPSessionId'))"/>
  92. </xts:param>
  93. </xsl:when>
  94. </xsl:choose>
  95. </xts:request>
  96. </openNavTree>
  97. </xts:update>
  98. </xts:sequence>
  99. </xsl:template>
  100. </xsl:stylesheet>
  101. </xts:block>
  102. <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
  103. <xts:block id="openNavTreeAgain" type="exec" mode="interpret" processor="XSLT" dependency="openNavTree" condition=".[/root/openNavTree/xos:status/xos:param[@name='statusCode'] != '200']" mandatory="false"
  104. xmlns:pf="http://developer.cognos.com/schemas/xts/pf" >
  105. <!-- This block makes the same NavigationTree request as in previous block
  106. The difference is that this request sends the cookies returned in the previous request.
  107. This request also returns HTTP 302 (Found), but no cookies and a different location for the desired navigation tree.
  108. -->
  109. <xts:logicsheet path="logicsheets/portal.xsl"/>
  110. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:xos="http://developer.cognos.com/schemas/xts/output/" exclude-result-prefixes="xts xtsext xsl pf bus xos">
  111. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  112. <pf:variables/>
  113. <xsl:variable name="timeout" select="'200'"/>
  114. <xsl:template match="/">
  115. <xts:sequence>
  116. <xts:update select="/root/openNavTreeAgain">
  117. <openNavTreeAgain>
  118. <xts:request protocol="GET" faultBlock="handleNavTreeFault" protocolHeader="true" >
  119. <xsl:attribute name="href">
  120. <xsl:choose>
  121. <xsl:when test="key('env-param','TM1WebURL')">
  122. <xsl:value-of select="key('env-param','TM1WebURL')"/>
  123. </xsl:when>
  124. <xsl:otherwise>
  125. <xsl:choose>
  126. <xsl:when test="key('env-param','https') and key('env-param','https') != '0' ">
  127. <xsl:text>https://</xsl:text>
  128. </xsl:when>
  129. <xsl:otherwise>
  130. <xsl:text>http://</xsl:text>
  131. </xsl:otherwise>
  132. </xsl:choose>
  133. <xsl:value-of select="key('env-param','TM1WebHost')"/>
  134. </xsl:otherwise>
  135. </xsl:choose>
  136. <!-- Copy the location from the first request, as returned in the HTTP header -->
  137. <xsl:value-of select="/root/openNavTree/xos:protocolHeader/xos:param[@name='Location']"/>
  138. </xsl:attribute>
  139. <xsl:if test="$timeout">
  140. <xts:param name="timeout">
  141. <xsl:value-of select="number($timeout) * 1000 "/>
  142. </xts:param>
  143. </xsl:if>
  144. <!-- Here's where the cookies get sent -->
  145. <xsl:for-each select="/root/openNavTree/xos:protocolHeader/xos:param[@name='Set-Cookie']">
  146. <!-- For each cookie returned in previous request -->
  147. <xts:param name="header">
  148. <xsl:value-of select="concat('Cookie=',text())"/>
  149. </xts:param>
  150. </xsl:for-each>
  151. </xts:request>
  152. </openNavTreeAgain>
  153. </xts:update>
  154. </xts:sequence>
  155. </xsl:template>
  156. </xsl:stylesheet>
  157. </xts:block> <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
  158. <xts:block id="getNavTree" type="exec" mode="interpret" processor="XSLT" dependency="openNavTreeAgain" condition=".[/root/openNavTree/xos:status/xos:param[@name='statusCode'] != '200' and /root/openNavTree/xos:status/xos:param[@name='statusCode'] != '200']" mandatory="false"
  159. xmlns:pf="http://developer.cognos.com/schemas/xts/pf" >
  160. <!-- This block finally opens the NavigationTree requested in the previous blocks.
  161. This request sends the cookies returned in the first request and the location returned in the second request.
  162. This request returns HTTP 200 (OK) and the desired navigation tree XML.
  163. -->
  164. <xts:logicsheet path="logicsheets/portal.xsl"/>
  165. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:xos="http://developer.cognos.com/schemas/xts/output/" exclude-result-prefixes="xts xtsext xsl pf bus xos">
  166. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  167. <pf:variables/>
  168. <xsl:variable name="timeout" select="'200'"/>
  169. <xsl:template match="/">
  170. <xts:sequence>
  171. <xts:update select="/root/tm1Web">
  172. <tm1Web><navTree>
  173. <xts:request protocol="GET" faultBlock="handleNavTreeFault" protocolHeader="true" >
  174. <xsl:attribute name="href">
  175. <xsl:choose>
  176. <xsl:when test="key('env-param','TM1WebURL')">
  177. <xsl:value-of select="key('env-param','TM1WebURL')"/>
  178. </xsl:when>
  179. <xsl:otherwise>
  180. <xsl:choose>
  181. <xsl:when test="key('env-param','https') and key('env-param','https') != '0' ">
  182. <xsl:text>https://</xsl:text>
  183. </xsl:when>
  184. <xsl:otherwise>
  185. <xsl:text>http://</xsl:text>
  186. </xsl:otherwise>
  187. </xsl:choose>
  188. <xsl:value-of select="key('env-param','TM1WebHost')"/>
  189. </xsl:otherwise>
  190. </xsl:choose>
  191. <!-- Copy the location from the second request, as returned in the HTTP header -->
  192. <xsl:value-of select="/root/openNavTreeAgain/xos:protocolHeader/xos:param[@name='Location']"/>
  193. </xsl:attribute>
  194. <xsl:if test="$timeout">
  195. <xts:param name="timeout">
  196. <xsl:value-of select="number($timeout) * 1000 "/>
  197. </xts:param>
  198. </xsl:if>
  199. <!-- Here's where the cookies get sent -->
  200. <xsl:for-each select="/root/openNavTree/xos:protocolHeader/xos:param[@name='Set-Cookie']">
  201. <!-- For each cookie returned in first request -->
  202. <xts:param name="header">
  203. <xsl:value-of select="concat('Cookie=',text())"/>
  204. </xts:param>
  205. </xsl:for-each>
  206. </xts:request>
  207. </navTree></tm1Web>
  208. </xts:update>
  209. </xts:sequence>
  210. </xsl:template>
  211. </xsl:stylesheet>
  212. </xts:block>
  213. <xts:block id="transformNavTreeContent" type="exec" mode="interpret" processor="XSLT" dependency="getNavTree" xmlns:pf="http://developer.cognos.com/schemas/xts/pf">
  214. <xts:logicsheet path="logicsheets/portal.xsl"/>
  215. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:xos="http://developer.cognos.com/schemas/xts/output/" exclude-result-prefixes="xts xtsext xsl pf bus xos">
  216. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  217. <pf:variables/>
  218. <xsl:template match="/root">
  219. <xts:sequence>
  220. <xts:append select="/root/output">
  221. <xts:transform processor="XSLT" src="/tm1/PRE102/serverContentTransform.xslt" option="part" mimeType="application/atom+xml">
  222. <xts:param name="messageBase">/messages/tm1buxmsgs.xml</xts:param>
  223. <root>
  224. <xsl:if test="key('env-param', 'Id') != ''">
  225. <Id>
  226. <xsl:value-of select="key('env-param','Id')"/>
  227. </Id>
  228. </xsl:if>
  229. <xsl:if test="key('env-param', 'TM1WebHost') != ''">
  230. <TM1WebURL>
  231. <xsl:choose>
  232. <xsl:when test="key('env-param','https') and key('env-param','https') != '0' ">
  233. <xsl:text>https://</xsl:text>
  234. </xsl:when>
  235. <xsl:otherwise>
  236. <xsl:text>http://</xsl:text>
  237. </xsl:otherwise>
  238. </xsl:choose>
  239. <xsl:value-of select="xtsext:urlencode(key('env-param','TM1WebHost'))"/>
  240. </TM1WebURL>
  241. </xsl:if>
  242. <xsl:if test="key('env-param', 'TM1WebURL') != ''">
  243. <TM1WebURL>
  244. <xsl:value-of select="xtsext:urlencode(key('env-param','TM1WebURL'))"/>
  245. </TM1WebURL>
  246. </xsl:if>
  247. <xsl:if test="key('env-param', 'TM1WebVirtualDirectory') != ''">
  248. <TM1WebVirtualDirectory>
  249. <xsl:value-of select="xtsext:urlencode(key('env-param','TM1WebVirtualDirectory'))"/>
  250. </TM1WebVirtualDirectory>
  251. </xsl:if>
  252. <xsl:if test="key('env-param', 'TM1Host') != ''">
  253. <TM1Host>
  254. <xsl:value-of select="key('env-param','TM1Host')"/>
  255. </TM1Host>
  256. </xsl:if>
  257. <xsl:if test="key('env-param', 'TM1DataServer') != ''">
  258. <TM1DataServer>
  259. <xsl:value-of select="xtsext:urlencode(key('env-param','TM1DataServer'))"/>
  260. </TM1DataServer>
  261. </xsl:if>
  262. <xsl:if test="key('env-param', 'TM1username') != ''">
  263. <TM1username>
  264. <xsl:value-of select="key('env-param','TM1username')"/>
  265. </TM1username>
  266. </xsl:if>
  267. <xsl:if test="key('env-param', 'TM1pass') != ''">
  268. <TM1pass>
  269. <xsl:value-of select="key('env-param','TM1pass')"/>
  270. </TM1pass>
  271. </xsl:if>
  272. <xsl:if test="key('env-param', 'TM1Toolbar') != ''">
  273. <TM1Toolbar>
  274. <xsl:value-of select="key('env-param','TM1Toolbar')"/>
  275. </TM1Toolbar>
  276. </xsl:if>
  277. <xsl:if test="key('env-param', 'ASPSessionId') != ''">
  278. <ASPSessionId>
  279. <xsl:value-of select="key('env-param','ASPSessionId')"/>
  280. </ASPSessionId>
  281. </xsl:if>
  282. <!-- Here's where the cookies get sent -->
  283. <xsl:for-each select="/root/openNavTree/xos:protocolHeader/xos:param[@name='Set-Cookie']">
  284. <!-- For each cookie returned in previous request -->
  285. <ASPSessionId>
  286. <xsl:value-of select="xtsext:urlencode(text())"/>
  287. </ASPSessionId>
  288. </xsl:for-each>
  289. <GatewayURL>
  290. <xsl:value-of select="$gateway"/>
  291. </GatewayURL>
  292. <WebRootURL>
  293. <xsl:value-of select="$webRoot"/>
  294. </WebRootURL>
  295. <xsl:copy-of select="/root/openNavTree/NavigationTree"/>
  296. <xsl:copy-of select="/root/openNavTreeAgain/NavigationTree"/>
  297. <xsl:copy-of select="/root/tm1Web/navTree/NavigationTree"/>
  298. </root>
  299. </xts:transform>
  300. </xts:append>
  301. </xts:sequence>
  302. </xsl:template>
  303. </xsl:stylesheet>
  304. </xts:block>
  305. <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
  306. <xts:block id="handleNavTreeFault" type="fault" processor="XSLT">
  307. <xsl:stylesheet version="1.0"
  308. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  309. xmlns:xtse="http://developer.cognos.com/schemas/xts/error/1/">
  310. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  311. <xsl:template match="/">
  312. <xtse:error>
  313. <xsl:for-each select="/root/fault/xts:exception[not(starts-with(xts:exceptionCode, 'java'))]">
  314. <xtse:message>
  315. <xsl:value-of select="xts:exceptionMsg"/>
  316. </xtse:message>
  317. <xtse:detail>
  318. <xsl:for-each select="xts:exceptionDetail">
  319. <xsl:call-template name="copyTree"/>
  320. </xsl:for-each>
  321. </xtse:detail>
  322. </xsl:for-each>
  323. </xtse:error>
  324. </xsl:template>
  325. <xsl:template name="copyTree">
  326. <xsl:param name="nodes" select="."/>
  327. <xsl:for-each select="$nodes">
  328. <xsl:copy>
  329. <xsl:for-each select="@*">
  330. <xsl:copy/>
  331. </xsl:for-each>
  332. <xsl:call-template name="copyTree">
  333. <xsl:with-param name="nodes" select="*|text()|comment()"/>
  334. </xsl:call-template>
  335. </xsl:copy>
  336. </xsl:for-each>
  337. </xsl:template>
  338. </xsl:stylesheet>
  339. </xts:block>
  340. </xts:morphlet>