use of io.apiman.manager.api.beans.policies.PolicyChainBean in project apiman by apiman.
the class OrganizationResourceImpl method getApiPolicyChain.
/**
* @see IOrganizationResource#getApiPolicyChain(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public PolicyChainBean getApiPolicyChain(String organizationId, String apiId, String version, String planId) throws ApiVersionNotFoundException, PlanNotFoundException {
// No permission check is needed, because this would break All APIs UI
// Try to get the API first - will throw an exception if not found.
ApiVersionBean avb = getApiVersion(organizationId, apiId, version);
try {
String planVersion = null;
Set<ApiPlanBean> plans = avb.getPlans();
if (plans != null) {
for (ApiPlanBean apiPlanBean : plans) {
if (apiPlanBean.getPlanId().equals(planId)) {
planVersion = apiPlanBean.getVersion();
break;
}
}
}
if (planVersion == null) {
throw ExceptionFactory.planNotFoundException(planId);
}
// Hide sensitive data and set only needed data for the UI
List<PolicySummaryBean> apiPolicies = RestHelper.hideSensitiveDataFromPolicySummaryBeanList(securityContext, query.getPolicies(organizationId, apiId, version, PolicyType.Api));
List<PolicySummaryBean> planPolicies = RestHelper.hideSensitiveDataFromPolicySummaryBeanList(securityContext, query.getPolicies(organizationId, planId, planVersion, PolicyType.Plan));
PolicyChainBean chain = new PolicyChainBean();
chain.getPolicies().addAll(planPolicies);
chain.getPolicies().addAll(apiPolicies);
return chain;
} catch (StorageException e) {
throw new SystemErrorException(e);
}
}
use of io.apiman.manager.api.beans.policies.PolicyChainBean in project apiman by apiman.
the class ApiService method getApiPolicyChain.
public PolicyChainBean getApiPolicyChain(String organizationId, String apiId, String version, String planId) throws ApiVersionNotFoundException, PlanNotFoundException {
// Try to get the API first - will throw an exception if not found.
ApiVersionBean avb = getApiVersionFromStorage(organizationId, apiId, version);
return tryAction(() -> {
String planVersion = null;
Set<ApiPlanBean> plans = avb.getPlans();
if (plans != null) {
for (ApiPlanBean apiPlanBean : plans) {
if (apiPlanBean.getPlanId().equals(planId)) {
planVersion = apiPlanBean.getVersion();
break;
}
}
}
if (planVersion == null) {
throw ExceptionFactory.planNotFoundException(planId);
}
// Hide sensitive data and set only needed data for the UI
List<PolicySummaryBean> apiPolicies = RestHelper.hideSensitiveDataFromPolicySummaryBeanList(securityContext, query.getPolicies(organizationId, apiId, version, PolicyType.Api));
List<PolicySummaryBean> planPolicies = RestHelper.hideSensitiveDataFromPolicySummaryBeanList(securityContext, query.getPolicies(organizationId, planId, planVersion, PolicyType.Plan));
PolicyChainBean chain = new PolicyChainBean();
chain.getPolicies().addAll(planPolicies);
chain.getPolicies().addAll(apiPolicies);
return chain;
});
}
Aggregations