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

Fix the invalid http error code for existing group name #534

Merged
Merged
Changes from all 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 @@ -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
Loading