fixing the null pointer exception

4.x.x
kamidu 8 years ago
parent 530e603fb5
commit 8c17418198

@ -39,8 +39,8 @@ utility = function () {
PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.startTenantFlow();
context = PrivilegedCarbonContext.getThreadLocalCarbonContext(); context = PrivilegedCarbonContext.getThreadLocalCarbonContext();
context.setTenantDomain(carbon.server.tenantDomain({ context.setTenantDomain(carbon.server.tenantDomain({
tenantId: userInfo.tenantId tenantId: userInfo.tenantId
})); }));
context.setTenantId(userInfo.tenantId); context.setTenantId(userInfo.tenantId);
context.setUsername(userInfo.username || null); context.setUsername(userInfo.username || null);
}; };
@ -161,15 +161,19 @@ utility = function () {
* @returns {*} * @returns {*}
*/ */
publicMethods.encodeJson = function (text) { publicMethods.encodeJson = function (text) {
return text if (text) {
.replace(/\\u003c/g, "<") return text
.replace(/</g, "&lt;") .replace(/\\u003c/g, "&lt;")
.replace(/\\u003e/g, "&gt;") .replace(/</g, "&lt;")
.replace(/>/g, "&gt;") .replace(/\\u003e/g, "&gt;")
.replace(/\\u0027/g, "&#39;") .replace(/>/g, "&gt;")
.replace(/'/g, "&#39;") .replace(/\\u0027/g, "&#39;")
.replace(/\\"/g, "&quot;") .replace(/'/g, "&#39;")
.replace(/\\u0022/g, "&quot;") .replace(/\\"/g, "&quot;")
.replace(/\\u0022/g, "&quot;");
} else {
return "";
}
}; };
return publicMethods; return publicMethods;

Loading…
Cancel
Save