use of jakarta.ws.rs.Produces in project OpenGrok by OpenGrok.
the class HistoryController method get.
@GET
@CorsEnable
@PathAuthorized
@Produces(MediaType.APPLICATION_JSON)
public HistoryDTO get(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("path") final String path, @QueryParam("withFiles") final boolean withFiles, @QueryParam("max") @DefaultValue(MAX_RESULTS + "") final int maxEntries, @QueryParam("start") @DefaultValue(0 + "") final int startIndex) throws HistoryException, IOException, NoPathParameterException {
File file = toFile(path);
History history = HistoryGuru.getInstance().getHistory(file, withFiles, true);
if (history == null) {
return null;
}
return getHistoryDTO(history.getHistoryEntries(maxEntries, startIndex), history.getTags(), startIndex, maxEntries, history.getHistoryEntries().size());
}
use of jakarta.ws.rs.Produces in project OpenGrok by OpenGrok.
the class AnnotationController method getContent.
@GET
@CorsEnable
@PathAuthorized
@Produces(MediaType.APPLICATION_JSON)
public List<AnnotationDTO> getContent(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("path") final String path, @QueryParam("revision") final String revision) throws IOException, NoPathParameterException {
File file = toFile(path);
Annotation annotation = HistoryGuru.getInstance().annotate(file, revision == null || revision.isEmpty() ? null : revision);
ArrayList<AnnotationDTO> annotationList = new ArrayList<>();
for (int i = 1; i <= annotation.size(); i++) {
annotationList.add(new AnnotationDTO(annotation.getRevision(i), annotation.getAuthor(i), annotation.getDesc(annotation.getRevision(i)), annotation.getFileVersion(annotation.getRevision(i)) + "/" + annotation.getRevisions().size()));
}
return annotationList;
}
use of jakarta.ws.rs.Produces 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.Produces 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.Produces in project OpenGrok by OpenGrok.
the class ProjectsController method getRepositoriesType.
@GET
@Path("/{project}/repositories/type")
@Produces(MediaType.APPLICATION_JSON)
public Set<String> getRepositoriesType(@PathParam("project") String projectName) {
// Avoid classification as a taint bug.
projectName = Laundromat.launderInput(projectName);
Project project = env.getProjects().get(projectName);
if (project != null) {
List<RepositoryInfo> infos = env.getProjectRepositoriesMap().get(project);
if (infos != null) {
return infos.stream().map(RepositoryInfo::getType).collect(Collectors.toSet());
}
}
return Collections.emptySet();
}
Aggregations