Search in sources :

Example 1 with DataID

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();
}
Also used : DataID(com.djrapitops.plan.delivery.webserver.cache.DataID) BadRequestException(com.djrapitops.plan.delivery.web.resolver.exception.BadRequestException)

Example 2 with DataID

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;
}
Also used : MimeType(com.djrapitops.plan.delivery.web.resolver.MimeType) Request(com.djrapitops.plan.delivery.web.resolver.request.Request) ServerUUID(com.djrapitops.plan.identification.ServerUUID) URIQuery(com.djrapitops.plan.delivery.web.resolver.request.URIQuery) Singleton(javax.inject.Singleton) Response(com.djrapitops.plan.delivery.web.resolver.Response) Inject(javax.inject.Inject) AsyncJSONResolverService(com.djrapitops.plan.delivery.webserver.cache.AsyncJSONResolverService) Resolver(com.djrapitops.plan.delivery.web.resolver.Resolver) WebUser(com.djrapitops.plan.delivery.web.resolver.request.WebUser) Identifiers(com.djrapitops.plan.identification.Identifiers) BadRequestException(com.djrapitops.plan.delivery.web.resolver.exception.BadRequestException) Optional(java.util.Optional) JSONStorage(com.djrapitops.plan.delivery.webserver.cache.JSONStorage) GraphJSONCreator(com.djrapitops.plan.delivery.rendering.json.graphs.GraphJSONCreator) Collections(java.util.Collections) DataID(com.djrapitops.plan.delivery.webserver.cache.DataID) ServerUUID(com.djrapitops.plan.identification.ServerUUID) JSONStorage(com.djrapitops.plan.delivery.webserver.cache.JSONStorage)

Aggregations

BadRequestException (com.djrapitops.plan.delivery.web.resolver.exception.BadRequestException)2 DataID (com.djrapitops.plan.delivery.webserver.cache.DataID)2 GraphJSONCreator (com.djrapitops.plan.delivery.rendering.json.graphs.GraphJSONCreator)1 MimeType (com.djrapitops.plan.delivery.web.resolver.MimeType)1 Resolver (com.djrapitops.plan.delivery.web.resolver.Resolver)1 Response (com.djrapitops.plan.delivery.web.resolver.Response)1 Request (com.djrapitops.plan.delivery.web.resolver.request.Request)1 URIQuery (com.djrapitops.plan.delivery.web.resolver.request.URIQuery)1 WebUser (com.djrapitops.plan.delivery.web.resolver.request.WebUser)1 AsyncJSONResolverService (com.djrapitops.plan.delivery.webserver.cache.AsyncJSONResolverService)1 JSONStorage (com.djrapitops.plan.delivery.webserver.cache.JSONStorage)1 Identifiers (com.djrapitops.plan.identification.Identifiers)1 ServerUUID (com.djrapitops.plan.identification.ServerUUID)1 Collections (java.util.Collections)1 Optional (java.util.Optional)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1