summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java
diff options
context:
space:
mode:
authorSimon Rettberg2016-04-18 15:18:59 +0200
committerSimon Rettberg2016-04-18 15:18:59 +0200
commita183af9133e033dac3d1be3d3a141296713cb36e (patch)
treebc11129b87b1d40d67cf9ddf20e01066f97213e7 /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java
parent(WiP) Global image sync (diff)
downloadtutor-module-a183af9133e033dac3d1be3d3a141296713cb36e.tar.gz
tutor-module-a183af9133e033dac3d1be3d3a141296713cb36e.tar.xz
tutor-module-a183af9133e033dac3d1be3d3a141296713cb36e.zip
[*] Make uploading images to central server work
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.java58
1 files changed, 33 insertions, 25 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 2d3d2b91..df845fdc 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
@@ -76,8 +76,10 @@ public class ServerHandler implements SatelliteServer.Iface {
private static final FileServer fileServer = FileServer.instance();
@Override
- public long getVersion() {
- return Version.VERSION;
+ public long getVersion(long clientVersion) {
+ if (clientVersion >= Version.VERSION)
+ return Version.VERSION;
+ return Math.max(clientVersion, Version.MIN_VERSION);
}
@Override
@@ -520,11 +522,37 @@ public class ServerHandler implements SatelliteServer.Iface {
}
@Override
+ public String publishImageVersion(String userToken, String imageVersionId)
+ throws TAuthorizationException, TNotFoundException, TInvocationException, TTransferRejectedException {
+ UserInfo user = SessionManager.getOrFail(userToken);
+ User.canCreateImageOrFail(user);
+ LocalImageVersion imgVersion = null;
+ ImageSummaryRead imgBase = null;
+ try {
+ imgVersion = DbImage.getLocalImageData(imageVersionId);
+ imgBase = DbImage.getImageSummary(user, imgVersion.imageBaseId);
+ //img.uploaderId
+ } catch (SQLException e1) {
+ throw new TInvocationException(InvocationError.INTERNAL_SERVER_ERROR, "Database error");
+ }
+ User.canUploadToMasterOrFail(user, imgBase);
+ try {
+ return SyncTransferHandler.requestImageUpload(userToken, imgBase, imgVersion);
+ } catch (TTransferRejectedException e) {
+ LOGGER.warn("Master server rejected upload of image version " + imgVersion.imageVersionId);
+ throw e;
+ } catch (SQLException e) {
+ throw new TInvocationException(InvocationError.INTERNAL_SERVER_ERROR, "Database error");
+ }
+ }
+
+ @Override
public String createLecture(String userToken, LectureWrite lecture) throws TAuthorizationException,
TInvocationException, TInvalidDateParam, TNotFoundException {
if (lecture == null || lecture.defaultPermissions == null)
throw new TInvocationException(InvocationError.MISSING_DATA, "Lecture data missing or incomplete");
- if (lecture.locationIds != null && lecture.locationIds.size() > RuntimeConfig.getMaxLocationsPerLecture())
+ if (lecture.locationIds != null
+ && lecture.locationIds.size() > RuntimeConfig.getMaxLocationsPerLecture())
throw new TInvocationException(InvocationError.INVALID_DATA, "Too many locations for lecture");
UserInfo user = SessionManager.getOrFail(userToken);
User.canCreateLectureOrFail(user);
@@ -542,7 +570,8 @@ public class ServerHandler implements SatelliteServer.Iface {
throws TAuthorizationException, TNotFoundException, TInvocationException, TInvalidDateParam {
if (newLectureData == null)
throw new TInvocationException(InvocationError.MISSING_DATA, "Lecture data missing or incomplete");
- if (newLectureData.locationIds != null && newLectureData.locationIds.size() > RuntimeConfig.getMaxLocationsPerLecture())
+ if (newLectureData.locationIds != null
+ && newLectureData.locationIds.size() > RuntimeConfig.getMaxLocationsPerLecture())
throw new TInvocationException(InvocationError.INVALID_DATA, "Too many locations for lecture");
UserInfo user = SessionManager.getOrFail(userToken);
LectureSummary oldLecture;
@@ -580,27 +609,6 @@ public class ServerHandler implements SatelliteServer.Iface {
@Override
public LectureRead getLectureDetails(String userToken, String lectureId) throws TAuthorizationException,
TNotFoundException, TInvocationException {
- //
- // TEST
- //
- /*
- String imageVersionId = "e9de1941-b673-4711-b033-d8c37d1e2d3e";
- LocalImageVersion img;
- try {
- img = DbImage.getLocalImageData(imageVersionId);
- SyncTransferHandler.requestImageUpload(userToken, img);
- } catch (SQLException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- } catch (TTransferRejectedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- */
- //
- //
- //
- //
UserInfo user = SessionManager.getOrFail(userToken);
User.canSeeLectureDetailsOrFail(user);
try {