diff options
author | Simon Rettberg | 2015-07-03 16:43:38 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-07-03 16:43:38 +0200 |
commit | 90c159d622f234b99e47293f3ff2a35d64e6f8c9 (patch) | |
tree | e967412b1464e9e3cad381399d5dd1c596c0bf28 /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java | |
parent | [server] Refactored permission checking classes a bit (diff) | |
download | tutor-module-90c159d622f234b99e47293f3ff2a35d64e6f8c9.tar.gz tutor-module-90c159d622f234b99e47293f3ff2a35d64e6f8c9.tar.xz tutor-module-90c159d622f234b99e47293f3ff2a35d64e6f8c9.zip |
[server] Adapt to API changes, refine permission checking for image version deletion
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 | 33 |
1 files changed, 21 insertions, 12 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 4ca2aef6..fc78a5aa 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 @@ -25,16 +25,6 @@ public class DbImage { private static final Logger LOGGER = Logger.getLogger(DbImage.class); - public static ImageSummaryRead getImageSummary(UserInfo user, String imageBaseId) throws SQLException, - TNotFoundException { - try (MysqlConnection connection = Database.getConnection()) { - return getImageSummary(connection, user, imageBaseId); - } catch (SQLException e) { - LOGGER.error("Query failed in DbImage.getImageSummary()", e); - throw e; - } - } - /** * Get list of all images visible to the given user, optionally filtered by * the given list of tags. @@ -131,7 +121,26 @@ public class DbImage { return entry; } - private static ImageSummaryRead getImageSummary(MysqlConnection connection, UserInfo user, + /** + * Get summary about an image by its base id. + * + * @param user + * @param imageBaseId + * @return + * @throws SQLException + * @throws TNotFoundException + */ + public static ImageSummaryRead getImageSummary(UserInfo user, String imageBaseId) throws SQLException, + TNotFoundException { + try (MysqlConnection connection = Database.getConnection()) { + return getImageSummary(connection, user, imageBaseId); + } catch (SQLException e) { + LOGGER.error("Query failed in DbImage.getImageSummary()", e); + throw e; + } + } + + protected static ImageSummaryRead getImageSummary(MysqlConnection connection, UserInfo user, String imageBaseId) throws SQLException, TNotFoundException { MysqlStatement stmt = connection.prepareStatement("SELECT" + " i.imagebaseid, i.currentversionid, i.latestversionid, i.displayname," @@ -280,7 +289,7 @@ public class DbImage { * @return * @throws SQLException */ - private static String getBaseIdForVersionId(MysqlConnection connection, String imageVersionId) + protected static String getBaseIdForVersionId(MysqlConnection connection, String imageVersionId) throws SQLException { MysqlStatement stmt = connection.prepareStatement("SELECT imagebaseid FROM imageversion" + " WHERE imageversionid = :imageversionid LIMIT 1"); |