Class ActorAdminRestController
java.lang.Object
de.gustavblass.fsu.fmi.roombooking.controller.admin.ActorAdminRestController
Defines the behaviour of the API server for the path
/api/v1/admin/users.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ActorServiceUsed to retrieve and save Actors from the database. -
Constructor Summary
ConstructorsConstructorDescriptionActorAdminRestController(@NonNull ActorService actorService) Constructs a newActorRestControllerwith the givenactorService. -
Method Summary
Modifier and TypeMethodDescription@NonNull org.springframework.http.ResponseEntity<Void> createActor(@Valid LocalActorCreatedByAdminDTO dto) HandlesPOSTrequests to/api/v1/admin/usersand saves a newActorbased on the form input (represented as anActorCreatedByAdminDTO) to the database.@NonNull org.springframework.http.ResponseEntity<Void> deleteActor(String userName) HandlesDELETErequests to/api/v1/admin/users/{userName}and removes theActorwith the givenActor.userNamefrom the database.
-
Field Details
-
actorService
Used to retrieve and save Actors from the database.
-
-
Constructor Details
-
ActorAdminRestController
Constructs a newActorRestControllerwith the givenactorService.- Parameters:
actorService- TheactorServiceto use for database access.
-
-
Method Details
-
createActor
@PostMapping("/api/v1/admin/users") @NonNull public @NonNull org.springframework.http.ResponseEntity<Void> createActor(@RequestBody @Valid @Valid LocalActorCreatedByAdminDTO dto) throws UnauthorisedException, PasswordNotConfirmedException, AlreadyExistsException, de.gustavblass.commons.exceptions.IllegalArgumentException HandlesPOSTrequests to/api/v1/admin/usersand saves a newActorbased on the form input (represented as anActorCreatedByAdminDTO) to the database. Validates the input according to the annotations inActorCreatedByAdminDTO.- Parameters:
dto- The form input by the admin, represented as a data-transfer object.- Returns:
- Empty response. Only the status code indicates success.
- Throws:
AlreadyExistsException- If theActorCreatedByAdminDTO.userNameis already taken.UnauthorisedException- If the end user making the request is not permitted to create Actors with the ActorRole that the given DTO has.PasswordNotConfirmedException- If theLocalActorCreatedByAdminDTO.repeatedPassworddoes not match theLocalActorCreatedByAdminDTO.password.de.gustavblass.commons.exceptions.IllegalArgumentException- If noLocalActorCreatedByAdminDTO.passwordis set.
-
deleteActor
@DeleteMapping("/api/v1/admin/users/{userName}") @NonNull public @NonNull org.springframework.http.ResponseEntity<Void> deleteActor(@PathVariable String userName) throws UnauthorisedException, ActorStillHasReservationsException, NotFoundException Handles
DELETErequests to/api/v1/admin/users/{userName}and removes theActorwith the givenActor.userNamefrom the database.The Actor to be deleted must not still have active Reservations that begin or end after the current time.
- Parameters:
userName- The user name whose corresponding user shall no longer be registered with the system.- Returns:
- Empty response. Only the status code indicates success.
- Throws:
NotFoundException- If no user with the given user name exists.UnauthorisedException- If the end user making the request is not permitted to delete Actors with theActorRolethat the Actor concerned has.ActorStillHasReservationsException- If the given Actor still has Reservations.
-