11package com .faforever .api .leaderboard ;
22
3- import com .faforever .api .web .ResourceNotFoundException ;
3+ import com .faforever .api .error .Error ;
4+ import com .faforever .api .error .ErrorCode ;
5+ import com .faforever .api .error .NotFoundApiException ;
46import com .google .common .collect .ImmutableMap ;
57import com .yahoo .elide .jsonapi .models .Data ;
68import com .yahoo .elide .jsonapi .models .JsonApiDocument ;
@@ -76,13 +78,13 @@ public CompletableFuture<JsonApiDocument> getGlobal(@RequestParam(value = "page[
7678 @ Async
7779 @ RequestMapping (path = "/ladder1v1/{playerId}" , method = RequestMethod .GET )
7880 @ ApiOperation ("Lists the ladder1v1 leaderboard for the specified player" )
79- public CompletableFuture <JsonApiDocument > getSingleLadder1v1 (@ PathVariable ("playerId" ) String playerId ) {
80- Ladder1v1LeaderboardEntry entry = leaderboardService .getLadder1v1Entry (Integer . valueOf ( playerId ) );
81+ public CompletableFuture <JsonApiDocument > getSingleLadder1v1 (@ PathVariable ("playerId" ) Integer playerId ) {
82+ Ladder1v1LeaderboardEntry entry = leaderboardService .getLadder1v1Entry (playerId );
8183 if (entry == null ) {
82- throw new ResourceNotFoundException ( "No ladder1v1 entry found for player: " + playerId );
84+ throw new NotFoundApiException ( new Error ( ErrorCode . ENTITY_NOT_FOUND , playerId ) );
8385 }
8486
85- Resource resource = new Resource (LADDER_1V1_LEADERBOARD_ENTRY , playerId , ImmutableMap .<String , Object >builder ()
87+ Resource resource = new Resource (LADDER_1V1_LEADERBOARD_ENTRY , playerId . toString () , ImmutableMap .<String , Object >builder ()
8688 .put ("name" , entry .getPlayerName ())
8789 .put ("mean" , entry .getMean ())
8890 .put ("deviation" , entry .getDeviation ())
@@ -99,13 +101,13 @@ public CompletableFuture<JsonApiDocument> getSingleLadder1v1(@PathVariable("play
99101 @ Async
100102 @ RequestMapping (path = "/global/{playerId}" , method = RequestMethod .GET )
101103 @ ApiOperation ("Lists the global leaderboard for the specified player" )
102- public CompletableFuture <JsonApiDocument > getSingleGlobal (@ PathVariable ("playerId" ) String playerId ) {
103- GlobalLeaderboardEntry entry = leaderboardService .getGlobalEntry (Integer . valueOf ( playerId ) );
104+ public CompletableFuture <JsonApiDocument > getSingleGlobal (@ PathVariable ("playerId" ) Integer playerId ) {
105+ GlobalLeaderboardEntry entry = leaderboardService .getGlobalEntry (playerId );
104106 if (entry == null ) {
105- throw new ResourceNotFoundException ( "No global leaderboard entry found for player: " + playerId );
107+ throw new NotFoundApiException ( new Error ( ErrorCode . ENTITY_NOT_FOUND , playerId ) );
106108 }
107109
108- Resource resource = new Resource (GLOBAL_LEADERBOARD_ENTRY , playerId , ImmutableMap .<String , Object >builder ()
110+ Resource resource = new Resource (GLOBAL_LEADERBOARD_ENTRY , playerId . toString () , ImmutableMap .<String , Object >builder ()
109111 .put ("name" , entry .getPlayerName ())
110112 .put ("mean" , entry .getMean ())
111113 .put ("deviation" , entry .getDeviation ())
0 commit comments