1

removed unneccessary fields, decreased field visibility

Co-authored-by: Christoph <tobi@urpost.de>
This commit is contained in:
Christoph
2020-03-18 21:32:05 +01:00
parent 2ba913f2c8
commit e4d8fb05cb
21 changed files with 76 additions and 127 deletions

View File

@ -10,7 +10,6 @@ import mops.gruppen2.domain.event.Event;
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.SerializationService;
import org.springframework.security.access.annotation.Secured; 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;
@ -26,36 +25,33 @@ import java.util.List;
@RequestMapping("/gruppen2/api") @RequestMapping("/gruppen2/api")
public class APIController { public class APIController {
private final SerializationService serializationService;
private final EventService eventService; private final EventService eventService;
private final GroupService groupService; private final GroupService groupService;
public APIController(SerializationService serializationService, EventService eventService, GroupService groupService) { public APIController(EventService eventService, GroupService groupService) {
this.serializationService = serializationService;
this.eventService = eventService; this.eventService = eventService;
this.groupService = groupService; this.groupService = groupService;
} }
@GetMapping("/updateGroups/{status}") @GetMapping("/updateGroups/{status}")
@Secured("ROLE_api_user") @Secured("ROLE_api_user")
@ApiOperation(value = "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 UpdatedGroupRequestMapper updateGroup(@ApiParam("Letzter Status des Anfragestellers") @PathVariable Long status) throws EventException { public UpdatedGroupRequestMapper updateGroup(@ApiParam("Letzter Status des Anfragestellers") @PathVariable Long status) throws EventException {
List<Event> events = eventService.getNewEvents(status); List<Event> events = eventService.getNewEvents(status);
UpdatedGroupRequestMapper updatedGroupRequestMapper = APIFormatterService.wrapp(eventService.getMaxEvent_id(), groupService.projectEventList(events));
return updatedGroupRequestMapper; return APIFormatterService.wrapp(eventService.getMaxEvent_id(), groupService.projectEventList(events));
} }
@GetMapping("/getGroupIdsOfUser/{teilnehmer}") @GetMapping("/getGroupIdsOfUser/{teilnehmer}")
@Secured("ROLE_api_user") @Secured("ROLE_api_user")
@ApiOperation(value = "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<Long> getGroupsOfUser(@ApiParam("Teilnehmer dessen groupIds zurückgegeben werden sollen") @PathVariable String teilnehmer) throws EventException { public List<Long> getGroupsOfUser(@ApiParam("Teilnehmer dessen groupIds zurückgegeben werden sollen") @PathVariable String teilnehmer) throws EventException {
return eventService.getGroupsOfUser(teilnehmer); return eventService.getGroupsOfUser(teilnehmer);
} }
@GetMapping("/getGroup/{groupId}") @GetMapping("/getGroup/{groupId}")
@Secured("ROLE_api_user") @Secured("ROLE_api_user")
@ApiOperation(value = "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 Long groupId) throws EventException { public Group getGroupFromId(@ApiParam("GruppenId der gefordeten Gruppe") @PathVariable Long groupId) throws EventException {
List<Event> eventList = eventService.getEventsOfGroup(groupId); List<Event> eventList = eventService.getEventsOfGroup(groupId);

View File

@ -8,7 +8,6 @@ import mops.gruppen2.domain.User;
import mops.gruppen2.security.Account; import mops.gruppen2.security.Account;
import mops.gruppen2.service.ControllerService; import mops.gruppen2.service.ControllerService;
import mops.gruppen2.service.CsvService; import mops.gruppen2.service.CsvService;
import mops.gruppen2.service.EventService;
import mops.gruppen2.service.GroupService; import mops.gruppen2.service.GroupService;
import mops.gruppen2.service.InviteLinkRepositoryService; import mops.gruppen2.service.InviteLinkRepositoryService;
import mops.gruppen2.service.KeyCloakService; import mops.gruppen2.service.KeyCloakService;
@ -38,7 +37,6 @@ import java.util.List;
public class Gruppen2Controller { public class Gruppen2Controller {
private final KeyCloakService keyCloakService; private final KeyCloakService keyCloakService;
private final EventService eventService;
private final GroupService groupService; private final GroupService groupService;
private final UserService userService; private final UserService userService;
private final ControllerService controllerService; private final ControllerService controllerService;
@ -46,9 +44,8 @@ public class Gruppen2Controller {
@Autowired @Autowired
Gruppen2Config gruppen2Config; Gruppen2Config gruppen2Config;
public Gruppen2Controller(KeyCloakService keyCloakService, EventService eventService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService) { public Gruppen2Controller(KeyCloakService keyCloakService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService) {
this.keyCloakService = keyCloakService; this.keyCloakService = keyCloakService;
this.eventService = eventService;
this.groupService = groupService; this.groupService = groupService;
this.userService = userService; this.userService = userService;
this.controllerService = controllerService; this.controllerService = controllerService;
@ -83,8 +80,8 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"}) @RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
@PostMapping("/createLecture") @PostMapping("/createLecture")
public String pCreateLecture(KeycloakAuthenticationToken token, public String pCreateLecture(KeycloakAuthenticationToken token,
@RequestParam(value = "title") String title, @RequestParam("title") String title,
@RequestParam(value = "beschreibung") String beschreibung, @RequestParam("beschreibung") String beschreibung,
@RequestParam(value = "visibility", required = false) Boolean visibility, @RequestParam(value = "visibility", required = false) Boolean visibility,
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException, EventException { @RequestParam(value = "file", required = false) MultipartFile file) throws IOException, EventException {
@ -101,7 +98,7 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"}) @RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
@PostMapping("/details/members/addUsersFromCsv") @PostMapping("/details/members/addUsersFromCsv")
public String addUsersFromCsv(@RequestParam(value = "group_id") Long group_id, public String addUsersFromCsv(@RequestParam("group_id") Long group_id,
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException { @RequestParam(value = "file", required = false) MultipartFile file) throws IOException {
List<User> userList = new ArrayList<>(); List<User> userList = new ArrayList<>();
if (!file.isEmpty()) { if (!file.isEmpty()) {
@ -134,8 +131,8 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"}) @RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
@PostMapping("/createGroup") @PostMapping("/createGroup")
public String pCreateGroup(KeycloakAuthenticationToken token, public String pCreateGroup(KeycloakAuthenticationToken token,
@RequestParam(value = "title") String title, @RequestParam("title") String title,
@RequestParam(value = "beschreibung") String beschreibung, @RequestParam("beschreibung") String beschreibung,
@RequestParam(value = "visibility", required = false) Boolean visibility) throws EventException { @RequestParam(value = "visibility", required = false) Boolean visibility) throws EventException {
Account account = keyCloakService.createAccountFromPrincipal(token); Account account = keyCloakService.createAccountFromPrincipal(token);
@ -147,7 +144,7 @@ public class Gruppen2Controller {
@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, @PathVariable(value = "id") Long id) throws EventException, ResponseStatusException { public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @PathVariable("id") Long id) throws EventException, ResponseStatusException {
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token)); model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
Group group = userService.getGroupById(id); Group group = userService.getGroupById(id);
@ -165,7 +162,7 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"}) @RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
@PostMapping("/detailsBeitreten") @PostMapping("/detailsBeitreten")
public String joinGroup(KeycloakAuthenticationToken token, Model model, @RequestParam(value = "id") Long id) throws EventException { public String joinGroup(KeycloakAuthenticationToken token, Model model, @RequestParam("id") Long id) throws EventException {
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token)); model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
Account account = keyCloakService.createAccountFromPrincipal(token); Account account = keyCloakService.createAccountFromPrincipal(token);
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail()); User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
@ -179,7 +176,7 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"}) @RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
@GetMapping("/detailsSearch") @GetMapping("/detailsSearch")
public String showGroupDetailsNoMember(KeycloakAuthenticationToken token, Model model, @RequestParam(value = "id") Long id) throws EventException { public String showGroupDetailsNoMember(KeycloakAuthenticationToken token, Model model, @RequestParam("id") Long id) throws EventException {
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token)); model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
Group group = userService.getGroupById(id); Group group = userService.getGroupById(id);
if (group != null) { if (group != null) {
@ -203,7 +200,7 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"}) @RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
@PostMapping("/leaveGroup") @PostMapping("/leaveGroup")
public String pLeaveGroup(KeycloakAuthenticationToken token, @RequestParam(value = "group_id") Long id) throws EventException { public String pLeaveGroup(KeycloakAuthenticationToken token, @RequestParam("group_id") Long id) throws EventException {
Account account = keyCloakService.createAccountFromPrincipal(token); Account account = keyCloakService.createAccountFromPrincipal(token);
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail()); User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
controllerService.deleteUser(user.getUser_id(), id); controllerService.deleteUser(user.getUser_id(), id);
@ -212,7 +209,7 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"}) @RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
@GetMapping("/details/members/{id}") @GetMapping("/details/members/{id}")
public String editMembers(Model model, KeycloakAuthenticationToken token, @PathVariable(value = "id") Long id) throws EventException { public String editMembers(Model model, KeycloakAuthenticationToken token, @PathVariable("id") Long id) throws EventException {
Account account = keyCloakService.createAccountFromPrincipal(token); Account account = keyCloakService.createAccountFromPrincipal(token);
Group group = userService.getGroupById(id); Group group = userService.getGroupById(id);
if (group.getRoles().get(account.getName()) == Role.ADMIN) { if (group.getRoles().get(account.getName()) == Role.ADMIN) {
@ -228,22 +225,17 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"}) @RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
@PostMapping("/details/members/changeRole") @PostMapping("/details/members/changeRole")
public String changeRole(KeycloakAuthenticationToken token, @RequestParam(value = "group_id") Long group_id, public String changeRole(KeycloakAuthenticationToken token, @RequestParam("group_id") Long group_id,
@RequestParam(value = "user_id") String user_id) throws EventException { @RequestParam("user_id") String user_id) throws EventException {
controllerService.updateRole(user_id, group_id); controllerService.updateRole(user_id, group_id);
return "redirect:/gruppen2/details/members/" + group_id; return "redirect:/gruppen2/details/members/" + group_id;
} }
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"}) @RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
@PostMapping("/details/members/deleteUser") @PostMapping("/details/members/deleteUser")
public String deleteUser(KeycloakAuthenticationToken token, @RequestParam(value = "group_id") Long group_id, public String deleteUser(KeycloakAuthenticationToken token, @RequestParam("group_id") Long group_id,
@RequestParam(value = "user_id") String user_id) throws EventException { @RequestParam("user_id") String user_id) throws EventException {
controllerService.deleteUser(user_id, group_id); controllerService.deleteUser(user_id, group_id);
return "redirect:/gruppen2/details/members/" + group_id; return "redirect:/gruppen2/details/members/" + group_id;
} }
@GetMapping("*")
public String defaultLink() {
return "errorRenameLater";
}
} }

View File

@ -18,4 +18,9 @@ public class MopsController {
request.logout(); request.logout();
return "redirect:/gruppen2/"; return "redirect:/gruppen2/";
} }
@GetMapping("*")
public String defaultLink() {
return "errorRenameLater";
}
} }

View File

@ -1,7 +1,5 @@
package mops.gruppen2.domain; package mops.gruppen2.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -13,15 +11,13 @@ import java.util.Map;
/** /**
* Repräsentiert den aggregierten Zustand einer Gruppe. * Repräsentiert den aggregierten Zustand einer Gruppe.
*/ */
@EqualsAndHashCode(callSuper = false)
@Getter @Getter
@Setter @Setter
@AllArgsConstructor
public class Group { public class Group {
private final List<User> members; private final List<User> members;
private final Map<String, Role> roles; private final Map<String, Role> roles;
private long id; private Long id;
private String title; private String title;
private String description; private String description;
private GroupType type; private GroupType type;

View File

@ -1,12 +0,0 @@
package mops.gruppen2.domain;
import lombok.Value;
// @ApiModelProperty
@Value
public class ProductSwaggerExample {
// @ApiModelProperty
String name;
String description;
}

View File

@ -1,18 +1,16 @@
package mops.gruppen2.domain; package mops.gruppen2.domain;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.Getter;
@Data @Getter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(exclude = {"givenname", "familyname", "email"}) @EqualsAndHashCode(exclude = {"givenname", "familyname", "email"})
public class User { public class User {
String user_id; private final String user_id;
String givenname; private final String givenname;
String familyname; private final String familyname;
String email; private final String email;
} }

View File

@ -1,17 +1,13 @@
package mops.gruppen2.domain.apiWrapper; package mops.gruppen2.domain.apiWrapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import mops.gruppen2.domain.Group; import mops.gruppen2.domain.Group;
import java.util.List; import java.util.List;
@Getter
@NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class UpdatedGroupRequestMapper { public class UpdatedGroupRequestMapper {
private Long status; private final Long status;
private List<Group> groupList; private final List<Group> groupList;
} }

View File

@ -1,11 +1,11 @@
package mops.gruppen2.domain.dto; package mops.gruppen2.domain.dto;
import lombok.Data; import lombok.Value;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table; import org.springframework.data.relational.core.mapping.Table;
@Table("event") @Table("event")
@Data @Value
public class EventDTO { public class EventDTO {
@Id @Id

View File

@ -1,13 +1,11 @@
package mops.gruppen2.domain.dto; package mops.gruppen2.domain.dto;
import lombok.AllArgsConstructor; import lombok.Value;
import lombok.Data;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table; import org.springframework.data.relational.core.mapping.Table;
@Table("invite") @Table("invite")
@Data @Value
@AllArgsConstructor
public class InviteLinkDTO { public class InviteLinkDTO {
@Id @Id

View File

@ -14,12 +14,12 @@ import mops.gruppen2.domain.User;
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor // For Jackson
public class AddUserEvent extends Event { public class AddUserEvent extends Event {
String givenname; private String givenname;
String familyname; private String familyname;
String email; private String email;
public AddUserEvent(Long group_id, String user_id, String givenname, String familyname, String email) { public AddUserEvent(Long group_id, String user_id, String givenname, String familyname, String email) {
super(group_id, user_id); super(group_id, user_id);

View File

@ -9,7 +9,7 @@ import mops.gruppen2.domain.Visibility;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor // For Jackson
public class CreateGroupEvent extends Event { public class CreateGroupEvent extends Event {
private Visibility groupVisibility; private Visibility groupVisibility;

View File

@ -1,11 +1,11 @@
package mops.gruppen2.domain.event; package mops.gruppen2.domain.event;
import lombok.EqualsAndHashCode; import lombok.Getter;
import lombok.Value; import lombok.NoArgsConstructor;
import mops.gruppen2.domain.Group; import mops.gruppen2.domain.Group;
@EqualsAndHashCode(callSuper = true) @Getter
@Value @NoArgsConstructor // For Jackson
public class DeleteGroupEvent extends Event { public class DeleteGroupEvent extends Event {
public DeleteGroupEvent(long group_id, String user_id) { public DeleteGroupEvent(long group_id, String user_id) {

View File

@ -11,7 +11,7 @@ import mops.gruppen2.domain.User;
* Entfernt ein einzelnes Mitglied einer Gruppe. * Entfernt ein einzelnes Mitglied einer Gruppe.
*/ */
@Getter @Getter
@NoArgsConstructor @NoArgsConstructor // For Jackson
public class DeleteUserEvent extends Event { public class DeleteUserEvent extends Event {
public DeleteUserEvent(Long group_id, String user_id) { public DeleteUserEvent(Long group_id, String user_id) {

View File

@ -5,14 +5,10 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter;
import mops.gruppen2.domain.Exceptions.EventException; import mops.gruppen2.domain.Exceptions.EventException;
import mops.gruppen2.domain.Group; import mops.gruppen2.domain.Group;
@Getter
@NoArgsConstructor
@AllArgsConstructor
@JsonTypeInfo( @JsonTypeInfo(
include = JsonTypeInfo.As.PROPERTY, include = JsonTypeInfo.As.PROPERTY,
use = JsonTypeInfo.Id.NAME, use = JsonTypeInfo.Id.NAME,
@ -26,13 +22,13 @@ import mops.gruppen2.domain.Group;
@JsonSubTypes.Type(value = UpdateGroupTitleEvent.class, name = "UpdateGroupTitleEvent"), @JsonSubTypes.Type(value = UpdateGroupTitleEvent.class, name = "UpdateGroupTitleEvent"),
@JsonSubTypes.Type(value = UpdateRoleEvent.class, name = "UpdateRoleEvent"), @JsonSubTypes.Type(value = UpdateRoleEvent.class, name = "UpdateRoleEvent"),
}) })
@Setter @Getter
@NoArgsConstructor
@AllArgsConstructor
public class Event { public class Event {
Long group_id; protected Long group_id;
String user_id; protected String user_id;
public void apply(Group group) throws EventException {}
public void apply(Group group) throws EventException {
}
} }

View File

@ -10,10 +10,10 @@ import mops.gruppen2.domain.Group;
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor // For Jackson
public class UpdateGroupDescriptionEvent extends Event { public class UpdateGroupDescriptionEvent extends Event {
String newGroupDescription; private String newGroupDescription;
public UpdateGroupDescriptionEvent(Long group_id, String user_id, String newGroupDescription) { public UpdateGroupDescriptionEvent(Long group_id, String user_id, String newGroupDescription) {
super(group_id, user_id); super(group_id, user_id);

View File

@ -10,10 +10,10 @@ import mops.gruppen2.domain.Group;
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor // For Jackson
public class UpdateGroupTitleEvent extends Event { public class UpdateGroupTitleEvent extends Event {
String newGroupTitle; private String newGroupTitle;
public UpdateGroupTitleEvent(Long group_id, String user_id, String newGroupTitle) { public UpdateGroupTitleEvent(Long group_id, String user_id, String newGroupTitle) {
super(group_id, user_id); super(group_id, user_id);

View File

@ -12,10 +12,10 @@ import mops.gruppen2.domain.Role;
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor // For Jackson
public class UpdateRoleEvent extends Event { public class UpdateRoleEvent extends Event {
Role newRole; private Role newRole;
public UpdateRoleEvent(Long group_id, String user_id, Role newRole) { public UpdateRoleEvent(Long group_id, String user_id, Role newRole) {
super(group_id, user_id); super(group_id, user_id);

View File

@ -1,18 +1,16 @@
package mops.gruppen2.security; package mops.gruppen2.security;
import lombok.AllArgsConstructor; import lombok.Value;
import lombok.Getter;
import java.util.Set; import java.util.Set;
@Getter @Value
@AllArgsConstructor
public class Account { public class Account {
private final String name; //user_id String email;
private final String email; String image;
private final String image; String name; //user_id
private final String givenname; String givenname;
private final String familyname; String familyname;
private final Set<String> roles; Set<String> roles;
} }

View File

@ -40,23 +40,19 @@ public class EventService {
* @return EventDTO * @return EventDTO
*/ */
public EventDTO getDTO(Event event) { public EventDTO getDTO(Event event) {
EventDTO eventDTO = new EventDTO(); boolean visibility = false;
eventDTO.setGroup_id(event.getGroup_id());
eventDTO.setUser_id(event.getUser_id());
if (event instanceof CreateGroupEvent) { if (event instanceof CreateGroupEvent) {
if (((CreateGroupEvent) event).getGroupVisibility() == Visibility.PRIVATE) { visibility = ((CreateGroupEvent) event).getGroupVisibility() == Visibility.PRIVATE;
eventDTO.setVisibility(false);
} else {
eventDTO.setVisibility(true);
}
} }
String payload = "";
try { try {
eventDTO.setEvent_payload(serializationService.serializeEvent(event)); payload = serializationService.serializeEvent(event);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
e.printStackTrace(); e.printStackTrace();
} }
return eventDTO;
return new EventDTO(null, event.getGroup_id(), event.getUser_id(), payload, visibility);
} }
/** /**

View File

@ -3,9 +3,6 @@ package mops.gruppen2.service;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import mops.gruppen2.domain.event.Event; import mops.gruppen2.domain.event.Event;
import mops.gruppen2.repository.EventRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
@ -14,13 +11,6 @@ import org.springframework.stereotype.Service;
@Service @Service
public class SerializationService { public class SerializationService {
private final EventRepository eventStore;
private final Logger log = LoggerFactory.getLogger(SerializationService.class);
public SerializationService(EventRepository eventStore) {
this.eventStore = eventStore;
}
/** /**
* Übersetzt mithilfe der Jackson-Library eine Java-Event-Repräsentation zu einem JSON-Event-Payload. * Übersetzt mithilfe der Jackson-Library eine Java-Event-Repräsentation zu einem JSON-Event-Payload.
* *

View File

@ -14,8 +14,8 @@ import java.util.List;
@Service @Service
public class UserService { public class UserService {
final EventRepository eventRepository; private final EventRepository eventRepository;
final GroupService groupService; private final GroupService groupService;
public UserService(EventRepository eventRepository, GroupService groupService) { public UserService(EventRepository eventRepository, GroupService groupService) {
this.eventRepository = eventRepository; this.eventRepository = eventRepository;