private void initProvider() { JiveGlobals.migrateProperty("provider.roster.className"); String className = JiveGlobals.getProperty("provider.roster.className", "org.jivesoftware.openfire.roster.DefaultRosterItemProvider"); if (provider == null || !className.equals(provider.getClass().getName())) { try { Class c = ClassUtils.forName(className); provider = (RosterItemProvider) c.newInstance(); } catch (Exception e) { Log.error("Error loading roster provider: " + className, e); provider = new DefaultRosterItemProvider(); } } }
@Override public void updateItem(String username, RosterItem item) { Connection con = null; PreparedStatement pstmt = null; long rosterID = item.getID(); try { con = DbConnectionManager.getConnection(); // Update existing roster item pstmt = con.prepareStatement(UPDATE_ROSTER_ITEM); pstmt.setInt(1, item.getSubStatus().getValue()); pstmt.setInt(2, item.getAskStatus().getValue()); pstmt.setInt(3, item.getRecvStatus().getValue()); pstmt.setString(4, item.getNickname()); pstmt.setLong(5, rosterID); pstmt.executeUpdate(); // Close now the statement (do not wait to be GC'ed) DbConnectionManager.fastcloseStmt(pstmt); // Delete old group list pstmt = con.prepareStatement(DELETE_ROSTER_ITEM_GROUPS); pstmt.setLong(1, rosterID); pstmt.executeUpdate(); insertGroups(rosterID, item.getGroups().iterator(), con); } catch (SQLException e) { Log.error(LocaleUtils.getLocalizedString("admin.error"), e); } finally { DbConnectionManager.closeConnection(pstmt, con); } }
@Override public RosterItem createItem(String username, RosterItem item) throws UserAlreadyExistsException { Connection con = null; PreparedStatement pstmt = null; try { long rosterID = SequenceManager.nextID(JiveConstants.ROSTER); con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(CREATE_ROSTER_ITEM); pstmt.setString(1, username); pstmt.setLong(2, rosterID); pstmt.setString(3, item.getJid().toBareJID()); pstmt.setInt(4, item.getSubStatus().getValue()); pstmt.setInt(5, item.getAskStatus().getValue()); pstmt.setInt(6, item.getRecvStatus().getValue()); pstmt.setString(7, item.getNickname()); pstmt.executeUpdate(); item.setID(rosterID); insertGroups(rosterID, item.getGroups().iterator(), con); } catch (SQLException e) { Log.warn("Error trying to insert a new row in ofRoster", e); throw new UserAlreadyExistsException(item.getJid().toBareJID()); } finally { DbConnectionManager.closeConnection(pstmt, con); } return item; }
private void initProvider() { JiveGlobals.migrateProperty("provider.roster.className"); String className = JiveGlobals.getProperty("provider.roster.className", "org.jivesoftware.openfire.roster.DefaultRosterItemProvider"); if (provider == null || !className.equals(provider.getClass().getName())) { try { Class c = ClassUtils.forName(className); provider = (RosterItemProvider) c.newInstance(); } catch (Exception e) { Log.error("Error loading roster provider: " + className, e); provider = new DefaultRosterItemProvider(); } } }
@Override public void updateItem(String username, RosterItem item) throws UserNotFoundException { Connection con = null; PreparedStatement pstmt = null; long rosterID = item.getID(); try { con = DbConnectionManager.getConnection(); // Update existing roster item pstmt = con.prepareStatement(UPDATE_ROSTER_ITEM); pstmt.setInt(1, item.getSubStatus().getValue()); pstmt.setInt(2, item.getAskStatus().getValue()); pstmt.setInt(3, item.getRecvStatus().getValue()); pstmt.setString(4, item.getNickname()); pstmt.setLong(5, rosterID); pstmt.executeUpdate(); // Close now the statement (do not wait to be GC'ed) DbConnectionManager.fastcloseStmt(pstmt); // Delete old group list pstmt = con.prepareStatement(DELETE_ROSTER_ITEM_GROUPS); pstmt.setLong(1, rosterID); pstmt.executeUpdate(); insertGroups(rosterID, item.getGroups().iterator(), con); } catch (SQLException e) { Log.error(LocaleUtils.getLocalizedString("admin.error"), e); } finally { DbConnectionManager.closeConnection(pstmt, con); } }
@Override public RosterItem createItem(String username, RosterItem item) throws UserAlreadyExistsException { Connection con = null; PreparedStatement pstmt = null; try { long rosterID = SequenceManager.nextID(JiveConstants.ROSTER); con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(CREATE_ROSTER_ITEM); pstmt.setString(1, username); pstmt.setLong(2, rosterID); pstmt.setString(3, item.getJid().toBareJID()); pstmt.setInt(4, item.getSubStatus().getValue()); pstmt.setInt(5, item.getAskStatus().getValue()); pstmt.setInt(6, item.getRecvStatus().getValue()); pstmt.setString(7, item.getNickname()); pstmt.executeUpdate(); item.setID(rosterID); insertGroups(rosterID, item.getGroups().iterator(), con); } catch (SQLException e) { Log.warn("Error trying to insert a new row in ofRoster", e); throw new UserAlreadyExistsException(item.getJid().toBareJID()); } finally { DbConnectionManager.closeConnection(pstmt, con); } return item; }