summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java
diff options
context:
space:
mode:
authorJonathan Bauer2016-05-04 18:21:47 +0200
committerJonathan Bauer2016-05-04 18:21:47 +0200
commit2420003d435ba1800c6ec0874c08bef1c1cd9a7a (patch)
tree288c9058f308d16fd719ac3bd223b1f7244d6419 /dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java
parent[client] only switch to 'Advanced' tab if its input fields contain errors (diff)
downloadtutor-module-2420003d435ba1800c6ec0874c08bef1c1cd9a7a.tar.gz
tutor-module-2420003d435ba1800c6ec0874c08bef1c1cd9a7a.tar.xz
tutor-module-2420003d435ba1800c6ec0874c08bef1c1cd9a7a.zip
[client] publish image stuff 2.0
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java53
1 files changed, 38 insertions, 15 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java
index 26e11504..b8ceb6b5 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java
@@ -3,7 +3,10 @@ package org.openslx.dozmod.thrift;
import java.awt.Frame;
import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
import org.apache.thrift.transport.TTransportException;
+import org.openslx.bwlp.thrift.iface.AuthorizationError;
+import org.openslx.bwlp.thrift.iface.TAuthorizationException;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.Gui.GuiCallable;
import org.openslx.dozmod.gui.helper.MessageType;
@@ -25,7 +28,7 @@ public class GuiErrorCallback implements ErrorCallback {
@Override
public boolean thriftError(int failCount, final String method, final Throwable t) {
// if it's not a transport exception, do not retry
- if (t != null && !(t instanceof TTransportException))
+ if (t != null && !(t instanceof TException))
return false;
// if it's the first fail, retry immediately
if (failCount == 1)
@@ -33,20 +36,40 @@ public class GuiErrorCallback implements ErrorCallback {
// Some methods are non-critical, so don't show a pop-up
if (ThriftError.failSilently(method))
return failCount == 2; // As it's silent, give it a second try...
- // Otherwise, ask user if we should retry
- final TTransportException tex = (TTransportException) t;
- return Gui.syncExec(new GuiCallable<Boolean>() {
- @Override
- public Boolean run() {
- String errMsg = null;
- if (tex != null) {
- errMsg = " (Fehler " + tex.getType() + ")";
- }
- return Gui.showMessageBox(parent, "Die Kommunikation mit " + serverString + " ist"
- + " gestört. Der Aufruf der Funktion " + method + " ist fehlgeschlagen" + errMsg
- + ".\n\n" + "Möchten Sie den Aufruf wiederholen?", MessageType.ERROR_RETRY, LOGGER, t);
+ if (t instanceof TAuthorizationException) {
+ final TAuthorizationException taex = (TAuthorizationException) t;
+ if (taex.getNumber() == AuthorizationError.NOT_AUTHENTICATED || taex.getNumber() == AuthorizationError.INVALID_TOKEN) {
+ // TODO somehow reauth the user :)
+ return Gui.syncExec(new GuiCallable<Boolean>() {
+ @Override
+ public Boolean run() {
+ if (Gui.showMessageBox(parent, "Ungültiges Sitzungstoken oder fehlerhafte Authentifizierung am " + serverString + "!" +
+ //"\n" + errMsg + "\n" +
+ "\nBitte starten Sie das Programm neu. Jetzt beenden?", MessageType.ERROR_RETRY, LOGGER, t)) {
+ // user confirmed exit
+ Gui.exit(0);
+ }
+ return false;
+ }
+ });
}
- });
+ }
+ if (t instanceof TTransportException) {
+ // Otherwise, ask user if we should retry
+ final TTransportException tex = (TTransportException) t;
+ return Gui.syncExec(new GuiCallable<Boolean>() {
+ @Override
+ public Boolean run() {
+ String errMsg = null;
+ if (tex != null) {
+ errMsg = " (Fehler " + tex.getType() + ")";
+ }
+ return Gui.showMessageBox(parent, "Die Kommunikation mit " + serverString + " ist"
+ + " gestört. Der Aufruf der Funktion " + method + " ist fehlgeschlagen" + errMsg
+ + ".\n\n" + "Möchten Sie den Aufruf wiederholen?", MessageType.ERROR_RETRY, LOGGER, t);
+ }
+ });
+ }
+ return false;
}
-
}