/**
   * Look for abandoned stars. We look for stars which are far enough from established empires, but
   * still near the centre of the universe and not *too* far...
   */
  private boolean findAbandonedStar() throws RequestException {
    String sql =
        "SELECT star_id, empire_id"
            + " FROM abandoned_stars"
            + " WHERE distance_to_non_abandoned_empire > 200"
            + " ORDER BY (distance_to_non_abandoned_empire + distance_to_centre) ASC"
            + " LIMIT 10";
    try (SqlStmt stmt = DB.prepare(sql)) {
      SqlResult res = stmt.select();

      List<Pair<Integer, Integer>> stars = new ArrayList<Pair<Integer, Integer>>();
      while (res.next()) {
        int starID = res.getInt(1);
        int empireID = res.getInt(2);
        stars.add(new Pair<Integer, Integer>(starID, empireID));
      }

      if (stars.size() > 0) {
        Pair<Integer, Integer> starDetails = stars.get(new Random().nextInt(stars.size()));

        // we need to reset the empire on this star so that they move to a different star if the log
        // in again.
        new EmpireController()
            .resetEmpire(
                starDetails.two, "You have not logged in for a while and your star was reclaimed.");

        mStarID = starDetails.one;
        findPlanetOnStar(new StarController().getStar(mStarID));

        // the star is no longer abandoned!
        sql = "DELETE FROM abandoned_stars WHERE star_id = ?";
        try (SqlStmt stmt2 = DB.prepare(sql)) {
          stmt2.setInt(1, mStarID);
          stmt2.update();
        }
        return true;
      }
    } catch (Exception e) {
      throw new RequestException(e);
    }

    return false;
  }
  @Override
  protected void get() throws RequestException {
    int empireID = Integer.parseInt(getUrlParameter("empire_id"));
    if (!getSession().isAdmin()) {
      throw new RequestException(403); // TODO: allow you to get your own...
    }

    String sql = "SELECT reason FROM empire_cash_audit WHERE empire_id = ? ORDER BY time DESC";
    try (SqlStmt stmt = DB.prepare(sql)) {
      stmt.setInt(1, empireID);
      SqlResult res = stmt.select();

      Messages.CashAuditRecords.Builder cash_audit_records_pb =
          Messages.CashAuditRecords.newBuilder();
      while (res.next()) {
        cash_audit_records_pb.addRecords(Messages.CashAuditRecord.parseFrom(res.getBytes(1)));
      }
      setResponseBody(cash_audit_records_pb.build());
    } catch (Exception e) {
      throw new RequestException(e);
    }
  }