1

refactor ValidationService

This commit is contained in:
killerber4t
2020-03-25 16:52:43 +01:00
parent 9045cace9c
commit 57df0263d4
4 changed files with 9 additions and 4 deletions

View File

@ -46,6 +46,7 @@ public class WebController {
* @param model tolles model
* @return index.html
*/
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
@GetMapping("")
public String index(KeycloakAuthenticationToken token, Model model) throws EventException {

View File

@ -20,7 +20,7 @@ public class UpdateGroupDescriptionEvent extends Event {
public UpdateGroupDescriptionEvent(UUID groupId, String userId, String newGroupDescription) {
super(groupId, userId);
this.newGroupDescription = newGroupDescription;
this.newGroupDescription = newGroupDescription.trim();
}
@Override

View File

@ -20,7 +20,7 @@ public class UpdateGroupTitleEvent extends Event {
public UpdateGroupTitleEvent(UUID groupId, String userId, String newGroupTitle) {
super(groupId, userId);
this.newGroupTitle = newGroupTitle;
this.newGroupTitle = newGroupTitle.trim();
}
@Override

View File

@ -123,16 +123,20 @@ public class ValidationService {
* @param userMaximum
*/
public void checkFields(String description, String title, Long userMaximum, Boolean maxInfiniteUsers) {
if (description == null) {
if (description == null || description.trim().length() == 0) {
throw new BadParameterException("Die Beschreibung wurde nicht korrekt angegeben");
}
if (title == null) {
if (title == null || title.trim().length() == 0) {
throw new BadParameterException("Der Titel wurde nicht korrekt angegeben");
}
if (userMaximum == null && maxInfiniteUsers == null) {
throw new BadParameterException("Teilnehmeranzahl wurde nicht korrekt angegeben");
}
if (userMaximum < 1 || userMaximum > 10000L) {
throw new BadParameterException("Teilnehmeranzahl wurde nicht korrekt angegeben");
}
}
}