fix pmd warnings
This commit is contained in:
43
build.gradle
43
build.gradle
@ -1,11 +1,9 @@
|
||||
import com.github.spotbugs.SpotBugsTask
|
||||
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.2.5.RELEASE'
|
||||
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
|
||||
id 'java'
|
||||
|
||||
id 'com.github.spotbugs' version '3.0.0'
|
||||
id 'com.github.spotbugs' version '4.0.1'
|
||||
id 'checkstyle'
|
||||
id 'pmd'
|
||||
}
|
||||
@ -14,30 +12,39 @@ group = 'mops'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
sourceCompatibility = '11'
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url = 'https://s3.cs.hhu.de/public/mops/'
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
spotbugs {
|
||||
toolVersion = '4.0.1'
|
||||
ignoreFailures = false
|
||||
reportLevel = "high"
|
||||
effort = "max"
|
||||
toolVersion = '4.0.0-RC1'
|
||||
showProgress = true
|
||||
}
|
||||
|
||||
tasks.withType(SpotBugsTask) {
|
||||
spotbugsMain {
|
||||
reports {
|
||||
xml.enabled = false
|
||||
html.enabled = true
|
||||
html {
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pmd {
|
||||
consoleOutput = true
|
||||
ignoreFailures = true
|
||||
toolVersion = "6.21.0"
|
||||
toolVersion = "6.22.0"
|
||||
rulePriority = 5
|
||||
ruleSets = ["category/java/errorprone.xml",
|
||||
"category/java/bestpractices.xml",
|
||||
"category/java/security.xml",
|
||||
"category/java/performance.xml",
|
||||
"category/java/design.xml"]
|
||||
ruleSetFiles = files("config/pmd/ruleset.xml")
|
||||
ruleSets = []
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
@ -56,16 +63,6 @@ configurations {
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url = 'https://s3.cs.hhu.de/public/mops/'
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
|
||||
|
@ -19,7 +19,7 @@
|
||||
<rule ref="category/java/bestpractices.xml/ConstantsInInterface"/>
|
||||
<rule ref="category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt"/>
|
||||
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach"/>
|
||||
<rule ref="category/java/bestpractices.xml/GuardLogStatement"/>
|
||||
<!-- <rule ref="category/java/bestpractices.xml/GuardLogStatement"/>-->
|
||||
<!-- <rule ref="category/java/bestpractices.xml/JUnit4SuitesShouldUseSuiteAnnotation" /> -->
|
||||
<!-- <rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseAfterAnnotation" /> -->
|
||||
<!-- <rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseBeforeAnnotation" /> -->
|
||||
@ -150,7 +150,7 @@
|
||||
<rule ref="category/java/design.xml/FinalFieldCouldBeStatic"/>
|
||||
<!-- <rule ref="category/java/design.xml/GodClass" /> -->
|
||||
<!-- <rule ref="category/java/design.xml/ImmutableField" /> -->
|
||||
<rule ref="category/java/design.xml/LawOfDemeter"/>
|
||||
<!-- <rule ref="category/java/design.xml/LawOfDemeter"/>-->
|
||||
<rule ref="category/java/design.xml/LogicInversion"/>
|
||||
|
||||
<rule ref="category/java/design.xml/CyclomaticComplexity"/>
|
||||
@ -298,7 +298,7 @@
|
||||
<rule ref="category/java/multithreading.xml/DontCallThreadRun"/>
|
||||
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking"/>
|
||||
<rule ref="category/java/multithreading.xml/NonThreadSafeSingleton"/>
|
||||
<rule ref="category/java/multithreading.xml/UnsynchronizedStaticDateFormatter"/>
|
||||
<!-- <rule ref="category/java/multithreading.xml/UnsynchronizedStaticDateFormatter"/>-->
|
||||
<!-- <rule ref="category/java/multithreading.xml/UseConcurrentHashMap" /> -->
|
||||
<rule ref="category/java/multithreading.xml/UseNotifyAllInsteadOfNotify"/>
|
||||
|
||||
|
20
gruppe.yml
20
gruppe.yml
@ -1,20 +0,0 @@
|
||||
# Bei "schicht" können Sie 'vormittags', 'nachmittags' oder 'egal' eintragen.
|
||||
|
||||
gruppe: IT-Bois
|
||||
url: https://github.com/hhu-propra2/abschlussprojekt-it-bois
|
||||
names:
|
||||
- killerber4t
|
||||
- tomvahl
|
||||
- AndiBuls
|
||||
- XXNitram
|
||||
- LukasEttel
|
||||
- Mahgs
|
||||
- ChUrl
|
||||
- kasch309
|
||||
notebook: true
|
||||
schicht: nachmittags
|
||||
projektauswahl:
|
||||
- Gruppenbildung
|
||||
- Punkteübersicht
|
||||
- Materialsammlung
|
||||
- Korrektorinnen Bewerbung
|
@ -55,7 +55,7 @@ public class LogAspect {
|
||||
joinPoint.proceed();
|
||||
long stop = System.currentTimeMillis();
|
||||
|
||||
log.trace("Ausführungsdauer: {} Millis", (stop - start));
|
||||
log.trace("Ausführungsdauer: {} Millis", stop - start);
|
||||
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Schreibt eine benutzerdefinierte Nachricht in den Trace-Stream bei Methodenaufruf
|
||||
* Schreibt eine benutzerdefinierte Nachricht in den Trace-Stream bei Methodenaufruf.
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -7,7 +7,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Schreibt die Methodenausführdauer in den Trace-Stream
|
||||
* Schreibt die Methodenausführdauer in den Trace-Stream.
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Schreibt eine Nachricht bei Methodenausführung in den Trace-Stream
|
||||
* Schreibt eine Nachricht bei Methodenausführung in den Trace-Stream.
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Schreibt eine Nachricht für jede ausgeführte Methode einer Klasse in den Trace-Stream
|
||||
* Schreibt eine Nachricht für jede ausgeführte Methode einer Klasse in den Trace-Stream.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -1,17 +1,15 @@
|
||||
package mops.gruppen2.domain.service;
|
||||
package mops.gruppen2.domain.helper;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.web.api.GroupRequestWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Log4j2
|
||||
public class APIService {
|
||||
public final class APIHelper {
|
||||
|
||||
private APIService() {}
|
||||
private APIHelper() {}
|
||||
|
||||
public static GroupRequestWrapper wrap(long status, List<Group> groupList) {
|
||||
return new GroupRequestWrapper(status, groupList);
|
@ -1,4 +1,4 @@
|
||||
package mops.gruppen2.domain.service;
|
||||
package mops.gruppen2.domain.helper;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectReader;
|
||||
import com.fasterxml.jackson.dataformat.csv.CsvMapper;
|
||||
@ -7,7 +7,6 @@ import lombok.extern.log4j.Log4j2;
|
||||
import mops.gruppen2.domain.User;
|
||||
import mops.gruppen2.domain.exception.EventException;
|
||||
import mops.gruppen2.domain.exception.WrongFileException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -16,11 +15,10 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Log4j2
|
||||
public final class CsvService {
|
||||
public final class CsvHelper {
|
||||
|
||||
private CsvService() {}
|
||||
private CsvHelper() {}
|
||||
|
||||
public static List<User> readCsvFile(MultipartFile file) throws EventException {
|
||||
if (file == null || file.isEmpty()) {
|
@ -1,21 +1,19 @@
|
||||
package mops.gruppen2.domain.service;
|
||||
package mops.gruppen2.domain.helper;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Log4j2
|
||||
public final class IdService {
|
||||
public final class IdHelper {
|
||||
|
||||
private IdService() {}
|
||||
private IdHelper() {}
|
||||
|
||||
public static List<UUID> stringsToUUID(List<String> groupIds) {
|
||||
return groupIds.stream()
|
||||
.map(IdService::stringToUUID)
|
||||
.map(IdHelper::stringToUUID)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
@ -1,19 +1,17 @@
|
||||
package mops.gruppen2.domain.service;
|
||||
package mops.gruppen2.domain.helper;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Übersetzt JSON-Event-Payloads zu Java-Event-Repräsentationen und zurück.
|
||||
*/
|
||||
@Service
|
||||
@Log4j2
|
||||
public final class JsonService {
|
||||
public final class JsonHelper {
|
||||
|
||||
private JsonService() {}
|
||||
private JsonHelper() {}
|
||||
|
||||
/**
|
||||
* Übersetzt eine Java-Event-Repräsentation zu einem JSON-Event-Payload.
|
||||
@ -25,7 +23,7 @@ public final class JsonService {
|
||||
* @throws JsonProcessingException Bei JSON Fehler
|
||||
*/
|
||||
|
||||
static String serializeEvent(Event event) throws JsonProcessingException {
|
||||
public static String serializeEvent(Event event) throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return mapper.writeValueAsString(event);
|
||||
}
|
||||
@ -39,7 +37,7 @@ public final class JsonService {
|
||||
*
|
||||
* @throws JsonProcessingException Bei JSON Fehler
|
||||
*/
|
||||
static Event deserializeEvent(String json) throws JsonProcessingException {
|
||||
public static Event deserializeEvent(String json) throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return mapper.readValue(json, Event.class);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mops.gruppen2.domain.service;
|
||||
package mops.gruppen2.domain.helper;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import mops.gruppen2.domain.Group;
|
||||
@ -12,15 +12,13 @@ import mops.gruppen2.domain.exception.UserAlreadyExistsException;
|
||||
import mops.gruppen2.domain.exception.UserNotFoundException;
|
||||
import mops.gruppen2.web.form.CreateForm;
|
||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import static mops.gruppen2.domain.Role.ADMIN;
|
||||
|
||||
@Service
|
||||
@Log4j2
|
||||
public final class ValidationService {
|
||||
public final class ValidationHelper {
|
||||
|
||||
private ValidationService() {}
|
||||
private ValidationHelper() {}
|
||||
|
||||
|
||||
// ######################################## CHECK ############################################
|
@ -7,6 +7,8 @@ import mops.gruppen2.domain.event.AddUserEvent;
|
||||
import mops.gruppen2.domain.event.CreateGroupEvent;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import mops.gruppen2.domain.exception.BadPayloadException;
|
||||
import mops.gruppen2.domain.helper.IdHelper;
|
||||
import mops.gruppen2.domain.helper.JsonHelper;
|
||||
import mops.gruppen2.persistance.EventRepository;
|
||||
import mops.gruppen2.persistance.dto.EventDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -80,7 +82,7 @@ public class EventStoreService {
|
||||
*/
|
||||
static EventDTO getDTOFromEvent(Event event) {
|
||||
try {
|
||||
String payload = JsonService.serializeEvent(event);
|
||||
String payload = JsonHelper.serializeEvent(event);
|
||||
return new EventDTO(null,
|
||||
event.getGroupId().toString(),
|
||||
event.getUserId(),
|
||||
@ -107,7 +109,7 @@ public class EventStoreService {
|
||||
|
||||
private static Event getEventFromDTO(EventDTO dto) {
|
||||
try {
|
||||
return JsonService.deserializeEvent(dto.getEvent_payload());
|
||||
return JsonHelper.deserializeEvent(dto.getEvent_payload());
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Payload {} konnte nicht deserialisiert werden!", dto.getEvent_payload(), e);
|
||||
throw new BadPayloadException(EventStoreService.class.toString());
|
||||
@ -231,7 +233,7 @@ public class EventStoreService {
|
||||
|
||||
List<Event> findEventsByGroupAndType(List<UUID> groupIds, String... types) {
|
||||
return getEventsFromDTOs(eventStore.findEventDTOsByGroupAndType(Arrays.asList(types),
|
||||
IdService.uuidsToString(groupIds)));
|
||||
IdHelper.uuidsToString(groupIds)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,7 @@ import mops.gruppen2.domain.event.UpdateGroupTitleEvent;
|
||||
import mops.gruppen2.domain.event.UpdateRoleEvent;
|
||||
import mops.gruppen2.domain.event.UpdateUserLimitEvent;
|
||||
import mops.gruppen2.domain.exception.EventException;
|
||||
import mops.gruppen2.domain.helper.ValidationHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -115,8 +116,8 @@ public class GroupService {
|
||||
* @throws EventException Falls der User nicht gefunden wird
|
||||
*/
|
||||
public void toggleMemberRole(User user, Group group) throws EventException {
|
||||
ValidationService.throwIfNoMember(group, user);
|
||||
ValidationService.throwIfLastAdmin(user, group);
|
||||
ValidationHelper.throwIfNoMember(group, user);
|
||||
ValidationHelper.throwIfLastAdmin(user, group);
|
||||
|
||||
Role role = group.getRoles().get(user.getId());
|
||||
updateRole(user, group, role.toggle());
|
||||
@ -148,8 +149,8 @@ public class GroupService {
|
||||
* Prüft, ob der Nutzer schon Mitglied ist und ob Gruppe voll ist.
|
||||
*/
|
||||
public void addUser(User user, Group group) {
|
||||
ValidationService.throwIfMember(group, user);
|
||||
ValidationService.throwIfGroupFull(group);
|
||||
ValidationHelper.throwIfMember(group, user);
|
||||
ValidationHelper.throwIfGroupFull(group);
|
||||
|
||||
Event event = new AddUserEvent(group, user);
|
||||
event.apply(group);
|
||||
@ -173,10 +174,10 @@ public class GroupService {
|
||||
* Prüft, ob der Nutzer Mitglied ist und ob er der letzte Admin ist.
|
||||
*/
|
||||
public void deleteUser(User user, Group group) throws EventException {
|
||||
ValidationService.throwIfNoMember(group, user);
|
||||
ValidationService.throwIfLastAdmin(user, group);
|
||||
ValidationHelper.throwIfNoMember(group, user);
|
||||
ValidationHelper.throwIfLastAdmin(user, group);
|
||||
|
||||
if (ValidationService.checkIfGroupEmpty(group)) {
|
||||
if (ValidationHelper.checkIfGroupEmpty(group)) {
|
||||
deleteGroup(user, group);
|
||||
} else {
|
||||
Event event = new DeleteUserEvent(group, user);
|
||||
@ -191,7 +192,7 @@ public class GroupService {
|
||||
* Prüft, ob der Nutzer Admin ist.
|
||||
*/
|
||||
public void deleteGroup(User user, Group group) {
|
||||
ValidationService.throwIfNoAdmin(group, user);
|
||||
ValidationHelper.throwIfNoAdmin(group, user);
|
||||
|
||||
Event event = new DeleteGroupEvent(group, user);
|
||||
event.apply(group);
|
||||
@ -206,7 +207,7 @@ public class GroupService {
|
||||
* Bei keiner Änderung wird nichts erzeugt.
|
||||
*/
|
||||
public void updateTitle(User user, Group group, String title) {
|
||||
ValidationService.throwIfNoAdmin(group, user);
|
||||
ValidationHelper.throwIfNoAdmin(group, user);
|
||||
|
||||
if (title.trim().equals(group.getTitle())) {
|
||||
return;
|
||||
@ -224,7 +225,7 @@ public class GroupService {
|
||||
* Bei keiner Änderung wird nichts erzeugt.
|
||||
*/
|
||||
public void updateDescription(User user, Group group, String description) {
|
||||
ValidationService.throwIfNoAdmin(group, user);
|
||||
ValidationHelper.throwIfNoAdmin(group, user);
|
||||
|
||||
if (description.trim().equals(group.getDescription())) {
|
||||
return;
|
||||
@ -242,7 +243,7 @@ public class GroupService {
|
||||
* Bei keiner Änderung wird nichts erzeugt.
|
||||
*/
|
||||
private void updateRole(User user, Group group, Role role) {
|
||||
ValidationService.throwIfNoMember(group, user);
|
||||
ValidationHelper.throwIfNoMember(group, user);
|
||||
|
||||
if (role == group.getRoles().get(user.getId())) {
|
||||
return;
|
||||
@ -260,7 +261,7 @@ public class GroupService {
|
||||
* Bei keiner Änderung wird nichts erzeugt.
|
||||
*/
|
||||
public void updateUserLimit(User user, Group group, long userLimit) {
|
||||
ValidationService.throwIfNoAdmin(group, user);
|
||||
ValidationHelper.throwIfNoAdmin(group, user);
|
||||
|
||||
if (userLimit == group.getUserLimit()) {
|
||||
return;
|
||||
|
@ -7,6 +7,7 @@ import mops.gruppen2.domain.User;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import mops.gruppen2.domain.exception.EventException;
|
||||
import mops.gruppen2.domain.exception.GroupNotFoundException;
|
||||
import mops.gruppen2.domain.helper.IdHelper;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -185,7 +186,7 @@ public class ProjectionService {
|
||||
* @throws GroupNotFoundException Wenn die Gruppe nicht gefunden wird
|
||||
*/
|
||||
public Group projectSingleGroup(UUID groupId) throws GroupNotFoundException {
|
||||
if (IdService.isEmpty(groupId)) {
|
||||
if (IdHelper.isEmpty(groupId)) {
|
||||
throw new GroupNotFoundException(groupId + ": " + ProjectionService.class);
|
||||
}
|
||||
|
||||
@ -202,7 +203,7 @@ public class ProjectionService {
|
||||
* Projiziert eine einzelne Gruppe, welche leer sein darf.
|
||||
*/
|
||||
public Group projectParent(UUID parentId) {
|
||||
if (IdService.isEmpty(parentId)) {
|
||||
if (IdHelper.isEmpty(parentId)) {
|
||||
return new Group();
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,9 @@ import lombok.extern.log4j.Log4j2;
|
||||
import mops.gruppen2.aspect.annotation.TraceMethodCalls;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.User;
|
||||
import mops.gruppen2.domain.service.APIService;
|
||||
import mops.gruppen2.domain.helper.APIHelper;
|
||||
import mops.gruppen2.domain.helper.IdHelper;
|
||||
import mops.gruppen2.domain.service.EventStoreService;
|
||||
import mops.gruppen2.domain.service.IdService;
|
||||
import mops.gruppen2.domain.service.ProjectionService;
|
||||
import mops.gruppen2.web.api.GroupRequestWrapper;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
@ -50,8 +50,8 @@ public class APIController {
|
||||
public GroupRequestWrapper getApiUpdate(@ApiParam("Letzte gespeicherte EventId des Anfragestellers")
|
||||
@PathVariable("id") long eventId) {
|
||||
|
||||
return APIService.wrap(eventStoreService.findMaxEventId(),
|
||||
projectionService.projectNewGroups(eventId));
|
||||
return APIHelper.wrap(eventStoreService.findMaxEventId(),
|
||||
projectionService.projectNewGroups(eventId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,7 +63,7 @@ public class APIController {
|
||||
public List<String> getApiUserGroups(@ApiParam("Nutzer-Id")
|
||||
@PathVariable("id") String userId) {
|
||||
|
||||
return IdService.uuidsToString(eventStoreService.findExistingUserGroups(new User(userId)));
|
||||
return IdHelper.uuidsToString(eventStoreService.findExistingUserGroups(new User(userId)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,11 +4,11 @@ import lombok.extern.log4j.Log4j2;
|
||||
import mops.gruppen2.aspect.annotation.TraceMethodCalls;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.User;
|
||||
import mops.gruppen2.domain.service.CsvService;
|
||||
import mops.gruppen2.domain.helper.CsvHelper;
|
||||
import mops.gruppen2.domain.helper.IdHelper;
|
||||
import mops.gruppen2.domain.helper.ValidationHelper;
|
||||
import mops.gruppen2.domain.service.GroupService;
|
||||
import mops.gruppen2.domain.service.IdService;
|
||||
import mops.gruppen2.domain.service.ProjectionService;
|
||||
import mops.gruppen2.domain.service.ValidationService;
|
||||
import mops.gruppen2.web.form.CreateForm;
|
||||
import mops.gruppen2.web.form.MetaForm;
|
||||
import mops.gruppen2.web.form.UserLimitForm;
|
||||
@ -56,7 +56,7 @@ public class GroupCreationController {
|
||||
@Valid UserLimitForm limit) {
|
||||
|
||||
// Zusätzlicher check: studentin kann keine lecture erstellen
|
||||
ValidationService.validateCreateForm(token, create);
|
||||
ValidationHelper.validateCreateForm(token, create);
|
||||
|
||||
User user = new User(token);
|
||||
Group group = groupService.createGroup(user,
|
||||
@ -68,9 +68,9 @@ public class GroupCreationController {
|
||||
|
||||
// ROLE_studentin kann kein CSV importieren
|
||||
if (token.getAccount().getRoles().contains("orga")) {
|
||||
groupService.addUsersToGroup(CsvService.readCsvFile(create.getFile()), group, user);
|
||||
groupService.addUsersToGroup(CsvHelper.readCsvFile(create.getFile()), group, user);
|
||||
}
|
||||
|
||||
return "redirect:/gruppen2/details/" + IdService.uuidToString(group.getId());
|
||||
return "redirect:/gruppen2/details/" + IdHelper.uuidToString(group.getId());
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ import lombok.extern.log4j.Log4j2;
|
||||
import mops.gruppen2.aspect.annotation.TraceMethodCalls;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.User;
|
||||
import mops.gruppen2.domain.service.CsvService;
|
||||
import mops.gruppen2.domain.helper.CsvHelper;
|
||||
import mops.gruppen2.domain.helper.IdHelper;
|
||||
import mops.gruppen2.domain.helper.ValidationHelper;
|
||||
import mops.gruppen2.domain.service.GroupService;
|
||||
import mops.gruppen2.domain.service.IdService;
|
||||
import mops.gruppen2.domain.service.InviteService;
|
||||
import mops.gruppen2.domain.service.ProjectionService;
|
||||
import mops.gruppen2.domain.service.ValidationService;
|
||||
import mops.gruppen2.web.form.MetaForm;
|
||||
import mops.gruppen2.web.form.UserLimitForm;
|
||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||
@ -63,7 +63,7 @@ public class GroupDetailsController {
|
||||
model.addAttribute("parent", parent);
|
||||
|
||||
// Detailseite für nicht-Mitglieder
|
||||
if (!ValidationService.checkIfMember(group, user)) {
|
||||
if (!ValidationHelper.checkIfMember(group, user)) {
|
||||
return "preview";
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ public class GroupDetailsController {
|
||||
User user = new User(token);
|
||||
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
|
||||
|
||||
if (ValidationService.checkIfMember(group, user)) {
|
||||
if (ValidationHelper.checkIfMember(group, user)) {
|
||||
return "redirect:/gruppen2/details/" + groupId;
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ public class GroupDetailsController {
|
||||
User user = new User(token);
|
||||
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
|
||||
|
||||
ValidationService.throwIfNoMember(group, user);
|
||||
ValidationHelper.throwIfNoMember(group, user);
|
||||
|
||||
groupService.deleteUser(user, group);
|
||||
|
||||
@ -119,7 +119,7 @@ public class GroupDetailsController {
|
||||
String serverURL = actualURL.substring(0, actualURL.indexOf("gruppen2/"));
|
||||
String link = serverURL + "gruppen2/join/" + inviteService.getLinkByGroup(group);
|
||||
|
||||
ValidationService.throwIfNoAdmin(group, user);
|
||||
ValidationHelper.throwIfNoAdmin(group, user);
|
||||
|
||||
model.addAttribute("group", group);
|
||||
model.addAttribute("link", link);
|
||||
@ -165,9 +165,9 @@ public class GroupDetailsController {
|
||||
@RequestParam(value = "file", required = false) MultipartFile file) {
|
||||
|
||||
User user = new User(token);
|
||||
Group group = projectionService.projectSingleGroup(IdService.stringToUUID(groupId));
|
||||
Group group = projectionService.projectSingleGroup(IdHelper.stringToUUID(groupId));
|
||||
|
||||
groupService.addUsersToGroup(CsvService.readCsvFile(file), group, user);
|
||||
groupService.addUsersToGroup(CsvHelper.readCsvFile(file), group, user);
|
||||
|
||||
return "redirect:/gruppen2/details/" + groupId + "/edit";
|
||||
}
|
||||
@ -182,12 +182,12 @@ public class GroupDetailsController {
|
||||
User user = new User(token);
|
||||
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
|
||||
|
||||
ValidationService.throwIfNoAdmin(group, user);
|
||||
ValidationHelper.throwIfNoAdmin(group, user);
|
||||
|
||||
groupService.toggleMemberRole(new User(userId), group);
|
||||
|
||||
// Falls sich der User selbst die Rechte genommen hat
|
||||
if (!ValidationService.checkIfAdmin(group, user)) {
|
||||
if (!ValidationHelper.checkIfAdmin(group, user)) {
|
||||
return "redirect:/gruppen2/details/" + groupId;
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ public class GroupDetailsController {
|
||||
User user = new User(token);
|
||||
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
|
||||
|
||||
ValidationService.throwIfNoAdmin(group, user);
|
||||
ValidationHelper.throwIfNoAdmin(group, user);
|
||||
|
||||
// Der eingeloggte User kann sich nicht selbst entfernen (er kann aber verlassen)
|
||||
if (!userId.equals(user.getId())) {
|
||||
|
@ -5,10 +5,10 @@ import mops.gruppen2.aspect.annotation.TraceMethodCalls;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.GroupType;
|
||||
import mops.gruppen2.domain.User;
|
||||
import mops.gruppen2.domain.helper.ValidationHelper;
|
||||
import mops.gruppen2.domain.service.InviteService;
|
||||
import mops.gruppen2.domain.service.ProjectionService;
|
||||
import mops.gruppen2.domain.service.SearchService;
|
||||
import mops.gruppen2.domain.service.ValidationService;
|
||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@ -79,7 +79,7 @@ public class SearchAndInviteController {
|
||||
}
|
||||
|
||||
// Bereits Mitglied
|
||||
if (ValidationService.checkIfMember(group, user)) {
|
||||
if (ValidationHelper.checkIfMember(group, user)) {
|
||||
return "redirect:/gruppen2/details/" + group.getId();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package mops.gruppen2.web.form;
|
||||
|
||||
import lombok.Data;
|
||||
import mops.gruppen2.domain.GroupType;
|
||||
import mops.gruppen2.domain.service.IdService;
|
||||
import mops.gruppen2.domain.helper.IdHelper;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
@ -24,6 +24,6 @@ public class CreateForm {
|
||||
}
|
||||
|
||||
public UUID getParent() {
|
||||
return getType() == GroupType.LECTURE ? IdService.emptyUUID() : IdService.stringToUUID(parent);
|
||||
return getType() == GroupType.LECTURE ? IdHelper.emptyUUID() : IdHelper.stringToUUID(parent);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package mops.gruppen2.domain.service;
|
||||
|
||||
import mops.gruppen2.Gruppen2Application;
|
||||
import mops.gruppen2.domain.Account;
|
||||
import mops.gruppen2.domain.helper.ValidationHelper;
|
||||
import mops.gruppen2.persistance.EventRepository;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -23,7 +24,7 @@ class ControllerServiceTest {
|
||||
@Autowired
|
||||
EventStoreService eventStoreService;
|
||||
@Autowired
|
||||
ValidationService validationService;
|
||||
ValidationHelper validationHelper;
|
||||
@Autowired
|
||||
EventRepository eventRepository;
|
||||
@Autowired
|
||||
|
@ -6,6 +6,7 @@ import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.GroupType;
|
||||
import mops.gruppen2.domain.User;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import mops.gruppen2.domain.helper.ValidationHelper;
|
||||
import mops.gruppen2.persistance.EventRepository;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
@ -53,7 +54,7 @@ class GroupServiceTest {
|
||||
@Autowired
|
||||
private EventStoreService eventStoreService;
|
||||
@Autowired
|
||||
private ValidationService validationService;
|
||||
private ValidationHelper validationHelper;
|
||||
@Autowired
|
||||
private InviteService inviteService;
|
||||
|
||||
|
Reference in New Issue
Block a user