use of jakarta.ws.rs.GET in project OpenGrok by OpenGrok.
the class FileController method getGenre.
@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();
}
use of jakarta.ws.rs.GET 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);
}
use of jakarta.ws.rs.GET in project OpenGrok by OpenGrok.
the class SystemController method getIndexTime.
@GET
@Path("/indextime")
@Produces(MediaType.APPLICATION_JSON)
public String getIndexTime() throws JsonProcessingException {
Date date = new IndexTimestamp().getDateForLastIndexRun();
ObjectMapper mapper = new ObjectMapper();
// StdDateFormat is ISO8601 since jackson 2.9
mapper.setDateFormat(new StdDateFormat().withColonInTimeZone(true));
return mapper.writeValueAsString(date);
}
Aggregations