mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-13 07:10:03 +01:00
Added a 504 Gateway error response to WebServer.
This commit is contained in:
parent
8a48a590ba
commit
d1b12c830c
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
/**
|
||||
* Thrown when InfoRequest can not connect to the other server.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class GatewayException extends WebException {
|
||||
|
||||
public GatewayException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public GatewayException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public GatewayException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ public interface TransferOperations {
|
||||
|
||||
void storeConfigSettings(String encodedSettingString) throws DBException;
|
||||
|
||||
@Deprecated
|
||||
void playerOnline(UUID playerUUID) throws DBException;
|
||||
|
||||
// Get
|
||||
@ -41,6 +42,7 @@ public interface TransferOperations {
|
||||
|
||||
Map<UUID, String> getEncodedServerHtml() throws DBException;
|
||||
|
||||
@Deprecated
|
||||
Optional<UUID> getServerPlayerIsOnlineOn(UUID playerUUID) throws DBException;
|
||||
|
||||
Map<UUID, String> getEncodedPlayerPluginsTabs(UUID playerUUID) throws DBException;
|
||||
|
@ -115,7 +115,7 @@ public abstract class SQLDB extends Database {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * secondsDelay);
|
||||
}).runTaskTimerAsynchronously(TimeAmount.SECOND.ticks() * secondsDelay, TimeAmount.MINUTE.ticks() * 5L);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -232,10 +232,8 @@ public abstract class SQLDB extends Database {
|
||||
}
|
||||
|
||||
private void clean() throws SQLException {
|
||||
Log.info("Cleaning the database.");
|
||||
tpsTable.clean();
|
||||
transferTable.clean();
|
||||
Log.info("Clean complete.");
|
||||
}
|
||||
|
||||
public abstract Connection getConnection() throws SQLException;
|
||||
|
@ -224,6 +224,7 @@ public class TransferTable extends Table {
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Optional<UUID> getServerPlayerIsOnline(UUID playerUUID) throws SQLException {
|
||||
String serverIDColumn = serverTable + "." + serverTable.getColumnID();
|
||||
String serverUUIDColumn = serverTable + "." + serverTable.getColumnUUID() + " as s_uuid";
|
||||
@ -250,6 +251,7 @@ public class TransferTable extends Table {
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void storePlayerOnlineOnThisServer(UUID playerUUID) throws SQLException {
|
||||
execute(new ExecStatement(insertStatement) {
|
||||
@Override
|
||||
|
@ -134,6 +134,8 @@ public class ConnectionOut {
|
||||
throw new UnauthorizedServerException(url.toString() + " reported that it does not recognize this server. Make sure '/plan m setup' was successful.");
|
||||
case 500:
|
||||
throw new InternalErrorException();
|
||||
case 504:
|
||||
throw new GatewayException(url.toString() + " reported that it failed to connect to this server.");
|
||||
default:
|
||||
throw new WebException(url.toString() + "| Wrong response code " + responseCode);
|
||||
}
|
||||
|
@ -64,6 +64,8 @@ public class InfoRequestPageHandler extends PageHandler {
|
||||
return 412;
|
||||
} else if (e instanceof InternalErrorException) {
|
||||
return 500;
|
||||
} else if (e instanceof GatewayException) {
|
||||
return 504;
|
||||
} else if (e instanceof ConnectionFailException) {
|
||||
return -1;
|
||||
} else {
|
||||
|
@ -13,10 +13,7 @@ import com.djrapitops.plan.system.webserver.response.*;
|
||||
import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse;
|
||||
import com.djrapitops.plan.system.webserver.response.cache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.response.cache.ResponseCache;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.UnauthorizedServerResponse;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.*;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -73,6 +70,8 @@ public class ResponseHandler extends TreePageHandler {
|
||||
return new BadRequestResponse(e.getMessage());
|
||||
} catch (UnauthorizedServerException e) {
|
||||
return new UnauthorizedServerResponse(e.getMessage());
|
||||
} catch (GatewayException e) {
|
||||
return new GatewayErrorResponse(e.getMessage());
|
||||
} catch (InternalErrorException e) {
|
||||
if (e.getCause() != null) {
|
||||
return new InternalErrorResponse(request.getTarget(), e.getCause());
|
||||
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.system.webserver.response.errors;
|
||||
|
||||
/**
|
||||
* ErrorResponse for GatewayException.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class GatewayErrorResponse extends ErrorResponse {
|
||||
|
||||
public GatewayErrorResponse(String message) {
|
||||
super.setHeader("HTTP/1.1 504 Gateway Error");
|
||||
super.setTitle("Failed to Connect (Gateway Error)");
|
||||
super.setParagraph(message);
|
||||
super.replacePlaceholders();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user