ServerFrame.java
Go to the documentation of this file.
1 package p2pgui;
2 
3 import p2putility.Config;
4 import java.awt.Frame;
5 import java.util.ArrayList;
6 import javax.swing.table.DefaultTableModel;
7 
13 public class ServerFrame extends javax.swing.JFrame {
14 
15 
16  //Modalita' debug
17  private static boolean detailerr = true;//false;//true;
18  private static boolean detailok = true;//false;//true;
19  private static boolean macro = true;//false;//true;
20 
21  //Variabili di configurazione del db
22  private static String userroot = "";
23  private static String pswdroot = "";
24  private static String dbroot = "";
25  private static String pswdp2p = "";
26  private static String userp2p = "";
27  private static String dbp2p = "";
28 
29  public static Thread t1;
30  public static Thread t2;
31 
32  public static p2pserver.InquireDB IDB;
33 
44  @SuppressWarnings({"static-access", "static-access"})
45  public ServerFrame() {
46 
48 
49  int again = -1;
50  String x = "";
51  do
52  {
53  getRootData();
54  try{
55  x = p2pserver.Connecttodbms.connect(false, dbroot, userroot, pswdroot).toString();
56  }
57  catch(Exception e){
58  p2putility.Util.logGeneric("DBMS connection error: "+e);
59  x = "";
60  }
61 
62  if(x.length()<1) // null o errore di connessione
63  {
64  again = javax.swing.JOptionPane.showConfirmDialog(null, "Error in DBMS connection. Try again?", "DBMS error", javax.swing.JOptionPane.YES_NO_OPTION);
65  if(again != javax.swing.JOptionPane.YES_OPTION)
66  System.exit(0);
67  }
68 
69  }while(x.length()<1);
70 
71  getP2pData();
72  new p2pserver.PrepareDB_root(macro,detailerr,detailok,dbroot,userroot,pswdroot,userp2p,pswdp2p,dbp2p);
73  new p2pserver.PrepareDB_user(macro,detailerr,detailok,userp2p,pswdp2p,dbp2p);
74 
75  IDB = new p2pserver.InquireDB(macro, dbp2p, userp2p, pswdp2p);
76 
77  //Thread per attivare il main di ServerListener
79  MT.dbg = true;
80  t1 = new Thread(MT);
81  t1.start();
82 
83 
84  //Thread per attivare ServerRMI
86  TRR.dbg = true;
87  t2 = new Thread(TRR);
88  t2.start();
89 
90  }
91 
96  @SuppressWarnings("unchecked")
97  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
98  private void initComponents() {
99 
100  jScrollPane2 = new javax.swing.JScrollPane();
101  jTable1 = new javax.swing.JTable();
102  jLabel1 = new javax.swing.JLabel();
103  jLabel3 = new javax.swing.JLabel();
104  jScrollPane3 = new javax.swing.JScrollPane();
105  jTable2 = new javax.swing.JTable();
106  jButton1 = new javax.swing.JButton();
107  jButton2 = new javax.swing.JButton();
108  jLabel2 = new javax.swing.JLabel();
109  jButton3 = new javax.swing.JButton();
110  jScrollPane4 = new javax.swing.JScrollPane();
111  jTable3 = new javax.swing.JTable();
112  jScrollPane5 = new javax.swing.JScrollPane();
113  jTable4 = new javax.swing.JTable();
114  jButton4 = new javax.swing.JButton();
115  jMenuBar1 = new javax.swing.JMenuBar();
116  jMenu1 = new javax.swing.JMenu();
117  jMenuItem1 = new javax.swing.JMenuItem();
118  jMenu2 = new javax.swing.JMenu();
119  jMenuItem2 = new javax.swing.JMenuItem();
120  jMenuItem3 = new javax.swing.JMenuItem();
121  jSeparator1 = new javax.swing.JSeparator();
122  jMenuItem4 = new javax.swing.JMenuItem();
123 
124  setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
125  setTitle("P2PFileSystem - Server");
126  setName("ServerFrame"); // NOI18N
127  addWindowListener(new java.awt.event.WindowAdapter() {
128  public void windowClosing(java.awt.event.WindowEvent evt) {
129  formWindowClosing(evt);
130  }
131  });
132 
133  jTable1.setModel(new javax.swing.table.DefaultTableModel(
134  new Object [][] {
135 
136  },
137  new String [] {
138  "ID", "IP", "USERNAME", "PASSWORD"
139  }
140  ) {
141  Class[] types = new Class [] {
142  java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
143  };
144 
145  public Class getColumnClass(int columnIndex) {
146  return types [columnIndex];
147  }
148  });
149  jTable1.setCellSelectionEnabled(true);
150  jTable1.getTableHeader().setReorderingAllowed(false);
151  jScrollPane2.setViewportView(jTable1);
152  jTable1.getColumnModel().getColumn(0).setPreferredWidth(20);
153  jTable1.getColumnModel().getColumn(1).setPreferredWidth(20);
154 
155  jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
156  jLabel1.setText("Connected clients");
157 
158  jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12));
159  jLabel3.setText("Client's files");
160 
161  jTable2.setModel(new javax.swing.table.DefaultTableModel(
162  new Object [][] {
163 
164  },
165  new String [] {
166  "Nome File", "ID nodo proprietario", "ID nodo in accesso", "Tipo di accesso"
167  }
168  ) {
169  Class[] types = new Class [] {
170  java.lang.String.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class
171  };
172  boolean[] canEdit = new boolean [] {
173  false, false, false, false
174  };
175 
176  public Class getColumnClass(int columnIndex) {
177  return types [columnIndex];
178  }
179 
180  public boolean isCellEditable(int rowIndex, int columnIndex) {
181  return canEdit [columnIndex];
182  }
183  });
184  jScrollPane3.setViewportView(jTable2);
185 
186  jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/LogOut_ico.png"))); // NOI18N
187  jButton1.setText("Log out");
188  jButton1.addActionListener(new java.awt.event.ActionListener() {
189  public void actionPerformed(java.awt.event.ActionEvent evt) {
191  }
192  });
193 
194  jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Refresh_ico.png"))); // NOI18N
195  jButton2.setText("Update file list");
196  jButton2.addActionListener(new java.awt.event.ActionListener() {
197  public void actionPerformed(java.awt.event.ActionEvent evt) {
199  }
200  });
201 
202  jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
203  jLabel2.setText("P2P File System ");
204 
205  jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/disconnectIcon.png"))); // NOI18N
206  jButton3.setText("Disconnect client");
207  jButton3.addActionListener(new java.awt.event.ActionListener() {
208  public void actionPerformed(java.awt.event.ActionEvent evt) {
210  }
211  });
212 
213  jTable3.setModel(new javax.swing.table.DefaultTableModel(
214  new Object [][] {
215 
216  },
217  new String [] {
218  "ID", "IP", "USERNAME", "PASSWORD"
219  }
220  ) {
221  Class[] types = new Class [] {
222  java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
223  };
224  boolean[] canEdit = new boolean [] {
225  false, false, false, false
226  };
227 
228  public Class getColumnClass(int columnIndex) {
229  return types [columnIndex];
230  }
231 
232  public boolean isCellEditable(int rowIndex, int columnIndex) {
233  return canEdit [columnIndex];
234  }
235  });
236  jTable3.getTableHeader().setReorderingAllowed(false);
237  jScrollPane4.setViewportView(jTable3);
238  jTable3.getColumnModel().getColumn(0).setPreferredWidth(20);
239  jTable3.getColumnModel().getColumn(1).setPreferredWidth(20);
240 
241  jTable4.setModel(new javax.swing.table.DefaultTableModel(
242  new Object [][] {
243 
244  },
245  new String [] {
246  "File ID", "Name", "Path", "Client ID", "Size", "Date", "Rights", "Insertion time"
247  }
248  ) {
249  Class[] types = new Class [] {
250  java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
251  };
252  boolean[] canEdit = new boolean [] {
253  false, false, false, false, false, false, false, false
254  };
255 
256  public Class getColumnClass(int columnIndex) {
257  return types [columnIndex];
258  }
259 
260  public boolean isCellEditable(int rowIndex, int columnIndex) {
261  return canEdit [columnIndex];
262  }
263  });
264  jScrollPane5.setViewportView(jTable4);
265 
266  jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Refresh_ico.png"))); // NOI18N
267  jButton4.setText("Update Client List");
268  jButton4.addActionListener(new java.awt.event.ActionListener() {
269  public void actionPerformed(java.awt.event.ActionEvent evt) {
271  }
272  });
273 
274  jMenu1.setText("File");
275 
276  jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/LogOut_ico.png"))); // NOI18N
277  jMenuItem1.setText("Log out");
278  jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
279  public void actionPerformed(java.awt.event.ActionEvent evt) {
281  }
282  });
283  jMenu1.add(jMenuItem1);
284 
285  jMenuBar1.add(jMenu1);
286 
287  jMenu2.setText("Action");
288 
289  jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Refresh_ico.png"))); // NOI18N
290  jMenuItem2.setText("Update Client list");
291  jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
292  public void actionPerformed(java.awt.event.ActionEvent evt) {
294  }
295  });
296  jMenu2.add(jMenuItem2);
297 
298  jMenuItem3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/disconnectIcon.png"))); // NOI18N
299  jMenuItem3.setText("Disconnect client");
300  jMenuItem3.setToolTipText("Open");
301  jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
302  public void actionPerformed(java.awt.event.ActionEvent evt) {
304  }
305  });
306  jMenu2.add(jMenuItem3);
307  jMenu2.add(jSeparator1);
308 
309  jMenuItem4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Refresh_ico.png"))); // NOI18N
310  jMenuItem4.setText("Update file list");
311  jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
312  public void actionPerformed(java.awt.event.ActionEvent evt) {
314  }
315  });
316  jMenu2.add(jMenuItem4);
317 
318  jMenuBar1.add(jMenu2);
319 
320  setJMenuBar(jMenuBar1);
321 
322  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
323  getContentPane().setLayout(layout);
324  layout.setHorizontalGroup(
325  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
326  .addGroup(layout.createSequentialGroup()
327  .addContainerGap()
328  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
329  .addGroup(layout.createSequentialGroup()
330  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
331  .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
332  .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE))
333  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
334  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
335  .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 770, Short.MAX_VALUE)
336  .addComponent(jLabel1)
337  .addGroup(layout.createSequentialGroup()
338  .addGap(456, 456, 456)
339  .addComponent(jButton2)
340  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 63, Short.MAX_VALUE)
341  .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE))
342  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
343  .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 594, javax.swing.GroupLayout.PREFERRED_SIZE)
344  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
345  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
346  .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE)
347  .addComponent(jButton4)))
348  .addComponent(jLabel3)))
349  .addComponent(jLabel2))
350  .addContainerGap())
351  );
352  layout.setVerticalGroup(
353  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
354  .addGroup(layout.createSequentialGroup()
355  .addGap(20, 20, 20)
356  .addComponent(jLabel2)
357  .addGap(18, 18, 18)
358  .addComponent(jLabel1)
359  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
360  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
361  .addGroup(layout.createSequentialGroup()
362  .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
363  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
364  .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
365  .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))
366  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
367  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
368  .addGap(84, 84, 84)
369  .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
370  .addGap(41, 41, 41)
371  .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
372  .addGroup(layout.createSequentialGroup()
373  .addGap(36, 36, 36)
374  .addComponent(jLabel3)
375  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
376  .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)
377  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
378  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
379  .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
380  .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE))
381  .addGap(3, 3, 3)))
382  .addGap(30, 30, 30))
383  );
384 
385  pack();
386  }// </editor-fold>//GEN-END:initComponents
387 
393  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
394  LogOutFrameServer l = new LogOutFrameServer(new javax.swing.JFrame(), true);
395  l.setLocationRelativeTo(null);
396  l.setVisible(true);
397  }//GEN-LAST:event_jButton1ActionPerformed
398 
404  private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
405  LogOutFrameServer l = new LogOutFrameServer(new javax.swing.JFrame(), true);
406  l.setLocationRelativeTo(null);
407  l.setVisible(true);
408  }//GEN-LAST:event_jMenuItem1ActionPerformed
409 
415  private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
416  getFileList();
417  }//GEN-LAST:event_jButton2ActionPerformed
418 
424  private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
425  getUserList();
426  }//GEN-LAST:event_jMenuItem2ActionPerformed
427 
434  private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
435  if(ServerFrame.IDB.isOpen()){
436  ServerFrame.IDB.delFileListBy(null, null, null, null, null, null, null, null, null, null);
437  ServerFrame.IDB.delUserListBy(null, null, null, null);
438  ServerFrame.IDB.close();
439  }
440  if(ServerFrame.t1.isAlive())
441  ServerFrame.t1.stop();
442  if(ServerFrame.t2.isAlive())
443  ServerFrame.t2.stop();
444  Config.w_serverOpen(false);
445  Frame[] f = Frame.getFrames();
446  for(int i =0; i< f.length; i++){
447  if(((f[i].getName()).equals("MainFrame")&&(!f[i].isVisible()))&&(!Config.r_clientOpen()))
448  System.exit(0);
449  }
450  }//GEN-LAST:event_formWindowClosing
451 
457  private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
459  getFileList();
460  }//GEN-LAST:event_jButton3ActionPerformed
461 
467  private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
468  getUserList();
469  }//GEN-LAST:event_jButton4ActionPerformed
470 
476  private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
477  getFileList();
478  }//GEN-LAST:event_jMenuItem4ActionPerformed
479 
485  private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
487  getFileList();
488  }//GEN-LAST:event_jMenuItem3ActionPerformed
489 
490 
491  // Variables declaration - do not modify//GEN-BEGIN:variables
492  private javax.swing.JButton jButton1;
493  private javax.swing.JButton jButton2;
494  private javax.swing.JButton jButton3;
495  private javax.swing.JButton jButton4;
496  private javax.swing.JLabel jLabel1;
497  private javax.swing.JLabel jLabel2;
498  private javax.swing.JLabel jLabel3;
499  private javax.swing.JMenu jMenu1;
500  private javax.swing.JMenu jMenu2;
501  private javax.swing.JMenuBar jMenuBar1;
502  private javax.swing.JMenuItem jMenuItem1;
503  private javax.swing.JMenuItem jMenuItem2;
504  private javax.swing.JMenuItem jMenuItem3;
505  private javax.swing.JMenuItem jMenuItem4;
506  private javax.swing.JScrollPane jScrollPane2;
507  private javax.swing.JScrollPane jScrollPane3;
508  private javax.swing.JScrollPane jScrollPane4;
509  private javax.swing.JScrollPane jScrollPane5;
510  private javax.swing.JSeparator jSeparator1;
511  private javax.swing.JTable jTable1;
512  private javax.swing.JTable jTable2;
513  private javax.swing.JTable jTable3;
514  private javax.swing.JTable jTable4;
515  // End of variables declaration//GEN-END:variables
516 
517 
518 
523  private static void getRootData(){
524  javax.swing.JLabel label1 = new javax.swing.JLabel("Insert <root> username:");
525  javax.swing.JTextField juf = new javax.swing.JTextField();
526  javax.swing.JLabel label2 = new javax.swing.JLabel("Insert <root> password:");
527  javax.swing.JPasswordField jpf = new javax.swing.JPasswordField();
528  javax.swing.JLabel label3 = new javax.swing.JLabel("Insert <root> default DB:");
529  javax.swing.JTextField jdf = new javax.swing.JTextField();
530  javax.swing.JOptionPane.showConfirmDialog(null,new Object[]{label1,juf , label2, jpf, label3, jdf}, "DBMS <root> Password:", javax.swing.JOptionPane.OK_CANCEL_OPTION,1);
531  pswdroot = jpf.getText();
532  userroot = juf.getText();
533  dbroot = jdf.getText();
534  jpf.setText("*****");
535  }
536 
540  private static void getP2pData(){
541 
542  // User
543  userp2p = p2putility.Config.r_userp2p();
544  // DataBase
545  dbp2p = p2putility.Config.r_dbp2p();
546 
547  // Password (random dynamic)
548  pswdp2p = "";
549 
550  int minlen = 7;
551  int maxlen = 9;
552  String charok = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890";
553 
554  int len = minlen + (int)(java.lang.Math.round(java.lang.Math.random()*(maxlen-minlen)));
555 
556  for(int i=0;i<len;i++)
557  pswdp2p += charok.charAt((int)(java.lang.Math.round(java.lang.Math.random()*(charok.length()-1))));
558  }
559 
564  private void getUserList(){
565  DefaultTableModel model1 = (DefaultTableModel)jTable3.getModel();
566  model1.setRowCount(0);
567  ArrayList listUser = IDB.getUserList(null);
568 
569  Object [] obj= new Object [10];
570 
571  for(int i=0; i< listUser.size(); i++){
572  int j=-1, k =-1;
573  ArrayList temp = (ArrayList)listUser.get(i);
574  obj[++k] = Integer.parseInt(temp.get(++j).toString());
575  obj[++k] = temp.get(++j).toString();
576  obj[++k] = temp.get(++j).toString();
577  obj[++k] = temp.get(++j).toString();
578  model1.addRow(obj);
579  }
580  model1.fireTableRowsInserted(0, listUser.size()-1);
581  }
582 
587  private void getFileList(){
588  DefaultTableModel model2 = (DefaultTableModel)jTable4.getModel();
589  model2.setRowCount(0);
590  ArrayList listFile = IDB.getFileList("");
591 
592  Object [] obj= new Object [10];
593 
594  for(int i=0; i< listFile.size(); i++){
595  int j=-1, k =-1;
596  ArrayList temp = (ArrayList)listFile.get(i);
597  obj[++k] = temp.get(++j).toString();
598  obj[++k] = temp.get(++j).toString();
599  obj[++k] = temp.get(++j).toString();
600  obj[++k] = temp.get(++j).toString();
601  j++;
602  obj[++k] = temp.get(++j).toString();
603  obj[++k] = temp.get(++j).toString();
604  obj[++k] = temp.get(++j).toString();
605  j++; //non inserisco lo stato obj[++k] = stateFromNumToWord(Integer.parseInt(temp.get(++j).toString()));
606  obj[++k] = temp.get(++j).toString();
607  model2.addRow(obj);
608  }
609  model2.fireTableRowsInserted(0, listFile.size()-1);
610  }
611 
617  private void disconnectClient(){
618  if(jTable3.getSelectedRow()!=-1 && jTable3.getRowCount()>0){
619 
620  int indexToRemove = jTable3.getSelectedRow();
621  String id = jTable3.getModel().getValueAt(indexToRemove, 0).toString();
622  String ip = jTable3.getModel().getValueAt(indexToRemove, 1).toString();
623  String user = jTable3.getModel().getValueAt(indexToRemove, 2).toString();
624  String pswd = jTable3.getModel().getValueAt(indexToRemove, 3).toString();
625 
626  IDB.delUserListBy(id, ip, user, pswd);
627 
628  DefaultTableModel model = (DefaultTableModel) jTable3.getModel();
629  model.removeRow(indexToRemove);
630  model.fireTableRowsDeleted(indexToRemove, indexToRemove);
631 
632  IDB.delFileListBy(null, null, null, id, null, null, null, null, "0", null);
633  p2putility.Util.logGeneric("Client disconnesso");
634 
635  }
636 
637  }
638 
639 
640 }
static void w_serverOpen(boolean value)
Permette la scrittura della varibile relativa in modo sicuro.
Definition: Config.java:405
void initComponents()
Metodo chiamato dal costruttore per inizializzare la form WARNING: Do NOT modify this code...
Classe che mette a disposizione funzioni per interfacciarsi al DBMS in modo rapido ed eventualmente s...
Definition: InquireDB.java:11
static String userp2p
static p2pserver.InquireDB IDB
javax.swing.JMenuItem jMenuItem3
javax.swing.JScrollPane jScrollPane5
Classe che permette la configurazione di tutto il programma in base alle specifiche esigenze dell&#39;ute...
Definition: Config.java:14
static void getP2pData()
Metodo che crea una password random per il nuovo utente che accede al db.
Classe che implementa metodi vari di utilita&#39; generale.
Definition: Util.java:14
void jButton2ActionPerformed(java.awt.event.ActionEvent evt)
Azione effettuata in seguito alla pressione del bottone di Update file list: creazione di un istanza ...
javax.swing.JButton jButton1
javax.swing.JMenuItem jMenuItem2
javax.swing.JMenuItem jMenuItem1
javax.swing.JTable jTable2
Classe che implementa il servizio Server.
static boolean macro
static String pswdroot
static String r_userp2p()
Permette la lettura della varibile relativa in modo sicuro.
Definition: Config.java:315
static boolean detailerr
static Thread t1
javax.swing.JScrollPane jScrollPane2
javax.swing.JMenuBar jMenuBar1
Classe che genera graficamente la finestra di LogOut dal frame Server.
void getFileList()
Metodo che tramite IDB ottiene la lista dei file condivisi e li inserisce nella tabella jTable4...
javax.swing.JMenu jMenu2
void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt)
Azione effettuata in seguito alla pressione del bottone di LogOut dal JMenu: creazione di un istanza ...
javax.swing.JButton jButton4
javax.swing.JLabel jLabel2
javax.swing.JTable jTable1
javax.swing.JButton jButton3
static boolean detailok
static String dbp2p
Classe che permette la preparazione delle tabelle accessibili dall&#39;utente specificato in configurazio...
void disconnectClient()
Metodo che disconnette il client selezionato dalla jTable3, eliminando il suo report dallo userDB e t...
static void logGeneric(String data)
Scrive i dati in input sul file di log Generico (se questo esiste valido)
Definition: Util.java:132
void formWindowClosing(java.awt.event.WindowEvent evt)
Azioni da effettuare alla chiusura della finestra: cancellazione delle tabelle dal db...
static String r_dbp2p()
Permette la lettura della varibile relativa in modo sicuro.
Definition: Config.java:320
static String pswdp2p
javax.swing.JButton jButton2
Classe che mette a disposizione funzioni per interfacciarsi al DBMS in modo rapido ed eventualmente s...
javax.swing.JTable jTable3
void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
Azione effettuata in seguito alla pressione del bottone di LogOut: creazione di un istanza di LogOutF...
javax.swing.JLabel jLabel1
Classe che permette la preparazione del DBMS in modo da renderlo accessibile in modo sicuro da un ute...
static String dbroot
javax.swing.JTable jTable4
javax.swing.JSeparator jSeparator1
static void getRootData()
Metodo che crea una form in cui inserire username e password di root del dbms, e il nome del db di de...
ServerFrame()
Costruttore che crea la form ServerFrame, prepara i DB, crea un istanza di InquireDB, attiva ServerListener e ServerRMI invocando due thread.
void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt)
Azioni effettuata in seguito alla pressione del bottone Disconnect Client dal JMenu: disconnessione d...
static Connection connect(boolean speak, String dbms, String user, String pswd)
Restituisce una connessione (Connection) al DB selezionato.
javax.swing.JScrollPane jScrollPane4
javax.swing.JScrollPane jScrollPane3
static Thread t2
void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt)
Azione effettuata in seguito alla pressione del bottone di Update user list dal JMenu: creazione di u...
Classe implementata a Thread che permette di lanciare un processo batch/bash che esegue il comando RM...
void getUserList()
Metodo che tramite IDB ottiene la lista degli utenti collegati e li inserisce nella tabella jTable3...
javax.swing.JLabel jLabel3
void jButton4ActionPerformed(java.awt.event.ActionEvent evt)
Azione effettuata in seguito alla pressione del bottone di Update user list: creazione di un istanza ...
static boolean r_clientOpen()
Permette la lettura della varibile relativa in modo sicuro.
Definition: Config.java:410
Classe che implementa il metodo run dell&#39;interfaccia Runnable e crea un&#39;istanza di ServerListener...
void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt)
Azione effettuata in seguito alla pressione del bottone di Update file list dal JMenu: creazione di u...
javax.swing.JMenuItem jMenuItem4
javax.swing.JMenu jMenu1
void jButton3ActionPerformed(java.awt.event.ActionEvent evt)
Azioni effettuata in seguito alla pressione del bottone Disconnect Client: disconnessione del client ...
static String userroot