Source:
public final Response getEventBookingForGivenGroup(@Context final HttpServletRequest request, @PathParam("event_id") final String eventId, @PathParam("group_id") final String groupId) { try { RegisteredUserDTO currentUser = userManager.getCurrentRegisteredUser(request); if (!Arrays.asList(Role.TEACHER, Role.EVENT_LEADER, Role.EVENT_MANAGER, Role.ADMIN).contains(currentUser.getRole())) { return SegueErrorResponse.getIncorrectRoleResponse(); } UserGroupDTO group = groupManager.getGroupById(Long.parseLong(groupId)); List<Long> groupMemberIds = groupManager.getUsersInGroup(group) .stream().map(RegisteredUserDTO::getId) .collect(Collectors.toList()); List<EventBookingDTO> eventBookings = bookingManager.getBookingByEventId(eventId) .stream().filter(booking -> groupMemberIds.contains(booking.getUserBooked().getId())) .collect(Collectors.toList()); if (Role.EVENT_LEADER.equals(currentUser.getRole())) { eventBookings = userAssociationManager.filterUnassociatedRecords( currentUser, eventBookings, booking -> booking.getUserBooked().getId()); } return Response.ok(eventBookings).build(); } catch (Exception e) { return new SegueErrorResponse(Status.INTERNAL_SERVER_ERROR, e.getMessage()).toResponse(); } }

Target:
public final Response getEventBookingForGivenGroup(@Context final HttpServletRequest request, @PathParam("event_id") final String eventId, @PathParam("group_id") final String groupId) { try { RegisteredUserDTO currentUser = userManager.getCurrentRegisteredUser(request); UserGroupDTO group = groupManager.getGroupById(Long.parseLong(groupId)); if (!(isUserAnAdmin(userManager, currentUser) || GroupManager.isOwnerOrAdditionalManager(group, currentUser.getId()))) { return new SegueErrorResponse(Status.FORBIDDEN, "You are not the owner or manager of this group.").toResponse(); } IsaacEventPageDTO eventPageDTO = getRawEventDTOById(eventId); if (null == eventPageDTO) { return new SegueErrorResponse(Status.BAD_REQUEST, "No event found with this ID.").toResponse(); } if (!EventBookingManager.eventAllowsGroupBookings(eventPageDTO)) { return new SegueErrorResponse(Status.FORBIDDEN, "This event does not accept group bookings.").toResponse(); } List<Long> groupMemberIds = groupManager.getUsersInGroup(group) .stream().map(RegisteredUserDTO::getId) .collect(Collectors.toList()); List<EventBookingDTO> eventBookings = bookingManager.getBookingsByEventId(eventId) .stream().filter(booking -> groupMemberIds.contains(booking.getUserBooked().getId())) .collect(Collectors.toList()); eventBookings = userAssociationManager.filterUnassociatedRecords(currentUser, eventBookings, booking -> booking.getUserBooked().getId()); return Response.ok(eventBookings).build(); } catch (SegueDatabaseException e) { String errorMsg = String.format( "Database error occurred while trying retrieve bookings for group (%s) on event (%s).", groupId, eventId); log.error(errorMsg, e); return new SegueErrorResponse(Status.INTERNAL_SERVER_ERROR, errorMsg).toResponse(); } catch (NoUserLoggedInException e) { return SegueErrorResponse.getNotLoggedInResponse(); } catch (ContentManagerException e) { return new SegueErrorResponse(Status.INTERNAL_SERVER_ERROR, "Content Database error occurred while trying to retrieve event information.") .toResponse(); } }