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.context.annotation.SessionScope;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.security.RolesAllowed;
import java.io.CharConversionException;
import java.io.IOException;
@ -97,13 +98,13 @@ public class Gruppen2Controller {
Account account = keyCloakService.createAccountFromPrincipal(token);
List<User> userList = new ArrayList<>();
if(userMaximum == null){
if (userMaximum == null) {
userMaximum = 100000L;
}
if (!file.isEmpty()) {
try {
userList = CsvService.read(file.getInputStream());
if(userList.size() > userMaximum){
if (userList.size() > userMaximum) {
userMaximum = (long) userList.size() + userMaximum;
}
} catch (UnrecognizedPropertyException | CharConversionException ex) {
@ -161,8 +162,8 @@ public class Gruppen2Controller {
if (!file.isEmpty()) {
try {
userList = CsvService.read(file.getInputStream());
if(userList.size()+group.getMembers().size()>group.getUserMaximum()){
controllerService.updateMaxUser(account, groupId, Long.valueOf(userList.size()) + group.getMembers().size());
if (userList.size() + group.getMembers().size() > group.getUserMaximum()) {
controllerService.updateMaxUser(account, UUID.fromString(groupId), (long) userList.size() + group.getMembers().size());
}
} catch (UnrecognizedPropertyException | CharConversionException ex) {
throw new WrongFileException(file.getOriginalFilename());
@ -334,7 +335,7 @@ public class Gruppen2Controller {
} else {
return "redirect:/details/";
}
}else {
} else {
return "privateGroupNoMember";
}
}
@ -361,10 +362,10 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
@PostMapping("/details/members/changeMaximum")
public String changeMaxSize(@RequestParam("maximum") Long maximum,
@RequestParam("group_id") Long groupId,
KeycloakAuthenticationToken token){
@RequestParam("group_id") String groupId,
KeycloakAuthenticationToken token) {
Account account = keyCloakService.createAccountFromPrincipal(token);
controllerService.updateMaxUser(account, groupId, maximum);
controllerService.updateMaxUser(account, UUID.fromString(groupId), maximum);
return "redirect:/gruppen2/details/members/" + groupId;
}

View File

@ -6,6 +6,8 @@ import lombok.NoArgsConstructor;
import mops.gruppen2.domain.Group;
import mops.gruppen2.domain.exception.EventException;
import java.util.UUID;
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ -13,8 +15,8 @@ public class UpdateUserMaxEvent extends Event {
private Long userMaximum;
public UpdateUserMaxEvent(Long group_id, String user_id, Long userMaximum) {
super(group_id,user_id);
public UpdateUserMaxEvent(UUID group_id, String user_id, Long userMaximum) {
super(group_id, user_id);
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.UpdateGroupTitleEvent;
import mops.gruppen2.domain.event.UpdateRoleEvent;
import mops.gruppen2.domain.event.UpdateUserMaxEvent;
import mops.gruppen2.domain.exception.EventException;
import mops.gruppen2.domain.exception.UserNotFoundException;
import mops.gruppen2.security.Account;
@ -130,8 +131,8 @@ public class ControllerService {
eventService.saveEvent(updateGroupDescriptionEvent);
}
public void updateMaxUser(Account account, Long groupId, Long userMaximum) {
UpdateUserMaxEvent updateUserMaxEvent = new UpdateUserMaxEvent(groupId,account.getName(),userMaximum);
public void updateMaxUser(Account account, UUID groupId, Long userMaximum) {
UpdateUserMaxEvent updateUserMaxEvent = new UpdateUserMaxEvent(groupId, account.getName(), userMaximum);
eventService.saveEvent(updateUserMaxEvent);
}

View File

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