diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 43c5b3f62..cbd0e3ae6 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -5,6 +5,9 @@
+
+
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
index ddfe56ffb..5bf195a1f 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,6 +2,10 @@
+
+
+
+
diff --git a/src/main/java/com/faforever/api/error/ErrorCode.java b/src/main/java/com/faforever/api/error/ErrorCode.java
index 9cfe5c131..65109c79b 100644
--- a/src/main/java/com/faforever/api/error/ErrorCode.java
+++ b/src/main/java/com/faforever/api/error/ErrorCode.java
@@ -99,8 +99,8 @@ public enum ErrorCode {
PARSING_LUA_FILE_FAILED(189, "Parsing lua files failed", "During the parsing of the lua file an error occured: {0}"),
NO_RUSH_RADIUS_MISSING(190, "No rush radius missing", "The scenario file must specify a no rush radius"),
INVALID_FEATURED_MOD(191, "Invalid featured mod name", "The featured mod name ''{0}'' is not allowed in this context."),
- API_KEY_INVALID(192, "Api key is invalid", "The api key is invalid.");
-
+ API_KEY_INVALID(192, "Api key is invalid", "The api key is invalid."),
+ PLAYER_ID_MUST_BE_NUMBER(193,"Player ID must be number","The player id must be a number");
private final int code;
private final String title;
private final String detail;
diff --git a/src/main/java/com/faforever/api/leaderboard/LeaderboardController.java b/src/main/java/com/faforever/api/leaderboard/LeaderboardController.java
index 164dc70c5..7775e1a52 100644
--- a/src/main/java/com/faforever/api/leaderboard/LeaderboardController.java
+++ b/src/main/java/com/faforever/api/leaderboard/LeaderboardController.java
@@ -100,9 +100,9 @@ public CompletableFuture getSingleLadder1v1(@PathVariable("play
@RequestMapping(path = "/global/{playerId}", method = RequestMethod.GET)
@ApiOperation("Lists the global leaderboard for the specified player")
public CompletableFuture getSingleGlobal(@PathVariable("playerId") String playerId) {
- GlobalLeaderboardEntry entry = leaderboardService.getGlobalEntry(Integer.valueOf(playerId));
+ GlobalLeaderboardEntry entry = leaderboardService.getGlobalEntry(playerId);
if (entry == null) {
- throw new ResourceNotFoundException("No global leaderboard entry found for player: " + playerId);
+ throw new ResourceNotFoundException("No global leader board entry found for player: " + playerId);
}
Resource resource = new Resource(GLOBAL_LEADERBOARD_ENTRY, playerId, ImmutableMap.builder()
diff --git a/src/main/java/com/faforever/api/leaderboard/LeaderboardService.java b/src/main/java/com/faforever/api/leaderboard/LeaderboardService.java
index ba07a81e3..7345d6143 100644
--- a/src/main/java/com/faforever/api/leaderboard/LeaderboardService.java
+++ b/src/main/java/com/faforever/api/leaderboard/LeaderboardService.java
@@ -1,5 +1,8 @@
package com.faforever.api.leaderboard;
+import com.faforever.api.error.ApiException;
+import com.faforever.api.error.ErrorCode;
+import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.cache.annotation.Cacheable;
@@ -35,8 +38,13 @@ public Page getGlobalLeaderboard(@Nullable Integer page,
return globalLeaderboardRepository.getLeaderboardByPage(getPageable(page, pageSize));
}
- public GlobalLeaderboardEntry getGlobalEntry(int playerId) {
- return globalLeaderboardRepository.findByPlayerId(playerId);
+ public GlobalLeaderboardEntry getGlobalEntry(String playerId) {
+ if (StringUtils.isNumeric(playerId)) {
+ return globalLeaderboardRepository.findByPlayerId(Integer.parseInt(playerId));
+ }
+ else {
+ throw ApiException.of(ErrorCode.PLAYER_ID_MUST_BE_NUMBER);
+ }
}
public Ladder1v1LeaderboardEntry getLadder1v1Entry(int playerId) {