summaryrefslogtreecommitdiff
path: root/backend/src/main/java/org/luxons
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@amadeus.com>2018-04-18 13:46:29 +0200
committerJoffrey Bion <joffrey.bion@amadeus.com>2018-04-18 18:49:30 +0200
commit08dfccecef98c0c1bc013e5565fcbf117fc63fbd (patch)
treea7ef7f20adf6c193a0b88d8cffbd021046f59499 /backend/src/main/java/org/luxons
parentUpgrade to Livedoc 3.0.0 (diff)
downloadseven-wonders-08dfccecef98c0c1bc013e5565fcbf117fc63fbd.tar.gz
seven-wonders-08dfccecef98c0c1bc013e5565fcbf117fc63fbd.tar.bz2
seven-wonders-08dfccecef98c0c1bc013e5565fcbf117fc63fbd.zip
Upgrade to Livedoc 4.3.2 and gradle 4.6
Diffstat (limited to 'backend/src/main/java/org/luxons')
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/actions/ChooseNameAction.java17
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/actions/CreateGameAction.java12
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/actions/JoinGameAction.java11
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/actions/PrepareMoveAction.java12
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/actions/ReorderPlayersAction.java14
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/actions/UpdateSettingsAction.java13
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/controllers/GameBrowserController.java38
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java23
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/controllers/HomeController.java17
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java38
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/doc/Documentation.java6
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/doc/GlobalDocumentation.java7
12 files changed, 160 insertions, 48 deletions
diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/ChooseNameAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/ChooseNameAction.java
index 6609d2ad..c404cd74 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/actions/ChooseNameAction.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/actions/ChooseNameAction.java
@@ -3,20 +3,23 @@ package org.luxons.sevenwonders.actions;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
-import org.hildan.livedoc.core.annotations.ApiObject;
-import org.hildan.livedoc.core.annotations.ApiObjectProperty;
+import org.hildan.livedoc.core.annotations.types.ApiType;
+import org.hildan.livedoc.core.annotations.types.ApiTypeProperty;
-@ApiObject(name = "Choose Name Action",
- description = "The action to choose the player's name. This is the first action that should be called.",
- group = "Actions")
+/**
+ * The action to choose the player's name. This is the first action that should be called.
+ */
+@ApiType(group = "Actions")
public class ChooseNameAction {
- @ApiObjectProperty(description = "The display name of the player. May contain spaces and special characters.",
- required = true)
@NotNull
@Size(min = 2, max = 20)
private String playerName;
+ /**
+ * @return The display name of the player. May contain spaces and special characters.
+ */
+ @ApiTypeProperty(required = true)
public String getPlayerName() {
return playerName;
}
diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/CreateGameAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/CreateGameAction.java
index c0b72c38..771a5a9c 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/actions/CreateGameAction.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/actions/CreateGameAction.java
@@ -3,15 +3,21 @@ package org.luxons.sevenwonders.actions;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
-import org.hildan.livedoc.core.annotations.ApiObject;
+import org.hildan.livedoc.core.annotations.types.ApiType;
-@ApiObject(name = "Create Game Action", description = "The action to create a game.", group = "Actions")
+/**
+ * The action to create a game.
+ */
+@ApiType(group = "Actions")
public class CreateGameAction {
@NotNull
@Size(min = 2, max = 30)
private String gameName;
+ /**
+ * @return The name of the game to create
+ */
public String getGameName() {
return gameName;
}
@@ -20,3 +26,5 @@ public class CreateGameAction {
this.gameName = gameName;
}
}
+
+
diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/JoinGameAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/JoinGameAction.java
index acb63772..2675dc71 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/actions/JoinGameAction.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/actions/JoinGameAction.java
@@ -2,14 +2,21 @@ package org.luxons.sevenwonders.actions;
import javax.validation.constraints.NotNull;
-import org.hildan.livedoc.core.annotations.ApiObject;
+import org.hildan.livedoc.core.annotations.types.ApiType;
+import org.luxons.sevenwonders.doc.Documentation;
-@ApiObject(name = "Join Game Action", description = "The action to join a game.", group = "Actions")
+/**
+ * The action to join a game.
+ */
+@ApiType(group = Documentation.GROUP_ACTIONS)
public class JoinGameAction {
@NotNull
private Long gameId;
+ /**
+ * @return The ID of the game to join
+ */
public Long getGameId() {
return gameId;
}
diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/PrepareMoveAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/PrepareMoveAction.java
index d1f82267..e3622b1b 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/actions/PrepareMoveAction.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/actions/PrepareMoveAction.java
@@ -2,16 +2,22 @@ package org.luxons.sevenwonders.actions;
import javax.validation.constraints.NotNull;
-import org.hildan.livedoc.core.annotations.ApiObject;
+import org.hildan.livedoc.core.annotations.types.ApiType;
+import org.luxons.sevenwonders.doc.Documentation;
import org.luxons.sevenwonders.game.api.PlayerMove;
-@ApiObject(name = "Prepare Move Action", description = "The action to prepare the next move during a game.",
- group = "Actions")
+/**
+ * The action to prepare the next move during a game.
+ */
+@ApiType(group = Documentation.GROUP_ACTIONS)
public class PrepareMoveAction {
@NotNull
private PlayerMove move;
+ /**
+ * @return the move to prepare
+ */
public PlayerMove getMove() {
return move;
}
diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/ReorderPlayersAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/ReorderPlayersAction.java
index d0a6d7fd..ce272340 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/actions/ReorderPlayersAction.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/actions/ReorderPlayersAction.java
@@ -3,16 +3,22 @@ package org.luxons.sevenwonders.actions;
import java.util.List;
import javax.validation.constraints.NotNull;
-import org.hildan.livedoc.core.annotations.ApiObject;
+import org.hildan.livedoc.core.annotations.types.ApiType;
+import org.luxons.sevenwonders.doc.Documentation;
-@ApiObject(name = "Reorder Players Action",
- description = "The action to update the order of the players around the table. Can only be called in the "
- + "lobby by the owner of the game.", group = "Actions")
+/**
+ * The action to update the order of the players around the table. Can only be called in the lobby by the owner of the
+ * game.
+ */
+@ApiType(group = Documentation.GROUP_ACTIONS)
public class ReorderPlayersAction {
@NotNull
private List<String> orderedPlayers;
+ /**
+ * @return the list of usernames of the players, in the new order
+ */
public List<String> getOrderedPlayers() {
return orderedPlayers;
}
diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/UpdateSettingsAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/UpdateSettingsAction.java
index 5dbfdc9e..7c48dee1 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/actions/UpdateSettingsAction.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/actions/UpdateSettingsAction.java
@@ -2,17 +2,22 @@ package org.luxons.sevenwonders.actions;
import javax.validation.constraints.NotNull;
-import org.hildan.livedoc.core.annotations.ApiObject;
+import org.hildan.livedoc.core.annotations.types.ApiType;
+import org.luxons.sevenwonders.doc.Documentation;
import org.luxons.sevenwonders.game.api.CustomizableSettings;
-@ApiObject(name = "Update Settings Action",
- description = "The action to update the settings of the game. Can only be called in the lobby by the owner"
- + " of the game.", group = "Actions")
+/**
+ * The action to update the settings of the game. Can only be called in the lobby by the owner of the game.
+ */
+@ApiType(group = Documentation.GROUP_ACTIONS)
public class UpdateSettingsAction {
@NotNull
private CustomizableSettings settings;
+ /**
+ * @return the new values for the settings
+ */
public CustomizableSettings getSettings() {
return settings;
}
diff --git a/backend/src/main/java/org/luxons/sevenwonders/controllers/GameBrowserController.java b/backend/src/main/java/org/luxons/sevenwonders/controllers/GameBrowserController.java
index 5f76e041..9bb96559 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/controllers/GameBrowserController.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/controllers/GameBrowserController.java
@@ -5,7 +5,6 @@ import java.util.Collection;
import java.util.Collections;
import org.hildan.livedoc.core.annotations.Api;
-import org.hildan.livedoc.core.annotations.ApiMethod;
import org.luxons.sevenwonders.actions.CreateGameAction;
import org.luxons.sevenwonders.actions.JoinGameAction;
import org.luxons.sevenwonders.errors.ApiMisuseException;
@@ -23,7 +22,10 @@ import org.springframework.messaging.simp.annotation.SubscribeMapping;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
-@Api(name = "Game Browser", description = "This is the place where the player looks for a game")
+/**
+ * This is the place where the player looks for a game.
+ */
+@Api(name = "GameBrowser")
@Controller
public class GameBrowserController {
@@ -46,14 +48,31 @@ public class GameBrowserController {
this.template = template;
}
- @ApiMethod(description = "Created or updated games. List of existing games received here on subscribe.")
+ /**
+ * Gets the created or updated games. The list of existing games is received on this topic at once upon
+ * subscription, and then each time the list changes.
+ *
+ * @param principal
+ * the connected user's information
+ *
+ * @return the current list of {@link Lobby}s
+ */
@SubscribeMapping("/games") // prefix /topic not shown
public Collection<Lobby> listGames(Principal principal) {
logger.info("Player '{}' subscribed to /topic/games", principal.getName());
return lobbyRepository.list();
}
- @ApiMethod(description = "Create a new lobby.")
+ /**
+ * Creates a new {@link Lobby}.
+ *
+ * @param action
+ * the action to create the game
+ * @param principal
+ * the connected user's information
+ *
+ * @return the newly created {@link Lobby}
+ */
@MessageMapping("/lobby/create")
@SendToUser("/queue/lobby/joined")
public Lobby createGame(@Validated CreateGameAction action, Principal principal) {
@@ -70,7 +89,16 @@ public class GameBrowserController {
return lobby;
}
- @ApiMethod(description = "Join an existing lobby.")
+ /**
+ * Joins an existing {@link Lobby}.
+ *
+ * @param action
+ * the action to join the game
+ * @param principal
+ * the connected user's information
+ *
+ * @return the {@link Lobby} that has just been joined
+ */
@MessageMapping("/lobby/join")
@SendToUser("/queue/lobby/joined")
public Lobby joinGame(@Validated JoinGameAction action, Principal principal) {
diff --git a/backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java b/backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java
index 41fd13f7..f8d60ece 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java
@@ -4,7 +4,6 @@ import java.security.Principal;
import java.util.List;
import org.hildan.livedoc.core.annotations.Api;
-import org.hildan.livedoc.core.annotations.ApiMethod;
import org.luxons.sevenwonders.actions.PrepareMoveAction;
import org.luxons.sevenwonders.game.Game;
import org.luxons.sevenwonders.game.api.PlayerTurnInfo;
@@ -21,7 +20,10 @@ import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Controller;
-@Api(name = "Game", description = "In-game events management")
+/**
+ * This API is for in-game events management.
+ */
+@Api(name = "Game")
@Controller
public class GameController {
@@ -37,7 +39,12 @@ public class GameController {
this.playerRepository = playerRepository;
}
- @ApiMethod(description = "Notifies the game that the player is ready to receive his hand.")
+ /**
+ * Notifies the game that the player is ready to receive his hand.
+ *
+ * @param principal
+ * the connected user's information
+ */
@MessageMapping("/game/sayReady")
public void ready(Principal principal) {
Player player = playerRepository.find(principal.getName());
@@ -69,8 +76,14 @@ public class GameController {
template.convertAndSend("/topic/game/" + gameId + "/playerReady", player.getUsername());
}
- @ApiMethod(description = "Prepares the player's next move. When all players have prepared their moves, all moves "
- + "are executed.")
+ /**
+ * Prepares the player's next move. When all players have prepared their moves, all moves are executed.
+ *
+ * @param action
+ * the action to prepare the move
+ * @param principal
+ * the connected user's information
+ */
@MessageMapping("/game/prepareMove")
public void prepareMove(PrepareMoveAction action, Principal principal) {
Player player = playerRepository.find(principal.getName());
diff --git a/backend/src/main/java/org/luxons/sevenwonders/controllers/HomeController.java b/backend/src/main/java/org/luxons/sevenwonders/controllers/HomeController.java
index c2b72637..97bc8b67 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/controllers/HomeController.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/controllers/HomeController.java
@@ -3,7 +3,6 @@ package org.luxons.sevenwonders.controllers;
import java.security.Principal;
import org.hildan.livedoc.core.annotations.Api;
-import org.hildan.livedoc.core.annotations.ApiMethod;
import org.luxons.sevenwonders.actions.ChooseNameAction;
import org.luxons.sevenwonders.lobby.Player;
import org.luxons.sevenwonders.repositories.PlayerRepository;
@@ -15,7 +14,10 @@ import org.springframework.messaging.simp.annotation.SendToUser;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
-@Api(name = "Home", description = "The home page of the game")
+/**
+ * Handles actions in the homepage of the game.
+ */
+@Api(name = "Home")
@Controller
public class HomeController {
@@ -28,7 +30,16 @@ public class HomeController {
this.playerRepository = playerRepository;
}
- @ApiMethod(description = "Creates/updates the player's name (for the user's session)")
+ /**
+ * Creates/updates the player's name (for the user's session).
+ *
+ * @param action
+ * the action to choose the name of the player
+ * @param principal
+ * the connected user's information
+ *
+ * @return the created {@link Player} object
+ */
@MessageMapping("/chooseName")
@SendToUser("/queue/nameChoice")
public Player chooseName(@Validated ChooseNameAction action, Principal principal) {
diff --git a/backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java b/backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java
index 2a1d563d..330a0f7f 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java
@@ -4,7 +4,6 @@ import java.security.Principal;
import java.util.Collections;
import org.hildan.livedoc.core.annotations.Api;
-import org.hildan.livedoc.core.annotations.ApiMethod;
import org.luxons.sevenwonders.actions.ReorderPlayersAction;
import org.luxons.sevenwonders.actions.UpdateSettingsAction;
import org.luxons.sevenwonders.errors.ApiMisuseException;
@@ -20,7 +19,10 @@ import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
-@Api(name = "Lobby", description = "The place where players gather before a game")
+/**
+ * Handles actions in the game's lobby. The lobby is the place where players gather before a game.
+ */
+@Api(name = "Lobby")
@Controller
public class LobbyController {
@@ -36,7 +38,12 @@ public class LobbyController {
this.template = template;
}
- @ApiMethod
+ /**
+ * Leaves the current lobby.
+ *
+ * @param principal
+ * the connected user's information
+ */
@MessageMapping("/lobby/leave")
public void leave(Principal principal) {
Lobby lobby = getLobby(principal);
@@ -46,7 +53,14 @@ public class LobbyController {
sendLobbyUpdateToPlayers(lobby);
}
- @ApiMethod
+ /**
+ * Reorders the players in the current lobby. This can only be done by the lobby's owner.
+ *
+ * @param action
+ * the action to reorder the players
+ * @param principal
+ * the connected user's information
+ */
@MessageMapping("/lobby/reorderPlayers")
public void reorderPlayers(@Validated ReorderPlayersAction action, Principal principal) {
Lobby lobby = getOwnedLobby(principal);
@@ -56,7 +70,14 @@ public class LobbyController {
sendLobbyUpdateToPlayers(lobby);
}
- @ApiMethod
+ /**
+ * Updates the game settings. This can only be done by the lobby's owner.
+ *
+ * @param action
+ * the action to update the settings
+ * @param principal
+ * the connected user's information
+ */
@MessageMapping("/lobby/updateSettings")
public void updateSettings(@Validated UpdateSettingsAction action, Principal principal) {
Lobby lobby = getOwnedLobby(principal);
@@ -71,7 +92,12 @@ public class LobbyController {
template.convertAndSend("/topic/games", Collections.singletonList(lobby));
}
- @ApiMethod
+ /**
+ * Starts the game.
+ *
+ * @param principal
+ * the connected user's information
+ */
@MessageMapping("/lobby/startGame")
public void startGame(Principal principal) {
Lobby lobby = getOwnedLobby(principal);
diff --git a/backend/src/main/java/org/luxons/sevenwonders/doc/Documentation.java b/backend/src/main/java/org/luxons/sevenwonders/doc/Documentation.java
new file mode 100644
index 00000000..e27bc2ff
--- /dev/null
+++ b/backend/src/main/java/org/luxons/sevenwonders/doc/Documentation.java
@@ -0,0 +1,6 @@
+package org.luxons.sevenwonders.doc;
+
+public class Documentation {
+
+ public static final String GROUP_ACTIONS = "Actions";
+}
diff --git a/backend/src/main/java/org/luxons/sevenwonders/doc/GlobalDocumentation.java b/backend/src/main/java/org/luxons/sevenwonders/doc/GlobalDocumentation.java
deleted file mode 100644
index 9826a0ba..00000000
--- a/backend/src/main/java/org/luxons/sevenwonders/doc/GlobalDocumentation.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.luxons.sevenwonders.doc;
-
-import org.hildan.livedoc.core.annotations.global.ApiGlobal;
-import org.hildan.livedoc.core.annotations.global.ApiGlobalSection;
-
-@ApiGlobal(sections = {@ApiGlobalSection(title = "First steps", paragraphs = {"Welcome to JsonDoc."})})
-public class GlobalDocumentation {}
bgstack15