1

Add check for empty csv file

and set required parameter to false

Co-Authored-By: Lukas Ettel <lukasettel@users.noreply.github.com>
This commit is contained in:
XXNitram
2020-03-18 15:05:09 +01:00
parent ecd6154580
commit 7e52935b77

View File

@ -79,10 +79,13 @@ public class Gruppen2Controller {
@RequestParam(value = "title") String title, @RequestParam(value = "title") String title,
@RequestParam(value = "beschreibung") String beschreibung, @RequestParam(value = "beschreibung") String beschreibung,
@RequestParam(value = "visibility", required = false) Boolean visibility, @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); Account account = keyCloakService.createAccountFromPrincipal(token);
List<User> userList = CsvService.read(file.getInputStream()); List<User> userList = new ArrayList<>();
if(!file.isEmpty()) {
userList = CsvService.read(file.getInputStream());
}
visibility = visibility == null; visibility = visibility == null;
controllerService.createLecture(account, title, beschreibung, visibility, userList); controllerService.createLecture(account, title, beschreibung, visibility, userList);