diff --git a/components/org.wso2.carbon.identity.organization.management.role.management.service/src/main/java/org/wso2/carbon/identity/organization/management/role/management/service/RoleManagerImpl.java b/components/org.wso2.carbon.identity.organization.management.role.management.service/src/main/java/org/wso2/carbon/identity/organization/management/role/management/service/RoleManagerImpl.java index 3ab89cd40..9c662678a 100644 --- a/components/org.wso2.carbon.identity.organization.management.role.management.service/src/main/java/org/wso2/carbon/identity/organization/management/role/management/service/RoleManagerImpl.java +++ b/components/org.wso2.carbon.identity.organization.management.role.management.service/src/main/java/org/wso2/carbon/identity/organization/management/role/management/service/RoleManagerImpl.java @@ -59,12 +59,12 @@ import static org.wso2.carbon.identity.organization.management.role.management.service.constant.RoleManagementConstants.USERS; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_GETTING_GROUP_VALIDITY; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_INVALID_ATTRIBUTE_PATCHING; -import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_INVALID_FILTER_FORMAT; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_INVALID_GROUP_ID; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_INVALID_ORGANIZATION; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_INVALID_ROLE; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_INVALID_USER_ID; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_REMOVING_REQUIRED_ATTRIBUTE; +import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_RETRIEVING_ORG_ROLES_INVALID_FILTER_FORMAT; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_ROLE_DISPLAY_NAME_ALREADY_EXISTS; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_ROLE_DISPLAY_NAME_MULTIPLE_VALUES; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_ROLE_DISPLAY_NAME_NULL; @@ -289,7 +289,7 @@ private void getExpressionNodes(String filter, List expressionNo Utils.setExpressionNodeAndOperatorLists(rootNode, expressionNodes, operators, true); } } catch (IOException | IdentityException e) { - throw handleClientException(ERROR_CODE_INVALID_FILTER_FORMAT); + throw handleClientException(ERROR_CODE_RETRIEVING_ORG_ROLES_INVALID_FILTER_FORMAT, filter); } } diff --git a/components/org.wso2.carbon.identity.organization.management.role.management.service/src/main/java/org/wso2/carbon/identity/organization/management/role/management/service/dao/RoleManagementDAOImpl.java b/components/org.wso2.carbon.identity.organization.management.role.management.service/src/main/java/org/wso2/carbon/identity/organization/management/role/management/service/dao/RoleManagementDAOImpl.java index 3ab8abde0..f4e49f62f 100644 --- a/components/org.wso2.carbon.identity.organization.management.role.management.service/src/main/java/org/wso2/carbon/identity/organization/management/role/management/service/dao/RoleManagementDAOImpl.java +++ b/components/org.wso2.carbon.identity.organization.management.role.management.service/src/main/java/org/wso2/carbon/identity/organization/management/role/management/service/dao/RoleManagementDAOImpl.java @@ -164,7 +164,7 @@ import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_GETTING_ROLE_FROM_ORGANIZATION_ID_ROLE_NAME; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_GETTING_USERS_USING_ROLE_ID; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_INVALID_ATTRIBUTE; -import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_INVALID_FILTER_FORMAT; +import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_ORG_ROLE_PATCH_REMOVE_OPERATION_INVALID_FILTER_FORMAT; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_PATCHING_ROLE; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_REMOVING_GROUPS_FROM_ROLE; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_REMOVING_PERMISSIONS_FROM_ROLE; @@ -713,22 +713,25 @@ private void patchOperationReplace(String roleId, String path, List valu private void patchOperationRemove(String roleId, String path) throws OrganizationManagementException { String patchPath = path; + String pathFilterExpression = StringUtils.EMPTY; if (patchPath.contains("[")) { - patchPath = patchPath.split("\\[")[0]; + if (StringUtils.strip(patchPath).endsWith("]")) { + patchPath = StringUtils.strip(patchPath.split("\\[")[0]); + //get the filter expression associated with the path. + pathFilterExpression = StringUtils.strip(path.split("\\[")[1].replace("]", "")).toLowerCase(); + } else { + throw handleClientException(ERROR_CODE_ORG_ROLE_PATCH_REMOVE_OPERATION_INVALID_FILTER_FORMAT, + StringUtils.strip(path.substring(path.indexOf("[") + 1)), roleId); + } } - patchPath = StringUtils.strip(patchPath); - - //get the values associated with the path. - String pathValues = StringUtils.strip(path.split("\\[")[1].replace("]", "")) - .toLowerCase(); - if (StringUtils.isNotBlank(pathValues)) { + if (StringUtils.isNotBlank(pathFilterExpression)) { if (StringUtils.equalsIgnoreCase(patchPath, GROUPS)) { - patchRemoveOpWithFilters(roleId, pathValues, GROUPS); + patchRemoveOpWithFilters(roleId, pathFilterExpression, GROUPS); } else if (StringUtils.equalsIgnoreCase(patchPath, USERS)) { - patchRemoveOpWithFilters(roleId, pathValues, USERS); + patchRemoveOpWithFilters(roleId, pathFilterExpression, USERS); } else if (StringUtils.equalsIgnoreCase(patchPath, PERMISSIONS)) { - patchRemoveOpWithFilters(roleId, pathValues, PERMISSIONS); + patchRemoveOpWithFilters(roleId, pathFilterExpression, PERMISSIONS); } } else { if (StringUtils.equalsIgnoreCase(patchPath, USERS)) { @@ -886,12 +889,12 @@ private void appendFilterQuery(List expressionNodes, List expressionNodes = new ArrayList<>(); List operators = new ArrayList<>(); try { - FilterTreeBuilder filterTreeBuilder = new FilterTreeBuilder(values); + FilterTreeBuilder filterTreeBuilder = new FilterTreeBuilder(filter); Node rootNode = filterTreeBuilder.buildTree(); Utils.setExpressionNodeAndOperatorLists(rootNode, expressionNodes, operators, false); FilterQueryBuilder filterQueryBuilder = new FilterQueryBuilder(); @@ -949,7 +952,8 @@ private void patchRemoveOpWithFilters(String roleId, String values, String path) } } } catch (IOException | IdentityException e) { - throw handleClientException(ERROR_CODE_INVALID_FILTER_FORMAT); + throw handleClientException(ERROR_CODE_ORG_ROLE_PATCH_REMOVE_OPERATION_INVALID_FILTER_FORMAT, filter, + roleId); } } diff --git a/pom.xml b/pom.xml index 10b7e5c2d..ab5f18835 100644 --- a/pom.xml +++ b/pom.xml @@ -398,7 +398,7 @@ [1.0.0,2.0.0) - 1.0.17 + 1.0.28 [1.0.0,2.0.0)