class FileController {

    public static final String PATH = "file";



    private StreamingOutput transfer(File file) throws FileNotFoundException {<FILL_FUNCTION_BODY>}

    @GET
    @CorsEnable
    @PathAuthorized
    @Path("/content")
    @Produces(MediaType.TEXT_PLAIN)
    public StreamingOutput getContentPlain(@Context HttpServletRequest request,
                             @Context HttpServletResponse response,
                             @QueryParam("path") final String path) throws IOException, ParseException, NoPathParameterException {

        File file = toFile(path);

        Document doc;
        if ((doc = getDocument(file)) == null) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot get document for file");
            return null;
        }

        String fileType = doc.get(QueryBuilder.T);
        if (!AbstractAnalyzer.Genre.PLAIN.typeName().equals(fileType)) {
            response.sendError(HttpServletResponse.SC_NOT_ACCEPTABLE, "Not a text file");
            return null;
        }

        return transfer(file);
    }

    @GET
    @CorsEnable
    @PathAuthorized
    @Path("/content")
    @Produces(MediaType.APPLICATION_OCTET_STREAM)
    public StreamingOutput getContentOctets(@Context HttpServletRequest request,
                                           @Context HttpServletResponse response,
                                           @QueryParam("path") final String path) throws IOException, NoPathParameterException {

        File file = toFile(path);

        try {
            return transfer(file);
        } catch (FileNotFoundException e) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot find file");
            return null;
        }
    }

    @GET
    @CorsEnable
    @PathAuthorized
    @Path("/genre")
    @Produces(MediaType.TEXT_PLAIN)
    public String getGenre(@Context HttpServletRequest request,
                           @Context HttpServletResponse response,
                           @QueryParam("path") final String path) throws IOException, ParseException, NoPathParameterException {

        File file = toFile(path);

        Document doc;
        if ((doc = getDocument(file)) == null) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot get document for file");
            return null;
        }

        AbstractAnalyzer.Genre genre = AbstractAnalyzer.Genre.get(doc.get(QueryBuilder.T));
        if (genre == null) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot get genre from the document");
            return null;
        }

        return genre.toString();
    }

    @GET
    @CorsEnable
    @PathAuthorized
    @Path("/defs")
    @Produces(MediaType.APPLICATION_JSON)
    public List<Object> getDefinitions(@Context HttpServletRequest request,
                                                @Context HttpServletResponse response,
                                                @QueryParam("path") final String path)
            throws IOException, NoPathParameterException, ParseException, ClassNotFoundException {

        File file = toFile(path);
        Definitions defs = IndexDatabase.getDefinitions(file);
        return Optional.ofNullable(defs).
                map(Definitions::getTags).
                stream().
                flatMap(Collection::stream).
                map(DTOUtil::createDTO).
                collect(Collectors.toList());
    }
}

        if (!file.exists()) {
            throw new FileNotFoundException(String.format("file %s does not exist", file));
        }

        return out -> {
            try (InputStream in = new FileInputStream(file)) {
                byte[] buffer = new byte[1024];
                int len = in.read(buffer);
                while (len != -1) {
                    out.write(buffer, 0, len);
                    len = in.read(buffer);
                }
            }
        };
    
<no_super_class>