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

Return 400 BadRequest for pre check validation failure of role deletion #493

Merged
merged 3 commits into from
Oct 26, 2023
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 @@ -79,6 +79,7 @@
import static org.wso2.carbon.identity.role.v2.mgt.core.RoleConstants.Error.INVALID_REQUEST;
import static org.wso2.carbon.identity.role.v2.mgt.core.RoleConstants.Error.OPERATION_FORBIDDEN;
import static org.wso2.carbon.identity.role.v2.mgt.core.RoleConstants.Error.ROLE_ALREADY_EXISTS;
import static org.wso2.carbon.identity.role.v2.mgt.core.RoleConstants.Error.ROLE_MANAGEMENT_ERROR_CODE_PREFIX;
import static org.wso2.carbon.identity.role.v2.mgt.core.RoleConstants.Error.ROLE_NOT_FOUND;

/**
Expand Down Expand Up @@ -277,6 +278,8 @@ public void deleteRole(String roleID) throws CharonException, NotFoundException,
throw new NotFoundException(e.getMessage());
} else if (StringUtils.equals(OPERATION_FORBIDDEN.getCode(), e.getErrorCode())) {
throw new BadRequestException(e.getMessage());
} else if (INVALID_REQUEST.getCode().equals(e.getErrorCode())) {
throw new BadRequestException(e.getMessage(), ResponseCodeConstants.INVALID_VALUE);
}
throw new CharonException(String.format("Error occurred while deleting the role: %s", roleID), e);
}
Expand Down Expand Up @@ -943,7 +946,8 @@ private void doUpdatePermissions(String roleId, Set<String> addedPermissions, Se
} catch (IdentityRoleManagementException e) {
if (RoleConstants.Error.INVALID_REQUEST.getCode().equals(e.getErrorCode())) {
throw new BadRequestException(e.getMessage());
} else if (RoleConstants.Error.INVALID_PERMISSION.getCode().equals("RMA-" + e.getErrorCode())) {
} else if (RoleConstants.Error.INVALID_PERMISSION.getCode()
.equals(ROLE_MANAGEMENT_ERROR_CODE_PREFIX + e.getErrorCode())) {
throw new BadRequestException(e.getMessage());
}
throw new CharonException(
Expand Down
Loading