Merge remote-tracking branch 'origin/master' into refactor-controllerService
# Conflicts: # src/main/java/mops/gruppen2/service/ControllerService.java
This commit is contained in:
@ -55,6 +55,7 @@ public class WebController {
|
|||||||
* @param model tolles model
|
* @param model tolles model
|
||||||
* @return index.html
|
* @return index.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||||
@GetMapping("")
|
@GetMapping("")
|
||||||
public String index(KeycloakAuthenticationToken token, Model model) throws EventException {
|
public String index(KeycloakAuthenticationToken token, Model model) throws EventException {
|
||||||
@ -325,6 +326,7 @@ public class WebController {
|
|||||||
@RequestParam("group_id") String groupId,
|
@RequestParam("group_id") String groupId,
|
||||||
KeycloakAuthenticationToken token) {
|
KeycloakAuthenticationToken token) {
|
||||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||||
|
validationService.checkIfNewMaximumIsValid(maximum, groupId);
|
||||||
controllerService.updateMaxUser(account, UUID.fromString(groupId), maximum);
|
controllerService.updateMaxUser(account, UUID.fromString(groupId), maximum);
|
||||||
return "redirect:/gruppen2/details/members/" + groupId;
|
return "redirect:/gruppen2/details/members/" + groupId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public class UpdateGroupDescriptionEvent extends Event {
|
|||||||
|
|
||||||
public UpdateGroupDescriptionEvent(UUID groupId, String userId, String newGroupDescription) {
|
public UpdateGroupDescriptionEvent(UUID groupId, String userId, String newGroupDescription) {
|
||||||
super(groupId, userId);
|
super(groupId, userId);
|
||||||
this.newGroupDescription = newGroupDescription;
|
this.newGroupDescription = newGroupDescription.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public class UpdateGroupTitleEvent extends Event {
|
|||||||
|
|
||||||
public UpdateGroupTitleEvent(UUID groupId, String userId, String newGroupTitle) {
|
public UpdateGroupTitleEvent(UUID groupId, String userId, String newGroupTitle) {
|
||||||
super(groupId, userId);
|
super(groupId, userId);
|
||||||
this.newGroupTitle = newGroupTitle;
|
this.newGroupTitle = newGroupTitle.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -4,6 +4,6 @@ import org.springframework.http.HttpStatus;
|
|||||||
|
|
||||||
public class WrongFileException extends EventException {
|
public class WrongFileException extends EventException {
|
||||||
public WrongFileException(String info) {
|
public WrongFileException(String info) {
|
||||||
super(HttpStatus.INTERNAL_SERVER_ERROR, "Die entsprechende Datei ist keine valide CSV-Datei!", info);
|
super(HttpStatus.BAD_REQUEST, "Die entsprechende Datei ist keine valide CSV-Datei!", info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import mops.gruppen2.domain.exception.EventException;
|
|||||||
import mops.gruppen2.domain.exception.UserNotFoundException;
|
import mops.gruppen2.domain.exception.UserNotFoundException;
|
||||||
import mops.gruppen2.domain.exception.WrongFileException;
|
import mops.gruppen2.domain.exception.WrongFileException;
|
||||||
import mops.gruppen2.security.Account;
|
import mops.gruppen2.security.Account;
|
||||||
import org.keycloak.jose.jwk.JWK;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|||||||
@ -130,16 +130,37 @@ public class ValidationService {
|
|||||||
* @param userMaximum Das user Limit der Gruppe
|
* @param userMaximum Das user Limit der Gruppe
|
||||||
*/
|
*/
|
||||||
public void checkFields(String description, String title, Long userMaximum, Boolean maxInfiniteUsers) {
|
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");
|
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");
|
throw new BadParameterException("Der Titel wurde nicht korrekt angegeben");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userMaximum == null && maxInfiniteUsers == null) {
|
if (userMaximum == null && maxInfiniteUsers == null) {
|
||||||
throw new BadParameterException("Teilnehmeranzahl wurde nicht korrekt angegeben");
|
throw new BadParameterException("Teilnehmeranzahl wurde nicht korrekt angegeben");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (userMaximum != null) {
|
||||||
|
if (userMaximum < 1 || userMaximum > 10000L) {
|
||||||
|
throw new BadParameterException("Teilnehmeranzahl wurde nicht korrekt angegeben");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkIfNewMaximumIsValid(Long newUserMaximum, String groupId) {
|
||||||
|
Group group = userService.getGroupById(UUID.fromString(groupId));
|
||||||
|
if (newUserMaximum == null) {
|
||||||
|
throw new BadParameterException("Es wurde keine neue maximale Teilnehmeranzahl angegeben!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newUserMaximum < 1 || newUserMaximum > 10000L) {
|
||||||
|
throw new BadParameterException("Die neue maximale Teilnehmeranzahl wurde nicht korrekt angegeben!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (group.getMembers().size() > newUserMaximum) {
|
||||||
|
throw new BadParameterException("Die neue maximale Teilnehmeranzahl ist kleiner als die aktuelle Teilnehmeranzahl!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user