Skip to content

Commit

Permalink
Add dev portal org visibility to seperate section
Browse files Browse the repository at this point in the history
  • Loading branch information
chamilaadhi committed Sep 18, 2024
1 parent e28bc64 commit e1f97f1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ public static AudienceEnum fromValue(String v) {
public enum VisibilityEnum {
PUBLIC("PUBLIC"),
PRIVATE("PRIVATE"),
RESTRICTED("RESTRICTED"),
RESTRICTED_BY_ORG("RESTRICTED_BY_ORG");
RESTRICTED("RESTRICTED");
private String value;

VisibilityEnum (String v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,11 @@ public static API fromDTOtoAPI(APIDTO dto, String provider) throws APIManagement
}
}

if (dto.getVisibleOrganizations() != null) {
if (dto.getVisibleOrganizations() != null && !dto.getVisibleOrganizations().isEmpty()) {
String visibleOrgs = StringUtils.join(dto.getVisibleOrganizations(), ',');
model.setVisibleOrganizations(visibleOrgs);
// check if need to have a config
// if (APIUtil.isCrossTenantSubscriptionsEnabled()) {
//
// }
} else {
model.setVisibleOrganizations(APIConstants.DEFAULT_VISIBLE_ORG);
}

List<String> accessControlRoles = dto.getAccessControlRoles();
Expand Down Expand Up @@ -943,8 +941,6 @@ private static String mapVisibilityFromDTOtoAPI(APIDTO.VisibilityEnum visibility
return APIConstants.API_PRIVATE_VISIBILITY;
case RESTRICTED:
return APIConstants.API_RESTRICTED_VISIBILITY;
case RESTRICTED_BY_ORG:
return APIConstants.API_RESTRICTED_BY_ORG;
// case CONTROLLED: todo add to swagger
// return APIConstants.API_CONTROLLED_VISIBILITY;
default:
Expand Down Expand Up @@ -1300,8 +1296,11 @@ public static APIDTO fromAPItoDTO(API model, boolean preserveCredentials,
dto.setVisibleRoles(Arrays.asList(model.getVisibleTenants().split(",")));
}

if (model.getVisibleOrganizations() != null) {
if (model.getVisibleOrganizations() != null
|| !APIConstants.DEFAULT_VISIBLE_ORG.equals(model.getVisibleOrganizations())) {
dto.setVisibleOrganizations(Arrays.asList(model.getVisibleOrganizations().split(",")));
} else {
dto.setVisibleOrganizations(Collections.EMPTY_LIST);
}

if (model.getAdditionalProperties() != null) {
Expand Down Expand Up @@ -1523,8 +1522,6 @@ private static APIDTO.VisibilityEnum mapVisibilityFromAPItoDTO(String visibility
return APIDTO.VisibilityEnum.PRIVATE;
case APIConstants.API_RESTRICTED_VISIBILITY:
return APIDTO.VisibilityEnum.RESTRICTED;
case APIConstants.API_RESTRICTED_BY_ORG:
return APIDTO.VisibilityEnum.RESTRICTED_BY_ORG;
// case APIConstants.API_CONTROLLED_VISIBILITY : todo add this to swagger
// return APIDTO.VisibilityEnum.CONTROLLED;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ private static API prepareForUpdateApi(API originalAPI, APIDTO apiDtoToUpdate, A
apiToUpdate.setVisibleRoles(StringUtils.EMPTY);
}
apiToUpdate.setUUID(originalAPI.getUUID());
apiToUpdate.setOrganization(originalAPI.getOrganization());
validateScopes(apiToUpdate);
apiToUpdate.setThumbnailUrl(originalAPI.getThumbnailUrl());
if (apiDtoToUpdate.getKeyManagers() instanceof List) {
Expand Down Expand Up @@ -1267,13 +1266,6 @@ public static API prepareToCreateAPIByDTO(APIDTO body, APIProvider apiProvider,
}
}

if (body.getVisibility() == APIDTO.VisibilityEnum.RESTRICTED_BY_ORG
&& body.getVisibleOrganizations().isEmpty()) {
throw new APIManagementException(
"Valid organizations should be added under 'visibleOrganizations' to restrict " + "the visibility",
ExceptionCodes.ORGS_CANNOT_BE_NULL);
}


//Get all existing versions of api been adding
List<String> apiVersions = apiProvider.getApiVersionsMatchingApiNameAndOrganization(body.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9766,7 +9766,6 @@ components:
- PUBLIC
- PRIVATE
- RESTRICTED
- RESTRICTED_BY_ORG
x-otherScopes:
- apim:api_publish
- apim:api_manage
Expand Down Expand Up @@ -12609,6 +12608,11 @@ components:
IsJWTEnabledForLoginTokens:
type: boolean
default: false
orgAccessControlEnabled:
type: boolean
description: |
Is Organization-based access control configuration enabled
example: true
customProperties:
type: array
items:
Expand Down

0 comments on commit e1f97f1

Please sign in to comment.