diff options
| author | Michael Wilson | 2014-10-07 14:01:52 +0200 |
|---|---|---|
| committer | Michael Wilson | 2014-10-07 14:01:52 +0200 |
| commit | af03c88129755f57fff3389bb35c5840c0e9751f (patch) | |
| tree | 238181e97734aea2ad8df4f7c6c5ca88e203bbd3 | |
| parent | -Volltextsuche vorbereitet, Funktion wird noch angepasst (diff) | |
| download | tutor-module-af03c88129755f57fff3389bb35c5840c0e9751f.tar.gz tutor-module-af03c88129755f57fff3389bb35c5840c0e9751f.tar.xz tutor-module-af03c88129755f57fff3389bb35c5840c0e9751f.zip | |
-Verwaltung von Rechten ist nun in der PermissionCreateImage_GUI.java möglich
12 files changed, 1805 insertions, 87 deletions
diff --git a/dozentenmodul/src/main/java/gui/image/PermissionCreateImage_GUI.java b/dozentenmodul/src/main/java/gui/image/PermissionCreateImage_GUI.java index d6ddc911..deddedda 100644 --- a/dozentenmodul/src/main/java/gui/image/PermissionCreateImage_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/PermissionCreateImage_GUI.java @@ -1,9 +1,9 @@ package gui.image; import gui.intro.About_GUI; +import gui.intro.Login_GUI; import gui.intro.MainMenue_GUI; -import java.awt.Checkbox; import java.awt.Color; import java.awt.Component; import java.awt.FlowLayout; @@ -18,14 +18,14 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import javax.swing.AbstractButton; -import javax.swing.ButtonGroup; import javax.swing.DefaultComboBoxModel; -import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -35,41 +35,48 @@ import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; 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.ScrollPaneConstants; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; -import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import javax.swing.table.JTableHeader; -import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import models.Image; +import models.ImageRights; import models.Links; -import util.GuiOrganizer; -import util.OpenLinks; -import javax.swing.JTable; -import javax.swing.JScrollPane; -import javax.swing.ScrollPaneConstants; -import javax.swing.JTextField; +import models.RightsManagement; -import org.eclipse.jface.viewers.CheckboxCellEditor; +import org.apache.log4j.Logger; +import org.apache.thrift.TException; -import java.awt.Choice; +import server.generated.Server.Client; +import server.generated.Person; +import models.person; +import util.GuiOrganizer; +import util.OpenLinks; @SuppressWarnings("serial") public class PermissionCreateImage_GUI extends JFrame { + private final static Logger LOGGER = Logger.getLogger(Login_GUI.class); + Client client = models.Client.clientcon.getClient(); private final JPanel contentPanel = new JPanel(); String[] result; - private JTable table; + private JTable table = null; private Class[] classes; - Object[] titles = { "Name", "Read", "Write", "Link","Admin"}; + Object[] titles = { "Name", "Read", "Write", "Link", "Admin", "userID" }; + private List<Person> map = null; + // Map<String,String> ogUsers = new HashMap(); final DefaultTableModel model = new DefaultTableModel(titles, 0) { @@ -90,6 +97,7 @@ public class PermissionCreateImage_GUI extends JFrame { } }; + private JTextField textField; private JLabel lblRead; private JLabel lblWrite; @@ -169,10 +177,81 @@ public class PermissionCreateImage_GUI extends JFrame { table = new JTable(); table.setModel(model); table.setSelectionForeground(Color.WHITE); - Object[] rowdata = { "Max Mustermann", new Boolean(false), - new Boolean(false), new Boolean(false), new Boolean(false), - new Boolean(false) }; - model.addRow(rowdata); + + // invisible attribute userID for identifying selected user + table.getColumnModel().getColumn(5).setWidth(0); + table.getColumnModel().getColumn(5).setMinWidth(0); + table.getColumnModel().getColumn(5).setMaxWidth(0); + + // if new session, get values for table from database + if (RightsManagement.rightsManagement.getPmImageCreateList().size() <= 0) { + System.out.println("getting data from db"); + System.out.println(RightsManagement.rightsManagement + .getPmImageCreateList().size()); + try { + map = client.getAllOGUsers(); + Iterator<server.generated.Person> i = map.iterator(); + + int x = 0; + while (i.hasNext()) { + // erzeuge Objekte fuer die Tabelle + Object[] obj = { + map.get(x).getNachname() + ", " + + map.get(x).getVorname(), // Name + false, // Read + false, // Write + false, // Link + false, // Admin + map.get(x).getUserID() // userID + }; + // Fuege diese Objekte der Tabelle hinzu + model.addRow(obj); + i.next(); + x++; + + } + System.out + .println("Number of returned users in permission list: " + + map.size()); + + } catch (TException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else // read from model + { + System.out + .println("RightsManagement.rightsManagement.getPmImageCreateList().size() " + + RightsManagement.rightsManagement + .getPmImageCreateList().size()); + System.out.println("reading from model"); + List<person> listt = RightsManagement.rightsManagement + .getPmImageCreateList(); + 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(); + + Object[] obj = { temp.getName() + ", " + temp.getVorname(), // Name + temp.isRead(), // Read + temp.isWrite(), // Write + temp.isLinkAllowed(), // Link + temp.isAdmin(), // Admin + temp.getUserID() // userID + }; + System.out.println("Processing: " + temp.getName() + ", " + + temp.getVorname() + ", " + temp.isRead() + ", " + + temp.isWrite() + ", " + temp.isLinkAllowed() + ", " + + temp.isAdmin() + ", " + temp.getUserID()); + // Fuege diese Objekte der Tabelle hinzu + model.addRow(obj); + x++; + + } + } TableCellRenderer rend = table.getTableHeader().getDefaultRenderer(); @@ -200,35 +279,30 @@ public class PermissionCreateImage_GUI extends JFrame { tc4.setHeaderRenderer(new CheckBoxHeader(new MyItemListener4(), (String) titles[4])); - /* - TableColumn tc5 = table.getColumnModel().getColumn(5); - tc5.setCellEditor(table.getDefaultEditor(Boolean.class)); - tc5.setCellRenderer(table.getDefaultRenderer(Boolean.class)); - tc5.setHeaderRenderer(new CheckBoxHeader(new MyItemListener5(), - (String) titles[5])); - */ + scrollPane.setViewportView(table); - + JPanel panel = new JPanel(); panel.setLayout(null); panel.setBorder(new TitledBorder(null, "Freigabe", - TitledBorder.LEADING, TitledBorder.TOP, null, null)); + TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel.setBackground(SystemColor.menu); panel.setBounds(10, 201, 537, 80); panel_1.add(panel); - + JLabel label = new JLabel("Freigabemodus:"); label.setBounds(10, 30, 250, 20); panel.add(label); - + final JComboBox comboBox_1 = new JComboBox(); - comboBox_1.setModel(new DefaultComboBoxModel(new String[] { - "Lokal (Eigene Hochschule)", - "Öffentlich (Alle Hochschulen)" })); + comboBox_1 + .setModel(new DefaultComboBoxModel(new String[] { + "Lokal (Eigene Hochschule)", + "Öffentlich (Alle Hochschulen)" })); comboBox_1.setSelectedIndex(0); comboBox_1.setBounds(270, 30, 250, 20); panel.add(comboBox_1); - + JLabel lblHauptmen = new JLabel("Hauptmenü"); lblHauptmen.addMouseListener(new MouseAdapter() { @Override @@ -260,7 +334,7 @@ public class PermissionCreateImage_GUI extends JFrame { lblNewLabel_1.setBounds(146, 11, 80, 14); contentPanel.add(lblNewLabel_1); - JLabel lblName = new JLabel("Name:"); + JLabel lblName = new JLabel("Nach Namen filtern:"); lblName.setBounds(10, 36, 46, 20); contentPanel.add(lblName); @@ -323,11 +397,11 @@ public class PermissionCreateImage_GUI extends JFrame { "Erzeugung einer Veranstaltung auf ein Image ist erlaubt."); lblLinkallowedDesc.setBounds(120, 58, 380, 20); panel_2.add(lblLinkallowedDesc); - + chckbxFrAlleSichtbar = new JCheckBox(""); chckbxFrAlleSichtbar.setBounds(115, 119, 21, 23); panel_2.add(chckbxFrAlleSichtbar); - + lblFuerAlleSichtbar = new JLabel("Für alle sichtbar"); lblFuerAlleSichtbar.setBounds(20, 120, 90, 20); panel_2.add(lblFuerAlleSichtbar); @@ -342,7 +416,7 @@ public class PermissionCreateImage_GUI extends JFrame { cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - //CreateImageFreigabe_GUI sr = new CreateImageFreigabe_GUI(); + CreateImageTechnisch_GUI ci = new CreateImageTechnisch_GUI(); ci.setVisible(true); dispose(); @@ -357,6 +431,8 @@ public class PermissionCreateImage_GUI extends JFrame { continueButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { + saveTableToList(); + Image.image.setShareMode(comboBox_1.getSelectedIndex()); FTPCreateUploader_GUI ea = new FTPCreateUploader_GUI(); ea.setVisible(true); @@ -497,6 +573,61 @@ public class PermissionCreateImage_GUI extends JFrame { } } } + + public void createRightsList() { + // ///// + } + + private void saveTableToList() { + System.out.println("Saving Table to List"); + + List<person> list = new ArrayList<person>(); + + int seperatorIndex = 0; + + // get values from table and save the checkbox values + if(map==null) System.out.println("Fuck: map is null"); + + //for (int i = 0; i < map.size(); i++) { + for (int i = 0; i < table.getRowCount(); i++) { + System.out.println("in for, rowcount="+table.getRowCount()); + person temp = new person(); + + // table.getModel().setValueAt(map.get, i, 5); + + temp.setUserID(table.getModel().getValueAt(i, 5).toString()); // get + // userID + temp.setAdmin(Boolean.parseBoolean(table.getModel() + .getValueAt(i, 4).toString())); // get Admin + temp.setLinkAllowed(Boolean.parseBoolean(table.getModel() + .getValueAt(i, 3).toString()));// get Link + temp.setWrite(Boolean.parseBoolean(table.getModel() + .getValueAt(i, 2).toString()));// get Write + temp.setRead(Boolean.parseBoolean(table.getModel().getValueAt(i, 1) + .toString()));// get Read + seperatorIndex = table.getModel().getValueAt(i, 0).toString() + .indexOf(","); + temp.setName(table.getModel().getValueAt(i, 0).toString() + .substring(0, seperatorIndex)); + temp.setVorname(table.getModel().getValueAt(i, 0).toString() + .substring(seperatorIndex + 2)); + + list.add(temp); + + System.out.println(temp.getName() + ", " + temp.getVorname() + ", " + + temp.getUserID() + ", " + temp.isAdmin() + ", " + + temp.isLinkAllowed() + ", " + temp.isWrite() + ", " + + temp.isRead()); + } + System.out.println("Now setting List information. Length is: " + + list.size()); + for (int y = 0; y < list.size(); y++) { + System.out.println("" + list.get(y).getName()); + } + RightsManagement.rightsManagement.setPmImageCreateList(list); + + } + } class CheckBoxHeader extends JCheckBox implements TableCellRenderer, @@ -524,8 +655,7 @@ class CheckBoxHeader extends JCheckBox implements TableCellRenderer, } } setColumn(column); - // rendererComponent.setText("Check All"); - // setBorder(UIManager.getBorder("TableHeader.cellBorder")); + return rendererComponent; } @@ -571,4 +701,5 @@ class CheckBoxHeader extends JCheckBox implements TableCellRenderer, public void mouseExited(MouseEvent e) { } + } diff --git a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java index a20daa55..8c076dc7 100644 --- a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java +++ b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java @@ -181,6 +181,7 @@ public class Login_GUI extends JFrame { 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); @@ -249,7 +250,7 @@ public class Login_GUI extends JFrame { person.verantwortlicher.setHochschule(hochschule); // Spaeter ueber result.getRole zum Beispiel die Rolle holen - person.verantwortlicher.setRole("Dozent"); + person.verantwortlicher.setRole("Dozent"); // person.verantwortlicher.setRole("Admin"); // person.verantwortlicher.setRole("Student"); // person.verantwortlicher.setRole("GetToTheChopper!"); diff --git a/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java b/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java index 21b5dcda..bdfd841a 100644 --- a/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java +++ b/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java @@ -42,6 +42,7 @@ import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; +import models.GUIRights; import models.ImageRights; import models.Links; import models.SessionData; @@ -543,39 +544,39 @@ public class MainMenue_GUI extends JFrame { // role==Student if (person.verantwortlicher.getRole().equals("Student")) { - ImageRights.rights.setRead(1); - ImageRights.rights.setWrite(0); - ImageRights.rights.setChangePermission(0); - ImageRights.rights.setAdmin(0); - ImageRights.rights.setLinkAllowed(0); + GUIRights.rights.setRead(1); + GUIRights.rights.setWrite(0); + GUIRights.rights.setChangePermission(0); + GUIRights.rights.setAdmin(0); + GUIRights.rights.setLinkAllowed(0); } else if (person.verantwortlicher.getRole().equals("Dozent")) { // role==Dozent - ImageRights.rights.setRead(1); - ImageRights.rights.setWrite(1); - ImageRights.rights.setChangePermission(0); - ImageRights.rights.setAdmin(0); - ImageRights.rights.setLinkAllowed(1); + GUIRights.rights.setRead(1); + GUIRights.rights.setWrite(1); + GUIRights.rights.setChangePermission(0); + GUIRights.rights.setAdmin(0); + GUIRights.rights.setLinkAllowed(1); } else if (person.verantwortlicher.getRole().equals("Admin")) { // role==Admin - ImageRights.rights.setRead(1); - ImageRights.rights.setWrite(1); - ImageRights.rights.setChangePermission(1); - ImageRights.rights.setAdmin(1); - ImageRights.rights.setLinkAllowed(1); + GUIRights.rights.setRead(1); + GUIRights.rights.setWrite(1); + GUIRights.rights.setChangePermission(1); + GUIRights.rights.setAdmin(1); + GUIRights.rights.setLinkAllowed(1); } else { // role==Nothing - ImageRights.rights.setRead(0); - ImageRights.rights.setWrite(0); - ImageRights.rights.setChangePermission(0); - ImageRights.rights.setAdmin(0); - ImageRights.rights.setLinkAllowed(0); + GUIRights.rights.setRead(0); + GUIRights.rights.setWrite(0); + GUIRights.rights.setChangePermission(0); + GUIRights.rights.setAdmin(0); + GUIRights.rights.setLinkAllowed(0); }// end if else // always print rights information LOGGER.info("Rights: (r, w, cp, a, la) = (" - + ImageRights.rights.getRead() + ", " - + ImageRights.rights.getWrite() + ", " - + ImageRights.rights.getChangePermission() + ", " - + ImageRights.rights.getAdmin() + ", " - + ImageRights.rights.getLinkAllowed() + ")"); + + GUIRights.rights.getRead() + ", " + + GUIRights.rights.getWrite() + ", " + + GUIRights.rights.getChangePermission() + ", " + + GUIRights.rights.getAdmin() + ", " + + GUIRights.rights.getLinkAllowed() + ")"); }// end setRoleRights public void setCorrectRadioButton() { diff --git a/dozentenmodul/src/main/java/models/GUIRights.java b/dozentenmodul/src/main/java/models/GUIRights.java new file mode 100644 index 00000000..a1937b78 --- /dev/null +++ b/dozentenmodul/src/main/java/models/GUIRights.java @@ -0,0 +1,62 @@ +package models; + +public class GUIRights { + + private int read; + private int write; + private int changePermission; + private int admin; + private int linkAllowed; + private String userID; + + public String getUserID() { + return userID; + } + + public void setUserID(String userID) { + this.userID = userID; + } + + public static GUIRights rights = new GUIRights(); + + public int getRead() { + return read; + } + + public void setRead(int read) { + this.read = read; + } + + public int getWrite() { + return write; + } + + public void setWrite(int write) { + this.write = write; + } + + public int getChangePermission() { + return changePermission; + } + + public void setChangePermission(int changePermission) { + this.changePermission = changePermission; + } + + public int getAdmin() { + return admin; + } + + public void setAdmin(int admin) { + this.admin = admin; + } + + public int getLinkAllowed() { + return linkAllowed; + } + + public void setLinkAllowed(int linkAllowed) { + this.linkAllowed = linkAllowed; + } + +} diff --git a/dozentenmodul/src/main/java/models/ImageRights.java b/dozentenmodul/src/main/java/models/ImageRights.java index 1b7e0e55..c5b5efbb 100644 --- a/dozentenmodul/src/main/java/models/ImageRights.java +++ b/dozentenmodul/src/main/java/models/ImageRights.java @@ -2,41 +2,48 @@ package models; public class ImageRights { - private int read; - private int write; - private int changePermission; - private int admin; - private int linkAllowed; + private boolean read; + private boolean write; + private boolean changePermission; + private boolean admin; + private boolean linkAllowed; + private String userID; + public String getUserID() { + return userID; + } + public void setUserID(String userID) { + this.userID = userID; + } public static ImageRights rights =new ImageRights(); - public int getRead() { + public boolean getRead() { return read; } - public void setRead(int read) { + public void setRead(boolean read) { this.read = read; } - public int getWrite() { + public boolean getWrite() { return write; } - public void setWrite(int write) { + public void setWrite(boolean write) { this.write = write; } - public int getChangePermission() { + public boolean getChangePermission() { return changePermission; } - public void setChangePermission(int changePermission) { + public void setChangePermission(boolean changePermission) { this.changePermission = changePermission; } - public int getAdmin() { + public boolean getAdmin() { return admin; } - public void setAdmin(int admin) { + public void setAdmin(boolean admin) { this.admin = admin; } - public int getLinkAllowed() { + public boolean getLinkAllowed() { return linkAllowed; } - public void setLinkAllowed(int linkAllowed) { + public void setLinkAllowed(boolean linkAllowed) { this.linkAllowed = linkAllowed; } diff --git a/dozentenmodul/src/main/java/models/RightsManagement.java b/dozentenmodul/src/main/java/models/RightsManagement.java new file mode 100644 index 00000000..38661870 --- /dev/null +++ b/dozentenmodul/src/main/java/models/RightsManagement.java @@ -0,0 +1,31 @@ +package models; + +import java.util.ArrayList; +import java.util.List; + +public class RightsManagement { + + + public RightsManagement(){ + // + } + + + + //list which holds all users and (non-)selected values of the table rightstable in permissionCreateImage + private List<person> pmImageCreateList = new ArrayList<person>(); + + + + + public static RightsManagement rightsManagement = new RightsManagement(); + + public List<person> getPmImageCreateList() { + return pmImageCreateList; + } + + public void setPmImageCreateList(List<person> list) { + this.pmImageCreateList = list; + } + +} diff --git a/dozentenmodul/src/main/java/models/person.java b/dozentenmodul/src/main/java/models/person.java index 479c2ecd..b1a44288 100644 --- a/dozentenmodul/src/main/java/models/person.java +++ b/dozentenmodul/src/main/java/models/person.java @@ -1,6 +1,6 @@ package models; -public class person{ +public class person { private String username; @@ -17,12 +17,65 @@ public class person{ private String Fakultaet; private boolean ischecked; - + private String role; - public static person verantwortlicher=new person(); + private boolean read; + private boolean write; + private boolean changePermission; + private boolean admin; + private boolean linkAllowed; + private String userID; + + public boolean isRead() { + return read; + } + + public void setRead(boolean read) { + this.read = read; + } + + public boolean isWrite() { + return write; + } + + public void setWrite(boolean write) { + this.write = write; + } + + public boolean isChangePermission() { + return changePermission; + } + + public void setChangePermission(boolean changePermission) { + this.changePermission = changePermission; + } + + public boolean isAdmin() { + return admin; + } + + public void setAdmin(boolean admin) { + this.admin = admin; + } + + public boolean isLinkAllowed() { + return linkAllowed; + } + + public void setLinkAllowed(boolean linkAllowed) { + this.linkAllowed = linkAllowed; + } + + public String getUserID() { + return userID; + } + + public void setUserID(String userID) { + this.userID = userID; + } - + public static person verantwortlicher = new person(); public String getRole() { return role; diff --git a/dozentenmodulserver/src/main/java/server/ServerHandler.java b/dozentenmodulserver/src/main/java/server/ServerHandler.java index da00dfe4..30fd5237 100644 --- a/dozentenmodulserver/src/main/java/server/ServerHandler.java +++ b/dozentenmodulserver/src/main/java/server/ServerHandler.java @@ -24,6 +24,7 @@ import server.generated.User; import server.generated.Image; import server.generated.Lecture; import server.generated.Server; +import server.generated.Person; import com.mysql.jdbc.StringUtils; @@ -547,5 +548,11 @@ public class ServerHandler implements Server.Iface { return true; } + @Override + public List<Person> getAllOGUsers() throws TException { + return sql.getAllOGUsers(); + //return null; + } + } diff --git a/dozentenmodulserver/src/main/java/server/generated/Person.java b/dozentenmodulserver/src/main/java/server/generated/Person.java new file mode 100644 index 00000000..19084ac9 --- /dev/null +++ b/dozentenmodulserver/src/main/java/server/generated/Person.java @@ -0,0 +1,588 @@ +/** + * Autogenerated by Thrift Compiler (0.9.1) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package server.generated; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Person implements org.apache.thrift.TBase<Person, Person._Fields>, java.io.Serializable, Cloneable, Comparable<Person> { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Person"); + + private static final org.apache.thrift.protocol.TField USER_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("userID", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField NACHNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("Nachname", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField VORNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("Vorname", org.apache.thrift.protocol.TType.STRING, (short)3); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new PersonStandardSchemeFactory()); + schemes.put(TupleScheme.class, new PersonTupleSchemeFactory()); + } + + public String userID; // required + public String Nachname; // required + public String Vorname; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + USER_ID((short)1, "userID"), + NACHNAME((short)2, "Nachname"), + VORNAME((short)3, "Vorname"); + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // USER_ID + return USER_ID; + case 2: // NACHNAME + return NACHNAME; + case 3: // VORNAME + return VORNAME; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.USER_ID, new org.apache.thrift.meta_data.FieldMetaData("userID", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.NACHNAME, new org.apache.thrift.meta_data.FieldMetaData("Nachname", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.VORNAME, new org.apache.thrift.meta_data.FieldMetaData("Vorname", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Person.class, metaDataMap); + } + + public Person() { + } + + public Person( + String userID, + String Nachname, + String Vorname) + { + this(); + this.userID = userID; + this.Nachname = Nachname; + this.Vorname = Vorname; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public Person(Person other) { + if (other.isSetUserID()) { + this.userID = other.userID; + } + if (other.isSetNachname()) { + this.Nachname = other.Nachname; + } + if (other.isSetVorname()) { + this.Vorname = other.Vorname; + } + } + + public Person deepCopy() { + return new Person(this); + } + + @Override + public void clear() { + this.userID = null; + this.Nachname = null; + this.Vorname = null; + } + + public String getUserID() { + return this.userID; + } + + public Person setUserID(String userID) { + this.userID = userID; + return this; + } + + public void unsetUserID() { + this.userID = null; + } + + /** Returns true if field userID is set (has been assigned a value) and false otherwise */ + public boolean isSetUserID() { + return this.userID != null; + } + + public void setUserIDIsSet(boolean value) { + if (!value) { + this.userID = null; + } + } + + public String getNachname() { + return this.Nachname; + } + + public Person setNachname(String Nachname) { + this.Nachname = Nachname; + return this; + } + + public void unsetNachname() { + this.Nachname = null; + } + + /** Returns true if field Nachname is set (has been assigned a value) and false otherwise */ + public boolean isSetNachname() { + return this.Nachname != null; + } + + public void setNachnameIsSet(boolean value) { + if (!value) { + this.Nachname = null; + } + } + + public String getVorname() { + return this.Vorname; + } + + public Person setVorname(String Vorname) { + this.Vorname = Vorname; + return this; + } + + public void unsetVorname() { + this.Vorname = null; + } + + /** Returns true if field Vorname is set (has been assigned a value) and false otherwise */ + public boolean isSetVorname() { + return this.Vorname != null; + } + + public void setVornameIsSet(boolean value) { + if (!value) { + this.Vorname = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case USER_ID: + if (value == null) { + unsetUserID(); + } else { + setUserID((String)value); + } + break; + + case NACHNAME: + if (value == null) { + unsetNachname(); + } else { + setNachname((String)value); + } + break; + + case VORNAME: + if (value == null) { + unsetVorname(); + } else { + setVorname((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case USER_ID: + return getUserID(); + + case NACHNAME: + return getNachname(); + + case VORNAME: + return getVorname(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case USER_ID: + return isSetUserID(); + case NACHNAME: + return isSetNachname(); + case VORNAME: + return isSetVorname(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof Person) + return this.equals((Person)that); + return false; + } + + public boolean equals(Person that) { + if (that == null) + return false; + + boolean this_present_userID = true && this.isSetUserID(); + boolean that_present_userID = true && that.isSetUserID(); + if (this_present_userID || that_present_userID) { + if (!(this_present_userID && that_present_userID)) + return false; + if (!this.userID.equals(that.userID)) + return false; + } + + boolean this_present_Nachname = true && this.isSetNachname(); + boolean that_present_Nachname = true && that.isSetNachname(); + if (this_present_Nachname || that_present_Nachname) { + if (!(this_present_Nachname && that_present_Nachname)) + return false; + if (!this.Nachname.equals(that.Nachname)) + return false; + } + + boolean this_present_Vorname = true && this.isSetVorname(); + boolean that_present_Vorname = true && that.isSetVorname(); + if (this_present_Vorname || that_present_Vorname) { + if (!(this_present_Vorname && that_present_Vorname)) + return false; + if (!this.Vorname.equals(that.Vorname)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + @Override + public int compareTo(Person other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetUserID()).compareTo(other.isSetUserID()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUserID()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.userID, other.userID); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetNachname()).compareTo(other.isSetNachname()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetNachname()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.Nachname, other.Nachname); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetVorname()).compareTo(other.isSetVorname()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetVorname()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.Vorname, other.Vorname); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("Person("); + boolean first = true; + + sb.append("userID:"); + if (this.userID == null) { + sb.append("null"); + } else { + sb.append(this.userID); + } + first = false; + if (!first) sb.append(", "); + sb.append("Nachname:"); + if (this.Nachname == null) { + sb.append("null"); + } else { + sb.append(this.Nachname); + } + first = false; + if (!first) sb.append(", "); + sb.append("Vorname:"); + if (this.Vorname == null) { + sb.append("null"); + } else { + sb.append(this.Vorname); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class PersonStandardSchemeFactory implements SchemeFactory { + public PersonStandardScheme getScheme() { + return new PersonStandardScheme(); + } + } + + private static class PersonStandardScheme extends StandardScheme<Person> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, Person struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // USER_ID + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.userID = iprot.readString(); + struct.setUserIDIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // NACHNAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.Nachname = iprot.readString(); + struct.setNachnameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // VORNAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.Vorname = iprot.readString(); + struct.setVornameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, Person struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.userID != null) { + oprot.writeFieldBegin(USER_ID_FIELD_DESC); + oprot.writeString(struct.userID); + oprot.writeFieldEnd(); + } + if (struct.Nachname != null) { + oprot.writeFieldBegin(NACHNAME_FIELD_DESC); + oprot.writeString(struct.Nachname); + oprot.writeFieldEnd(); + } + if (struct.Vorname != null) { + oprot.writeFieldBegin(VORNAME_FIELD_DESC); + oprot.writeString(struct.Vorname); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class PersonTupleSchemeFactory implements SchemeFactory { + public PersonTupleScheme getScheme() { + return new PersonTupleScheme(); + } + } + + private static class PersonTupleScheme extends TupleScheme<Person> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, Person struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetUserID()) { + optionals.set(0); + } + if (struct.isSetNachname()) { + optionals.set(1); + } + if (struct.isSetVorname()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); + if (struct.isSetUserID()) { + oprot.writeString(struct.userID); + } + if (struct.isSetNachname()) { + oprot.writeString(struct.Nachname); + } + if (struct.isSetVorname()) { + oprot.writeString(struct.Vorname); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, Person struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(3); + if (incoming.get(0)) { + struct.userID = iprot.readString(); + struct.setUserIDIsSet(true); + } + if (incoming.get(1)) { + struct.Nachname = iprot.readString(); + struct.setNachnameIsSet(true); + } + if (incoming.get(2)) { + struct.Vorname = iprot.readString(); + struct.setVornameIsSet(true); + } + } + } + +} + diff --git a/dozentenmodulserver/src/main/java/server/generated/Server.java b/dozentenmodulserver/src/main/java/server/generated/Server.java index 0a7d99c5..60f3faae 100644 --- a/dozentenmodulserver/src/main/java/server/generated/Server.java +++ b/dozentenmodulserver/src/main/java/server/generated/Server.java @@ -82,6 +82,8 @@ public class Server { public boolean writeLectureRights(String lecturename, String username, String lastName, String firstName, String mail, String university, String role) throws org.apache.thrift.TException; + public List<Person> getAllOGUsers() throws org.apache.thrift.TException; + } public interface AsyncIface { @@ -132,6 +134,8 @@ public class Server { public void writeLectureRights(String lecturename, String username, String lastName, String firstName, String mail, String university, String role, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void getAllOGUsers(org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + } public static class Client extends org.apache.thrift.TServiceClient implements Iface { @@ -761,6 +765,28 @@ public class Server { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "writeLectureRights failed: unknown result"); } + public List<Person> getAllOGUsers() throws org.apache.thrift.TException + { + send_getAllOGUsers(); + return recv_getAllOGUsers(); + } + + public void send_getAllOGUsers() throws org.apache.thrift.TException + { + getAllOGUsers_args args = new getAllOGUsers_args(); + sendBase("getAllOGUsers", args); + } + + public List<Person> recv_getAllOGUsers() throws org.apache.thrift.TException + { + getAllOGUsers_result result = new getAllOGUsers_result(); + receiveBase(result, "getAllOGUsers"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getAllOGUsers failed: unknown result"); + } + } public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> { @@ -1749,6 +1775,35 @@ public class Server { } } + public void getAllOGUsers(org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + getAllOGUsers_call method_call = new getAllOGUsers_call(resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class getAllOGUsers_call extends org.apache.thrift.async.TAsyncMethodCall { + public getAllOGUsers_call(org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getAllOGUsers", org.apache.thrift.protocol.TMessageType.CALL, 0)); + getAllOGUsers_args args = new getAllOGUsers_args(); + args.write(prot); + prot.writeMessageEnd(); + } + + public List<Person> getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_getAllOGUsers(); + } + } + } public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor { @@ -1785,6 +1840,7 @@ public class Server { processMap.put("createUser", new createUser()); processMap.put("writeImageRights", new writeImageRights()); processMap.put("writeLectureRights", new writeLectureRights()); + processMap.put("getAllOGUsers", new getAllOGUsers()); return processMap; } @@ -2262,6 +2318,26 @@ public class Server { } } + public static class getAllOGUsers<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getAllOGUsers_args> { + public getAllOGUsers() { + super("getAllOGUsers"); + } + + public getAllOGUsers_args getEmptyArgsInstance() { + return new getAllOGUsers_args(); + } + + protected boolean isOneway() { + return false; + } + + public getAllOGUsers_result getResult(I iface, getAllOGUsers_args args) throws org.apache.thrift.TException { + getAllOGUsers_result result = new getAllOGUsers_result(); + result.success = iface.getAllOGUsers(); + return result; + } + } + } public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> { @@ -2298,6 +2374,7 @@ public class Server { processMap.put("createUser", new createUser()); processMap.put("writeImageRights", new writeImageRights()); processMap.put("writeLectureRights", new writeLectureRights()); + processMap.put("getAllOGUsers", new getAllOGUsers()); return processMap; } @@ -3488,6 +3565,57 @@ public class Server { } } + public static class getAllOGUsers<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getAllOGUsers_args, List<Person>> { + public getAllOGUsers() { + super("getAllOGUsers"); + } + + public getAllOGUsers_args getEmptyArgsInstance() { + return new getAllOGUsers_args(); + } + + public AsyncMethodCallback<List<Person>> getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback<List<Person>>() { + public void onComplete(List<Person> o) { + getAllOGUsers_result result = new getAllOGUsers_result(); + result.success = o; + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + getAllOGUsers_result result = new getAllOGUsers_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, getAllOGUsers_args args, org.apache.thrift.async.AsyncMethodCallback<List<Person>> resultHandler) throws TException { + iface.getAllOGUsers(resultHandler); + } + } + } public static class getFtpUser_args implements org.apache.thrift.TBase<getFtpUser_args, getFtpUser_args._Fields>, java.io.Serializable, Cloneable, Comparable<getFtpUser_args> { @@ -27821,4 +27949,658 @@ public class Server { } + public static class getAllOGUsers_args implements org.apache.thrift.TBase<getAllOGUsers_args, getAllOGUsers_args._Fields>, java.io.Serializable, Cloneable, Comparable<getAllOGUsers_args> { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getAllOGUsers_args"); + + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new getAllOGUsers_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new getAllOGUsers_argsTupleSchemeFactory()); + } + + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { +; + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getAllOGUsers_args.class, metaDataMap); + } + + public getAllOGUsers_args() { + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public getAllOGUsers_args(getAllOGUsers_args other) { + } + + public getAllOGUsers_args deepCopy() { + return new getAllOGUsers_args(this); + } + + @Override + public void clear() { + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof getAllOGUsers_args) + return this.equals((getAllOGUsers_args)that); + return false; + } + + public boolean equals(getAllOGUsers_args that) { + if (that == null) + return false; + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + @Override + public int compareTo(getAllOGUsers_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("getAllOGUsers_args("); + boolean first = true; + + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getAllOGUsers_argsStandardSchemeFactory implements SchemeFactory { + public getAllOGUsers_argsStandardScheme getScheme() { + return new getAllOGUsers_argsStandardScheme(); + } + } + + private static class getAllOGUsers_argsStandardScheme extends StandardScheme<getAllOGUsers_args> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, getAllOGUsers_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, getAllOGUsers_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getAllOGUsers_argsTupleSchemeFactory implements SchemeFactory { + public getAllOGUsers_argsTupleScheme getScheme() { + return new getAllOGUsers_argsTupleScheme(); + } + } + + private static class getAllOGUsers_argsTupleScheme extends TupleScheme<getAllOGUsers_args> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getAllOGUsers_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getAllOGUsers_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + } + } + + } + + public static class getAllOGUsers_result implements org.apache.thrift.TBase<getAllOGUsers_result, getAllOGUsers_result._Fields>, java.io.Serializable, Cloneable, Comparable<getAllOGUsers_result> { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getAllOGUsers_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.LIST, (short)0); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new getAllOGUsers_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new getAllOGUsers_resultTupleSchemeFactory()); + } + + public List<Person> success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, Person.class)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getAllOGUsers_result.class, metaDataMap); + } + + public getAllOGUsers_result() { + } + + public getAllOGUsers_result( + List<Person> success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public getAllOGUsers_result(getAllOGUsers_result other) { + if (other.isSetSuccess()) { + List<Person> __this__success = new ArrayList<Person>(other.success.size()); + for (Person other_element : other.success) { + __this__success.add(new Person(other_element)); + } + this.success = __this__success; + } + } + + public getAllOGUsers_result deepCopy() { + return new getAllOGUsers_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public int getSuccessSize() { + return (this.success == null) ? 0 : this.success.size(); + } + + public java.util.Iterator<Person> getSuccessIterator() { + return (this.success == null) ? null : this.success.iterator(); + } + + public void addToSuccess(Person elem) { + if (this.success == null) { + this.success = new ArrayList<Person>(); + } + this.success.add(elem); + } + + public List<Person> getSuccess() { + return this.success; + } + + public getAllOGUsers_result setSuccess(List<Person> success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((List<Person>)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof getAllOGUsers_result) + return this.equals((getAllOGUsers_result)that); + return false; + } + + public boolean equals(getAllOGUsers_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + @Override + public int compareTo(getAllOGUsers_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("getAllOGUsers_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getAllOGUsers_resultStandardSchemeFactory implements SchemeFactory { + public getAllOGUsers_resultStandardScheme getScheme() { + return new getAllOGUsers_resultStandardScheme(); + } + } + + private static class getAllOGUsers_resultStandardScheme extends StandardScheme<getAllOGUsers_result> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, getAllOGUsers_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list62 = iprot.readListBegin(); + struct.success = new ArrayList<Person>(_list62.size); + for (int _i63 = 0; _i63 < _list62.size; ++_i63) + { + Person _elem64; + _elem64 = new Person(); + _elem64.read(iprot); + struct.success.add(_elem64); + } + iprot.readListEnd(); + } + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, getAllOGUsers_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.success.size())); + for (Person _iter65 : struct.success) + { + _iter65.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getAllOGUsers_resultTupleSchemeFactory implements SchemeFactory { + public getAllOGUsers_resultTupleScheme getScheme() { + return new getAllOGUsers_resultTupleScheme(); + } + } + + private static class getAllOGUsers_resultTupleScheme extends TupleScheme<getAllOGUsers_result> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getAllOGUsers_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + { + oprot.writeI32(struct.success.size()); + for (Person _iter66 : struct.success) + { + _iter66.write(oprot); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getAllOGUsers_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + { + org.apache.thrift.protocol.TList _list67 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.success = new ArrayList<Person>(_list67.size); + for (int _i68 = 0; _i68 < _list67.size; ++_i68) + { + Person _elem69; + _elem69 = new Person(); + _elem69.read(iprot); + struct.success.add(_elem69); + } + } + struct.setSuccessIsSet(true); + } + } + } + + } + } diff --git a/dozentenmodulserver/src/main/java/sql/SQL.java b/dozentenmodulserver/src/main/java/sql/SQL.java index 92af9f14..0b5765fa 100644 --- a/dozentenmodulserver/src/main/java/sql/SQL.java +++ b/dozentenmodulserver/src/main/java/sql/SQL.java @@ -20,6 +20,9 @@ import org.apache.log4j.Logger; import server.BinaryListener;
import server.generated.Image;
import server.generated.Lecture;
+import server.generated.Person;
+
+
public class SQL {
@@ -249,7 +252,8 @@ public class SQL { try {
Connection con=getConnection();
Statement stm = con.createStatement();
-
+
+ //create a UUID
String uid = UUID.randomUUID().toString();
log.info(" - Query is: "+"INSERT INTO `bwLehrpool`.`m_VLData_imageInfo`(`GUID_imageID`,`imageVersion`,`image_name`,`image_description`,`image_path`,`image_lastCall`,`image_create_time`,`image_update_time`,`image_owner`,`image_change_by`,`rec_create_time`,`rec_change_time`,`rec_owner`,`rec_change_by`,`content_operatingSystem`,`status_isCompressed`,`status_isSecure`,`status_isOptimzed`,`status_isValid`,`status_isReady`,`status_isDeleted`,`status_isLastOfficialVersion`,`cond_hasLicenseRestriction`,`cond_hasInternetRestriction`,`cond_minRAM`,`cond_minCPUs`,`image_isTemplate`,`image_filesize`,`image_syncMode`)VALUES('"
@@ -1051,4 +1055,48 @@ public class SQL { }
return id;
}
+
+ //get all users from HS OG -- temp, tb replaced by allUsers bwLehrpool
+ public List<Person> getAllOGUsers(){
+ Connection con=getConnection();
+ Statement stm=null;
+ ResultSet res = null;
+ //Map<String, String> map = new HashMap<String, String>();
+ List<Person> list = new ArrayList<Person>();
+
+
+ try {
+ stm = con.createStatement();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ res = stm.executeQuery("SELECT userID, Nachname, Vorname FROM m_user ORDER BY Nachname ASC;");
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ while (res.next()) {
+
+
+ list.add(new Person(res.getString("userID"),
+ res.getString("Nachname"),
+ res.getString("Vorname")));
+
+ }
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return list;
+
+ }
+
+
+
+
}
diff --git a/dozentenmodulserver/thrift/server.thrift b/dozentenmodulserver/thrift/server.thrift index d8cf2506..0a3313e9 100644 --- a/dozentenmodulserver/thrift/server.thrift +++ b/dozentenmodulserver/thrift/server.thrift @@ -33,6 +33,12 @@ struct Lecture{ 8: string imagename, 9: string username, } +struct Person{ + 1: string userID, + 2: string Nachname, + 3: string Vorname, +} + service Server{ User getFtpUser(), int DeleteFtpUser(1: string user), @@ -57,4 +63,5 @@ service Server{ bool createUser(1: string loginName, 2: string lastName, 3: string firstName, 4: string mail, 5: string university), bool writeImageRights(1: string imagename, 2: string username, 3: string lastName, 4: string firstName, 5: string mail, 6: string university, 7: string role), bool writeLectureRights(1: string lecturename, 2: string username, 3: string lastName, 4: string firstName, 5: string mail, 6: string university, 7: string role), + list<Person>getAllOGUsers(), } |
