diff --git a/src/main/java/org/wso2/scim2/client/ProvisioningClient.java b/src/main/java/org/wso2/scim2/client/ProvisioningClient.java index 3f732bb..9c5741e 100644 --- a/src/main/java/org/wso2/scim2/client/ProvisioningClient.java +++ b/src/main/java/org/wso2/scim2/client/ProvisioningClient.java @@ -1,19 +1,17 @@ /* - * Copyright (c) 2018-2024, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.wso2.scim2.client; diff --git a/src/main/java/org/wso2/scim2/operation/GroupOperations.java b/src/main/java/org/wso2/scim2/operation/GroupOperations.java index 621a088..b9a045d 100644 --- a/src/main/java/org/wso2/scim2/operation/GroupOperations.java +++ b/src/main/java/org/wso2/scim2/operation/GroupOperations.java @@ -154,13 +154,14 @@ public void updateGroup() throws IdentitySCIMException { return; } - // get corresponding userIds - Group updatedGroup = setUserIdForMembers(); String encodedGroup; - if (updatedGroup != null) { - encodedGroup = scimClient.encodeSCIMObject(updatedGroup, SCIMConstants.JSON); - } else { + List users = ((Group) scimObject).getMembersWithDisplayName(); + if (CollectionUtils.isEmpty(users)) { encodedGroup = scimClient.encodeSCIMObject((AbstractSCIMObject) scimObject, SCIMConstants.JSON); + } else { + // Find corresponding userIds of group members and enrich the scimObject. + Group updatedGroup = addUserIDForMembersOfGroup(); + encodedGroup = scimClient.encodeSCIMObject(updatedGroup, SCIMConstants.JSON); } client.setURL(groupEPURL + "/" + groupId); Scimv2GroupsApi api = new Scimv2GroupsApi(client); @@ -188,12 +189,10 @@ public void updateGroup() throws IdentitySCIMException { } } - private Group setUserIdForMembers() throws AbstractCharonException, ScimApiException, IOException { + private Group addUserIDForMembersOfGroup() throws AbstractCharonException, ScimApiException, IOException { List users = ((Group) scimObject).getMembersWithDisplayName(); - if (CollectionUtils.isEmpty(users)) { - return null; - } + //create a deep copy of the group since we are going to update the member ids Group copiedGroup = (Group) CopyUtil.deepCopy(scimObject); //delete existing members in the group since we are going to update it with