use of io.gravitee.rest.api.portal.rest.model.ApiInformation in project gravitee-management-rest-api by gravitee-io.
the class ApiInformationsResource method getApiInformations.
@GET
@Produces({ MediaType.APPLICATION_JSON })
@RequirePortalAuth
public Response getApiInformations(@Context Request request, @PathParam("apiId") String apiId) {
final ApiQuery apiQuery = new ApiQuery();
apiQuery.setIds(Collections.singletonList(apiId));
Collection<ApiEntity> userApis = apiService.findPublishedByUser(getAuthenticatedUserOrNull(), apiQuery);
if (userApis.stream().anyMatch(a -> a.getId().equals(apiId))) {
List<ApiHeaderEntity> all = apiService.getPortalHeaders(apiId);
List<ApiInformation> information = all.stream().map(apiHeaderEntity -> {
ApiInformation ai = new ApiInformation();
ai.setName(apiHeaderEntity.getName());
ai.setValue(apiHeaderEntity.getValue());
return ai;
}).collect(Collectors.toList());
return Response.ok(information).build();
}
throw new ApiNotFoundException(apiId);
}
Aggregations