Advertisement
Guest User

Untitled

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