summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/thrift/ThriftConnection.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-02-19 17:52:27 +0100
committerSimon Rettberg2015-02-19 17:52:27 +0100
commit265946d452f1374d2a43c71f1403a4da7712194c (patch)
treeaeb90854ef722b6da780fdb5134bc2d140b1ee81 /dozentenmodul/src/main/java/thrift/ThriftConnection.java
parent• changed contact information from michael.wilson to bwlehrpool (diff)
downloadtutor-module-265946d452f1374d2a43c71f1403a4da7712194c.tar.gz
tutor-module-265946d452f1374d2a43c71f1403a4da7712194c.tar.xz
tutor-module-265946d452f1374d2a43c71f1403a4da7712194c.zip
Remove client -> server dependency, move thrift classes to master-sync-shared
Diffstat (limited to 'dozentenmodul/src/main/java/thrift/ThriftConnection.java')
-rw-r--r--dozentenmodul/src/main/java/thrift/ThriftConnection.java79
1 files changed, 50 insertions, 29 deletions
diff --git a/dozentenmodul/src/main/java/thrift/ThriftConnection.java b/dozentenmodul/src/main/java/thrift/ThriftConnection.java
index 8b0221e8..a026ef03 100644
--- a/dozentenmodul/src/main/java/thrift/ThriftConnection.java
+++ b/dozentenmodul/src/main/java/thrift/ThriftConnection.java
@@ -9,47 +9,68 @@ import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
-import org.apache.thrift.transport.TTransportException;
-
-import server.generated.Server;
-import server.generated.Server.Client;
+import org.openslx.sat.thrift.iface.Server;
+import org.openslx.sat.thrift.iface.Server.Client;
+import org.openslx.sat.thrift.version.Version;
public class ThriftConnection {
-
- private final static Logger LOGGER = Logger.getLogger(ThriftConnection.class);
-
- private String satAddress = ""+SessionData.session.getServerAdress();
- final TTransport transport = new TSocket(satAddress, 9090);
-
- public ThriftConnection() {
- // TODO Auto-generated constructor stub
- }
-
- public Client getThriftConnection()
- {
-
+
+ private final static Logger LOGGER = Logger
+ .getLogger(ThriftConnection.class);
+
+ private String satAddress = SessionData.session.getServerAdress();
+ final TTransport transport = new TSocket(satAddress, 9090, 10000);
+
+ public Client getThriftConnection() {
+
try {
transport.open();
- } catch (TTransportException e) {
- LOGGER.error("Keine Verbindung möglich! Satellit: " + satAddress);
- e.printStackTrace();
+ } catch (Exception e) {
+ LOGGER.error("Keine Verbindung möglich! Satellit: " + satAddress, e);
JOptionPane.showMessageDialog(null,
- "Konnte keine Verbindung zum Satellit '" + satAddress + "' aufbauen!",
- "Debug-Message", JOptionPane.ERROR_MESSAGE);
+ "Konnte keine Verbindung zum Satellit '" + satAddress
+ + "' aufbauen!", "Debug-Message",
+ JOptionPane.ERROR_MESSAGE);
return null;
}
final TProtocol protocol = new TBinaryProtocol(transport);
-
final Server.Client client = new Server.Client(protocol);
- LOGGER.info("Verbindung zu "+satAddress+" wurde aufgebaut.");
-
+ LOGGER.info("Verbindung zu " + satAddress + " wurde aufgebaut.");
+
+ long remoteVersion;
+ try {
+ remoteVersion = client.getVersion();
+ } catch (Exception e) {
+ LOGGER.error(
+ "Could not query sat server version after successful connect! Assuming untagged version 1",
+ e);
+ remoteVersion = 1;
+ }
+ String text = null;
+ if (remoteVersion > Version.VERSION) {
+ text = "Das von Ihnen verwendete Dozentenmodul ist zu alt, um mit dem Satelliten-Server zu verbinden.\n"
+ + "Sie verwenden Version "
+ + Version.VERSION
+ + ", der Satellit "
+ + remoteVersion
+ + "\n"
+ + "Aktuelle Version unter http://bwlehrpool.hs-offenburg.de/";
+ } else if (remoteVersion < Version.VERSION) {
+ text = "Das von Ihnen verwendete Dozentenmodul ist zu neu, um mit dem Satelliten-Server zu verbinden.\n"
+ + "Sie verwenden Version "
+ + Version.VERSION
+ + ", der Satellit " + remoteVersion;
+ }
+ if (text != null) {
+ JOptionPane.showMessageDialog(null, text, "Fehler",
+ JOptionPane.ERROR_MESSAGE);
+ }
+
return client;
- }
+ }
- public void closeThriftConnection()
- {
- //System.out.println("Ich funktioniere auch, wenn ich nicht geschlossen, sondern im TaskManager gekillt werde"); //works
+ public void closeThriftConnection() {
LOGGER.info("Verbindung wird geplant getrennt.");
transport.close();
}