Refactor device status filter management service #384
Open
pramilaniroshan
wants to merge 7 commits from pramilaniroshan/device-mgt-core:fix-subtenat-device-status-issue
into master
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'pramilaniroshan/device-mgt-core:fix-subtenat-device-status-issue'
Deleting a branch is permanent. It CANNOT be undone. Continue?
https://roadmap.entgra.net/issues/11060
List<AllowedDeviceStatus> statusList = gson.fromJson(metadata.getMetaValue(), listType);
MetadataManagementService metadataManagementService = new MetadataManagementServiceImpl();
Metadata metadata = metadataManagementService.retrieveMetadata(MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY);
Gson gson = new Gson();
Declare the Gson object as a filed to better memory optimization
List<String> allowedStatus = status.getStatus();
return allowedStatus.contains(deviceStatus);
}
MetadataManagementService metadataManagementService = new MetadataManagementServiceImpl();
Same code block as L224 - L241. Check the possibility of declaring method instead of duplicating the code
What is the commit of the solution for this? If it is not possible then there should be a comment that explains the reason.
Further check this [1] as well.
[1] - #384/files#issuecomment-15824
This is the commit
eb6186ba28
eb6186ba28
}
}
private void addDefaultDeviceStatusFilters(int tenantId) throws MetadataManagementException {
Add Java Doc comment.
}
}
private void addDefaultDeviceStatusCheck(int tenantId) throws MetadataManagementException {
Add Java Doc comment.
}
List<AllowedDeviceStatus> statusList = retrieveAndParseMetadata(tenantId);
for (AllowedDeviceStatus status : statusList) {
if (status.getType().equalsIgnoreCase(deviceType)) {
It is better if we check whether the value of 'deviceType' is empty or not using StringUtils and throw error. Further swap the check and modify it as follows to avoid from getting null point exception.
" deviceType.equalsIgnoreCase(status.getType()) "
return Collections.emptyList();
}
private List<AllowedDeviceStatus> retrieveAndParseMetadata(int tenantId) throws MetadataManagementException {
Add Java Doc comment.
}
Remove unnecessary new line
public void updateDefaultDeviceStatusFilters(int tenantId, String deviceType, List<String> deviceStatus) throws MetadataManagementException {
try {
if (StringUtils.isEmpty(deviceType)) {
throw new IllegalArgumentException("Device type must not be empty or null");
Log and throw the exception.
This PR needs to be improved. Hence until it is improved, it is not possible to merge . Please check the PR and identify mistakes and update the PR.
Reviewers