From 8c174181986ed122a5e0fbf2c6a7bd78543dcc7e Mon Sep 17 00:00:00 2001 From: kamidu Date: Thu, 23 Mar 2017 12:23:02 +0530 Subject: [PATCH] fixing the null pointer exception --- .../devicemgt/app/modules/utility.js | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js index d1658872b3..7b6add5fa8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js @@ -39,8 +39,8 @@ utility = function () { PrivilegedCarbonContext.startTenantFlow(); context = PrivilegedCarbonContext.getThreadLocalCarbonContext(); context.setTenantDomain(carbon.server.tenantDomain({ - tenantId: userInfo.tenantId - })); + tenantId: userInfo.tenantId + })); context.setTenantId(userInfo.tenantId); context.setUsername(userInfo.username || null); }; @@ -161,15 +161,19 @@ utility = function () { * @returns {*} */ publicMethods.encodeJson = function (text) { - return text - .replace(/\\u003c/g, "<") - .replace(//g, ">") - .replace(/\\u0027/g, "'") - .replace(/'/g, "'") - .replace(/\\"/g, """) - .replace(/\\u0022/g, """) + if (text) { + return text + .replace(/\\u003c/g, "<") + .replace(//g, ">") + .replace(/\\u0027/g, "'") + .replace(/'/g, "'") + .replace(/\\"/g, """) + .replace(/\\u0022/g, """); + } else { + return ""; + } }; return publicMethods;