From e6ea2175cdab7455f1d23e9e6abccce3b9557766 Mon Sep 17 00:00:00 2001 From: charitha Date: Mon, 4 Nov 2019 12:39:15 +0530 Subject: [PATCH] Add review suggestions --- .../service/api/GroupManagementService.java | 2 +- .../GroupManagementProviderServiceImpl.java | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java index 48802315742..f61d2124932 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java @@ -450,7 +450,7 @@ public interface GroupManagementService { "the requested resource."), @ApiResponse( code = 404, - message = "Group found.", + message = "Group not found.", response = ErrorResponse.class), @ApiResponse( code = 406, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java index f3c3ab2c82e..efe71421dbc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -569,12 +569,16 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid count = groupDAO.getOwnGroupsCount(username, tenantId); count += groupDAO.getGroupsCount(roleList, tenantId); return count; - } catch (UserStoreException | GroupManagementDAOException | SQLException e) { - String msg = "Error occurred while retrieving group count of user '" + username + "'"; + } catch (UserStoreException e) { + String msg = "Error occurred while retrieving role list of user '" + username + "'"; log.error(msg, e); throw new GroupManagementException(msg, e); - } catch (Exception e) { - String msg = "Error occurred in getGroupCount for username '" + username + "'"; + } catch (SQLException e) { + String msg = "Error occurred while opening db connection to get group count."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (GroupManagementDAOException e) { + String msg = "Error occurred while retrieving group count of user '" + username + "'"; log.error(msg, e); throw new GroupManagementException(msg, e); } finally { @@ -1002,6 +1006,13 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } + /** + * This is populating group properties in to the group pass as an argument. Call should be manage the transactions. + * + * @param deviceGroup which needs to populate with properties + * @param tenantId of the caller + * @throws GroupManagementDAOException on DAO exceptions + */ private void populateGroupProperties(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException { if (deviceGroup != null && deviceGroup.getGroupId() > 0) { deviceGroup.setGroupProperties(this.groupDAO.getAllGroupProperties(deviceGroup.getGroupId(),