copy.xts 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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, 2014
  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. Copies an object in CM based on parameters passed in.
  14. Should create a CM command like so:
  15. <copy xmlns="http://developer.cognos.com/schemas/xts-cm/1/" select="/Contents/folder/report" target="/Contents/folder2/report2"/>
  16. -->
  17. <xts:morphlet xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:cml="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/cml/1/" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" xmlns:create="http://developer.cognos.com/schemas/xts/portal/iFrmCmd/1/" xmlns:cms="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/cms/1/">
  18. <xts:block id="doCopy" processor="XSLT" type="exec">
  19. <xts:logicsheet path="portal/iFrmCmd/logicsheets/cm-save.xsl"/>
  20. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  21. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  22. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  23. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  24. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  25. xmlns:form="http://developer.cognos.com/schemas/xts/portal/iFrmCmd/1/"
  26. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  27. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  28. exclude-result-prefixes="xtsext">
  29. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  30. <xsl:template match="/">
  31. <xsl:apply-templates select="root/command/form:copy"/>
  32. </xsl:template>
  33. <xsl:template match="form:env">
  34. <xts:sequence>
  35. <xts:append>
  36. <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
  37. <send:request provider="cm" faultBlock="copyFault">
  38. <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
  39. <cm:copy xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  40. <cm:objects xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  41. <xsl:choose>
  42. <!-- Single object copy operation -->
  43. <xsl:when test="(form:param[@name = 'm_obj'] and (form:param[@name = 'm_obj'] != ''))">
  44. <cm:nil>
  45. <cm:searchPath><xsl:value-of select="form:param[@name = 'm_obj']"/></cm:searchPath>
  46. </cm:nil>
  47. </xsl:when>
  48. <!-- Group copy operation -->
  49. <xsl:otherwise>
  50. <xsl:copy-of select="form:clipboard/*"/>
  51. </xsl:otherwise>
  52. </xsl:choose>
  53. </cm:objects>
  54. <cm:target>
  55. <xsl:value-of select="form:param[@name = 'm_p_path']"/>
  56. </cm:target>
  57. <xsl:if test="form:param[@name='m_obj']">
  58. <cm:newName><xsl:value-of select="form:param[@name='m_p_defaultName']"/></cm:newName>
  59. </xsl:if>
  60. <xsl:choose>
  61. <xsl:when test="form:param[@name='overwriteExistingItems'] = 'true'">
  62. <xsl:choose>
  63. <xsl:when test="form:param[@name='cmdErrorUpdateActionReplace'] = 'true'">
  64. <cm:options recursive="true" updateAction="replace"/>
  65. </xsl:when>
  66. <xsl:otherwise>
  67. <!-- "replace" by default -->
  68. <xsl:choose>
  69. <xsl:when test="string(/root/system/param[@name = 'updateTargetObjectWhenOverwrite']) = 'true'">
  70. <cm:options recursive="true" updateAction="update"/>
  71. </xsl:when>
  72. <xsl:otherwise>
  73. <cm:options recursive="true" updateAction="replace"/>
  74. </xsl:otherwise>
  75. </xsl:choose>
  76. </xsl:otherwise>
  77. </xsl:choose>
  78. </xsl:when>
  79. <xsl:otherwise>
  80. <cm:options recursive="true" updateAction="fail"/>
  81. </xsl:otherwise>
  82. </xsl:choose>
  83. </cm:copy>
  84. </xts:transform>
  85. </send:request>
  86. </xts:transform>
  87. </xts:append>
  88. </xts:sequence>
  89. </xsl:template>
  90. </xsl:stylesheet>
  91. </xts:block>
  92. <!--
  93. Performs any additional operations after the copy has successfully completed
  94. -->
  95. <xts:block id="postCopy" processor="XSLT" type="exec" dependency="doCopy" condition=".[/root/*[local-name()='copyResponse']//*[local-name()='storeID']]" mandatory="false">
  96. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  97. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  98. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  99. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  100. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  101. xmlns:form="http://developer.cognos.com/schemas/xts/portal/iFrmCmd/1/"
  102. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/">
  103. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  104. <xsl:template match="/">
  105. <xsl:apply-templates select="root/command/form:copy"/>
  106. </xsl:template>
  107. <xsl:template match="form:env">
  108. <xsl:if test="form:param[@name='cmdAquirePermissionsFromTargetParent'] = 'true'">
  109. <xsl:variable name="targetStoreID" select="/root/*[local-name()='copyResponse']//*[local-name()='storeID']"/>
  110. <xts:sequence>
  111. <xts:append>
  112. <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
  113. <send:request provider="cm" faultBlock="copyFault">
  114. <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
  115. <cm:update>
  116. <cm:objects xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  117. <xsl:variable name="objType" select="name(/root/*[local-name()='copyResponse']/*)"/>
  118. <xsl:element name="{$objType}">
  119. <cm:searchPath>
  120. <xsl:value-of select="concat('storeID(&quot;',string($targetStoreID),'&quot;)')"/>
  121. </cm:searchPath>
  122. <cm:policies/>
  123. </xsl:element>
  124. </cm:objects>
  125. </cm:update>
  126. </xts:transform>
  127. </send:request>
  128. </xts:transform>
  129. </xts:append>
  130. </xts:sequence>
  131. </xsl:if>
  132. </xsl:template>
  133. </xsl:stylesheet>
  134. </xts:block>
  135. <xts:block id="copyFault" type="fault" processor="XSLT">
  136. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  137. <xsl:output method="xml"/>
  138. <xsl:template match="/root/fault">
  139. <xsl:choose>
  140. <xsl:when test="./*[local-name() = 'exception']/*[local-name() = 'exceptionDetail']/*[local-name() = 'exception']/*[local-name()='errorCode'] = 'cmNameConflict'">
  141. <copyFault>
  142. <xsl:copy-of select="."/>
  143. </copyFault>
  144. </xsl:when>
  145. <xsl:otherwise>
  146. <xsl:copy-of select="."/>
  147. </xsl:otherwise>
  148. </xsl:choose>
  149. </xsl:template>
  150. <xsl:template match="text()"/>
  151. </xsl:stylesheet>
  152. </xts:block>
  153. <xts:block id="result" processor="XSLT" type="exec" mode="output" mimeType="text/xml" dependency="postCopy">
  154. <xts:logicsheet path="logicsheets/cm-logic.xsl"/>
  155. <xsl:stylesheet xmlns:form="http://developer.cognos.com/schemas/xts/portal/iFrmCmd/1/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:cml="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/cml/1/" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" version="1.0">
  156. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  157. <xsl:template match="/root">
  158. <xsl:choose>
  159. <xsl:when test="bus:response"><xsl:copy-of select="bus:response/child::*"/></xsl:when>
  160. <xsl:when test="./copyFault">
  161. <error>
  162. <errorCode>
  163. <xsl:value-of select="./copyFault/fault/*[local-name()='exception']/*[local-name()='exceptionDetail']/*[local-name()='exception']/*[local-name()='errorCode']"/>
  164. </errorCode>
  165. <xsl:if test="/root/command/form:copy/form:env/form:param[@name='overwriteExistingItems'] = 'true'">
  166. <errorCodeDetails>failOnOverwrite</errorCodeDetails>
  167. </xsl:if>
  168. <errorMessage>
  169. <xsl:value-of select="./copyFault/fault/*[local-name()='exception']/*[local-name()='exceptionDetail']/*[local-name()='exception']/*[local-name()='message']/*[local-name()='messageString']"/>
  170. </errorMessage>
  171. </error>
  172. </xsl:when>
  173. <xsl:otherwise><error/></xsl:otherwise>
  174. </xsl:choose>
  175. </xsl:template>
  176. <xsl:template match="text()"/>
  177. </xsl:stylesheet>
  178. </xts:block>
  179. </xts:morphlet>