Skip to content

Commit

Permalink
Fix orgs with space
Browse files Browse the repository at this point in the history
  • Loading branch information
chamilaadhi committed Oct 11, 2024
1 parent 6a6d5ce commit 9081ab9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 9081ab9

Please sign in to comment.