1
1
package com .faforever .api .leaderboard ;
2
2
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 ;
4
6
import com .google .common .collect .ImmutableMap ;
5
7
import com .yahoo .elide .jsonapi .models .Data ;
6
8
import com .yahoo .elide .jsonapi .models .JsonApiDocument ;
@@ -76,13 +78,13 @@ public CompletableFuture<JsonApiDocument> getGlobal(@RequestParam(value = "page[
76
78
@ Async
77
79
@ RequestMapping (path = "/ladder1v1/{playerId}" , method = RequestMethod .GET )
78
80
@ 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 );
81
83
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 ) );
83
85
}
84
86
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 ()
86
88
.put ("name" , entry .getPlayerName ())
87
89
.put ("mean" , entry .getMean ())
88
90
.put ("deviation" , entry .getDeviation ())
@@ -99,13 +101,13 @@ public CompletableFuture<JsonApiDocument> getSingleLadder1v1(@PathVariable("play
99
101
@ Async
100
102
@ RequestMapping (path = "/global/{playerId}" , method = RequestMethod .GET )
101
103
@ 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 );
104
106
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 ) );
106
108
}
107
109
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 ()
109
111
.put ("name" , entry .getPlayerName ())
110
112
.put ("mean" , entry .getMean ())
111
113
.put ("deviation" , entry .getDeviation ())
0 commit comments