Add attched roles to logs when creating groups

deviceOrganization^2
prathabanKavin 10 months ago
parent 2a153b7ddd
commit a259a5892e

@ -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)

@ -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;
}

@ -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());
}

Loading…
Cancel
Save