/** * Updated the existing privacy list in the database. * * @param username the username of the user that updated a privacy list. * @param list the PrivacyList to update in the database. */ public void updatePrivacyList(String username, PrivacyList list) { Connection con = null; PreparedStatement pstmt = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(UPDATE_PRIVACY_LIST); pstmt.setInt(1, (list.isDefault() ? 1 : 0)); pstmt.setString(2, list.asElement().asXML()); pstmt.setString(3, username); pstmt.setString(4, list.getName()); pstmt.executeUpdate(); } catch (Exception e) { Log.error("Error updating privacy list: " + list.getName() + " of username: " + username, e); } finally { DbConnectionManager.closeConnection(pstmt, con); } }
/** * Creates and saves the new privacy list to the database. * * @param username the username of the user that created a new privacy list. * @param list the PrivacyList to save. */ public void createPrivacyList(String username, PrivacyList list) { Connection con = null; PreparedStatement pstmt = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(INSERT_PRIVACY_LIST); pstmt.setString(1, username); pstmt.setString(2, list.getName()); pstmt.setInt(3, (list.isDefault() ? 1 : 0)); pstmt.setString(4, list.asElement().asXML()); pstmt.executeUpdate(); } catch (Exception e) { Log.error("Error adding privacy list: " + list.getName() + " of username: "******"0", which is the case we care about. privacyListCount.set(-1); }