further refactor of eventhandling
Co-Authored-By: Talha Caliskan <killerber4t@users.noreply.github.com> Co-Authored-By: tomvahl <tomvahl@users.noreply.github.com> Co-Authored-By: xxnitram <xxnitram@users.noreply.github.com> Co-Authored-By: kasch309 <kasch309@users.noreply.github.com>
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package mops.gruppen2.domain.event;
|
||||
|
||||
import lombok.*;
|
||||
import mops.gruppen2.domain.Exceptions.EventException;
|
||||
import mops.gruppen2.domain.Exceptions.UserNotFoundException;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.Role;
|
||||
@ -17,19 +18,14 @@ import java.util.Optional;
|
||||
public class UpdateRoleEvent extends Event {
|
||||
|
||||
Role newRole;
|
||||
|
||||
public UpdateRoleEvent(Long event_id, Long group_id, String user_id, Role newRole) {
|
||||
super(event_id, group_id, user_id);
|
||||
this.newRole = newRole;
|
||||
}
|
||||
|
||||
public UpdateRoleEvent(Long group_id, String user_id, Role newRole) {
|
||||
super(group_id, user_id);
|
||||
this.newRole = newRole;
|
||||
}
|
||||
|
||||
private void apply(Group group) throws UserNotFoundException {
|
||||
User user;
|
||||
public void apply(Group group) {
|
||||
User user = new User(user_id, null, null, null);
|
||||
|
||||
Optional<User> userOptional = group.getMembers().stream()
|
||||
.filter(u -> u.getUser_id().equals(user_id))
|
||||
@ -38,7 +34,6 @@ public class UpdateRoleEvent extends Event {
|
||||
if (userOptional.isPresent()) {
|
||||
user = userOptional.get();
|
||||
} else {
|
||||
throw new UserNotFoundException("Nutzer wurde nicht gefunden!");
|
||||
}
|
||||
|
||||
if (group.getRoles().containsKey(user) && newRole == Role.MEMBER) {
|
||||
|
||||
Reference in New Issue
Block a user