summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodulserver')
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java52
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java5
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java2
3 files changed, 45 insertions, 14 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 6b672c86..da52a5b3 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
@@ -57,7 +57,7 @@ public class DbImage {
// TODO: Implement tag search functionality
try (MysqlConnection connection = Database.getConnection()) {
MysqlStatement stmt = connection.prepareStatement("SELECT"
- + " i.imagebaseid, i.latestversionid, i.displayname,"
+ + " i.imagebaseid, i.latestversionid, i.displayname, i.description,"
+ " i.osid, i.virtid, i.createtime, i.updatetime, i.ownerid,"
+ " i.sharemode, i.istemplate, i.canlinkdefault, i.candownloaddefault,"
+ " i.caneditdefault, i.canadmindefault,"
@@ -87,7 +87,21 @@ public class DbImage {
public static ImageDetailsRead getImageDetails(UserInfo user, String imageBaseId)
throws TNotFoundException, SQLException {
try (MysqlConnection connection = Database.getConnection()) {
- MysqlStatement stmt = connection.prepareStatement("SELECT i.imagebaseid, i.latestversionid,"
+
+ // if Student is trying to download only needed information is filled
+ MysqlStatement stmt = null;
+ if (user.role.equals("STUDENT"))
+ {
+ stmt = connection.prepareStatement("SELECT i.imagebaseid, i.latestversionid,"
+ + " null, null, null, null, null, null, null, null,"
+ + " null, null,"
+ + " null, null, null, null,"
+ + " null, null, null, null"
+ + " FROM imagebase i"
+ + " LEFT JOIN imagepermission perm ON (i.imagebaseid = perm.imagebaseid AND perm.userid = :userid)"
+ + " WHERE i.imagebaseid = :imagebaseid");
+ } else {
+ stmt = connection.prepareStatement("SELECT i.imagebaseid, i.latestversionid,"
+ " i.displayname, i.description, i.osid, i.virtid, i.createtime, i.updatetime, i.ownerid, i.updaterid,"
+ " i.sharemode, i.istemplate,"
+ " i.canlinkdefault, i.candownloaddefault, i.caneditdefault, i.canadmindefault,"
@@ -95,6 +109,13 @@ public class DbImage {
+ " FROM imagebase i"
+ " LEFT JOIN imagepermission perm ON (i.imagebaseid = perm.imagebaseid AND perm.userid = :userid)"
+ " WHERE i.imagebaseid = :imagebaseid");
+ }
+
+
+
+ // if Student is trying to download only needed information is filled
+
+
stmt.setString("userid", user == null ? "-" : user.userId);
stmt.setString("imagebaseid", imageBaseId);
ResultSet rs = stmt.executeQuery();
@@ -102,7 +123,7 @@ public class DbImage {
throw new TNotFoundException();
// Exists:
List<String> tags = DbSoftwareTag.getImageTags(connection, imageBaseId);
- List<ImageVersionDetails> versions = getImageVersions(connection, imageBaseId);
+ List<ImageVersionDetails> versions = getImageVersions(connection, imageBaseId, user);
ImagePermissions defaultPermissions = DbImagePermissions.fromResultSetDefault(rs);
ImageDetailsRead image = new ImageDetailsRead(rs.getString("imagebaseid"),
rs.getString("latestversionid"), versions, rs.getString("displayname"),
@@ -188,8 +209,8 @@ public class DbImage {
private static ImageSummaryRead resultSetToSummary(UserInfo user, ResultSet rs) throws SQLException {
ImagePermissions defaultPermissions = DbImagePermissions.fromResultSetDefault(rs);
ImageSummaryRead entry = new ImageSummaryRead(rs.getString("imagebaseid"),
- rs.getString("latestversionid"), rs.getString("displayname"), rs.getInt("osid"),
- rs.getString("virtid"), rs.getLong("createtime"), rs.getLong("updatetime"),
+ rs.getString("latestversionid"), rs.getString("displayname"), rs.getString("description"),
+ rs.getInt("osid"), rs.getString("virtid"), rs.getLong("createtime"), rs.getLong("updatetime"),
rs.getLong("uploadtime"), rs.getLong("expiretime"), rs.getString("ownerid"),
rs.getString("uploaderid"), toShareMode(rs.getString("sharemode")), rs.getLong("filesize"),
rs.getByte("isrestricted") != 0, rs.getByte("isvalid") != 0, rs.getByte("isprocessed") != 0,
@@ -227,7 +248,7 @@ public class DbImage {
protected static ImageSummaryRead getImageSummary(MysqlConnection connection, UserInfo user,
String imageBaseId) throws SQLException, TNotFoundException {
MysqlStatement stmt = connection.prepareStatement("SELECT"
- + " i.imagebaseid, i.latestversionid, i.displayname,"
+ + " i.imagebaseid, i.latestversionid, i.displayname, i.description,"
+ " i.osid, i.virtid, i.createtime, i.updatetime, i.ownerid,"
+ " i.sharemode, i.istemplate, i.canlinkdefault, i.candownloaddefault,"
+ " i.caneditdefault, i.canadmindefault,"
@@ -247,13 +268,22 @@ public class DbImage {
return resultSetToSummary(user, rs);
}
- protected static List<ImageVersionDetails> getImageVersions(MysqlConnection connection, String imageBaseId)
+ protected static List<ImageVersionDetails> getImageVersions(MysqlConnection connection, String imageBaseId, UserInfo user)
throws SQLException {
List<ImageVersionDetails> versionList = new ArrayList<>();
- MysqlStatement stmt = connection.prepareStatement("SELECT"
- + " imageversionid, createtime, expiretime, filesize, uploaderid,"
- + " isrestricted, isvalid, isprocessed" + " FROM imageversion"
- + " WHERE imagebaseid = :imagebaseid");
+ MysqlStatement stmt = null;
+ if (user.role.equals("STUDENT")) {
+ stmt = connection.prepareStatement("SELECT"
+ + " imageversionid, createtime, expiretime, filesize, null,"
+ + " isrestricted, isvalid, isprocessed" + " FROM imageversion"
+ + " WHERE imagebaseid = :imagebaseid");
+ } else {
+ stmt = connection.prepareStatement("SELECT"
+ + " imageversionid, createtime, expiretime, filesize, uploaderid,"
+ + " isrestricted, isvalid, isprocessed" + " FROM imageversion"
+ + " WHERE imagebaseid = :imagebaseid");
+
+ }
stmt.setString("imagebaseid", imageBaseId);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java
index 3dc58d47..c07a0ed9 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java
@@ -192,6 +192,7 @@ public class DbLecture {
LectureSummary lecture = new LectureSummary();
lecture.setLectureId(rs.getString("lectureid"));
lecture.setLectureName(rs.getString("lecturename"));
+ lecture.setDescription(rs.getString("description"));
lecture.setImageVersionId(rs.getString("imageversionid"));
lecture.setImageBaseId(rs.getString("imagebaseid"));
lecture.setIsEnabled(rs.getBoolean("isenabled"));
@@ -214,7 +215,7 @@ public class DbLecture {
}
private static final String summaryBaseSql = "SELECT"
- + " l.lectureid, l.displayname AS lecturename, l.imageversionid, i.imagebaseid,"
+ + " l.lectureid, l.displayname AS lecturename, l.description, l.imageversionid, i.imagebaseid,"
+ " l.isenabled, l.starttime, l.endtime, l.lastused, l.usecount, l.ownerid, l.updaterid,"
+ " l.isexam, l.hasinternetaccess, l.hasusbaccess, l.caneditdefault, l.canadmindefault,"
+ " i.isvalid AS imgvalid, perm.canedit, perm.canadmin"
@@ -566,7 +567,7 @@ public class DbLecture {
+ " FROM lecture l "
+ " INNER JOIN imageversion i USING (imageversionid)"
+ " INNER JOIN imagebase b USING (imagebaseid)"
- + " INNER JOIN os_x_virt o USING (osid, virtid)" + " WHERE l.lectureid = :lectureid");
+ + " LEFT JOIN os_x_virt o USING (osid, virtid)" + " WHERE l.lectureid = :lectureid");
stmt.setString("lectureid", lectureId);
ResultSet rs = stmt.executeQuery();
long now = Util.unixTime();
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 06c1e5a7..4910ec4c 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
@@ -303,7 +303,7 @@ public class ServerHandler implements SatelliteServer.Iface {
public ImageDetailsRead getImageDetails(String userToken, String imageBaseId)
throws TAuthorizationException, TNotFoundException, TInvocationException {
UserInfo user = SessionManager.getOrFail(userToken);
- User.canSeeImageDetailsOrFail(user);
+
try {
return DbImage.getImageDetails(user, imageBaseId);
} catch (SQLException e) {