summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java
diff options
context:
space:
mode:
authorStephan Schwaer2015-10-27 17:45:37 +0100
committerStephan Schwaer2015-10-27 17:45:37 +0100
commitc1e86bdfb57a71fbe1a90100b03964bf05f0aea1 (patch)
treea799fcd7aa04920213de8000ebbbabb59e49f7c9 /dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java
parent[client] Add two floppy drives to vmx of downloaded VM (diff)
downloadtutor-module-c1e86bdfb57a71fbe1a90100b03964bf05f0aea1.tar.gz
tutor-module-c1e86bdfb57a71fbe1a90100b03964bf05f0aea1.tar.xz
tutor-module-c1e86bdfb57a71fbe1a90100b03964bf05f0aea1.zip
[client] Clean up deleteLectures and improve it's user feadback.
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.java54
1 files changed, 31 insertions, 23 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 6a7be596..b1c21cff 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java
@@ -6,6 +6,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -146,7 +147,7 @@ public class ThriftActions {
remoteVersion = 1; // Assume something old
}
}
-
+
if (client == null || remoteVersion == -1) {
if (interactive) {
Gui.asyncMessageBox(
@@ -157,19 +158,18 @@ public class ThriftActions {
}
return false;
}
-
+
if (remoteVersion != Version.VERSION) {
if (interactive) {
Gui.asyncMessageBox("Das von Ihnen verwendete Dozentenmodul ist nicht mit dem"
- + " gewählten Satelliten-Server kompatibel.\n"
- + "Ihre Version: "+ Version.VERSION + "\n"
- + "Satelliten-Version: " + remoteVersion,
+ + " gewählten Satelliten-Server kompatibel.\n" + "Ihre Version: "
+ + Version.VERSION + "\n" + "Satelliten-Version: " + remoteVersion,
MessageType.ERROR, LOGGER, null);
continue;
}
return false;
}
-
+
// all good, try to get the whoami info
try {
whoami = client.whoami(satToken);
@@ -177,7 +177,7 @@ public class ThriftActions {
if (interactive) {
ThriftError.showMessage(window, LOGGER, e,
"Authentifizierung erfolgreich, der Satelliten-Server verweigert jedoch die Verbindung.\n"
- + "Versuchen Sie, sich erneut anzumelden.\n");
+ + "Versuchen Sie, sich erneut anzumelden.\n");
}
return false;
} catch (TException e) {
@@ -197,7 +197,7 @@ public class ThriftActions {
return false;
}
} while (interactive && whoami == null);
-
+
if (whoami != null) {
Session.initialize(whoami, address, satToken, masterToken);
ThriftManager.setSatelliteAddress(
@@ -783,7 +783,8 @@ public class ThriftActions {
questionText += "\nWollen Sie diese Version samt Veranstaltungen löschen?\n";
}
if (!matches)
- questionText = "Wollen Sie die Image-Version vom " + FormatHelper.shortDate(version.createTime) + " Uhr wirklich löschen?";
+ questionText = "Wollen Sie die Image-Version vom " + FormatHelper.shortDate(version.createTime)
+ + " Uhr wirklich löschen?";
if (!userConfirmed(frame, questionText))
return;
@@ -987,38 +988,45 @@ public class ThriftActions {
* Callback interface reporting the status of the deletion back to the gui
*/
public interface DeleteLectureCallback {
- void deleted(boolean success);
+ void deleted(Map<LectureSummary, TException> failedLectures);
}
/**
- * NON-BLOCKING Deletes the lecture with the given lectureId
+ * NON-BLOCKING Deletes the lectures of the given list
*
* @param frame to display user feedback on
- * @param lectureId id of the lecture to delete
- * @param callback interface to report the status back to the gui
+ * @param list of lectures to be deleted
+ * @param callback interface to report the lectures, which haven't been
+ * deleted.
*/
- public static void deleteLecture(final Frame frame, final String lectureId,
+ public static void deleteLecture(final Frame frame, final List<LectureSummary> lectures,
final DeleteLectureCallback callback) {
- if (lectureId == null)
+ if (lectures == null)
return;
- if (!userConfirmed(frame, "Wollen Sie diese Veranstaltung wirklick löschen?"))
+ String messageText = lectures.size() == 1 ? "Wollen Sie diese Veranstaltung wirklich löschen?"
+ : "Wollen Sie die " + lectures.size() + " Veranstaltungen wirklich löschen?";
+ if (!userConfirmed(frame, messageText))
return;
+
QuickTimer.scheduleOnce(new Task() {
- boolean success = false;
+ Map<LectureSummary, TException> failedLectures = new HashMap<LectureSummary, TException>();
@Override
public void fire() {
- try {
- ThriftManager.getSatClient().deleteLecture(Session.getSatelliteToken(), lectureId);
- success = true;
- } catch (TException e) {
- ThriftError.showMessage(frame, LOGGER, e, "Konnte Veranstaltungdaten nicht abrufen");
+ for (final LectureSummary l : lectures) {
+ if (l == null)
+ continue;
+ try {
+ ThriftManager.getSatClient().deleteLecture(Session.getSatelliteToken(), l.lectureId);
+ } catch (TException e) {
+ failedLectures.put(l, e);
+ }
}
Gui.asyncExec(new Runnable() {
@Override
public void run() {
if (callback != null) {
- callback.deleted(success);
+ callback.deleted(failedLectures);
}
}
});