monitor.xts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. <!--======================================================================
  13. "monitor" command is used to perform the following actions:
  14. - start
  15. - stop
  16. - test
  17. - unregister
  18. ======================================================================-->
  19. <xts:morphlet xmlns:xts="http://developer.cognos.com/schemas/xts/" requiredCapability="canUseAdministrationPortal">
  20. <xts:block id="doAction" processor="XSLT" type="exec">
  21. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  22. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" xmlns:form="http://developer.cognos.com/schemas/xts/portal/iFrmCmd/1/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" version="1.0">
  23. <xsl:variable name="prefix" select="'checkbox_'"/>
  24. <xsl:template match="/root/command/form:monitor/form:env">
  25. <xsl:variable name="action">
  26. <xsl:value-of select="form:param[@name='ifrmcmd']"/>
  27. </xsl:variable>
  28. <xsl:variable name="imm">
  29. <xsl:value-of select="form:param[@name='m_smt_imm']"/>
  30. </xsl:variable>
  31. <xsl:choose>
  32. <!-- ==================================================
  33. = perform actions from tools monitor page. =
  34. ===================================================-->
  35. <xsl:when test="form:param[starts-with(@name,$prefix)] and not($action='activate')">
  36. <xsl:for-each select="form:param[starts-with(@name,$prefix)]">
  37. <xsl:call-template name="send-requests">
  38. <xsl:with-param name="path" select="xtsext:urldecode(string(.))"/>
  39. <xsl:with-param name="action" select="$action"/>
  40. <xsl:with-param name="imm" select="$imm"/>
  41. </xsl:call-template>
  42. </xsl:for-each>
  43. </xsl:when>
  44. <!-- ==================================================
  45. = perform actions from actions page =
  46. ===================================================-->
  47. <xsl:otherwise>
  48. <xsl:call-template name="send-requests">
  49. <xsl:with-param name="path" select="form:param[@name = 'm_obj']"/>
  50. <xsl:with-param name="action" select="$action"/>
  51. <xsl:with-param name="imm" select="$imm"/>
  52. </xsl:call-template>
  53. </xsl:otherwise>
  54. </xsl:choose>
  55. </xsl:template>
  56. <!--===============================================================================================
  57. Send monitor actions.
  58. ===============================================================================================-->
  59. <xsl:template name="send-requests">
  60. <xsl:param name="path"/>
  61. <xsl:param name="action"/>
  62. <xsl:param name="imm"/>
  63. <xts:sequence>
  64. <xts:append>
  65. <monitorResponse>
  66. <path><xsl:value-of select="$path"/></path>
  67. <xsl:choose>
  68. <!-- ================ action: start =================== -->
  69. <xsl:when test="$action = 'start'">
  70. <!-- startService requst to dispatcher. TODO: need to be revised !!!-->
  71. <send:request provider="dispatcher" faultBlock="faultHandler">
  72. <bus2:startService xmlns:bus2="http://developer.cognos.com/schemas/bibus/3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  73. <service xsi:type="xsd:string">
  74. <xsl:value-of select="$path"/>
  75. </service>
  76. </bus2:startService>
  77. </send:request>
  78. </xsl:when>
  79. <!-- ================ action: stop =================== -->
  80. <xsl:when test="$action = 'stop'">
  81. <!-- stopService requst to dispatcher. TODO: need to be revised !!!-->
  82. <send:request provider="dispatcher" faultBlock="faultHandler">
  83. <bus2:stopService xmlns:bus2="http://developer.cognos.com/schemas/bibus/3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  84. <service xsi:type="xsd:string">
  85. <xsl:value-of select="$path"/>
  86. </service>
  87. <immediately xsi:type="xsd:boolean">
  88. <xsl:choose>
  89. <xsl:when test="$imm = 'true' ">true</xsl:when>
  90. <xsl:otherwise>false</xsl:otherwise>
  91. </xsl:choose>
  92. </immediately>
  93. </bus2:stopService>
  94. </send:request>
  95. </xsl:when>
  96. <!-- ================ action: test (ping) =================== -->
  97. <xsl:when test="$action = 'test'">
  98. <!-- send ping request to dispatcher/services. TODO: need to be revised !!!-->
  99. <send:request provider="dispatcher" faultBlock="faultHandler">
  100. <bus2:ping xmlns:bus2="http://developer.cognos.com/schemas/bibus/3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  101. <dispatcher xsi:type="xsd:string">
  102. <xsl:value-of select="$path"/>
  103. </dispatcher>
  104. </bus2:ping>
  105. </send:request>
  106. </xsl:when>
  107. <!-- ================ action: unregister ( dispatcher) =================== -->
  108. <xsl:when test="$action = 'unregister'">
  109. <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
  110. <send:request provider="cm" faultBlock="faultHandler">
  111. <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
  112. <cm:delete xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  113. <cm:search>
  114. <xsl:value-of select="$path"/>
  115. </cm:search>
  116. <cm:options recursive="true" force="true"/>
  117. </cm:delete>
  118. </xts:transform>
  119. </send:request>
  120. </xts:transform>
  121. </xsl:when>
  122. <!-- ================ action: set_default_active (cm) =================== -->
  123. <xsl:when test="$action = 'set_default_active'">
  124. <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
  125. <send:request provider="cm" faultBlock="faultHandler">
  126. <bus2:update xmlns:bus2="http://developer.cognos.com/schemas/bibus/3/"
  127. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  128. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  129. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  130. xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  131. <objects xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus2:baseClass[1]">
  132. <item xsi:type="bus2:contentManagerService">
  133. <searchPath xsi:type="bus2:stringProp">
  134. <value xsi:type="xsd:string">
  135. <xsl:value-of select="$path"/>
  136. </value>
  137. </searchPath>
  138. <startAsActive xsi:type="bus2:booleanProp">
  139. <value xsi:type="xsd:boolean">true</value>
  140. </startAsActive>
  141. </item>
  142. </objects>
  143. </bus2:update>
  144. </send:request>
  145. </xts:transform>
  146. </xsl:when>
  147. <!-- ================ action: activate (cm) =================== -->
  148. <xsl:when test="$action = 'activate'">
  149. <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
  150. <send:request provider="cm" faultBlock="faultHandler">
  151. <bus2:activate xmlns:bus2="http://developer.cognos.com/schemas/bibus/3/"
  152. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  153. <contentManagerURI xsi:type="xsd:string">
  154. <xsl:value-of select="$path"/>
  155. </contentManagerURI>
  156. </bus2:activate>
  157. </send:request>
  158. </xts:transform>
  159. </xsl:when>
  160. </xsl:choose>
  161. </monitorResponse>
  162. </xts:append>
  163. </xts:sequence>
  164. </xsl:template>
  165. </xsl:stylesheet>
  166. </xts:block>
  167. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-Fault handler=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  168. <xts:block id="faultHandler" type="fault" processor="XSLT">
  169. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  170. <xsl:output method="xml"/>
  171. <xsl:template match="/root/fault">
  172. <copyFault>
  173. <xsl:copy-of select="."/>
  174. </copyFault>
  175. </xsl:template>
  176. <xsl:template match="text()"/>
  177. </xsl:stylesheet>
  178. </xts:block>
  179. <!-- Although using XSLTC can complile, it doesn't work properly -->
  180. <xts:block id="result" processor="XSLT" type="exec" mode="output" mimeType="text/xml" dependency="doAction">
  181. <xts:logicsheet path="logicsheets/cm-logic.xsl"/>
  182. <xsl:stylesheet version="1.0"
  183. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  184. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  185. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  186. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  187. xmlns:form="http://developer.cognos.com/schemas/xts/portal/iFrmCmd/1/">
  188. <xsl:template match="/">
  189. <response xmlns="http://developer.cognos.com/schemas/xts/admin/iServerManagement/1/">
  190. <xsl:apply-templates/>
  191. <xsl:if test="/root/command/form:monitor[@debug='true']">
  192. <debug>
  193. <xsl:copy-of select="/root"/>
  194. </debug>
  195. </xsl:if>
  196. </response>
  197. </xsl:template>
  198. <xsl:template match="monitorResponse[.//xts:exception]">
  199. <status success="false">
  200. <path><xsl:value-of select="path"/></path>
  201. <detail>
  202. <xsl:for-each select=".//xts:exception/*[local-name()='exceptionDetail']/*[local-name()='exception']">
  203. <error>
  204. <xsl:if test="@errorCode != ''">
  205. <xsl:value-of select="@errorCode"/>
  206. <xsl:text>-</xsl:text>
  207. </xsl:if>
  208. <xsl:choose>
  209. <xsl:when test="@errorCodeString != ''">
  210. <xsl:value-of select="@errorCodeString"/>
  211. </xsl:when>
  212. <xsl:when test="./*[local-name()='message']/*[local-name()='messageString']">
  213. <xsl:value-of select="./*[local-name()='message']/*[local-name()='messageString']"/>
  214. </xsl:when>
  215. <xsl:otherwise>
  216. <xsl:value-of select="./*[local-name()='message']"/>
  217. </xsl:otherwise>
  218. </xsl:choose>
  219. </error>
  220. </xsl:for-each>
  221. </detail>
  222. </status>
  223. </xsl:template>
  224. <xsl:template match="monitorResponse[not (.//xts:exception) and not (//cm:deleteResponse/@count=0)]">
  225. <status success="true">
  226. <path><xsl:value-of select="path"/></path>
  227. <xsl:copy-of select="./*[local-name()='pingResponse']/*"/>
  228. </status>
  229. </xsl:template>
  230. <xsl:template match="monitorResponse[not (.//xts:exception) and (//cm:deleteResponse/@count=0)] ">
  231. <status success="false" count="0">
  232. <path><xsl:value-of select="path"/></path>
  233. </status>
  234. </xsl:template>
  235. <xsl:template match="text()"/>
  236. </xsl:stylesheet>
  237. </xts:block>
  238. </xts:morphlet>