1

Exception rework: clearer message + origin

Co-authored-by: [Mahgs] <maxoerter@gmx.de>
Co-authored-by: Christoph <tobi@urpost.de>
This commit is contained in:
Christoph
2020-03-18 18:49:40 +01:00
parent 2d8472bd4a
commit b1460abe48
20 changed files with 76 additions and 111 deletions

View File

@ -2,19 +2,17 @@ package mops.gruppen2.controller;
import mops.gruppen2.config.Gruppen2Config;
import mops.gruppen2.domain.Exceptions.EventException;
import mops.gruppen2.domain.Exceptions.GroupNotFoundException;
import mops.gruppen2.domain.Group;
import mops.gruppen2.domain.Role;
import mops.gruppen2.domain.User;
import mops.gruppen2.domain.Visibility;
import mops.gruppen2.domain.event.CreateGroupEvent;
import mops.gruppen2.security.Account;
import mops.gruppen2.service.*;
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.annotation.SessionScope;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.server.ResponseStatusException;
@ -33,15 +31,13 @@ public class Gruppen2Controller {
Gruppen2Config gruppen2Config;
private final KeyCloakService keyCloakService;
private final EventService eventService;
private final GroupService groupService;
private final UserService userService;
private final ControllerService controllerService;
private final InviteLinkRepositoryService inviteLinkRepositoryService;
public Gruppen2Controller(KeyCloakService keyCloakService, EventService eventService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService) {
public Gruppen2Controller(KeyCloakService keyCloakService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService) {
this.keyCloakService = keyCloakService;
this.eventService = eventService;
this.groupService = groupService;
this.userService = userService;
this.controllerService = controllerService;
@ -138,7 +134,8 @@ public class Gruppen2Controller {
model.addAttribute("admin", Role.ADMIN);
return "detailsMember";
}
throw new GroupNotFoundException();
throw new GroupNotFoundException(this.getClass().toString());
}
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
@ -162,7 +159,7 @@ public class Gruppen2Controller {
model.addAttribute("group", group);
return "detailsNoMember";
}
throw new GroupNotFoundException();
throw new GroupNotFoundException(this.getClass().toString());
}
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
@ -174,7 +171,7 @@ public class Gruppen2Controller {
model.addAttribute("group", group);
return "redirect:/gruppen2/detailsSearch?id=" + group.getId();
}
throw new GroupNotFoundException();
throw new GroupNotFoundException(this.getClass().toString());
}
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})