revert-70aa11f8
harshanl 8 years ago
commit 67942d5c1d

@ -264,10 +264,14 @@ public class UserManagementServiceImpl implements UserManagementService {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Getting the list of users with all user-related information"); log.debug("Getting the list of users with all user-related information");
} }
List<BasicUserInfo> userList, offsetList;
RequestValidationUtil.validatePaginationParameters(offset, limit); RequestValidationUtil.validatePaginationParameters(offset, limit);
List<BasicUserInfo> userList, offsetList;
String appliedFilter = ((filter == null) || filter.isEmpty() ? "*" : filter); String appliedFilter = ((filter == null) || filter.isEmpty() ? "*" : filter);
int appliedLimit = (limit <= 0) ? -1 : (limit + offset); // to get whole set of users, appliedLimit is set to -1
// by default, this whole set is limited to 100 - MaxUserNameListLength of user-mgt.xml
int appliedLimit = -1;
try { try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
@ -285,14 +289,23 @@ public class UserManagementServiceImpl implements UserManagementService {
userList.add(user); userList.add(user);
} }
if (offset <= userList.size()) { int toIndex = offset + limit;
offsetList = userList.subList(offset, userList.size()); int listSize = userList.size();
int lastIndex = listSize - 1;
if (offset <= lastIndex) {
if (toIndex <= listSize) {
offsetList = userList.subList(offset, toIndex);
} else {
offsetList = userList.subList(offset, listSize);
}
} else { } else {
offsetList = new ArrayList<>(); offsetList = new ArrayList<>();
} }
BasicUserInfoList result = new BasicUserInfoList(); BasicUserInfoList result = new BasicUserInfoList();
result.setList(offsetList); result.setList(offsetList);
result.setCount(offsetList.size()); result.setCount(users.length);
return Response.status(Response.Status.OK).entity(result).build(); return Response.status(Response.Status.OK).entity(result).build();
} catch (UserStoreException e) { } catch (UserStoreException e) {

@ -35,18 +35,20 @@ function appendQueryParam (url, queryParam , value) {
if (uriMatcher.match("/{context}/api/data-tables/invoker")) { if (uriMatcher.match("/{context}/api/data-tables/invoker")) {
var url = request.getParameter("url"); var url = request.getParameter("url");
var targetURL = devicemgtProps["httpsURL"] + request.getParameter("url"); var targetURL = devicemgtProps["httpsURL"] + request.getParameter("url");
//noinspection JSUnresolvedFunction getAllParameters
var allParams = request.getAllParameters(); var allParams = request.getAllParameters();
for (var key in allParams) { for (var allParamsKey in allParams) {
if (allParams.hasOwnProperty(key)) { if (allParams.hasOwnProperty(allParamsKey)) {
if(key == "limit" || key == "offset"){ if (allParamsKey == "limit" || allParamsKey == "offset") {
targetURL = appendQueryParam(targetURL, key, allParams[key]); targetURL = appendQueryParam(targetURL, allParamsKey, allParams[allParamsKey]);
} } else if (allParamsKey == "filter") {
if(key == "filter"){ if (allParams[allParamsKey]) {
if(allParams[key]){ var searchPayload = JSON.parse(allParams[allParamsKey]);
var searchPayload = JSON.parse(allParams[key]); for (var searchPayloadKey in searchPayload) {
for (var key in searchPayload) { if (searchPayload.hasOwnProperty(searchPayloadKey)) {
targetURL = appendQueryParam(targetURL, key, searchPayload[key]); targetURL = appendQueryParam(targetURL, searchPayloadKey, searchPayload[searchPayloadKey]);
}
} }
} }
} }

@ -32,8 +32,8 @@ if (uriMatcher.match("/{context}/api/operation/paginate")) {
var length = request.getParameter("length"); var length = request.getParameter("length");
var search = request.getParameter("search[value]"); var search = request.getParameter("search[value]");
var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices/" + var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
deviceType + "/" + deviceId + "/operations?offset=" + index + "&limit=" + length; "/devices/" + deviceType + "/" + deviceId + "/operations?offset=" + index + "&limit=" + length;
serviceInvokers.XMLHttp.get( serviceInvokers.XMLHttp.get(
restAPIEndpoint, restAPIEndpoint,
@ -46,7 +46,7 @@ if (uriMatcher.match("/{context}/api/operation/paginate")) {
paginatedResult["recordsFiltered"] = responsePayload["count"]; paginatedResult["recordsFiltered"] = responsePayload["count"];
paginatedResult["data"] = responsePayload["operations"]; paginatedResult["data"] = responsePayload["operations"];
response["status"] = 200; response["status"] = restAPIResponse["status"];
response["content"] = paginatedResult; response["content"] = paginatedResult;
} else { } else {
response["status"] = restAPIResponse["status"]; response["status"] = restAPIResponse["status"];

@ -26,11 +26,11 @@ var constants = require("/app/modules/constants.js");
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var utility = require("/app/modules/utility.js").utility; var utility = require("/app/modules/utility.js")["utility"];
var apiWrapperUtil = require("/app/modules/oauth/token-handlers.js")["handlers"]; var apiWrapperUtil = require("/app/modules/oauth/token-handlers.js")["handlers"];
var util = require("/app/modules/oauth/token-handler-utils.js")["utils"]; var util = require("/app/modules/oauth/token-handler-utils.js")["utils"];
var responseProcessor = require('utils').response; var responseProcessor = require("utils").response;
var result; var result;

@ -18,17 +18,20 @@
var carbonModule = require("carbon"); var carbonModule = require("carbon");
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var utility = require("/app/modules/utility.js")["utility"];
//noinspection JSUnresolvedFunction Server
var carbonServer = new carbonModule.server.Server({ var carbonServer = new carbonModule.server.Server({
tenanted: true, tenanted: true,
url: devicemgtProps["httpsURL"] + "/admin" url: devicemgtProps["httpsURL"] + "/admin"
}); });
application.put("carbonServer", carbonServer); application.put("carbonServer", carbonServer);
var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; //var permissions = {
var utility = require("/app/modules/utility.js")["utility"]; // "/permission/admin/device-mgt/user": ["ui.execute"],
// "/permission/admin/manage/api/subscribe": ["ui.execute"]
//};
var permissions = {
'/permission/admin/device-mgt/user': ['ui.execute'],
'/permission/admin/manage/api/subscribe': ['ui.execute']
};
//userModule.addRole("internal/devicemgt-user", ["admin"], permissions); //userModule.addRole("internal/devicemgt-user", ["admin"], permissions);

@ -60,21 +60,6 @@ utility = function () {
return getOsgiService("org.wso2.carbon.policy.mgt.core.PolicyManagerService"); return getOsgiService("org.wso2.carbon.policy.mgt.core.PolicyManagerService");
}; };
publicMethods.getIoTServerConfig = function (configName) {
var path = "/config/iot-config.json";
var file = new File(path);
try {
file.open("r");
var content = file.readAll();
} catch (err) {
log.error("Error while reading IoT server config file `" + path + "`: " + err);
} finally {
file.close();
}
var json = parse(content);
return json[configName];
};
publicMethods.getDeviceTypeConfig = function (deviceType) { publicMethods.getDeviceTypeConfig = function (deviceType) {
var unitName = publicMethods.getTenantedDeviceUnitName(deviceType, "type-view"); var unitName = publicMethods.getTenantedDeviceUnitName(deviceType, "type-view");

@ -31,6 +31,9 @@ function onRequest() {
if (response["status"] == "success") { if (response["status"] == "success") {
page["roles"] = response["content"]; page["roles"] = response["content"];
} }
var userStores = userModule.getSecondaryUserStores();
page["userStores"] = userStores;
page["charLimit"] = devicemgtProps["usernameLength"]; page["charLimit"] = devicemgtProps["usernameLength"];
page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"]; page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"];
page["usernameHelpMsg"] = devicemgtProps["userValidationConfig"]["usernameHelpMsg"]; page["usernameHelpMsg"] = devicemgtProps["userValidationConfig"]["usernameHelpMsg"];

@ -1,9 +0,0 @@
{
"grantType": "password urn:ietf:params:oauth:grant-type:saml2-bearer refresh_token",
"saasApp": true,
"tokenScope": "admin",
"requireDynamicClientRegistration": true,
"audience": "https://localhost:9443/oauth2/token",
"assertionConsumerURL": "https://localhost:9443/devicemgt/sso/acs",
"recepientValidationURL": "https://localhost:9443/oauth2/token"
}
Loading…
Cancel
Save