From 7e52935b777f9fec88ebb26bb555826d16b59318 Mon Sep 17 00:00:00 2001 From: XXNitram Date: Wed, 18 Mar 2020 15:05:09 +0100 Subject: [PATCH] Add check for empty csv file and set required parameter to false Co-Authored-By: Lukas Ettel --- .../java/mops/gruppen2/controller/Gruppen2Controller.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/mops/gruppen2/controller/Gruppen2Controller.java b/src/main/java/mops/gruppen2/controller/Gruppen2Controller.java index a6bdcca..9ae3d51 100644 --- a/src/main/java/mops/gruppen2/controller/Gruppen2Controller.java +++ b/src/main/java/mops/gruppen2/controller/Gruppen2Controller.java @@ -79,10 +79,13 @@ public class Gruppen2Controller { @RequestParam(value = "title") String title, @RequestParam(value = "beschreibung") String beschreibung, @RequestParam(value = "visibility", required = false) Boolean visibility, - @RequestParam("file") MultipartFile file) throws IOException { + @RequestParam(value = "file", required = false) MultipartFile file) throws IOException { Account account = keyCloakService.createAccountFromPrincipal(token); - List userList = CsvService.read(file.getInputStream()); + List userList = new ArrayList<>(); + if(!file.isEmpty()) { + userList = CsvService.read(file.getInputStream()); + } visibility = visibility == null; controllerService.createLecture(account, title, beschreibung, visibility, userList);