Userservice plugin leaves user roster items in DB when user is deleted

Description

Quoute form igniterealtime
"I am removing account it is not really removing rosters from that account. Later, when I will add account with same name it has already rosters in his roster list (same as before deleting account)."

Environment

None

Activity

Show:
Dele Olajide
December 15, 2013, 5:53 PM
Edited

This works better

public void deleteUser(String username) throws UserNotFoundException, SharedGroupException
{
User user = getUser(username);
userManager.deleteUser(user);

rosterManager.deleteRoster(server.createJID(username, null));
}

Dele Olajide
December 15, 2013, 3:40 PM

This is the change I am making. To iterate the roster of the user and delete all roster items before deleting the actual user and thereby ensuring DB referential integrity.

public void deleteUser(String username) throws UserNotFoundException, SharedGroupException
{
Roster r = rosterManager.getRoster(username);

Collection<RosterItem> rosterItems = r.getRosterItems();

for (RosterItem rosterItem: rosterItems)
{
r.deleteRosterItem(rosterItem.getJid(), true);
}

User user = getUser(username);
userManager.deleteUser(user);
}

Fixed

Assignee

Dele Olajide

Reporter

Dele Olajide