1

Merge remote-tracking branch 'origin/master' into csv-error-handling

# Conflicts:
#	src/main/java/mops/gruppen2/controller/Gruppen2Controller.java
#	src/main/java/mops/gruppen2/domain/User.java
#	src/main/java/mops/gruppen2/service/ControllerService.java
#	src/main/resources/templates/createStudent.html
This commit is contained in:
XXNitram
2020-03-19 17:01:32 +01:00
21 changed files with 185 additions and 48 deletions

View File

@ -20,6 +20,7 @@ public class Group {
private Long id;
private String title;
private String description;
private Long userMaximum;
private GroupType type;
private Visibility visibility;
private Long parent;

View File

@ -11,8 +11,8 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(exclude = {"givenname", "familyname", "email"})
public class User {
private String id;
private String givenname;
private String familyname;
private String email;
private String id;
private String givenname;
private String familyname;
private String email;
}

View File

@ -7,6 +7,7 @@ import mops.gruppen2.domain.Group;
import mops.gruppen2.domain.Role;
import mops.gruppen2.domain.User;
import mops.gruppen2.domain.exception.EventException;
import mops.gruppen2.domain.exception.GroupFullException;
import mops.gruppen2.domain.exception.UserAlreadyExistsException;
/**
@ -35,6 +36,10 @@ public class AddUserEvent extends Event {
if (group.getMembers().contains(user)) {
throw new UserAlreadyExistsException(this.getClass().toString());
}
//andere exception
if (group.getMembers().size() == group.getUserMaximum()){
throw new GroupFullException(this.getClass().toString());
}
group.getMembers().add(user);
group.getRoles().put(userId, Role.MEMBER);

View File

@ -15,12 +15,14 @@ public class CreateGroupEvent extends Event {
private Visibility groupVisibility;
private Long groupParent;
private GroupType groupType;
private Long groupUserMaximum;
public CreateGroupEvent(Long groupId, String userId, Long parent, GroupType type, Visibility visibility) {
public CreateGroupEvent(Long groupId, String userId, Long parent, GroupType type, Visibility visibility, Long userMaximum) {
super(groupId, userId);
this.groupParent = parent;
this.groupType = type;
this.groupVisibility = visibility;
this.groupUserMaximum = userMaximum;
}
@Override
@ -29,5 +31,6 @@ public class CreateGroupEvent extends Event {
group.setParent(this.groupParent);
group.setType(this.groupType);
group.setVisibility(this.groupVisibility);
group.setUserMaximum(this.groupUserMaximum);
}
}

View File

@ -0,0 +1,11 @@
package mops.gruppen2.domain.exception;
import org.springframework.http.HttpStatus;
public class GroupFullException extends EventException {
public GroupFullException(String info) {
super(HttpStatus.INTERNAL_SERVER_ERROR, "Der User existiert bereits.", info);
}
}

View File

@ -0,0 +1,10 @@
package mops.gruppen2.domain.exception;
import org.springframework.http.HttpStatus;
public class NoAdminAfterActionException extends EventException {
public NoAdminAfterActionException(String info) {
super(HttpStatus.INTERNAL_SERVER_ERROR, "Nach dieser Aktion hätte die Gruppe keinen Admin mehr", info);
}
}