OWLCS Parlay X Presence Custom Error Codes

8-10 Developers Guide

8.7.1.3 Adding a Buddy to a Buddy List and Retrieving the List

Adding a buddy to a buddy list is done by first creating a buddy, setting the information needed on that buddy and then using the BLM to add it to the buddy list. Example 8–3 shows how to use the BLM representing Alice to add Bob as a new buddy of Alice and then getting the updated list back. Example 8–3 Adding a New Buddy to the Buddy List of Alice URI uri = new URIsip:bobexample.com; Buddy bob = manager.createBuddyuri; Optionally, setting additional information. manager.setDisplaynameBobby; VCard vcard = bob.getVCard; vcard.setCitySan Francisco; vcard.setCountryUSA; very important to set the VCard back on the buddy again bob.setVCardvcard; Update the buddy info using the BLM manager.updateBuddybob; Getting the updated buddy list ListBuddy buddies = manager.getBuddies; Example 8–3 shows how to create a new Buddy, Bob, and how that buddy is added to Alices buddy list by using the BLM representing Alice. To add more information about the user Bob, such as the address and other information, access Bobs Vcard information and then set the appropriate properties.

8.7.1.4 Removing a Buddy from a Buddy List

Removing a buddy is very similar to adding a buddy. Use the method removeBuddy and pass in the buddy that is to be removed. If there are many buddies to remove, use the removeBuddies method and pass in the list of buddies to remove. Example 8–4 shows how Bob is removed from Alices buddy list. Example 8–4 Removing a Buddy URI uri = new URIsip:bobexample.com; Buddy bob = manager.createBuddyuri; manager.removeBuddybob;

8.7.1.5 Manipulating your presence rules document

To allow a watcher to view the presence status, use the method allowWatcherString watcher to add the watcher to the allow list. Use blockWatcherString watcher to block someone from viewing your presence status. Example 8–5 Allowing or blocking watchers manager.allowWatchersip:bobexample.com; manager.blockWatchersip:carolexample.com; Note: Since the method getVCard is actually returning a clone of the VCard, the method setVCard must be called on the buddy again in order for the information to be updated. Parlay X Presence Web Services 8-11

8.7.2 Exceptions

BuddyListException is the base exception, and if the program is not set to register the specific exception, then it can simply catch it. XDMException is the base exception for all exceptions concerning communication with the remote XDMS. XDMException signals that an error occurred when communicating with the XDMS for example: a connection problem, wrong path to the XCAP root, or something else. DocumentConflictException is a subclass to the XDMException; it signals that a mid-air conflict was detected that could not be resolved. This can occur when multiple clients access the same document on the XDMS. BuddyListManager attempts to resolve such a clash, but if it cannot, it throws an exception.