Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for bulkID in SCIM2 #393

Merged
merged 6 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.wso2.charon3.core.encoder;

import org.apache.commons.lang.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -53,8 +54,10 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.wso2.charon3.core.schema.SCIMDefinitions.DataType.BINARY;
import static org.wso2.charon3.core.schema.SCIMDefinitions.DataType.BOOLEAN;
Expand Down Expand Up @@ -881,6 +884,7 @@ public BulkRequestData decodeBulkData(String bulkResourceString) throws BadReque
List<BulkRequestContent> rolesEndpointOperationList = new ArrayList<>();
int failOnErrorsAttribute;
List<String> schemas = new ArrayList<>();
Set<String> encounteredBulkIds = new HashSet<>();

JSONObject decodedObject;
try {
Expand Down Expand Up @@ -917,9 +921,14 @@ public BulkRequestData decodeBulkData(String bulkResourceString) throws BadReque

if (requestMethod.equals(SCIMConstants.OperationalConstants.POST)) {

if (!member.optString(SCIMConstants.OperationalConstants.BULK_ID).equals("") &&
member.optString(SCIMConstants.OperationalConstants.BULK_ID) != null) {
String bulkId = member.optString(SCIMConstants.OperationalConstants.BULK_ID);

if (StringUtils.isNotEmpty(bulkId)) {
if (encounteredBulkIds.contains(bulkId)) {
String error = "Duplicate bulkId found: " + bulkId;
throw new BadRequestException(error, ResponseCodeConstants.INVALID_VALUE);
}
encounteredBulkIds.add(bulkId);
setRequestData(requestType, requestMethod, requestVersion, member, usersEndpointOperationList,
groupsEndpointOperationList, rolesEndpointOperationList);
} else {
Expand Down
Loading