device organization api implementation to get children of root nodes #353
Merged
tcdlpds
merged 4 commits from isuri/device-mgt-core:deviceOrgImprovements
into master
9 months ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'isuri/device-mgt-core:deviceOrgImprovements'
Deleting a branch is permanent. It CANNOT be undone. Continue?
WIP: device organization api implementation to get children of root nodesto device organization api implementation to get children of root nodes 9 months agopackage io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto;
Add the license
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceNodeResult;
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceOrganization;
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.PaginationRequest;
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.*;
Do not use wild card imports
allDeviceOrganizations.add(childrenResult);
}
return allDeviceOrganizations;
} catch (Exception e) {
What is the reason for catching Exception here? Can't we catch the specific exceptions?
return allDeviceOrganizations;
} catch (Exception e) {
String msg = "Error occurred while retrieving all device organizations for roots.";
log.error(msg);
Log error as well.
* @return A response containing a list of root device organizations.
*/
@GET
@Path("roots-children")
Better to change the context path into /roots/children
PaginationRequest paginationRequest = new PaginationRequest(request.getOffSet(), request.getLimit());
List<DeviceOrganization> roots = getDeviceOrganizationRoots(paginationRequest);
if (roots == null || roots.isEmpty()) {
What is the purpose of logging warn message for the empty list here? If there is no reason it is better to remove the warn log and can also omit the empty checking as well.
If roots are empty or null when iterating over it there can be NullPointerExceptions. That is why the check is added. warn msg can be removed.
Iterating over an empty list isn't throw a null ptr. So
Got the point?
Yeah, it was a technical misunderstanding on my side.
if (childrenResult != null) {
allDeviceOrganizations.add(childrenResult);
} else {
log.warn("no children found for roots.");
If there is no reason, better to remove the warn log from the loop.
}
}
return allDeviceOrganizations;
} catch (NullPointerException | DeviceOrganizationMgtPluginException e) {
No need to catch the NullPointerException here since it's a runtime exception.
}
@GET
@Path("roots-children")
Better to change the context path into /roots/children
3092737268
into master 9 months agoReviewers
3092737268
.