<commit_before>package fr.alecharp.picshare.resource;

import fr.alecharp.picshare.domain.Event;
import fr.alecharp.picshare.service.EventService;
import net.codestory.http.annotations.Get;
import net.codestory.http.templating.Model;
import net.codestory.http.templating.ModelAndView;

import javax.inject.Inject;
import java.util.Optional;

/**
 * @author <NAME>
 */
public class EventResource {
    private final EventService eventService;

    @Inject
    public EventResource(EventService eventService) {
        this.eventService = eventService;
    }

    @Get("/event/:id")
    public ModelAndView dashboard(String id) {
        Optional<Event> event = eventService.get(id);
        return event.isPresent() ?
                ModelAndView.of("event/display.html", "event", event.get()) :
                ModelAndView.of("404.html");
    }
}<commit_msg>Create HTTP API to download the file<commit_after>package fr.alecharp.picshare.resource;

import fr.alecharp.picshare.domain.Event;
import fr.alecharp.picshare.service.EventService;
import fr.alecharp.picshare.service.PictureService;
import net.codestory.http.Response;
import net.codestory.http.annotations.Get;
import net.codestory.http.annotations.Prefix;
import net.codestory.http.templating.Model;
import net.codestory.http.templating.ModelAndView;

import javax.inject.Inject;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Optional;

/**
 * @author <NAME>
 */
@Prefix("/event")
public class EventResource {
    private final EventService eventService;
    private final PictureService pictureService;

    @Inject
    public EventResource(EventService eventService, PictureService pictureService) {
        this.eventService = eventService;
        this.pictureService = pictureService;
    }

    @Get("/:id")
    public ModelAndView dashboard(String id) {
        Optional<Event> event = eventService.get(id);
        return event.isPresent() ?
                ModelAndView.of("event/display.html", "event", event.get()) :
                ModelAndView.of("404.html");
    }

    @Get("/:id/:picture")
    public void download(String id, String picture, Response resp) throws IOException {
        resp.setHeader("Content-Type", "application/octet-stream");
        Files.copy(pictureService.getPicture(id, picture), resp.outputStream());
    }
}
{'fraction_non_alphanumeric': 0.11799914493373237, 'fraction_numerical': 0.0025651988029072254, 'mean_word_length': 3.7950819672131146, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2768033', 'n_tokens_mistral': 698, 'n_tokens_neox': 699, 'n_words': 131}