FaultDialog.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2011
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. function FaultDialog(oCV) {
  13. this.m_oCV = oCV;
  14. }
  15. FaultDialog.prototype = new IFaultDialog();
  16. FaultDialog.prototype.show = function(soapFault) {
  17. // we should never get here since stand alone Viewer doesn't handle SOAP faults. The fault
  18. // should have been returned as an HTML page
  19. if(typeof console != "undefined") {
  20. console.log("FaultDialog - an unhandled soap fault was returned: %o", soapFault);
  21. }
  22. };
  23. FaultDialog.prototype.handleUnknownHTMLResponse = function(responseText) {
  24. // make sure we clear the tracking and conversation before we unload the viewer
  25. // or we'll trigger a cancel request which will more then likely cause another fault.
  26. this.m_oCV.setTracking("");
  27. this.m_oCV.setConversation("");
  28. if (responseText) {
  29. // this is an HTML response, most likely a fault page.
  30. // Bug #: 650188 -- IE is blank page, FF and Chrome appear to be continually loading... The below code fixes both. Must be enabled using a
  31. // switch in viewerconfig.properties or advanced server properties.
  32. if(this.m_oCV.envParams["useAlternateErrorCodeRendering"]){
  33. var headNode = document.getElementsByTagName("head")[0];
  34. var bodySrc = responseText.match(/<body[^>]*>([\s\S]*)<\/body>/im)[1];
  35. // Loop through and add any scripts to our head
  36. var scriptRegEx = /<script[^>]*>([\s\S]*?)<\/script>/igm;
  37. var scriptNode = scriptRegEx.exec(responseText);
  38. while (scriptNode != null) {
  39. var aScript = document.createElement("script");
  40. aScript.type= 'text/javascript';
  41. var scriptSrc = scriptNode[0].match(/src="([\s\S]*?)"/i);
  42. if (scriptSrc == null){
  43. aScript.text= scriptNode[1]; // script is inline
  44. } else {
  45. aScript.src = scriptSrc[1]; // script is linked
  46. }
  47. headNode.appendChild(aScript);
  48. scriptNode = scriptRegEx.exec(responseText);
  49. }
  50. document.body.innerHTML = bodySrc;
  51. } else {
  52. document.write(responseText);
  53. }
  54. }
  55. };