use of io.apiman.manager.api.rest.exceptions.InvalidPlanStatusException in project apiman by apiman.
the class OrganizationResourceImpl method deletePlan.
@Override
public void deletePlan(@PathParam("organizationId") String organizationId, @PathParam("planId") String planId) throws ApiNotFoundException, NotAuthorizedException, InvalidPlanStatusException {
securityContext.checkPermissions(PermissionType.planAdmin, organizationId);
List<PlanVersionSummaryBean> lockedPlans = listPlanVersions(organizationId, planId).stream().filter(summary -> summary.getStatus() == PlanStatus.Locked).collect(toList());
if (!lockedPlans.isEmpty())
throw ExceptionFactory.invalidPlanStatusException(lockedPlans);
try {
storage.beginTx();
PlanBean plan = storage.getPlan(organizationId, planId);
storage.deletePlan(plan);
storage.commitTx();
} catch (AbstractRestException e) {
storage.rollbackTx();
throw e;
} catch (Exception e) {
storage.rollbackTx();
throw new SystemErrorException(e);
}
}
use of io.apiman.manager.api.rest.exceptions.InvalidPlanStatusException in project apiman by apiman.
the class PlanService method deletePlan.
public void deletePlan(String organizationId, String planId) throws ApiNotFoundException, NotAuthorizedException, InvalidPlanStatusException {
List<PlanVersionSummaryBean> lockedPlans = listPlanVersions(organizationId, planId).stream().filter(summary -> summary.getStatus() == PlanStatus.Locked).collect(toList());
if (!lockedPlans.isEmpty())
throw ExceptionFactory.invalidPlanStatusException(lockedPlans);
tryAction(() -> {
PlanBean plan = storage.getPlan(organizationId, planId);
storage.deletePlan(plan);
});
}
Aggregations