diff options
author | Jonathan Bauer | 2016-08-31 16:54:59 +0200 |
---|---|---|
committer | Jonathan Bauer | 2016-08-31 16:54:59 +0200 |
commit | 26cd5699373dbe35ee24700189e8a3e580ae6243 (patch) | |
tree | 0389541c704fbfe05aeb514365e4643f84bbfa20 /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java | |
parent | [client] Reset filter when hiding lecture list if filtered by linked image (diff) | |
download | tutor-module-26cd5699373dbe35ee24700189e8a3e580ae6243.tar.gz tutor-module-26cd5699373dbe35ee24700189e8a3e580ae6243.tar.xz tutor-module-26cd5699373dbe35ee24700189e8a3e580ae6243.zip |
[client] vm-config editor finished, accessible from the popup menu of image's versions
Diffstat (limited to 'dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java')
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java | 34 |
1 files changed, 34 insertions, 0 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 e445721a..eb5bebff 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 @@ -892,6 +892,40 @@ public class DbImage { } } + public static byte[] getVirtualizerConfig(String imageVersionId) throws SQLException, + TNotFoundException { + try (MysqlConnection connection = Database.getConnection()) { + MysqlStatement stmt = connection.prepareStatement("SELECT" + + " virtualizerconfig FROM imageversion" + + " WHERE imageversionid = :imageversionid"); + stmt.setString("imageversionid", imageVersionId); + ResultSet rs = stmt.executeQuery(); + if (!rs.next()) + throw new TNotFoundException(); + return rs.getBytes("virtualizerconfig"); + } catch (SQLException e) { + LOGGER.error("Query failed in DbImage.getVirtualizerConfig()", e); + throw e; + } + } + + public static void setVirtualizerConfig(String imageVersionId, byte[] machineDescription) throws SQLException, + TNotFoundException { + if (imageVersionId == null || machineDescription == null || machineDescription.length == 0) + return; + try (MysqlConnection connection = Database.getConnection()) { + MysqlStatement stmt = connection.prepareStatement("UPDATE imageversion SET virtualizerconfig = :virtualizerconfig" + + " WHERE imageversionid = :imageversionid"); + stmt.setString("imageversionid", imageVersionId); + stmt.setBinary("virtualizerconfig", machineDescription); + stmt.executeUpdate(); + connection.commit(); + } catch (SQLException e) { + LOGGER.error("Query failed in DbImage.setVersionDetails()", e); + throw e; + } + } + public enum DeleteState { KEEP, SHOULD_DELETE, |