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 ff770ed7789..fc8f080b07c 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 @@ -558,12 +558,17 @@ public class GroupManagementServiceImpl implements GroupManagementService { PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername().isEmpty()); if (group != null) { DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), groups.getUserRoles()); + String stringRoles = ""; + if(groups.getUserRoles() != null){ + stringRoles = new Gson().toJson(groups.getUserRoles()); + } log.info( "Group " + group.getName() + " created", groupMgtContextBuilder .setActionTag("ADD_GROUP") .setGroupId(String.valueOf(group.getGroupId())) .setName(group.getName()) + .setRoles(stringRoles) .setOwner(group.getOwner()) .setTenantID(tenantId) .setTenantDomain(tenantDomain) diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/GroupMgtLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/GroupMgtLogContext.java index 113f22fb2c7..ed867ec1128 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/GroupMgtLogContext.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/GroupMgtLogContext.java @@ -25,6 +25,7 @@ public class GroupMgtLogContext extends LogContext { private final String name; private final String owner; private final String actionTag; + private final String roles; private final String deviceCount; private final String deviceIdentifiers; private final String userName; @@ -36,6 +37,7 @@ public class GroupMgtLogContext extends LogContext { this.name = builder.name; this.owner = builder.owner; this.actionTag = builder.actionTag; + this.roles = builder.roles; this.deviceCount = builder.deviceCount; this.deviceIdentifiers = builder.deviceIdentifiers; this.userName = builder.userName; @@ -59,6 +61,10 @@ public class GroupMgtLogContext extends LogContext { return actionTag; } + public String getRoles() { + return roles; + } + public String getDeviceCount() { return deviceCount; } @@ -84,6 +90,7 @@ public class GroupMgtLogContext extends LogContext { private String name; private String owner; private String actionTag; + private String roles; private String deviceCount; private String deviceIdentifiers; private String userName; @@ -129,6 +136,15 @@ public class GroupMgtLogContext extends LogContext { return this; } + public String getRoles() { + return roles; + } + + public Builder setRoles(String roles) { + this.roles = roles; + return this; + } + public String getDeviceCount() { return deviceCount; } diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java index 713ac3cc2fc..adfb01ef4d1 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java @@ -228,6 +228,9 @@ public final class MDCContextUtil { if (mdcContext.getActionTag() != null) { MDC.put("ActionTag", mdcContext.getActionTag()); } + if (mdcContext.getRoles() != null) { + MDC.put("Roles", mdcContext.getRoles()); + } if (mdcContext.getDeviceCount() != null) { MDC.put("DeviceCount", mdcContext.getDeviceCount()); }