get_portal_pages.xslt 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. <xsl:stylesheet version="1.0"
  13. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  14. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  15. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  16. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  17. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  18. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  19. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  20. exclude-result-prefixes="xts xtsext send bus cm pf">
  21. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  22. <pf:sessionpassport/>
  23. <xsl:template match="root">
  24. <xts:sequence>
  25. <!-- Read portal pages from CM -->
  26. <xts:append select="/root">
  27. <portalTabs xmlns="http://developer.cognos.com/schemas/xts-cm/1/" >
  28. <send:request provider="cm2" postxslt="transforms/CM/post-process-tabs.xslt">
  29. <bus:query xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  30. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  31. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  32. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  33. xmlns:cm2="http://developer.cognos.com/schemas/contentManagerService/1"
  34. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  35. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  36. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/">
  37. <search xsi:type="xsd:string">~</search>
  38. <properties xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:propEnum[1]">
  39. <item xsi:type="bus:propEnum">portalPages</item>
  40. </properties>
  41. <options xsi:type="bus:queryOptions">
  42. <schemaInfo xsi:type="xsd:boolean">false</schemaInfo>
  43. <refProps xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:refProp[1]">
  44. <item xsi:type="bus:refProp">
  45. <refPropName xsi:type="bus:propEnum">portalPages</refPropName>
  46. <properties xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:propEnum[5]">
  47. <item xsi:type="bus:propEnum">defaultName</item>
  48. <item xsi:type="bus:propEnum">permissions</item>
  49. <item xsi:type="bus:propEnum">searchPath</item>
  50. <item xsi:type="bus:propEnum">disabled</item>
  51. <item xsi:type="bus:propEnum">storeID</item>
  52. </properties>
  53. </item>
  54. </refProps>
  55. </options>
  56. </bus:query>
  57. </send:request>
  58. </portalTabs>
  59. </xts:append>
  60. <!-- Remove any objects from the portal pages array that we don't support (CC only supports objects of type pagelet, content and folder when it is the root personal folder only) -->
  61. <xts:delete select="/root/portalTabs/*[(local-name() != 'content' and local-name() != 'pagelet' and local-name() != 'folder') or (local-name() = 'folder' and ./*[local-name() = 'storeID'] != /root/session/param[@name='mrootid'] ) ] "/>
  62. <xsl:if test="string(/root/system/param[@name='hideInaccessibleTabs']) = 'true'">
  63. <!-- Throw away inaccessible tabs -->
  64. <xts:delete select="/root/*[local-name()='portalTabs']/*[not(contains(concat(' ', ./*[local-name() = 'permissions'], ' '), ' execute '))] "/>
  65. <!-- Update cached id of the first tab in case it happens to be one of the tabs we tosses away above -->
  66. <xts:replace select="/root/session/param[@name='dcid']"><param name="dcid"><xts:queryValue select="/root/*[local-name()='portalTabs']/*/*[local-name()='storeID']"/></param></xts:replace>
  67. </xsl:if>
  68. <xts:append>
  69. <TDS-set>
  70. <xts:function name="TDSRequest">
  71. <xts:param name="action">set</xts:param>
  72. <xts:param name="session-id"><xsl:value-of select="$passport"/></xts:param>
  73. <xts:param name="name"><xsl:value-of select="'ccPages'"/></xts:param>
  74. <xts:param name="source">
  75. <xts:transform xmlns:xts="http://developer.cognos.com/schemas/xts/" name="XMLEncode">
  76. <xts:queryNode select="/root/*[local-name()= 'portalTabs']"/>
  77. </xts:transform>
  78. </xts:param>
  79. </xts:function>
  80. </TDS-set>
  81. </xts:append>
  82. <!-- New cache stamp -->
  83. <xsl:variable name="cachestamp" select="xtsext:getCurrentDateTime('EST')"/>
  84. <xsl:choose>
  85. <xsl:when test="/root/session/param[@name='cachestamp']">
  86. <xts:replace select="/root/session/param[@name='cachestamp']">
  87. <param name="cachestamp"><xsl:value-of select="$cachestamp"/></param>
  88. </xts:replace>
  89. </xsl:when>
  90. <xsl:otherwise>
  91. <xts:append select="/root/session">
  92. <param name="cachestamp"><xsl:value-of select="$cachestamp"/></param>
  93. </xts:append>
  94. </xsl:otherwise>
  95. </xsl:choose>
  96. <!-- Tell the set session block to repack the cc session cookie -->
  97. <xts:append>
  98. <updateSession/>
  99. </xts:append>
  100. <!-- Add the tabs to where they would normally be stored -->
  101. <xts:replace select="/root/cmContent/*[local-name()='queryResponse']/*[local-name()='queryReply'][1]/*[local-name()='runTimeState']">
  102. <runTimeState xmlns="http://developer.cognos.com/schemas/xts-cm/1/" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  103. <xts:queryNode select="/root/*[local-name()= 'portalTabs']"/>
  104. </runTimeState>
  105. </xts:replace>
  106. </xts:sequence>
  107. </xsl:template>
  108. </xsl:stylesheet>