use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.ThrottlingPolicyPermissionInfoDTO in project carbon-apimgt by wso2.
the class ThrottlingPolicyMappingUtil method setTierPermissions.
/**
* Fills the tier information on TierDTO
*
* @param throttlingPolicyDTO Object Containing throttling policy DTOs
* @param throttlingPolicy Throttling Policy object
* @return ThrottlingPolicyDTO with permission info
*/
public static ThrottlingPolicyDTO setTierPermissions(ThrottlingPolicyDTO throttlingPolicyDTO, Tier throttlingPolicy) {
ThrottlingPolicyPermissionInfoDTO tierPermission = new ThrottlingPolicyPermissionInfoDTO();
// If no permission found for the tier, the default permission will be applied
if (throttlingPolicy.getTierPermission() == null || throttlingPolicy.getTierPermission().getPermissionType() == null) {
tierPermission.setType(ThrottlingPolicyPermissionInfoDTO.TypeEnum.valueOf("ALLOW"));
List<String> roles = new ArrayList<>();
roles.add("Internal/everyone");
tierPermission.setRoles(roles);
} else {
String permissionType = throttlingPolicy.getTierPermission().getPermissionType();
tierPermission.setType(ThrottlingPolicyPermissionInfoDTO.TypeEnum.valueOf(permissionType.toUpperCase()));
tierPermission.setRoles(Arrays.asList(throttlingPolicy.getTierPermission().getRoles()));
}
throttlingPolicyDTO.setThrottlingPolicyPermissions(tierPermission);
return throttlingPolicyDTO;
}
Aggregations