getSpDetails.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /********************************************************************************************************************************
  2. * Licensed Materials - Property of IBM *
  3. * *
  4. * IBM Cognos Products: AGS *
  5. * *
  6. * (C) Copyright IBM Corp. 2005, 2010 *
  7. * *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
  9. *********************************************************************************************************************************/
  10. var GET_SP_DETAILS_RESPONSE_ROOT = "getSpDetailsResponse";
  11. var GET_SP_DETAILS_PACKAGE = "getSpPackage";
  12. var GET_SP_DETAILS_CONTEXT = "getSpDetails_context";
  13. var GET_SP_DETAILS_SP_NAME = "getSpDetails_sp_name";
  14. var GET_SP_MARKUP = "markup";
  15. var current_task_id;
  16. var current_sp_name;
  17. var doGetSpDetailsRequestURL;
  18. //called to initiate the asynch requests
  19. //this is a special method for the stored proc page
  20. //the sp page has to use asynch to get the select drop down
  21. //markup
  22. function startGetSpParametersRequest(sql_package, context, sp_name, taskId){
  23. applicationActionManager.blockActions();
  24. current_sp_name = sp_name;
  25. current_task_id = taskId;
  26. doGetSpDetailsRequest(getGetSpDetailsRequestString(sql_package, context, sp_name, taskId));
  27. }
  28. function resendSpDetailsRequest() {
  29. getCommandStackManager().getCommandStack().push("doGetSpDetailsRequest()");
  30. }
  31. function doGetSpDetailsRequest(request,isSecondary)
  32. {
  33. if (request == undefined || request.length ==0) {
  34. request = doGetSpDetailsRequestURL;
  35. } else if (!isSecondary) {
  36. doGetSpDetailsRequestURL = request;
  37. }
  38. // build up the URL
  39. var url = "b_action=xts.run";
  40. url += URIEncode("m","/ags/async/asyncConv.xts");
  41. url += URIEncode("buildResponseXTS","/ags/async/getSpDetailsResponse.xts");
  42. // force SOAPFault for passport expire instead of getting a logon page
  43. url += URIEncode("forceSOAPFault","false");
  44. url += request;
  45. if (cafContextId != "") {
  46. url += URIEncode("cafcontextid",cafContextId);
  47. //SEC_INFO url - The request is not parsed as a string so should not be subject to an injection attack
  48. }
  49. try{
  50. // send off the resquest
  51. sendDispatcherRequestWithXMLTextResponse(url, getSpDetailsXMLTextResponse);
  52. }catch(ex){
  53. applicationActionManager.allowActions(ex);
  54. }
  55. }
  56. // utility function
  57. function getGetSpDetailsRequestString(sql_package, context, sp_name, taskId)
  58. {
  59. current_task_id = taskId;
  60. var sURL = "";
  61. var pl = "pl";
  62. var cl = "cl";
  63. var locales = getLocales(cl, pl);
  64. sURL += URIEncode(pl, locales[pl]);
  65. sURL += URIEncode(cl, locales[cl]);
  66. sURL += URIEncode("sql_package", sql_package);
  67. sURL += URIEncode("model", sql_package + "/model[last()]");
  68. sURL += URIEncode("inlineSpecType", "reportServiceMetadataSpecification");
  69. sURL += URIEncode("buildRequestXTS","/ags/async/spRequest.xts");
  70. sURL += URIEncode("context", context);
  71. sURL += URIEncode("method", "runSpecification");
  72. sURL += URIEncode("parameterValues", getConnectionParameterValues(sp_name + taskId));
  73. sURL += URIEncode("displayedPage", "sql");
  74. // always have to ask for credential parameters too
  75. sURL += URIEncode("credentialParameters", "true");
  76. //SEC_INFO sUrl - The request is not parsed as a string so should not be subject to an injection attack
  77. return sURL;
  78. }
  79. function getSpDetailsXMLTextResponse(responseArray)
  80. {
  81. // get the values returned
  82. var responseXML = responseArray[0];
  83. var responseText = responseArray[1];
  84. var workingRoot = responseXML.getElementsByTagName(ASYNC_WORKING);
  85. var promptingRoot = responseXML.getElementsByTagName(ASYNC_PROMPTING);
  86. var getParametersResponseRoot = responseXML.getElementsByTagName(GET_SP_DETAILS_RESPONSE_ROOT);
  87. var httpStop = true;
  88. var parsedResponse = parseResponse(responseXML,responseText);
  89. // decide what we're going to do
  90. //This is a case when getContent in asyncConv faults with either session expiry or
  91. //external logon to a different name space fault.
  92. if (parsedResponse.isLogonFault()) {
  93. doPassportExpire(responseXML,resendSpDetailsRequest,parsedResponse);
  94. } else if (parsedResponse.isSoapFault()) {
  95. if (parsedResponse.isCancelledWait()) {
  96. //This was a server cancelled wait. We need to resubmit. This could happen
  97. //if we have a SSO on and we hit an password protected external datasource,
  98. //The dispacther will fire the same request again, in this wait fired twice
  99. //Will cancel conversation if first wait fails. WO1903, WO2338
  100. resendSpDetailsRequest();
  101. setTimeout("getCommandStackManager().processCommandStack()", 100);
  102. } else {
  103. // we have a fault which is a genuine fault fault
  104. doSOAPFault(responseXML,tidyParametersDiv,parsedResponse);
  105. }
  106. } else if (workingRoot.length == 1) {
  107. httpStop = false;
  108. // we have a working response
  109. doWorking(workingRoot[0], "doGetSpDetailsRequest");
  110. } else if (promptingRoot.length == 1) {
  111. // are we prompting - promptGetSpDetailsResponse
  112. doPrompting(promptingRoot[0], 4);
  113. } else if (getParametersResponseRoot.length == 1) {
  114. httpStop = false;
  115. // we have the actually information
  116. useGetSpDetailsResponse(getParametersResponseRoot[0]);
  117. } else {
  118. tidyParametersDiv();
  119. if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) {
  120. // check the text response to see if we got a html page back in the response
  121. doHTMLResponse(responseText);
  122. } else {
  123. // send the alert
  124. alert(asyncGetParametersError_string);
  125. }
  126. }
  127. if(httpStop){
  128. applicationActionManager.allowActions();
  129. }
  130. }
  131. function promptGetSpDetailsResponse(parameters, response, conversation, clientContext, tracking)
  132. {
  133. if (response == "Cancel" || response == "Error")
  134. {
  135. // we don't want to close everything down - so just cancel the prompt and parameter load
  136. injectHTML("");
  137. // hide the dialog frame
  138. hideDialogFrame();
  139. }
  140. else
  141. {
  142. // we're passed the parameters - so save them for the task
  143. saveParameterValues(parameters, current_sp_name + current_task_id);
  144. // send the context and the final response from prompts back
  145. var request = getGetSpDetailsRequestString(null, clientContext, current_sp_name, current_task_id);
  146. //request += URIEncode("context", clientContext);
  147. request += URIEncode("promptResponse", response);
  148. request += URIEncode("disp_trackingInfo", tracking);
  149. // hide the dialog frame
  150. hideDialogFrame();
  151. //SEC_INFO request - javascript encode the request prior to firing setTimeout. The
  152. //setTimeout function will un-encode the request before it is submitted
  153. request = jsStrEncode(request);
  154. // resubmit the request
  155. setTimeout("doGetSpDetailsRequest(\'" + request + "\');",100);
  156. }
  157. }
  158. function useGetSpDetailsResponse(responseRootNode)
  159. {
  160. // get the spDetails returned
  161. var getParamsPackage = responseRootNode.getElementsByTagName(GET_SP_DETAILS_PACKAGE);
  162. var getParamsContext = responseRootNode.getElementsByTagName(GET_SP_DETAILS_CONTEXT);
  163. var getParamsSpName = responseRootNode.getElementsByTagName(GET_SP_DETAILS_SP_NAME);
  164. var getParamsMarkup = responseRootNode.getElementsByTagName(GET_SP_MARKUP);
  165. var sp_package = getTextNodeValue(getParamsPackage[0]);
  166. var sp_name = getTextNodeValue(getParamsSpName[0]);
  167. var context = getTextNodeValue(getParamsContext[0]);
  168. var markup = getParamsMarkup ? getTextNodeValue(getParamsMarkup[0]) : "";
  169. var taskId = sp_name + current_task_id;
  170. if(!sp_package || ! sp_name){
  171. clearParametersValues();
  172. injectHTML(markup ? markup : "");
  173. }else{
  174. var request = parent.getConfigFrame().getGetParametersQfSpecificationRequestString(sp_package, sp_name, context, taskId);
  175. var command = "parent.getConfigFrame().startGetParametersRequest('" + jsStrEncode(request) + "', parent.getConfigFrame().getGetParametersQfSpecificationRequestString)";
  176. // do the request
  177. setTimeout(command, 100);
  178. }
  179. }