From d677cc175fa93b23572c713405ded931e09f6277 Mon Sep 17 00:00:00 2001 From: Michel Jung Date: Fri, 31 Mar 2017 23:47:36 +0200 Subject: [PATCH 1/8] Fix name of test class --- .../map/{MapControllerTest.java => MapsControllerTest.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/test/java/com/faforever/api/map/{MapControllerTest.java => MapsControllerTest.java} (96%) diff --git a/src/test/java/com/faforever/api/map/MapControllerTest.java b/src/test/java/com/faforever/api/map/MapsControllerTest.java similarity index 96% rename from src/test/java/com/faforever/api/map/MapControllerTest.java rename to src/test/java/com/faforever/api/map/MapsControllerTest.java index e31fb3c0c..bec0b581c 100644 --- a/src/test/java/com/faforever/api/map/MapControllerTest.java +++ b/src/test/java/com/faforever/api/map/MapsControllerTest.java @@ -26,7 +26,7 @@ @RunWith(SpringRunner.class) @WebMvcTest(MapsController.class) @Import(TestWebSecurityConfig.class) -public class MapControllerTest { +public class MapsControllerTest { private MockMvc mvc; @MockBean @@ -85,6 +85,6 @@ public void successUpload() throws Exception { } private InputStream loadMapResourceAsStream(String filename) { - return MapControllerTest.class.getResourceAsStream("/maps/" + filename); + return MapsControllerTest.class.getResourceAsStream("/maps/" + filename); } } From 0157a157ad0335e67628450f6ef1fedcd0e67637 Mon Sep 17 00:00:00 2001 From: Michel Jung Date: Fri, 31 Mar 2017 23:54:43 +0200 Subject: [PATCH 2/8] Use sequential error codes. Codes have no semantic. --- .../com/faforever/api/error/ErrorCode.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/faforever/api/error/ErrorCode.java b/src/main/java/com/faforever/api/error/ErrorCode.java index 23573b49d..35925f9b8 100644 --- a/src/main/java/com/faforever/api/error/ErrorCode.java +++ b/src/main/java/com/faforever/api/error/ErrorCode.java @@ -53,16 +53,16 @@ public enum ErrorCode { MAP_NO_VALID_JSON_METADATA(146, "No valid json", "Metadata json is not valid"), MAP_RENAME_FAILED(147, "Cannot rename to correct name failed ", "Cannot rename file '{0}'"), MAP_INVALID_ZIP(148, "Invalid zip file", "The zip file should only contain one folder at the root level"), - CLAN_CREATE_CREATOR_IS_IN_A_CLAN(201, "You are already in a clan", "Clan creator is already member of a clan"), - CLAN_ACCEPT_TOKEN_EXPIRE(203, "Token Expire", "The Invitation Link expire"), - CLAN_ACCEPT_WRONG_PLAYER(204, "Wrong Player", "Your are not the invited player"), - CLAN_ACCEPT_PLAYER_IN_A_CLAN(205, "Player is in a clan", "You are already in a clan"), - CLAN_NOT_LEADER(206, "You Permission", "You are not the leader of the clan"), - CLAN_NOT_EXISTS(207, "Cannot find Clan", "Clan with id '{0}' is not available"), - CLAN_GENERATE_LINK_PLAYER_NOT_FOUND(208, "Player not found", "Cannot find player with id '{0}' who should be invited to the clan"), - CLAN_NAME_EXISTS(209, "Clan Name already in use", "The clan name '{0}' is already in use. Please choose a different clan name."), - CLAN_TAG_EXISTS(210, "Clan Tag already in use", "The clan tag '{0}' is already in use. Please choose a different clan tag."), - VALIDATION_FAILED(900, "Validation failed", "{0}"); + CLAN_CREATE_CREATOR_IS_IN_A_CLAN(149, "You are already in a clan", "Clan creator is already member of a clan"), + CLAN_ACCEPT_TOKEN_EXPIRE(150, "Token Expire", "The Invitation Link expire"), + CLAN_ACCEPT_WRONG_PLAYER(151, "Wrong Player", "Your are not the invited player"), + CLAN_ACCEPT_PLAYER_IN_A_CLAN(152, "Player is in a clan", "You are already in a clan"), + CLAN_NOT_LEADER(153, "You Permission", "You are not the leader of the clan"), + CLAN_NOT_EXISTS(154, "Cannot find Clan", "Clan with id '{0}' is not available"), + CLAN_GENERATE_LINK_PLAYER_NOT_FOUND(155, "Player not found", "Cannot find player with id '{0}' who should be invited to the clan"), + CLAN_NAME_EXISTS(156, "Clan Name already in use", "The clan name '{0}' is already in use. Please choose a different clan name."), + CLAN_TAG_EXISTS(157, "Clan Tag already in use", "The clan tag '{0}' is already in use. Please choose a different clan tag."), + VALIDATION_FAILED(158, "Validation failed", "{0}"); private final int code; private final String title; From a453deb363f274cafe031302725b2a499c45bab1 Mon Sep 17 00:00:00 2001 From: Michel Jung Date: Sat, 1 Apr 2017 15:26:10 +0200 Subject: [PATCH 3/8] Fix #45 mod upload --- .idea/codeStyleSettings.xml | 1 + gradle.properties | 2 +- .../api/config/FafApiProperties.java | 10 +- .../GlobalControllerExceptionHandler.java | 7 +- .../com/faforever/api/data/domain/Mod.java | 11 + .../faforever/api/data/domain/ModVersion.java | 7 +- .../data/listeners/ModVersionEnricher.java | 12 +- .../LegacyFeaturedModDeploymentTask.java | 2 +- .../com/faforever/api/error/ErrorCode.java | 28 +-- .../com/faforever/api/map/MapService.java | 13 +- .../com/faforever/api/map/MapsController.java | 2 +- .../com/faforever/api/mod/ModRepository.java | 33 +++ .../com/faforever/api/mod/ModService.java | 198 ++++++++++++++++++ .../api/mod/ModVersionRepository.java | 9 + .../com/faforever/api/mod/ModsController.java | 53 +++++ .../faforever/api/player/PlayerService.java | 1 - .../com/faforever/api/user/UserService.java | 28 +++ .../com/faforever/api/config/ErrorTest.java | 2 +- .../com/faforever/api/mod/ModServiceTest.java | 91 ++++++++ src/test/resources/mods/No Friendly Fire.zip | Bin 0 -> 22969 bytes 20 files changed, 473 insertions(+), 37 deletions(-) create mode 100644 src/main/java/com/faforever/api/mod/ModRepository.java create mode 100644 src/main/java/com/faforever/api/mod/ModService.java create mode 100644 src/main/java/com/faforever/api/mod/ModVersionRepository.java create mode 100644 src/main/java/com/faforever/api/mod/ModsController.java create mode 100644 src/main/java/com/faforever/api/user/UserService.java create mode 100644 src/test/java/com/faforever/api/mod/ModServiceTest.java create mode 100644 src/test/resources/mods/No Friendly Fire.zip diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml index ec81b4b9a..b018c82fa 100644 --- a/.idea/codeStyleSettings.xml +++ b/.idea/codeStyleSettings.xml @@ -12,6 +12,7 @@