mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
deviceOrg: get children of root best practices apply
This commit is contained in:
parent
d2593114b7
commit
0de808229f
@ -433,7 +433,7 @@ public interface DeviceOrganizationMgtService {
|
||||
* @return A response containing a list of root device organizations.
|
||||
*/
|
||||
@GET
|
||||
@Path("roots-children")
|
||||
@Path("roots/children")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
|
||||
@ -158,7 +158,7 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("roots-children")
|
||||
@Path("roots/children")
|
||||
@Override
|
||||
public Response getDeviceOrganizationChildrenForRoots(
|
||||
@DefaultValue("0") @QueryParam("offset") int offset,
|
||||
|
||||
@ -177,22 +177,15 @@ public class DeviceOrganizationServiceImpl implements DeviceOrganizationService
|
||||
PaginationRequest paginationRequest = new PaginationRequest(request.getOffSet(), request.getLimit());
|
||||
List<DeviceOrganization> roots = getDeviceOrganizationRoots(paginationRequest);
|
||||
|
||||
if (roots == null || roots.isEmpty()) {
|
||||
log.warn("No root device organizations found.");
|
||||
return allDeviceOrganizations; // Return an empty list
|
||||
}
|
||||
|
||||
// Iterate over each root and fetch its children
|
||||
for (DeviceOrganization root : roots) {
|
||||
DeviceNodeResult childrenResult = getChildrenOfDeviceNode(root.getDeviceId(), request.getMaxDepth(), request.isIncludeDevice());
|
||||
if (childrenResult != null) {
|
||||
allDeviceOrganizations.add(childrenResult);
|
||||
} else {
|
||||
log.warn("no children found for roots.");
|
||||
}
|
||||
}
|
||||
return allDeviceOrganizations;
|
||||
} catch (NullPointerException | DeviceOrganizationMgtPluginException e) {
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
String msg = "Error occurred while retrieving all device organizations for roots.";
|
||||
log.error(msg, e);
|
||||
throw new DeviceOrganizationMgtPluginException(msg, e);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user