summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java
diff options
context:
space:
mode:
authorSimon Rettberg2015-08-20 12:47:25 +0200
committerSimon Rettberg2015-08-20 12:47:25 +0200
commit82712b2a52cd45ddba8bae02d4b783e38471b51f (patch)
tree3e579be2db024c80d6eb5746ad3c9ce40eb56c91 /dozentenmodul/src/main/java
parent[client] Cancel hash generator if upload fails (diff)
downloadtutor-module-82712b2a52cd45ddba8bae02d4b783e38471b51f.tar.gz
tutor-module-82712b2a52cd45ddba8bae02d4b783e38471b51f.tar.xz
tutor-module-82712b2a52cd45ddba8bae02d4b783e38471b51f.zip
[client] One error callback for master and sat connection
Diffstat (limited to 'dozentenmodul/src/main/java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/App.java7
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java44
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java46
3 files changed, 54 insertions, 43 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
index 4be5a34d..29721387 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
@@ -150,15 +150,18 @@ public class App {
// setup global thrift connection error handler before anything else
// Set master server to use (TODO: make configurable via command line)
try {
- ThriftManager.setMasterServerAddress(SSLContext.getDefault(), "bwlp-masterserver.ruf.uni-freiburg.de", THRIFT_SSL_PORT,
- THRIFT_TIMEOUT_MS);
+ ThriftManager.setMasterServerAddress(SSLContext.getDefault(),
+ "bwlp-masterserver.ruf.uni-freiburg.de", THRIFT_SSL_PORT, THRIFT_TIMEOUT_MS);
} catch (final NoSuchAlgorithmException e1) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Gui.showMessageBox(null, "SSL nicht verfügbar", MessageType.ERROR, LOGGER, e1);
+ // TODO: Ask if user wants to establish plain connection, quit otherwise
+ System.exit(1);
}
});
+ return;
}
SwingUtilities.invokeLater(new Runnable() {
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java
index f8c179b0..bb62da38 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java
@@ -44,9 +44,9 @@ import org.openslx.dozmod.gui.window.LoginWindow;
import org.openslx.dozmod.gui.window.MainMenuWindow;
import org.openslx.dozmod.gui.window.VirtualizerNoticeWindow;
import org.openslx.dozmod.state.UploadWizardState;
+import org.openslx.dozmod.thrift.GuiErrorCallback;
import org.openslx.dozmod.thrift.Session;
import org.openslx.thrifthelper.ThriftManager;
-import org.openslx.thrifthelper.ThriftManager.ErrorCallback;
public abstract class MainWindow {
@@ -136,45 +136,8 @@ public abstract class MainWindow {
});
// Set up thrift error message displaying
- // TODO: Make this ECB a class with a parameter for the name to display, as this is the only thing that differs here
- ThriftManager.setMasterErrorCallback(new ErrorCallback() {
- @Override
- public boolean thriftError(int failCount, final String method, final Throwable t) {
- // if it's the first fail, retry immediately
- if (failCount == 1)
- return true;
- // Otherwise, ask user if we should retry
- return Gui.syncExec(new GuiCallable<Boolean>() {
- @Override
- public Boolean run() {
- return Gui.showMessageBox(mainWindow,
- "Die Kommunikation mit dem bwLehrpool-Zentralserver ist"
- + " gestört. Der Aufruf der Funktion " + method
- + " ist fehlgeschlagen.\n\n" + "Möchten Sie den Aufruf wiederholen?",
- MessageType.ERROR_RETRY, LOGGER, t);
- }
- });
- }
- });
- ThriftManager.setSatelliteErrorCallback(new ErrorCallback() {
- @Override
- public boolean thriftError(int failCount, final String method, final Throwable t) {
- // if it's the first fail, retry immediately
- if (failCount == 1)
- return true;
- // Otherwise, ask user if we should retry
- return Gui.syncExec(new GuiCallable<Boolean>() {
- @Override
- public Boolean run() {
- return Gui.showMessageBox(mainWindow,
- "Die Kommunikation mit dem Satellitenserver ist"
- + " gestört. Der Aufruf der Funktion " + method
- + " ist fehlgeschlagen.\n\n" + "Möchten Sie den Aufruf wiederholen?",
- MessageType.ERROR_RETRY, LOGGER, t);
- }
- });
- }
- });
+ ThriftManager.setMasterErrorCallback(new GuiErrorCallback(mainWindow, "dem bwLehrpool-Zentralserver"));
+ ThriftManager.setSatelliteErrorCallback(new GuiErrorCallback(mainWindow, "dem Satellitenserver"));
// Same for config errors
Config.setErrorCallback(new Config.ErrorCallback() {
@@ -253,7 +216,6 @@ public abstract class MainWindow {
WhoamiInfo whoami = ThriftManager.getNewSatelliteClient(
GraphicalCertHandler.getSslContext(session.address), session.address,
App.THRIFT_SSL_PORT, App.THRIFT_TIMEOUT_MS).whoami(session.token);
- // TODO: Satellite whoami call
Session.initialize(whoami, session.address, session.token, session.masterToken);
ThriftManager.setSatelliteAddress(
GraphicalCertHandler.getSslContext(Session.getSatelliteAddress()),
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java
new file mode 100644
index 00000000..df0b160e
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java
@@ -0,0 +1,46 @@
+package org.openslx.dozmod.thrift;
+
+import java.awt.Frame;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.transport.TTransportException;
+import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.Gui.GuiCallable;
+import org.openslx.dozmod.gui.helper.MessageType;
+import org.openslx.thrifthelper.ThriftManager.ErrorCallback;
+
+public class GuiErrorCallback implements ErrorCallback {
+
+ private static final Logger LOGGER = Logger.getLogger(GuiErrorCallback.class);
+
+ private final Frame parent;
+
+ private final String serverString;
+
+ public GuiErrorCallback(Frame parent, String serverString) {
+ this.parent = parent;
+ this.serverString = serverString;
+ }
+
+ @Override
+ public boolean thriftError(int failCount, final String method, final Throwable t) {
+ // if it's not a transport exception, do not retry
+ if (!(t instanceof TTransportException))
+ return false;
+ final TTransportException tex = (TTransportException) t;
+ // if it's the first fail, retry immediately
+ if (failCount == 1)
+ return true;
+ // Otherwise, ask user if we should retry
+ return Gui.syncExec(new GuiCallable<Boolean>() {
+ @Override
+ public Boolean run() {
+ return Gui.showMessageBox(parent, "Die Kommunikation mit " + serverString + " ist"
+ + " gestört. Der Aufruf der Funktion " + method + " ist fehlgeschlagen (Fehler "
+ + tex.getType() + ").\n\n" + "Möchten Sie den Aufruf wiederholen?",
+ MessageType.ERROR_RETRY, LOGGER, t);
+ }
+ });
+ }
+
+}