Search in sources :

Example 1 with NotFoundException

use of com.djrapitops.plan.delivery.web.resolver.exception.NotFoundException in project Plan by plan-player-analytics.

the class PlayerPageExporter method exportHtml.

private void exportHtml(ExportPaths exportPaths, Path playerDirectory, UUID playerUUID) throws IOException {
    Path to = playerDirectory.resolve("index.html");
    try {
        Page page = pageFactory.playerPage(playerUUID);
        export(to, exportPaths.resolveExportPaths(page.toHtml()));
    } catch (IllegalStateException notFound) {
        throw new NotFoundException(notFound.getMessage());
    }
}
Also used : Path(java.nio.file.Path) NotFoundException(com.djrapitops.plan.delivery.web.resolver.exception.NotFoundException) Page(com.djrapitops.plan.delivery.rendering.pages.Page)

Example 2 with NotFoundException

use of com.djrapitops.plan.delivery.web.resolver.exception.NotFoundException in project Plan by plan-player-analytics.

the class HttpsServerTest method testAccess.

default void testAccess(String address, String cookie) throws IOException, KeyManagementException, NoSuchAlgorithmException {
    HttpURLConnection connection = null;
    try {
        connection = connector.getConnection("GET", address);
        connection.setRequestProperty("Cookie", cookie);
        int responseCode = connection.getResponseCode();
        switch(responseCode) {
            case 200:
            case 302:
                return;
            case 400:
                throw new BadRequestException("Bad Request: " + address);
            case 403:
                throw new ForbiddenException(address + " returned 403");
            case 404:
                throw new NotFoundException(address + " returned a 404, ensure that your server is connected to an up to date Plan server.");
            case 500:
                // Not supported
                throw new IllegalStateException();
            default:
                throw new WebException(address + "| Wrong response code " + responseCode);
        }
    } finally {
        connection.disconnect();
    }
}
Also used : ForbiddenException(com.djrapitops.plan.exceptions.connection.ForbiddenException) HttpURLConnection(java.net.HttpURLConnection) WebException(com.djrapitops.plan.exceptions.connection.WebException) BadRequestException(com.djrapitops.plan.delivery.web.resolver.exception.BadRequestException) NotFoundException(com.djrapitops.plan.delivery.web.resolver.exception.NotFoundException)

Aggregations

NotFoundException (com.djrapitops.plan.delivery.web.resolver.exception.NotFoundException)2 Page (com.djrapitops.plan.delivery.rendering.pages.Page)1 BadRequestException (com.djrapitops.plan.delivery.web.resolver.exception.BadRequestException)1 ForbiddenException (com.djrapitops.plan.exceptions.connection.ForbiddenException)1 WebException (com.djrapitops.plan.exceptions.connection.WebException)1 HttpURLConnection (java.net.HttpURLConnection)1 Path (java.nio.file.Path)1