summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Sanitizer.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-09-04 19:22:07 +0200
committerSimon Rettberg2015-09-04 19:22:07 +0200
commitd18172067ab35d2721cb8764976d2753d6b37ba2 (patch)
tree9346669d6c4d6eb23d096abac92f1df5c5df66d0 /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Sanitizer.java
parent[client] Close details windows on save, 'Cancel' => 'Close' (diff)
downloadtutor-module-d18172067ab35d2721cb8764976d2753d6b37ba2.tar.gz
tutor-module-d18172067ab35d2721cb8764976d2753d6b37ba2.tar.xz
tutor-module-d18172067ab35d2721cb8764976d2753d6b37ba2.zip
[server] Sanitize permissions when saving/checking
Diffstat (limited to 'dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Sanitizer.java')
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Sanitizer.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Sanitizer.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Sanitizer.java
index 52a32288..8ce4df5c 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Sanitizer.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Sanitizer.java
@@ -2,6 +2,8 @@ package org.openslx.bwlp.sat.util;
import org.openslx.bwlp.sat.RuntimeConfig;
import org.openslx.bwlp.thrift.iface.DateParamError;
+import org.openslx.bwlp.thrift.iface.ImagePermissions;
+import org.openslx.bwlp.thrift.iface.LecturePermissions;
import org.openslx.bwlp.thrift.iface.LectureWrite;
import org.openslx.bwlp.thrift.iface.TInvalidDateParam;
@@ -64,4 +66,35 @@ public class Sanitizer {
throw new TInvalidDateParam(DateParamError.TOO_HIGH, "Expiry date lies too far in the future");
}
+ /**
+ * Set consistent state for lecture permissions on writing.
+ */
+ public static LecturePermissions handleLecturePermissions(LecturePermissions perms) {
+ if (perms == null)
+ return new LecturePermissions();
+ if (perms.admin && !perms.edit) {
+ perms = new LecturePermissions(perms);
+ perms.edit = true;
+ }
+ return perms;
+ }
+
+ /**
+ * Set consistent state for image permissions on writing.
+ */
+ public static ImagePermissions handleImagePermissions(ImagePermissions perms) {
+ if (perms == null)
+ return new ImagePermissions();
+ if (perms.admin && (!perms.edit || !perms.download || !perms.link)) {
+ perms = new ImagePermissions(perms);
+ perms.edit = true;
+ perms.download = true;
+ perms.link = true;
+ } else if (perms.edit && !perms.download) {
+ perms = new ImagePermissions(perms);
+ perms.download = true;
+ }
+ return perms;
+ }
+
}