@@ -1668,6 +1668,61 @@ public int countNodeThreads(String node) throws NodeStoreException {
16681668 close (selectStatement );
16691669 }
16701670 }
1671+
1672+ @ Override
1673+ public void jidOnline (JID jid ) throws NodeStoreException {
1674+ PreparedStatement addStatement = null ;
1675+ try {
1676+ jidOffline (jid );
1677+ addStatement = conn .prepareStatement (dialect .addOnlineJid ());
1678+ addStatement .setString (1 , jid .toFullJID ());
1679+ addStatement .executeUpdate ();
1680+ addStatement .close ();
1681+ } catch (SQLException e ) {
1682+ throw new NodeStoreException (e );
1683+ } finally {
1684+ close (addStatement );
1685+ }
1686+ }
1687+
1688+ @ Override
1689+ public void jidOffline (JID jid ) throws NodeStoreException {
1690+ PreparedStatement stmt = null ;
1691+ try {
1692+ stmt = conn .prepareStatement (dialect .deleteOnlineJid ());
1693+ stmt .setString (1 , jid .toFullJID ());
1694+ stmt .executeUpdate ();
1695+ } catch (SQLException e ) {
1696+ throw new NodeStoreException (e );
1697+ } finally {
1698+ close (stmt ); // Will implicitly close the resultset if required
1699+ }
1700+ }
1701+
1702+ @ Override
1703+ public ArrayList <JID > onlineJids (JID jid ) throws NodeStoreException {
1704+ PreparedStatement stmt = null ;
1705+
1706+ try {
1707+ stmt = conn .prepareStatement (dialect .selectOnlineResources ());
1708+
1709+ stmt .setString (1 , jid .toBareJID () + "%" );
1710+
1711+ java .sql .ResultSet rs = stmt .executeQuery ();
1712+
1713+ ArrayList <JID > result = new ArrayList <JID >();
1714+
1715+ while (rs .next ()) {
1716+ result .add (new JID (rs .getString (1 )));
1717+ }
1718+
1719+ return result ;
1720+ } catch (SQLException e ) {
1721+ throw new NodeStoreException (e );
1722+ } finally {
1723+ close (stmt ); // Will implicitly close the resultset if required
1724+ }
1725+ }
16711726
16721727 @ Override
16731728 public Transaction beginTransaction () throws NodeStoreException {
@@ -1799,6 +1854,12 @@ private String getLocalId(String nodeItemId) {
17991854 public interface NodeStoreSQLDialect {
18001855 String insertNode ();
18011856
1857+ String addOnlineJid ();
1858+
1859+ String deleteOnlineJid ();
1860+
1861+ String selectOnlineResources ();
1862+
18021863 String selectNodeMemberships ();
18031864
18041865 String selectUserMemberships ();
@@ -1934,7 +1995,7 @@ public interface NodeStoreSQLDialect {
19341995 String selectUserFeedItems ();
19351996
19361997 String selectCountUserFeedItems ();
1937-
1998+
19381999 }
19392000
19402001}
0 commit comments