/** {@inheritDoc} */
  @Override
  public Response getStatus(HttpServletRequest request, String tickId) {
    String crsid = (String) request.getSession().getAttribute("RavenRemoteUser");

    /* Get the fork object, returning if not found */
    Fork fork = db.getFork(Fork.generateForkId(crsid, tickId));
    if (fork == null) {
      log.error(
          "User "
              + crsid
              + " 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();
    }

    /* Call the test service */
    publicinterfaces.Status status;
    try {
      status = testServiceProxy.pollStatus(config.getConfig().getSecurityToken(), crsid, tickId);
    } catch (InternalServerErrorException e) {
      RemoteFailureHandler h = new RemoteFailureHandler();
      SerializableException s = h.readException(e);

      log.error(
          "User "
              + crsid
              + " failed getting the running status of "
              + crsid
              + " "
              + tickId
              + "\nCause: "
              + s.toString());
      return Response.status(Status.NOT_FOUND).entity(Strings.MISSING).build();
    } catch (NoSuchTestException e) {
      log.error(
          "User " + crsid + " failed getting the running status of " + crsid + " " + tickId, e);
      return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e).build();
    }

    /* Check if the tests are complete */
    if ((status.getProgress() == status.getMaxProgress())
        && (status.getCurrentPositionInQueue() == 0)) {

      /* The fork has finished testing and the report is available */
      fork.setTesting(false);
      fork.setReportAvailable(true);

      /*
       * Get all of the groups this tick is in and set whether the user
       * can sign up for ticking in them or not
       */
      List<String> groupIds = db.getTick(tickId).getGroups();

      boolean unitPass = status.getInfo().equals("PASS");
      if (unitPass) {
        for (String groupId : groupIds) {
          tickSignupService.allowSignup(crsid, groupId, tickId);
        }
        fork.incrementUnitPasses();
      } else {
        for (String groupId : groupIds) {
          tickSignupService.disallowSignup(crsid, groupId, tickId);
        }
        fork.incrementUnitFails();
      }

      /* Set whether the fork passed and save it */
      fork.setUnitPass(unitPass);
      db.saveFork(fork);
    }

    /* Return the status object */
    return Response.ok(status).build();
  }