fix: sub tenants grouping issue

master
Thilina Sandaruwan 1 year ago committed by pasindu
parent 5d9938d7be
commit fde6de94bb

@ -44,6 +44,7 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.GroupMan
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil;
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.apache.commons.lang.StringUtils;
import javax.ws.rs.DefaultValue; import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET; import javax.ws.rs.GET;
@ -106,13 +107,22 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ
@DefaultValue("5") @QueryParam("limit") int limit) { @DefaultValue("5") @QueryParam("limit") int limit) {
try { try {
RequestValidationUtil.validatePaginationParameters(offset, limit); RequestValidationUtil.validatePaginationParameters(offset, limit);
String currentUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
GroupPaginationRequest request = new GroupPaginationRequest(offset, limit); GroupPaginationRequest request = new GroupPaginationRequest(offset, limit);
request.setGroupName(name); request.setGroupName(name);
request.setOwner(owner); request.setOwner(owner);
request.setStatus(status); request.setStatus(status);
request.setDepth(depth); request.setDepth(depth);
PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService()
PaginationResult deviceGroupsResult;
if (StringUtils.isBlank(currentUser)) {
deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService()
.getGroupsWithHierarchy(null, request, requireGroupProps); .getGroupsWithHierarchy(null, request, requireGroupProps);
} else {
deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService()
.getGroupsWithHierarchy(currentUser, request, requireGroupProps);
}
DeviceGroupList deviceGroupList = new DeviceGroupList(); DeviceGroupList deviceGroupList = new DeviceGroupList();
deviceGroupList.setList(deviceGroupsResult.getData()); deviceGroupList.setList(deviceGroupsResult.getData());
deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal()); deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal());

Loading…
Cancel
Save