/******************************************************************************************************************************** * Licensed Materials - Property of IBM * * * * IBM Cognos Products: AGS * * * * (C) Copyright IBM Corp. 2005, 2015 * * * * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * *********************************************************************************************************************************/ // General async constants. var ASYNC_CONTEXT = "context"; var ASYNC_WORKING = "working"; var ASYNC_PROMPTING = "prompting"; var ASYNC_CONVERSATION = "conversation"; var ASYNC_TRACKING = "tracking"; var ASYNC_RESPONSE = "asyncResponse"; var ASYNC_HTMLFRAGMENT = "htmlFragment"; var ASYNC_ROUTINGSERVERGROUP = "routingServerGroup"; var CANCEL_RESPONSE = "cancelResponse"; // fault constants. var FAULT_SOAPFAULT = "soapFault"; var FAULT_PASSPORT = "passport"; var isAsynchRequestCancelledState = false; function setAsynchRequestCancelled(isCancelled){ isAsynchRequestCancelledState = isCancelled; } function isAsynchRequestCancelled(){ return isAsynchRequestCancelledState; } //a cancel call has been fulfilled function processAsynchCancel(){ getCommandStackManager().getCommandStack().cancel(); doClosePopUp(); isAsynchRequestCancelledState = false; } /* function doLoginFromFault(){ var soapFault = cfgGet("doLoginFromFault"); if(soapFault != undefined && soapFault != null){ applicationActionManager.allowActions(); //Create a holder and set the htmlFragment. //You may set 'm' if you need to. var holder = new Object(); //cam_passport will not be there if session expired. so then //when we fire the call to doLoginProxy, the dispatcher checks //the passport and if it is not there it prompts for a login. if (document.cookie.indexOf("cam_passport=") != -1) { //We have a passport, so then we attempt to add an htmlFragment. //This means that the session is fine and that we need to login, //maybe because we hit a secured external datasource. //Regex to remove holder['htmlFragment'] = decode(getXML(soapFault).replace(new RegExp("<\\?xml.*\\?>\r\n","i"),"")); } checkLogin(holder,"getCommandStackManager().processCommandStack()"); } } */ function doLoginFromFault(){ // Get the XML Node fault object returned by EMF fault handler. var xmlNode = cfgGet( "doLoginFromFault" ); // Create XMLResponseParser object from the node for easier processing. var parsedResponse = new XMLResponseParser( xmlNode, "" ); // Get the HTML fault from the EMF rendered response. var htmlFaultObj = parsedResponse.getHtmlFault(); if ( htmlFaultObj != null ) { var htmlFaultHtml = parsedResponse.getTextValueForXPath( "//fault//html" ); var popUpFrame = getPopUpFrame(); setResetOM( "/ags/doLoginProxy.xts" ); popUpFrame.document.open(); popUpFrame.document.write( htmlFaultHtml ); popUpFrame.document.close(); } return true; } function doPassportExpire(responseNode, tidyFunction,parsedResponse) { applicationActionManager.allowActions(); if (typeof tidyFunction == "function") { tidyFunction(); } if (responseNode) { if(parsedResponse.getErrorCode() == 'caf'){ // cfgSet("CAN_CANCEL_LOGON", true); } //Set the fault so that we can pick it up later. //This call is in an XMLHTTP call back and so needs to end //in order to allow for another call to be initiated by //checkLogin. cfgSet("doLoginFromFault", responseNode); setTimeout("doLoginFromFault()",100); }else{ setTimeout("checkLogin('getCommandStackManager().processCommandStack()')",100); } } function doSOAPFault(obj, tidyFunction,parsedResponse) { // we're not going any further here // so allow actions at least and clear the command stack getCommandStackManager().getCommandStack().doFail(); applicationActionManager.allowActions(); if (typeof tidyFunction == "function") { tidyFunction(); } processAsynchCancel(); //If we have error messages we send them through //otherwise send the entire fault as is. var msgs = parsedResponse.getErrorMessages(); if (msgs.length > 0) { metadataFault(msgs); functionsTree.childrenReadyForNode(functionsTree.getRootNode()); // say that we've not loaded the tree cfgSet("META_FunctionTreeLoadedFirstTime",null); }else{ metadataFault(parsedResponse.getFaultAsMessage); } } function doCancel(obj, requestFunction, soapAction) { // get the conversation element var conversationElements = obj.getElementsByTagName(ASYNC_CONVERSATION); // get the tracking element var trackingElements = obj.getElementsByTagName(ASYNC_TRACKING); // get the context element var contextElements = obj.getElementsByTagName(ASYNC_CONTEXT); // get the routingServerGroup element var routingServerGroupElements = obj.getElementsByTagName(ASYNC_ROUTINGSERVERGROUP); // we want the actual values var conversation = getTextNodeValue(conversationElements[0]); var tracking = getTextNodeValue(trackingElements[0]); var context = getTextNodeValue(contextElements[0]); var routingServerGroup = getTextNodeValue(routingServerGroupElements[0]); // build the request var request = URIEncode("conversation", conversation); request += URIEncode("disp_trackingInfo", tracking); request += URIEncode("context", context); // only send the routingServerGroup if there was one defined if (routingServerGroup != null && routingServerGroup != "") { request += URIEncode("routingServerGroup", routingServerGroup); } request += URIEncode("method", "cancel"); if(soapAction){ request += URIEncode("soapAction", soapAction); } // send the request setTimeout(requestFunction + "(\'" + request + "\',true);", 100); } function doWorking(obj, requestFunction) { // get the conversation element var conversationElements = obj.getElementsByTagName(ASYNC_CONVERSATION); // get the tracking element var trackingElements = obj.getElementsByTagName(ASYNC_TRACKING); // get the context element var contextElements = obj.getElementsByTagName(ASYNC_CONTEXT); // get the routingServerGroup element var routingServerGroupElements = obj.getElementsByTagName(ASYNC_ROUTINGSERVERGROUP); // we want the actual values var conversation = getTextNodeValue(conversationElements[0]); var tracking = getTextNodeValue(trackingElements[0]); var context = getTextNodeValue(contextElements[0]); var routingServerGroup = getTextNodeValue(routingServerGroupElements[0]); // build the request var request = URIEncode("doWait","1"); request += URIEncode("conversation", conversation); request += URIEncode("disp_trackingInfo", tracking); request += URIEncode("context", context); // only send the routingServerGroup if there was one defined if (routingServerGroup != null && routingServerGroup != "") { request += URIEncode("routingServerGroup", routingServerGroup); } //SEC_INFO request - javascript encode the request prior to firing setTimeout. The //setTimeout function will un-encode the request before it is submitted request = jsStrEncode(request); // send the request setTimeout(requestFunction + "(\'" + request + "\',true);", 100); } function doPrompting(obj, callbackFunctionId, xslURL) { // get the conversation element var conversationElements = obj.getElementsByTagName(ASYNC_CONVERSATION); // get the tracking element var trackingElements = obj.getElementsByTagName(ASYNC_TRACKING); // get the htmlFragment element var htmlFragmentElement = obj.getElementsByTagName(ASYNC_HTMLFRAGMENT); // get the context element var contextElements = obj.getElementsByTagName(ASYNC_CONTEXT); // get the routingServerGroup element var routingServerGroupElements = obj.getElementsByTagName(ASYNC_ROUTINGSERVERGROUP); // we want the actual values var conversation = getTextNodeValue(conversationElements[0]); var tracking = getTextNodeValue(trackingElements[0]); var htmlFragment = getTextNodeValue(htmlFragmentElement[0]); var context = getTextNodeValue(contextElements[0]); var routingServerGroup = getTextNodeValue(routingServerGroupElements[0]); // clear the dialogFrame dlgReset(); // set all the following values dlgSetParm("m", "prompting/promptDataSource.xts"); // callback function: WO2397 dlgSetParm("ccs_cbdata", callbackFunctionId); dlgSetParm("ccs_invoke", "parent"); // clientContext dlgSetParm("clientContext", context); // isEncoded dlgSetParm("isEncoded", "1"); // conversation dlgSetParm("conversation", conversation); // tracking dlgSetParm("tracking", tracking); // release conversation dlgSetParm("releaseConversation", "1"); // process recursion dlgSetParm("processRecursion", "1"); // html fragment dlgSetParm("htmlFragment", htmlFragment); // set the routingServerGroup into the prompting kit (only set this if it's defined) if (routingServerGroup != null && routingServerGroup != "") { dlgSetParm("routingServerGroup", routingServerGroup); } // get the full response dlgSetParm("returnEntireResponse", "1"); if (xslURL) { dlgSetParm("run.xslURL", xslURL); } changeMenu(TAB_MODEL) //if this has been in a command stack //the stack eval call may have re blocked by the time it comes back from the dispatcher var wasBlocked = applicationActionManager.isBlocked(); applicationActionManager.allowActions(); dlgSubmit("popUpFrame"); if(wasBlocked ){ applicationActionManager.blockActions(); } } // WO 2397-Prompting JavaScript Callback function pdsCallback(pdsState) { // don't actually check on state - that's passed into the individual functions cause they might deal with error's/cancels differently // just call the function directly - pass in arguments based on attributes of pdsState. They're renamed "response" to "state" which is confusingly annoying. //1. doPrompting(promptingRoot[0],"parent.getConfigFrame().promptFunctionResponse"); //2. doPrompting(promptingRoot[0],"parent.getConfigFrame().promptGetParametersResponse"); //3. doPrompting(promptingRoot[0],"parent.getConfigFrame().promptCollectResponse"); //4. doPrompting(promptingRoot[0],"parent.getConfigFrame().promptGetSpDetailsResponse"); //5. doPrompting(promptingRoot[0],"parent.getConfigFrame().promptMemberResponse"); //6. doPrompting(promptingRoot[0],"parent.getConfigFrame().promptMetadataResponse"); //7. doPrompting(promptingRoot[0],"parent.getConfigFrame().promptSelectDataResponse","selectValue.xslt"); //8. doPrompting(promptingRoot[0],'parent.getConfigFrame().promptValidateConditionResponse'); var cmdId = pdsState.ccs_cbdata ; // command id would be passed back to us as pdsState.ccs_cbdata switch(cmdId){ case '1': promptFunctionResponse(pdsState.parameters, pdsState.state, pdsState.conversation, pdsState.clientContext, pdsState.tracking); break; case '2': promptGetParametersResponse(pdsState.parameters, pdsState.state, pdsState.conversation, pdsState.clientContext, pdsState.tracking); break; case '3': promptCollectResponse(pdsState.parameters, pdsState.state, pdsState.conversation, pdsState.clientContext, pdsState.tracking); break; case '4': promptGetSpDetailsResponse(pdsState.parameters, pdsState.state, pdsState.conversation, pdsState.clientContext, pdsState.tracking); break; case '5': promptMemberResponse(pdsState.parameters, pdsState.state, pdsState.conversation, pdsState.clientContext, pdsState.tracking); break; case '6': promptMetadataResponse(pdsState.parameters, pdsState.state, pdsState.conversation, pdsState.clientContext, pdsState.tracking); break; case '7': promptSelectDataResponse(pdsState.parameters, pdsState.state, pdsState.conversation, pdsState.clientContext, pdsState.tracking); break; case '8': promptValidateConditionResponse(pdsState.parameters, pdsState.state, pdsState.conversation, pdsState.clientContext, pdsState.tracking); break; default: alert('pdsCallBack: unknown cmd id '+cmdId); } } function doHTMLResponse(responseText) { // we got a html response back - so open a window to display it var error_window = window.open("", "asyncError", "height=480,width=640,resizable=yes"); var error_window_doc = error_window.document; // write the text into the window error_window_doc.write(responseText); } function addDebugWaitMessage(message){ var mArea = getPopUpFrame().document.getElementById("wait_debug_message"); if(mArea){ //mArea.innerHTML += "
" + message; mArea.innerHTML = message; } } function removeXMLNameSpaces(obj,responseText) { if(!obj)return null; var cleanXML = null; //Calls may contain namespace others do not, so we clean up all namespaces //and reload the xml into a new document. if(document.documentMode > 10){ cleanXML = responseText.replace(new RegExp(" -1; } } return (result); }; this.isCancelledWait = function() { var result = false; if (this.obj) { //find the wait element var isWait = selectSingleNode("//formFieldVars//item[./name = 'doWait']",this.obj); if (isWait) { result = selectSingleNode("//exception//message/messageString[contains(.,'RSV-BBP-0036') and contains(.,'asynchWait_Request')]",this.obj); } } return (result); }; this.isSoapFault = function(){ var result = false; if (this.obj) { //find the soap fault element var soapFault = selectSingleNode("//Body/Fault",this.obj);//this.obj.selectSingleNode("//Body/Fault"); if (soapFault) { result = true; } } return (result); }; this.getErrorCode = function(){ var result = ""; if (this.obj) { //find the soap fault error code var errorCodeNode = selectSingleNode("//Body//errorCode",this.obj);//this.obj.selectSingleNode("//Body//errorCode"); if (errorCodeNode) { result = getTextNodeValue(errorCodeNode); } } return (result); }; this.getErrorSeverity = function(){ var result = ""; if (this.obj) { //find the soap fault error code var errorSeverityNode = selectSingleNode("//Body//exception//severity",this.obj);//this.obj.selectSingleNode("//Body//exception//severity"); if (errorCodeNode) { result = getTextNodeValue(errorSeverityNode); } } return (result); }; this.getErrorMessages = function(){ var result = new Array(); if (this.obj) { //find the soap fault error code var msgStringNodes = selectNodes("//Body//exception//message//messageString",this.obj);//this.obj.selectNodes("//Body//exception//message//messageString"); if (!msgStringNodes || msgStringNodes.length == 0 ) { //This is an error like null pointer from ASV. msgStringNodes = selectNodes("//Body//Fault//stackTrace",this.obj); } for (var i=0;msgStringNodes && i < msgStringNodes.length;i++) { result.push(getTextNodeValue(msgStringNodes[i])); } } return (result); }; this.getErrorMessageNodes = function(){ var result = new Array(); if (this.obj) { //find the soap fault error code var msgStringNodes = selectNodes("//Body//exception//message//messageString",this.obj);//this.obj.selectNodes("//Body//exception//message//messageString"); if (!msgStringNodes || msgStringNodes.length == 0 ) { //This is an error like null pointer from ASV. msgStringNodes = selectNodes("//Body//Fault//stackTrace",this.obj); } for (var i=0;msgStringNodes && i < msgStringNodes.length;i++) { result.push(msgStringNodes[i]); } } return (result); }; this.getFaultAsMessage = function(){ var result = new Array(); if (this.obj) { result.push(getXML(obj)); } return (result); }; // Get the HTML fault for the EMF renderer. this.getHtmlFault = function() { var result = ""; if (this.obj) { result = selectSingleNode("//fault//html", this.obj); } return ( result ); }; this.isHTML = function() { return new RegExp("<\s*\/?\s*html\s*.*?>","gim").test(this.cleanUpHTML()); }; this.isEmptyBody = function() { var response = true; if (this.isHTML()) { var cleanHTHML = this.cleanUpHTML(); cleanHTHML.match(new RegExp("]*>(.*)","gim")); response = RegExp.$1.replace(/^\s+|\s+$/g,"").length == 0; } return response; }; this.contains = function(pattern) { return this.responseText.indexOf(pattern) > -1; }; this.cleanUpHTML = function() { var html = this.responseText.replace(new RegExp("[\r\n]*","gim"),""); html = html.replace(new RegExp("