Wildfire 3.2.4 Javadoc

org.jivesoftware.wildfire.roster
Class RosterItemProvider

java.lang.Object
  extended by org.jivesoftware.wildfire.roster.RosterItemProvider

public class RosterItemProvider
extends Object

Defines the provider methods required for creating, reading, updating and deleting roster items.

Rosters are another user resource accessed via the user or chatbot's long ID. A user/chatbot may have zero or more roster items and each roster item may have zero or more groups. Each roster item is additionaly keyed on a XMPP jid. In most cases, the entire roster will be read in from memory and manipulated or sent to the user. However some operations will need to retrive specific roster items rather than the entire roster.

Author:
Iain Shigeoka

Constructor Summary
RosterItemProvider()
           
 
Method Summary
 RosterItem createItem(String username, RosterItem item)
          Creates a new roster item for the given user (optional operation).
 void deleteItem(String username, long rosterItemID)
          Delete the roster item with the given itemJID for the user (optional operation).
static RosterItemProvider getInstance()
           
 int getItemCount(String username)
          Obtain a count of the number of roster items available for the given user.
 Iterator<RosterItem> getItems(String username)
          Retrieve an iterator of RosterItems for the given user.
 Iterator<String> getUsernames(String jid)
          Returns an iterator on the usernames whose roster includes the specified JID.
 void updateItem(String username, RosterItem item)
          Update the roster item in storage with the information contained in the given item (optional operation).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RosterItemProvider

public RosterItemProvider()
Method Detail

getInstance

public static RosterItemProvider getInstance()

createItem

public RosterItem createItem(String username,
                             RosterItem item)
                      throws UserAlreadyExistsException
Creates a new roster item for the given user (optional operation).

Important! The item passed as a parameter to this method is strictly a convenience for passing all of the data needed for a new roster item. The roster item returned from the method will be cached by Wildfire. In some cases, the roster item passed in will be passed back out. However, if an implementation may return RosterItems as a separate class (for example, a RosterItem that directly accesses the backend storage, or one that is an object in an object database).

Parameters:
username - the username of the user/chatbot that owns the roster item.
item - the settings for the roster item to create.
Returns:
the new roster item.
Throws:
UserAlreadyExistsException - if a roster item with the username already exists.

updateItem

public void updateItem(String username,
                       RosterItem item)
                throws UserNotFoundException
Update the roster item in storage with the information contained in the given item (optional operation).

If you don't want roster items edited through wildfire, throw UnsupportedOperationException.

Parameters:
username - the username of the user/chatbot that owns the roster item
item - The roster item to update
Throws:
UserNotFoundException - If no entry could be found to update

deleteItem

public void deleteItem(String username,
                       long rosterItemID)
Delete the roster item with the given itemJID for the user (optional operation).

If you don't want roster items deleted through wildfire, throw UnsupportedOperationException.

Parameters:
username - the long ID of the user/chatbot that owns the roster item
rosterItemID - The roster item to delete

getUsernames

public Iterator<String> getUsernames(String jid)
Returns an iterator on the usernames whose roster includes the specified JID.

Parameters:
jid - the jid that the rosters should include.
Returns:
an iterator on the usernames whose roster includes the specified JID.

getItemCount

public int getItemCount(String username)
Obtain a count of the number of roster items available for the given user.

Parameters:
username - the username of the user/chatbot that owns the roster items
Returns:
The number of roster items available for the user

getItems

public Iterator<RosterItem> getItems(String username)
Retrieve an iterator of RosterItems for the given user.

This method will commonly be called when a user logs in. The data will be cached in memory when possible. However, some rosters may be very large so items may need to be retrieved from the provider more frequently than usual for provider data.

Parameters:
username - the username of the user/chatbot that owns the roster items
Returns:
An iterator of all RosterItems owned by the user

Wildfire 3.2.4 Javadoc

Copyright © 2003-2007 Jive Software.