Merge pull request #149 from hhu-propra2/invite-link-update
Invite link update
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -33,4 +33,4 @@ out/
|
|||||||
.floo
|
.floo
|
||||||
.flooignore
|
.flooignore
|
||||||
|
|
||||||
/mysql/*
|
/mysql/db/storage/
|
||||||
|
@ -226,7 +226,6 @@
|
|||||||
<property name="lineWrappingIndentation" value="8"/>
|
<property name="lineWrappingIndentation" value="8"/>
|
||||||
<property name="arrayInitIndent" value="4"/>
|
<property name="arrayInitIndent" value="4"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="OverloadMethodsDeclarationOrder"/>
|
|
||||||
<module name="VariableDeclarationUsageDistance"/>
|
<module name="VariableDeclarationUsageDistance"/>
|
||||||
<module name="MethodParamPad">
|
<module name="MethodParamPad">
|
||||||
<property name="tokens"
|
<property name="tokens"
|
||||||
|
@ -6,3 +6,10 @@ CREATE TABLE event
|
|||||||
event_type VARCHAR(36),
|
event_type VARCHAR(36),
|
||||||
event_payload JSON
|
event_payload JSON
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE invite
|
||||||
|
(
|
||||||
|
invite_id INT PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
group_id VARCHAR(36) NOT NULL,
|
||||||
|
invite_link VARCHAR(36) NOT NULL
|
||||||
|
);
|
||||||
|
@ -2,6 +2,7 @@ package mops.gruppen2;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
@ -14,6 +15,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@EnableCaching
|
||||||
@EnableSwagger2
|
@EnableSwagger2
|
||||||
public class Gruppen2Application {
|
public class Gruppen2Application {
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ import mops.gruppen2.domain.exception.EventException;
|
|||||||
import mops.gruppen2.service.APIFormatterService;
|
import mops.gruppen2.service.APIFormatterService;
|
||||||
import mops.gruppen2.service.EventService;
|
import mops.gruppen2.service.EventService;
|
||||||
import mops.gruppen2.service.GroupService;
|
import mops.gruppen2.service.GroupService;
|
||||||
|
import mops.gruppen2.service.UserService;
|
||||||
|
import org.springframework.security.access.annotation.Secured;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -28,14 +30,16 @@ public class APIController {
|
|||||||
|
|
||||||
private final EventService eventService;
|
private final EventService eventService;
|
||||||
private final GroupService groupService;
|
private final GroupService groupService;
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
public APIController(EventService eventService, GroupService groupService) {
|
public APIController(EventService eventService, GroupService groupService, UserService userService) {
|
||||||
this.eventService = eventService;
|
this.eventService = eventService;
|
||||||
this.groupService = groupService;
|
this.groupService = groupService;
|
||||||
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/updateGroups/{status}")
|
@GetMapping("/updateGroups/{status}")
|
||||||
//@Secured("ROLE_api_user")
|
@Secured("ROLE_api_user")
|
||||||
@ApiOperation("Gibt alle Gruppen zurück in denen sich etwas geändert hat")
|
@ApiOperation("Gibt alle Gruppen zurück in denen sich etwas geändert hat")
|
||||||
public GroupRequestWrapper updateGroup(@ApiParam("Letzter Status des Anfragestellers") @PathVariable Long status) throws EventException {
|
public GroupRequestWrapper updateGroup(@ApiParam("Letzter Status des Anfragestellers") @PathVariable Long status) throws EventException {
|
||||||
List<Event> events = eventService.getNewEvents(status);
|
List<Event> events = eventService.getNewEvents(status);
|
||||||
@ -44,16 +48,16 @@ public class APIController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getGroupIdsOfUser/{teilnehmer}")
|
@GetMapping("/getGroupIdsOfUser/{teilnehmer}")
|
||||||
//@Secured("ROLE_api_user")
|
@Secured("ROLE_api_user")
|
||||||
@ApiOperation("Gibt alle Gruppen zurück in denen sich ein Teilnehmer befindet")
|
@ApiOperation("Gibt alle Gruppen zurück in denen sich ein Teilnehmer befindet")
|
||||||
public List<String> getGroupsOfUser(@ApiParam("Teilnehmer dessen groupIds zurückgegeben werden sollen") @PathVariable String teilnehmer) {
|
public List<String> getGroupsOfUser(@ApiParam("Teilnehmer dessen groupIds zurückgegeben werden sollen") @PathVariable String teilnehmer) {
|
||||||
return eventService.findGroupIdsByUser(teilnehmer).stream()
|
return userService.getUserGroups(teilnehmer).stream()
|
||||||
.map(UUID::toString)
|
.map(group -> group.getId().toString())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getGroup/{groupId}")
|
@GetMapping("/getGroup/{groupId}")
|
||||||
//@Secured("ROLE_api_user")
|
@Secured("ROLE_api_user")
|
||||||
@ApiOperation("Gibt die Gruppe mit der als Parameter mitgegebenden groupId zurück")
|
@ApiOperation("Gibt die Gruppe mit der als Parameter mitgegebenden groupId zurück")
|
||||||
public Group getGroupFromId(@ApiParam("GruppenId der gefordeten Gruppe") @PathVariable String groupId) throws EventException {
|
public Group getGroupFromId(@ApiParam("GruppenId der gefordeten Gruppe") @PathVariable String groupId) throws EventException {
|
||||||
List<Event> eventList = eventService.getEventsOfGroup(UUID.fromString(groupId));
|
List<Event> eventList = eventService.getEventsOfGroup(UUID.fromString(groupId));
|
||||||
|
@ -3,15 +3,18 @@ package mops.gruppen2.controller;
|
|||||||
import mops.gruppen2.domain.Group;
|
import mops.gruppen2.domain.Group;
|
||||||
import mops.gruppen2.domain.Role;
|
import mops.gruppen2.domain.Role;
|
||||||
import mops.gruppen2.domain.User;
|
import mops.gruppen2.domain.User;
|
||||||
|
import mops.gruppen2.domain.Visibility;
|
||||||
import mops.gruppen2.domain.exception.EventException;
|
import mops.gruppen2.domain.exception.EventException;
|
||||||
import mops.gruppen2.domain.exception.PageNotFoundException;
|
import mops.gruppen2.domain.exception.PageNotFoundException;
|
||||||
import mops.gruppen2.security.Account;
|
import mops.gruppen2.security.Account;
|
||||||
import mops.gruppen2.service.ControllerService;
|
import mops.gruppen2.service.ControllerService;
|
||||||
import mops.gruppen2.service.GroupService;
|
import mops.gruppen2.service.GroupService;
|
||||||
|
import mops.gruppen2.service.InviteService;
|
||||||
import mops.gruppen2.service.KeyCloakService;
|
import mops.gruppen2.service.KeyCloakService;
|
||||||
import mops.gruppen2.service.UserService;
|
import mops.gruppen2.service.UserService;
|
||||||
import mops.gruppen2.service.ValidationService;
|
import mops.gruppen2.service.ValidationService;
|
||||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -39,13 +42,15 @@ public class WebController {
|
|||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final ControllerService controllerService;
|
private final ControllerService controllerService;
|
||||||
private final ValidationService validationService;
|
private final ValidationService validationService;
|
||||||
|
private final InviteService inviteService;
|
||||||
|
|
||||||
public WebController(KeyCloakService keyCloakService, GroupService groupService, UserService userService, ControllerService controllerService, ValidationService validationService) {
|
public WebController(KeyCloakService keyCloakService, GroupService groupService, UserService userService, ControllerService controllerService, ValidationService validationService, InviteService inviteService) {
|
||||||
this.keyCloakService = keyCloakService;
|
this.keyCloakService = keyCloakService;
|
||||||
this.groupService = groupService;
|
this.groupService = groupService;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.controllerService = controllerService;
|
this.controllerService = controllerService;
|
||||||
this.validationService = validationService;
|
this.validationService = validationService;
|
||||||
|
this.inviteService = inviteService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +60,6 @@ public class WebController {
|
|||||||
* @param model tolles model
|
* @param model tolles model
|
||||||
* @return index.html
|
* @return index.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||||
@GetMapping("")
|
@GetMapping("")
|
||||||
public String index(KeycloakAuthenticationToken token, Model model) throws EventException {
|
public String index(KeycloakAuthenticationToken token, Model model) throws EventException {
|
||||||
@ -78,6 +82,7 @@ public class WebController {
|
|||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
|
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
|
||||||
@PostMapping("/createOrga")
|
@PostMapping("/createOrga")
|
||||||
|
@CacheEvict(value = "groups", allEntries = true)
|
||||||
public String postCrateGroupAsOrga(KeycloakAuthenticationToken token,
|
public String postCrateGroupAsOrga(KeycloakAuthenticationToken token,
|
||||||
@RequestParam("title") String title,
|
@RequestParam("title") String title,
|
||||||
@RequestParam("description") String description,
|
@RequestParam("description") String description,
|
||||||
@ -108,6 +113,7 @@ public class WebController {
|
|||||||
|
|
||||||
@RolesAllowed({"ROLE_studentin"})
|
@RolesAllowed({"ROLE_studentin"})
|
||||||
@PostMapping("/createStudent")
|
@PostMapping("/createStudent")
|
||||||
|
@CacheEvict(value = "groups", allEntries = true)
|
||||||
public String postCreateGroupAsStudent(KeycloakAuthenticationToken token,
|
public String postCreateGroupAsStudent(KeycloakAuthenticationToken token,
|
||||||
@RequestParam("title") String title,
|
@RequestParam("title") String title,
|
||||||
@RequestParam("description") String description,
|
@RequestParam("description") String description,
|
||||||
@ -125,6 +131,7 @@ public class WebController {
|
|||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
|
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
|
||||||
@PostMapping("/details/members/addUsersFromCsv")
|
@PostMapping("/details/members/addUsersFromCsv")
|
||||||
|
@CacheEvict(value = "groups", allEntries = true)
|
||||||
public String addUsersFromCsv(KeycloakAuthenticationToken token,
|
public String addUsersFromCsv(KeycloakAuthenticationToken token,
|
||||||
@RequestParam("group_id") String groupId,
|
@RequestParam("group_id") String groupId,
|
||||||
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException {
|
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException {
|
||||||
@ -164,6 +171,7 @@ public class WebController {
|
|||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||||
@PostMapping("/details/changeMetadata")
|
@PostMapping("/details/changeMetadata")
|
||||||
|
@CacheEvict(value = "groups", allEntries = true)
|
||||||
public String pChangeMetadata(KeycloakAuthenticationToken token,
|
public String pChangeMetadata(KeycloakAuthenticationToken token,
|
||||||
@RequestParam("title") String title,
|
@RequestParam("title") String title,
|
||||||
@RequestParam("description") String description,
|
@RequestParam("description") String description,
|
||||||
@ -187,12 +195,16 @@ public class WebController {
|
|||||||
groups = validationService.checkSearch(search, groups, account);
|
groups = validationService.checkSearch(search, groups, account);
|
||||||
model.addAttribute("account", account);
|
model.addAttribute("account", account);
|
||||||
model.addAttribute("gruppen", groups);
|
model.addAttribute("gruppen", groups);
|
||||||
|
model.addAttribute("inviteService", inviteService);
|
||||||
return "search";
|
return "search";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||||
@GetMapping("/details/{id}")
|
@GetMapping("/details/{id}")
|
||||||
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, HttpServletRequest request, @PathVariable("id") String groupId) throws EventException {
|
public String showGroupDetails(KeycloakAuthenticationToken token,
|
||||||
|
Model model,
|
||||||
|
HttpServletRequest request,
|
||||||
|
@PathVariable("id") String groupId) throws EventException {
|
||||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||||
|
|
||||||
Group group = userService.getGroupById(UUID.fromString(groupId));
|
Group group = userService.getGroupById(UUID.fromString(groupId));
|
||||||
@ -219,13 +231,14 @@ public class WebController {
|
|||||||
|
|
||||||
String actualURL = request.getRequestURL().toString();
|
String actualURL = request.getRequestURL().toString();
|
||||||
String serverURL = actualURL.substring(0, actualURL.indexOf("gruppen2/"));
|
String serverURL = actualURL.substring(0, actualURL.indexOf("gruppen2/"));
|
||||||
model.addAttribute("link", serverURL + "gruppen2/acceptinvite/" + groupId);
|
model.addAttribute("link", serverURL + "gruppen2/acceptinvite/" + inviteService.getLinkByGroupId(group.getId()));
|
||||||
|
|
||||||
return "detailsMember";
|
return "detailsMember";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||||
@PostMapping("/detailsBeitreten")
|
@PostMapping("/detailsBeitreten")
|
||||||
|
@CacheEvict(value = "groups", allEntries = true)
|
||||||
public String joinGroup(KeycloakAuthenticationToken token,
|
public String joinGroup(KeycloakAuthenticationToken token,
|
||||||
Model model, @RequestParam("id") String groupId) throws EventException {
|
Model model, @RequestParam("id") String groupId) throws EventException {
|
||||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||||
@ -234,7 +247,7 @@ public class WebController {
|
|||||||
Group group = userService.getGroupById(UUID.fromString(groupId));
|
Group group = userService.getGroupById(UUID.fromString(groupId));
|
||||||
validationService.checkIfUserInGroupJoin(group, user);
|
validationService.checkIfUserInGroupJoin(group, user);
|
||||||
validationService.checkIfGroupFull(group);
|
validationService.checkIfGroupFull(group);
|
||||||
controllerService.addUser(account, UUID.fromString(groupId));
|
controllerService.addUser(account, group.getId());
|
||||||
return "redirect:/gruppen2/";
|
return "redirect:/gruppen2/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,19 +270,46 @@ public class WebController {
|
|||||||
return "detailsNoMember";
|
return "detailsNoMember";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Muss post-mapping sein
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||||
@GetMapping("/acceptinvite/{groupId}")
|
@GetMapping("/acceptinvite/{link}")
|
||||||
public String acceptInvite(KeycloakAuthenticationToken token,
|
public String acceptInvite(KeycloakAuthenticationToken token,
|
||||||
Model model, @PathVariable String groupId) throws EventException {
|
Model model,
|
||||||
|
@PathVariable("link") String link) throws EventException {
|
||||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||||
Group group = userService.getGroupById(UUID.fromString(groupId));
|
Group group = userService.getGroupById(inviteService.getGroupIdFromLink(link));
|
||||||
validationService.checkGroup(group.getTitle());
|
validationService.checkGroup(group.getTitle());
|
||||||
model.addAttribute("group", group);
|
model.addAttribute("group", group);
|
||||||
return "redirect:/gruppen2/detailsSearch?id=" + group.getId();
|
|
||||||
|
//controllerService.addUser(keyCloakService.createAccountFromPrincipal(token), group.getId());
|
||||||
|
|
||||||
|
if (group.getVisibility() == Visibility.PUBLIC) {
|
||||||
|
return "redirect:/gruppen2/details/" + group.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "joinprivate";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||||
|
@PostMapping("/acceptinvite")
|
||||||
|
@CacheEvict(value = "groups", allEntries = true)
|
||||||
|
public String postAcceptInvite(KeycloakAuthenticationToken token,
|
||||||
|
@RequestParam("id") String groupId) {
|
||||||
|
|
||||||
|
Account acc = keyCloakService.createAccountFromPrincipal(token);
|
||||||
|
|
||||||
|
User user = new User(acc.getName(), acc.getGivenname(), acc.getFamilyname(), acc.getEmail());
|
||||||
|
|
||||||
|
if (!validationService.checkIfUserInGroup(userService.getGroupById(UUID.fromString(groupId)), user)) {
|
||||||
|
controllerService.addUser(keyCloakService.createAccountFromPrincipal(token), UUID.fromString(groupId));
|
||||||
|
}
|
||||||
|
|
||||||
|
return "redirect:/gruppen2/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||||
@PostMapping("/leaveGroup")
|
@PostMapping("/leaveGroup")
|
||||||
|
@CacheEvict(value = "groups", allEntries = true)
|
||||||
public String pLeaveGroup(KeycloakAuthenticationToken token,
|
public String pLeaveGroup(KeycloakAuthenticationToken token,
|
||||||
@RequestParam("group_id") String groupId) throws EventException {
|
@RequestParam("group_id") String groupId) throws EventException {
|
||||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||||
@ -282,6 +322,7 @@ public class WebController {
|
|||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||||
@PostMapping("/deleteGroup")
|
@PostMapping("/deleteGroup")
|
||||||
|
@CacheEvict(value = "groups", allEntries = true)
|
||||||
public String pDeleteGroup(KeycloakAuthenticationToken token,
|
public String pDeleteGroup(KeycloakAuthenticationToken token,
|
||||||
@RequestParam("group_id") String groupId) {
|
@RequestParam("group_id") String groupId) {
|
||||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||||
@ -310,6 +351,7 @@ public class WebController {
|
|||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||||
@PostMapping("/details/members/changeRole")
|
@PostMapping("/details/members/changeRole")
|
||||||
|
@CacheEvict(value = "groups", allEntries = true)
|
||||||
public String changeRole(KeycloakAuthenticationToken token,
|
public String changeRole(KeycloakAuthenticationToken token,
|
||||||
@RequestParam("group_id") String groupId,
|
@RequestParam("group_id") String groupId,
|
||||||
@RequestParam("user_id") String userId) throws EventException {
|
@RequestParam("user_id") String userId) throws EventException {
|
||||||
@ -322,6 +364,7 @@ public class WebController {
|
|||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||||
@PostMapping("/details/members/changeMaximum")
|
@PostMapping("/details/members/changeMaximum")
|
||||||
|
@CacheEvict(value = "groups", allEntries = true)
|
||||||
public String changeMaxSize(@RequestParam("maximum") Long maximum,
|
public String changeMaxSize(@RequestParam("maximum") Long maximum,
|
||||||
@RequestParam("group_id") String groupId,
|
@RequestParam("group_id") String groupId,
|
||||||
KeycloakAuthenticationToken token) {
|
KeycloakAuthenticationToken token) {
|
||||||
@ -333,6 +376,7 @@ public class WebController {
|
|||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||||
@PostMapping("/details/members/deleteUser")
|
@PostMapping("/details/members/deleteUser")
|
||||||
|
@CacheEvict(value = "groups", allEntries = true)
|
||||||
public String deleteUser(@RequestParam("group_id") String groupId,
|
public String deleteUser(@RequestParam("group_id") String groupId,
|
||||||
@RequestParam("user_id") String userId) throws EventException {
|
@RequestParam("user_id") String userId) throws EventException {
|
||||||
User user = new User(userId, "", "", "");
|
User user = new User(userId, "", "", "");
|
||||||
|
@ -11,8 +11,8 @@ import lombok.NoArgsConstructor;
|
|||||||
@EqualsAndHashCode(exclude = {"givenname", "familyname", "email"})
|
@EqualsAndHashCode(exclude = {"givenname", "familyname", "email"})
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String givenname;
|
private String givenname;
|
||||||
private String familyname;
|
private String familyname;
|
||||||
private String email;
|
private String email;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import org.springframework.data.relational.core.mapping.Table;
|
|||||||
public class InviteLinkDTO {
|
public class InviteLinkDTO {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
Long link_id;
|
Long invite_id;
|
||||||
String group_id;
|
String group_id;
|
||||||
String invite_link;
|
String invite_link;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package mops.gruppen2.domain.exception;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
|
public class InvalidInviteException extends EventException {
|
||||||
|
|
||||||
|
public InvalidInviteException(String info) {
|
||||||
|
super(HttpStatus.NOT_FOUND, "Der Einladungslink ist ungültig.", info);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package mops.gruppen2.domain.exception;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
|
public class NoInviteExistException extends EventException {
|
||||||
|
|
||||||
|
public NoInviteExistException(String info) {
|
||||||
|
super(HttpStatus.NOT_FOUND, "Für diese Gruppe existiert kein Link.", info);
|
||||||
|
}
|
||||||
|
}
|
@ -12,15 +12,12 @@ import java.util.List;
|
|||||||
//TODO Rename Queries + Formatting
|
//TODO Rename Queries + Formatting
|
||||||
public interface EventRepository extends CrudRepository<EventDTO, Long> {
|
public interface EventRepository extends CrudRepository<EventDTO, Long> {
|
||||||
|
|
||||||
@Query("select distinct group_id from event where user_id =:id")
|
@Query("SELECT DISTINCT group_id FROM event WHERE user_id = :id")
|
||||||
List<String> findGroup_idsWhereUser_id(@Param("id") String userId);
|
List<String> findGroup_idsWhereUser_id(@Param("id") String userId);
|
||||||
|
|
||||||
@Query("select * from event where group_id =:id")
|
@Query("SELECT * FROM event WHERE group_id = :id")
|
||||||
List<EventDTO> findEventDTOByGroup_id(@Param("id") String groupId);
|
List<EventDTO> findEventDTOByGroup_id(@Param("id") String groupId);
|
||||||
|
|
||||||
//@Query("SELECT * FROM event WHERE event_id > ?#{[0]}")
|
|
||||||
//Iterable<EventDTO> findNewEventSinceStatus(@Param("status") Long status);
|
|
||||||
|
|
||||||
@Query("SELECT DISTINCT group_id FROM event WHERE event_id > :status")
|
@Query("SELECT DISTINCT group_id FROM event WHERE event_id > :status")
|
||||||
List<String> findNewEventSinceStatus(@Param("status") Long status);
|
List<String> findNewEventSinceStatus(@Param("status") Long status);
|
||||||
|
|
||||||
|
20
src/main/java/mops/gruppen2/repository/InviteRepository.java
Normal file
20
src/main/java/mops/gruppen2/repository/InviteRepository.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package mops.gruppen2.repository;
|
||||||
|
|
||||||
|
import mops.gruppen2.domain.dto.InviteLinkDTO;
|
||||||
|
import org.springframework.data.jdbc.repository.query.Query;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface InviteRepository extends CrudRepository<InviteLinkDTO, Long> {
|
||||||
|
|
||||||
|
@Query("SELECT group_id FROM invite WHERE invite_link = :link")
|
||||||
|
String findGroupIdByLink(@Param("link") String link);
|
||||||
|
|
||||||
|
@Query("DELETE FROM invite WHERE group_id = :group")
|
||||||
|
void deleteLinkOfGroup(@Param("group") String group);
|
||||||
|
|
||||||
|
@Query("SELECT invite_link FROM invite WHERE group_id = :group")
|
||||||
|
String findLinkByGroupId(@Param("group") String group);
|
||||||
|
}
|
@ -48,7 +48,7 @@ class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope(scopeName = WebApplicationContext.SCOPE_REQUEST,
|
@Scope(scopeName = WebApplicationContext.SCOPE_REQUEST,
|
||||||
proxyMode = ScopedProxyMode.TARGET_CLASS)
|
proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||||
public AccessToken getAccessToken() {
|
public AccessToken getAccessToken() {
|
||||||
HttpServletRequest request =
|
HttpServletRequest request =
|
||||||
((ServletRequestAttributes) RequestContextHolder
|
((ServletRequestAttributes) RequestContextHolder
|
||||||
@ -61,14 +61,10 @@ class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
|
|||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
super.configure(http);
|
super.configure(http);
|
||||||
http.authorizeRequests()
|
http.authorizeRequests()
|
||||||
.antMatchers("/actuator/**")
|
.antMatchers("/actuator/**")
|
||||||
.hasRole("monitoring")
|
.hasRole("monitoring")
|
||||||
.anyRequest()
|
.anyRequest()
|
||||||
.permitAll()
|
.permitAll();
|
||||||
.and()
|
|
||||||
.csrf()
|
|
||||||
.ignoringAntMatchers("/gruppen2/createOrga")
|
|
||||||
.ignoringAntMatchers("/gruppen2/details/members/addUsersFromCsv");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,11 +38,13 @@ public class ControllerService {
|
|||||||
|
|
||||||
private final EventService eventService;
|
private final EventService eventService;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
|
private final InviteService inviteService;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
|
|
||||||
public ControllerService(EventService eventService, UserService userService) {
|
public ControllerService(EventService eventService, UserService userService, InviteService inviteService) {
|
||||||
this.eventService = eventService;
|
this.eventService = eventService;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
|
this.inviteService = inviteService;
|
||||||
this.logger = Logger.getLogger("controllerServiceLogger");
|
this.logger = Logger.getLogger("controllerServiceLogger");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +68,8 @@ public class ControllerService {
|
|||||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), parent, groupType, groupVisibility, userMaximum);
|
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), parent, groupType, groupVisibility, userMaximum);
|
||||||
eventService.saveEvent(createGroupEvent);
|
eventService.saveEvent(createGroupEvent);
|
||||||
|
|
||||||
|
inviteService.createLink(groupId);
|
||||||
|
|
||||||
addUser(account, groupId);
|
addUser(account, groupId);
|
||||||
updateTitle(account, groupId, title);
|
updateTitle(account, groupId, title);
|
||||||
updateDescription(account, groupId, description);
|
updateDescription(account, groupId, description);
|
||||||
@ -221,6 +225,7 @@ public class ControllerService {
|
|||||||
|
|
||||||
public void deleteGroupEvent(String userId, UUID groupId) {
|
public void deleteGroupEvent(String userId, UUID groupId) {
|
||||||
DeleteGroupEvent deleteGroupEvent = new DeleteGroupEvent(groupId, userId);
|
DeleteGroupEvent deleteGroupEvent = new DeleteGroupEvent(groupId, userId);
|
||||||
|
inviteService.destroyLink(groupId);
|
||||||
eventService.saveEvent(deleteGroupEvent);
|
eventService.saveEvent(deleteGroupEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,6 @@ public class EventService {
|
|||||||
return translateEventDTOs(eventDTOList);
|
return translateEventDTOs(eventDTOList);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Nur AddUserEvents betrachten
|
|
||||||
public List<UUID> findGroupIdsByUser(String userId) {
|
public List<UUID> findGroupIdsByUser(String userId) {
|
||||||
return eventStore.findGroup_idsWhereUser_id(userId).stream()
|
return eventStore.findGroup_idsWhereUser_id(userId).stream()
|
||||||
.map(UUID::fromString)
|
.map(UUID::fromString)
|
||||||
|
@ -8,6 +8,7 @@ import mops.gruppen2.domain.event.Event;
|
|||||||
import mops.gruppen2.domain.exception.EventException;
|
import mops.gruppen2.domain.exception.EventException;
|
||||||
import mops.gruppen2.repository.EventRepository;
|
import mops.gruppen2.repository.EventRepository;
|
||||||
import mops.gruppen2.security.Account;
|
import mops.gruppen2.security.Account;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -77,6 +78,7 @@ public class GroupService {
|
|||||||
* @throws EventException Projektionsfehler
|
* @throws EventException Projektionsfehler
|
||||||
*/
|
*/
|
||||||
//TODO Rename
|
//TODO Rename
|
||||||
|
@Cacheable("groups")
|
||||||
public List<Group> getAllGroupWithVisibilityPublic(String userId) throws EventException {
|
public List<Group> getAllGroupWithVisibilityPublic(String userId) throws EventException {
|
||||||
List<Event> groupEvents = eventService.translateEventDTOs(eventRepository.findAllEventsByType("CreateGroupEvent"));
|
List<Event> groupEvents = eventService.translateEventDTOs(eventRepository.findAllEventsByType("CreateGroupEvent"));
|
||||||
groupEvents.addAll(eventService.translateEventDTOs(eventRepository.findAllEventsByType("UpdateGroupDescriptionEvent")));
|
groupEvents.addAll(eventService.translateEventDTOs(eventRepository.findAllEventsByType("UpdateGroupDescriptionEvent")));
|
||||||
@ -100,6 +102,7 @@ public class GroupService {
|
|||||||
*
|
*
|
||||||
* @return List of groups
|
* @return List of groups
|
||||||
*/
|
*/
|
||||||
|
@Cacheable("groups")
|
||||||
public List<Group> getAllLecturesWithVisibilityPublic() {
|
public List<Group> getAllLecturesWithVisibilityPublic() {
|
||||||
List<Event> createEvents = eventService.translateEventDTOs(eventRepository.findAllEventsByType("CreateGroupEvent"));
|
List<Event> createEvents = eventService.translateEventDTOs(eventRepository.findAllEventsByType("CreateGroupEvent"));
|
||||||
createEvents.addAll(eventService.translateEventDTOs(eventRepository.findAllEventsByType("DeleteGroupEvent")));
|
createEvents.addAll(eventService.translateEventDTOs(eventRepository.findAllEventsByType("DeleteGroupEvent")));
|
||||||
@ -124,6 +127,7 @@ public class GroupService {
|
|||||||
* @throws EventException Projektionsfehler
|
* @throws EventException Projektionsfehler
|
||||||
*/
|
*/
|
||||||
//Todo Rename
|
//Todo Rename
|
||||||
|
@Cacheable("groups")
|
||||||
public List<Group> findGroupWith(String search, Account account) throws EventException {
|
public List<Group> findGroupWith(String search, Account account) throws EventException {
|
||||||
if (search.isEmpty()) {
|
if (search.isEmpty()) {
|
||||||
return getAllGroupWithVisibilityPublic(account.getName());
|
return getAllGroupWithVisibilityPublic(account.getName());
|
||||||
|
47
src/main/java/mops/gruppen2/service/InviteService.java
Normal file
47
src/main/java/mops/gruppen2/service/InviteService.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package mops.gruppen2.service;
|
||||||
|
|
||||||
|
import mops.gruppen2.domain.dto.InviteLinkDTO;
|
||||||
|
import mops.gruppen2.domain.exception.InvalidInviteException;
|
||||||
|
import mops.gruppen2.domain.exception.NoInviteExistException;
|
||||||
|
import mops.gruppen2.repository.InviteRepository;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class InviteService {
|
||||||
|
|
||||||
|
private final InviteRepository inviteRepository;
|
||||||
|
|
||||||
|
public InviteService(InviteRepository inviteRepository) {
|
||||||
|
this.inviteRepository = inviteRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createLink(UUID groupId) {
|
||||||
|
inviteRepository.save(new InviteLinkDTO(null, groupId.toString(), UUID.randomUUID().toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroyLink(UUID groupId) {
|
||||||
|
inviteRepository.deleteLinkOfGroup(groupId.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getGroupIdFromLink(String link) {
|
||||||
|
try {
|
||||||
|
return UUID.fromString(inviteRepository.findGroupIdByLink(link));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new InvalidInviteException(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLinkByGroupId(UUID groupId) {
|
||||||
|
try {
|
||||||
|
return inviteRepository.findLinkByGroupId(groupId.toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NoInviteExistException(groupId.toString());
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ import mops.gruppen2.domain.User;
|
|||||||
import mops.gruppen2.domain.event.Event;
|
import mops.gruppen2.domain.event.Event;
|
||||||
import mops.gruppen2.domain.exception.EventException;
|
import mops.gruppen2.domain.exception.EventException;
|
||||||
import mops.gruppen2.domain.exception.GroupNotFoundException;
|
import mops.gruppen2.domain.exception.GroupNotFoundException;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -25,6 +26,7 @@ public class UserService {
|
|||||||
|
|
||||||
//Test nötig??
|
//Test nötig??
|
||||||
|
|
||||||
|
@Cacheable("groups")
|
||||||
public List<Group> getUserGroups(User user) throws EventException {
|
public List<Group> getUserGroups(User user) throws EventException {
|
||||||
List<UUID> groupIds = eventService.findGroupIdsByUser(user.getId());
|
List<UUID> groupIds = eventService.findGroupIdsByUser(user.getId());
|
||||||
List<Event> events = groupService.getGroupEvents(groupIds);
|
List<Event> events = groupService.getGroupEvents(groupIds);
|
||||||
@ -41,6 +43,11 @@ public class UserService {
|
|||||||
return newGroups;
|
return newGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cacheable("groups")
|
||||||
|
public List<Group> getUserGroups(String userId) throws EventException {
|
||||||
|
return getUserGroups(new User(userId, null, null, null));
|
||||||
|
}
|
||||||
|
|
||||||
public Group getGroupById(UUID groupId) throws EventException {
|
public Group getGroupById(UUID groupId) throws EventException {
|
||||||
List<UUID> groupIds = new ArrayList<>();
|
List<UUID> groupIds = new ArrayList<>();
|
||||||
groupIds.add(groupId);
|
groupIds.add(groupId);
|
||||||
|
@ -19,3 +19,5 @@ keycloak.use-resource-role-mappings=true
|
|||||||
keycloak.autodetect-bearer-only=true
|
keycloak.autodetect-bearer-only=true
|
||||||
keycloak.confidential-port=443
|
keycloak.confidential-port=443
|
||||||
server.error.include-stacktrace=always
|
server.error.include-stacktrace=always
|
||||||
|
management.endpoints.web.exposure.include=info,health
|
||||||
|
spring.cache.type=NONE
|
||||||
|
@ -15,4 +15,5 @@ keycloak.credentials.secret=fc6ebf10-8c63-4e71-a667-4eae4e8209a1
|
|||||||
keycloak.verify-token-audience=true
|
keycloak.verify-token-audience=true
|
||||||
keycloak.use-resource-role-mappings=true
|
keycloak.use-resource-role-mappings=true
|
||||||
keycloak.autodetect-bearer-only=true
|
keycloak.autodetect-bearer-only=true
|
||||||
keycloak.confidential-port= 443
|
keycloak.confidential-port=443
|
||||||
|
management.endpoints.web.exposure.include=info,health
|
||||||
|
@ -8,3 +8,12 @@ CREATE TABLE event
|
|||||||
event_type VARCHAR(32),
|
event_type VARCHAR(32),
|
||||||
event_payload VARCHAR(2500)
|
event_payload VARCHAR(2500)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS invite;
|
||||||
|
|
||||||
|
CREATE TABLE invite
|
||||||
|
(
|
||||||
|
invite_id INT PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
group_id VARCHAR(36) NOT NULL,
|
||||||
|
invite_link VARCHAR(36) NOT NULL
|
||||||
|
);
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-10">
|
<div class="col-10">
|
||||||
<h1>Metadaten ändern</h1>
|
<h1>Metadaten ändern</h1>
|
||||||
<form action="/gruppen2/details/changeMetadata" method="post">
|
<form method="post" th:action="@{/gruppen2/details/changeMetadata}">
|
||||||
<div class="shadow-sm p-2"
|
<div class="shadow-sm p-2"
|
||||||
style=" border: 10px solid aliceblue; background: aliceblue">
|
style=" border: 10px solid aliceblue; background: aliceblue">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -38,7 +38,8 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-10">
|
<div class="col-10">
|
||||||
<h1>Gruppenerstellung</h1>
|
<h1>Gruppenerstellung</h1>
|
||||||
<form method="post" action="/gruppen2/createOrga" enctype="multipart/form-data">
|
<form enctype="multipart/form-data" method="post"
|
||||||
|
th:action="@{/gruppen2/createOrga}">
|
||||||
<div class="shadow-sm p-2"
|
<div class="shadow-sm p-2"
|
||||||
style=" border: 10px solid aliceblue; background: aliceblue">
|
style=" border: 10px solid aliceblue; background: aliceblue">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -37,8 +37,9 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-10">
|
<div class="col-10">
|
||||||
<h1>Gruppenerstellung</h1>
|
<h1>Gruppenerstellung</h1>
|
||||||
<form method="post" action="/gruppen2/createStudent">
|
<form method="post" th:action="@{/gruppen2/createStudent}">
|
||||||
<div class="shadow-sm p-2" style=" border: 10px solid aliceblue; border-radius: 5px; background: aliceblue">
|
<div class="shadow-sm p-2"
|
||||||
|
style=" border: 10px solid aliceblue; border-radius: 5px; background: aliceblue">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="titel">Titel</label>
|
<label for="titel">Titel</label>
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
th:text="${parent.getTitle()}">Parent</span>
|
th:text="${parent.getTitle()}">Parent</span>
|
||||||
|
|
||||||
<div class="input-group mb-3" style="margin-top: 10px"
|
<div class="input-group mb-3" style="margin-top: 10px"
|
||||||
th:if="${group.getVisibility() == group.getVisibility().PRIVATE}">
|
th:if="${roles.get(user.getId()) == admin}">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text" id="inputGroup-sizing-default"
|
<span class="input-group-text" id="inputGroup-sizing-default"
|
||||||
style="background: #52a1eb">Einladungslink:</span>
|
style="background: #52a1eb">Einladungslink:</span>
|
||||||
@ -83,15 +83,16 @@
|
|||||||
style="background: #52a1eb; border: none; margin: 5px">
|
style="background: #52a1eb; border: none; margin: 5px">
|
||||||
<a style="color: white" th:href="@{/gruppen2}">Zurück</a>
|
<a style="color: white" th:href="@{/gruppen2}">Zurück</a>
|
||||||
</button>
|
</button>
|
||||||
<form action="/gruppen2/leaveGroup" method="post">
|
<form method="post" th:action="@{/gruppen2/leaveGroup}">
|
||||||
<button class="btn btn-danger" style="border-style: none; margin: 5px"
|
<button class="btn btn-danger" style="border-style: none; margin: 5px"
|
||||||
th:name="group_id" th:value="${group.getId()}"
|
th:name="group_id" th:value="${group.getId()}"
|
||||||
type="submit">Gruppe verlassen
|
type="submit">Gruppe verlassen
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<form action="/gruppen2/deleteGroup" method="post">
|
<form method="post" th:action="@{/gruppen2/deleteGroup}">
|
||||||
<button class="btn btn-danger" style="border-style: none; margin: 5px"
|
<button class="btn btn-danger" style="border-style: none; margin: 5px"
|
||||||
th:name="group_id" th:value="${group.getId()}" th:if="${group.getRoles().get(user.getId()) == admin}"
|
th:name="group_id" th:value="${group.getId()}"
|
||||||
|
th:if="${group.getRoles().get(user.getId()) == admin}"
|
||||||
type="submit">Gruppe löschen
|
type="submit">Gruppe löschen
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@ -132,7 +133,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
function copyLink() {
|
function copyLink() {
|
||||||
var copyText = document.getElementById("groupLink");
|
const copyText = document.getElementById("groupLink");
|
||||||
|
|
||||||
copyText.select();
|
copyText.select();
|
||||||
copyText.setSelectionRange(0, 99999);
|
copyText.setSelectionRange(0, 99999);
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group mt-2">
|
<div class="form-group mt-2">
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<form method="post" action="/gruppen2/detailsBeitreten">
|
<form method="post" th:action="@{/gruppen2/detailsBeitreten}">
|
||||||
<button class="btn btn-primary"
|
<button class="btn btn-primary"
|
||||||
style="background: #52a1eb; border-style: none;"
|
style="background: #52a1eb; border-style: none;"
|
||||||
th:href="@{/gruppen2/detailsBeitreten}"
|
th:href="@{/gruppen2/detailsBeitreten}"
|
||||||
|
@ -48,16 +48,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="shadow p-2" style="border: 10px solid aliceblue; background: aliceblue">
|
<div class="shadow p-2" style="border: 10px solid aliceblue; background: aliceblue">
|
||||||
<div class="form-group pt-4" th:if="${account.getRoles().contains('orga')}">
|
<div class="form-group pt-4" th:if="${account.getRoles().contains('orga')}">
|
||||||
<form action="/gruppen2/details/members/addUsersFromCsv"
|
<form th:action="@{/gruppen2/details/members/addUsersFromCsv}"
|
||||||
enctype="multipart/form-data"
|
enctype="multipart/form-data"
|
||||||
method="post">
|
method="post">
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
<div class="custom-file">
|
<div class="custom-file">
|
||||||
<input class="custom-file-input" id="file" th:name="file" type="file">
|
<input class="custom-file-input" id="file" th:name="file"
|
||||||
<label class="custom-file-label" for="file">CSV Datei von Mitgliedern hochladen</label>
|
type="file">
|
||||||
|
<label class="custom-file-label" for="file">CSV Datei von
|
||||||
|
Mitgliedern hochladen</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<button class="btn btn-outline-secondary" style="background: #52a1eb; border-style: none"
|
<button class="btn btn-outline-secondary"
|
||||||
|
style="background: #52a1eb; border-style: none"
|
||||||
th:name="group_id" th:value="${group.getId()}"
|
th:name="group_id" th:value="${group.getId()}"
|
||||||
type="submit">
|
type="submit">
|
||||||
<a style="color: white">Hinzufügen</a>
|
<a style="color: white">Hinzufügen</a>
|
||||||
@ -67,12 +70,16 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group pt-4">
|
<div class="form-group pt-4">
|
||||||
<form action="/gruppen2/details/members/changeMaximum" method="post">
|
<form method="post" th:action="@{/gruppen2/details/members/changeMaximum}">
|
||||||
<div class="input-group mb-3" id="userMaximum">
|
<div class="input-group mb-3" id="userMaximum">
|
||||||
<input class="form-control" placeholder="Maximale Teilnehmerzahl ändern..." th:name="maximum"
|
<input class="form-control"
|
||||||
type="number" th:min="${group.getMembers().size()}" max="10000">
|
placeholder="Maximale Teilnehmerzahl ändern..."
|
||||||
|
th:name="maximum"
|
||||||
|
type="number" th:min="${group.getMembers().size()}"
|
||||||
|
max="10000">
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<button class="btn btn-outline-secondary" style="background: #52a1eb; border-style: none"
|
<button class="btn btn-outline-secondary"
|
||||||
|
style="background: #52a1eb; border-style: none"
|
||||||
th:name="group_id" th:value="${group.getId()}"
|
th:name="group_id" th:value="${group.getId()}"
|
||||||
type="submit">
|
type="submit">
|
||||||
<a style="color: white">Speichern</a>
|
<a style="color: white">Speichern</a>
|
||||||
@ -99,21 +106,27 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="text-right btn-toolbar" style="float: right;" role="toolbar">
|
<div class="text-right btn-toolbar" style="float: right;" role="toolbar">
|
||||||
<form action="/gruppen2/details/members/changeRole" method="post">
|
<form method="post"
|
||||||
|
th:action="@{/gruppen2/details/members/changeRole}">
|
||||||
<input th:name="group_id" th:value="${group.getId()}"
|
<input th:name="group_id" th:value="${group.getId()}"
|
||||||
type="hidden">
|
type="hidden">
|
||||||
<input th:name="user_id" th:value="${member.getId()}"
|
<input th:name="user_id" th:value="${member.getId()}"
|
||||||
type="hidden">
|
type="hidden">
|
||||||
<button class="btn btn-warning btn-sm" type="submit" style="margin: 5px">Rolle
|
<button class="btn btn-warning btn-sm" type="submit"
|
||||||
|
style="margin: 5px">Rolle
|
||||||
ändern
|
ändern
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<form action="/gruppen2/details/members/deleteUser" method="post">
|
<form method="post"
|
||||||
|
th:action="@{/gruppen2/details/members/deleteUser}">
|
||||||
<input th:name="group_id" th:value="${group.getId()}"
|
<input th:name="group_id" th:value="${group.getId()}"
|
||||||
type="hidden">
|
type="hidden">
|
||||||
<input th:name="user_id" th:value="${member.getId()}"
|
<input th:name="user_id" th:value="${member.getId()}"
|
||||||
type="hidden">
|
type="hidden">
|
||||||
<button class="btn btn-danger btn-sm" style="margin: 5px" th:if='!${account.getName().equals(member.getId())}'>Mitglied entfernen</button>
|
<button class="btn btn-danger btn-sm" style="margin: 5px"
|
||||||
|
th:if='!${account.getName().equals(member.getId())}'>
|
||||||
|
Mitglied entfernen
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-10">
|
<div class="col-10">
|
||||||
<h1>Meine Gruppen</h1>
|
<h1>Meine Gruppen</h1>
|
||||||
<form action="/" method="get">
|
<form method="get" th:action="@{/}">
|
||||||
<h3 style="color: dodgerblue; font-weight: bold; font-optical-sizing: auto">
|
<h3 style="color: dodgerblue; font-weight: bold; font-optical-sizing: auto">
|
||||||
<small style="font-weight: normal; color: black">Mitglied in </small>
|
<small style="font-weight: normal; color: black">Mitglied in </small>
|
||||||
<small style="font-weight: bold; color: black"
|
<small style="font-weight: bold; color: black"
|
||||||
|
81
src/main/resources/templates/joinprivate.html
Normal file
81
src/main/resources/templates/joinprivate.html
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}"
|
||||||
|
xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Gruppendetails</title>
|
||||||
|
<th:block th:fragment="headcontent">
|
||||||
|
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||||
|
</th:block>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation"
|
||||||
|
th:switch="${account.getRoles().contains('orga')}">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
|
||||||
|
</li>
|
||||||
|
<li th:case="${true}">
|
||||||
|
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
|
||||||
|
</li>
|
||||||
|
<li th:case="${false}">
|
||||||
|
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
|
||||||
|
</li>
|
||||||
|
<li class="active">
|
||||||
|
<a href="/findGroup" th:href="@{/gruppen2/findGroup}">Suche</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<main th:fragment="bodycontent">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-9">
|
||||||
|
<div class="shadow-sm p-4"
|
||||||
|
style="border: 1px solid aliceblue; border-radius: 5px; background: aliceblue">
|
||||||
|
<h1 style="color: black; font-weight: bold; font-optical-sizing: auto; overflow-wrap: break-word"
|
||||||
|
th:text="${group.getTitle()}"></h1>
|
||||||
|
<h3>Möchtest du dieser privaten Gruppe beitreten?</h3>
|
||||||
|
<div class="shadow-sm p-4" style="background: white">
|
||||||
|
<p style="overflow-wrap: break-word; font-optical-sizing: auto"
|
||||||
|
th:text="${group.getDescription()}"></p>
|
||||||
|
</div>
|
||||||
|
<div class="form-group mt-2">
|
||||||
|
<div class="text-right">
|
||||||
|
<form method="post" th:action="@{/gruppen2/acceptinvite}">
|
||||||
|
<input name="id" th:value="${group.getId()}" type="hidden"/>
|
||||||
|
<button class="btn btn-primary"
|
||||||
|
style="background: #52a1eb; border-style: none;"
|
||||||
|
type="submit">Ja, Gruppe beitreten
|
||||||
|
</button>
|
||||||
|
<a class="btn btn-primary"
|
||||||
|
href="/gruppen2"
|
||||||
|
style="background: #52a1eb; border-style: none;"
|
||||||
|
type="submit">Ich will das nicht.
|
||||||
|
</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-3" style="white-space: nowrap">
|
||||||
|
<div style="display: inline-block; margin: 0">
|
||||||
|
<h2>Mitglieder</h2>
|
||||||
|
<div th:switch="${group.getUserMaximum() != 100000}">
|
||||||
|
<h4 th:case="${true}">
|
||||||
|
<a th:text="${group.getMembers().size()}"></a>
|
||||||
|
<a>von maximal</a>
|
||||||
|
<a th:text="${group.getUserMaximum()}"></a>
|
||||||
|
<a>Benutzern.</a>
|
||||||
|
</h4>
|
||||||
|
<h4 th:case="false">unbegrenzte Teilnehmeranzahl</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -35,7 +35,7 @@
|
|||||||
<h1>Gruppensuche</h1>
|
<h1>Gruppensuche</h1>
|
||||||
<div class="shadow-sm p-2"
|
<div class="shadow-sm p-2"
|
||||||
style="border: 10px solid aliceblue; border-radius: 5px; background: aliceblue">
|
style="border: 10px solid aliceblue; border-radius: 5px; background: aliceblue">
|
||||||
<form action="/gruppen2/findGroup" method="get">
|
<form method="get" th:action="@{/gruppen2/findGroup}">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="suchleiste">Suchbegriff:</label>
|
<label for="suchleiste">Suchbegriff:</label>
|
||||||
<input class="form-control" id="suchleiste"
|
<input class="form-control" id="suchleiste"
|
||||||
|
@ -29,11 +29,11 @@ public class TestBuilder {
|
|||||||
|
|
||||||
public static Account account(String name) {
|
public static Account account(String name) {
|
||||||
return new Account(name,
|
return new Account(name,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Group apply(Group group, Event... events) {
|
public static Group apply(Group group, Event... events) {
|
||||||
@ -56,8 +56,8 @@ public class TestBuilder {
|
|||||||
*/
|
*/
|
||||||
public static UUID uuidFromInt(int id) {
|
public static UUID uuidFromInt(int id) {
|
||||||
return UUID.fromString("00000000-0000-0000-0000-"
|
return UUID.fromString("00000000-0000-0000-0000-"
|
||||||
+ "0".repeat(11 - String.valueOf(id).length())
|
+ "0".repeat(11 - String.valueOf(id).length())
|
||||||
+ id);
|
+ id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,18 +69,18 @@ public class TestBuilder {
|
|||||||
*/
|
*/
|
||||||
public static List<Event> completePublicGroups(int count, int membercount) {
|
public static List<Event> completePublicGroups(int count, int membercount) {
|
||||||
return IntStream.range(0, count)
|
return IntStream.range(0, count)
|
||||||
.parallel()
|
.parallel()
|
||||||
.mapToObj(i -> completePublicGroup(membercount))
|
.mapToObj(i -> completePublicGroup(membercount))
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Event> completePrivateGroups(int count, int membercount) {
|
public static List<Event> completePrivateGroups(int count, int membercount) {
|
||||||
return IntStream.range(0, count)
|
return IntStream.range(0, count)
|
||||||
.parallel()
|
.parallel()
|
||||||
.mapToObj(i -> completePrivateGroup(membercount))
|
.mapToObj(i -> completePrivateGroup(membercount))
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Event> completePublicGroup(int membercount) {
|
public static List<Event> completePublicGroup(int membercount) {
|
||||||
@ -123,25 +123,25 @@ public class TestBuilder {
|
|||||||
*/
|
*/
|
||||||
public static List<Event> createPublicGroupEvents(int count) {
|
public static List<Event> createPublicGroupEvents(int count) {
|
||||||
return IntStream.range(0, count)
|
return IntStream.range(0, count)
|
||||||
.parallel()
|
.parallel()
|
||||||
.mapToObj(i -> createPublicGroupEvent())
|
.mapToObj(i -> createPublicGroupEvent())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Event> createPrivateGroupEvents(int count) {
|
public static List<Event> createPrivateGroupEvents(int count) {
|
||||||
return IntStream.range(0, count)
|
return IntStream.range(0, count)
|
||||||
.parallel()
|
.parallel()
|
||||||
.mapToObj(i -> createPublicGroupEvent())
|
.mapToObj(i -> createPublicGroupEvent())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Event> createMixedGroupEvents(int count) {
|
public static List<Event> createMixedGroupEvents(int count) {
|
||||||
return IntStream.range(0, count)
|
return IntStream.range(0, count)
|
||||||
.parallel()
|
.parallel()
|
||||||
.mapToObj(i -> faker.random().nextInt(0, 1) > 0.5
|
.mapToObj(i -> faker.random().nextInt(0, 1) > 0.5
|
||||||
? createPublicGroupEvent()
|
? createPublicGroupEvent()
|
||||||
: createPrivateGroupEvent())
|
: createPrivateGroupEvent())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Event createPrivateGroupEvent(UUID groupId) {
|
public static Event createPrivateGroupEvent(UUID groupId) {
|
||||||
@ -195,9 +195,9 @@ public class TestBuilder {
|
|||||||
*/
|
*/
|
||||||
public static List<Event> addUserEvents(int count, UUID groupId) {
|
public static List<Event> addUserEvents(int count, UUID groupId) {
|
||||||
return IntStream.range(0, count)
|
return IntStream.range(0, count)
|
||||||
.parallel()
|
.parallel()
|
||||||
.mapToObj(i -> addUserEvent(groupId, String.valueOf(i)))
|
.mapToObj(i -> addUserEvent(groupId, String.valueOf(i)))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Event addUserEvent(UUID groupId, String userId) {
|
public static Event addUserEvent(UUID groupId, String userId) {
|
||||||
@ -221,8 +221,8 @@ public class TestBuilder {
|
|||||||
public static List<Event> deleteUserEvents(int count, List<Event> eventList) {
|
public static List<Event> deleteUserEvents(int count, List<Event> eventList) {
|
||||||
List<Event> removeEvents = new ArrayList<>();
|
List<Event> removeEvents = new ArrayList<>();
|
||||||
List<Event> shuffle = eventList.parallelStream()
|
List<Event> shuffle = eventList.parallelStream()
|
||||||
.filter(event -> event instanceof AddUserEvent)
|
.filter(event -> event instanceof AddUserEvent)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
Collections.shuffle(shuffle);
|
Collections.shuffle(shuffle);
|
||||||
|
|
||||||
@ -245,8 +245,8 @@ public class TestBuilder {
|
|||||||
*/
|
*/
|
||||||
public static List<Event> deleteUserEvents(Group group) {
|
public static List<Event> deleteUserEvents(Group group) {
|
||||||
return group.getMembers().parallelStream()
|
return group.getMembers().parallelStream()
|
||||||
.map(user -> deleteUserEvent(group.getId(), user.getId()))
|
.map(user -> deleteUserEvent(group.getId(), user.getId()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Event deleteUserEvent(UUID groupId, String userId) {
|
public static Event deleteUserEvent(UUID groupId, String userId) {
|
||||||
|
@ -2,6 +2,7 @@ package mops.gruppen2.service;
|
|||||||
|
|
||||||
import com.github.javafaker.Faker;
|
import com.github.javafaker.Faker;
|
||||||
import mops.gruppen2.repository.EventRepository;
|
import mops.gruppen2.repository.EventRepository;
|
||||||
|
import mops.gruppen2.repository.InviteRepository;
|
||||||
import mops.gruppen2.security.Account;
|
import mops.gruppen2.security.Account;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -12,6 +13,7 @@ import java.util.Set;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
class ControllerServiceTest {
|
class ControllerServiceTest {
|
||||||
|
|
||||||
Faker faker;
|
Faker faker;
|
||||||
Account account;
|
Account account;
|
||||||
ControllerService controllerService;
|
ControllerService controllerService;
|
||||||
@ -20,7 +22,8 @@ class ControllerServiceTest {
|
|||||||
EventRepository eventRepository;
|
EventRepository eventRepository;
|
||||||
GroupService groupService;
|
GroupService groupService;
|
||||||
JsonService jsonService;
|
JsonService jsonService;
|
||||||
|
InviteRepository inviteRepository;
|
||||||
|
InviteService inviteService;
|
||||||
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
@ -30,7 +33,9 @@ class ControllerServiceTest {
|
|||||||
eventService = new EventService(jsonService, eventRepository);
|
eventService = new EventService(jsonService, eventRepository);
|
||||||
groupService = new GroupService(eventService, eventRepository);
|
groupService = new GroupService(eventService, eventRepository);
|
||||||
userService = new UserService(groupService, eventService);
|
userService = new UserService(groupService, eventService);
|
||||||
controllerService = new ControllerService(eventService, userService);
|
inviteRepository = mock(InviteRepository.class);
|
||||||
|
inviteService = new InviteService(inviteRepository);
|
||||||
|
controllerService = new ControllerService(eventService, userService, inviteService);
|
||||||
Set<String> roles = new HashSet<>();
|
Set<String> roles = new HashSet<>();
|
||||||
roles.add("l");
|
roles.add("l");
|
||||||
account = new Account("ich", "ich@hhu.de", "l", "ichdude", "jap", roles);
|
account = new Account("ich", "ich@hhu.de", "l", "ichdude", "jap", roles);
|
||||||
|
@ -88,12 +88,12 @@ class GroupServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getGroupEvents() {
|
void getGroupEvents() {
|
||||||
// CreateGroupEvent test1 = new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L);
|
//CreateGroupEvent test1 = new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L);
|
||||||
// CreateGroupEvent test2 = new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.SIMPLE, Visibility.PUBLIC, 10L);
|
//CreateGroupEvent test2 = new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.SIMPLE, Visibility.PUBLIC, 10L);
|
||||||
|
|
||||||
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
||||||
createPublicGroupEvent(uuidFromInt(1)),
|
createPublicGroupEvent(uuidFromInt(1)),
|
||||||
createPrivateGroupEvent(uuidFromInt(2)));
|
createPrivateGroupEvent(uuidFromInt(2)));
|
||||||
|
|
||||||
List<UUID> groupIds = Arrays.asList(uuidFromInt(0), uuidFromInt(1));
|
List<UUID> groupIds = Arrays.asList(uuidFromInt(0), uuidFromInt(1));
|
||||||
|
|
||||||
@ -117,52 +117,52 @@ class GroupServiceTest {
|
|||||||
Group group = TestBuilder.apply(test1, test2);
|
Group group = TestBuilder.apply(test1, test2);
|
||||||
|
|
||||||
assertThat(group.getType()).isEqualTo(null);
|
assertThat(group.getType()).isEqualTo(null);
|
||||||
assertThat(groupService.getAllGroupWithVisibilityPublic("test1")).isEmpty();
|
assertThat(groupService.getAllGroupWithVisibilityPublic("errer")).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getAllGroupWithVisibilityPublicTestGroupPublic() {
|
void getAllGroupWithVisibilityPublicTestGroupPublic() {
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||||
// eventService.saveEvent(new DeleteGroupEvent(uuidFromInt(0), "test1"));
|
//eventService.saveEvent(new DeleteGroupEvent(uuidFromInt(0), "test1"));
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||||
// eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); //Wofür ist das
|
//eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); //Wofür ist das
|
||||||
|
|
||||||
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
||||||
deleteGroupEvent(uuidFromInt(0)),
|
deleteGroupEvent(uuidFromInt(0)),
|
||||||
createPublicGroupEvent());
|
createPublicGroupEvent());
|
||||||
|
|
||||||
assertThat(groupService.getAllGroupWithVisibilityPublic("test1").size()).isEqualTo(1);
|
assertThat(groupService.getAllGroupWithVisibilityPublic("test1").size()).isEqualTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getAllGroupWithVisibilityPublicTestAddSomeEvents() {
|
void getAllGroupWithVisibilityPublicTestAddSomeEvents() {
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||||
// eventService.saveEvent(new DeleteGroupEvent(uuidFromInt(0), "test1"));
|
//eventService.saveEvent(new DeleteGroupEvent(uuidFromInt(0), "test1"));
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||||
// eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); // Wofür?
|
//eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); // Wofür?
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(2), "test3", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(2), "test3", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(3), "test4", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(3), "test4", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(4), "test5", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(4), "test5", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||||
|
|
||||||
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
||||||
deleteGroupEvent(uuidFromInt(0)),
|
deleteGroupEvent(uuidFromInt(0)),
|
||||||
createPublicGroupEvent(),
|
createPublicGroupEvent(),
|
||||||
createPublicGroupEvent(),
|
createPublicGroupEvent(),
|
||||||
createPublicGroupEvent(),
|
createPublicGroupEvent(),
|
||||||
createPrivateGroupEvent());
|
createPrivateGroupEvent());
|
||||||
|
|
||||||
assertThat(groupService.getAllGroupWithVisibilityPublic("test1").size()).isEqualTo(3);
|
assertThat(groupService.getAllGroupWithVisibilityPublic("test1").size()).isEqualTo(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getAllGroupWithVisibilityPublic_UserInGroup() {
|
void getAllGroupWithVisibilityPublic_UserInGroup() {
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||||
// eventService.saveEvent(new AddUserEvent(uuidFromInt(0), "test1", "test", "test", "test@test"));
|
//eventService.saveEvent(new AddUserEvent(uuidFromInt(0), "test1", "test", "test", "test@test"));
|
||||||
|
|
||||||
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
||||||
addUserEvent(uuidFromInt(0), "kobold"),
|
addUserEvent(uuidFromInt(0), "kobold"),
|
||||||
createPrivateGroupEvent(),
|
createPrivateGroupEvent(),
|
||||||
createPublicGroupEvent());
|
createPublicGroupEvent());
|
||||||
|
|
||||||
//Das kommt glaube ich eher in einen Test für die Projektion
|
//Das kommt glaube ich eher in einen Test für die Projektion
|
||||||
//assertThat(groupService.getAllGroupWithVisibilityPublic("test2").get(0).getMembers().size()).isEqualTo(1);
|
//assertThat(groupService.getAllGroupWithVisibilityPublic("test2").get(0).getMembers().size()).isEqualTo(1);
|
||||||
@ -173,34 +173,34 @@ class GroupServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getAllLecturesWithVisibilityPublic() {
|
void getAllLecturesWithVisibilityPublic() {
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||||
// eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); // Hä
|
//eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); // Hä
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(2), "test3", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(2), "test3", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(3), "test4", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(3), "test4", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(4), "test5", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(4), "test5", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||||
|
|
||||||
eventService.saveAll(createLectureEvent(),
|
eventService.saveAll(createLectureEvent(),
|
||||||
createPublicGroupEvent(),
|
createPublicGroupEvent(),
|
||||||
createLectureEvent(),
|
createLectureEvent(),
|
||||||
createLectureEvent(),
|
createLectureEvent(),
|
||||||
createLectureEvent());
|
createLectureEvent());
|
||||||
|
|
||||||
assertThat(groupService.getAllLecturesWithVisibilityPublic().size()).isEqualTo(4);
|
assertThat(groupService.getAllLecturesWithVisibilityPublic().size()).isEqualTo(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void findGroupWith_UserMember_AllGroups() {
|
void findGroupWith_UserMember_AllGroups() {
|
||||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||||
// eventService.saveEvent(new AddUserEvent(uuidFromInt(0), "test1", "test", "test", "test@test"));
|
//eventService.saveEvent(new AddUserEvent(uuidFromInt(0), "test1", "test", "test", "test@test"));
|
||||||
// eventService.saveEvent(new UpdateGroupTitleEvent(uuidFromInt(0), "test1", "TestGroup"));
|
//eventService.saveEvent(new UpdateGroupTitleEvent(uuidFromInt(0), "test1", "TestGroup"));
|
||||||
// eventService.saveEvent(new UpdateGroupDescriptionEvent(uuidFromInt(0), "test1", "TestDescription"));
|
//eventService.saveEvent(new UpdateGroupDescriptionEvent(uuidFromInt(0), "test1", "TestDescription"));
|
||||||
// eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(0), "test1", Role.MEMBER));
|
//eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(0), "test1", Role.MEMBER));
|
||||||
|
|
||||||
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
||||||
addUserEvent(uuidFromInt(0), "jens"),
|
addUserEvent(uuidFromInt(0), "jens"),
|
||||||
updateGroupTitleEvent(uuidFromInt(0)),
|
updateGroupTitleEvent(uuidFromInt(0)),
|
||||||
updateGroupDescriptionEvent(uuidFromInt(0)));
|
updateGroupDescriptionEvent(uuidFromInt(0)));
|
||||||
|
|
||||||
//assertThat(groupService.findGroupWith("T", new Account("jens", "a@A", "test", "peter", "mueller", null)).size()).isEqualTo(1);
|
//assertThat(groupService.findGroupWith("T", new Account("jens", "a@A", "test", "peter", "mueller", null)).size()).isEqualTo(1);
|
||||||
assertThat(groupService.findGroupWith("", account("jens"))).isEmpty();
|
assertThat(groupService.findGroupWith("", account("jens"))).isEmpty();
|
||||||
@ -209,7 +209,7 @@ class GroupServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
void findGroupWith_UserNoMember_AllGroups() {
|
void findGroupWith_UserNoMember_AllGroups() {
|
||||||
eventService.saveAll(completePublicGroups(10, 0),
|
eventService.saveAll(completePublicGroups(10, 0),
|
||||||
completePrivateGroups(10, 0));
|
completePrivateGroups(10, 0));
|
||||||
|
|
||||||
assertThat(groupService.findGroupWith("", account("jens"))).hasSize(10);
|
assertThat(groupService.findGroupWith("", account("jens"))).hasSize(10);
|
||||||
}
|
}
|
||||||
@ -217,12 +217,12 @@ class GroupServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
void findGroupWith_FilterGroups() {
|
void findGroupWith_FilterGroups() {
|
||||||
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
||||||
updateGroupTitleEvent(uuidFromInt(0), "KK"),
|
updateGroupTitleEvent(uuidFromInt(0), "KK"),
|
||||||
updateGroupDescriptionEvent(uuidFromInt(0), "ABCDE"),
|
updateGroupDescriptionEvent(uuidFromInt(0), "ABCDE"),
|
||||||
createPublicGroupEvent(uuidFromInt(1)),
|
createPublicGroupEvent(uuidFromInt(1)),
|
||||||
updateGroupTitleEvent(uuidFromInt(1), "ABCDEFG"),
|
updateGroupTitleEvent(uuidFromInt(1), "ABCDEFG"),
|
||||||
updateGroupDescriptionEvent(uuidFromInt(1), "KK"),
|
updateGroupDescriptionEvent(uuidFromInt(1), "KK"),
|
||||||
createPrivateGroupEvent());
|
createPrivateGroupEvent());
|
||||||
|
|
||||||
assertThat(groupService.findGroupWith("A", account("jesus"))).hasSize(2);
|
assertThat(groupService.findGroupWith("A", account("jesus"))).hasSize(2);
|
||||||
assertThat(groupService.findGroupWith("F", account("jesus"))).hasSize(1);
|
assertThat(groupService.findGroupWith("F", account("jesus"))).hasSize(1);
|
||||||
|
Reference in New Issue
Block a user