use of io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto in project apiman by apiman.
the class DeveloperPortalResourceImpl method getApiVersion.
@Override
public ApiVersionBeanDto getApiVersion(String orgId, String apiId, String apiVersion) {
securityContext.checkPermissionsOrDiscoverability(EntityType.API, orgId, apiId, apiVersion, Set.of(PermissionType.apiView));
ApiVersionBeanDto v = apiService.getApiVersion(orgId, apiId, apiVersion);
// TODO(msavy): probably a nicer way of doing this.
Set<ApiPlanBeanDto> filteredPlans = v.getPlans().stream().filter(ap -> securityContext.hasPermission(PermissionType.planView, orgId) || permittedDiscoverability(ap.getDiscoverability())).collect(Collectors.toSet());
v.setPlans(filteredPlans);
// TODO(msavy): make new projection for this.
return RestHelper.hideSensitiveDataFromApiVersionBean(v);
}
use of io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto in project apiman by apiman.
the class DeveloperResourceImpl method getAllApiVersions.
@Override
public List<DeveloperApiVersionBeanDto> getAllApiVersions(String id) throws DeveloperNotFoundException, NotAuthorizedException {
securityContext.checkIfUserIsCurrentUser(id);
List<ApiVersionBeanDto> apiVersionBeans = new ArrayList<>();
List<ContractSummaryBean> contracts = getAllClientContracts(id);
for (ContractSummaryBean contract : contracts) {
ApiVersionBeanDto apiVersion = apiService.getApiVersion(contract.getApiOrganizationId(), contract.getApiId(), contract.getApiVersion());
if (securityContext.isAdmin()) {
apiVersionBeans.add(apiVersion);
} else {
apiVersionBeans.add(RestHelper.hideSensitiveDataFromApiVersionBean(apiVersion));
}
}
return apiVersionBeans.stream().map(DeveloperMapper.INSTANCE::toDto).collect(Collectors.toList());
}
use of io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto in project apiman by apiman.
the class OrganizationResourceImpl method getApiVersion.
@Override
public ApiVersionBeanDto getApiVersion(String organizationId, String apiId, String version) throws ApiVersionNotFoundException {
securityContext.checkPermissionsOrDiscoverability(API, organizationId, apiId, version, Set.of(PermissionType.apiView));
if (securityContext.hasPermission(PermissionType.apiView, organizationId)) {
return apiService.getApiVersion(organizationId, apiId, version);
} else {
ApiVersionBeanDto av = apiService.getApiVersion(organizationId, apiId, version);
Set<ApiPlanBeanDto> filteredPlans = av.getPlans().stream().filter(avp -> securityContext.getPermittedDiscoverabilities().contains(avp.getDiscoverability())).collect(Collectors.toSet());
av.setPlans(filteredPlans);
return av;
}
}
use of io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto in project apiman by apiman.
the class RestHelper method hideSensitiveDataFromApiVersionBean.
/**
* This method will hide sensitive data, such as created by, from the result
*
* @param apiVersionBean the apiVersionBean
* @return the apiVersionBean without sensitive data
*/
public static ApiVersionBeanDto hideSensitiveDataFromApiVersionBean(ApiVersionBeanDto apiVersionBean) {
ApiBeanDto api = new ApiBeanDto();
api.setId(apiVersionBean.getApi().getId());
api.setName(apiVersionBean.getApi().getName());
api.setDescription(apiVersionBean.getApi().getDescription());
api.setImage(apiVersionBean.getApi().getImage());
OrganizationBean org = new OrganizationBean();
org.setId(apiVersionBean.getApi().getOrganization().getId());
org.setName(apiVersionBean.getApi().getOrganization().getName());
org.setDescription(apiVersionBean.getApi().getOrganization().getDescription());
api.setOrganization(org);
ApiVersionBeanDto apiVersion = new ApiVersionBeanDto();
apiVersion.setApi(api);
apiVersion.setStatus(apiVersionBean.getStatus());
apiVersion.setEndpointType(apiVersionBean.getEndpointType());
apiVersion.setEndpointContentType(apiVersionBean.getEndpointContentType());
apiVersion.setGateways(apiVersionBean.getGateways());
apiVersion.setPublicAPI(apiVersionBean.isPublicAPI());
apiVersion.setPlans(apiVersionBean.getPlans());
apiVersion.setVersion(apiVersionBean.getVersion());
apiVersion.setDefinitionType(apiVersionBean.getDefinitionType());
apiVersion.setPublicDiscoverability(apiVersionBean.getPublicDiscoverability());
apiVersion.setExtendedDescription(apiVersionBean.getExtendedDescription());
// dates
apiVersion.setCreatedOn(apiVersionBean.getCreatedOn());
apiVersion.setModifiedOn(apiVersionBean.getModifiedOn());
apiVersion.setPublishedOn(apiVersionBean.getPublishedOn());
apiVersion.setRetiredOn(apiVersionBean.getRetiredOn());
return apiVersion;
}
Aggregations