parameter to obtain a single subcommunity

This commit is contained in:
Michele Artini 2024-10-18 14:58:06 +02:00
parent 6c6253115a
commit bc8acad413
1 changed files with 4 additions and 2 deletions

View File

@ -59,12 +59,14 @@ public class SubCommunityApiController extends AbstractExporterController {
@ApiResponse(responseCode = "404", description = "not found"), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error") @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public List<SubCommunity> getSubCommunities(@PathVariable final String id, @RequestParam(required = false, defaultValue = "false") final boolean all) public List<SubCommunity> getSubCommunities(@PathVariable final String id,
@RequestParam(required = false) final String subCommunityId,
@RequestParam(required = false, defaultValue = "false") final boolean all)
throws CommunityException { throws CommunityException {
try { try {
return communityService.getSubCommunitiesForCommunity(id) return communityService.getSubCommunitiesForCommunity(id)
.stream() .stream()
.filter(sc -> all || sc.isBrowsable()) .filter(sc -> subCommunityId != null ? subCommunityId.equals(sc.getSubCommunityId()) : all || sc.isBrowsable())
.collect(Collectors.toList()); .collect(Collectors.toList());
} catch (final ResourceNotFoundException e) { } catch (final ResourceNotFoundException e) {
throw e; throw e;