From e66c3dc6f62fc8e22c0100c19395426fe0562401 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Thu, 15 Jun 2023 14:29:10 +0530 Subject: [PATCH] add error log --- .../impl/admin/GroupManagementAdminServiceImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 30546f214a..4495a3fe9c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -152,21 +152,22 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ @Path("/roles/share") @Override public Response createGroupWithRoles(DeviceGroupRoleWrapper group) { - String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (group == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } - group.setOwner(owner); + group.setOwner(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); group.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); try { DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), group.getUserRoles()); return Response.status(Response.Status.CREATED).build(); } catch (GroupManagementException e) { - String msg = "Error occurred while adding new group."; + String msg = "Error occurred while adding " + group.getName() + " group"; + log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (GroupAlreadyExistException e) { String msg = "Group already exists with name : " + group.getName() + "."; + log.warn(msg); return Response.status(Response.Status.CONFLICT).entity(msg).build(); } catch (RoleDoesNotExistException e) { return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();