use of io.gravitee.rest.api.model.PolicyListItem in project gravitee-management-rest-api by gravitee-io.
the class PoliciesResource method convert.
private PolicyListItem convert(PolicyEntity policy) {
PolicyListItem item = new PolicyListItem();
item.setId(policy.getId());
item.setName(policy.getName());
item.setDescription(policy.getDescription());
item.setVersion(policy.getVersion());
item.setType(policy.getType());
item.setCategory(policy.getCategory());
PolicyDevelopmentEntity development = policy.getDevelopment();
if (development != null) {
item.setOnRequest(development.getOnRequestMethod() != null);
item.setOnResponse(development.getOnResponseMethod() != null);
} else {
item.setOnRequest(false);
item.setOnResponse(false);
}
return item;
}
use of io.gravitee.rest.api.model.PolicyListItem in project gravitee-management-rest-api by gravitee-io.
the class PoliciesResource method getSwaggerPolicy.
@GET
@Path("swagger")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "List policies which are handling Swagger / OAI definition", notes = "These policies are used when importing an OAI to create an API")
@Permissions({ @Permission(value = RolePermission.ENVIRONMENT_API, acls = RolePermissionAction.READ) })
public List<PolicyListItem> getSwaggerPolicy() {
return policyOperationVisitorManager.getPolicyVisitors().stream().filter(operationVisitor -> operationVisitor.display()).map(operationVisitor -> {
PolicyListItem item = new PolicyListItem();
item.setId(operationVisitor.getId());
item.setName(operationVisitor.getName());
return item;
}).sorted(Comparator.comparing(PolicyListItem::getName)).collect(Collectors.toList());
}
Aggregations