summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2021-05-19 13:12:33 +0200
committerSimon Rettberg2021-05-19 13:12:33 +0200
commit470eeb92e9164e631c790eb27c1f79ba88bfecf8 (patch)
tree08ac90143297fc4449b7e05a62e23a29469996e5
parent[server] Restart database docker container only on failure (diff)
downloadtutor-module-470eeb92.tar.gz
tutor-module-470eeb92.tar.xz
tutor-module-470eeb92.zip
[server] Fix inverted user == null logic
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java10
1 files changed, 5 insertions, 5 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 edf02eb4..cbaae1ab 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,8 +90,8 @@ 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 == null || user.role == Role.STUDENT) {
- stmt = connection.prepareStatement("SELECT i.imagebaseid, i.latestversionid, i.virtid"
+ if (user != null && user.role == Role.STUDENT) {
+ stmt = connection.prepareStatement("SELECT i.imagebaseid, i.latestversionid, i.virtid, i.osid"
+ " FROM imagebase i"
+ " LEFT JOIN imagepermission perm ON (i.imagebaseid = perm.imagebaseid AND perm.userid = :userid)"
+ " WHERE i.imagebaseid = :imagebaseid");
@@ -115,7 +115,7 @@ public class DbImage {
List<ImageVersionDetails> versions = getImageVersions(connection, imageBaseId, user);
ImageDetailsRead image;
- if (user == null || 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 == null || 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 != null && user.role != Role.STUDENT) {
+ if (user == null || user.role != Role.STUDENT) {
uploaderID = rs.getString("uploaderid");
}
versionList.add(new ImageVersionDetails(imageVersionId, rs.getLong("createtime"),