Convert enum values to upper case before attempting to parse

This commit is contained in:
Colin McDonald 2016-10-20 22:59:48 -04:00
parent ee1e578140
commit 525bd64c3b
3 changed files with 3 additions and 3 deletions

View File

@ -36,7 +36,7 @@ public final class POSTAuditLog implements Handler<RoutingContext> {
AuditLogActionType type; AuditLogActionType type;
try { try {
type = AuditLogActionType.valueOf(requestBody.getString("type")); type = AuditLogActionType.valueOf(requestBody.getString("type", "").toUpperCase());
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
ErrorUtils.respondNotFound(ctx, "Audit log action type", requestBody.getString("type")); ErrorUtils.respondNotFound(ctx, "Audit log action type", requestBody.getString("type"));
return; return;

View File

@ -29,7 +29,7 @@ public final class DELETEUsersIdActivePunishment implements Handler<RoutingConte
} }
JsonObject requestBody = ctx.getBodyAsJson(); JsonObject requestBody = ctx.getBodyAsJson();
Punishment.PunishmentType type = Punishment.PunishmentType.valueOf(requestBody.getString("type").toUpperCase()); Punishment.PunishmentType type = Punishment.PunishmentType.valueOf(requestBody.getString("type", "").toUpperCase());
// We purposely don't do a null check, punishment removals don't have to have a user/ip. // We purposely don't do a null check, punishment removals don't have to have a user/ip.
User removedBy = SyncUtils.runBlocking(v -> User.findById(requestBody.getString("removedBy"), v)); User removedBy = SyncUtils.runBlocking(v -> User.findById(requestBody.getString("removedBy"), v));
String reason = requestBody.getString("reason"); String reason = requestBody.getString("reason");

View File

@ -45,7 +45,7 @@ public final class POSTPunishments implements Handler<RoutingContext> {
return; return;
} }
Punishment.PunishmentType type = Punishment.PunishmentType.valueOf(requestBody.getString("type")); Punishment.PunishmentType type = Punishment.PunishmentType.valueOf(requestBody.getString("type", "").toUpperCase());
if (type != Punishment.PunishmentType.WARN) { if (type != Punishment.PunishmentType.WARN) {
List<Punishment> punishments = SyncUtils.runBlocking(v -> Punishment.findByUserAndType(target, ImmutableSet.of(type), v)); List<Punishment> punishments = SyncUtils.runBlocking(v -> Punishment.findByUserAndType(target, ImmutableSet.of(type), v));