diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index 9734c9622db..0be452585f9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -264,10 +264,14 @@ public class UserManagementServiceImpl implements UserManagementService { if (log.isDebugEnabled()) { log.debug("Getting the list of users with all user-related information"); } - List userList, offsetList; + RequestValidationUtil.validatePaginationParameters(offset, limit); + + List userList, offsetList; 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 { UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); @@ -285,14 +289,23 @@ public class UserManagementServiceImpl implements UserManagementService { userList.add(user); } - if (offset <= userList.size()) { - offsetList = userList.subList(offset, userList.size()); + int toIndex = offset + limit; + 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 { offsetList = new ArrayList<>(); } + BasicUserInfoList result = new BasicUserInfoList(); result.setList(offsetList); - result.setCount(offsetList.size()); + result.setCount(users.length); return Response.status(Response.Status.OK).entity(result).build(); } catch (UserStoreException e) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag index 05ca19906ae..0fb2945cf49 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag @@ -35,18 +35,20 @@ function appendQueryParam (url, queryParam , value) { if (uriMatcher.match("/{context}/api/data-tables/invoker")) { var url = request.getParameter("url"); var targetURL = devicemgtProps["httpsURL"] + request.getParameter("url"); + //noinspection JSUnresolvedFunction getAllParameters var allParams = request.getAllParameters(); - for (var key in allParams) { - if (allParams.hasOwnProperty(key)) { - if(key == "limit" || key == "offset"){ - targetURL = appendQueryParam(targetURL, key, allParams[key]); - } - if(key == "filter"){ - if(allParams[key]){ - var searchPayload = JSON.parse(allParams[key]); - for (var key in searchPayload) { - targetURL = appendQueryParam(targetURL, key, searchPayload[key]); + for (var allParamsKey in allParams) { + if (allParams.hasOwnProperty(allParamsKey)) { + if (allParamsKey == "limit" || allParamsKey == "offset") { + targetURL = appendQueryParam(targetURL, allParamsKey, allParams[allParamsKey]); + } else if (allParamsKey == "filter") { + if (allParams[allParamsKey]) { + var searchPayload = JSON.parse(allParams[allParamsKey]); + for (var searchPayloadKey in searchPayload) { + if (searchPayload.hasOwnProperty(searchPayloadKey)) { + targetURL = appendQueryParam(targetURL, searchPayloadKey, searchPayload[searchPayloadKey]); + } } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag index c6dca893214..7465f21649a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag @@ -32,8 +32,8 @@ if (uriMatcher.match("/{context}/api/operation/paginate")) { var length = request.getParameter("length"); var search = request.getParameter("search[value]"); - var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices/" + - deviceType + "/" + deviceId + "/operations?offset=" + index + "&limit=" + length; + var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + + "/devices/" + deviceType + "/" + deviceId + "/operations?offset=" + index + "&limit=" + length; serviceInvokers.XMLHttp.get( restAPIEndpoint, @@ -46,7 +46,7 @@ if (uriMatcher.match("/{context}/api/operation/paginate")) { paginatedResult["recordsFiltered"] = responsePayload["count"]; paginatedResult["data"] = responsePayload["operations"]; - response["status"] = 200; + response["status"] = restAPIResponse["status"]; response["content"] = paginatedResult; } else { response["status"] = restAPIResponse["status"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag index 212a0875394..22d2b74fc7f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag @@ -26,11 +26,11 @@ var constants = require("/app/modules/constants.js"); var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; 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 util = require("/app/modules/oauth/token-handler-utils.js")["utils"]; -var responseProcessor = require('utils').response; +var responseProcessor = require("utils").response; var result; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js index d9f442cdd4e..1c367b38f5c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js @@ -18,17 +18,20 @@ var carbonModule = require("carbon"); 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({ tenanted: true, url: devicemgtProps["httpsURL"] + "/admin" }); + application.put("carbonServer", carbonServer); -var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; -var utility = require("/app/modules/utility.js")["utility"]; +//var permissions = { +// "/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); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js index f5dd896bc43..3af4f59e6a0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js @@ -60,21 +60,6 @@ utility = function () { 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) { var unitName = publicMethods.getTenantedDeviceUnitName(deviceType, "type-view"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js index 5ba8114a045..a014415bc69 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js @@ -31,6 +31,9 @@ function onRequest() { if (response["status"] == "success") { page["roles"] = response["content"]; } + + var userStores = userModule.getSecondaryUserStores(); + page["userStores"] = userStores; page["charLimit"] = devicemgtProps["usernameLength"]; page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"]; page["usernameHelpMsg"] = devicemgtProps["userValidationConfig"]["usernameHelpMsg"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/config/iot-config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/config/iot-config.json deleted file mode 100644 index 708d1eca74b..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/config/iot-config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "IoTMgtHost" : "localhost" -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/config/service-provider.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/config/service-provider.json deleted file mode 100644 index b2041d5def7..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/config/service-provider.json +++ /dev/null @@ -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" -}