use of com.yahoo.elide.jsonapi.models.Data in project faf-java-api by FAForever.
the class FeaturedModsController method getFiles.
@Async
@RequestMapping(path = "/{modId}/files/{version}")
@ApiOperation("Lists the required files for a specific featured mod version")
public CompletableFuture<JsonApiDocument> getFiles(@PathVariable("modId") int modId, @PathVariable("version") String version, @RequestParam(value = "page[number]", required = false) Integer page) {
Integer innerPage = Optional.ofNullable(page).orElse(0);
if (innerPage > 1) {
return CompletableFuture.completedFuture(new JsonApiDocument(new Data<>(Collections.emptyList())));
}
ImmutableMap<Integer, FeaturedMod> mods = Maps.uniqueIndex(featuredModService.getFeaturedMods(), FeaturedMod::getId);
FeaturedMod featuredMod = mods.get(modId);
Integer innerVersion = "latest".equals(version) ? null : Integer.valueOf(version);
List<Resource> values = featuredModService.getFiles(featuredMod.getTechnicalName(), innerVersion).stream().map(modFileMapper()).collect(Collectors.toList());
return CompletableFuture.completedFuture(new JsonApiDocument(new Data<>(values)));
}
Aggregations