RegistrationServiceImpl.xts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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/wsrp-impl/RegistrationServiceImpl.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="execution" type="exec" mode="interpret" processor="XSLT" nodelist="envelope,implementation">
  17. <xsl:stylesheet version="1.0"
  18. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  19. xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types"
  20. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  21. xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
  22. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt">
  23. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  24. <xsl:variable name="op" select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Body/*[1]"/>
  25. <xsl:variable name="op-name" select="local-name($op)"/>
  26. <xsl:variable name="version" select="/root/implementation/@version"/>
  27. <xsl:template match="/">
  28. <xts:sequence>
  29. <xts:append select="/root/output">
  30. <xos:part>
  31. <xos:entityHeader>
  32. <xos:param name="Content-type">text/xml</xos:param>
  33. </xos:entityHeader>
  34. <xos:entityBody>
  35. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  36. <SOAP-ENV:Body>
  37. <xsl:choose>
  38. <xsl:when test="$op-name = 'register'">
  39. <wsrp:registerResponse>
  40. <wsrp:registrationHandle>
  41. <xsl:value-of select="xtsext:generateGUID()"/>
  42. </wsrp:registrationHandle>
  43. <wsrp:registrationState>
  44. <xsl:call-template name="create-state">
  45. <xsl:with-param name="data" select="$op"/>
  46. </xsl:call-template>
  47. </wsrp:registrationState>
  48. <xsl:if test="$version">
  49. <wsrp:extensions>
  50. <cpsext:version xmlns:cpsext="http://developer.cognos.com/schemas/cps/wsrp/extensions/1/"><xsl:value-of select="$version"/></cpsext:version>
  51. </wsrp:extensions>
  52. </xsl:if>
  53. </wsrp:registerResponse>
  54. </xsl:when>
  55. <xsl:when test="$op-name = 'modifyRegistration'">
  56. <wsrp:modifyRegistrationResponse>
  57. <wsrp:registrationState>
  58. <xsl:call-template name="create-state">
  59. <xsl:with-param name="data" select="$op/wsrp:registrationData"/>
  60. </xsl:call-template>
  61. </wsrp:registrationState>
  62. </wsrp:modifyRegistrationResponse>
  63. </xsl:when>
  64. <xsl:when test="$op-name = 'deregister'">
  65. <wsrp:deregisterResponse/>
  66. </xsl:when>
  67. </xsl:choose>
  68. </SOAP-ENV:Body>
  69. </SOAP-ENV:Envelope>
  70. </xos:entityBody>
  71. </xos:part>
  72. </xts:append>
  73. </xts:sequence>
  74. </xsl:template>
  75. <xsl:template name="create-state">
  76. <xsl:param name="data"/>
  77. <xsl:variable name="state">
  78. <!-- consumerAgent -->
  79. <xsl:call-template name="gen-param">
  80. <xsl:with-param name="name" select="'consumerAgent'"/>
  81. <xsl:with-param name="value">
  82. <xsl:variable name="agent" select="$data/wsrp:consumerAgent"/>
  83. <xsl:choose>
  84. <xsl:when test="contains($agent, 'WebSphere')">websphere</xsl:when>
  85. <xsl:when test="contains($agent, 'Liferay')">liferay</xsl:when>
  86. <xsl:when test="contains($agent, 'Plumtree')">plumtree</xsl:when>
  87. <xsl:when test="contains($agent, 'SAP')">sap</xsl:when>
  88. <xsl:when test="contains($agent, 'Cognos')">cognos</xsl:when>
  89. <xsl:when test="contains($agent, 'Sharepoint')">sharepoint</xsl:when>
  90. <xsl:otherwise>default</xsl:otherwise>
  91. </xsl:choose>
  92. </xsl:with-param>
  93. </xsl:call-template>
  94. <!-- properties -->
  95. <xsl:for-each select="$data/wsrp:registrationProperties">
  96. <xsl:call-template name="gen-param">
  97. <xsl:with-param name="name" select="@name"/>
  98. <xsl:with-param name="value" select="wsrp:stringValue"/>
  99. </xsl:call-template>
  100. </xsl:for-each>
  101. </xsl:variable>
  102. <xsl:value-of select="xtsext:base64encode( string( $state ), true())"/>
  103. </xsl:template>
  104. <xsl:template name="gen-param">
  105. <xsl:param name="name" select="@name"/>
  106. <xsl:param name="value" select="wsrp:value"/>
  107. <xsl:text>&lt;param name="</xsl:text>
  108. <xsl:value-of select="$name"/>
  109. <xsl:text>"></xsl:text>
  110. <xsl:value-of select="xtsext:xmlencode(string($value))"/>
  111. <xsl:text>&lt;/param></xsl:text>
  112. </xsl:template>
  113. </xsl:stylesheet>
  114. </xts:block>
  115. </xts:morphlet>