Merge branch 'dev' into TEST-api-tests
This commit is contained in:
@ -117,17 +117,4 @@ public class GroupCreationController {
|
||||
|
||||
return "redirect:/gruppen2";
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_actuator"})
|
||||
@PostMapping("/details/members/addUsersFromCsv")
|
||||
@CacheEvict(value = "groups", allEntries = true)
|
||||
public String addUsersFromCsv(KeycloakAuthenticationToken token,
|
||||
@RequestParam("group_id") String groupId,
|
||||
@RequestParam(value = "file", required = false) MultipartFile file) {
|
||||
|
||||
Account account = KeyCloakService.createAccountFromPrincipal(token);
|
||||
controllerService.addUsersFromCsv(account, file, groupId);
|
||||
|
||||
return "redirect:/gruppen2/details/members/" + groupId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
@ -259,4 +260,17 @@ public class GroupDetailsController {
|
||||
|
||||
return "redirect:/gruppen2";
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_actuator"})
|
||||
@PostMapping("/details/members/addUsersFromCsv")
|
||||
@CacheEvict(value = "groups", allEntries = true)
|
||||
public String addUsersFromCsv(KeycloakAuthenticationToken token,
|
||||
@RequestParam("group_id") String groupId,
|
||||
@RequestParam(value = "file", required = false) MultipartFile file) {
|
||||
|
||||
Account account = KeyCloakService.createAccountFromPrincipal(token);
|
||||
controllerService.addUsersFromCsv(account, file, groupId);
|
||||
|
||||
return "redirect:/gruppen2/details/members/" + groupId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ public class GruppenfindungController {
|
||||
Model model) {
|
||||
|
||||
Account account = KeyCloakService.createAccountFromPrincipal(token);
|
||||
//TODO: new Contructor/method
|
||||
User user = new User(account);
|
||||
|
||||
model.addAttribute("account", account);
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package mops.gruppen2.domain.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import mops.gruppen2.domain.Group;
|
||||
@ -16,7 +15,6 @@ import java.util.UUID;
|
||||
* Fügt einen einzelnen Nutzer einer Gruppe hinzu.
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor // For Jackson
|
||||
public class AddUserEvent extends Event {
|
||||
|
||||
@ -33,14 +31,14 @@ public class AddUserEvent extends Event {
|
||||
|
||||
@Override
|
||||
protected void applyEvent(Group group) throws EventException {
|
||||
User user = new User(this.userId, this.givenname, this.familyname, this.email);
|
||||
User user = new User(userId, givenname, familyname, email);
|
||||
|
||||
if (group.getMembers().contains(user)) {
|
||||
throw new UserAlreadyExistsException(this.getClass().toString());
|
||||
throw new UserAlreadyExistsException(getClass().toString());
|
||||
}
|
||||
|
||||
if (group.getMembers().size() >= group.getUserMaximum()) {
|
||||
throw new GroupFullException(this.getClass().toString());
|
||||
throw new GroupFullException(getClass().toString());
|
||||
}
|
||||
|
||||
group.getMembers().add(user);
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package mops.gruppen2.domain.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import mops.gruppen2.domain.Group;
|
||||
@ -10,7 +9,6 @@ import mops.gruppen2.domain.Visibility;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor // For Jackson
|
||||
public class CreateGroupEvent extends Event {
|
||||
|
||||
@ -21,18 +19,18 @@ public class CreateGroupEvent extends Event {
|
||||
|
||||
public CreateGroupEvent(UUID groupId, String userId, UUID parent, GroupType type, Visibility visibility, Long userMaximum) {
|
||||
super(groupId, userId);
|
||||
this.groupParent = parent;
|
||||
this.groupType = type;
|
||||
this.groupVisibility = visibility;
|
||||
this.groupUserMaximum = userMaximum;
|
||||
groupParent = parent;
|
||||
groupType = type;
|
||||
groupVisibility = visibility;
|
||||
groupUserMaximum = userMaximum;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyEvent(Group group) {
|
||||
group.setId(this.groupId);
|
||||
group.setParent(this.groupParent);
|
||||
group.setType(this.groupType);
|
||||
group.setVisibility(this.groupVisibility);
|
||||
group.setUserMaximum(this.groupUserMaximum);
|
||||
group.setId(groupId);
|
||||
group.setParent(groupParent);
|
||||
group.setType(groupType);
|
||||
group.setVisibility(groupVisibility);
|
||||
group.setUserMaximum(groupUserMaximum);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,5 +23,6 @@ public class DeleteGroupEvent extends Event {
|
||||
group.setVisibility(null);
|
||||
group.setType(null);
|
||||
group.setParent(null);
|
||||
group.setUserMaximum(0L);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
package mops.gruppen2.domain.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.exception.NoValueException;
|
||||
import mops.gruppen2.domain.exception.BadParameterException;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -12,7 +11,6 @@ import java.util.UUID;
|
||||
* Ändert nur die Gruppenbeschreibung.
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor // For Jackson
|
||||
public class UpdateGroupDescriptionEvent extends Event {
|
||||
|
||||
@ -25,10 +23,10 @@ public class UpdateGroupDescriptionEvent extends Event {
|
||||
|
||||
@Override
|
||||
protected void applyEvent(Group group) {
|
||||
if (this.newGroupDescription.isEmpty()) {
|
||||
throw new NoValueException(this.getClass().toString());
|
||||
if (newGroupDescription.isEmpty()) {
|
||||
throw new BadParameterException("Die Beschreibung ist leer.");
|
||||
}
|
||||
|
||||
group.setDescription(this.newGroupDescription);
|
||||
group.setDescription(newGroupDescription);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
package mops.gruppen2.domain.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.exception.NoValueException;
|
||||
import mops.gruppen2.domain.exception.BadParameterException;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -12,7 +11,6 @@ import java.util.UUID;
|
||||
* Ändert nur den Gruppentitel.
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor // For Jackson
|
||||
public class UpdateGroupTitleEvent extends Event {
|
||||
|
||||
@ -26,7 +24,7 @@ public class UpdateGroupTitleEvent extends Event {
|
||||
@Override
|
||||
protected void applyEvent(Group group) {
|
||||
if (newGroupTitle.isEmpty()) {
|
||||
throw new NoValueException(getClass().toString());
|
||||
throw new BadParameterException("Der Titel ist leer.");
|
||||
}
|
||||
|
||||
group.setTitle(newGroupTitle);
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package mops.gruppen2.domain.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import mops.gruppen2.domain.Group;
|
||||
@ -13,7 +12,6 @@ import java.util.UUID;
|
||||
* Aktualisiert die Gruppenrolle eines Teilnehmers.
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor // For Jackson
|
||||
public class UpdateRoleEvent extends Event {
|
||||
|
||||
@ -26,12 +24,12 @@ public class UpdateRoleEvent extends Event {
|
||||
|
||||
@Override
|
||||
protected void applyEvent(Group group) throws UserNotFoundException {
|
||||
if (group.getRoles().containsKey(this.userId)) {
|
||||
group.getRoles().put(this.userId, this.newRole);
|
||||
if (group.getRoles().containsKey(userId)) {
|
||||
group.getRoles().put(userId, newRole);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new UserNotFoundException(this.getClass().toString());
|
||||
throw new UserNotFoundException(getClass().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
package mops.gruppen2.domain.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.exception.BadParameterException;
|
||||
import mops.gruppen2.domain.exception.EventException;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpdateUserMaxEvent extends Event {
|
||||
|
||||
@ -22,6 +21,10 @@ public class UpdateUserMaxEvent extends Event {
|
||||
|
||||
@Override
|
||||
protected void applyEvent(Group group) throws EventException {
|
||||
if (userMaximum <= 0 || userMaximum < group.getMembers().size()) {
|
||||
throw new BadParameterException("Usermaximum zu klein.");
|
||||
}
|
||||
|
||||
group.setUserMaximum(userMaximum);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
package mops.gruppen2.domain.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
public class NoValueException extends EventException {
|
||||
|
||||
public NoValueException(String info) {
|
||||
super(HttpStatus.BAD_REQUEST, "Eine Information fehlt.", info);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user