/** {@inheritDoc} */ @Override public Response getAllReports(HttpServletRequest request, String tickId, String crsid) { String myCrsid = (String) request.getSession().getAttribute("RavenRemoteUser"); /* The user operated on is the caller */ if (crsid.equals("")) { crsid = myCrsid; } /* Get the fork object, returning if not found */ Fork fork = db.getFork(Fork.generateForkId(crsid, tickId)); if (fork == null) { log.error( "User " + myCrsid + " requested fork " + Fork.generateForkId(crsid, tickId) + " to get testing status, but it couldn't be found"); return Response.status(Status.NOT_FOUND).entity(Strings.MISSING).build(); } /* Check permissions */ if (!(permissions.forkCreator(myCrsid, crsid, tickId) || permissions.tickRole(myCrsid, tickId, Role.MARKER))) { log.warn( "User " + myCrsid + " tried to access fork " + Fork.generateForkId(crsid, tickId) + " but was denied permission"); return Response.status(Status.FORBIDDEN).entity(Strings.INVALIDROLE).build(); } /* Call the test service */ List<Report> status; try { status = testServiceProxy.getAllReports(config.getConfig().getSecurityToken(), crsid, tickId); } catch (InternalServerErrorException e) { RemoteFailureHandler h = new RemoteFailureHandler(); SerializableException s = h.readException(e); log.error( "User " + myCrsid + " failed getting all reports for " + crsid + " " + tickId + "\nCause: " + s.toString()); return Response.status(Status.NOT_FOUND).entity(Strings.MISSING).build(); } catch (UserNotInDBException | TickNotInDBException e) { log.error("User " + myCrsid + " failed getting all reports for " + crsid + " " + tickId, e); return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e).build(); } /* * Set the fork's last report date from the last report and * save it */ fork.setLastReport(new DateTime(status.get(status.size() - 1).getCreationDate())); db.saveFork(fork); /* Return all of the reports */ return Response.ok(status).build(); }