gethandler.xts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cpscrn
  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. <!-- $Header: //cpscrn/main/templates/cps4/producer/gethandler.xts#1 $ -->
  13. <!-- $DateTime: 2008/10/22 11:12:04 $ -->
  14. <!-- $Change: 25109 $ -->
  15. <xts:morphlet version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/">
  16. <xts:block id="wsdl" type="exec" mode="interpret" processor="XSLT" condition=".[/root/env/param[@name = 'wsdl']]">
  17. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  18. <xsl:template match="/">
  19. <xsl:if test="string(/root/interfaces/interfaceInfo/param[@name = 'extraInfo']) != '/cps4/portlets/cmm'">
  20. <xsl:for-each select="/root/interfaces/interfaceInfo[param[@name = 'virtualPath'] != '']">
  21. <xts:sequence>
  22. <xts:append>
  23. <xts:request protocol="FILEREAD" target="{ /root/interfaces/interfaceInfo/param[@name = 'extraInfo'] }/implementation.xml" faultBlock="interfaceFault"/>
  24. </xts:append>
  25. </xts:sequence>
  26. </xsl:for-each>
  27. </xsl:if>
  28. <!-- get gateway to determine protocol scheme (ie. https) and CpsProtocolScheme override property -->
  29. <xts:sequence>
  30. <xts:append>
  31. <xts:function name="getConfiguration">
  32. <xts:param name="gateway"/>
  33. <xts:param name="CPSProtocolScheme"/>
  34. </xts:function>
  35. </xts:append>
  36. </xts:sequence>
  37. </xsl:template>
  38. </xsl:stylesheet>
  39. </xts:block>
  40. <xts:block id="interfaceFault" type="fault" processor="XSLT">
  41. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  42. <xsl:template match="/">
  43. <error>
  44. <xsl:copy-of select="/root/fault/*"/>
  45. </error>
  46. </xsl:template>
  47. </xsl:stylesheet>
  48. </xts:block>
  49. <xts:block id="wsdl_service" dependency="wsdl" type="exec" processor="XSLT" mode="interpret">
  50. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" exclude-result-prefixes="xts xtsext">
  51. <xsl:variable name="http-param" select="/root/http/param"/>
  52. <xsl:variable name="config-property" select="/root/configuration/property"/>
  53. <xsl:template match="/">
  54. <xts:sequence>
  55. <xts:append select="/root/output">
  56. <xsl:choose>
  57. <xsl:when test="/root/error">
  58. <xos:statusCode xmlns:xos="http://developer.cognos.com/schemas/xts/output/">404</xos:statusCode>
  59. </xsl:when>
  60. <xsl:otherwise>
  61. <!--
  62. NOTE: The CGI 1.1 interface does not describe the protocol scheme (ie. https) so the following
  63. rules are used to return the correct scheme.
  64. 1) A server property called CPSProtocolScheme may be defined to override everything. The values
  65. for this property are either "http" or "https".
  66. 2) The configuration gateway parameter's protocol scheme is used.
  67. Since multiple gateways may be used, the rest of the configuration gateway parameter is discarded and
  68. the URI is reconstructed from the incomming http parameters.
  69. -->
  70. <xsl:variable name="cps-protocol-scheme" select="$config-property[@name = 'CPSProtocolScheme']"/>
  71. <xsl:variable name="gateway" select="$config-property[@name = 'gateway']"/>
  72. <xsl:variable name="gateway-scheme">
  73. <xsl:if test="contains($gateway, '://')">
  74. <xsl:value-of select="substring-before($gateway, '://')"/>
  75. </xsl:if>
  76. </xsl:variable>
  77. <xsl:variable name="protocol">
  78. <xsl:choose>
  79. <xsl:when test="$cps-protocol-scheme != ''">
  80. <xsl:value-of select="$cps-protocol-scheme"/>
  81. </xsl:when>
  82. <xsl:when test="$gateway-scheme != ''">
  83. <xsl:value-of select="$gateway-scheme"/>
  84. </xsl:when>
  85. <xsl:otherwise>http</xsl:otherwise>
  86. </xsl:choose>
  87. </xsl:variable>
  88. <!--
  89. NOTE: Support for the http param REQUEST_URI has been removed but may be required if this code is ported back to series 7.
  90. -->
  91. <xsl:variable name="path_info">
  92. <xsl:value-of select="$http-param[@name = 'PATH_INFO']"/>
  93. </xsl:variable>
  94. <xsl:variable name="server_gateway">
  95. <xsl:value-of select="concat($protocol, '://')"/>
  96. <xsl:value-of select="$http-param[@name = 'SERVER_NAME']"/>
  97. <xsl:if test="$http-param[@name = 'SERVER_PORT'] != '' and $http-param[@name = 'SERVER_PORT'] != '80'">
  98. <xsl:text>:</xsl:text>
  99. <xsl:value-of select="$http-param[@name = 'SERVER_PORT']"/>
  100. </xsl:if>
  101. <xsl:value-of select="$http-param[@name = 'SCRIPT_NAME']"/>
  102. </xsl:variable>
  103. <xsl:variable name="request-uri">
  104. <xsl:value-of select="$server_gateway"/>
  105. <xsl:value-of select="$path_info"/>
  106. </xsl:variable>
  107. <xsl:variable name="markup-binding">
  108. <xsl:choose>
  109. <xsl:when test="contains($path_info, '/wsrp/cps4/portlets/cmm')">
  110. <xsl:value-of select="$server_gateway"/>
  111. <xsl:text>/wsrp/fragments/markup/handle/cmm/edit:generic</xsl:text>
  112. </xsl:when>
  113. <xsl:otherwise>
  114. <xsl:value-of select="$request-uri"/>
  115. </xsl:otherwise>
  116. </xsl:choose>
  117. </xsl:variable>
  118. <xsl:variable name="producer-xml" select="xtsext:web64encode('/WEB-INF/fragments/producers/cmm/', true())"/>
  119. <xsl:variable name="service-description-binding">
  120. <xsl:choose>
  121. <xsl:when test="contains($path_info, '/wsrp/cps4/portlets/cmm')">
  122. <xsl:value-of select="$server_gateway"/>
  123. <xsl:text>/wsrp/fragments/description/producerxml/</xsl:text>
  124. <xsl:value-of select="$producer-xml"/>
  125. </xsl:when>
  126. <xsl:otherwise>
  127. <xsl:value-of select="$request-uri"/>
  128. </xsl:otherwise>
  129. </xsl:choose>
  130. </xsl:variable>
  131. <xsl:variable name="registration-binding">
  132. <xsl:choose>
  133. <xsl:when test="contains($path_info, '/wsrp/cps4/portlets/cmm')">
  134. <xsl:value-of select="$server_gateway"/>
  135. <xsl:text>/wsrp/fragments/registration/producerxml/</xsl:text>
  136. <xsl:value-of select="$producer-xml"/>
  137. </xsl:when>
  138. <xsl:otherwise>
  139. <xsl:value-of select="$request-uri"/>
  140. </xsl:otherwise>
  141. </xsl:choose>
  142. </xsl:variable>
  143. <xsl:variable name="portlet-management-binding">
  144. <xsl:choose>
  145. <xsl:when test="contains($path_info, '/wsrp/cps4/portlets/cmm')">
  146. <xsl:value-of select="$server_gateway"/>
  147. <xsl:text>/wsrp/fragments/management</xsl:text>
  148. </xsl:when>
  149. <xsl:otherwise>
  150. <xsl:value-of select="$request-uri"/>
  151. </xsl:otherwise>
  152. </xsl:choose>
  153. </xsl:variable>
  154. <xos:part xmlns:xos="http://developer.cognos.com/schemas/xts/output/">
  155. <xos:entityHeader>
  156. <xos:param name="Content-Type">text/xml; charset=utf-8</xos:param>
  157. </xos:entityHeader>
  158. <xos:entityBody>
  159. <wsdl:definitions targetNamespace="urn:oasis:names:tc:wsrp:v1:wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:bind="urn:oasis:names:tc:wsrp:v1:bind" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  160. <wsdl:import namespace="urn:oasis:names:tc:wsrp:v1:bind" location="http://www.oasis-open.org/committees/wsrp/specifications/version1/wsrp_v1_bindings.wsdl"/>
  161. <wsdl:service name="WSRPService">
  162. <xsl:variable name="extension" select="/root/implementation/extension"/>
  163. <xsl:apply-templates select="$extension/*[local-name()='segment']" mode="copy"/>
  164. <wsdl:port binding="bind:WSRP_v1_Markup_Binding_SOAP" name="WSRPBaseService">
  165. <soap:address location="{ $markup-binding }"/>
  166. <xsl:apply-templates select="$extension/*[local-name()='port' and @name='WSRPBaseService']/*[local-name()='portletAddress']" mode="copy"/>
  167. </wsdl:port>
  168. <wsdl:port binding="bind:WSRP_v1_ServiceDescription_Binding_SOAP" name="WSRPServiceDescriptionService">
  169. <soap:address location="{ $service-description-binding }"/>
  170. <xsl:apply-templates select="$extension/*[local-name()='port' and @name='WSRPServiceDescriptionService']/*[local-name()='portletAddress']" mode="copy"/>
  171. </wsdl:port>
  172. <wsdl:port binding="bind:WSRP_v1_Registration_Binding_SOAP" name="WSRPRegistrationService">
  173. <soap:address location="{ $registration-binding }"/>
  174. <xsl:apply-templates select="$extension/*[local-name()='port' and @name='WSRPRegistrationService']/*[local-name()='portletAddress']" mode="copy"/>
  175. </wsdl:port>
  176. <wsdl:port binding="bind:WSRP_v1_PortletManagement_Binding_SOAP" name="WSRPPortletManagementService">
  177. <soap:address location="{ $portlet-management-binding }"/>
  178. <xsl:apply-templates select="$extension/*[local-name()='port' and @name='WSRPPortletManagementService']/*[local-name()='portletAddress']" mode="copy"/>
  179. </wsdl:port>
  180. </wsdl:service>
  181. </wsdl:definitions>
  182. </xos:entityBody>
  183. </xos:part>
  184. </xsl:otherwise>
  185. </xsl:choose>
  186. </xts:append>
  187. </xts:sequence>
  188. </xsl:template>
  189. <!-- Using xsl:copy-of will sometime cause a namespace leak. To fix this, we use this template to copy the elements -->
  190. <xsl:template match="*" mode="copy">
  191. <xsl:element name="{name()}" namespace="{namespace-uri()}">
  192. <xsl:copy-of select="@*"/>
  193. <xsl:apply-templates mode="copy"/>
  194. </xsl:element>
  195. </xsl:template>
  196. <xsl:template match="text()" mode="copy">
  197. <xsl:value-of select="."/>
  198. </xsl:template>
  199. </xsl:stylesheet>
  200. </xts:block>
  201. <xts:block id="resource" type="exec" mode="interpret" processor="XSLT" condition=".[not(/root/env/param[@name = 'wsdl'])]">
  202. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  203. <xsl:template match="/">
  204. <xts:sequence>
  205. <xts:append select="/root/output">
  206. <xts:request protocol="FILEREAD" target="{ /root/interfaces/interfaceInfo/param[@name = 'extraInfo'] }" mimeType="image/gif" option="part" faultBlock="resourceFault"/>
  207. </xts:append>
  208. </xts:sequence>
  209. </xsl:template>
  210. </xsl:stylesheet>
  211. </xts:block>
  212. <xts:block id="resourceFault" type="fault" processor="XSLT">
  213. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xos="http://developer.cognos.com/schemas/xts/output/">
  214. <xsl:template match="/">
  215. <xos:statusCode xmlns:xos="http://developer.cognos.com/schemas/xts/output/">404</xos:statusCode>
  216. </xsl:template>
  217. </xsl:stylesheet>
  218. </xts:block>
  219. </xts:morphlet>