Class RoomAdminController

java.lang.Object
de.gustavblass.fsu.fmi.roombooking.controller.admin.RoomAdminController

@Controller public class RoomAdminController extends Object
Defines the behaviour of the API server for the path /admin/rooms.
  • Field Details

  • Constructor Details

  • Method Details

    • getCreateRoomForm

      @GetMapping({"/admin/r\u00e4ume/hinzuf\u00fcgen","/en/admin/rooms/add"}) @NonNull public @NonNull String getCreateRoomForm(NewRoomDTO newRoomDTO, @NonNull @NonNull org.springframework.ui.Model model)
      Handles GET requests to /admin/rooms/add.
      Parameters:
      newRoomDTO - An empty NewRoomDTO only used for binding in the Thymeleaf template.
      model - Used to add the existing EquipmentTypes to the form.
      Returns:
      The admins' create-room form.
    • createRoom

      @PostMapping({"/admin/r\u00e4ume/hinzuf\u00fcgen","/en/admin/rooms/add"}) @NonNull public @NonNull String createRoom(@Valid @NonNull @Valid @NonNull NewRoomDTO dto, @NonNull @NonNull org.springframework.validation.BindingResult bindingResult, @NonNull @NonNull org.springframework.ui.Model model, @NonNull @NonNull jakarta.servlet.http.HttpServletResponse response) throws IllegalStateException, InvalidIndividualEquipmentException, InvalidCommonEquipmentException, de.gustavblass.commons.exceptions.IllegalArgumentException
      Handles POST requests to /admin/rooms and adds the given NewRoomDTO as a new Room to the database.
      Parameters:
      dto - The data-transfer object that represents the new Room. Must be valid according to the annotations on the class fields. Must have a unique (new) Room.number.
      bindingResult - The result of the DTO validation.
      model - Used to add the existing EquipmentTypes to the form.
      response - The web server's response to the admin's HTTP request.
      Returns:
      In case of success: The room page (e.g. /rooms/42). Otherwise: The form, with the original input preserved and with error messages shown.
      Throws:
      de.gustavblass.commons.exceptions.IllegalArgumentException - If the DTO conversion fails.
      InvalidIndividualEquipmentException - If one of the Room's IndividualEquipmentTypes does not exist in the database.
      InvalidCommonEquipmentException - If one of the Room's CommonEquipmentTypes does not exist in the database.
      IllegalStateException - If the room path is malformed.