diff --git a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java index aaa8e0ddf5ca..61a598515a3d 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java @@ -1092,10 +1092,10 @@ public DevPortalAPISearchResult searchAPIsForDevPortal(Organization org, String if (!PersistenceUtil.isAdminUser(ctx)) { String orgName = ctx.getOrganization().getName(); if (orgName != null && orgName.contains(" ")) { - orgName = "\"" + orgName + "\""; + orgName = orgName.replace(" ", "+"); } - modifiedQuery = modifiedQuery + "&visible_organizations=(" + APIConstants.DEFAULT_VISIBLE_ORG + " OR *" - + orgName + "*)"; + modifiedQuery = modifiedQuery + "&visible_organizations=(" + APIConstants.DEFAULT_VISIBLE_ORG + " OR " + + orgName + ")"; } log.debug("Modified query for devportal search: " + modifiedQuery); String userNameLocal; @@ -3088,6 +3088,9 @@ private void updateRegistryResources(Registry registry, String artifactPath, Str // the roles that were specified can be maintained. apiResource.setProperty(APIConstants.DISPLAY_PUBLISHER_ROLES, publisherAccessControlRoles); apiResource.setProperty(APIConstants.ACCESS_CONTROL, publisherAccessControl); + if (!StringUtils.isEmpty(visibleOrganizations) && visibleOrganizations.contains(" ")) { + visibleOrganizations = visibleOrganizations.replace(" ", "+"); + } apiResource.setProperty(APIConstants.VISIBLE_ORGANIZATIONS, visibleOrganizations); apiResource.removeProperty(APIConstants.CUSTOM_API_INDEXER_PROPERTY); if (additionalProperties != null && additionalProperties.size() != 0) { diff --git a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/utils/RegistryPersistenceUtil.java b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/utils/RegistryPersistenceUtil.java index 68d68151ced6..c5333097b498 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/utils/RegistryPersistenceUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/utils/RegistryPersistenceUtil.java @@ -800,7 +800,11 @@ private static API setResourceProperties(API api, Resource apiResource, String a } } api.setAccessControl(apiResource.getProperty(APIConstants.ACCESS_CONTROL)); - api.setVisibleOrganizations(apiResource.getProperty(APIConstants.VISIBLE_ORGANIZATIONS)); + String visibleOrg = apiResource.getProperty(APIConstants.VISIBLE_ORGANIZATIONS); + if (visibleOrg != null) { + visibleOrg = visibleOrg.replace("+", " "); + } + api.setVisibleOrganizations(visibleOrg); String accessControlRoles = null;