diff options
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java index 5b821881..edf02eb4 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java @@ -90,7 +90,7 @@ public class DbImage { try (MysqlConnection connection = Database.getConnection()) { MysqlStatement stmt = null; // Students should only be able to request a download of an image. Therefore not all information is needed for this task. - if (user.role == Role.STUDENT) { + if (user == null || user.role == Role.STUDENT) { stmt = connection.prepareStatement("SELECT i.imagebaseid, i.latestversionid, i.virtid" + " FROM imagebase i" + " LEFT JOIN imagepermission perm ON (i.imagebaseid = perm.imagebaseid AND perm.userid = :userid)" @@ -115,7 +115,7 @@ public class DbImage { List<ImageVersionDetails> versions = getImageVersions(connection, imageBaseId, user); ImageDetailsRead image; - if (user.role == Role.STUDENT) { + if (user == null || user.role == Role.STUDENT) { // Students should only have download permissions. // todo evaluate if this is needed and if there is a nicer way to create ImageDetailsRead object ImagePermissions defaultPermissions = new ImagePermissions(false, true, false, false); @@ -273,7 +273,7 @@ public class DbImage { throws SQLException { List<ImageVersionDetails> versionList = new ArrayList<>(); MysqlStatement stmt = null; - if (user.role == Role.STUDENT) { + if (user == null || user.role == Role.STUDENT) { stmt = connection.prepareStatement("SELECT" + " imageversionid, createtime, expiretime, filesize," + " isrestricted, isvalid, isprocessed" @@ -293,7 +293,7 @@ public class DbImage { String imageVersionId = rs.getString("imageversionid"); String uploaderID = ""; // Only student doesn't know the uploaderid - if (user.role != Role.STUDENT) { + if (user != null && user.role != Role.STUDENT) { uploaderID = rs.getString("uploaderid"); } versionList.add(new ImageVersionDetails(imageVersionId, rs.getLong("createtime"), |