revert-70aa11f8
harshanl 8 years ago
commit 67942d5c1d

@ -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<BasicUserInfo> userList, offsetList;
RequestValidationUtil.validatePaginationParameters(offset, limit);
List<BasicUserInfo> 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) {

@ -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]);
}
}
}
}

@ -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"];

@ -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;

@ -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);

@ -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");

@ -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"];

@ -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