ContactExchange.Item.Action action = null;
if (item.getAction() == null || item.getAction() == ContactExchange.Item.Action.ADD) {
// If the contact does not exist yes, add it and request subscription.
// (After completing the roster set, the receiving application SHOULD also send a <presence/> stanza of type "subscribe" to the JID of the new item.)
if (contact == null) {
rosterManager.addContact(new Contact(item.getJid(), item.getName(), item.getGroups()), true, null);
action = ContactExchange.Item.Action.ADD;
} else {
List<String> newGroups = new ArrayList<>(contact.getGroups());
List<String> additionalGroups = new ArrayList<>(item.getGroups());
// Remove all existing groups from the list.