1

Refactor WebController and ValidationService

Co-Authored-By: Talha Caliskan <killerber4t@users.noreply.github.com>
This commit is contained in:
XXNitram
2020-03-25 15:43:41 +01:00
parent 1dd3f9b6fe
commit 0c43050166
3 changed files with 120 additions and 115 deletions

View File

@ -76,22 +76,11 @@ public class ControllerService {
updateRole(account.getName(), groupId);
}
public void createOrga(Account account, String title, String description, Boolean visibility, Boolean lecture, Boolean maxInfiniteUsers, Long userMaximum, UUID parent, MultipartFile file) throws EventException, IOException {
public UUID createOrga(Account account, String title, String description, Boolean visibility, Boolean lecture, Boolean maxInfiniteUsers, Long userMaximum, UUID parent) throws EventException, IOException {
List<User> userList = new ArrayList<>();
if (userMaximum == null) {
userMaximum = 100000L;
}
if (!file.isEmpty()) {
try {
userList = CsvService.read(file.getInputStream());
if (userList.size() > userMaximum) {
userMaximum = (long) userList.size() + userMaximum;
}
} catch (UnrecognizedPropertyException | CharConversionException ex) {
logger.warning("File konnte nicht gelesen werden");
throw new WrongFileException(file.getOriginalFilename());
}
}
visibility = visibility == null;
lecture = lecture != null;
maxInfiniteUsers = maxInfiniteUsers != null;
@ -122,7 +111,8 @@ public class ControllerService {
updateTitle(account, groupId, title);
updateDescription(account, groupId, description);
updateRole(account.getName(), groupId);
addUserList(userList, groupId);
return groupId;
}