diff options
author | Jonathan Bauer | 2015-08-21 12:39:39 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-08-21 12:39:39 +0200 |
commit | 5ce7b1169157edb9cded0b44ae7118a45af9d123 (patch) | |
tree | 35061d3909d840ec8fafd4eb382bec90a0e5bb4a /dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java | |
parent | [client] added LectureCustomPermissionManager and merged ImagePermissionManag... (diff) | |
download | tutor-module-5ce7b1169157edb9cded0b44ae7118a45af9d123.tar.gz tutor-module-5ce7b1169157edb9cded0b44ae7118a45af9d123.tar.xz tutor-module-5ce7b1169157edb9cded0b44ae7118a45af9d123.zip |
[client] support deletion of image base in ThriftActions
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java index f45c05c7..8b8ceb90 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java @@ -49,6 +49,7 @@ public class ThriftActions { void downloadInitialized(boolean success); } /** + * NON-BLOCKING * Initializes the download of the given imageVersionId saving it to the given * imageName * @@ -307,7 +308,7 @@ public class ThriftActions { /* ******************************************************************************* * - * IMAGE VERSION DELETION + * IMAGE / VERSION DELETION * * Deletes a specific image version * @@ -326,33 +327,46 @@ public class ThriftActions { } /** * NON-BLOCKING - * Deletes the given imageVersionId of the image imageBaseId and calls the given - * callback method to inform about the outcome of the operation. + * Deletes either an image base or an image version depending on the parameters. + * To delete an image base, give the imageBaseId and let imageVersionId be null. + * To delete an image version, set both imageBaseId and imageVersionId. + * The success of the operation will be forwarded to the GUI through the DeleteCallback. * * @param frame next parent frame of the caller of this method * @param imageBaseId uuid of the image that belongs to the version * @param imageVersionId id of the image version to be deleted * @param callback called to inform the GUI about the deletion status (see DeleteCallback interface) */ - public static void deleteImageVersion(final Frame frame, final String imageBaseId, + public static void deleteImageBaseOrVersion(final Frame frame, final String imageBaseId, final String imageVersionId, final DeleteCallback callback) { - // requires confirmation of the user - if (!Gui.showMessageBox(frame, "Wollen Sie diese Image-Version wirklich löschen?", - MessageType.QUESTION_YESNO, LOGGER, null)) + String questionText; + if (imageBaseId == null) { + return; + } else { + questionText = imageVersionId == null ? + "Wollen Sie dieses Image wirklich löschen?" : "Wollen Sie diese Image-Version wirklich löschen?"; + } + if (!userConfirmed(frame, questionText)) return; - // try to actually delete this version of the image + + // perform the deletion QuickTimer.scheduleOnce(new Task() { boolean success = false; - @Override public void fire() { try { - ThriftManager.getSatClient().deleteImageVersion(Session.getSatelliteToken(), - imageVersionId); - LOGGER.info("Deleted version '" + imageVersionId + "' of image '" + imageBaseId + "'."); + if (imageVersionId == null) { + // deleting an image base + ThriftManager.getSatClient().deleteImageBase(Session.getSatelliteToken(), imageBaseId); + LOGGER.info("Deleted image with id '" + imageBaseId + "'"); + } else { + // deleting an image version + ThriftManager.getSatClient().deleteImageVersion(Session.getSatelliteToken(), imageVersionId); + LOGGER.info("Deleted version '" + imageVersionId + "' of image '" + imageBaseId + "'."); + } success = true; } catch (TException e) { - ThriftError.showMessage(frame, LOGGER, e, "Das Löschen der Version ist gescheitert"); + ThriftError.showMessage(frame, LOGGER, e, "Löschen fehlgeschlagen"); if (callback != null) callback.isDeleted(success); return; @@ -367,4 +381,15 @@ public class ThriftActions { } }); } + + /** + * Helper to ask the user for confirmation. Returns his choice. + * + * @param frame frame to show this message box on + * @param message question message to display to the user + * @return true if the user confirmed (clicked yes), false otherwise + */ + private static boolean userConfirmed(final Frame frame, final String message) { + return Gui.showMessageBox(frame, message, MessageType.QUESTION_YESNO, LOGGER, null); + } } |