From ca8502df5d32baf0a47fc2eddde3cca7b00a0617 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 21 Aug 2015 15:32:18 +0200 Subject: [client] ThriftActions & calls in LectureWizard --- .../openslx/dozmod/gui/wizard/LectureWizard.java | 21 ++++++++++----------- .../org/openslx/dozmod/thrift/ThriftActions.java | 7 +++++-- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'dozentenmodul/src/main/java/org/openslx') diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java index b29fe91f..f156ee48 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java @@ -2,6 +2,8 @@ package org.openslx.dozmod.gui.wizard; import java.awt.Window; +import javax.swing.JOptionPane; + import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.ImageSummaryRead; @@ -16,6 +18,7 @@ import org.openslx.dozmod.gui.wizard.page.LectureCustomPermissionPage; import org.openslx.dozmod.gui.wizard.page.LectureOptionsPage; import org.openslx.dozmod.state.LectureWizardState; import org.openslx.dozmod.thrift.Session; +import org.openslx.dozmod.thrift.ThriftActions; import org.openslx.dozmod.thrift.ThriftError; import org.openslx.dozmod.thrift.cache.LectureCache; import org.openslx.thrifthelper.ThriftManager; @@ -80,25 +83,21 @@ public class LectureWizard extends Wizard implements UiFeedback { if (state.uuid != null) { // already got a uuid, this is bad as we were about to do it! LOGGER.error("UUID for new lecture already present, something's bad..."); - return true; + return false; } // ok, lets create it - try { - // push to sat - state.uuid = ThriftManager.getSatClient().createLecture(Session.getSatelliteToken(), - lectureWriteFromState()); - if(state.permissionMap != null && !state.permissionMap.isEmpty()) - ThriftManager.getSatClient().writeLecturePermissions(Session.getSatelliteToken(), state.uuid, state.permissionMap); - } catch (TException e) { - ThriftError.showMessage(this, LOGGER, e, "Failed to create lecture"); + if (ThriftActions.createLecture(JOptionPane.getFrameForComponent(this), lectureWriteFromState()) == null) return false; - } + if(state.permissionMap != null && !state.permissionMap.isEmpty()) + if (!ThriftActions.writeLecturePermissions(JOptionPane.getFrameForComponent(this), state.uuid, state.permissionMap)) + return false; + + // all good, feedback if (Gui.showMessageBox(this, "Veranstaltung erstellt! Wollen Sie zur Übersicht wechseln?", MessageType.QUESTION_YESNO, null, null)) { LectureCache.get(true); MainWindow.showPage(LectureListWindow.class); } - // TODO run the actually request over external threaded class return true; } 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 5b2a931b..19ada0f2 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java @@ -518,18 +518,21 @@ public class ThriftActions { return uuid; } /** + * GUI-BLOCKING * Writes custom lecture permissions (permissions param) for the given lectureId. * * @param frame to show user feedback on * @param lectureId lecture's id to write custom permissions for * @param permissions actual permission map to push */ - public static void writeLecturePermissions(final Frame frame, final String lectureId, final Map permissions) { + public static boolean writeLecturePermissions(final Frame frame, final String lectureId, final Map permissions) { try { - ThriftManager.getSatClient().writeLecturePermissions(Session.getSatelliteToken(), lectureId, permissions); + ThriftManager.getSatClient().writeLecturePermissions(Session.getSatelliteToken(), lectureId, permissions); } catch (TException e) { ThriftError.showMessage(frame, LOGGER, e, "Failed to write lecture permissions"); + return false; } + return true; } /* ******************************************************************************* -- cgit v1.2.3-55-g7522