@Path("/reports/{exercise}")
public Response getReports(@PathParam("exercise") String exercise, @HeaderParam("Authorization") String token) {
if (token == null) {
return Response.status(Response.Status.UNAUTHORIZED).build();
}
Token userToken = tokenFacade.validateToken(token);
if (userToken == null) {
return Response.status(Response.Status.FORBIDDEN).build();
}
String userid = userToken.getUserid();
List<File> reports = AntRunner.getTestsReports(exercise, userid);
File buildXml = AntRunner.getBuildXml(exercise, userid);
if (reports.isEmpty() && !buildXml.exists() ) {
return Response.status(Response.Status.NOT_FOUND).entity("Reports not found").build();
}