G_UIPESoapAction.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. IBM Confidential
  3. OCO Source Materials
  4. IBM Cognos Products: uipe
  5. (C) Copyright IBM Corp. 2014
  6. The source code for this program is not published or otherwise divested of its trade secrets, irrespective of what has been deposited with the U.S. Copyright Office.
  7. */
  8. /**
  9. * Query the name and store id of all the UI Profiles in CM
  10. *
  11. * @constructor
  12. * @extends C_BusRequest
  13. * @param {I_RequestListener} v_oListener The listener for this request. If null, then no events will be fired.
  14. */
  15. function C_UIProfileQueryRequest( v_oListener )
  16. {
  17. var v_aBusRequest = [];
  18. v_aBusRequest.push("<bus:query><requests>");
  19. v_aBusRequest.push(
  20. '<item xsi:type="bus:queryRequest">' +
  21. '<search xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">/catalog/catalogFolder[@name="User Interface Profiles"]/catalogFolder[@name="Report Studio Profiles"]/userInterfaceProfile</search>' +
  22. '<properties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SOAP-ENC:Array" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENC:arrayType="bus:propEnum[3]">' +
  23. ' <item xsi:type="bus:propEnum">defaultName</item>' +
  24. ' <item xsi:type="bus:propEnum">storeID</item>' +
  25. ' <item xsi:type="bus:propEnum">permissions</item>' +
  26. '</properties>' +
  27. '</item>' +
  28. '<item xsi:type="bus:queryRequest">' +
  29. '<search xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">/catalog/catalogFolder[@name="User Interface Profiles"]/catalogFolder[@name="Cognos Workspace Do More Profiles"]/userInterfaceProfile</search>' +
  30. '<properties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SOAP-ENC:Array" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENC:arrayType="bus:propEnum[3]">' +
  31. ' <item xsi:type="bus:propEnum">defaultName</item>' +
  32. ' <item xsi:type="bus:propEnum">storeID</item>' +
  33. ' <item xsi:type="bus:propEnum">permissions</item>' +
  34. '</properties>' +
  35. '</item>'
  36. );
  37. v_aBusRequest.push("</requests></bus:query>");
  38. this.F_ConstructBaseClass( v_oListener, C_BusRequest.K_sSOAPAction_contentManagerService, v_aBusRequest.join("") );
  39. };
  40. C_UIProfileQueryRequest.F_Extends( C_BusRequest );
  41. C_UIProfileQueryRequest.prototype.F_ProcessResponse = function()
  42. {
  43. this.m_oNameMap = {};
  44. C_UIProfileQueryRequest.superClass.F_ProcessResponse.call( this );
  45. var v_docSoapResponse = this.F_GetResponse();
  46. if ( !v_docSoapResponse )
  47. {
  48. return;
  49. }
  50. var v_nlProfiles = v_docSoapResponse.selectNodes( "/SOAP-ENV:Envelope/SOAP-ENV:Body/*/returns/item/queryResult/item" );
  51. if (v_nlProfiles.length == 0)
  52. {
  53. this.F_SetNewErrorRes( "IDS_BAD_PROFILES_RESPONSE", v_docSoapResponse.xml );
  54. return;
  55. }
  56. for( var i = 0; i < v_nlProfiles.length; i++ )
  57. {
  58. var v_nItem = v_nlProfiles.item( i );
  59. var v_sProfileName = v_nItem.selectSingleNode( "defaultName/value" ) ? v_nItem.selectSingleNode( "defaultName/value" ).text : "";
  60. var v_sStoreID = v_nItem.selectSingleNode( "storeID/value" ) ? v_nItem.selectSingleNode( "storeID/value" ).text : "";
  61. if ( v_sProfileName && v_sStoreID )
  62. {
  63. this.m_oNameMap[v_sProfileName] = v_sStoreID;
  64. }
  65. }
  66. };
  67. C_UIProfileQueryRequest.prototype.F_GetNameMap = function( )
  68. {
  69. return this.m_oNameMap;
  70. };
  71. /**
  72. * Save the UI Profile to CM
  73. *
  74. * @constructor
  75. * @extends C_BusRequest
  76. * @param {I_RequestListener} v_oListener The listener for this request. If null, then no events will be fired.
  77. */
  78. function C_UIProfileSaveRequest( v_oListener, v_sStoreID, v_nProfile, v_bReloadUI )
  79. {
  80. this.m_sStoreID = v_sStoreID;
  81. this.m_nProfile = v_nProfile;
  82. this.m_bReloadUI = v_bReloadUI;
  83. var v_sXML = this.f_applyNameSpace( this.m_nProfile.xml );
  84. var v_oBase64Encode = new C_Base64Codec();
  85. var v_sBase64Doc = v_oBase64Encode.F_Encode( v_sXML );
  86. var v_sBusRequest =
  87. '<bus:update>' +
  88. '<objects xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:baseClass[1]">' +
  89. '<item xsi:type="bus:userInterfaceProfile">' +
  90. '<searchPath xsi:type="bus:stringProp">' +
  91. '<value xsi:type="xsd:string">storeID("' + this.m_sStoreID + '")</value>' +
  92. '</searchPath>' +
  93. '<data xsi:type="bus:base64BinaryMIMEProp">' +
  94. '<value xsi:type="xsd:base64Binary">' + v_sBase64Doc + '</value>' +
  95. '</data>' +
  96. '<dataType xsi:type="cm:stringProp">' +
  97. '<value xsi:type="xsd:string" xml:space="preserve">application/xml</value>' +
  98. '</dataType>' +
  99. '</item>' +
  100. '</objects>' +
  101. '<options xsi:type="bus:updateOptions">' +
  102. '</options>' +
  103. '</bus:update>';
  104. this.F_ConstructBaseClass( v_oListener, C_BusRequest.K_sSOAPAction_contentManagerService, v_sBusRequest );
  105. };
  106. C_UIProfileSaveRequest.F_Extends( C_BusRequest );
  107. C_UIProfileSaveRequest.prototype.f_applyNameSpace = function( s )
  108. {
  109. return s.replace( '<RSProfile', '<RSProfile xmlns="' + G_UIPE.M_sProfileVersion + '"' );
  110. };
  111. C_UIProfileSaveRequest.prototype.F_ProcessResponse = function()
  112. {
  113. };
  114. C_UIProfileSaveRequest.prototype.F_GetProfile = function()
  115. {
  116. return this.m_nProfile;
  117. };
  118. C_UIProfileSaveRequest.prototype.F_IsReloadUI = function()
  119. {
  120. return this.m_bReloadUI;
  121. };
  122. /**
  123. * Load the UI Profile from CM
  124. *
  125. * @constructor
  126. * @extends C_BusRequest
  127. * @param {I_RequestListener} v_oListener The listener for this request. If null, then no events will be fired.
  128. */
  129. function C_UIProfileLoadRequest( v_oListener, v_sStoreID )
  130. {
  131. var v_sBusRequest =
  132. '<bus:query><requests>' +
  133. '<item xsi:type="bus:queryRequest">' +
  134. '<search xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">storeID("' + v_sStoreID + '")</search>' +
  135. '<properties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SOAP-ENC:Array" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENC:arrayType="bus:propEnum[3]">' +
  136. '<item xsi:type="bus:propEnum">data</item>' +
  137. '</properties>' +
  138. '</item>' +
  139. '</requests></bus:query>';
  140. this.F_ConstructBaseClass( v_oListener, C_BusRequest.K_sSOAPAction_contentManagerService, v_sBusRequest );
  141. };
  142. C_UIProfileLoadRequest.F_Extends( C_BusRequest );
  143. C_UIProfileLoadRequest.prototype.F_ProcessResponse = function()
  144. {
  145. C_UIProfileLoadRequest.superClass.F_ProcessResponse.call( this );
  146. var v_docSoapResponse = this.F_GetResponse();
  147. if ( !v_docSoapResponse )
  148. {
  149. return;
  150. }
  151. var v_nlProfiles = v_docSoapResponse.selectNodes( "/SOAP-ENV:Envelope/SOAP-ENV:Body/*/returns/item/queryResult/item" );
  152. if (v_nlProfiles.length == 0)
  153. {
  154. this.F_SetNewErrorRes( "IDS_BAD_PROFILES_RESPONSE", v_docSoapResponse.xml );
  155. return;
  156. }
  157. var v_nItem = v_nlProfiles.item( 0 );
  158. var v_sProfileData = v_nItem.selectSingleNode( "data/value" ) ? v_nItem.selectSingleNode( "data/value" ).text : "";
  159. var v_oBase64Codec = new C_Base64Codec();
  160. var v_sProfile = v_oBase64Codec.F_Decode( v_sProfileData );
  161. // remove any namespace for now
  162. var re = /\s+xmlns\s*=\s*["'](.+?)["']/;
  163. if (v_sProfile.search(re) == -1)
  164. {
  165. alert('Profile is missing the xmlns attribute.');
  166. }
  167. else
  168. {
  169. var v_sVersion = RegExp.$1;
  170. if ( v_sVersion == G_UIPE.M_sProfileVersion )
  171. {
  172. var v_docProfile = U_XML.F_LoadString( null, G_UIPE.F_GetInlineProfileDTD() + v_sProfile.replace(re, "") );
  173. if ( v_docProfile )
  174. {
  175. this.m_docUIProfile = v_docProfile;
  176. }
  177. else
  178. {
  179. alert("Profile does not pass profile DTD validation.");
  180. window.close();
  181. }
  182. }
  183. else
  184. {
  185. alert('Profile has xmlns of "' + v_sVersion + '" expected "' + G_UIPE.M_sProfileVersion + '"');
  186. }
  187. }
  188. };
  189. C_UIProfileLoadRequest.prototype.F_GetUIProfile = function( )
  190. {
  191. return this.m_docUIProfile ? this.m_docUIProfile.documentElement : null;
  192. };