use of com.djrapitops.plan.delivery.webserver.cache.DataID in project Plan by plan-player-analytics.
the class GraphsJSONResolver method getResponse.
private Response getResponse(Request request) {
String type = request.getQuery().get("type").orElseThrow(() -> new BadRequestException("'type' parameter was not defined."));
DataID dataID = getDataID(type);
return Response.builder().setMimeType(MimeType.JSON).setJSONContent(getGraphJSON(request, dataID).json).build();
}
use of com.djrapitops.plan.delivery.webserver.cache.DataID in project Plan by plan-player-analytics.
the class GraphsJSONResolver method getGraphJSON.
private JSONStorage.StoredJSON getGraphJSON(Request request, DataID dataID) {
Optional<Long> timestamp = Identifiers.getTimestamp(request);
JSONStorage.StoredJSON storedJSON;
if (request.getQuery().get("server").isPresent()) {
// Can throw BadRequestException
ServerUUID serverUUID = identifiers.getServerUUID(request);
storedJSON = jsonResolverService.resolve(timestamp, dataID, serverUUID, theServerUUID -> generateGraphDataJSONOfType(dataID, theServerUUID, request.getQuery()));
} else {
// Assume network
storedJSON = jsonResolverService.resolve(timestamp, dataID, () -> generateGraphDataJSONOfType(dataID));
}
return storedJSON;
}
Aggregations