Skip to content

Commit

Permalink
Merge pull request #534 from somindatommy/fix_http_error_code
Browse files Browse the repository at this point in the history
Fix the invalid http error code for existing group name
  • Loading branch information
UdeshAthukorala authored Feb 27, 2024
2 parents 998419e + 35226f4 commit d8961fb
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.wso2.carbon.user.core.UserStoreClientException;
import org.wso2.carbon.user.core.constants.UserCoreErrorConstants;

import static org.wso2.carbon.user.core.constants.UserCoreErrorConstants.ErrorMessages.ERROR_CODE_GROUP_ALREADY_EXISTS;

/**
* Default implementation of SCIMUserStoreErrorResolver. Should be used to resolve errors thrown by default
* user store managers packed in the product.
Expand All @@ -42,7 +44,9 @@ public SCIMUserStoreException resolve(UserStoreException e) {
if (e.getMessage().contains(ERROR_CODE_USER_NOT_FOUND)) {
String msg = e.getMessage().substring(e.getMessage().indexOf(":") + 1).trim();
return new SCIMUserStoreException(msg, HttpStatus.SC_NOT_FOUND);
} else if (e.getMessage().contains(ERROR_CODE_EXISTING_ROLE_NAME)) {
} else if (e.getMessage().contains(ERROR_CODE_EXISTING_ROLE_NAME) ||
(e instanceof org.wso2.carbon.user.core.UserStoreClientException &&
((UserStoreClientException) e).getErrorCode().contains(ERROR_CODE_GROUP_ALREADY_EXISTS.getCode()))) {
String groupName = e.getMessage().substring(e.getMessage().indexOf(":") + 1).trim().split("\\s+")[0];
String msg =
"Group name: " + groupName + " is already there in the system. Please pick another group name.";
Expand Down

0 comments on commit d8961fb

Please sign in to comment.