I developed a VCard plugin for OpenFire XMPP server with the main purpose of creating/updating and retrieving users' avatars via HTTP requests. Unfortunately, the plugin does not work as expected - VCard changes are propogated into the database (ofVcard
table), but neither the user whose userpic was updated nor his buddies see the refreshed image. Here is how I create/update the VCards:
...
XMPPServer server = XMPPServer.getInstance();
VCardManager vcardManager = server.getVCardManager();
public void createOrUpdateVcard(String username, String vcard)
throws Exception {
SAXReader reader = new SAXReader();
reader.setValidation(false);
// convert String into InputStream
InputStream is = new ByteArrayInputStream(vcard.getBytes());
// read it with BufferedReader
BufferedReader br = new BufferedReader(new InputStreamReader(is));
try {
// Reading malformed XML will lead to DocumentException
Document document = reader.read(is);
Element vCardElement = document.getRootElement();
log.info("Username: " + username);
vcardManager.setVCard(username, vCardElement);
} catch (DocumentException e) {
throw new MalformedXmlException(e);
}
}
...
When I change avatars directly from the client (we are using Jitsi), the changes are not only immediately stored in the database, but all the buddies get the refreshed image. I see that VCardManager
, which I use, dispatches events internally:
VCardEventDispatcher.dispatchVCardUpdated(username, newvCard);
but they seem not to have any effect.
I cannot figure out what is the difference between the way the setVcard
method is called from the handleIQ(IQ packet)
in IQvCardHandler
and in my own code. What am I missing?