summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftError.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-08-13 15:45:10 +0200
committerSimon Rettberg2015-08-13 15:45:10 +0200
commit9693e1a8484cc7ab05e6d62bad7bfa561d4aa3d7 (patch)
treefc32e08b30d5643cf1bbd1753ec6f1cc076a8217 /dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftError.java
parent[client] Fix positioning of Wizard (diff)
downloadtutor-module-9693e1a8484cc7ab05e6d62bad7bfa561d4aa3d7.tar.gz
tutor-module-9693e1a8484cc7ab05e6d62bad7bfa561d4aa3d7.tar.xz
tutor-module-9693e1a8484cc7ab05e6d62bad7bfa561d4aa3d7.zip
[client] Layout tweaks, Change owner feature
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftError.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftError.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftError.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftError.java
new file mode 100644
index 00000000..fcee1448
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftError.java
@@ -0,0 +1,62 @@
+package org.openslx.dozmod.thrift;
+
+import java.awt.Component;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+import org.openslx.bwlp.thrift.iface.AuthorizationError;
+import org.openslx.bwlp.thrift.iface.TAuthorizationException;
+import org.openslx.bwlp.thrift.iface.TInternalServerError;
+import org.openslx.bwlp.thrift.iface.TNotFoundException;
+import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.helper.MessageType;
+
+public class ThriftError {
+
+ public static void showMessage(Component parent, Logger logger, TException ex, String messageText) {
+ if (ex instanceof TNotFoundException) {
+ messageText += "\n\nNicht gefunden";
+ } else if (ex instanceof TAuthorizationException) {
+ String reason = getString(((TAuthorizationException) ex).getNumber());
+ messageText += "\n\nZugriff verweigert: " + reason + "\n" + ex.getMessage();
+ } else if (ex instanceof TInternalServerError) {
+ messageText += "\n\nEin serverseitiger Fehler ist aufgetreten. Bitte kontaktieren Sie den lokalen Support.";
+ } else {
+ messageText += "\n\nUnerwartete Ausnahme " + ex.getClass().getSimpleName() + " ist aufgetreten.";
+ }
+ logger.warn("A thrift call raised an exception", ex);
+ Gui.showMessageBox(parent, messageText, MessageType.ERROR, null, null);
+ }
+
+ public static String getString(AuthorizationError error) {
+ if (error == null)
+ return "(AuthorizationError=null)";
+ switch (error) {
+ case ACCOUNT_SUSPENDED:
+ return "Das Benutzerkonto ist gesperrt";
+ case BANNED_NETWORK:
+ return "Das Netzwerk, aus dem Sie operieren, ist gesperrt";
+ case CHALLENGE_FAILED:
+ return "Challenge fehlgeschlagen";
+ case GENERIC_ERROR:
+ return "Generischer Fehler";
+ case INVALID_CREDENTIALS:
+ return "Ungültige Zugangsdaten";
+ case INVALID_KEY:
+ return "Ungültiger Schlüssel";
+ case INVALID_ORGANIZATION:
+ return "Ungültige oder unbekannte Organisation";
+ case INVALID_TOKEN:
+ return "Ungültiges Sitzungstoken";
+ case NOT_AUTHENTICATED:
+ return "Nicht authentifiziert";
+ case NO_PERMISSION:
+ return "Keine ausreichenden Berechtigungen";
+ case ORGANIZATION_SUSPENDED:
+ return "Ihre zugehörige Organisation ist gesperrt";
+ default:
+ return "Unbekannter Fehlercode: " + error.toString();
+ }
+ }
+
+}