fixing jars

merge-requests/1/head
Rasika 9 years ago
parent 2dcc9b8eac
commit d4283a39e8

@ -23,7 +23,7 @@ userModule = function () {
var constants = require("/modules/constants.js"); var constants = require("/modules/constants.js");
var utility = require("/modules/utility.js").utility; var utility = require("/modules/utility.js").utility;
var userManagementService = utility.getUserManagementService(); //var userManagementService = utility.getUserManagementService();
var publicMethods = {}; var publicMethods = {};
var privateMethods = {}; var privateMethods = {};
@ -245,35 +245,35 @@ userModule = function () {
} }
}; };
publicMethods.getUsers = function () { //publicMethods.getUsers = function () {
var carbon = require('carbon'); // var carbon = require('carbon');
//
var carbonUser = session.get(constants.USER_SESSION_KEY); // var carbonUser = session.get(constants.USER_SESSION_KEY);
if (!carbonUser) { // if (!carbonUser) {
log.error("User object was not found in the session"); // log.error("User object was not found in the session");
throw constants.ERRORS.USER_NOT_FOUND; // throw constants.ERRORS.USER_NOT_FOUND;
} // }
//
var userList; // var userList;
try{ // try{
userList = userManagementService.getUsersForTenant(carbonUser.tenantId); // userList = userManagementService.getUsersForTenant(carbonUser.tenantId);
}catch(e){ // }catch(e){
log.error("Error occurred while reading all users"); // log.error("Error occurred while reading all users");
return []; // return [];
} // }
//
var users = []; // var users = [];
var i, userObject; // var i, userObject;
for (i = 0; i < userList.size(); i++) { // for (i = 0; i < userList.size(); i++) {
userObject = userList.get(i); // userObject = userList.get(i);
users.push({ // users.push({
"username" : userObject.getUserName(), // "username" : userObject.getUserName(),
"email" : userObject.getEmail(), // "email" : userObject.getEmail(),
"name" : userObject.getFirstName() + " " + userObject.getLastName() // "name" : userObject.getFirstName() + " " + userObject.getLastName()
}); // });
} // }
return users; // return users;
}; //};
publicMethods.isAuthorized = function (permission) { publicMethods.isAuthorized = function (permission) {
var carbonModule = require("carbon"); var carbonModule = require("carbon");

@ -18,18 +18,20 @@
var utility; var utility;
utility = function () { utility = function () {
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;
var getOsgiService = function (className) { //var getOsgiService = function (className) {
return PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(JavaClass.forName(className)); // var log = new Log();
}; // log.info("###### Current Class : "+className);
// return PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(JavaClass.forName(className));
//};
var publicMethods = {}; var publicMethods = {};
publicMethods.getUserManagementService = function () { //publicMethods.getUserManagementService = function () {
return getOsgiService('org.wso2.carbon.device.mgt.user.core.service.UserManagementService'); // return getOsgiService('org.wso2.carbon.device.mgt.user.core.service.UserManagementService');
}; //};
publicMethods.insertAppPermissions = function (userModule, type) { publicMethods.insertAppPermissions = function (userModule, type) {
userModule.addPermissions([{key: "device-mgt", name: "Device Management"}], "", type); userModule.addPermissions([{key: "device-mgt", name: "Device Management"}], "", type);

Loading…
Cancel
Save