Skip to content

Commit

Permalink
Fix the null pointer for operation json list.
Browse files Browse the repository at this point in the history
  • Loading branch information
Malith-19 committed Jun 28, 2024
1 parent 5e0de7a commit 78a8572
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -746,13 +746,26 @@ private ComplexAttribute buildComplexValue(AttributeSchema attributeSchema,
*/
public ArrayList<PatchOperation> decodeRequest(String scimResourceString) throws BadRequestException {


ArrayList<PatchOperation> operationList = new ArrayList<PatchOperation>();
try {
//decode the string into json representation
JSONObject decodedJsonObj = new JSONObject(new JSONTokener(scimResourceString));
//obtain the Operations values
JSONArray operationJsonList = (JSONArray) decodedJsonObj.opt(SCIMConstants.OperationalConstants.OPERATIONS);

//check if operationJsonList is null
if (operationJsonList == null) {

//throw appropriate exception based on the key check
if (decodedJsonObj.has(StringUtils.lowerCase(SCIMConstants.OperationalConstants.OPERATIONS))) {
throw new BadRequestException("Invalid JSON schema.", ResponseCodeConstants.INVALID_SYNTAX);
}

//if the key with lowercase name does not exist, throw this exception
throw new BadRequestException(ResponseCodeConstants.INVALID_SYNTAX);
}


//for each operation, create a PatchOperation object and add the relevant values to it
for (int count = 0; count < operationJsonList.length(); count++) {
JSONObject operation = (JSONObject) operationJsonList.get(count);
Expand Down

0 comments on commit 78a8572

Please sign in to comment.