summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-08-13 18:18:46 +0200
committerSimon Rettberg2015-08-13 18:18:46 +0200
commit13f7d6ad1a2ede4761d4758617e939c5dc386d3c (patch)
treeb3088f670598973deffb3ee02b248d313f5a592d /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java
parent[client] More layout tweaks, cleanups, GridManager usage (diff)
downloadtutor-module-13f7d6ad1a2ede4761d4758617e939c5dc386d3c.tar.gz
tutor-module-13f7d6ad1a2ede4761d4758617e939c5dc386d3c.tar.xz
tutor-module-13f7d6ad1a2ede4761d4758617e939c5dc386d3c.zip
[server] Validate lecture/imageversion dates, conditionally set isTemplate
Diffstat (limited to 'dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java')
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java32
1 files changed, 17 insertions, 15 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java
index 7ce167e0..2a9d5d6f 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java
@@ -7,7 +7,7 @@ import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
-import org.openslx.bwlp.sat.database.Paginator;
+import org.openslx.bwlp.sat.RuntimeConfig;
import org.openslx.bwlp.sat.database.mappers.DbImage;
import org.openslx.bwlp.sat.database.mappers.DbImagePermissions;
import org.openslx.bwlp.sat.database.mappers.DbLecture;
@@ -19,6 +19,7 @@ import org.openslx.bwlp.sat.permissions.User;
import org.openslx.bwlp.sat.thrift.cache.OperatingSystemList;
import org.openslx.bwlp.sat.thrift.cache.OrganizationList;
import org.openslx.bwlp.sat.thrift.cache.VirtualizerList;
+import org.openslx.bwlp.sat.util.Sanitizer;
import org.openslx.bwlp.sat.util.Util;
import org.openslx.bwlp.thrift.iface.AuthorizationError;
import org.openslx.bwlp.thrift.iface.ImageBaseWrite;
@@ -39,6 +40,7 @@ import org.openslx.bwlp.thrift.iface.ShareMode;
import org.openslx.bwlp.thrift.iface.TAuthorizationException;
import org.openslx.bwlp.thrift.iface.TImageDataException;
import org.openslx.bwlp.thrift.iface.TInternalServerError;
+import org.openslx.bwlp.thrift.iface.TInvalidDateParam;
import org.openslx.bwlp.thrift.iface.TInvalidTokenException;
import org.openslx.bwlp.thrift.iface.TNotFoundException;
import org.openslx.bwlp.thrift.iface.TTransferRejectedException;
@@ -55,17 +57,6 @@ public class ServerHandler implements SatelliteServer.Iface {
private static final FileServer fileServer = FileServer.instance();
- private static final SatelliteConfig satConfig;
-
- static {
- satConfig = new SatelliteConfig();
- satConfig.setDefaultImagePermissions(new ImagePermissions(true, true, false, false));
- satConfig.setDefaultLecturePermissions(new LecturePermissions(false, false));
- satConfig.setMaxImageValidityDays(200);
- satConfig.setMaxLectureValidityDays(100);
- satConfig.setPageSize(Paginator.PER_PAGE);
- }
-
@Override
public long getVersion() {
return Version.VERSION;
@@ -73,7 +64,7 @@ public class ServerHandler implements SatelliteServer.Iface {
@Override
public SatelliteConfig getConfiguration() {
- return satConfig;
+ return RuntimeConfig.get();
}
/*
@@ -255,6 +246,7 @@ public class ServerHandler implements SatelliteServer.Iface {
}
// TODO: Should other fields be validated? Most fields should be protected by fk constraints,
// but the user would only get a generic error, with no hint at the actual problem.
+ // The update routine will make sure only the super user can change the template flag
DbImage.updateImageMetadata(user, imageBaseId, newData);
} catch (SQLException e1) {
throw new TInternalServerError();
@@ -350,10 +342,19 @@ public class ServerHandler implements SatelliteServer.Iface {
}
@Override
+ public void setImageVersionExpiry(String userToken, String imageBaseId, long expireTime)
+ throws TAuthorizationException, TNotFoundException, TInternalServerError, TInvalidDateParam,
+ TException {
+ UserInfo user = SessionManager.getOrFail(userToken);
+ User.canChangeImageExpireDateOrFail(user);
+ }
+
+ @Override
public String createLecture(String userToken, LectureWrite lecture) throws TAuthorizationException,
- TInternalServerError {
+ TInternalServerError, TInvalidDateParam {
UserInfo user = SessionManager.getOrFail(userToken);
User.canCreateLectureOrFail(user);
+ Sanitizer.handleLectureDates(lecture);
try {
return DbLecture.create(user, lecture);
} catch (SQLException e) {
@@ -363,9 +364,10 @@ public class ServerHandler implements SatelliteServer.Iface {
@Override
public void updateLecture(String userToken, String lectureId, LectureWrite lecture)
- throws TAuthorizationException, TNotFoundException, TInternalServerError {
+ throws TAuthorizationException, TNotFoundException, TInternalServerError, TInvalidDateParam {
UserInfo user = SessionManager.getOrFail(userToken);
User.canEditLectureOrFail(user, lectureId);
+ Sanitizer.handleLectureDates(lecture);
try {
DbLecture.update(user, lectureId, lecture);
} catch (SQLException e) {