How to use the process.getProperty function in process

To help you get started, we’ve selected a few process examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wso2 / carbon-device-mgt / components / device-mgt / org.wso2.carbon.device.mgt.ui / src / main / resources / jaggeryapps / devicemgt / app / modules / conf-reader / main.js View on Github external
} else if ((typeof value === "string") && value.indexOf("%date-year%") > -1) {
                    var year = new Date().getFullYear();
                    return value.replace("%date-year%", year);
                } else if ((typeof value === "string") && value.indexOf("%server.ip%") > -1) {
                    var getProperty = require("process").getProperty;
                    return value.replace("%server.ip%", getProperty("carbon.local.ip"));
                } else {
                    var paramPattern = new RegExp("%(.*?)%", "g");
                    var out = value;
                    while ((matches = paramPattern.exec(value)) !== null) {
                        // This is necessary to avoid infinite loops with zero-width matches
                        if (matches.index === paramPattern.lastIndex) {
                            paramPattern.lastIndex++;
                        }
                        if (matches.length == 2) {
                            var property = process.getProperty(matches[1]);
                            if (property) {
                                out = out.replace(new RegExp("%" + matches[1] + "%", "g"), property);
                            }
                        }
                    }
                    return out;
                }
            }
        );
github wso2 / carbon-device-mgt / components / device-mgt / org.wso2.carbon.device.mgt.ui / src / main / resources / jaggeryapps / devicemgt / app / modules / business-controllers / device.js View on Github external
"org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService";
					//noinspection JSUnresolvedFunction, JSUnresolvedVariable
					var JWTClientManagerService = carbon.server.osgiService(JWTClientManagerServicePackagePath);
					//noinspection JSUnresolvedFunction
					var jwtClient = JWTClientManagerService.getJWTClient();
					// returning access token by JWT grant type
					var deviceScope = "device_" + type.replace(" ", "") + "_" + deviceId + " perm:device:enroll " +
						"perm:device:disenroll perm:device:modify perm:devices:operations perm:device:publish-event";
					var tokenInfo = jwtClient.getAccessToken(config.clientId, config.clientSecret,
						userName, deviceScope);
					config.accessToken = tokenInfo.getAccessToken();
					config.refreshToken = tokenInfo.getRefreshToken();
					if (config.accessToken == null) {
						return null;
					}
					config.mqttGateway = "tcp://" + process.getProperty("mqtt.broker.host") + ":" + process.getProperty("mqtt.broker.port");
					config.httpsGateway = "https://" + process.getProperty("iot.gateway.host") + ":" + process.getProperty("iot.gateway.https.port");
					config.httpGateway = "http://" + process.getProperty("iot.gateway.host") + ":" + process.getProperty("iot.gateway.http.port");
					return config;
				} else {
					return null;
				}
				return config;
			},
			function (responsePayload) {
github wso2 / product-iots / modules / samples / currentsensor / component / ui / src / main / resources / jaggeryapps / devicemgt / app / units / cdmf.unit.device.type.currentsensor.device-view / device-view.js View on Github external
function onRequest(context) {

    var log = new Log("device-view.js");
    var deviceType = context.uriParams.deviceType;
    var deviceId = request.getParameter("id");

    var getProperty = require("process").getProperty;
    var port = getProperty("carbon.https.port");
    var host = getProperty("carbon.local.ip");
    var sessionId = session.getId();
    if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
        var deviceModule = require("/app/modules/device.js").deviceModule;
        var device = deviceModule.viewDevice(deviceType, deviceId);

        if (device && device.status != "error") {
            return {"device": device.content, "port" : port, "host" : host , "sessionId" : sessionId};
        }
    }
}
github wso2 / product-es / modules / apps / publisher / config / publisher.js View on Github external
config = function () {
        var log = new Log(),
            pinch = require('/modules/pinch.min.js').pinch,
            config = require('/config/publisher.json'),
            process = require('process'),
            localIP = process.getProperty('server.host'),
            httpPort = process.getProperty('http.port'),
            httpsPort = process.getProperty('https.port');
            carbonLocalIP=process.getProperty('carbon.local.ip');

        pinch(config, /^/, function (path, key, value) {
            if ((typeof value === 'string') && value.indexOf('%https.host%') > -1) {
                return value.replace('%https.host%', 'https://' + localIP + ':' + httpsPort);
            } else if ((typeof value === 'string') && value.indexOf('%http.host%') > -1) {
                return value.replace('%http.host%', 'http://' + localIP + ':' + httpPort);
            }
            else if((typeof value === 'string') && value.indexOf('%https.carbon.local.ip%') > -1)
            {
                return value.replace('%https.carbon.local.ip%', 'https://' + carbonLocalIP + ':' + httpsPort);
            }
            else if((typeof value === 'string') && value.indexOf('%http.carbon.local.ip%') > -1) {
                return value.replace('%http.carbon.local.ip%', 'http://' + carbonLocalIP + ':' + httpPort);
            }
github wso2-attic / carbon-uuf / src / lib / utils.js View on Github external
var cachedAppConfFileLMD = parseInt(application.get(constants.CACHE_KEY_APP_CONF_FILE_LMD));
            var appConfFileLMD = parseInt(appConfFile.getLastModified());
            if (appConfFileLMD > cachedAppConfFileLMD) {
                updateCache = true;
            }
        } else {
            updateCache = true;
        }

        if (updateCache) {
            appConfFile.open("r");
            var content = appConfFile.readAll();
            var getProperty = require("process").getProperty;
            content = content.replace(/\$\{server\.ip}/g, getProperty("carbon.local.ip"));
            content = content.replace(/\$\{server\.http_port}/g, getProperty("carbon.http.port"));
            content = content.replace(/\$\{server\.https_port}/g, getProperty("carbon.https.port"));

            var appConf = parse(content);
            application.put(constants.CACHE_KEY_APP_CONF, appConf);
            application.put(constants.CACHE_KEY_APP_CONF_FILE_LMD,
                            String(appConfFile.getLastModified()));
            return appConf;
        } else {
            return cachedAppConf;
        }
    };
github wso2-attic / mdm / config / mdm.js View on Github external
config = function () {
        var log = new Log(),
            pinch = require('/modules/pinch.min.js').pinch,
            config = require('/config/config.json'),
            process = require('process'),
            localIP = process.getProperty('carbon.local.ip'),
            host = process.getProperty('server.host'),
            httpPort = process.getProperty('http.port'),
            httpsPort = process.getProperty('https.port');

        pinch(config, /^/, function (path, key, value) {
            if ((typeof value === 'string') && value.indexOf('%https.ip%') > -1) {
                return value.replace('%https.ip%', 'https://' + localIP + ':' + httpsPort);
            } else if ((typeof value === 'string') && value.indexOf('%http.ip%') > -1) {
                return value.replace('%http.ip%', 'http://' + localIP + ':' + httpPort);
            }else if ((typeof value === 'string') && value.indexOf('%https.host%') > -1) {
                return value.replace('%https.host%', 'http://' + host + ':' + httpPort);
            }else if ((typeof value === 'string') && value.indexOf('%http.host%') > -1) {
                return value.replace('%http.host%', 'http://' + host + ':' + httpPort);
            }
            return  value;
        });
github wso2 / carbon-device-mgt / components / device-mgt / org.wso2.carbon.device.mgt.ui / src / main / resources / jaggeryapps / uuf-template-app / lib / utils.js View on Github external
var updateCache = false;
        if (cachedAppConf) {
            var cachedAppConfFileLMD = parseInt(application.get(constants.CACHE_KEY_APP_CONF_FILE_LMD));
            var appConfFileLMD = parseInt(appConfFile.getLastModified());
            if (appConfFileLMD > cachedAppConfFileLMD) {
                updateCache = true;
            }
        } else {
            updateCache = true;
        }

        if (updateCache) {
            appConfFile.open("r");
            var content = appConfFile.readAll();
            var getProperty = require("process").getProperty;
            content = content.replace(/\$\{server\.ip}/g, getProperty("carbon.local.ip"));
            content = content.replace(/\$\{server\.http_port}/g, getProperty("carbon.http.port"));
            content = content.replace(/\$\{server\.https_port}/g, getProperty("carbon.https.port"));

            var appConf = parse(content);
            application.put(constants.CACHE_KEY_APP_CONF, appConf);
            application.put(constants.CACHE_KEY_APP_CONF_FILE_LMD,
                            String(appConfFile.getLastModified()));
            return appConf;
        } else {
            return cachedAppConf;
        }
    };
github wso2 / product-es / modules / apps / storage / modules / data / injectors / asset.display.injector.js View on Github external
function getUrl(uuid,config,object){

        var context=config.context;
        var storageUrlPattern=config.storageUrlPattern;
        var ip=process.getProperty('server.host');
        var https=process.getProperty('https.port');
        var http=process.getProperty('http.port');

        storageUrlPattern=storageUrlPattern.replace('{ip}',ip);

        storageUrlPattern=storageUrlPattern.replace('{http}',http);

        storageUrlPattern=storageUrlPattern.replace('{context}',context);
        storageUrlPattern=storageUrlPattern.replace('{uuid}',uuid);
        storageUrlPattern=storageUrlPattern.replace('{id}',object.id);

        log.debug('new url: '+storageUrlPattern);
        return storageUrlPattern;
    }
github wso2 / product-es / modules / apps / social / configs / social.js View on Github external
config = function () {
        var log = new Log(),
            pinch = require('/modules/pinch.min.js').pinch,
            config = require('/configs/social.json'),
            process = require('process'),
            localIP = process.getProperty('server.host'),
            httpPort = process.getProperty('http.port'),
            httpsPort = process.getProperty('https.port');
        var carbonLocalIP=process.getProperty('carbon.local.ip');


        pinch(config, /^/, function (path, key, value) {
            if ((typeof value === 'string') && value.indexOf('%https.host%') > -1) {
                return value.replace('%https.host%', 'https://' + localIP + ':' + httpsPort);
            } else if ((typeof value === 'string') && value.indexOf('%http.host%') > -1) {
                return value.replace('%http.host%', 'http://' + localIP + ':' + httpPort);
            }
            else if((typeof value === 'string') && value.indexOf('%https.carbon.local.ip%') > -1)
            {
                return value.replace('%https.carbon.local.ip%', 'https://' + carbonLocalIP + ':' + httpsPort);
            }
            else if((typeof value === 'string') && value.indexOf('%http.carbon.local.ip%') > -1) {
                return value.replace('%http.carbon.local.ip%', 'http://' + carbonLocalIP + ':' + httpPort);
github wso2-attic / carbon-uuf / src / lib / utils.js View on Github external
var updateCache = false;
        if (cachedAppConf) {
            var cachedAppConfFileLMD = parseInt(application.get(constants.CACHE_KEY_APP_CONF_FILE_LMD));
            var appConfFileLMD = parseInt(appConfFile.getLastModified());
            if (appConfFileLMD > cachedAppConfFileLMD) {
                updateCache = true;
            }
        } else {
            updateCache = true;
        }

        if (updateCache) {
            appConfFile.open("r");
            var content = appConfFile.readAll();
            var getProperty = require("process").getProperty;
            content = content.replace(/\$\{server\.ip}/g, getProperty("carbon.local.ip"));
            content = content.replace(/\$\{server\.http_port}/g, getProperty("carbon.http.port"));
            content = content.replace(/\$\{server\.https_port}/g, getProperty("carbon.https.port"));

            var appConf = parse(content);
            application.put(constants.CACHE_KEY_APP_CONF, appConf);
            application.put(constants.CACHE_KEY_APP_CONF_FILE_LMD,
                            String(appConfFile.getLastModified()));
            return appConf;
        } else {
            return cachedAppConf;
        }
    };