Skip to content

Commit

Permalink
Call addGroupWithID from createGroup function
Browse files Browse the repository at this point in the history
  • Loading branch information
LakshiAthapaththu committed Aug 8, 2023
1 parent 1af8a42 commit e96d5fd
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2587,6 +2587,7 @@ public Group createGroup(Group group, Map<String, Boolean> requiredAttributes)
// If members are sent when creating the group, check whether users already exist in the user store.
List<Object> userIds = group.getMembers();
List<String> userDisplayNames = group.getMembersWithDisplayName();
org.wso2.carbon.user.core.common.Group coreGroup = null;
if (isNotEmpty(userIds)) {
List<String> members = new ArrayList<>();
for (Object userId : userIds) {
Expand Down Expand Up @@ -2628,22 +2629,25 @@ public Group createGroup(Group group, Map<String, Boolean> requiredAttributes)
SCIMGroupHandler scimGroupHandler = new SCIMGroupHandler(carbonUM.getTenantId());
scimGroupHandler.createSCIMAttributes(group);
// carbonUM.addRoleWithID(group.getDisplayName(), members.toArray(new String[0]), null, false);
org.wso2.carbon.user.core.common.Group coreGroup =
carbonUM.addRoleWithRoleID(group.getDisplayName(), members.toArray(new String[0]), null, false);
group.getAttributeList().remove(SCIMConstants.CommonSchemaConstants.ID);
group.setId(coreGroup.getGroupID());
coreGroup = carbonUM.addGroupWithID(group.getDisplayName(), members.toArray(new String[0]), null, false);
if (log.isDebugEnabled()) {
log.debug("Group: " + group.getDisplayName() + " is created through SCIM.");
}
} else {
// Add other scim attributes in the identity DB since user store doesn't support some attributes.
SCIMGroupHandler scimGroupHandler = new SCIMGroupHandler(carbonUM.getTenantId());
scimGroupHandler.createSCIMAttributes(group);
carbonUM.addRoleWithID(group.getDisplayName(), null, null, false);
// carbonUM.addRoleWithID(group.getDisplayName(), null, null, false);
coreGroup = carbonUM.addGroupWithID(group.getDisplayName(), null, null, false);

if (log.isDebugEnabled()) {
log.debug("Group: " + group.getDisplayName() + " is created through SCIM.");
}
}
group.getAttributeList().remove(SCIMConstants.CommonSchemaConstants.ID);
if (coreGroup != null) {
group.setId(coreGroup.getGroupID());
}
} catch (UserStoreException e) {
try {
SCIMGroupHandler scimGroupHandler = new SCIMGroupHandler(carbonUM.getTenantId());
Expand Down

0 comments on commit e96d5fd

Please sign in to comment.