123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522 |
- /********************************************************************************************************************************
- * 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 <?xml version="1.0"..?>
- 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 += "<br>" + 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("</[a-zA-Z0-9-]*:","gim"),"</");
- cleanXML = cleanXML.replace(new RegExp("<[a-zA-Z0-9-]*:","gim"),"<");
- }else{
- cleanXML = getXML(obj).replace(new RegExp("</[a-zA-Z0-9-]*:","gim"),"</");
- cleanXML = cleanXML.replace(new RegExp("<[a-zA-Z0-9-]*:","gim"),"<");
- }
- //we have a new document
- obj = parseXMLString(cleanXML);
- if (window.clipboardData) {
- //This is so that we can use the contains xpath function, in IE xpath query of XML
- obj.setProperty("SelectionLanguage","XPath");
- }
- return obj;
- }
- function getXML(obj) {
- if (window.clipboardData) {
- return obj.xml;
- } else {
- return (new XMLSerializer( )).serializeToString(obj);
- }
- }
- function parseResponse(obj,responseText) {
- return new XMLResponseParser(obj,responseText);
- }
- function XMLResponseParser(obj,responseText) {
- this.responseXML = obj;
- //remove namespaces
- this.obj = removeXMLNameSpaces(obj,responseText);
- this.responseText = responseText?responseText:"";
-
- this.getTextValueForXPath = function(xpath) {
- var result = "";
- if (this.obj) {
- var node = selectSingleNode(xpath,this.obj);
- if (node) {
- result = getTextNodeValue(node);
- }
- }
- return (result);
- };
-
- this.isLogonFault = function() {
- var result = false;
- if (this.obj) {
- //find the cam action element
- var camAction = selectSingleNode("//item[./name = 'h_CAM_action']",this.obj);//.selectSingleNode("//item[./name = 'h_CAM_action']");
- if (camAction) {
- //Check the value if it is a logon or logonAs
- var value = selectSingleNode("./value",camAction);//camAction.selectSingleNode("./value");
- result = value && getTextNodeValue(value).indexOf("logon") > -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("<body[^>]*>(.*)</body>","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("</[a-zA-Z0-9-]*:","gim"),"</");
- html = html.replace(new RegExp("<[a-zA-Z0-9-]*:","gim"),"<");
- return html;
- }
- }
|