main.xts 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  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. Interface:
  10. startwel present if this is the start of your session. The welcome page will be shown if enabled
  11. m_launchRS launches reportStudio. This property takes precedence over startwel.
  12. This morphlet used to direct the navigation in CognosConnection. Using the parameters above, the welcome page can be show or lauch report studio or do a go home operation.
  13. A go home operation is specified by not specifying any parameters to main.xts.
  14. If startwel is specified but the welcome page is disabled then a go home operation is done
  15. -->
  16. <xts:morphlet xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" messageBase="messages/portal.xml, messages/portalRL.xml">
  17. <!-- Allows the caller to override the productLocale and contentLocale used by CRN -->
  18. <!-- ================================================================= -->
  19. <xts:block id="modifyLocales" type="exec" mode="interpret" processor="XSLT" condition=".[/root/env/param[@name = 'm_productLocale'] or /root/env/param[@name = 'm_contentLocale']]" mandatory="false">
  20. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="bus SOAP-ENV SOAP-ENC xts">
  21. <xsl:template match="/">
  22. <xts:sequence>
  23. <xsl:variable name="xpath">
  24. <xsl:text>@name='CRN'</xsl:text>
  25. <xsl:if test="(/root/session/param[@name='cl'] != /root/env/param[@name='m_contentLocale']) or not(/root/session/param[@name='cl'])">
  26. <xsl:text> or @name='cc_session'</xsl:text>
  27. </xsl:if>
  28. </xsl:variable>
  29. <!-- get ride of potentially out of date cookie... -->
  30. <xts:delete select="/root/header/*[local-name() = 'biBusHeader']/*[local-name() = 'hdrSession']/*[local-name()='cookieVars']/item[{$xpath}]"/>
  31. <xts:delete select="/root/cookies/cookie[{$xpath}]"/>
  32. <!--
  33. A new CRN cookie is generated when not all user preferences are passed in, so by only specifying contentLocale and productLocale (and leaving out
  34. things like TimeZone, a response from CM will include a Set-Cookie with a new CRN cookie that contains the productLocale and/or contentLocale
  35. that we want to use.
  36. -->
  37. <xts:delete select="/root/header/*[local-name() = 'biBusHeader']/*[local-name() = 'userPreferenceVars']"/>
  38. <xts:append select="/root/header/*[local-name() = 'biBusHeader']">
  39. <bus:userPreferenceVars xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:userPreferenceVar[]">
  40. <xsl:if test="/root/env/param[@name = 'm_productLocale']">
  41. <item>
  42. <name xsi:type="xsd:string">productLocale</name>
  43. <value xsi:type="xsd:string">
  44. <xsl:value-of select="/root/env/param[@name = 'm_productLocale']"/>
  45. </value>
  46. </item>
  47. </xsl:if>
  48. <xsl:if test="/root/env/param[@name = 'm_contentLocale']">
  49. <item>
  50. <name xsi:type="xsd:string">contentLocale</name>
  51. <value xsi:type="xsd:string">
  52. <xsl:value-of select="/root/env/param[@name = 'm_contentLocale']"/>
  53. </value>
  54. </item>
  55. </xsl:if>
  56. </bus:userPreferenceVars>
  57. </xts:append>
  58. </xts:sequence>
  59. </xsl:template>
  60. </xsl:stylesheet>
  61. </xts:block>
  62. <xts:block id="setAS_TICKET" dependency="response" type="exec" mode="interpret" processor="XSLT" condition=".[/root/env/param[@name = 'm_asTicket']]" mandatory="false">
  63. <xsl:stylesheet version="1.0"
  64. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  65. xmlns:bus="http://developer.cognos.com/schemas/bibus/2/"
  66. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  67. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  68. exclude-result-prefixes="bus xts xtsext">
  69. <xsl:template match="/" >
  70. <xts:sequence>
  71. <xts:append select="/root/output/*[local-name() = 'protocolHeader']/*[local-name() = 'param' and @name = 'setSoapHeader']/*[local-name() = 'Header']/*[local-name() = 'biBusHeader']/*[local-name() = 'hdrSession']/*[local-name() = 'setCookieVars']">
  72. <item xsi:type="bus:setCookieVar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  73. <name xsi:type="xsd:string">AS_TICKET</name>
  74. <value xsi:type="xsd:string">
  75. <xsl:value-of select="xtsext:urldecode(string(/root/env/param[@name = 'm_asTicket']))"/>
  76. </value>
  77. <maxAge xsi:type="xsd:int">0</maxAge>
  78. <path xsi:type="xsd:string">/</path>
  79. </item>
  80. </xts:append>
  81. </xts:sequence>
  82. </xsl:template>
  83. </xsl:stylesheet>
  84. </xts:block>
  85. <!-- ======================================================== -->
  86. <!-- Session Management -->
  87. <!-- ======================================================== -->
  88. <!-- Reads session-sensitive info from CM -->
  89. <xts:block processor="XSLT" type="exec" mandatory="false" dependency="modifyLocales"
  90. id="refreshSession"
  91. path="portal/cc/read_session.xml"
  92. condition=".[
  93. (string(/root/cookies/cookie[@name = 'cc_session']) = '' and not(/root/setCookies/cookie[@name='cam_passport' and string(@maxAge) = '-1']))
  94. or /root/env/param[@name='m_reload']
  95. or /root/env/param[@name='m_root'] ]">
  96. <xts:logicsheet path="logicsheets/cm-logic.xsl"/>
  97. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  98. </xts:block>
  99. <!-- Update the <session> element for this request. -->
  100. <xts:block id="buildSession" path="portal/session.xml" dependency="refreshSession" processor="XSLT" type="exec"
  101. condition=".[
  102. /root/newSession
  103. or /root/env/param[@name='ui']
  104. or /root/env/param[@name='d']
  105. or /root/env/param[starts-with(@name,'m_s_')]
  106. or /root/env/param[@name = 'resetSort'] ]"
  107. mandatory="false"/>
  108. <!-- Save changes to the state info in a cookie -->
  109. <xts:block mode="interpret" processor="XSLT" type="exec"
  110. id="setSession"
  111. path="portal/set_session.xml"
  112. dependency="buildSession getAccountOptions"
  113. condition=".[/root/updateSession or /root/deleteCookies]"
  114. mandatory="false"/>
  115. <!-- Retrieve the account options if refreshSession did not run -->
  116. <xts:block id="getAccountOptions" mode="interpret" processor="XSLT" type="exec" dependency="refreshSession" condition=".[not(/root/newSession or /root/setCookies/cookie[@name='cam_passport' and string(@maxAge) = '-1'])]" mandatory="false">
  117. <xts:logicsheet path="logicsheets/cm-logic.xsl"/>
  118. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  119. <xsl:stylesheet version="1.0"
  120. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  121. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  122. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  123. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  124. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" exclude-result-prefixes="xts send bus">
  125. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  126. <xsl:template match="root">
  127. <xts:sequence>
  128. <xts:append>
  129. <accountOptions>
  130. <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
  131. <send:request provider="cm">
  132. <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
  133. <cm:query xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  134. <!-- Get account options -->
  135. <cm:search>~</cm:search>
  136. <cm:properties>
  137. <cm:property name="options"/>
  138. </cm:properties>
  139. </cm:query>
  140. </xts:transform>
  141. </send:request>
  142. </xts:transform>
  143. </accountOptions>
  144. </xts:append>
  145. </xts:sequence>
  146. </xsl:template>
  147. </xsl:stylesheet>
  148. </xts:block>
  149. <xts:block id="getConfigInfo" mode="interpret"
  150. processor="XSLT" type="exec" dependency="" mandatory="false">
  151. <xts:logicsheet path="logicsheets/portal.xsl"/>
  152. <xsl:stylesheet version="1.0"
  153. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  154. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  155. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  156. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  157. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  158. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" exclude-result-prefixes="xts send bus">
  159. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  160. <xsl:template match="root">
  161. <xts:sequence>
  162. <xsl:if test="/root/cookies/cookie[@name='mvc'] and not(/root/env/param[@name='mvc_homeredirect'])">
  163. <xts:append>
  164. <mvcSettings>
  165. <xts:function name="getConfiguration">
  166. <xts:param name="MVC_gateway"/> <!-- N gateway -->
  167. </xts:function>
  168. </mvcSettings>
  169. </xts:append>
  170. </xsl:if>
  171. <xts:append>
  172. <generalConfigSettings>
  173. <xts:function name="getConfiguration">
  174. <xts:param name="portal.launchBusinessInsightChromeless"/>
  175. </xts:function>
  176. </generalConfigSettings>
  177. </xts:append>
  178. </xts:sequence>
  179. </xsl:template>
  180. </xsl:stylesheet>
  181. </xts:block>
  182. <!--
  183. ===============================================================================================
  184. Determine what page is required and redirect to the appropriate location
  185. ===============================================================================================
  186. -->
  187. <xts:block
  188. id="redirectionLogic"
  189. dependency="setSession getConfigInfo"
  190. mode="interpret"
  191. processor="XSLT"
  192. type="exec"
  193. mimeType="text/html"
  194. mandatory="true">
  195. <xts:logicsheet path="logicsheets/portal.xsl"/>
  196. <xsl:stylesheet version="1.0"
  197. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  198. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  199. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  200. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  201. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  202. xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
  203. exclude-result-prefixes="xtsext cm xts pf">
  204. <pf:variables/>
  205. <pf:CustomWelcomeURL/>
  206. <xsl:variable name="ICSoftwareWelcomeURL">
  207. <xsl:value-of select="$gateway"/>?b_action=xts.run&amp;m=portal/welcome/welcome.xts<xsl:text/>
  208. </xsl:variable>
  209. <xsl:variable name="isHomeAPI" select="/root/env/param[@name='homeAPI']"/>
  210. <xsl:variable name="isLaunchBusinessInsightChromeless" select="string(/root/generalConfigSettings/configuration/property[@name='portal.launchBusinessInsightChromeless']) = 'true'"/>
  211. <xsl:template match="/root">
  212. <xsl:choose>
  213. <!-- calling home api -->
  214. <xsl:when test="$isHomeAPI">
  215. <xsl:call-template name="executeHomeRequest"/>
  216. </xsl:when>
  217. <!-- Redirect to another URL -->
  218. <xsl:when test="string(/root/env/param[@name='m_redirect']) != '' ">
  219. <xsl:call-template name="redirect">
  220. <xsl:with-param name="url" select="/root/env/param[@name='m_redirect']"/>
  221. <xsl:with-param name="windowMode">
  222. <xsl:choose>
  223. <xsl:when test="/root/env/param[@name='m_redirect_uitool'] = 'DashboardConsole'">
  224. <xsl:choose>
  225. <xsl:when test="$isLaunchBusinessInsightChromeless">openChromelessWindow</xsl:when>
  226. <xsl:otherwise>openChromedWindow</xsl:otherwise>
  227. </xsl:choose>
  228. </xsl:when>
  229. <xsl:when test="/root/env/param[@name='m_redirect_windowmode']='1'">openChromedWindow</xsl:when>
  230. <xsl:when test="/root/env/param[@name='m_redirect_windowmode']='2'">openChromelessWindow</xsl:when>
  231. <xsl:otherwise>openSameWindow</xsl:otherwise>
  232. </xsl:choose>
  233. </xsl:with-param>
  234. </xsl:call-template>
  235. </xsl:when>
  236. <!-- Re-invoke an original request after authentication -->
  237. <xsl:when test="/root/env/param[@name='m_method'] or /root/env/param[@name='m_pathInfo'] or /root/env/param[starts-with(@name, 'o_')]">
  238. <xsl:call-template name="executeInternalRedirection"/>
  239. </xsl:when>
  240. <!-- Statup C8 with Welcome page -->
  241. <xsl:when test="(string(/root/env/param[@name='startwel']) != '' and key('session-param', 'showWelcomePage') = 'true') ">
  242. <xsl:choose>
  243. <xsl:when test="not($welcomeURLOverride) or $hasCustomWelcomeURL">
  244. <!-- xsl:call-template name="executeWelcomeRequest"/-->
  245. <xsl:call-template name="redirect">
  246. <xsl:with-param name="url" select="'/bi'"/>
  247. </xsl:call-template>
  248. </xsl:when>
  249. <xsl:otherwise>
  250. <xsl:call-template name="executeHomeRequest"/>
  251. </xsl:otherwise>
  252. </xsl:choose>
  253. </xsl:when>
  254. <!-- Perform a go home command -->
  255. <xsl:otherwise>
  256. <xsl:call-template name="executeHomeRequest"/>
  257. </xsl:otherwise>
  258. </xsl:choose>
  259. </xsl:template>
  260. <!-- Handle a Welcome Command -->
  261. <xsl:template name="executeWelcomeRequest">
  262. <xsl:variable name="welcomeURL">
  263. <xsl:choose>
  264. <xsl:when test="$hasCustomWelcomeURL">
  265. <xsl:value-of select="$customWelcomeURL"/>
  266. </xsl:when>
  267. <xsl:otherwise>
  268. <xsl:value-of select="$ICSoftwareWelcomeURL"/>
  269. </xsl:otherwise>
  270. </xsl:choose>
  271. </xsl:variable>
  272. <xsl:call-template name="redirect">
  273. <xsl:with-param name="url" select="$welcomeURL"/>
  274. </xsl:call-template>
  275. </xsl:template>
  276. <!-- Handle a Home Command -->
  277. <xsl:template name="executeHomeRequest">
  278. <xsl:variable name="rawCMHomeURL">
  279. <xsl:call-template name="buildBasicHomeQueryString"/>
  280. </xsl:variable>
  281. <xsl:variable name="gatewayTarget">
  282. <xsl:value-of select="$gateway"/>
  283. </xsl:variable>
  284. <xsl:variable name="sanitizedHomeURL">
  285. <xsl:choose>
  286. <xsl:when test="starts-with($rawCMHomeURL , 'http://' ) or starts-with($rawCMHomeURL , 'https://' )">
  287. <xsl:choose>
  288. <xsl:when test="xtsext:cafaction('issafeurl_null', normalize-space($rawCMHomeURL)) = 'true'">
  289. <xsl:value-of select="$rawCMHomeURL"/>
  290. </xsl:when>
  291. <xsl:otherwise>
  292. <xsl:text>error:INVALID_HOME_DOMAIN_NAME</xsl:text>
  293. </xsl:otherwise>
  294. </xsl:choose>
  295. </xsl:when>
  296. <xsl:otherwise>
  297. <xsl:value-of select="concat( $gatewayTarget, '?', xtsext:protect((string($rawCMHomeURL)),'url','url','getdata') ) "/>
  298. </xsl:otherwise>
  299. </xsl:choose>
  300. </xsl:variable>
  301. <!-- if no ui.tool it will behave as if caller is within CC world, CC CMM etc -->
  302. <xsl:variable name="sourceComponent" select="/root/env/param[@name='ui.tool']"/>
  303. <xsl:variable name="isDCHome" select="contains($rawCMHomeURL,'ui.tool=DashboardConsole')"/>
  304. <xsl:variable name="windowMode">
  305. <xsl:call-template name="genWindowMode">
  306. <xsl:with-param name="sourceComponent" select="$sourceComponent"/>
  307. <xsl:with-param name="isDCHome" select="$isDCHome"/>
  308. </xsl:call-template>
  309. </xsl:variable>
  310. <xsl:choose>
  311. <xsl:when test="$isHomeAPI">
  312. <xsl:choose>
  313. <xsl:when test="$sanitizedHomeURL != '' and not(starts-with($sanitizedHomeURL , 'error'))">
  314. <xsl:call-template name="setupHomeAPI">
  315. <xsl:with-param name="url" select="$sanitizedHomeURL"/>
  316. <xsl:with-param name="windowMode" select="$windowMode"/>
  317. </xsl:call-template>
  318. </xsl:when>
  319. <xsl:otherwise>
  320. <xsl:call-template name="homeAPIError">
  321. <xsl:with-param name="errorMessage">
  322. <xts:string id="IDS_PAGE_INVALID_HOME_DOMAIN"><xts:param name="badURL"> <xsl:value-of select="$rawCMHomeURL"/> </xts:param></xts:string>
  323. </xsl:with-param>
  324. </xsl:call-template>
  325. </xsl:otherwise>
  326. </xsl:choose>
  327. </xsl:when>
  328. <xsl:when test="$sanitizedHomeURL != '' and not(starts-with($sanitizedHomeURL , 'error'))">
  329. <xsl:call-template name="redirect">
  330. <xsl:with-param name="url" select="$sanitizedHomeURL"/>
  331. <xsl:with-param name="windowMode" select="$windowMode"/>
  332. </xsl:call-template>
  333. </xsl:when>
  334. <xsl:when test="starts-with($sanitizedHomeURL , 'error')">
  335. <xsl:call-template name="printError">
  336. <xsl:with-param name="errorMessage">
  337. <xts:string id="IDS_PAGE_INVALID_HOME_DOMAIN"><xts:param name="badURL"> <xsl:value-of select="$rawCMHomeURL"/> </xts:param></xts:string>
  338. </xsl:with-param>
  339. </xsl:call-template>
  340. </xsl:when>
  341. </xsl:choose>
  342. </xsl:template>
  343. <!-- Build basic home query string as read from CM -->
  344. <xsl:template name="buildBasicHomeQueryString">
  345. <!-- MVC -->
  346. <xsl:variable name="mvc-redirectToN" select="/root/cookies/cookie[@name='mvc'] and not(/root/session/param[@name='mvcsys'] = 'n')"/>
  347. <xsl:variable name="mvc-gateway" select="/root/mvcSettings/configuration/property[@name='MVC_gateway']"/>
  348. <xsl:variable name="defaultquery"><xsl:value-of select="string(/root/system/param[@name='CCHome'])"/></xsl:variable>
  349. <xsl:variable name="homequery">
  350. <xsl:choose>
  351. <xsl:when test="/root/accountOptions">
  352. <xsl:value-of select="string(/root/accountOptions/cm:queryResponse/cm:account/options/value/item[name='homePage']/value)"/>
  353. </xsl:when>
  354. <xsl:otherwise>
  355. <xsl:value-of select="string(/root/newSession/cm:queryResponse/cm:queryReply[3]/cm:account/options/value/item[name='homePage']/value)"/>
  356. </xsl:otherwise>
  357. </xsl:choose>
  358. </xsl:variable>
  359. <xsl:variable name="param-sep">
  360. <xsl:choose>
  361. <xsl:when test="$homequery != '' and not(/root/env/param[@name='gohome']) and contains(string($homequery), '://') and not(contains(string($homequery), '?'))">
  362. <xsl:text>?</xsl:text>
  363. </xsl:when>
  364. <xsl:otherwise>
  365. <xsl:text>&amp;</xsl:text>
  366. </xsl:otherwise>
  367. </xsl:choose>
  368. </xsl:variable>
  369. <xsl:choose>
  370. <!-- MVC -->
  371. <!-- Detect and redirect to the N side home iff user is in mvc environment -->
  372. <xsl:when test="$mvc-redirectToN and not(/root/env/param[@name='mvc_homeredirect']) and string($mvc-gateway) != ''">
  373. <xsl:value-of select="$mvc-gateway"/>?<xsl:text/>
  374. <xsl:text>b_action=xts.run&amp;m=portal/main.xts&amp;mvc_homeredirect=true</xsl:text>
  375. </xsl:when>
  376. <xsl:when test="$homequery != '' and not(/root/env/param[@name='gohome'])">
  377. <xsl:value-of select="$homequery"/>
  378. </xsl:when>
  379. <xsl:otherwise>
  380. <xsl:value-of select="$defaultquery"/>
  381. </xsl:otherwise>
  382. </xsl:choose>
  383. <!-- add this here to indicate that we are invoking home command -->
  384. <xsl:value-of select="$param-sep"/>
  385. <xsl:text>gohome=</xsl:text>
  386. </xsl:template>
  387. <!-- Handle Recovery from Authentication Faults -->
  388. <xsl:template name="executeInternalRedirection">
  389. <xsl:choose>
  390. <!-- Handle POST-style redirection -->
  391. <xsl:when test="translate(string(env/param[@name = 'm_method']),'POST', 'post') = 'post'">
  392. <xts:sequence>
  393. <xts:append select="/root">
  394. <redirectForm action="{concat($gateway,env/param[@name='m_pathInfo'])}">
  395. <xsl:for-each select="env/param[starts-with(@name, 'o_')]">
  396. <input name="{substring-after(@name, 'o_')}" type="hidden">
  397. <value><xsl:value-of select="."/></value>
  398. </input>
  399. </xsl:for-each>
  400. </redirectForm>
  401. </xts:append>
  402. </xts:sequence>
  403. </xsl:when>
  404. <!-- Handle GET-style redirection -->
  405. <xsl:otherwise>
  406. <xsl:variable name="redirect-url">
  407. <xsl:value-of select="$gateway"/><xsl:value-of select="env/param[@name='m_pathInfo']"/><xsl:text/>
  408. <xsl:if test="count(env/param[starts-with(@name, 'o_')]) > 0">
  409. <xsl:text>?</xsl:text>
  410. <xsl:for-each select="env/param[starts-with(@name, 'o_')]">
  411. <xsl:if test="position() != 1">
  412. <xsl:text/>&amp;<xsl:text/>
  413. </xsl:if>
  414. <xsl:value-of select="substring-after(@name, 'o_')"/>=<xsl:value-of select="xtsext:protect(xtsext:urlencode(string(.)),'url',concat('NAME',substring-after(@name, 'o_')),'getdata')"/>
  415. </xsl:for-each>
  416. </xsl:if>
  417. </xsl:variable>
  418. <!-- TODO: Check for long URL before executing a GET -->
  419. <xsl:call-template name="redirect">
  420. <xsl:with-param name="url" select="$redirect-url"/>
  421. </xsl:call-template>
  422. </xsl:otherwise>
  423. </xsl:choose>
  424. </xsl:template>
  425. <xsl:template name="redirect">
  426. <xsl:param name="url"/>
  427. <xsl:param name="windowMode" select="'openSameWindow'"/>
  428. <xts:sequence>
  429. <xts:append select="/root">
  430. <redirectURL windowMode="{$windowMode}">
  431. <xsl:value-of select="$url"/>
  432. </redirectURL>
  433. </xts:append>
  434. <xsl:if test="$windowMode = 'openChromedWindow' or $windowMode = 'openChromelessWindow'">
  435. <xts:append select="/root">
  436. <back-url>
  437. <xsl:choose>
  438. <xsl:when test="string(env/param[@name='backURL']) != ''">
  439. <xsl:value-of select="string(env/param[@name='backURL'])"/>
  440. </xsl:when>
  441. <xsl:when test="string(env/param[@name='ui.backURL']) != ''">
  442. <xsl:value-of select="string(env/param[@name='ui.backURL'])"/>
  443. </xsl:when>
  444. <xsl:otherwise>
  445. <xsl:value-of select="$ICSoftwareWelcomeURL"/>
  446. </xsl:otherwise>
  447. </xsl:choose>
  448. </back-url>
  449. </xts:append>
  450. </xsl:if>
  451. </xts:sequence>
  452. </xsl:template>
  453. <xsl:template name="setupHomeAPI">
  454. <xsl:param name="url"/>
  455. <xsl:param name="windowMode" select="'chrome'"/>
  456. <!-- Process the window mode so that it fits the home api -->
  457. <xsl:variable name="openHomeIn">
  458. <xsl:choose>
  459. <xsl:when test="$windowMode= 'openChromedWindow' or $windowMode= 'openChromelessWindow'">openNewWindow</xsl:when>
  460. <xsl:otherwise>openSameWindow</xsl:otherwise>
  461. </xsl:choose>
  462. </xsl:variable>
  463. <!-- need to fix up the windowMode to send the proper paramater -->
  464. <xsl:variable name="windowModeParam">
  465. <xsl:choose>
  466. <xsl:when test="contains($windowMode,'Chromeless')">chromeless</xsl:when>
  467. <xsl:otherwise>chrome</xsl:otherwise>
  468. </xsl:choose>
  469. </xsl:variable>
  470. <xsl:variable name="windowProp">
  471. <xsl:choose>
  472. <xsl:when test="$windowMode='openChromedWindow' or $windowMode='openSameChromedWindow'"><xsl:text>location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes,directories=yes</xsl:text></xsl:when>
  473. <xsl:when test="$windowMode='openChromelessWindow' or $windowMode='openSameChromelessWindow'"><xsl:text>location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no,directories=no</xsl:text></xsl:when>
  474. </xsl:choose>
  475. </xsl:variable>
  476. <xts:sequence>
  477. <xts:append select="/root">
  478. <homeInfo>
  479. <openHomeIn><xsl:value-of select="$openHomeIn"/></openHomeIn>
  480. <windowMode><xsl:value-of select="$windowModeParam"/></windowMode>
  481. <windowProp><xsl:value-of select="$windowProp"/></windowProp>
  482. <url><xsl:value-of select="$url"/></url>
  483. </homeInfo>
  484. </xts:append>
  485. </xts:sequence>
  486. </xsl:template>
  487. <xsl:template name="homeAPIError">
  488. <xsl:param name="errorMessage" select="''"/>
  489. <xts:sequence>
  490. <xts:append select="/root">
  491. <homeInfo>
  492. <error><xsl:value-of select="$errorMessage"/></error>
  493. </homeInfo>
  494. </xts:append>
  495. </xts:sequence>
  496. </xsl:template>
  497. <!-- The Home behaviour is the same whether the HomeApi is called or not but for Home API need to parse into separate parameters
  498. so we will add whether it is chrome or chromeless here so we only calculate it once.
  499. This does not effect the non-API because it only checks chrome/chromeless for new windows since same window
  500. honours it's mode -->
  501. <xsl:template name="genWindowMode">
  502. <xsl:param name="sourceComponent" select="''"/>
  503. <xsl:param name="isDCHome" select="''"/>
  504. <xsl:choose>
  505. <!-- caller is dc (bux) -->
  506. <xsl:when test="$sourceComponent='DashboardConsole'">
  507. <xsl:choose>
  508. <!-- dc is home, window can be chrome or chromeless does not matter -->
  509. <xsl:when test="$isDCHome">
  510. <xsl:choose>
  511. <!-- dc is chrome so can open in same window -->
  512. <xsl:when test="not($isLaunchBusinessInsightChromeless)">openSameChromedWindow</xsl:when>
  513. <xsl:otherwise>openSameChromelessWindow</xsl:otherwise>
  514. </xsl:choose>
  515. </xsl:when>
  516. <!-- home is within CC world -->
  517. <xsl:otherwise>
  518. <xsl:choose>
  519. <!-- dc is chrome so can open in same window -->
  520. <xsl:when test="not($isLaunchBusinessInsightChromeless)">openSameChromedWindow</xsl:when>
  521. <!-- chromeless is set so open in new chromed window -->
  522. <xsl:otherwise>openChromedWindow</xsl:otherwise>
  523. </xsl:choose>
  524. </xsl:otherwise>
  525. </xsl:choose>
  526. </xsl:when>
  527. <!-- caller is within CC world -->
  528. <xsl:when test="not($sourceComponent='DashboardConsole')">
  529. <xsl:choose>
  530. <!-- home is within CC world -->
  531. <xsl:when test="not($isDCHome)">openSameChromedWindow</xsl:when>
  532. <xsl:otherwise>
  533. <!-- Home is dc (bux) -->
  534. <xsl:choose>
  535. <!-- dc is chrome ok to open in same window -->
  536. <xsl:when test="not($isLaunchBusinessInsightChromeless)">openSameChromedWindow</xsl:when>
  537. <!-- chromeless is set -->
  538. <xsl:otherwise>openChromelessWindow</xsl:otherwise>
  539. </xsl:choose>
  540. </xsl:otherwise>
  541. </xsl:choose>
  542. </xsl:when>
  543. </xsl:choose>
  544. </xsl:template>
  545. <xsl:template name="printError">
  546. <xsl:param name="errorMessage"/>
  547. <xts:sequence>
  548. <xts:append select="/root">
  549. <redirectionError>
  550. <xsl:value-of select="$errorMessage"/>
  551. </redirectionError>
  552. </xts:append>
  553. </xts:sequence>
  554. </xsl:template>
  555. </xsl:stylesheet>
  556. </xts:block>
  557. <xts:block
  558. id="response"
  559. dependency="redirectionLogic"
  560. mode="output"
  561. processor="XSLT"
  562. condition=".[not(/root/env/param[@name='homeAPI'])]"
  563. type="exec"
  564. mimeType="text/html"
  565. mandatory="false">
  566. <xts:logicsheet path="logicsheets/portal.xsl"/>
  567. <xsl:stylesheet version="1.0"
  568. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  569. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  570. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  571. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  572. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  573. exclude-result-prefixes="xtsext xts pf cm">
  574. <pf:variables/>
  575. <xsl:template match="/root">
  576. <xsl:variable name="windowMode" select="string(/root/redirectURL/@windowMode)"/>
  577. <xsl:variable name="back-url" select="/root/back-url"/>
  578. <xsl:variable name="redirect-url" select="string(/root/redirectURL)"/>
  579. <html lang="{/root/session/param[@name='productLocale']}">
  580. <head>
  581. <title><xts:string id="IDS_COGNOS_REPORTS"/></title>
  582. <meta http-equiv="expires" content="0"/>
  583. <!-- MVC Housekeeping ... -->
  584. <xsl:if test="$mvc-N-enabled">
  585. <script language="javascript" src="{$webcontent}/{$app}/js/cookie_jar.js"/>
  586. <script language="javascript">
  587. var sCookiePath = "<xsl:value-of select="xtsext:javascriptencode(string($cookie_path))"/>";
  588. var sCookieDomain = "<xsl:value-of select="xtsext:javascriptencode(string($cookie_domain))"/>";
  589. var sCookieSecure = "<xsl:value-of select="xtsext:javascriptencode(string($cookie_secure))"/>";
  590. delCookie("mvcpfstate");
  591. delCookie("mvcmfstate");
  592. delCookie("mvcsstate");
  593. </script>
  594. </xsl:if>
  595. <xsl:if test="$redirect-url !='' ">
  596. <xsl:choose>
  597. <!-- Redirect URL requires a new window to be opened. This happens when home requires a new browser chrome state -->
  598. <xsl:when test="$windowMode = 'openChromedWindow' or $windowMode = 'openChromelessWindow'">
  599. <xsl:variable name="windowProperties">
  600. <xsl:choose>
  601. <xsl:when test="$windowMode = 'openChromedWindow'">
  602. <xsl:text>location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes,directories=yes</xsl:text>
  603. </xsl:when>
  604. <xsl:otherwise>
  605. <xsl:text>location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no,directories=no</xsl:text>
  606. </xsl:otherwise>
  607. </xsl:choose>
  608. </xsl:variable>
  609. <script language="javascript">
  610. var backURL = '<xsl:value-of select="xtsext:javascriptencode($back-url)"/>';
  611. function doOnload()
  612. {
  613. if (!newWindow())
  614. showPopUpWarning();
  615. else
  616. returnToPreviousView();
  617. }
  618. <!-- Try and open a new window and return a handle to it to determine if it opened successfully -->
  619. function newWindow()
  620. {
  621. var windowProperties = '<xsl:value-of select="$windowProperties"/>';
  622. var windowURL = '<xsl:value-of select="xtsext:javascriptencode($redirect-url)"/>';
  623. var windowHandle = window.open(windowURL,"_blank", windowProperties);
  624. return windowHandle;
  625. }
  626. function retryWindowOpen()
  627. {
  628. var launchWindow = newWindow();
  629. returnToPreviousView();
  630. }
  631. function returnToPreviousView()
  632. {
  633. if (backURL != '')
  634. window.location.href = backURL;
  635. else
  636. {
  637. showInfoPage();
  638. hidePopUpWarning();
  639. }
  640. }
  641. function showPopUpWarning()
  642. {
  643. if (document.getElementById('popUpWarning'))
  644. document.getElementById('popUpWarning').style.display = 'block';
  645. }
  646. function hidePopUpWarning()
  647. {
  648. if (document.getElementById('popUpWarning'))
  649. document.getElementById('popUpWarning').style.display = 'none';
  650. }
  651. function showInfoPage()
  652. {
  653. if (document.getElementById('infoPage'))
  654. document.getElementById('infoPage').style.display = 'block';
  655. }
  656. </script>
  657. </xsl:when>
  658. <xsl:otherwise>
  659. <xsl:choose>
  660. <!-- execute JS-style redirection via "official" JS context -->
  661. <xsl:when test="starts-with($redirect-url,'javascript:') or /root/env/param[@name = 'm_passportID']">
  662. <script language="javascript">
  663. window.location.href = "<xsl:value-of select="xtsext:javascriptencode(string($redirect-url))"/>";
  664. </script>
  665. </xsl:when>
  666. <!-- execute other redirection -->
  667. <xsl:otherwise>
  668. <!--
  669. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  670. COGCQ00234767 - Content Expiration doesn't work when accessing main portal.
  671. Remove the use of meta tag http-equiv="refresh" since the Content Expiration setting is ignored.
  672. Use the window .replace javascript function, since it behaves like the "refresh" in that the url is
  673. not placed in the browsers history.
  674. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  675. -->
  676. <script language="javascript">
  677. window.location.replace("<xsl:value-of select="xtsext:javascriptencode(string($redirect-url))"/>");
  678. </script>
  679. </xsl:otherwise>
  680. </xsl:choose>
  681. </xsl:otherwise>
  682. </xsl:choose>
  683. </xsl:if>
  684. </head>
  685. <body bgcolor="#ffffff" onload="if (window.doOnload) doOnload()">
  686. <!-- POST-style redirection -->
  687. <xsl:if test="/root/redirectForm">
  688. <form name="pform" method="post" action="{@action}">
  689. <xsl:for-each select="/root/redirectForm/*">
  690. <input>
  691. <xsl:copy-of select="@*"/>
  692. <xsl:attribute name="value"><xsl:value-of select="./value"/></xsl:attribute>
  693. </input>
  694. </xsl:for-each>
  695. </form>
  696. <script language="javascript">document.pform.submit();</script>
  697. </xsl:if>
  698. <xsl:variable name="style" select="'font-family: Tahoma; font-size: 90%; color: #666699; padding: 50px; text-align: center;'"/>
  699. <!-- Opening a new window -->
  700. <xsl:if test="$windowMode = 'openChromedWindow' or $windowMode = 'openChromelessWindow'">
  701. <xsl:if test="$back-url = ''">
  702. <div id="infoPage" style="{$style} margin-top:100px; margin-left:100px; display:none;">
  703. <xsl:variable name="closeLink">
  704. <a href="javascript:window.close()"><xts:string id="IDS_WARN_CLOSE_THIS_PAGE_closeHyperlink"/></a>
  705. </xsl:variable>
  706. <xts:string id="IDS_WARN_CLOSE_THIS_PAGE">
  707. <xts:param name="closeHyperlink"><xsl:copy-of select="$closeLink"/></xts:param>
  708. </xts:string>
  709. </div>
  710. </xsl:if>
  711. <!-- Place holder to display warnings about pop-up blockers -->
  712. <div id="popUpWarning" style="{$style} display:none;">
  713. <xsl:variable name="homeLink">
  714. <a href="javascript:retryWindowOpen()"><xts:string id="IDS_PAGE_MENU_HOME"/></a>
  715. </xsl:variable>
  716. <xts:string id="IDS_WARN_POPUP_BLOCKER_HOME">
  717. <xts:param name="homeHyperlink"><xsl:copy-of select="$homeLink"/></xts:param>
  718. </xts:string>
  719. </div>
  720. </xsl:if>
  721. <!-- Display error -->
  722. <xsl:if test="/root/redirectionError">
  723. <div style="{$style}">
  724. <xsl:value-of select="/root/redirectionError"/>
  725. </div>
  726. </xsl:if>
  727. </body>
  728. </html>
  729. </xsl:template>
  730. </xsl:stylesheet>
  731. </xts:block>
  732. <xts:block id="responseHomeAPI" type="exec" mode="output" dependency="redirectionLogic" processor="XSLT" condition=".[/root/env/param[@name='homeAPI']]" mandatory="false" mimeType="application/javascript" contentId="responseHomeAPI" partId="part1">
  733. <xts:logicsheet path="logicsheets/portal.xsl"/>
  734. <xsl:stylesheet version="1.0" xmlns:pf="http://developer.cognos.com/schemas/xts/pf" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:xos="http://developer.cognos.com/schemas/xts/output/" xmlns:xts="http://developer.cognos.com/schemas/xts/" exclude-result-prefixes="xts xtsext">
  735. <xsl:output method="html" encoding="utf-8" indent="no"/>
  736. <xsl:template match="/">
  737. <xsl:choose>
  738. <xsl:when test="/root/homeInfo/openHomeIn">
  739. <xsl:text/>({ "home": {
  740. "openHomeIn":"<xsl:value-of select="xtsext:javascriptencode(string(/root/homeInfo/openHomeIn))"/>",
  741. "windowMode":"<xsl:value-of select="xtsext:javascriptencode(string(/root/homeInfo/windowMode))"/>",
  742. "windowProp":"<xsl:value-of select="xtsext:javascriptencode(string(/root/homeInfo/windowProp))"/>",
  743. "url":"<xsl:value-of select="xtsext:javascriptencode(string(/root/homeInfo/url))" disable-output-escaping="yes" />"}<xsl:text/>
  744. })<xsl:text/>
  745. </xsl:when>
  746. <xsl:when test="/root/homeInfo/error">
  747. <xsl:text/>({ "home": {
  748. "error":"<xsl:value-of select="xtsext:javascriptencode(string(/root/homeInfo/error))"/>"}<xsl:text/>
  749. })<xsl:text/>
  750. </xsl:when>
  751. </xsl:choose>
  752. </xsl:template>
  753. </xsl:stylesheet>
  754. </xts:block>
  755. <!-- Debug -->
  756. <!-- ============================================================================= -->
  757. <xts:block id="debug" dependency="response" condition=".[/root/env/param[@name='d'] = '1' or /root/session/param[@name='debug'] = '1']" type="exec" mode="output" processor="XSLT" mandatory="false" mimeType="text/html">
  758. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  759. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dbg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/debug/" exclude-result-prefixes="dbg">
  760. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no" omit-xml-declaration="yes"/>
  761. <dbg:templates/>
  762. <xsl:template match="/">
  763. <dbg:dumpxml select="/root"/>
  764. </xsl:template>
  765. </xsl:stylesheet>
  766. </xts:block>
  767. </xts:morphlet>