1

some uuid improvements

This commit is contained in:
Christoph
2020-03-24 14:37:23 +01:00
parent 2f8a044c53
commit 5c6d94753b
4 changed files with 17 additions and 12 deletions

View File

@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.annotation.SessionScope; import org.springframework.web.context.annotation.SessionScope;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.security.RolesAllowed; import javax.annotation.security.RolesAllowed;
import java.io.CharConversionException; import java.io.CharConversionException;
import java.io.IOException; import java.io.IOException;
@ -162,7 +163,7 @@ public class Gruppen2Controller {
try { try {
userList = CsvService.read(file.getInputStream()); userList = CsvService.read(file.getInputStream());
if (userList.size() + group.getMembers().size() > group.getUserMaximum()) { if (userList.size() + group.getMembers().size() > group.getUserMaximum()) {
controllerService.updateMaxUser(account, groupId, Long.valueOf(userList.size()) + group.getMembers().size()); controllerService.updateMaxUser(account, UUID.fromString(groupId), (long) userList.size() + group.getMembers().size());
} }
} catch (UnrecognizedPropertyException | CharConversionException ex) { } catch (UnrecognizedPropertyException | CharConversionException ex) {
throw new WrongFileException(file.getOriginalFilename()); throw new WrongFileException(file.getOriginalFilename());
@ -361,10 +362,10 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"}) @RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
@PostMapping("/details/members/changeMaximum") @PostMapping("/details/members/changeMaximum")
public String changeMaxSize(@RequestParam("maximum") Long maximum, public String changeMaxSize(@RequestParam("maximum") Long maximum,
@RequestParam("group_id") Long groupId, @RequestParam("group_id") String groupId,
KeycloakAuthenticationToken token) { KeycloakAuthenticationToken token) {
Account account = keyCloakService.createAccountFromPrincipal(token); Account account = keyCloakService.createAccountFromPrincipal(token);
controllerService.updateMaxUser(account, groupId, maximum); controllerService.updateMaxUser(account, UUID.fromString(groupId), maximum);
return "redirect:/gruppen2/details/members/" + groupId; return "redirect:/gruppen2/details/members/" + groupId;
} }

View File

@ -6,6 +6,8 @@ import lombok.NoArgsConstructor;
import mops.gruppen2.domain.Group; import mops.gruppen2.domain.Group;
import mops.gruppen2.domain.exception.EventException; import mops.gruppen2.domain.exception.EventException;
import java.util.UUID;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ -13,7 +15,7 @@ public class UpdateUserMaxEvent extends Event {
private Long userMaximum; private Long userMaximum;
public UpdateUserMaxEvent(Long group_id, String user_id, Long userMaximum) { public UpdateUserMaxEvent(UUID group_id, String user_id, Long userMaximum) {
super(group_id, user_id); super(group_id, user_id);
this.userMaximum = userMaximum; this.userMaximum = userMaximum;
} }

View File

@ -12,6 +12,7 @@ import mops.gruppen2.domain.event.DeleteUserEvent;
import mops.gruppen2.domain.event.UpdateGroupDescriptionEvent; import mops.gruppen2.domain.event.UpdateGroupDescriptionEvent;
import mops.gruppen2.domain.event.UpdateGroupTitleEvent; import mops.gruppen2.domain.event.UpdateGroupTitleEvent;
import mops.gruppen2.domain.event.UpdateRoleEvent; import mops.gruppen2.domain.event.UpdateRoleEvent;
import mops.gruppen2.domain.event.UpdateUserMaxEvent;
import mops.gruppen2.domain.exception.EventException; import mops.gruppen2.domain.exception.EventException;
import mops.gruppen2.domain.exception.UserNotFoundException; import mops.gruppen2.domain.exception.UserNotFoundException;
import mops.gruppen2.security.Account; import mops.gruppen2.security.Account;
@ -130,7 +131,7 @@ public class ControllerService {
eventService.saveEvent(updateGroupDescriptionEvent); eventService.saveEvent(updateGroupDescriptionEvent);
} }
public void updateMaxUser(Account account, Long groupId, Long userMaximum) { public void updateMaxUser(Account account, UUID groupId, Long userMaximum) {
UpdateUserMaxEvent updateUserMaxEvent = new UpdateUserMaxEvent(groupId, account.getName(), userMaximum); UpdateUserMaxEvent updateUserMaxEvent = new UpdateUserMaxEvent(groupId, account.getName(), userMaximum);
eventService.saveEvent(updateUserMaxEvent); eventService.saveEvent(updateUserMaxEvent);
} }

View File

@ -99,6 +99,7 @@ public class GroupService {
List<Group> visibleGroups = projectEventList(createEvents); List<Group> visibleGroups = projectEventList(createEvents);
return visibleGroups.parallelStream() return visibleGroups.parallelStream()
.filter(group -> group.getType() != null)
.filter(group -> group.getType() == GroupType.LECTURE) .filter(group -> group.getType() == GroupType.LECTURE)
.filter(group -> group.getVisibility() == Visibility.PUBLIC) .filter(group -> group.getVisibility() == Visibility.PUBLIC)
.collect(Collectors.toList()); .collect(Collectors.toList());