From cd9d127a5e1b1616ac5d0409fe225e0c93114f33 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Thu, 15 Jun 2023 11:15:23 +0530 Subject: [PATCH] remove unnecessary variable, change error msg --- .../jaxrs/service/impl/GroupManagementServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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/GroupManagementServiceImpl.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/GroupManagementServiceImpl.java index b7e9ba8271a..262e51eb9fb 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/GroupManagementServiceImpl.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/GroupManagementServiceImpl.java @@ -449,15 +449,15 @@ public class GroupManagementServiceImpl implements GroupManagementService { @Path("/roles/share") @Override public Response createGroupWithRoles(DeviceGroupRoleWrapper groups) { - String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (groups == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } - groups.setOwner(owner); + groups.setOwner(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); groups.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); try { DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(groups, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); - DeviceGroup group = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroup(groups.getName(), owner.isEmpty()); + DeviceGroup group = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroup(groups.getName(), + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername().isEmpty()); if (group != null) { DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), groups.getUserRoles()); return Response.status(Response.Status.CREATED).entity(group.getGroupId()).build(); @@ -467,7 +467,7 @@ public class GroupManagementServiceImpl implements GroupManagementService { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } catch (GroupManagementException e) { - String msg = "Error occurred while adding new group."; + String msg = "Error occurred while adding " + groups.getName() + " group"; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (GroupAlreadyExistException e) {