use of org.graylog2.rest.models.system.lookup.CacheApi in project graylog2-server by Graylog2.
the class LookupTableResource method get.
@GET
@Path("tables/{idOrName}")
@ApiOperation(value = "Retrieve the named lookup table")
public LookupTablePage get(@ApiParam(name = "idOrName") @PathParam("idOrName") @NotEmpty String idOrName, @ApiParam(name = "resolve") @QueryParam("resolve") @DefaultValue("false") boolean resolveObjects) {
Optional<LookupTableDto> lookupTableDto = dbTableService.get(idOrName);
if (!lookupTableDto.isPresent()) {
throw new NotFoundException();
}
LookupTableDto tableDto = lookupTableDto.get();
checkPermission(RestPermissions.LOOKUP_TABLES_READ, tableDto.id());
Set<CacheApi> caches = Collections.emptySet();
Set<DataAdapterApi> adapters = Collections.emptySet();
if (resolveObjects) {
caches = dbCacheService.findByIds(Collections.singleton(tableDto.cacheId())).stream().map(CacheApi::fromDto).collect(Collectors.toSet());
adapters = dbDataAdapterService.findByIds(Collections.singleton(tableDto.dataAdapterId())).stream().map(DataAdapterApi::fromDto).collect(Collectors.toSet());
}
final PaginatedList<LookupTableApi> result = PaginatedList.singleton(LookupTableApi.fromDto(tableDto), 1, 1);
return new LookupTablePage(null, result.pagination(), result, caches, adapters);
}
Aggregations