From: Sandy M. <san...@us...> - 2006-02-01 20:09:56
|
Update of /cvsroot/gatormail/GatorMail/src/java/edu/ufl/osg/webmail/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv667/src/java/edu/ufl/osg/webmail/data Modified Files: AddressBkDAO_DB.java ConfigDAO_FILE.java Log Message: Code cleanups discovered by FindBugs 0.9.4 and by IDEA. Index: ConfigDAO_FILE.java =================================================================== RCS file: /cvsroot/gatormail/GatorMail/src/java/edu/ufl/osg/webmail/data/ConfigDAO_FILE.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ConfigDAO_FILE.java 22 Feb 2004 08:00:04 -0000 1.2 --- ConfigDAO_FILE.java 1 Feb 2006 20:09:44 -0000 1.3 *************** *** 39,43 **** props = new Properties(); try { ! props.load(this.getClass().getResourceAsStream(propPath)); } catch (IOException ioe) { logger.error(ioe.toString()); --- 39,43 ---- props = new Properties(); try { ! props.load(ConfigDAO_FILE.class.getResourceAsStream(propPath)); } catch (IOException ioe) { logger.error(ioe.toString()); Index: AddressBkDAO_DB.java =================================================================== RCS file: /cvsroot/gatormail/GatorMail/src/java/edu/ufl/osg/webmail/data/AddressBkDAO_DB.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AddressBkDAO_DB.java 9 Sep 2005 17:07:07 -0000 1.4 --- AddressBkDAO_DB.java 1 Feb 2006 20:09:44 -0000 1.5 *************** *** 64,68 **** protected AddressBkDAO_DB() throws AddressBkDAOException { ! ConfigDAO configDAO = null; try { configDAO = DAOFactory.getInstance().getConfigDAO(); --- 64,68 ---- protected AddressBkDAO_DB() throws AddressBkDAOException { ! final ConfigDAO configDAO; try { configDAO = DAOFactory.getInstance().getConfigDAO(); *************** *** 129,140 **** try { con = getConnection(); ! final PreparedStatement ps = con.prepareStatement("SELECT entry " + "FROM addressbook " + "WHERE userid = ?"); ! ps.setString(1, permId); ! final ResultSet rs = ps.executeQuery(); ! while (rs.next()) { ! try { ! coll.add(new InternetAddress(rs.getString(1))); ! } catch (AddressException e) { ! e.printStackTrace(); //To change body of catch statement use Options | File Templates. } } --- 129,147 ---- try { con = getConnection(); ! PreparedStatement ps = null; ! try { ! ps = con.prepareStatement("SELECT entry " + "FROM addressbook " + "WHERE userid = ?"); ! ps.setString(1, permId); ! final ResultSet rs = ps.executeQuery(); ! while (rs.next()) { ! try { ! coll.add(new InternetAddress(rs.getString(1))); ! } catch (AddressException e) { ! e.printStackTrace(); //To change body of catch statement use Options | File Templates. ! } ! } ! } finally { ! if (ps != null) { ! ps.close(); } } *************** *** 143,148 **** logger.error("Problem in getAddressList", e); try { ! if (con != null) con.close(); } catch (SQLException se) { logger.error(se.getMessage(), se); --- 150,156 ---- logger.error("Problem in getAddressList", e); try { ! if (con != null) { con.close(); + } } catch (SQLException se) { logger.error(se.getMessage(), se); *************** *** 159,175 **** try { con = getConnection(); ! final PreparedStatement ps = con.prepareStatement("INSERT INTO addressbook " + "(userid, entry) " + "VALUES (?, ?)"); ! ps.setString(1, permId); ! ps.setString(2, internetAddress.toString()); ! final int count = ps.executeUpdate(); ! if (count == 0) { ! throw new AddressBkDAOException("Address book insert failed for entry: " + internetAddress.toString()); } con.close(); } catch (Exception e) { try { ! if (con != null) con.close(); } catch (SQLException se) { logger.error(se.getMessage(), se); --- 167,191 ---- try { con = getConnection(); ! PreparedStatement ps = null; ! try { ! ps = con.prepareStatement("INSERT INTO addressbook " + "(userid, entry) " + "VALUES (?, ?)"); ! ps.setString(1, permId); ! ps.setString(2, internetAddress.toString()); ! final int count = ps.executeUpdate(); ! if (count == 0) { ! throw new AddressBkDAOException("Address book insert failed for entry: " + internetAddress.toString()); ! } ! } finally { ! if (ps != null) { ! ps.close(); ! } } con.close(); } catch (Exception e) { try { ! if (con != null) { con.close(); + } } catch (SQLException se) { logger.error(se.getMessage(), se); *************** *** 183,200 **** try { con = getConnection(); ! final PreparedStatement ps = con.prepareStatement("DELETE FROM addressbook " + "WHERE userid = ? " + "AND entry = ?"); ! ps.setString(1, permId); ! ps.setString(2, internetAddress.toString()); ! final int count = ps.executeUpdate(); ! if (count == 0) { ! logger.error("address book delete failed. permId: " + permId + ", entry: " + internetAddress.toString()); ! throw new AddressBkDAOException("Address book delete failed for entry: " + internetAddress.toString()); } con.close(); } catch (Exception e) { try { ! if (con != null) con.close(); } catch (SQLException se) { logger.error(se.getMessage(), se); --- 199,224 ---- try { con = getConnection(); ! PreparedStatement ps = null; ! try { ! ps = con.prepareStatement("DELETE FROM addressbook " + "WHERE userid = ? " + "AND entry = ?"); ! ps.setString(1, permId); ! ps.setString(2, internetAddress.toString()); ! final int count = ps.executeUpdate(); ! if (count == 0) { ! logger.error("address book delete failed. permId: " + permId + ", entry: " + internetAddress.toString()); ! throw new AddressBkDAOException("Address book delete failed for entry: " + internetAddress.toString()); ! } ! } finally { ! if (ps != null) { ! ps.close(); ! } } con.close(); } catch (Exception e) { try { ! if (con != null) { con.close(); + } } catch (SQLException se) { logger.error(se.getMessage(), se); |