summaryrefslogtreecommitdiffstats
path: root/dozentenmodul
diff options
context:
space:
mode:
authorJonathan Bauer2015-03-02 13:22:44 +0100
committerJonathan Bauer2015-03-02 13:22:44 +0100
commitea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a (patch)
tree1e252164aa23b6b74d30c6185fda06ceddcd6041 /dozentenmodul
parentpom.xml (diff)
downloadtutor-module-ea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a.tar.gz
tutor-module-ea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a.tar.xz
tutor-module-ea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a.zip
ThriftManager class: use getSatClient() and getMasterClient() to get the singleton instances of the thrift clients to satellite and master servers
DO NOT CREATE NEW THRIFT OBJECTS!!!
Diffstat (limited to 'dozentenmodul')
-rw-r--r--dozentenmodul/src/main/java/auth/Authentification.java1
-rw-r--r--dozentenmodul/src/main/java/ftp/DownloadTask.java2
-rw-r--r--dozentenmodul/src/main/java/gui/image/CreateImageTechnisch_GUI.java9
-rw-r--r--dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java35
-rw-r--r--dozentenmodul/src/main/java/gui/image/EditImageAllgemein_GUI.java11
-rw-r--r--dozentenmodul/src/main/java/gui/image/EditImageTechnisch_GUI.java13
-rw-r--r--dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java30
-rw-r--r--dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java20
-rw-r--r--dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java38
-rw-r--r--dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java22
-rw-r--r--dozentenmodul/src/main/java/gui/image/SearchEditImage_GUI.java23
-rw-r--r--dozentenmodul/src/main/java/gui/image/SearchImage_GUI.java23
-rw-r--r--dozentenmodul/src/main/java/gui/intro/Login_GUI.java64
-rw-r--r--dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java6
-rw-r--r--dozentenmodul/src/main/java/gui/lecture/CreateLectureAllgemein_GUI.java13
-rw-r--r--dozentenmodul/src/main/java/gui/lecture/CreateLectureLink_GUI.java40
-rw-r--r--dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java32
-rw-r--r--dozentenmodul/src/main/java/gui/lecture/EditLectureAllgemein_GUI.java6
-rw-r--r--dozentenmodul/src/main/java/gui/lecture/EditLectureLink_GUI.java71
-rw-r--r--dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java30
-rw-r--r--dozentenmodul/src/main/java/gui/lecture/PermissionEditLecture_GUI.java79
-rw-r--r--dozentenmodul/src/main/java/gui/lecture/SearchLecture_GUI.java18
-rw-r--r--dozentenmodul/src/main/java/thrift/MasterThriftConnection.java42
-rw-r--r--dozentenmodul/src/main/java/thrift/ThriftConnection.java77
-rw-r--r--dozentenmodul/src/main/java/thrift/ThriftManager.java155
-rw-r--r--dozentenmodul/src/main/java/util/ListAllOtherUsers_GUI.java19
-rw-r--r--dozentenmodul/src/main/java/util/ServiceProviderResponse.java13
-rw-r--r--dozentenmodul/src/main/java/util/ShibbolethECP.java32
28 files changed, 371 insertions, 553 deletions
diff --git a/dozentenmodul/src/main/java/auth/Authentification.java b/dozentenmodul/src/main/java/auth/Authentification.java
index d242c01e..d7a195f7 100644
--- a/dozentenmodul/src/main/java/auth/Authentification.java
+++ b/dozentenmodul/src/main/java/auth/Authentification.java
@@ -1,6 +1,5 @@
package auth;
-import org.openslx.imagemaster.thrift.iface.UserInfo;
public class Authentification {
diff --git a/dozentenmodul/src/main/java/ftp/DownloadTask.java b/dozentenmodul/src/main/java/ftp/DownloadTask.java
index bb81ab51..63335f46 100644
--- a/dozentenmodul/src/main/java/ftp/DownloadTask.java
+++ b/dozentenmodul/src/main/java/ftp/DownloadTask.java
@@ -5,7 +5,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
-import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -22,7 +21,6 @@ import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
-import config.Config;
import util.ResourceLoader;
/**
diff --git a/dozentenmodul/src/main/java/gui/image/CreateImageTechnisch_GUI.java b/dozentenmodul/src/main/java/gui/image/CreateImageTechnisch_GUI.java
index 42e98c4f..ac90c518 100644
--- a/dozentenmodul/src/main/java/gui/image/CreateImageTechnisch_GUI.java
+++ b/dozentenmodul/src/main/java/gui/image/CreateImageTechnisch_GUI.java
@@ -46,9 +46,8 @@ import models.person;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
-import org.openslx.sat.thrift.iface.Server.Client;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
@SuppressWarnings("serial")
@@ -66,8 +65,6 @@ public class CreateImageTechnisch_GUI extends JFrame {
private JCheckBox chckbxIsLicensed;
private JCheckBox chckbxIsInternetBlocked;
JComboBox<String> comboBox;
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
Component c = null;
private static final String HELP_MESSAGE = "<html><div align = \"center\">" +
"Geben Sie hier bitte einige technische Daten an, die dann mit dem Image angezeigt werden.<br />" +
@@ -85,7 +82,7 @@ public class CreateImageTechnisch_GUI extends JFrame {
@Override
public void windowClosing(WindowEvent arg0) {
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
@@ -202,7 +199,7 @@ public class CreateImageTechnisch_GUI extends JFrame {
});
List<String> os = null;
try {
- os = client.getAllOS(SessionData.session.getAuthToken());
+ os = ThriftManager.getSatClient().getAllOS(SessionData.session.getAuthToken());
for(int i=0; i<os.size();i++){
comboBox.addItem(os.get(i).toString());
}
diff --git a/dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java b/dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java
index 44e86aae..c6dc58c9 100644
--- a/dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java
+++ b/dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java
@@ -61,9 +61,8 @@ import models.person;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import org.openslx.sat.thrift.iface.Image;
-import org.openslx.sat.thrift.iface.Server.Client;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
@SuppressWarnings("serial")
@@ -116,9 +115,6 @@ public class DeleteImage_GUI extends JFrame {
+ "Wird das Image nach dem Löschen nochmal benötigt, muss es erneut hochgeladen werden."
+ "</div></html>";
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
-
final DefaultTableModel modelMyImages = new DefaultTableModel(titles, 0) {
public boolean isCellEditable(int rowIndex, int mColIndex) {
return false;
@@ -145,9 +141,8 @@ public class DeleteImage_GUI extends JFrame {
@Override
public void windowClosing(WindowEvent arg0) {
// Beendet die Anwendung nach klick auf X
- con.closeThriftConnection();
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -298,7 +293,7 @@ public class DeleteImage_GUI extends JFrame {
try {
// Holt sich eine Liste aller verfügbaren Betriebssysteme vom
// Server
- List<String> list = client.getAllOS(SessionData.session
+ List<String> list = ThriftManager.getSatClient().getAllOS(SessionData.session
.getAuthToken());
// Leeres Item hinzufuegen
comboBox.addItem("");
@@ -352,12 +347,6 @@ public class DeleteImage_GUI extends JFrame {
lblHauptmen.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
-
- // oeffnet das Hauuetmenue
- con.closeThriftConnection();
-
- // oeffnet das Hauuetmenue
-
DeleteImage_GUI.this.setVisible(false);
MainMenue_GUI main = new MainMenue_GUI(c);
main.setVisible(true);
@@ -418,17 +407,17 @@ public class DeleteImage_GUI extends JFrame {
// Unbdingt abfragen!
try {
- if (!client.connectedToLecture(imageid,
+ if (!ThriftManager.getSatClient().connectedToLecture(imageid,
imageversion,
SessionData.session.getAuthToken())) {
try {
// try to delete file from file system
- if (client.deleteImageServer(imageid,
+ if (ThriftManager.getSatClient().deleteImageServer(imageid,
imageversion,
SessionData.session.getAuthToken()) == true) {
// successful, now delete file from DB
- if (client.deleteImageData(imageid,
+ if (ThriftManager.getSatClient().deleteImageData(imageid,
imageversion,
SessionData.session
.getAuthToken())) {
@@ -566,12 +555,6 @@ public class DeleteImage_GUI extends JFrame {
JButton okButton = new JButton("Zurück");
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
-
- // oeffnet das Hauptmenü
- con.closeThriftConnection();
-
- // oeffnet das Hauptmenue
-
MainMenue_GUI main = new MainMenue_GUI(c);
main.setVisible(true);
dispose();
@@ -791,11 +774,11 @@ public class DeleteImage_GUI extends JFrame {
// Hole eine Liste der Images
if (person.verantwortlicher.getRole() == "Admin") {
// get complete list
- images = client.getImageList(person.verantwortlicher
+ images = ThriftManager.getSatClient().getImageList(person.verantwortlicher
.getUserID(),SessionData.session.getAuthToken());
} else {
// get permitted list
- images = client.getImageListPermissionAdmin(
+ images = ThriftManager.getSatClient().getImageListPermissionAdmin(
person.verantwortlicher.getUserID(),
SessionData.session.getAuthToken());
}
@@ -867,7 +850,7 @@ public class DeleteImage_GUI extends JFrame {
try {
SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat out = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
- Map<String, String> res = client.getImageData(id, version,
+ Map<String, String> res = ThriftManager.getSatClient().getImageData(id, version,
SessionData.session.getAuthToken());
labelName.setText(res.get("name"));
labelOS.setText(res.get("os"));
diff --git a/dozentenmodul/src/main/java/gui/image/EditImageAllgemein_GUI.java b/dozentenmodul/src/main/java/gui/image/EditImageAllgemein_GUI.java
index 1dfd8191..57406817 100644
--- a/dozentenmodul/src/main/java/gui/image/EditImageAllgemein_GUI.java
+++ b/dozentenmodul/src/main/java/gui/image/EditImageAllgemein_GUI.java
@@ -43,9 +43,8 @@ import models.SessionData;
import models.person;
import org.apache.thrift.TException;
-import org.openslx.sat.thrift.iface.Server.Client;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
@SuppressWarnings("serial")
@@ -59,8 +58,6 @@ public class EditImageAllgemein_GUI extends JFrame {
private JTextField EMail;
private JTextField imagename;
private JTextArea textAreadesc;
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
private JPanel panel_2;
private JLabel lblNewLabel;
private JTextPane txtpnBitteWhlenSie;
@@ -86,9 +83,8 @@ public class EditImageAllgemein_GUI extends JFrame {
@Override
public void windowClosing(WindowEvent arg0) {
// Beendet die Anwendung bei einem Klick auf das X
- con.closeThriftConnection();
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -433,7 +429,8 @@ public class EditImageAllgemein_GUI extends JFrame {
public void initData() {
try {
- Map<String, String> map = client.getImageData(Image.image.getImageId(), Image.image.getVersion(),SessionData.session.getAuthToken());
+ Map<String, String> map = ThriftManager.getSatClient().getImageData(
+ Image.image.getImageId(), Image.image.getVersion(),SessionData.session.getAuthToken());
if (map.get("internet").equals("0")) {
Image.image.setInternet(false);
diff --git a/dozentenmodul/src/main/java/gui/image/EditImageTechnisch_GUI.java b/dozentenmodul/src/main/java/gui/image/EditImageTechnisch_GUI.java
index 6895f6c1..679b3c62 100644
--- a/dozentenmodul/src/main/java/gui/image/EditImageTechnisch_GUI.java
+++ b/dozentenmodul/src/main/java/gui/image/EditImageTechnisch_GUI.java
@@ -45,9 +45,8 @@ import models.person;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
-import org.openslx.sat.thrift.iface.Server.Client;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
@SuppressWarnings("serial")
@@ -65,8 +64,6 @@ public class EditImageTechnisch_GUI extends JFrame {
private JCheckBox chckbxIsLicensed;
private JCheckBox chckbxIsInternetBlocked;
JComboBox<String> comboBox;
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
Component c = null;
private static final String HELP_MESSAGE = "<html><div align = \"center\">" +
"Bearbeiten Sie hier die technischen Angaben zu Ihrem Image, die Sie beim Erzeugen des Images hinterlegt haben.<br />" +
@@ -83,7 +80,7 @@ public class EditImageTechnisch_GUI extends JFrame {
public void windowClosing(WindowEvent arg0) {
// Beendet die Anwendung bei Klick auf das X
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -200,7 +197,7 @@ public class EditImageTechnisch_GUI extends JFrame {
List<String> os = null;
try {
- os=client.getAllOS(SessionData.session.getAuthToken());
+ os=ThriftManager.getSatClient().getAllOS(SessionData.session.getAuthToken());
for(int i=0;i<os.size();i++) {
comboBox.addItem(os.get(i).toString());
}
@@ -218,7 +215,7 @@ public class EditImageTechnisch_GUI extends JFrame {
panel_1.add(comboBox);
try {
- comboBox.setSelectedItem(client.getOsNameForGuestOs(Image.image.getOS(),SessionData.session.getAuthToken()));
+ comboBox.setSelectedItem(ThriftManager.getSatClient().getOsNameForGuestOs(Image.image.getOS(),SessionData.session.getAuthToken()));
} catch (TException e1)
{
// TODO Auto-generated catch block
@@ -381,7 +378,7 @@ public class EditImageTechnisch_GUI extends JFrame {
try {
//check if user may change permissions and choose window
- if(client.userIsImageAdmin(Image.image.getImageId(),SessionData.session.getAuthToken(), person.verantwortlicher.getUserID()) == true || (person.verantwortlicher.getRole().equals("Admin"))) {
+ if(ThriftManager.getSatClient().userIsImageAdmin(Image.image.getImageId(),SessionData.session.getAuthToken(), person.verantwortlicher.getUserID()) == true || (person.verantwortlicher.getRole().equals("Admin"))) {
//user has permission, go to permission GUI
PermissionEditImage_GUI ea=new PermissionEditImage_GUI(c);
ea.setVisible(true);
diff --git a/dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java b/dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java
index a2247b97..d201d3b7 100644
--- a/dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java
+++ b/dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java
@@ -47,10 +47,9 @@ import models.person;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
-import org.openslx.sat.thrift.iface.Server.Client;
import org.openslx.sat.thrift.iface.User;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
import config.Config;
import ftp.UploadTask;
@@ -91,8 +90,6 @@ public class FTPCreateUploader_GUI extends JFrame implements
double speed;
long bytesread;
boolean taskrun = false;
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
JButton btnFinish = new JButton("Fertigstellen");
JButton btnUploadStarten = new JButton("Upload auf Server starten");
JButton btnZurck = new JButton("Zurück");
@@ -120,7 +117,7 @@ public class FTPCreateUploader_GUI extends JFrame implements
try {
- uuid = client.createRandomUUID(SessionData.session.getAuthToken());
+ uuid = ThriftManager.getSatClient().createRandomUUID(SessionData.session.getAuthToken());
} catch (TException e1) {
@@ -145,16 +142,15 @@ public class FTPCreateUploader_GUI extends JFrame implements
// 0=beenden, 1=abbrechen
if (choice == 0) {
try {
- client.DeleteFtpUser(user.userName,
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,
SessionData.session.getAuthToken());
} catch (TException e1) {
e1.printStackTrace();
}
task.cancel(true);
- con.closeThriftConnection();
try {
- client.setSessionInvalid(SessionData.session
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session
.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
@@ -166,7 +162,7 @@ public class FTPCreateUploader_GUI extends JFrame implements
// no upload running, close window
try {
- client.setSessionInvalid(SessionData.session
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session
.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
@@ -401,7 +397,7 @@ public class FTPCreateUploader_GUI extends JFrame implements
isAborted = true; // set flag
try {
- client.DeleteFtpUser(user.userName,
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,
SessionData.session.getAuthToken());
LOGGER.info("Deleted FTP user.");
} catch (TException e1) {
@@ -470,7 +466,7 @@ public class FTPCreateUploader_GUI extends JFrame implements
if (taskrun == true) {
try {
- client.DeleteFtpUser(user.userName,
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,
SessionData.session.getAuthToken());
} catch (TException e1) {
@@ -528,7 +524,7 @@ public class FTPCreateUploader_GUI extends JFrame implements
// 0=beenden, 1=abbrechen
if (choice == 0) {
try {
- client.DeleteFtpUser(user.userName,
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,
SessionData.session.getAuthToken());
} catch (TException e1) {
@@ -642,7 +638,7 @@ public class FTPCreateUploader_GUI extends JFrame implements
try {
LOGGER.info("Getting FTP User...");
- user = client.getFtpUser(SessionData.session.getAuthToken());
+ user = ThriftManager.getSatClient().getFtpUser(SessionData.session.getAuthToken());
LOGGER.info("Received FTP user.");
// LOGGER.debug("FTP name: " + user.userName);
// LOGGER.debug("FTP path: " + user.path);
@@ -737,7 +733,7 @@ public class FTPCreateUploader_GUI extends JFrame implements
try {
- client.writeVLdata(Image.image.getImagename(),
+ ThriftManager.getSatClient().writeVLdata(Image.image.getImagename(),
Image.image.getDesc(), person.verantwortlicher.getTel(),
person.verantwortlicher.getFakultaet(),
Image.image.isLicensed(), Image.image.isInternet(),
@@ -750,10 +746,10 @@ public class FTPCreateUploader_GUI extends JFrame implements
// System.out.println("userID is: "+person.verantwortlicher.getUserID());
System.out.println("starting file copy...");
- client.startFileCopy(Image.image.getNewName(),
+ ThriftManager.getSatClient().startFileCopy(Image.image.getNewName(),
SessionData.session.getAuthToken());
- client.writeImageRights(uuid, SessionData.session.getAuthToken(),
+ ThriftManager.getSatClient().writeImageRights(uuid, SessionData.session.getAuthToken(),
person.verantwortlicher.getRole(),
person.verantwortlicher.getHochschule(),
person.verantwortlicher.getUserID());
@@ -761,7 +757,7 @@ public class FTPCreateUploader_GUI extends JFrame implements
for (int i = 0; i < RightsManagement.rightsManagement
.getPermittedUserList().size(); i++) {
// System.out.println("Writing additional rights for user "+RightsManagement.rightsManagement.getPermittedUserList().get(i).getUserID()+", User "+i+"/"+RightsManagement.rightsManagement.getPermittedUserList().size());
- client.writeAdditionalImageRights(uuid,
+ ThriftManager.getSatClient().writeAdditionalImageRights(uuid,
RightsManagement.rightsManagement
.getPermittedUserList().get(i).getUserID(),
RightsManagement.rightsManagement
diff --git a/dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java b/dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java
index d190c50f..6db115fb 100644
--- a/dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java
+++ b/dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java
@@ -42,10 +42,9 @@ import models.person;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
-import org.openslx.sat.thrift.iface.Server.Client;
import org.openslx.sat.thrift.iface.User;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
import config.Config;
import ftp.DownloadTask;
@@ -84,8 +83,6 @@ public class FTPEditDownloader_GUI extends JFrame implements
long bytesread;
JLabel lblZeit;
boolean taskrun = false;
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
JButton btnZurck = new JButton("Zurück");
JButton btnDownloadStarten = new JButton("Download starten");
JButton btnDownloadStoppen = new JButton("Download abbrechen");
@@ -123,10 +120,9 @@ public class FTPEditDownloader_GUI extends JFrame implements
// 0=beenden, 1=abbrechen
if (choice == 0) {
try {
- client.DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
- con.closeThriftConnection();
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
@@ -141,7 +137,7 @@ public class FTPEditDownloader_GUI extends JFrame implements
} else {
// no download running, close window
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
@@ -426,7 +422,7 @@ public class FTPEditDownloader_GUI extends JFrame implements
isAborted = true; // set flag
try {
- client.DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
LOGGER.info("FTP user deleted.");
} catch (TException e1) {
@@ -465,7 +461,7 @@ public class FTPEditDownloader_GUI extends JFrame implements
if (choice == 0) {
task.cancel(true);
try {
- client.DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
} catch (TException e1) {
e1.printStackTrace();
@@ -527,11 +523,11 @@ public class FTPEditDownloader_GUI extends JFrame implements
// Klick
btnDownloadStarten.setText("Bitte warten");
try {
- user = client.getFtpUser(SessionData.session.getAuthToken());
+ user = ThriftManager.getSatClient().getFtpUser(SessionData.session.getAuthToken());
downloadFile = user.path
+ "/"
- + client.getPathOfImage(Image.image.getImageId(),
+ + ThriftManager.getSatClient().getPathOfImage(Image.image.getImageId(),
Image.image.getVersion(),SessionData.session.getAuthToken());
} catch (TException e) {
diff --git a/dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java b/dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java
index a8c2424c..231fd82f 100644
--- a/dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java
+++ b/dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java
@@ -47,10 +47,9 @@ import models.person;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
-import org.openslx.sat.thrift.iface.Server.Client;
import org.openslx.sat.thrift.iface.User;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
import config.Config;
import ftp.UploadTask;
@@ -91,8 +90,6 @@ public class FTPEditUploader_GUI extends JFrame implements
boolean fileupload = false;
boolean taskrun = false;
int progress = 0;
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
JButton btnUploadStarten = new JButton("Upload auf Server starten");
JButton btnSpeicherortAuswhlen = new JButton("Image auswählen");
JButton btnFinish = new JButton("Fertigstellen");
@@ -135,20 +132,19 @@ public class FTPEditUploader_GUI extends JFrame implements
// 0=beenden, 1=abbrechen
if (choice == 0) {
try {
- client.DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
} catch (TException e1) {
e1.printStackTrace();
}
task.cancel(true);
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- con.closeThriftConnection();
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -158,7 +154,7 @@ public class FTPEditUploader_GUI extends JFrame implements
} else {
// no upload running, close window
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -375,7 +371,7 @@ public class FTPEditUploader_GUI extends JFrame implements
isAborted = true; // set flag
try {
- client.DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
LOGGER.info("FTP user deleted.");
} catch (TException e1) {
e1.printStackTrace();
@@ -449,7 +445,7 @@ public class FTPEditUploader_GUI extends JFrame implements
if (taskrun == true) {
try {
- client.DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
} catch (TException e1) {
e1.printStackTrace();
@@ -479,7 +475,7 @@ public class FTPEditUploader_GUI extends JFrame implements
// 0=beenden, 1=abbrechen
if (choice == 0) {
try {
- client.DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
} catch (TException e1) {
e1.printStackTrace();
}
@@ -488,7 +484,7 @@ public class FTPEditUploader_GUI extends JFrame implements
try {
- if(client.userIsImageAdmin(Image.image.getImageId(), SessionData.session.getAuthToken(),person.verantwortlicher.getUserID()) == true || person.verantwortlicher.getRole().equals("Admin")){
+ if(ThriftManager.getSatClient().userIsImageAdmin(Image.image.getImageId(), SessionData.session.getAuthToken(),person.verantwortlicher.getUserID()) == true || person.verantwortlicher.getRole().equals("Admin")){
//user is admin and may change permissions
PermissionEditImage_GUI ei = new PermissionEditImage_GUI(c);
@@ -519,7 +515,7 @@ public class FTPEditUploader_GUI extends JFrame implements
try {
System.out.println("userID in editimageuploader is : "+person.verantwortlicher.getUserID());
- if(client.userIsImageAdmin(Image.image.getImageId(), SessionData.session.getAuthToken(),person.verantwortlicher.getUserID()) == true)
+ if(ThriftManager.getSatClient().userIsImageAdmin(Image.image.getImageId(), SessionData.session.getAuthToken(),person.verantwortlicher.getUserID()) == true)
{
//user is admin and may change permissions
PermissionEditImage_GUI ei = new PermissionEditImage_GUI(c);
@@ -624,7 +620,7 @@ public class FTPEditUploader_GUI extends JFrame implements
try {
//LOGGER.info("Getting FTP-User...");
- user = client.getFtpUser(SessionData.session.getAuthToken());
+ user = ThriftManager.getSatClient().getFtpUser(SessionData.session.getAuthToken());
LOGGER.info("Received FTP user.");
//LOGGER.debug("FTP name: " + user.userName);
//LOGGER.debug("FTP path: " + user.path);
@@ -727,7 +723,7 @@ public class FTPEditUploader_GUI extends JFrame implements
LOGGER.debug("New file uploaded and new filename is set");
//LOGGER.debug("(NOT NULL) new FileName is '"+Image.image.getNewName()+"', imagepath="+ Image.image.getImagepath());
- client.updateImageData(
+ ThriftManager.getSatClient().updateImageData(
Image.image.getImagename(),
Image.image.getImagename(),
Image.image.getDesc(),
@@ -746,14 +742,14 @@ public class FTPEditUploader_GUI extends JFrame implements
SessionData.session.getAuthToken()
);
if (fileupload == true) {
- client.startFileCopy(Image.image.getNewName(),SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().startFileCopy(Image.image.getNewName(),SessionData.session.getAuthToken());
}
} else { //no new file uploaded and old file name stays
//LOGGER.debug("(NULL) newName is '"+Image.image.getNewName()+"', imagepath="+ Image.image.getImagepath());
LOGGER.debug("old file should remain");
- client.updateImageData(
+ ThriftManager.getSatClient().updateImageData(
Image.image.getImagename(),
Image.image.getImagename(),
Image.image.getDesc(),
@@ -773,7 +769,7 @@ public class FTPEditUploader_GUI extends JFrame implements
);
if (fileupload == true) {
- client.startFileCopy(Image.image.getNewName(),SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().startFileCopy(Image.image.getNewName(),SessionData.session.getAuthToken());
// client.startFileCopy(Image.image.getImagename());
}
}
@@ -781,7 +777,7 @@ public class FTPEditUploader_GUI extends JFrame implements
// remove all additional user permissions on first stage
- client.deleteAllAdditionalImagePermissions(Image.image.getImageId(),SessionData.session.getAuthToken(),person.verantwortlicher.getUserID());
+ ThriftManager.getSatClient().deleteAllAdditionalImagePermissions(Image.image.getImageId(),SessionData.session.getAuthToken(),person.verantwortlicher.getUserID());
// then, add user permissions as they have been set new
for (int i = 0; i < RightsManagement.rightsManagement.getPermittedUserList().size(); i++)
@@ -795,7 +791,7 @@ public class FTPEditUploader_GUI extends JFrame implements
+ RightsManagement.rightsManagement.getPermittedUserList().size());
*/
- client.writeAdditionalImageRights(Image.image.getImageId(),
+ ThriftManager.getSatClient().writeAdditionalImageRights(Image.image.getImageId(),
RightsManagement.rightsManagement.getPermittedUserList().get(i).getUserID(),
RightsManagement.rightsManagement.getPermittedUserList().get(i).isImageRead(),
RightsManagement.rightsManagement.getPermittedUserList().get(i).isImageWrite(),
diff --git a/dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java b/dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java
index 823d8894..0cb63429 100644
--- a/dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java
+++ b/dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java
@@ -42,10 +42,9 @@ import models.person;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
-import org.openslx.sat.thrift.iface.Server.Client;
import org.openslx.sat.thrift.iface.User;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
import config.Config;
import ftp.DownloadTask;
@@ -81,8 +80,6 @@ public class FTPSearchDownloader_GUI extends JFrame implements
long bytesread;
JLabel lblZeit;
boolean taskrun = false;
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
JButton btnZurck = new JButton("Zurück");
JButton btnDownloadStarten = new JButton("Download starten");
JButton btnMainMenu = new JButton("Hauptmenü");
@@ -122,16 +119,15 @@ public class FTPSearchDownloader_GUI extends JFrame implements
if (choice == 0) {
try {
- client.DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
- con.closeThriftConnection();
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
@@ -147,7 +143,7 @@ public class FTPSearchDownloader_GUI extends JFrame implements
} else {
// no download running, close window
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
@@ -432,7 +428,7 @@ public class FTPSearchDownloader_GUI extends JFrame implements
isAborted = true; // set flag
try {
- client.DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
LOGGER.info("Deleted FTP user.");
} catch (TException e1) {
// TODO Auto-generated catch block
@@ -472,7 +468,7 @@ public class FTPSearchDownloader_GUI extends JFrame implements
if (choice == 0) {
task.cancel(true);
try {
- client.DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken());
} catch (TException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
@@ -534,11 +530,11 @@ public class FTPSearchDownloader_GUI extends JFrame implements
// Klick
btnDownloadStarten.setText("Bitte warten");
try {
- user = client.getFtpUser(SessionData.session.getAuthToken());
+ user = ThriftManager.getSatClient().getFtpUser(SessionData.session.getAuthToken());
downloadFile = user.path
+ "/"
- + client.getPathOfImage(Image.image.getImageId(),
+ + ThriftManager.getSatClient().getPathOfImage(Image.image.getImageId(),
Image.image.getVersion(),SessionData.session.getAuthToken());
} catch (TException e) {
diff --git a/dozentenmodul/src/main/java/gui/image/SearchEditImage_GUI.java b/dozentenmodul/src/main/java/gui/image/SearchEditImage_GUI.java
index 7ebd604d..3ad45213 100644
--- a/dozentenmodul/src/main/java/gui/image/SearchEditImage_GUI.java
+++ b/dozentenmodul/src/main/java/gui/image/SearchEditImage_GUI.java
@@ -61,9 +61,8 @@ import models.SessionData;
import models.person;
import org.apache.thrift.TException;
-import org.openslx.sat.thrift.iface.Server.Client;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
//import models.person;
@@ -116,10 +115,6 @@ public class SearchEditImage_GUI extends JFrame {
+ "Klicken Sie auf \"Weiter\" um das Image für weitere Schritte auszuwählen."
+ "</div></html>";
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
-
-
final DefaultTableModel modelMyImages = new DefaultTableModel(titles, 0) {
public boolean isCellEditable(int rowIndex, int mColIndex) {
@@ -151,13 +146,11 @@ public class SearchEditImage_GUI extends JFrame {
public void windowClosing(WindowEvent arg0) {
// Beendet die Anwendung nach klick auf X
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- con.closeThriftConnection();
-
System.exit(0);
}
@@ -315,7 +308,7 @@ public class SearchEditImage_GUI extends JFrame {
try {
// Holt sich eine Liste aller verfuegbaren Betriebssysteme vom
// Server
- List<String> list = client.getAllOS(SessionData.session.getAuthToken());
+ List<String> list = ThriftManager.getSatClient().getAllOS(SessionData.session.getAuthToken());
// Leeres Item hinzufuegen
comboBox.addItem("");
for (int i = 0; i < list.size(); i++) {
@@ -750,10 +743,10 @@ public class SearchEditImage_GUI extends JFrame {
// Hole eine Liste der passenden Images,
if(person.verantwortlicher.getRole()=="Admin"){
//get complete list
- images = client.getImageList(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
+ images = ThriftManager.getSatClient().getImageList(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
} else {
//only get permitted list
- images = client.getImageListPermissionWrite(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
+ images = ThriftManager.getSatClient().getImageListPermissionWrite(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
}
Iterator<org.openslx.sat.thrift.iface.Image> i = images.iterator();
@@ -821,7 +814,7 @@ public class SearchEditImage_GUI extends JFrame {
try {
SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat out = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
- Map<String, String> res = client.getImageData(id, version,SessionData.session.getAuthToken());
+ Map<String, String> res = ThriftManager.getSatClient().getImageData(id, version,SessionData.session.getAuthToken());
labelName.setText(res.get("name"));
labelOS.setText(res.get("os"));
labelUpdate.setText(out.format(in.parse(res.get("lastupdate"))));
@@ -850,7 +843,7 @@ public class SearchEditImage_GUI extends JFrame {
textAreadesc.setText(res.get("desc"));
res.clear();
- List<String> contacts = client.getAdditionalImageContacts(id,SessionData.session.getAuthToken());
+ List<String> contacts = ThriftManager.getSatClient().getAdditionalImageContacts(id,SessionData.session.getAuthToken());
labelWeitereVerantwortliche.setText("");
for (int i = 0; i < contacts.size(); i++)
{
@@ -870,7 +863,7 @@ public class SearchEditImage_GUI extends JFrame {
try {
//get values from server and set them in model
- map=client.getItemOwner(imageid,SessionData.session.getAuthToken());
+ map=ThriftManager.getSatClient().getItemOwner(imageid,SessionData.session.getAuthToken());
ItemOwner.itemOwner.setUserID(map.get("userID"));
ItemOwner.itemOwner.setUsername(map.get("loginName"));
diff --git a/dozentenmodul/src/main/java/gui/image/SearchImage_GUI.java b/dozentenmodul/src/main/java/gui/image/SearchImage_GUI.java
index 18f4a1e7..78b21987 100644
--- a/dozentenmodul/src/main/java/gui/image/SearchImage_GUI.java
+++ b/dozentenmodul/src/main/java/gui/image/SearchImage_GUI.java
@@ -60,9 +60,8 @@ import models.SessionData;
import models.person;
import org.apache.thrift.TException;
-import org.openslx.sat.thrift.iface.Server.Client;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
@SuppressWarnings("serial")
@@ -114,8 +113,7 @@ public class SearchImage_GUI extends JFrame {
"Die Volltextsuche sucht in den Feldern Name und Beschreibung." +
"</div></html>";
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
+
final DefaultTableModel modelAll = new DefaultTableModel(titles, 0) {
public boolean isCellEditable(int rowIndex, int mColIndex) {
return false;
@@ -166,12 +164,11 @@ public class SearchImage_GUI extends JFrame {
public void windowClosing(WindowEvent arg0) {
// Beendet die Anwendung nach klick auf X
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- con.closeThriftConnection();
System.exit(0);
}
@@ -420,7 +417,7 @@ public class SearchImage_GUI extends JFrame {
try {
// Holt sich eine Liste aller verfuegbaren Betriebssysteme vom
// Server
- List<String> list = client.getAllOS(SessionData.session.getAuthToken());
+ List<String> list = ThriftManager.getSatClient().getAllOS(SessionData.session.getAuthToken());
// Leeres Item hinzufuegen
comboBox.addItem("");
for (int i = 0; i < list.size(); i++) {
@@ -987,9 +984,9 @@ public class SearchImage_GUI extends JFrame {
// Hole eine Liste der Images
if(person.verantwortlicher.getRole()=="Admin"){
//get complete list
- images = client.getImageList(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
+ images = ThriftManager.getSatClient().getImageList(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
} else {
- images = client.getImageListPermissionRead(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
+ images = ThriftManager.getSatClient().getImageListPermissionRead(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
}
Iterator<org.openslx.sat.thrift.iface.Image> i = images.iterator();
@@ -1037,7 +1034,7 @@ public class SearchImage_GUI extends JFrame {
List<org.openslx.sat.thrift.iface.Image> images;
try {
// Hole eine Liste der Images
- images = client.getImageList(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
+ images = ThriftManager.getSatClient().getImageList(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
Iterator<org.openslx.sat.thrift.iface.Image> i = images.iterator();
SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -1087,7 +1084,7 @@ public class SearchImage_GUI extends JFrame {
List<org.openslx.sat.thrift.iface.Image> images;
try {
// Hole eine Liste der Images
- images = client.getImageListAllTemplates(SessionData.session.getAuthToken());
+ images = ThriftManager.getSatClient().getImageListAllTemplates(SessionData.session.getAuthToken());
Iterator<org.openslx.sat.thrift.iface.Image> i = images.iterator();
SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -1155,7 +1152,7 @@ public class SearchImage_GUI extends JFrame {
try {
SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat out = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
- Map<String, String> res = client.getImageData(id, version,SessionData.session.getAuthToken());
+ Map<String, String> res = ThriftManager.getSatClient().getImageData(id, version,SessionData.session.getAuthToken());
labelName.setText(res.get("name"));
labelOS.setText(res.get("os"));
labelUpdate.setText(out.format(in.parse(res.get("lastupdate"))));
@@ -1182,7 +1179,7 @@ public class SearchImage_GUI extends JFrame {
labelVersion.setText(res.get("version"));
textAreadesc.setText(res.get("desc"));
- List<String> contacts = client.getAdditionalImageContacts(id,SessionData.session.getAuthToken());
+ List<String> contacts = ThriftManager.getSatClient().getAdditionalImageContacts(id,SessionData.session.getAuthToken());
labelWeitereVerantwortliche.setText("");
for (int i = 0; i < contacts.size(); i++)
{
diff --git a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
index 0af27fee..974a62aa 100644
--- a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
+++ b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
@@ -41,13 +41,12 @@ import models.person;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
-import org.openslx.imagemaster.thrift.iface.ImageServer.Client;
+import org.openslx.imagemaster.thrift.iface.ImageServer;
import org.openslx.imagemaster.thrift.iface.OrganizationData;
import org.openslx.imagemaster.thrift.iface.UserInfo;
import org.openslx.sat.thrift.iface.Server;
-import thrift.MasterThriftConnection;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.GuiOrganizer;
import util.ResourceLoader;
import util.ShibbolethECP;
@@ -295,24 +294,12 @@ public class Login_GUI extends JFrame {
public void performLogin(final String loginType) {
LOGGER.info("Trying login of type: " + loginType);
-
-
- if (loginType == LOGIN_TYPE_BWLEHRPOOL)
- {
+ if (loginType == LOGIN_TYPE_BWLEHRPOOL) {
// start the authentication process against the masterserver
org.openslx.imagemaster.thrift.iface.SessionData result = null;
// Connect to Master
- MasterThriftConnection thrift = new MasterThriftConnection();
- Client client = thrift.getMasterThriftConnection();
-
- if (client == null) {
- // Thrift connection to master could not be established
- setStatus(Color.red, "Fehler: Masterserver nicht erreichbar.", null);
- LOGGER.info("Thrift client could not be initialized, is the masterserver up and running?");
- return;
- }
-
+ ImageServer.Client client = ThriftManager.getMasterClient();
String passText = new String(lblpass.getPassword());
UserInfo user = null;
// Log user in
@@ -355,18 +342,14 @@ public class Login_GUI extends JFrame {
// set Information
SessionData.session.setAuthToken(result.authToken);
SessionData.session.setSessionID(result.sessionId);
+ // TODO: support list of adresses
SessionData.session.setServerAdress(result.serverAddress);
+ ThriftManager.setSatellite(result.serverAddress);
// Satellite-Connection
setStatus(Color.black, "Hole Verbindungsdaten von Server...", null);
- // set connection to bwLehrpoolSuiteServer
- ThriftConnection bwthrift = new ThriftConnection();
- Server.Client bwClient = bwthrift.getThriftConnection();
- models.Client.clientcon.setClient(bwClient);
// User-Info
- //LOGGER.debug("Session-ID: " + result.sessionId);
- //LOGGER.debug("Token: " + result.authToken);
setStatus(Color.green, "Daten erhalten.", null);
String hochschule = user.eMail.substring(user.eMail.indexOf("@") + 1);
@@ -417,6 +400,11 @@ public class Login_GUI extends JFrame {
JOptionPane.showMessageDialog(c, "Anmeldung fehlgeschlagen. Überprüfen Sie den Benutzername und Passwort.",
"Fehler", JOptionPane.ERROR_MESSAGE);
break;
+ case ERROR_UNREG:
+ setStatus(Color.red, "Fehler: Nicht bei bwLehrpool registriert!", null);
+ JOptionPane.showMessageDialog(c, "Sie sind nicht bei bwLehrpool registriert.\nGehen Sie dazu auf folgende Seite:\n"
+ + ShibbolethECP.getRegistrationUrl(), "Fehler", JOptionPane.ERROR_MESSAGE);
+ break;
case ERROR_SP:
setStatus(Color.red, "Fehler: bwIDM-Anmeldung fehlgeschlagen!", null);
JOptionPane.showMessageDialog(c, "Anmeldung erfolgreich aber die Antwort des Service Providers ist ungültig.",
@@ -480,33 +468,19 @@ public class Login_GUI extends JFrame {
* This function should be called on a successful login.
*/
private void showMainMenu() {
-
- /*
- * TODO check if user has already been regisistered. if not, do so
- *
- *
- */
- //import server.generated.Server.Client;
- Server.Client client_2 = models.Client.clientcon.getClient();
- try
- {
- boolean authenticated = client_2.authenticated(authToken);
-
- if(!authenticated)
- {
+ try {
+ boolean authenticated = ThriftManager.getSatClient().authenticated(authToken);
+ if(!authenticated) {
//TODO message for user and deactivation of menu points, actually just system exit
System.exit(0);
}
-
} catch (TException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
- String pk_institution = client_2.setInstitution(person.verantwortlicher.getHochschule(),SessionData.session.getAuthToken());
- //LOGGER.info("Institution of user is: "+pk_institution);
- client_2.setPerson(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken(),pk_institution);
- //LOGGER.info("user data, ID="+person.verantwortlicher.getUserID()+" , Name="+person.verantwortlicher.getName()+" , Vorname="+ person.verantwortlicher.getVorname()+" , E-Mail="+ person.verantwortlicher.getEMail()+" , Institution="+ pk_institution);
+ String pk_institution = ThriftManager.getSatClient().setInstitution(person.verantwortlicher.getHochschule(),SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setPerson(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken(),pk_institution);
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -636,11 +610,11 @@ public class Login_GUI extends JFrame {
protected Boolean doInBackground() throws Exception {
publish("Info: Hole Liste von IdPs");
// if not then request it from the masterserver
- MasterThriftConnection thrift = new MasterThriftConnection();
- Client client = thrift.getMasterThriftConnection();
List<OrganizationData> tempOrgs = null;
try {
- tempOrgs = client.getOrganizations();
+ if (ThriftManager.getMasterClient() == null) LOGGER.error("DERP");
+
+ tempOrgs = ThriftManager.getMasterClient().getOrganizations();
} catch (TException e) {
LOGGER.error("Could not fetch list of identity providers from the masterserver, see trace: ", e);
return false;
diff --git a/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java b/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java
index 504203fe..c811b585 100644
--- a/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java
+++ b/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java
@@ -56,6 +56,7 @@ import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import org.openslx.sat.thrift.iface.Server.Client;
+import thrift.ThriftManager;
import util.News;
import util.OpenLinks;
import util.ResourceLoader;
@@ -82,9 +83,6 @@ public class MainMenue_GUI extends JFrame {
private JMenuItem mntmAbout;
Component c = null;
- Client client = models.Client.clientcon.getClient();
-
-
// for testing
ImageRights imageRights = new ImageRights();
@@ -97,7 +95,7 @@ public class MainMenue_GUI extends JFrame {
@Override
public void windowClosing(WindowEvent arg0) {
try {
- tokenDeleted = client.setSessionInvalid(SessionData.session.getAuthToken());
+ tokenDeleted = ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/dozentenmodul/src/main/java/gui/lecture/CreateLectureAllgemein_GUI.java b/dozentenmodul/src/main/java/gui/lecture/CreateLectureAllgemein_GUI.java
index 54a22d9f..1bac4642 100644
--- a/dozentenmodul/src/main/java/gui/lecture/CreateLectureAllgemein_GUI.java
+++ b/dozentenmodul/src/main/java/gui/lecture/CreateLectureAllgemein_GUI.java
@@ -46,8 +46,8 @@ import models.SessionData;
import models.person;
import org.apache.thrift.TException;
-import org.openslx.sat.thrift.iface.Server.Client;
+import thrift.ThriftManager;
import util.OpenLinks;
import com.toedter.calendar.JDateChooser;
@@ -70,7 +70,6 @@ public class CreateLectureAllgemein_GUI extends JFrame {
Date startDate = new Date();
Date endDate;
Component c = null;
- Client client = models.Client.clientcon.getClient();
private boolean descriptionLengthOK = false; // description may not be
// longer than
// MAX_DESCRIPTION_LENGTH
@@ -94,7 +93,7 @@ public class CreateLectureAllgemein_GUI extends JFrame {
@Override
public void windowClosing(WindowEvent arg0) {
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -512,11 +511,10 @@ public class CreateLectureAllgemein_GUI extends JFrame {
mntmFaq.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
- OpenLinks open = new OpenLinks();
URI windows;
try {
windows = new URI(Links.getFAQ());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
e.printStackTrace();
@@ -529,13 +527,10 @@ public class CreateLectureAllgemein_GUI extends JFrame {
mntmOtrs.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
URI windows;
try {
windows = new URI(Links.getOTRS());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
e.printStackTrace();
diff --git a/dozentenmodul/src/main/java/gui/lecture/CreateLectureLink_GUI.java b/dozentenmodul/src/main/java/gui/lecture/CreateLectureLink_GUI.java
index 14b050a9..837b6683 100644
--- a/dozentenmodul/src/main/java/gui/lecture/CreateLectureLink_GUI.java
+++ b/dozentenmodul/src/main/java/gui/lecture/CreateLectureLink_GUI.java
@@ -63,9 +63,8 @@ import models.person;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import org.openslx.sat.thrift.iface.Image;
-import org.openslx.sat.thrift.iface.Server.Client;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
@SuppressWarnings("serial")
@@ -100,8 +99,6 @@ public class CreateLectureLink_GUI extends JFrame {
private String uuid = null;
String[] titles = { "Image-Name", "Lizenzpflichtig", "OS", "Veranstaltung",
"Verantwortlicher", "Letztes Update", "ID", "Version", "Template", "Beschreibung" };
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
private static final String HELP_MESSAGE = "<html><div align=\"center\">"
+ "Damit Ihre Veranstaltung geladen werden kann, muss sie mit einem Image verbunden werden.<br />"
@@ -126,7 +123,7 @@ public class CreateLectureLink_GUI extends JFrame {
- RowFilter rf = null;
+ RowFilter<Object, Object> rf = null;
List<RowFilter<Object,Object>> filters = new ArrayList<RowFilter<Object,Object>>(2);
/**
@@ -142,12 +139,11 @@ public class CreateLectureLink_GUI extends JFrame {
@Override
public void windowClosing(WindowEvent arg0) {
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- con.closeThriftConnection();
System.exit(0);
}
@@ -216,8 +212,6 @@ public class CreateLectureLink_GUI extends JFrame {
setBounds(0, 0, 918, 722);
setLocationRelativeTo(formerGUI);
- final DefaultTableModel model = new DefaultTableModel(titles, 0);
-
getContentPane().setLayout(null);
{
JPanel panel = new JPanel();
@@ -300,7 +294,7 @@ public class CreateLectureLink_GUI extends JFrame {
comboBox = new JComboBox<String>();
try {
- List<String> list = client.getAllOS(SessionData.session.getAuthToken());
+ List<String> list = ThriftManager.getSatClient().getAllOS(SessionData.session.getAuthToken());
comboBox.addItem("");
for (int i = 0; i < list.size(); i++) {
comboBox.addItem(list.get(i));
@@ -443,8 +437,6 @@ public class CreateLectureLink_GUI extends JFrame {
"Veranstaltung erzeugen und abschließen");
doLinkButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- String username = person.verantwortlicher.getName()
- + " " + person.verantwortlicher.getVorname();
// check if a row is selected
if (tablemyImages.getSelectedRow() != -1) {
@@ -457,7 +449,7 @@ public class CreateLectureLink_GUI extends JFrame {
"yyyy-MM-dd HH:mm:ss");
//create new lecture
- client.writeLecturedata(
+ ThriftManager.getSatClient().writeLecturedata(
Lecture.lecture.getName(),
Lecture.lecture.getShortDesc(),
Lecture.lecture.getDesc(),
@@ -474,7 +466,7 @@ public class CreateLectureLink_GUI extends JFrame {
System.out.println("lectureID" + " " + uuid);
//set rights for this user
- client.writeLectureRights(
+ ThriftManager.getSatClient().writeLectureRights(
uuid,
person.verantwortlicher.getRole(),
SessionData.session.getAuthToken(),
@@ -485,7 +477,7 @@ public class CreateLectureLink_GUI extends JFrame {
//set rights for additional users
for(int i=0; i< RightsManagement.rightsManagement.getPermittedUserList().size(); i++){
//System.out.println("Writing additional rights for user "+RightsManagement.rightsManagement.getPermittedUserList().get(i).getUserID()+", User "+(i+1)+"/"+RightsManagement.rightsManagement.getPermittedUserList().size());
- client.writeAdditionalLectureRights(
+ ThriftManager.getSatClient().writeAdditionalLectureRights(
uuid,
RightsManagement.rightsManagement.getPermittedUserList().get(i).getUserID(),
RightsManagement.rightsManagement.getPermittedUserList().get(i).isLecture_read(),
@@ -682,14 +674,11 @@ public class CreateLectureLink_GUI extends JFrame {
mntmFaq.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
URI windows;
try {
windows = new URI(Links.getFAQ());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
@@ -703,14 +692,11 @@ public class CreateLectureLink_GUI extends JFrame {
mntmOtrs.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
URI windows;
try {
windows = new URI(Links.getOTRS());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
@@ -743,7 +729,7 @@ public class CreateLectureLink_GUI extends JFrame {
try
{
- uuid = client.createRandomUUID(SessionData.session.getAuthToken());
+ uuid = ThriftManager.getSatClient().createRandomUUID(SessionData.session.getAuthToken());
}
catch (TException e1)
{
@@ -763,9 +749,9 @@ public class CreateLectureLink_GUI extends JFrame {
// Hole eine Liste der Images
if(person.verantwortlicher.getRole()=="Admin"){
//get complete list
- images = client.getImageList(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
+ images = ThriftManager.getSatClient().getImageList(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
} else {
- images = client.getImageListPermissionLink(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
+ images = ThriftManager.getSatClient().getImageListPermissionLink(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
}
Iterator<Image> i = images.iterator();
@@ -819,7 +805,7 @@ public class CreateLectureLink_GUI extends JFrame {
SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat out = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
- Map<String, String> res = client.getImageData(id, version,SessionData.session.getAuthToken());
+ Map<String, String> res = ThriftManager.getSatClient().getImageData(id, version,SessionData.session.getAuthToken());
labelName.setText(res.get("name"));
labelOS.setText(res.get("os"));
labelUpdate.setText(out.format(in.parse(res.get("lastupdate"))));
diff --git a/dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java b/dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java
index 438e817f..0dd68697 100644
--- a/dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java
+++ b/dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java
@@ -59,9 +59,8 @@ import models.person;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import org.openslx.sat.thrift.iface.Lecture;
-import org.openslx.sat.thrift.iface.Server.Client;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
@SuppressWarnings("serial")
@@ -90,9 +89,6 @@ public class DeleteLecture_GUI extends JFrame {
"Gültigkeitsdatum", "Aktiv", "Letzte Benutzung",
"Verantwortlicher", "Image", "Schlagwort", "ID" };
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
-
final DefaultTableModel modelMyLectures = new DefaultTableModel(titles, 0){
public boolean isCellEditable(int rowIndex, int mColIndex) {
return false;
@@ -106,7 +102,6 @@ public class DeleteLecture_GUI extends JFrame {
modelMyLectures);
private JButton button;
- private JTextField textField;
Component c = null;
private static final String HELP_MESSAGE = "<html><div align=\"center\">"
@@ -115,7 +110,7 @@ public class DeleteLecture_GUI extends JFrame {
+ "Veraltet bedeutet, dass Veranstaltungen, die drei Monate lang nicht augerufen wurden, vorerst deaktiviert werden."
+ "</div></html>";
- RowFilter rf = null;
+ RowFilter<Object, Object> rf = null;
List<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>(2);
/**
@@ -132,12 +127,11 @@ public class DeleteLecture_GUI extends JFrame {
public void windowClosing(WindowEvent arg0) {
// Beendet die Anwendung nach klick auf X
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- con.closeThriftConnection();
System.exit(0);
}
@@ -376,8 +370,6 @@ public class DeleteLecture_GUI extends JFrame {
String lectureID = "";
int eingabe;
- String username = person.verantwortlicher.getName() + " "
- + person.verantwortlicher.getVorname();
// check if a row is selected
if (tablemyLectures.getSelectedRowCount() != 0) {
// a row is selected
@@ -401,7 +393,7 @@ public class DeleteLecture_GUI extends JFrame {
// LOGGER.info("Lösche Veranstaltung: " + lectureID);
try {
- if (client.deleteLecture(
+ if (ThriftManager.getSatClient().deleteLecture(
lectureID,
SessionData.session.getAuthToken(),
person.verantwortlicher.getHochschule()
@@ -568,14 +560,11 @@ public class DeleteLecture_GUI extends JFrame {
mntmFaq.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
URI windows;
try {
windows = new URI(Links.getFAQ());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
@@ -589,14 +578,11 @@ public class DeleteLecture_GUI extends JFrame {
mntmOtrs.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
URI windows;
try {
windows = new URI(Links.getOTRS());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
@@ -641,12 +627,12 @@ public class DeleteLecture_GUI extends JFrame {
if(person.verantwortlicher.getRole()=="Admin")
{
//get complete list
- lectures = client.getLectureList(SessionData.session.getAuthToken());
+ lectures = ThriftManager.getSatClient().getLectureList(SessionData.session.getAuthToken());
}
else
{
//get permitted list
- lectures = client.getLectureListPermissionAdmin(SessionData.session.getAuthToken());
+ lectures = ThriftManager.getSatClient().getLectureListPermissionAdmin(SessionData.session.getAuthToken());
}
Iterator<Lecture> i = lectures.iterator();
@@ -704,7 +690,7 @@ public class DeleteLecture_GUI extends JFrame {
SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat out = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
- Map<String, String> res = client.getLectureData(id,SessionData.session.getAuthToken());
+ Map<String, String> res = ThriftManager.getSatClient().getLectureData(id,SessionData.session.getAuthToken());
labelName.setText(res.get("name"));
labelAktiv.setText(res.get("isActive"));
labeldesc.setText(res.get("desc"));
diff --git a/dozentenmodul/src/main/java/gui/lecture/EditLectureAllgemein_GUI.java b/dozentenmodul/src/main/java/gui/lecture/EditLectureAllgemein_GUI.java
index 88a79fb6..597a3539 100644
--- a/dozentenmodul/src/main/java/gui/lecture/EditLectureAllgemein_GUI.java
+++ b/dozentenmodul/src/main/java/gui/lecture/EditLectureAllgemein_GUI.java
@@ -556,11 +556,10 @@ public class EditLectureAllgemein_GUI extends JFrame {
mntmFaq.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
- OpenLinks open = new OpenLinks();
URI windows;
try {
windows = new URI(Links.getFAQ());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
e.printStackTrace();
@@ -573,11 +572,10 @@ public class EditLectureAllgemein_GUI extends JFrame {
mntmOtrs.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
- OpenLinks open = new OpenLinks();
URI windows;
try {
windows = new URI(Links.getOTRS());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
e.printStackTrace();
diff --git a/dozentenmodul/src/main/java/gui/lecture/EditLectureLink_GUI.java b/dozentenmodul/src/main/java/gui/lecture/EditLectureLink_GUI.java
index 9ae612f6..3e78751c 100644
--- a/dozentenmodul/src/main/java/gui/lecture/EditLectureLink_GUI.java
+++ b/dozentenmodul/src/main/java/gui/lecture/EditLectureLink_GUI.java
@@ -62,9 +62,8 @@ import models.person;
import org.apache.thrift.TException;
import org.openslx.sat.thrift.iface.Image;
-import org.openslx.sat.thrift.iface.Server.Client;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
@SuppressWarnings("serial")
@@ -98,8 +97,7 @@ public class EditLectureLink_GUI extends JFrame {
Component c = null;
String[] titles = { "Image-Name", "Lizenzpflichtig", "OS", "Veranstaltung",
"Verantwortlicher", "Letztes Update", "ID", "Version", "Template", "Beschreibung" };
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
+
final DefaultTableModel modelAll = new DefaultTableModel(titles, 0) {
public boolean isCellEditable(int rowIndex, int mColIndex) {
return false;
@@ -122,18 +120,17 @@ public class EditLectureLink_GUI extends JFrame {
modelMyImages);
final TableRowSorter<TableModel> rowSorterPublicVorlagen = new TableRowSorter<TableModel>(
modelPublicVorlagen);
- private JTextField textField;
- RowFilter orFilter = null;
+ RowFilter<Object, Object> orFilter = null;
List<RowFilter<Object,Object>> orFilters = new ArrayList<RowFilter<Object,Object>>();
//needed for templates, filter for name OR desc AND temp_flag --> (name || desc) && (temp_flag)
- RowFilter andFilter = null;
+ RowFilter<Object, Object> andFilter = null;
List<RowFilter<Object,Object>> andFilters = new ArrayList<RowFilter<Object,Object>>();
//the final filter which handles the search in the templates
- RowFilter templateFilter = null;
+ RowFilter<Object, Object> templateFilter = null;
ArrayList<RowFilter<Object, Object>> finalFilters = new ArrayList<RowFilter<Object, Object>>();
@@ -152,12 +149,11 @@ public class EditLectureLink_GUI extends JFrame {
@Override
public void windowClosing(WindowEvent arg0) {
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- con.closeThriftConnection();
System.exit(0);
}
@@ -412,7 +408,7 @@ public class EditLectureLink_GUI extends JFrame {
comboBox = new JComboBox<String>();
try {
- List<String> list = client.getAllOS(SessionData.session.getAuthToken());
+ List<String> list = ThriftManager.getSatClient().getAllOS(SessionData.session.getAuthToken());
comboBox.addItem("");
for (int i = 0; i < list.size(); i++) {
comboBox.addItem(list.get(i));
@@ -627,7 +623,7 @@ public class EditLectureLink_GUI extends JFrame {
//check which GUI to open
try {
- if(client.userIsLectureAdmin(person.verantwortlicher.getUserID(), Lecture.lecture.getid(),SessionData.session.getAuthToken()) || (person.verantwortlicher.getRole().equals("Admin"))){
+ if(ThriftManager.getSatClient().userIsLectureAdmin(person.verantwortlicher.getUserID(), Lecture.lecture.getid(),SessionData.session.getAuthToken()) || (person.verantwortlicher.getRole().equals("Admin"))){
//user is admin of the lecture
PermissionEditLecture_GUI ev = new PermissionEditLecture_GUI(c);
@@ -662,15 +658,12 @@ public class EditLectureLink_GUI extends JFrame {
if (tablemyImages.getSelectedRow() != -1) {
// a row is selected, do operations
- String imagename = tablemyImages.getValueAt(
- tablemyImages.getSelectedRow(), 0)
- .toString();
try {
DateFormat formatter = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
// update the lecture
- client.updateLecturedata(
+ ThriftManager.getSatClient().updateLecturedata(
Lecture.lecture.getid(),
Lecture.lecture.getNewName(),
Lecture.lecture.getShortDesc(),
@@ -698,7 +691,7 @@ public class EditLectureLink_GUI extends JFrame {
// remove all additional user permissions on
// first stage
- client.deleteAllAdditionalLecturePermissions(
+ ThriftManager.getSatClient().deleteAllAdditionalLecturePermissions(
Lecture.lecture.getid(),
SessionData.session.getAuthToken(),
person.verantwortlicher.getUserID());
@@ -724,7 +717,7 @@ public class EditLectureLink_GUI extends JFrame {
);
*/
- client.writeAdditionalLectureRights(
+ ThriftManager.getSatClient().writeAdditionalLectureRights(
Lecture.lecture.getid(),
RightsManagement.rightsManagement
.getPermittedUserList()
@@ -777,13 +770,10 @@ public class EditLectureLink_GUI extends JFrame {
.toString().equals(username)) {
// a row is selected, do operations
- String imagename = tablePublicVorlagen.getValueAt(
- tablePublicVorlagen.getSelectedRow(), 0)
- .toString();
try {
DateFormat formatter = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
- client.updateLecturedata(
+ ThriftManager.getSatClient().updateLecturedata(
Lecture.lecture.getName(),
Lecture.lecture.getNewName(),
Lecture.lecture.getShortDesc(),
@@ -815,7 +805,7 @@ public class EditLectureLink_GUI extends JFrame {
// remove all additional user permissions on
// first stage
- client.deleteAllAdditionalLecturePermissions(
+ ThriftManager.getSatClient().deleteAllAdditionalLecturePermissions(
Lecture.lecture.getid(),
SessionData.session.getAuthToken(),
person.verantwortlicher.getUserID());
@@ -835,7 +825,7 @@ public class EditLectureLink_GUI extends JFrame {
+ RightsManagement.rightsManagement
.getPermittedUserList()
.size());
- client.writeAdditionalLectureRights(
+ ThriftManager.getSatClient().writeAdditionalLectureRights(
Lecture.lecture.getName(),
RightsManagement.rightsManagement
.getPermittedUserList()
@@ -886,13 +876,10 @@ public class EditLectureLink_GUI extends JFrame {
4).toString().equals(username)) {
// a row is selected, do operations
- String imagename = tableAllImages.getValueAt(
- tableAllImages.getSelectedRow(), 0)
- .toString();
try {
DateFormat formatter = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
- client.updateLecturedata(
+ ThriftManager.getSatClient().updateLecturedata(
Lecture.lecture.getName(),
Lecture.lecture.getNewName(),
Lecture.lecture.getShortDesc(),
@@ -922,7 +909,7 @@ public class EditLectureLink_GUI extends JFrame {
// remove all additional user permissions on
// first stage
- client.deleteAllAdditionalLecturePermissions(
+ ThriftManager.getSatClient().deleteAllAdditionalLecturePermissions(
Lecture.lecture.getid(),
SessionData.session.getAuthToken(),
person.verantwortlicher.getUserID());
@@ -942,7 +929,7 @@ public class EditLectureLink_GUI extends JFrame {
+ RightsManagement.rightsManagement
.getPermittedUserList()
.size());
- client.writeAdditionalLectureRights(
+ ThriftManager.getSatClient().writeAdditionalLectureRights(
Lecture.lecture.getName(),
RightsManagement.rightsManagement
.getPermittedUserList()
@@ -1145,14 +1132,11 @@ public class EditLectureLink_GUI extends JFrame {
mntmFaq.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
URI windows;
try {
windows = new URI(Links.getFAQ());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
@@ -1166,14 +1150,11 @@ public class EditLectureLink_GUI extends JFrame {
mntmOtrs.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
URI windows;
try {
windows = new URI(Links.getOTRS());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
@@ -1216,10 +1197,10 @@ public class EditLectureLink_GUI extends JFrame {
// Hole eine Liste der Images
if(person.verantwortlicher.getRole()=="Admin"){
//get complete list
- images = client.getImageList(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
+ images = ThriftManager.getSatClient().getImageList(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
} else {
//get permitted list
- images = client.getImageListPermissionLink(person.verantwortlicher
+ images = ThriftManager.getSatClient().getImageListPermissionLink(person.verantwortlicher
.getUserID(),SessionData.session.getAuthToken());
}
@@ -1259,10 +1240,10 @@ public class EditLectureLink_GUI extends JFrame {
// Hole eine Liste der Images
if(person.verantwortlicher.getRole()=="Admin"){
//get complete list
- images = client.getImageList(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
+ images = ThriftManager.getSatClient().getImageList(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken());
} else {
//get permitted list
- images = client.getImageListPermissionLink(person.verantwortlicher
+ images = ThriftManager.getSatClient().getImageListPermissionLink(person.verantwortlicher
.getUserID(),SessionData.session.getAuthToken());
}
@@ -1301,8 +1282,8 @@ public class EditLectureLink_GUI extends JFrame {
List<Image> images;
// Hole eine Liste der Images
- //images = client.getImageListPermissionLink(person.verantwortlicher.getUserID());
- images = client.getImageListAllTemplates(SessionData.session.getAuthToken());
+ //images = ThriftManager.getSatClient().getImageListPermissionLink(person.verantwortlicher.getUserID());
+ images = ThriftManager.getSatClient().getImageListAllTemplates(SessionData.session.getAuthToken());
Iterator<Image> i = images.iterator();
SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -1356,7 +1337,7 @@ public class EditLectureLink_GUI extends JFrame {
try {
SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat out = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
- Map<String, String> res = client.getImageData(id, version,SessionData.session.getAuthToken());
+ Map<String, String> res = ThriftManager.getSatClient().getImageData(id, version,SessionData.session.getAuthToken());
labelName.setText(res.get("name"));
labelOS.setText(res.get("os"));
labelUpdate.setText(out.format(in.parse(res.get("lastupdate"))));
diff --git a/dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java b/dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java
index a3119b79..3f2da363 100644
--- a/dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java
+++ b/dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java
@@ -61,9 +61,8 @@ import models.SessionData;
import models.person;
import org.apache.thrift.TException;
-import org.openslx.sat.thrift.iface.Server.Client;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
@SuppressWarnings("serial")
@@ -89,8 +88,6 @@ public class EditLectureSearch_GUI extends JFrame {
String[] titles = { "Veranstaltungsname", "Beschreibung",
"Gültigkeitsdatum", "Aktiv", "Letzte Benutzung",
"Verantwortlicher", "Image", "Schlagwort", "ID" };
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
private static final String HELP_MESSAGE = "<html><div align=\"center\">"
+ "Suchen Sie hier Ihre Veranstaltungen und wählen Sie sie für weitere Schritte aus.<br />"
+ "Klicken Sie anschließend auf \"Weiter\", um die Details der Veranstaltung sowie die Berechtigungen zu ändern."
@@ -105,7 +102,7 @@ public class EditLectureSearch_GUI extends JFrame {
final TableRowSorter<TableModel> rowSorterMyLectures = new TableRowSorter<TableModel>(
modelMyLectures);
- RowFilter rf = null;
+ RowFilter<Object, Object> rf = null;
List<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>(
2);
@@ -123,12 +120,11 @@ public class EditLectureSearch_GUI extends JFrame {
public void windowClosing(WindowEvent arg0) {
// Beendet die Anwendung nach klick auf X
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- con.closeThriftConnection();
System.exit(0);
}
@@ -392,8 +388,6 @@ public class EditLectureSearch_GUI extends JFrame {
JButton btnContinue = new JButton("Weiter");
btnContinue.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- String username = person.verantwortlicher.getName()
- + " " + person.verantwortlicher.getVorname();
// check if a row is selected
if (tablemyLectures.getSelectedRow() != -1) {
@@ -598,14 +592,11 @@ public class EditLectureSearch_GUI extends JFrame {
mntmFaq.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
URI windows;
try {
windows = new URI(Links.getFAQ());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
@@ -619,14 +610,11 @@ public class EditLectureSearch_GUI extends JFrame {
mntmOtrs.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
URI windows;
try {
windows = new URI(Links.getOTRS());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
@@ -670,10 +658,10 @@ public class EditLectureSearch_GUI extends JFrame {
// Hole eine Liste der erlaubten Images für die diese Person
if(person.verantwortlicher.getRole()=="Admin"){
//get complete list
- lectures = client.getLectureList(SessionData.session.getAuthToken());
+ lectures = ThriftManager.getSatClient().getLectureList(SessionData.session.getAuthToken());
} else {
//get permitted list
- lectures = client.getLectureListPermissionWrite(SessionData.session.getAuthToken());
+ lectures = ThriftManager.getSatClient().getLectureListPermissionWrite(SessionData.session.getAuthToken());
}
Iterator<org.openslx.sat.thrift.iface.Lecture> i = lectures.iterator();
@@ -732,7 +720,7 @@ public class EditLectureSearch_GUI extends JFrame {
SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat out = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
- Map<String, String> res = client.getLectureData(id,SessionData.session.getAuthToken());
+ Map<String, String> res = ThriftManager.getSatClient().getLectureData(id,SessionData.session.getAuthToken());
labelName.setText(res.get("name"));
labelAktiv.setText(res.get("isActive"));
labeldesc.setText(res.get("desc"));
@@ -750,7 +738,7 @@ public class EditLectureSearch_GUI extends JFrame {
try {
// get values from server and set them in model
- map = client.getItemOwner(lectureid,SessionData.session.getAuthToken());
+ map = ThriftManager.getSatClient().getItemOwner(lectureid,SessionData.session.getAuthToken());
ItemOwner.itemOwner.setUserID(map.get("userID"));
ItemOwner.itemOwner.setUsername(map.get("loginName"));
diff --git a/dozentenmodul/src/main/java/gui/lecture/PermissionEditLecture_GUI.java b/dozentenmodul/src/main/java/gui/lecture/PermissionEditLecture_GUI.java
index ab53c43d..5eb40b0b 100644
--- a/dozentenmodul/src/main/java/gui/lecture/PermissionEditLecture_GUI.java
+++ b/dozentenmodul/src/main/java/gui/lecture/PermissionEditLecture_GUI.java
@@ -42,7 +42,6 @@ import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
-import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import models.Lecture;
@@ -53,8 +52,8 @@ import models.person;
import org.apache.thrift.TException;
import org.openslx.sat.thrift.iface.Person;
-import org.openslx.sat.thrift.iface.Server.Client;
+import thrift.ThriftManager;
import util.CheckIntegrity;
import util.ListAllOtherUsers_GUI;
import util.OpenLinks;
@@ -62,7 +61,6 @@ import util.OpenLinks;
@SuppressWarnings("serial")
public class PermissionEditLecture_GUI extends JFrame {
- Client client = models.Client.clientcon.getClient();
private final JPanel contentPanel = new JPanel();
String[] result;
private JTable table;
@@ -102,7 +100,7 @@ public class PermissionEditLecture_GUI extends JFrame {
@Override
public void windowClosing(WindowEvent arg0) {
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -229,7 +227,7 @@ public class PermissionEditLecture_GUI extends JFrame {
//System.out.println("Loading data from db");
try {
- map = client.getPermissionForUserAndLecture(
+ map = ThriftManager.getSatClient().getPermissionForUserAndLecture(
SessionData.session.getAuthToken(),Lecture.lecture.getid(),person.verantwortlicher.getUserID()
);
Iterator<Person> i = map.iterator();
@@ -268,9 +266,7 @@ public class PermissionEditLecture_GUI extends JFrame {
.getPermittedUserList();
Iterator<person> i = listt.iterator();
- int x = 0;
while (i.hasNext()) {
- // System.out.println("current pos=" + x);
// erzeuge Objekte fuer die Tabelle
person temp = i.next();
@@ -286,7 +282,6 @@ public class PermissionEditLecture_GUI extends JFrame {
// + temp.isLecture_admin() + ", " + temp.getUserID());
// Fuege diese Objekte der Tabelle hinzu
model.addRow(obj);
- x++;
}
}// end set list of permitted users
@@ -294,7 +289,6 @@ public class PermissionEditLecture_GUI extends JFrame {
// Boolean(false),new Boolean(false),new Boolean(false)};
// model.addRow(rowdata);
- TableCellRenderer rend = table.getTableHeader().getDefaultRenderer();
TableColumn tc1 = table.getColumnModel().getColumn(1);
tc1.setCellEditor(table.getDefaultEditor(Boolean.class));
@@ -503,14 +497,11 @@ public class PermissionEditLecture_GUI extends JFrame {
mntmFaq.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
URI windows;
try {
windows = new URI(Links.getFAQ());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
@@ -524,14 +515,11 @@ public class PermissionEditLecture_GUI extends JFrame {
mntmOtrs.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
URI windows;
try {
windows = new URI(Links.getOTRS());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
@@ -593,8 +581,6 @@ public class PermissionEditLecture_GUI extends JFrame {
// save the entered rights into the model and prepare them to be written to
// the database
private void saveTableToList() {
- //System.out.println("Saving Table to List");
-
List<person> list = new ArrayList<person>();
int seperatorIndex = 0;
@@ -608,22 +594,6 @@ public class PermissionEditLecture_GUI extends JFrame {
seperatorIndex = table.getModel().getValueAt(i, 0).toString()
.indexOf(",");
- //LOGGER.info(table.getModel().getValueAt(i, 4).toString()
- // + " (userID)\t"
- // + Boolean.parseBoolean(table.getModel().getValueAt(i, 3)
- // .toString())
- // + "(admin)\t"
- // + Boolean.parseBoolean(table.getModel().getValueAt(i, 2)
- // .toString())
- // + "(write)\t"
- // + Boolean.parseBoolean(table.getModel().getValueAt(i, 1)
- // .toString())
- // + "(read)\t"
- // + table.getModel().getValueAt(i, 0).toString()
- // .substring(0, seperatorIndex)
- // + "(Nachname)\t"
- // + table.getModel().getValueAt(i, 0).toString()
- // .substring(seperatorIndex + 2) + "(Vorname)");
temp.setUserID(table.getModel().getValueAt(i, 4).toString()); // get
// userID
@@ -651,10 +621,6 @@ public class PermissionEditLecture_GUI extends JFrame {
}
}
- //for (int y = 0; y < list.size(); y++) {
- // System.out.println("" + list.get(y).getName());
- //}
-
RightsManagement.rightsManagement.setPermittedUserList(list);
}// end saveTableToList()
@@ -712,38 +678,3 @@ public class PermissionEditLecture_GUI extends JFrame {
}
}
}
-/*
- * class CheckBoxHeader extends JCheckBox implements TableCellRenderer,
- * MouseListener { protected CheckBoxHeader rendererComponent; protected int
- * column; protected boolean mousePressed = false;
- *
- * public CheckBoxHeader(ItemListener itemListener ,String text) {
- * rendererComponent = this; rendererComponent.addItemListener(itemListener);
- * rendererComponent.setText(text); }
- *
- * public Component getTableCellRendererComponent( JTable table, Object value,
- * boolean isSelected, boolean hasFocus, int row, int column) { if (table !=
- * null) { JTableHeader header = table.getTableHeader(); if (header != null) {
- * rendererComponent.setForeground(header.getForeground());
- * rendererComponent.setBackground(header.getBackground());
- * rendererComponent.setFont(header.getFont());
- * rendererComponent.setBorder(header.getBorder());
- * header.addMouseListener(rendererComponent); } } setColumn(column);
- * //rendererComponent.setText("Check All");
- * //setBorder(UIManager.getBorder("TableHeader.cellBorder"));
- *
- * return rendererComponent; } protected void setColumn(int column) {
- * this.column = column; } public int getColumn() { return column; } protected
- * void handleClickEvent(MouseEvent e) { if (mousePressed) { mousePressed=false;
- * JTableHeader header = (JTableHeader)(e.getSource()); JTable tableView =
- * header.getTable(); TableColumnModel columnModel = tableView.getColumnModel();
- * int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column =
- * tableView.convertColumnIndexToModel(viewColumn);
- *
- * if (viewColumn == this.column && e.getClickCount() == 1 && column != -1) {
- * doClick(); } } } public void mouseClicked(MouseEvent e) {
- * handleClickEvent(e); ((JTableHeader)e.getSource()).repaint(); } public void
- * mousePressed(MouseEvent e) { mousePressed = true; } public void
- * mouseReleased(MouseEvent e) { } public void mouseEntered(MouseEvent e) { }
- * public void mouseExited(MouseEvent e) { } }
- */
diff --git a/dozentenmodul/src/main/java/gui/lecture/SearchLecture_GUI.java b/dozentenmodul/src/main/java/gui/lecture/SearchLecture_GUI.java
index bd387fab..fbb24849 100644
--- a/dozentenmodul/src/main/java/gui/lecture/SearchLecture_GUI.java
+++ b/dozentenmodul/src/main/java/gui/lecture/SearchLecture_GUI.java
@@ -60,9 +60,8 @@ import models.person;
import org.apache.thrift.TException;
import org.openslx.sat.thrift.iface.Lecture;
-import org.openslx.sat.thrift.iface.Server.Client;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
import util.OpenLinks;
@SuppressWarnings("serial")
@@ -89,8 +88,6 @@ public class SearchLecture_GUI extends JFrame {
String[] titles = { "Veranstaltungsname", "Beschreibung",
"Gültigkeitsdatum", "Aktiv", "Letzte Benutzung",
"Verantwortlicher", "Image", "Schlagwort", "ID" };
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
final DefaultTableModel modelAll = new DefaultTableModel(titles, 0){
public boolean isCellEditable(int rowIndex, int mColIndex) {
@@ -127,9 +124,8 @@ public class SearchLecture_GUI extends JFrame {
@Override
public void windowClosing(WindowEvent arg0) {
// Beendet die Anwendung nach klick auf X
- con.closeThriftConnection();
try {
- client.setSessionInvalid(SessionData.session.getAuthToken());
+ ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -628,10 +624,10 @@ public class SearchLecture_GUI extends JFrame {
// Hole eine Liste der erlaubten Images für die diese Person
if(person.verantwortlicher.getRole()=="Admin"){
//get complete list
- lectures = client.getLectureList(SessionData.session.getAuthToken());
+ lectures = ThriftManager.getSatClient().getLectureList(SessionData.session.getAuthToken());
} else {
//get permitted list
- lectures = client.getLectureListPermissionRead(SessionData.session.getAuthToken());
+ lectures = ThriftManager.getSatClient().getLectureListPermissionRead(SessionData.session.getAuthToken());
}
Iterator<Lecture> i = lectures.iterator();
@@ -671,8 +667,8 @@ public class SearchLecture_GUI extends JFrame {
List<Lecture> lectures;
try {
// Hole eine Liste der erlaubten Images für die diese Person
- //lectures = client.getLectureList();
- lectures = client.getLectureList(SessionData.session.getAuthToken());
+ //lectures = ThriftManager.getSatClient().getLectureList();
+ lectures = ThriftManager.getSatClient().getLectureList(SessionData.session.getAuthToken());
Iterator<Lecture> i = lectures.iterator();
SimpleDateFormat in=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat out=new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
@@ -725,7 +721,7 @@ public class SearchLecture_GUI extends JFrame {
SimpleDateFormat in=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat out=new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
- Map<String,String> res=client.getLectureData(id,SessionData.session.getAuthToken());
+ Map<String,String> res=ThriftManager.getSatClient().getLectureData(id,SessionData.session.getAuthToken());
labelName.setText(res.get("name"));
labelAktiv.setText(res.get("isActive"));
labeldesc.setText(res.get("desc"));
diff --git a/dozentenmodul/src/main/java/thrift/MasterThriftConnection.java b/dozentenmodul/src/main/java/thrift/MasterThriftConnection.java
deleted file mode 100644
index 686d0944..00000000
--- a/dozentenmodul/src/main/java/thrift/MasterThriftConnection.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package thrift;
-
-import org.apache.log4j.Logger;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.transport.TFramedTransport;
-import org.apache.thrift.transport.TSocket;
-import org.apache.thrift.transport.TTransport;
-import org.apache.thrift.transport.TTransportException;
-import org.openslx.imagemaster.thrift.iface.ImageServer.Client;
-
-public class MasterThriftConnection {
-
- private final static Logger LOGGER = Logger.getLogger(MasterThriftConnection.class);
-
- public static final String MASTERSERVER_IP = "132.230.4.16";
- public static final int MASTERSERVER_PORT = 9090;
- public static final int MASTERSERVER_TIMEOUT_MS = 30000;
-
- final TTransport transport = new TFramedTransport(new TSocket(
- MASTERSERVER_IP, MASTERSERVER_PORT, MASTERSERVER_TIMEOUT_MS));
-
- public Client getMasterThriftConnection() {
-
- try {
- transport.open();
- } catch (TTransportException e) {
- LOGGER.error("Keine Verbindung möglich!");
- return null;
- }
-
- final TProtocol protocol = new TBinaryProtocol(transport);
- final Client client = new Client(protocol);
- LOGGER.info("Masterserver '" + MASTERSERVER_IP + "' erreichbar.");
-
- return client;
- }
-
- public void closeMasterThriftConnection() {
- transport.close();
- }
-}
diff --git a/dozentenmodul/src/main/java/thrift/ThriftConnection.java b/dozentenmodul/src/main/java/thrift/ThriftConnection.java
deleted file mode 100644
index a026ef03..00000000
--- a/dozentenmodul/src/main/java/thrift/ThriftConnection.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package thrift;
-
-import javax.swing.JOptionPane;
-
-import models.SessionData;
-
-import org.apache.log4j.Logger;
-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.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, 10000);
-
- public Client getThriftConnection() {
-
- try {
- transport.open();
- } 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);
- return null;
- }
-
- final TProtocol protocol = new TBinaryProtocol(transport);
- final Server.Client client = new Server.Client(protocol);
- 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() {
- LOGGER.info("Verbindung wird geplant getrennt.");
- transport.close();
- }
-}
diff --git a/dozentenmodul/src/main/java/thrift/ThriftManager.java b/dozentenmodul/src/main/java/thrift/ThriftManager.java
new file mode 100644
index 00000000..716c4439
--- /dev/null
+++ b/dozentenmodul/src/main/java/thrift/ThriftManager.java
@@ -0,0 +1,155 @@
+package thrift;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TFramedTransport;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+import org.openslx.imagemaster.thrift.iface.ImageServer;
+import org.openslx.sat.thrift.iface.Server;
+
+public class ThriftManager {
+
+ private final static Logger LOGGER = Logger.getLogger(ThriftManager.class);
+
+ /**
+ * Public variables to represent client types
+ * TODO: Public needed?
+ */
+ public static enum ClientType {
+ MASTER, SATELLITE
+ }
+ /**
+ * Private singleton instances of itself and the satellite/master clients
+ */
+ private static ThreadLocal<ThriftManager> _instance = null;
+ private static ThreadLocal<Server.Client> _satClient = new ThreadLocal<>();
+ private static ThreadLocal<ImageServer.Client> _masterClient = new ThreadLocal<>();
+
+ /**
+ * Private members for master connection information
+ */
+ private static final String MASTERSERVER_IP = "132.230.4.16";
+ private static final int MASTERSERVER_PORT = 9090;
+ private static final int MASTERSERVER_TIMEOUT = 30000;
+
+
+ /**
+ * Private members for satellite connection information
+ */
+ private static String SATELLITE_IP = null;
+ private static final int SATELLITE_PORT = 9090;
+ private static final int SATELLITE_TIMEOUT = 10000;
+
+ /**
+ * Protected constructor to avoid external instantiation
+ */
+ protected ThriftManager() {
+ if (_instance.get() == null) {
+ _instance.set(new ThriftManager());
+ }
+ if (_instance.get() == null) {
+ // something very wrong...
+ LOGGER.error("Could not initialize Thrift Manager, this should not happen. Contact a developper.");
+ // TODO handle: exit? message box?
+ }
+ }
+
+ /**
+ * Initialise the client of type 'type' with give ip, port and timeout.
+ *
+ * @param type type of the client. Valid are 'MASTER' or 'SATELLITE'
+ * @param ip ip of the server to connect to
+ * @param port port of the server to connect to
+ * @param timeout timeout of the connection in milliseconds
+ * @return true if initializing the client worked, false otherwise
+ */
+ private static boolean init(ClientType type, String ip, int port, int timeout) {
+
+ /*
+ * Master Connection
+ */
+ if (type == ClientType.MASTER) {
+ TTransport transport =
+ new TFramedTransport(new TSocket(MASTERSERVER_IP, MASTERSERVER_PORT, MASTERSERVER_TIMEOUT));
+ try {
+ transport.open();
+ } catch (TTransportException e) {
+ LOGGER.error("Could not open transport to thrift's server with IP: " + MASTERSERVER_IP);
+ return false;
+ }
+ final TProtocol protocol = new TBinaryProtocol(transport);
+ // now we are ready to create the client, according to ClientType!
+ _masterClient.set(new ImageServer.Client(protocol));
+ LOGGER.info("Masterserver '" + MASTERSERVER_IP + "' reachable. Client initialised.");
+ }
+ /*
+ * Satellite Connection
+ */
+ if (type == ClientType.SATELLITE) {
+ // first check if we have a sat ip
+ if (SATELLITE_IP == null) {
+ LOGGER.error("Satellite ip adress was not set prior to getting the sat client. Use setSatellite(<ip>).");
+ return false;
+ }
+ // ok lets do it
+ TTransport transport =
+ new TSocket(SATELLITE_IP, SATELLITE_PORT, SATELLITE_TIMEOUT);
+ try {
+ transport.open();
+ } catch (TTransportException e) {
+ LOGGER.error("Could not open transport to thrift's server with IP: " + SATELLITE_IP);
+ return false;
+ }
+ final TProtocol protocol = new TBinaryProtocol(transport);
+ // now we are ready to create the client, according to ClientType!
+ _satClient.set(new Server.Client(protocol));
+ }
+ return true;
+ }
+ /**
+ * Sets the IP of the satellite to connect to
+ * @param ip the ip of the satellite as String
+ * @return true if setting the ip worked, false otherwise
+ */
+ public static boolean setSatellite(String ip) {
+ if (ip.isEmpty()) {
+ LOGGER.error("Given IP for satellite is empty.");
+ return false;
+ }
+ SATELLITE_IP = ip;
+ return true;
+ }
+ /**
+ * Returns the singleton client of the thrift connection to the satellite
+ * @return the thrift client to the satellite server
+ */
+ public static Server.Client getSatClient() {
+ if (_satClient.get() == null) {
+ init(ClientType.SATELLITE, SATELLITE_IP, SATELLITE_PORT, SATELLITE_TIMEOUT);
+ }
+ if (_satClient.get() == null) {
+ LOGGER.error("Satelite client still null. Initialisation must have failed. Contact developper.");
+ return null;
+ }
+ return _satClient.get();
+ }
+
+ /**
+ * Returns the singleton client of the master thrift connection
+ * @return the thrift client to the master server
+ */
+ public static ImageServer.Client getMasterClient() {
+ if (_masterClient.get() == null) {
+ LOGGER.debug("Initialising master thrift client...");
+ init(ClientType.MASTER, MASTERSERVER_IP, MASTERSERVER_PORT, MASTERSERVER_TIMEOUT);
+ }
+ if (_masterClient.get() == null) {
+ LOGGER.error("Satellite client still null. Initialisation must have failed. Contact developper.");
+ return null;
+ }
+ return _masterClient.get();
+ }
+}
diff --git a/dozentenmodul/src/main/java/util/ListAllOtherUsers_GUI.java b/dozentenmodul/src/main/java/util/ListAllOtherUsers_GUI.java
index e09f0b08..56adaf4f 100644
--- a/dozentenmodul/src/main/java/util/ListAllOtherUsers_GUI.java
+++ b/dozentenmodul/src/main/java/util/ListAllOtherUsers_GUI.java
@@ -30,7 +30,6 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTable;
-import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
@@ -46,9 +45,8 @@ import models.person;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import org.openslx.sat.thrift.iface.Person;
-import org.openslx.sat.thrift.iface.Server.Client;
-import thrift.ThriftConnection;
+import thrift.ThriftManager;
@SuppressWarnings("serial")
public class ListAllOtherUsers_GUI extends JFrame {
@@ -62,14 +60,9 @@ public class ListAllOtherUsers_GUI extends JFrame {
boolean activeSearch = false;
String[] titles = { "userID", "Nachname", "Vorname", "Mail" };
-
- ThriftConnection con = new ThriftConnection();
- Client client = models.Client.clientcon.getClient();
- //final DefaultTableModel modelUsers = new DefaultTableModel(titles, 0);
private JButton btnAdd;
private List<Person> map = null; // List of people
- private JTextField textField;
Component c = null;
private JTable table;
private int userIDPos;
@@ -111,7 +104,6 @@ public class ListAllOtherUsers_GUI extends JFrame {
@Override
public void windowClosing(WindowEvent arg0) {
// Beendet die Anwendung nach klick auf X
- con.closeThriftConnection();
dispose();
}
@@ -290,12 +282,10 @@ public class ListAllOtherUsers_GUI extends JFrame {
@Override
public void mousePressed(MouseEvent arg0) {
- OpenLinks open = new OpenLinks();
-
URI windows;
try {
windows = new URI(Links.getFAQ());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
e.printStackTrace();
@@ -309,11 +299,10 @@ public class ListAllOtherUsers_GUI extends JFrame {
@Override
public void mousePressed(MouseEvent arg0) {
- OpenLinks open = new OpenLinks();
URI windows;
try {
windows = new URI(Links.getOTRS());
- open.openWebpage(windows);
+ OpenLinks.openWebpage(windows);
} catch (URISyntaxException e) {
e.printStackTrace();
}
@@ -362,7 +351,7 @@ public class ListAllOtherUsers_GUI extends JFrame {
}
//get the info
- map = client.getAllOtherSatelliteUsers(user,SessionData.session.getAuthToken());
+ map = ThriftManager.getSatClient().getAllOtherSatelliteUsers(user,SessionData.session.getAuthToken());
Iterator<Person> i = map.iterator();
int x = 0;
diff --git a/dozentenmodul/src/main/java/util/ServiceProviderResponse.java b/dozentenmodul/src/main/java/util/ServiceProviderResponse.java
index 62819ded..99f120f1 100644
--- a/dozentenmodul/src/main/java/util/ServiceProviderResponse.java
+++ b/dozentenmodul/src/main/java/util/ServiceProviderResponse.java
@@ -1,14 +1,7 @@
package util;
public class ServiceProviderResponse {
- private String status;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String sTATUS) {
- status = sTATUS;
- }
-
+ public String status;
+ public String id;
+ public String url;
}
diff --git a/dozentenmodul/src/main/java/util/ShibbolethECP.java b/dozentenmodul/src/main/java/util/ShibbolethECP.java
index 3dea9e3e..b834b1a2 100644
--- a/dozentenmodul/src/main/java/util/ShibbolethECP.java
+++ b/dozentenmodul/src/main/java/util/ShibbolethECP.java
@@ -1,8 +1,10 @@
package util;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import org.apache.http.HttpResponse;
import org.apache.http.ParseException;
@@ -31,13 +33,19 @@ public class ShibbolethECP {
private static final Gson GSON = new GsonBuilder().create();
/**
+ * URL for bwLehrpool registration
+ */
+ private static URL _registrationUrl = null;
+ /**
* Return codes
*/
public static enum ReturnCode {
NO_ERROR(0, "Authentication against the identity provider and request of the service provider resource worked."),
ERROR_IDP(1, "Authentication against the identity provider failed."),
- ERROR_SP(2, "Invalid resource of the service provider."),
- ERROR_OTHER(3, "Internal class error.");
+ ERROR_UNREG(2, "User not registered to use bwLehrpool"),
+ ERROR_SP(3, "Invalid resource of the service provider."),
+ ERROR_URL(4, "Invalid URL received from master server."),
+ ERROR_OTHER(5, "Internal class error.");
private final int id;
private final String msg;
@@ -63,7 +71,7 @@ public class ShibbolethECP {
static {
URI tmp;
try {
- tmp = new URI("https://bwlp-masterserver.ruf.uni-freiburg.de/secure-all/test.php");
+ tmp = new URI("https://bwlp-masterserver.ruf.uni-freiburg.de/secure-all/api.php");
} catch (URISyntaxException e) {
// should never happen!
LOGGER.error("Bad URI syntax of the service provider, see trace: ", e);
@@ -148,9 +156,23 @@ public class ShibbolethECP {
LOGGER.error("Bad JSON syntax, see trace: ", e);
return ReturnCode.ERROR_SP;
}
- LOGGER.debug("SP JSON STATUS: " + spr.getStatus());
// TODO: here we will need to parse the answer accordingly.
// no errors, meaning everything worked fine.
- return spr.getStatus().equals("funzt") ? ReturnCode.NO_ERROR : ReturnCode.ERROR_SP;
+ if (spr.status.equals("unregistered")) {
+ try {
+ _registrationUrl = new URL(spr.url);
+ } catch (MalformedURLException e) {
+ LOGGER.error("URL returned by masterserver is malformed, see trace: " + e);
+ return ReturnCode.ERROR_URL;
+ }
+ return ReturnCode.ERROR_UNREG;
+ }
+ // TODO the rest of the cases...
+
+ // still here? then something else went wrong
+ return ReturnCode.ERROR_OTHER;
+ }
+ public static URL getRegistrationUrl() {
+ return _registrationUrl;
}
}