#set ($almautheticationerror_title = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.almautheticationerrortitle")) #set ($error_title = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.errortitle")) #set ($edit_authetication_button_title = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.editautheticationbuttontitle")) #set ($almauthetication_problem_title = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.autheticationproblemtitle")) #set ($close_button_title = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.closebuttontitle")) #set ($ok_button_title = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.okbuttontitle")) #set ($cancel_button_title = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.cancelbuttontitle")) #set ($bms_suite_name = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.bmsapp.name")) #set ($unknown_error_msg_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.server.errors.unknownerrormsg.text")) #set ($catastrophic_error_msg_title = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.server.errors.catastrophicerrormsg.title")) #set ($catastrophic_error_msg_text_part1 = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.server.errors.catastrophicerrormsg.text.part1")) #set ($catastrophic_error_msg_text_part2 = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.server.errors.catastrophicerrormsg.text.part2")) #set ($timeout_error_msg_title = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.server.errors.timeouterrormsg.title")) #set ($timeout_error_msg_text_part1 = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.server.errors.timeouterrormsg.text.part1")) #set ($timeout_error_msg_text_part2 = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "ALMTerms", "almterms.server.errors.timeouterrormsg.text.part2")) Ext.namespace("ExtJsErrorHandlerLib"); #set ($ALM_SECURITY_ERROR="ALM_SECURITY_ERROR") // Javascript classes, scoped objects and functions for errorhandling when using EXTJS var ErrorHandlerLib ={ respositoryId: '', showAlmErrorMsg : function(message,title,myProcessResult,repoid) { ErrorHandlerLib.repositoryId = repoid; var t = title ? title:"$almauthetication_problem_title"; Ext.MessageBox.buttonText.ok = '$edit_authetication_button_title'; Ext.MessageBox.buttonText.cancel = '$close_button_title'; Ext.Msg.show({ title:t, msg: ''+message+'', buttons: Ext.Msg.OKCANCEL, icon: Ext.MessageBox.WARNING, fn: myProcessResult || ErrorHandlerLib.processResult }); Ext.MessageBox.buttonText.ok = '$ok_button_title'; Ext.MessageBox.buttonText.cancel = '$cancel_button_title'; }, showErrorMsg : function(message,title) { var t = title ? title:"$error_title"; Ext.Msg.show({ title:t, msg: ''+message+'', buttons: Ext.Msg.OK, icon: Ext.MessageBox.WARNING }); }, processResult: function(){ //do nothing }, showErrorWithJSONObject : function(r, options,almusermappingsSuccessCallbackFn) { var message = ""; if((r.success != undefined) && !r.success) { if(options && options.settings && options.settings.msg) { message += options.settings.msg + "

"; } if(r.data[0].msg) { message += r.data[0].msg + "

"; } } var title = (options && options.settings) ? options.settings.title:"$error_title"; if (message.length > 0) { var errorcode = r.data[0].errorcodes; if(r.data[1] && r.data[1].errorcodes) { errorcode = r.data[1].errorcodes; } //if alm security context error pop up the almusermappings dialog if(errorcode == '$ALM_SECURITY_ERROR') { var repoid = ''; if(r.data[0] && r.data[0].repositoryid) { repoid = r.data[0].repositoryid; } if(r.data[1] && r.data[1].repositoryid) { repoid = r.data[1].repositoryid; } if(r.data[2] && r.data[2].repositoryid) { repoid = r.data[2].repositoryid; } almusermappings.successcallbackFn = (almusermappingsSuccessCallbackFn) ? almusermappingsSuccessCallbackFn:null; ErrorHandlerLib.showAlmErrorMsg(message, title,ErrorHandlerLib.showALMUserMapping,repoid); } else ErrorHandlerLib.showErrorMsg(message,title); } }, // Displays error in response text from the server showResponseError : function(response,options) { var text = response.responseText; text = text.replace('\n','
'); var r = Ext.decode(text); ErrorHandlerLib.showErrorWithJSONObject(r, options); }, // Displays error messaged embedded in action with the standard server error message. showActionError : function(action) { if( action.failureType == Ext.form.Action.CONNECT_FAILURE ) { var errMsg = '$unknown_error_msg_text'; var errMsgTitle = '$catastrophic_error_msg_title'; if ( action.response.status == 0 ) { errMsgTitle = '$catastrophic_error_msg_title'; errMsg = '$catastrophic_error_msg_text_part1'+' '+'$bms_suite_name'+' '+'$catastrophic_error_msg_text_part2'; } else if ( action.response.status == -1 ) { errMsgTitle = '$timeout_error_msg_title'; errMsg = '$timeout_error_msg_text_part1'+' '+'$bms_suite_name'+' '+'$timeout_error_msg_text_part2'; } ErrorHandlerLib.showErrorMsg(errMsg, errMsgTitle); return; } else if (action.failureType == Ext.form.Action.CLIENT_INVALID) { //These are client-side validation errors (shown by the visual indicators) return; } var respText = action.response.responseText; respText = respText.replace('\n','
'); var r = Ext.util.JSON.decode(respText); var message = ""; if(action.options && action.options.settings && action.options.settings.msg && action.options.settings.show) { message += action.options.settings.msg + "

"; } if(r.data[0].msg) { message += r.data[0].msg + "

"; } var title = (action.options && action.options.settings && action.options.settings.title) ? action.options.settings.title:"$error_title"; if (message.length > 0) { //if alm security context error pop up the almusermappings dialog var errorcode = r.data[0].errorcodes; if(r.data[1] && r.data[1].errorcodes) { errorcode = r.data[1].errorcodes; } if(errorcode == '$ALM_SECURITY_ERROR') { var repoid = ''; if(r.data[0] && r.data[0].repositoryid) { repoid = r.data[0].repositoryid; } if(r.data[1] && r.data[1].repositoryid) { repoid = r.data[1].repositoryid; } if(r.data[2] && r.data[2].repositoryid) { repoid = r.data[2].repositoryid; } title = '$almautheticationerror_title'; ErrorHandlerLib.showAlmErrorMsg(message, title,ErrorHandlerLib.showALMUserMapping,repoid); } else ErrorHandlerLib.showErrorMsg(message,title); } }, /** * The function to call when a failure packet was recieved, or when an error ocurred in * the Ajax communication of form submission. * @param {Object} form ,The form that requested the action * @param {Object} action,The Action class. If an Ajax error ocurred, * the failure type will be in failureType. The result property of this object may be examined * to perform custom postprocessing. * The specific call back should be passed in the settings. For * format and example see below * * Request Format: * xxx.form.submit({ * url: xxx, * success: xxx, * failure: ErrorHandlerLib.onFormFailure, * settings: {show:true/false ,msg:UI_error_message ,callback:xxxfailurefn}, * params: {xxx}, * ... * }); * * Example: * xxx.form.submit({ * url: 'pbv/PBVAsyncHandler?action=SAVE-RANKS', * success: sprintplanning.reqReinsertHandler, * failure: ErrorHandlerLib.onAjaxFailure, * settings: {show: true, msg:'Saving ranks failed', callback: sprintplanning.OnSaveRanksFailure}, * params: {start:0, limit:25, paramString: paramString, reqbacklogid: sprintplanning.selBacklog} * }); * Response JSON Format: * action.result = {success:false/false, data:[{msg:somemsg , errorcodes:[001,002,xxx], payload:whatever }]} */ onFormFailure: function(form, action){ //Deal with only Server errors here and skip the Client-side form validations if( action.failureType != Ext.form.Action.CLIENT_INVALID ) { ErrorHandlerLib.showActionError(action); if( action.options.settings && action.options.settings.callback) { action.options.settings.callback(action.result, action.options,r.data[0].errorcodes ); } } }, /** * The function to call when a failure on a ajax request * @param {Object} result ,The response * @param {Object} request,The request * The specific call back should be passed in the settings. For * format and example see below * * Format: * xxx.form.submit({ * url: xxx, * success: xxx, * failure: ErrorHandlerLib.onAjaxFailure, * settings: {show:true/false,msg:UI_error_message ,callback: xxxfailurefn}, * params: {xxx}, * .. * }); * * Example: * Ext.Ajax.request({ * url: 'pbv/PBVAsyncHandler?action=SAVE-RANKS', * success: sprintplanning.reqReinsertHandler, * failure: ErrorHandlerLib.onAjaxFailure, * settings: {show: true, msg:'Updating ranks failed', callback: sprintplanning.OnSaveRanksFailure}, * params: {start:0, limit:25, paramString: paramString, reqbacklogid: sprintplanning.selBacklog} * }); * Response JSON Format: * result = {success:false/false, data:[{msg:somemsg , errorcodes:[xxx] }]} */ onAjaxFailure: function(response, options){ if(options ) { if (options.settings && options.settings.show) { //diaplay the UI message if any otherwise display msg from the response ErrorHandlerLib.showResponseError(response, options); } else ErrorHandlerLib.showResponseError(response, options); } else ErrorHandlerLib.showResponseError(response); if( options && options.settings && options.settings.callback) { var errorcode = response.data[0].errorcodes; if(response.data[1] && response.data[1].errorcodes) { errorcode = response.data[1].errorcodes; } options.settings.callback(response, options,errorcode ); } }, OnStoreLoad:function(store, records, options,title){ if (records.length > 0) { var errorMsg = records[records.length-1].get('warningMsg'); var errorCodes = records[records.length-1].get('errorcodes'); var repositoryid = records[records.length-1].get('repositoryid'); if (errorMsg && errorCodes && errorMsg.length > 0) { store.remove(records[records.length-1]); if (errorCodes == 'ALM_SECURITY_ERROR') { var options = { settings: { show: "true",title: title}}; errorMsg = errorMsg.replace('\n','
'); if(repositoryid == undefined) { repositoryid = ''; } var libDataStr = "{success:false, data:[{'msg': '" +errorMsg + "', errorcodes:'" + errorCodes + "', repositoryid:'" + repositoryid + "'}]}"; var libData = Ext.decode(libDataStr); ErrorHandlerLib.showErrorWithJSONObject(libData, options); } else { Ext.MessageBox.show({ title: 'Warning', msg: errorMsg, icon: Ext.MessageBox.WARNING, buttons: Ext.MessageBox.OK }); } } } if( options && options.settings && options.settings.callback) { options.settings.callback(store, records,options ); } }, // showALMUserMapping:function(btn) { if (btn == 'ok') { var repoid = ErrorHandlerLib.repositoryId; ErrorHandlerLib.repositoryId = ''; //reset almusermappings.show("$currentUserId",repoid); } } };