I have written a plugin to add/remove contacts via a web-interface. The plugin uses RosterItemProvider to do the add/remove part.
What I am seeing is that although the updates make it to the database fine - if a IM client logs in (e.g. via Spark) - their contact list hasn’'t been updated. Only after I restart openfire do the updates flow through to the client.
I am thinking this is due to the roster cache - but logic would tell me that if I am going via RosterItemProvider (and not directly to the database) that both the cache and db would get updated.
Instead of working with the RosterItemProvider it’‘s better to retrieve the User whose roster you’'re altering and make changes to it directly, that way any changes you make will “flow” to the client and their roster. To quote the Roster javadocs:
Updates to this roster is effectively a change to the user’'s roster. To reflect this, the changes to this class will automatically update the persistently stored roster, as well as send out update announcements to all logged in user sessions.