feat(manager-api-rest): add various policy methods to devportal endpoint
Required for the devportal UI
MODIFY
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/DeveloperPortalResourceImpl.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/DeveloperPortalResourceImpl.java
@@ -7,15 +7,19 @@ import io.apiman.manager.api.beans.developers.ApiVersionPolicySummaryDto;
import io.apiman.manager.api.beans.developers.DeveloperApiPlanSummaryDto;
import io.apiman.manager.api.beans.orgs.NewOrganizationBean;
import io.apiman.manager.api.beans.orgs.OrganizationBean;
+import io.apiman.manager.api.beans.policies.PolicyBean;
import io.apiman.manager.api.beans.search.SearchCriteriaBean;
import io.apiman.manager.api.beans.search.SearchResultsBean;
import io.apiman.manager.api.beans.summary.ApiSummaryBean;
import io.apiman.manager.api.beans.summary.ApiVersionSummaryBean;
+import io.apiman.manager.api.beans.summary.PolicySummaryBean;
import io.apiman.manager.api.rest.IDeveloperPortalResource;
import io.apiman.manager.api.rest.exceptions.ApiVersionNotFoundException;
import io.apiman.manager.api.rest.exceptions.InvalidSearchCriteriaException;
import io.apiman.manager.api.rest.exceptions.NotAuthorizedException;
import io.apiman.manager.api.rest.exceptions.OrganizationNotFoundException;
+import io.apiman.manager.api.rest.exceptions.PlanVersionNotFoundException;
+import io.apiman.manager.api.rest.exceptions.PolicyNotFoundException;
import io.apiman.manager.api.rest.exceptions.util.ExceptionFactory;
import io.apiman.manager.api.rest.impl.util.RestHelper;
import io.apiman.manager.api.security.ISecurityContext;
@@ -23,6 +27,7 @@ import io.apiman.manager.api.service.ApiService;
import io.apiman.manager.api.service.ApiService.ApiDefinitionStream;
import io.apiman.manager.api.service.DevPortalService;
import io.apiman.manager.api.service.OrganizationService;
+import io.apiman.manager.api.service.PlanService;
import java.util.List;
import java.util.stream.Collectors;
@@ -38,16 +43,18 @@ public class DeveloperPortalResourceImpl implements IDeveloperPortalResource {
private final IApimanLogger LOG = ApimanLoggerFactory.getLogger(DeveloperPortalResourceImpl.class);
private ApiService apiService;
+ private PlanService planService;
private DevPortalService portalService;
private OrganizationService orgService;
private ISecurityContext securityContext;
@Inject
public DeveloperPortalResourceImpl(ApiService apiService,
- DevPortalService portalService,
+ PlanService planService, DevPortalService portalService,
OrganizationService orgService,
ISecurityContext securityContext) {
this.apiService = apiService;
+ this.planService = planService;
this.portalService = portalService;
this.orgService = orgService;
this.securityContext = securityContext;
@@ -111,6 +118,18 @@ public class DeveloperPortalResourceImpl implements IDeveloperPortalResource {
.build();
}
+ @Override
+ public List<PolicySummaryBean> listPlanPolicies(String orgId, String planId, String version)
+ throws OrganizationNotFoundException, PlanVersionNotFoundException, NotAuthorizedException {
+ return planService.listPlanPolicies(orgId, planId, version);
+ }
+
+ @Override
+ public PolicyBean getPlanPolicy(String orgId, String planId, String version, long policyId)
+ throws OrganizationNotFoundException, PlanVersionNotFoundException, PolicyNotFoundException, NotAuthorizedException {
+ return planService.getPlanPolicy(orgId, planId, version, policyId);
+ }
+
private ApiVersionBean apiVersionMustBeExposedInPortal(String orgId, String apiId, String apiVersion) {
ApiVersionBean retrieved = apiService.getApiVersion(orgId, apiId, apiVersion);
if (!retrieved.isExposeInPortal()) {

MODIFY
manager/api/rest-impl/src/main/java/io/apiman/manager/api/service/DevPortalService.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/service/DevPortalService.java
@@ -8,6 +8,7 @@ import io.apiman.manager.api.beans.search.SearchCriteriaBean;
import io.apiman.manager.api.beans.search.SearchResultsBean;
import io.apiman.manager.api.beans.summary.ApiPlanSummaryBean;
import io.apiman.manager.api.beans.summary.ApiSummaryBean;
+import io.apiman.manager.api.beans.summary.PolicySummaryBean;
import io.apiman.manager.api.beans.summary.mappers.ApiMapper;
import io.apiman.manager.api.core.IStorage;
import io.apiman.manager.api.core.IStorageQuery;
@@ -75,7 +76,6 @@ public class DevPortalService implements DataAccessUtilMixin {
.collect(Collectors.toList());
}
-
// TODO Use mapstruct
private DeveloperApiPlanSummaryDto toDto(String orgId, ApiPlanSummaryBean apiPsb) {
List<PolicyBean> planPolicies = tryAction(() -> Lists.newArrayList(storage.getAllPolicies(orgId, apiPsb.getPlanId(), apiPsb.getVersion(), PolicyType.Plan)));
@@ -101,5 +101,4 @@ public class DevPortalService implements DataAccessUtilMixin {
summary.setCreatedOn(psb.getCreatedOn());
return summary;
}
-
}

MODIFY
manager/api/rest/src/main/java/io/apiman/manager/api/rest/IDeveloperPortalResource.java
manager/api/rest/src/main/java/io/apiman/manager/api/rest/IDeveloperPortalResource.java
package io.apiman.manager.api.rest;
import io.apiman.manager.api.beans.apis.ApiVersionBean;
-import io.apiman.manager.api.beans.developers.DeveloperApiPlanSummaryDto;
import io.apiman.manager.api.beans.developers.ApiVersionPolicySummaryDto;
+import io.apiman.manager.api.beans.developers.DeveloperApiPlanSummaryDto;
import io.apiman.manager.api.beans.orgs.NewOrganizationBean;
import io.apiman.manager.api.beans.orgs.OrganizationBean;
+import io.apiman.manager.api.beans.policies.PolicyBean;
import io.apiman.manager.api.beans.search.SearchCriteriaBean;
import io.apiman.manager.api.beans.search.SearchResultsBean;
import io.apiman.manager.api.beans.summary.ApiSummaryBean;
import io.apiman.manager.api.beans.summary.ApiVersionSummaryBean;
+import io.apiman.manager.api.beans.summary.PolicySummaryBean;
import io.apiman.manager.api.rest.exceptions.ApiVersionNotFoundException;
import io.apiman.manager.api.rest.exceptions.InvalidSearchCriteriaException;
import io.apiman.manager.api.rest.exceptions.NotAuthorizedException;
import io.apiman.manager.api.rest.exceptions.OrganizationAlreadyExistsException;
import io.apiman.manager.api.rest.exceptions.OrganizationNotFoundException;
+import io.apiman.manager.api.rest.exceptions.PlanVersionNotFoundException;
+import io.apiman.manager.api.rest.exceptions.PolicyNotFoundException;
import java.util.List;
import javax.ws.rs.Consumes;
@@ -84,4 +88,18 @@ public interface IDeveloperPortalResource {
@Produces({ MediaType.APPLICATION_JSON, "application/wsdl+xml", "application/x-yaml" })
Response getApiDefinition(@PathParam("orgId") String orgId, @PathParam("apiId") String apiId, @PathParam("apiVersion") String apiVersion)
throws ApiVersionNotFoundException;
+
+ @GET
+ @Path("organizations/{orgId}/plans/{planId}/versions/{version}/policies")
+ @Produces(MediaType.APPLICATION_JSON)
+ public List<PolicySummaryBean> listPlanPolicies(@PathParam("orgId") String organizationId, @PathParam("planId") String planId, @PathParam("version") String version)
+ throws OrganizationNotFoundException, PlanVersionNotFoundException, NotAuthorizedException;
+
+ @GET
+ @Path("organizations/{orgId}/plans/{planId}/versions/{version}/policies/{policyId}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public PolicyBean getPlanPolicy(@PathParam("orgId") String organizationId, @PathParam("planId") String planId, @PathParam("version") String version,
+ @PathParam("policyId") long policyId)
+ throws OrganizationNotFoundException, PlanVersionNotFoundException, PolicyNotFoundException, NotAuthorizedException;
+
}

feat(manager-api-rest): add various policy methods to devportal endpoint

Required for the devportal UI