diff --git a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMRoleManagerV2.java b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMRoleManagerV2.java index 38a052b9d..889359100 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMRoleManagerV2.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMRoleManagerV2.java @@ -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; /** @@ -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); } @@ -943,7 +946,8 @@ private void doUpdatePermissions(String roleId, Set 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(