Advertisement
Guest User

Untitled

a guest
May 7th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 16.72 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. import java.sql.Connection;
  7. import java.sql.PreparedStatement;
  8. import java.sql.ResultSet;
  9. import java.sql.SQLException;
  10. import java.util.ArrayList;
  11. import java.util.List;
  12. import java.util.UUID;
  13. import javax.naming.Context;
  14. import javax.naming.InitialContext;
  15. import javax.naming.NamingException;
  16. import javax.sql.DataSource;
  17.  
  18. /**
  19.  *
  20.  * @author marc
  21.  */
  22. public class Services {
  23.  
  24.     private Connection getConnection() throws NamingException, SQLException
  25.     {
  26.         Context context = new InitialContext();
  27.         DataSource ds = (DataSource)context.lookup("java:comp/env/jdbc/test");
  28.         return ds.getConnection();
  29.     }
  30.  
  31.     public boolean isUsernameAvailable(String username)
  32.     {
  33.         boolean retour = false;
  34.  
  35.         try
  36.         {
  37.             Connection cn = this.getConnection();
  38.  
  39.             PreparedStatement st = cn.prepareStatement(
  40.                 "SELECT 1 FROM users WHERE username = ?"
  41.             );
  42.             st.setString(1, username);
  43.  
  44.             ResultSet rs = st.executeQuery();
  45.             if (!rs.next()) retour = true;
  46.  
  47.             rs.close();
  48.             st.close();
  49.             cn.close();
  50.         }
  51.         catch (Exception e) {
  52.             e.printStackTrace();
  53.         }
  54.  
  55.         return retour;
  56.     }
  57.  
  58.     public boolean isAccessGranted(String username, String password, String uuid, String usbid)
  59.     {
  60.         boolean retour = false;
  61.  
  62.         try
  63.         {
  64.             Connection cn = this.getConnection();
  65.  
  66.             PreparedStatement st = cn.prepareStatement(
  67.                 "SELECT 1 FROM users WHERE username = ? AND password = ? AND uuid = ? AND usbid = ?"
  68.             );
  69.             st.setString(1, username);
  70.             st.setString(2, password);
  71.             st.setString(3, uuid);
  72.             st.setString(4, usbid);
  73.  
  74.             ResultSet rs = st.executeQuery();
  75.             if (rs.next()) retour = true;
  76.  
  77.             rs.close();
  78.             st.close();
  79.             cn.close();
  80.         }
  81.         catch (Exception e) {
  82.             e.printStackTrace();
  83.         }
  84.        
  85.         return retour;
  86.     }
  87.  
  88.     public String createNewAccount(String username, String password, String firstname, String lastname, String email, String usbid)
  89.     {
  90.         String retour = null;
  91.  
  92.         try
  93.         {
  94.             Connection cn = this.getConnection();
  95.  
  96.             retour = UUID.randomUUID().toString().toUpperCase().replaceAll("-", "");
  97.  
  98.             PreparedStatement st = cn.prepareStatement(
  99.                 "INSERT INTO users VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, 0)"
  100.             );
  101.             st.setString(1, retour);
  102.             st.setString(2, usbid);
  103.             st.setString(3, username);
  104.             st.setString(4, password);
  105.             st.setString(5, firstname);
  106.             st.setString(6, lastname);
  107.             st.setString(7, email);
  108.  
  109.             st.executeUpdate();
  110.  
  111.             st.close();
  112.             cn.close();
  113.         }
  114.         catch (Exception e) {
  115.             e.printStackTrace();
  116.         }
  117.  
  118.         return retour;
  119.     }
  120.  
  121.     public boolean blacklistAccount(String username, String password)
  122.     {
  123.         boolean retour = false;
  124.  
  125.         try
  126.         {
  127.             Connection cn = this.getConnection();
  128.  
  129.             PreparedStatement st = cn.prepareStatement(
  130.                 "UPDATE users SET blacklist = 1 WHERE username = ? AND password = ?"
  131.             );
  132.             st.setString(1, username);
  133.             st.setString(2, password);
  134.  
  135.             st.executeUpdate();
  136.             retour = true;
  137.  
  138.             st.close();
  139.             cn.close();
  140.         }
  141.         catch (Exception e) {
  142.             e.printStackTrace();
  143.         }
  144.  
  145.         return retour;
  146.     }
  147.  
  148.     public int addNewForm(String url, String action, String method, String name, int number)
  149.     {
  150.         int retour = 0;
  151.  
  152.         try
  153.         {
  154.             Connection cn = this.getConnection();
  155.  
  156.             PreparedStatement st = cn.prepareStatement(
  157.                 "INSERT INTO forms VALUES (NULL, ?, ?, ?, ?, ?, NOW(), 0)",
  158.                 PreparedStatement.RETURN_GENERATED_KEYS
  159.             );
  160.             st.setString(1, url);
  161.             st.setString(2, action);
  162.             st.setString(3, method);
  163.             st.setString(4, name);
  164.             st.setInt(5, number);
  165.  
  166.             st.executeUpdate();
  167.             ResultSet rs = st.getGeneratedKeys();
  168.             if (rs.next()) retour = rs.getInt(1);
  169.  
  170.             rs.close();
  171.             st.close();
  172.             cn.close();
  173.         }
  174.         catch (Exception e) {
  175.             e.printStackTrace();
  176.         }
  177.  
  178.         return retour;
  179.     }
  180.  
  181.     public int addNewField(int formid, String name, String type, String value, int rank)
  182.     {
  183.         int retour = 0;
  184.  
  185.         try
  186.         {
  187.             Connection cn = this.getConnection();
  188.  
  189.             PreparedStatement st = cn.prepareStatement(
  190.                 "INSERT INTO fields VALUES (NULL, ?, ?, ?, ?, ?)",
  191.                 PreparedStatement.RETURN_GENERATED_KEYS
  192.             );
  193.             st.setInt(1, formid);
  194.             st.setString(2, name);
  195.             st.setString(3, type);
  196.             st.setString(4, value);
  197.             st.setInt(5, rank);
  198.  
  199.             st.executeUpdate();
  200.             ResultSet rs = st.getGeneratedKeys();
  201.             if (rs.next()) retour = rs.getInt(1);
  202.  
  203.             rs.close();
  204.             st.close();
  205.             cn.close();
  206.         }
  207.         catch (Exception e) {
  208.             e.printStackTrace();
  209.         }
  210.  
  211.         return retour;
  212.     }
  213.  
  214.     /*
  215.     public Global getGlobalFormById(int id)
  216.     {
  217.         Global form = null;
  218.  
  219.         try
  220.         {
  221.             Connection cn = this.getConnection();
  222.  
  223.             PreparedStatement st1 = cn.prepareStatement(
  224.                 "SELECT id, url, action, method, name, number FROM forms WHERE id = ?"
  225.             );
  226.             st1.setInt(1, id);
  227.  
  228.             ResultSet rs1 = st1.executeQuery();
  229.             if (rs1.next()) {
  230.                 Global tmp = new Global (
  231.                     rs1.getInt("id"), rs1.getString("url"), rs1.getString("action"),
  232.                     rs1.getString("method"), rs1.getString("name"), rs1.getInt("number")
  233.                 );
  234.  
  235.                 List<Field> fields = new ArrayList<Field>();
  236.  
  237.                 PreparedStatement st2 = cn.prepareStatement(
  238.                     "SELECT id, idform, name, type, value, rank FROM fields WHERE idform = ?"
  239.                 );
  240.                 st2.setInt(1, rs1.getInt("id"));
  241.  
  242.                 ResultSet rs2 = st2.executeQuery();
  243.                 while (rs2.next()) {
  244.                     Field field = new Field (
  245.                         rs2.getInt("id"), rs2.getInt("idform"), rs2.getString("name"),
  246.                         rs2.getString("type"), rs2.getString("value"), rs2.getInt("rank")
  247.                     );
  248.  
  249.                     fields.add(field);
  250.                 }
  251.  
  252.                 tmp.setFields((Field[]) fields.toArray(new Field[0]));
  253.  
  254.                 rs2.close();
  255.                 st2.close();
  256.  
  257.                 form = tmp;
  258.             }
  259.  
  260.             rs1.close();
  261.             st1.close();
  262.             cn.close();
  263.         }
  264.         catch (Exception e) {
  265.             e.printStackTrace();
  266.         }
  267.  
  268.         return form;
  269.     }
  270.  
  271.     public Form getFormById(int id)
  272.     {
  273.         Form form = null;
  274.  
  275.         try
  276.         {
  277.             Connection cn = this.getConnection();
  278.  
  279.             PreparedStatement st = cn.prepareStatement(
  280.                 "SELECT id, url, action, method, name, number FROM forms WHERE id = ?"
  281.             );
  282.             st.setInt(1, id);
  283.  
  284.             ResultSet rs = st.executeQuery();
  285.             if (rs.next()) {
  286.                 Form tmp = new Form (
  287.                     rs.getInt("id"), rs.getString("url"), rs.getString("action"),
  288.                     rs.getString("method"), rs.getString("name"), rs.getInt("number")
  289.                 );
  290.  
  291.                 form = tmp;
  292.             }
  293.  
  294.             rs.close();
  295.             st.close();
  296.             cn.close();
  297.         }
  298.         catch (Exception e) {
  299.             e.printStackTrace();
  300.         }
  301.  
  302.         return form;
  303.     }
  304.  
  305.     public Field getFieldById(int id)
  306.     {
  307.         Field field = null;
  308.  
  309.         try
  310.         {
  311.             Connection cn = this.getConnection();
  312.  
  313.             PreparedStatement st = cn.prepareStatement(
  314.                 "SELECT id, idform, name, type, value, rank FROM fields WHERE id = ?"
  315.             );
  316.             st.setInt(1, id);
  317.  
  318.             ResultSet rs = st.executeQuery();
  319.             if (rs.next()) {
  320.                 Field tmp = new Field (
  321.                     rs.getInt("id"), rs.getInt("idform"), rs.getString("name"),
  322.                     rs.getString("type"), rs.getString("value"), rs.getInt("rank")
  323.                 );
  324.  
  325.                 field = tmp;
  326.             }
  327.  
  328.             rs.close();
  329.             st.close();
  330.             cn.close();
  331.         }
  332.         catch (Exception e) {
  333.             e.printStackTrace();
  334.         }
  335.  
  336.         return field;
  337.     }
  338.     */
  339.  
  340.     /*
  341.     public Global[] getGlobalForms(boolean valid)
  342.     {
  343.         List<Global> forms = new ArrayList<Global>();
  344.  
  345.         try
  346.         {
  347.             Connection cn = this.getConnection();
  348.  
  349.             PreparedStatement st1;
  350.             if (valid) {
  351.                 st1 = cn.prepareStatement(
  352.                     "SELECT id, url, action, method, name, number FROM forms WHERE valid = 1"
  353.                 );
  354.             } else {
  355.                 st1 = cn.prepareStatement(
  356.                     "SELECT id, url, action, method, name, number FROM forms"
  357.                 );
  358.             }
  359.  
  360.             ResultSet rs1 = st1.executeQuery();
  361.             while (rs1.next()) {
  362.                 Global tmp = new Global (
  363.                     rs1.getInt("id"), rs1.getString("url"), rs1.getString("action"),
  364.                     rs1.getString("method"), rs1.getString("name"), rs1.getInt("number")
  365.                 );
  366.  
  367.                 List<Field> fields = new ArrayList<Field>();
  368.  
  369.                 PreparedStatement st2 = cn.prepareStatement(
  370.                     "SELECT id, idform, name, type, value, rank FROM fields WHERE idform = ?"
  371.                 );
  372.                 st2.setInt(1, rs1.getInt("id"));
  373.  
  374.                 ResultSet rs2 = st2.executeQuery();
  375.                 while (rs2.next()) {
  376.                     Field field = new Field (
  377.                         rs2.getInt("id"), rs2.getInt("idform"), rs2.getString("name"),
  378.                         rs2.getString("type"), rs2.getString("value"), rs2.getInt("rank")
  379.                     );
  380.  
  381.                     fields.add(field);
  382.                 }
  383.  
  384.                 tmp.setFields((Field[]) fields.toArray(new Field[0]));
  385.  
  386.                 rs2.close();
  387.                 st2.close();
  388.  
  389.                 forms.add(tmp);
  390.             }
  391.  
  392.             rs1.close();
  393.             st1.close();
  394.             cn.close();
  395.         }
  396.         catch (Exception e) {
  397.             e.printStackTrace();
  398.         }
  399.  
  400.         //return forms;
  401.         return (Global[]) forms.toArray(new Global[0]);
  402.     }
  403.     */
  404.  
  405.     public Form[] getForms(boolean valid)
  406.     {
  407.         List<Form> forms = new ArrayList<Form>();
  408.  
  409.         try
  410.         {
  411.             Connection cn = this.getConnection();
  412.  
  413.             PreparedStatement st;
  414.             if (valid) {
  415.                 st = cn.prepareStatement(
  416.                     "SELECT id, url, action, method, name, number FROM forms WHERE valid = 1"
  417.                 );
  418.             } else {
  419.                 st = cn.prepareStatement(
  420.                     "SELECT id, url, action, method, name, number FROM forms"
  421.                 );
  422.             }
  423.  
  424.             ResultSet rs = st.executeQuery();
  425.             while (rs.next()) {
  426.                 Form tmp = new Form (
  427.                     rs.getInt("id"), rs.getString("url"), rs.getString("action"),
  428.                     rs.getString("method"), rs.getString("name"), rs.getInt("number")
  429.                 );
  430.  
  431.                 forms.add(tmp);
  432.             }
  433.  
  434.             rs.close();
  435.             st.close();
  436.             cn.close();
  437.         }
  438.         catch (Exception e) {
  439.             e.printStackTrace();
  440.         }
  441.  
  442.         //return forms;
  443.         return (Form[]) forms.toArray(new Form[0]);
  444.     }
  445.  
  446.     public Field[] getFieldsByForm(int id)
  447.     {
  448.         List<Field> fields = new ArrayList<Field>();
  449.  
  450.         try
  451.         {
  452.             Connection cn = this.getConnection();
  453.  
  454.             PreparedStatement st = cn.prepareStatement(
  455.                 "SELECT id, idform, name, type, value, rank FROM fields WHERE idform = ?"
  456.             );
  457.             st.setInt(1, id);
  458.  
  459.             ResultSet rs = st.executeQuery();
  460.             while (rs.next()) {
  461.                 Field tmp = new Field (
  462.                     rs.getInt("id"), rs.getInt("idform"), rs.getString("name"),
  463.                     rs.getString("type"), rs.getString("value"), rs.getInt("rank")
  464.                 );
  465.  
  466.                 fields.add(tmp);
  467.             }
  468.  
  469.             rs.close();
  470.             st.close();
  471.             cn.close();
  472.         }
  473.         catch (Exception e) {
  474.             e.printStackTrace();
  475.         }
  476.  
  477.         //return fields;
  478.         return (Field[]) fields.toArray(new Field[0]);
  479.     }
  480.  
  481.     /*
  482.     public String[] getFormsToString(boolean valid)
  483.     {
  484.         String[] retour = new String[0];
  485.  
  486.         try
  487.         {
  488.             Form[] forms = this.getForms(valid);
  489.  
  490.             retour = new String[forms.length];
  491.  
  492.             for(int i = 0; i < forms.length; i++) {
  493.                 retour[i]  = forms[i].getId() + "|";
  494.                 retour[i] += forms[i].getUrl() + "|";
  495.                 retour[i] += forms[i].getAction() + "|";
  496.                 retour[i] += forms[i].getMethod() + "|";
  497.                 retour[i] += forms[i].getName() + "|";
  498.                 retour[i] += forms[i].getNumber();
  499.             }
  500.  
  501.             List<Form> forms = this.getForms(valid);
  502.  
  503.             retour = new String[forms.size()];
  504.  
  505.             int i = 0;
  506.             for (Form form : forms) {
  507.                 retour[i]  = form.getId() + "|";
  508.                 retour[i] += form.getUrl() + "|";
  509.                 retour[i] += form.getAction() + "|";
  510.                 retour[i] += form.getMethod() + "|";
  511.                 retour[i] += form.getName() + "|";
  512.                 retour[i] += form.getNumber();
  513.                 i++;
  514.             }
  515.         }
  516.         catch (Exception e) {
  517.             e.printStackTrace();
  518.         }
  519.  
  520.         return retour;
  521.     }
  522.  
  523.     public String[] getFieldsByFormToString(int id)
  524.     {
  525.         String[] retour = new String[0];
  526.  
  527.         try
  528.         {
  529.             Field[] fields = this.getFieldsByForm(id);
  530.  
  531.             retour = new String[fields.length];
  532.  
  533.             for(int i = 0; i < fields.length; i++) {
  534.                 retour[i]  = fields[i].getId() + "|";
  535.                 retour[i] += fields[i].getIdform() + "|";
  536.                 retour[i] += fields[i].getName() + "|";
  537.                 retour[i] += fields[i].getType() + "|";
  538.                 retour[i] += fields[i].getValue() + "|";
  539.                 retour[i] += fields[i].getRank();
  540.             }
  541.  
  542.             List<Field> fields = this.getFieldsByForm(id);
  543.  
  544.             retour = new String[fields.size()];
  545.  
  546.             int i = 0;
  547.             for (Field field : fields) {
  548.                 retour[i]  = field.getId() + "|";
  549.                 retour[i] += field.getIdform() + "|";
  550.                 retour[i] += field.getName() + "|";
  551.                 retour[i] += field.getType() + "|";
  552.                 retour[i] += field.getValue() + "|";
  553.                 retour[i] += field.getRank();
  554.                 i++;
  555.             }
  556.         }
  557.         catch (Exception e) {
  558.             e.printStackTrace();
  559.         }
  560.  
  561.         return retour;
  562.     }
  563.     */
  564.  
  565.     public int isPortalAccessGranted(String username, String password)
  566.     {
  567.         int retour = 0;
  568.  
  569.         try
  570.         {
  571.             Connection cn = this.getConnection();
  572.  
  573.             PreparedStatement st = cn.prepareStatement(
  574.                 "SELECT id FROM users WHERE username = ? AND password = ?"
  575.             );
  576.             st.setString(1, username);
  577.             st.setString(2, password);
  578.  
  579.             ResultSet rs = st.executeQuery();
  580.             if (rs.next()) retour = rs.getInt("id");
  581.  
  582.             rs.close();
  583.             st.close();
  584.             cn.close();
  585.         }
  586.         catch (Exception e) {
  587.             e.printStackTrace();
  588.         }
  589.  
  590.         return retour;
  591.     }
  592.  
  593.     public int addNewGadget(int idg, int ido, String title, int col, int row, int idu, Pref[] prefs)
  594.     {
  595.         int retour = 0;
  596.  
  597.         try
  598.         {
  599.             Connection cn = this.getConnection();
  600.  
  601.             PreparedStatement st1 = cn.prepareStatement(
  602.                 "INSERT INTO gadgets VALUES (NULL, ?, ?, ?, ?, ?, ?)",
  603.                 PreparedStatement.RETURN_GENERATED_KEYS
  604.             );
  605.             st1.setInt(1, idg);
  606.             st1.setInt(2, ido);
  607.             st1.setString(3, title);
  608.             st1.setInt(4, col);
  609.             st1.setInt(5, row);
  610.             st1.setInt(6, idu);
  611.  
  612.             st1.executeUpdate();
  613.             ResultSet rs1 = st1.getGeneratedKeys();
  614.             if (rs1.next()) {
  615.                 retour = rs1.getInt(1);
  616.  
  617.                 for (Pref pref : prefs)
  618.                 {
  619.                     PreparedStatement st2 = cn.prepareCall(
  620.                         "INSERT INTO prefs VALUES (?, ?, ?)"
  621.                     );
  622.                     st2.setInt(1, retour);
  623.                     st2.setString(2, pref.getKey());
  624.                     st2.setString(3, pref.getValue());
  625.  
  626.                     st2.executeUpdate();
  627.                     st2.close();
  628.                 }
  629.             }
  630.  
  631.             rs1.close();
  632.             st1.close();
  633.             cn.close();
  634.         }
  635.         catch (Exception e) {
  636.             e.printStackTrace();
  637.         }
  638.  
  639.         return retour;
  640.     }
  641.  
  642.     public boolean removeGadget(int id)
  643.     {
  644.         int retour = 0;
  645.  
  646.         try
  647.         {
  648.             Connection cn = this.getConnection();
  649.  
  650.             PreparedStatement st = cn.prepareStatement(
  651.                 "DELETE FROM gadgets WHERE id = ?"
  652.             );
  653.             st.setInt(1, id);
  654.             retour = st.executeUpdate();
  655.  
  656.             st.close();
  657.             cn.close();
  658.         }
  659.         catch (Exception e) {
  660.             e.printStackTrace();
  661.         }
  662.  
  663.         return retour > 0;
  664.     }
  665.  
  666.     public boolean setGadgetPosition(int id, int col, int row)
  667.     {
  668.         int retour = 0;
  669.  
  670.         try
  671.         {
  672.             Connection cn = this.getConnection();
  673.  
  674.             PreparedStatement st = cn.prepareStatement(
  675.                 "UPDATE gadgets SET col = ?, row = ? WHERE id = ?"
  676.             );
  677.             st.setInt(1, col);
  678.             st.setInt(2, row);
  679.             st.setInt(3, id);
  680.             retour = st.executeUpdate();
  681.  
  682.             st.close();
  683.             cn.close();
  684.         }
  685.         catch (Exception e) {
  686.             e.printStackTrace();
  687.         }
  688.  
  689.         return retour > 0;
  690.     }
  691.  
  692.     public boolean setGadgetPrefs(int id, Pref[] prefs)
  693.     {
  694.         int retour = 0;
  695.  
  696.         try
  697.         {
  698.             Connection cn = this.getConnection();
  699.  
  700.             for (Pref pref : prefs)
  701.             {
  702.                 PreparedStatement st = cn.prepareStatement(
  703.                     "INSERT INTO prefs (idg, key, value) VALUES (?, ?, ?) " +
  704.                     "ON DUPLICATE KEY UPDATE value = ?"
  705.                 );
  706.                 st.setInt(1, id);
  707.                 st.setString(2, pref.getKey());
  708.                 st.setString(3, pref.getValue());
  709.                 st.setString(4, pref.getValue());
  710.  
  711.  
  712.                 retour = st.executeUpdate();
  713.                 st.close();
  714.             }
  715.  
  716.             cn.close();
  717.         }
  718.         catch (Exception e) {
  719.             e.printStackTrace();
  720.         }
  721.  
  722.         return retour > 0;
  723.     }
  724.  
  725.     public Gadget[] getGadgetsByUser(int id)
  726.     {
  727.         List<Gadget> gadgets = new ArrayList<Gadget>();
  728.  
  729.         try
  730.         {
  731.             Connection cn = this.getConnection();
  732.  
  733.             PreparedStatement st = cn.prepareStatement(
  734.                 "SELECT id, idg, ido, title, col, row, idu FROM gadgets WHERE idu = ? ORDER BY row ASC, col ASC"
  735.             );
  736.             st.setInt(1, id);
  737.  
  738.             ResultSet rs = st.executeQuery();
  739.             while (rs.next()) {
  740.                 Gadget g = new Gadget(
  741.                     rs.getInt("id"), rs.getInt("idg"), rs.getInt("ido"), rs.getString("title"),
  742.                     rs.getInt("col"), rs.getInt("row"), rs.getInt("idu")
  743.                 );
  744.                 gadgets.add(g);
  745.             }
  746.  
  747.             rs.close();
  748.             st.close();
  749.             cn.close();
  750.         }
  751.         catch (Exception e) {
  752.             e.printStackTrace();
  753.         }
  754.  
  755.         //return gadgets;
  756.         return (Gadget[]) gadgets.toArray(new Gadget[0]);
  757.     }
  758.  
  759.     public Pref[] getPrefsByGadget(int id)
  760.     {
  761.         List<Pref> prefs = new ArrayList<Pref>();
  762.  
  763.         try
  764.         {
  765.             Connection cn = this.getConnection();
  766.  
  767.             PreparedStatement st = cn.prepareStatement(
  768.                 "SELECT 'key', 'value' FROM prefs WHERE idg = ?"
  769.             );
  770.             st.setInt(1, id);
  771.  
  772.             ResultSet rs = st.executeQuery();
  773.             while (rs.next()) {
  774.                 Pref pref = new Pref(rs.getString("key"), rs.getString("value"));
  775.                 prefs.add(pref);
  776.             }
  777.  
  778.             rs.close();
  779.             st.close();
  780.             cn.close();
  781.         }
  782.         catch (Exception e) {
  783.             e.printStackTrace();
  784.         }
  785.  
  786.         //return prefs;
  787.         return (Pref[]) prefs.toArray(new Pref[0]);
  788.     }
  789. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement