Refactoring base ui app config reader

revert-70aa11f8
dilanua 8 years ago
parent 1916c4df5f
commit c12630e65c

@ -22,7 +22,7 @@ var log = new Log("api/data-tables-invoker-api.jag");
var uri = request.getRequestURI(); var uri = request.getRequestURI();
var uriMatcher = new URIMatcher(String(uri)); var uriMatcher = new URIMatcher(String(uri));
var devicemgtProps = require("/app/conf/devicemgt-props.js").config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var serviceInvokers = require("/app/modules/backend-service-invoker.js")["backendServiceInvoker"]; var serviceInvokers = require("/app/modules/backend-service-invoker.js")["backendServiceInvoker"];
function appendQueryParam (url, queryParam , value) { function appendQueryParam (url, queryParam , value) {

@ -24,7 +24,7 @@ var log = new Log("api/device-api.jag");
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var deviceModule = require("/app/modules/device.js").deviceModule; var deviceModule = require("/app/modules/device.js").deviceModule;
var utility = require("/app/modules/utility.js").utility; var utility = require("/app/modules/utility.js").utility;
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var userModule = require("/app/modules/user.js").userModule; var userModule = require("/app/modules/user.js").userModule;
var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker; var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker;

@ -23,7 +23,7 @@ var uriMatcher = new URIMatcher(String(uri));
var log = new Log("api/device-api.jag"); var log = new Log("api/device-api.jag");
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var utility = require("/app/modules/utility.js").utility; var utility = require("/app/modules/utility.js").utility;
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker; var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker;
var user = session.get(constants.USER_SESSION_KEY); var user = session.get(constants.USER_SESSION_KEY);

@ -23,7 +23,7 @@ var uri = request.getRequestURI();
var uriMatcher = new URIMatcher(String(uri)); var uriMatcher = new URIMatcher(String(uri));
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var serviceInvokers = require("/app/modules/backend-service-invoker.js")["backendServiceInvoker"]; var serviceInvokers = require("/app/modules/backend-service-invoker.js")["backendServiceInvoker"];
if (uriMatcher.match("/{context}/api/invoker/execute/")) { if (uriMatcher.match("/{context}/api/invoker/execute/")) {

@ -23,7 +23,7 @@ var uriMatcher = new URIMatcher(String(uri));
var log = new Log("api/operation-api.jag"); var log = new Log("api/operation-api.jag");
var serviceInvokers = require("/app/modules/backend-service-invoker.js")["backendServiceInvoker"]; var serviceInvokers = require("/app/modules/backend-service-invoker.js")["backendServiceInvoker"];
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
if (uriMatcher.match("/{context}/api/operation/paginate")) { if (uriMatcher.match("/{context}/api/operation/paginate")) {
var deviceType = request.getParameter("deviceType"); var deviceType = request.getParameter("deviceType");

@ -23,7 +23,7 @@ var uriMatcher = new URIMatcher(String(uri));
var log = new Log("api/user-api.jag"); var log = new Log("api/user-api.jag");
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var userModule = require("/app/modules/user.js").userModule; var userModule = require("/app/modules/user.js").userModule;
var deviceModule = require("/app/modules/device.js").deviceModule; var deviceModule = require("/app/modules/device.js").deviceModule;
var utility = require("/app/modules/utility.js").utility; var utility = require("/app/modules/utility.js").utility;

@ -19,9 +19,9 @@
var config = function () { var config = function () {
var conf = application.get("UI_CONFIG"); var conf = application.get("UI_CONFIG");
if (!conf) { if (!conf) {
var pinch = require("/app/modules/pinch.min.js")["pinch"]; var pinch = require("/app/conf/reader/pinch.min.js")["pinch"];
var server = require("carbon")["server"];
var config = require("/app/conf/config.json"); var config = require("/app/conf/config.json");
var server = require("carbon")["server"];
pinch(config, /^/, function (path, key, value) { pinch(config, /^/, function (path, key, value) {
if ((typeof value === "string") && value.indexOf("%https.ip%") > -1) { if ((typeof value === "string") && value.indexOf("%https.ip%") > -1) {
return value.replace("%https.ip%", server.address("https")); return value.replace("%https.ip%", server.address("https"));

@ -20,7 +20,7 @@ var apiWrapperUtil = function () {
var module = {}; var module = {};
var tokenUtil = require("/app/modules/util.js").util; var tokenUtil = require("/app/modules/util.js").util;
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var log = new Log("/app/modules/api-wrapper-util.js"); var log = new Log("/app/modules/api-wrapper-util.js");
module.refreshToken = function () { module.refreshToken = function () {

@ -31,7 +31,7 @@ var backendServiceInvoker = function () {
var TOKEN_EXPIRED = "Access token expired"; var TOKEN_EXPIRED = "Access token expired";
var TOKEN_INVALID = "Invalid input. Access token validation failed"; var TOKEN_INVALID = "Invalid input. Access token validation failed";
var devicemgtProps = require("/app/conf/devicemgt-props.js").config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var userModule = require("/app/modules/user.js")["userModule"]; var userModule = require("/app/modules/user.js")["userModule"];
var tokenUtil = require("/app/modules/api-wrapper-util.js")["apiWrapperUtil"]; var tokenUtil = require("/app/modules/api-wrapper-util.js")["apiWrapperUtil"];

@ -22,7 +22,7 @@ deviceModule = function () {
var utility = require('/app/modules/utility.js').utility; var utility = require('/app/modules/utility.js').utility;
var constants = require('/app/modules/constants.js'); var constants = require('/app/modules/constants.js');
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker; var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker;
var ArrayList = Packages.java.util.ArrayList; var ArrayList = Packages.java.util.ArrayList;

@ -22,7 +22,7 @@ var groupModule = {};
var userModule = require("/app/modules/user.js").userModule; var userModule = require("/app/modules/user.js").userModule;
var constants = require('/app/modules/constants.js'); var constants = require('/app/modules/constants.js');
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var utility = require("/app/modules/utility.js").utility; var utility = require("/app/modules/utility.js").utility;
var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker; var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker;

@ -17,7 +17,7 @@
*/ */
var carbonModule = require("carbon"); var carbonModule = require("carbon");
var devicemgtProps = require("/app/conf/devicemgt-props.js").config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var carbonServer = new carbonModule.server.Server({ var carbonServer = new carbonModule.server.Server({
tenanted: true, tenanted: true,
url: devicemgtProps["httpsURL"] + "/admin" url: devicemgtProps["httpsURL"] + "/admin"

@ -33,7 +33,7 @@ var onFail;
properties = {username: context.input.username, password: context.input.password}; properties = {username: context.input.username, password: context.input.password};
apiWrapperUtil.setupAccessTokenPair(constants.GRANT_TYPE_PASSWORD, properties); apiWrapperUtil.setupAccessTokenPair(constants.GRANT_TYPE_PASSWORD, properties);
} }
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var carbonServer = require("carbon").server; var carbonServer = require("carbon").server;
(new carbonServer.Server({url: devicemgtProps["adminService"]})) (new carbonServer.Server({url: devicemgtProps["adminService"]}))
.login(context.input.username, context.input.password); .login(context.input.username, context.input.password);

@ -20,7 +20,7 @@ var operationModule = function () {
var log = new Log("/app/modules/operation.js"); var log = new Log("/app/modules/operation.js");
var utility = require('/app/modules/utility.js').utility; var utility = require('/app/modules/utility.js').utility;
var constants = require('/app/modules/constants.js'); var constants = require('/app/modules/constants.js');
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker; var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker;
var publicMethods = {}; var publicMethods = {};

@ -25,7 +25,7 @@ policyModule = function () {
var constants = require('/app/modules/constants.js'); var constants = require('/app/modules/constants.js');
var utility = require("/app/modules/utility.js")["utility"]; var utility = require("/app/modules/utility.js")["utility"];
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker; var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker;
var publicMethods = {}; var publicMethods = {};

@ -24,7 +24,7 @@ var userModule = function () {
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var utility = require("/app/modules/utility.js")["utility"]; var utility = require("/app/modules/utility.js")["utility"];
var devicemgtProps = require("/app/conf/devicemgt-props.js").config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var serviceInvokers = require("/app/modules/backend-service-invoker.js")["backendServiceInvoker"]; var serviceInvokers = require("/app/modules/backend-service-invoker.js")["backendServiceInvoker"];
/* Initializing user manager */ /* Initializing user manager */

@ -21,7 +21,7 @@ var util = function () {
var module = {}; var module = {};
var Base64 = Packages.org.apache.commons.codec.binary.Base64; var Base64 = Packages.org.apache.commons.codec.binary.Base64;
var String = Packages.java.lang.String; var String = Packages.java.lang.String;
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var carbon = require('carbon'); var carbon = require('carbon');
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var adminUser = devicemgtProps["adminUser"]; var adminUser = devicemgtProps["adminUser"];

@ -20,7 +20,7 @@ var utility;
utility = function () { utility = function () {
var constants = require('/app/modules/constants.js'); var constants = require('/app/modules/constants.js');
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var log = new Log("/app/modules/utility.js"); var log = new Log("/app/modules/utility.js");
var JavaClass = Packages.java.lang.Class; var JavaClass = Packages.java.lang.Class;
var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext; var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext;

@ -21,7 +21,7 @@ function onRequest(context) {
var user = session.get(constants.USER_SESSION_KEY); var user = session.get(constants.USER_SESSION_KEY);
var userModule = require("/app/modules/user.js").userModule; var userModule = require("/app/modules/user.js").userModule;
var permissions = userModule.getUIPermissions(); var permissions = userModule.getUIPermissions();
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
if (!permissions.VIEW_DASHBOARD) { if (!permissions.VIEW_DASHBOARD) {
response.sendRedirect(constants.WEB_APP_CONTEXT + "/devices"); response.sendRedirect(constants.WEB_APP_CONTEXT + "/devices");

@ -23,7 +23,7 @@
* @returns {*} A context object that returns the dynamic state of this page to be presented * @returns {*} A context object that returns the dynamic state of this page to be presented
*/ */
function onRequest(context) { function onRequest(context) {
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var page = {}; var page = {};
page["groupNameJSRegEx"] = devicemgtProps.groupValidationConfig.groupNameJSRegEx; page["groupNameJSRegEx"] = devicemgtProps.groupValidationConfig.groupNameJSRegEx;
page["groupNameRegExViolationErrorMsg"] = devicemgtProps.groupValidationConfig.groupNameRegExViolationErrorMsg; page["groupNameRegExViolationErrorMsg"] = devicemgtProps.groupValidationConfig.groupNameRegExViolationErrorMsg;

@ -26,7 +26,7 @@ function onRequest(context) {
//var log = new Log("/app/pages/cdmf.page.user.create server-side js"); //var log = new Log("/app/pages/cdmf.page.user.create server-side js");
var userModule = require("/app/modules/user.js")["userModule"]; var userModule = require("/app/modules/user.js")["userModule"];
var devicemgtProps = require("/app/conf/devicemgt-props.js").config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
var page = {}; var page = {};
var response = userModule.getRolesByUserStore(); var response = userModule.getRolesByUserStore();

@ -20,7 +20,7 @@ function onRequest(context) {
var userModule = require("/app/modules/user.js").userModule; var userModule = require("/app/modules/user.js").userModule;
var userName = request.getParameter("username"); var userName = request.getParameter("username");
var user = userModule.getUser(userName)["content"]; var user = userModule.getUser(userName)["content"];
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/reader/main.js").config();
if (user) { if (user) {
var title; var title;
if (user.firstname || user.lastname) { if (user.firstname || user.lastname) {

@ -29,7 +29,7 @@ function onRequest(context) {
var page = {}; var page = {};
var userModule = require("/app/modules/user.js")["userModule"]; var userModule = require("/app/modules/user.js")["userModule"];
var deviceMgtProps = require("/app/conf/devicemgt-props.js").config(); require("/app/conf/reader/main.js").config();
page["adminUser"] = deviceMgtProps["adminUser"]; page["adminUser"] = deviceMgtProps["adminUser"];
page["permissions"] = userModule.getUIPermissions(); page["permissions"] = userModule.getUIPermissions();

@ -30,7 +30,7 @@ function onRequest (context) {
var userModule = require("/app/modules/user.js").userModule; var userModule = require("/app/modules/user.js").userModule;
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var permissions = userModule.getUIPermissions(); var permissions = userModule.getUIPermissions();
var mdmProps = require('/app/conf/devicemgt-props.js').config(); var mdmProps = require("/app/conf/reader/main.js").config();
context.permissions = permissions; context.permissions = permissions;
context["enrollmentURL"] = mdmProps.enrollmentURL; context["enrollmentURL"] = mdmProps.enrollmentURL;

@ -24,7 +24,7 @@
*/ */
function onRequest(context) { function onRequest(context) {
var userModule = require("/app/modules/user.js")["userModule"]; var userModule = require("/app/modules/user.js")["userModule"];
var deviceMgtProps = require('/app/conf/devicemgt-props.js').config(); var deviceMgtProps = require("/app/conf/reader/main.js").config();
var response = userModule.getRoles(); var response = userModule.getRoles();
if (response["status"] == "success") { if (response["status"] == "success") {
context["roles"] = response["content"]; context["roles"] = response["content"];

@ -24,7 +24,7 @@
*/ */
function onRequest(context) { function onRequest(context) {
var userModule = require("/app/modules/user.js")["userModule"]; var userModule = require("/app/modules/user.js")["userModule"];
var deviceMgtProps = require("/app/conf/devicemgt-props.js").config(); var deviceMgtProps = require("/app/conf/reader/main.js").config();
var uri = request.getRequestURI(); var uri = request.getRequestURI();
var uriMatcher = new URIMatcher(String(uri)); var uriMatcher = new URIMatcher(String(uri));
var isMatched = uriMatcher.match("/{context}/role/edit/{rolename}"); var isMatched = uriMatcher.match("/{context}/role/edit/{rolename}");

@ -30,7 +30,7 @@ function onRequest(context) {
if (userModule.isAuthorized("/permission/admin/device-mgt/roles/remove")) { if (userModule.isAuthorized("/permission/admin/device-mgt/roles/remove")) {
context["removePermitted"] = true; context["removePermitted"] = true;
} }
var deviceMgtProps = require("/app/conf/devicemgt-props.js").config(); var deviceMgtProps = require("/app/conf/reader/main.js").config();
context["appContext"] = deviceMgtProps.appContext; context["appContext"] = deviceMgtProps.appContext;
context["adminRole"] = deviceMgtProps.adminRole; context["adminRole"] = deviceMgtProps.adminRole;
return context; return context;

Loading…
Cancel
Save