use of org.opengrok.web.api.v1.filter.CorsEnable in project OpenGrok by OpenGrok.
the class FileController method getContentPlain.
@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);
}
Aggregations