mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-10-31 17:25:58 +01:00
Improve Roster API
Make Roster entries Map from BareJid to RosterEntry, since only bare JIDs are allowed as roster items as per RFC 6121 § 3.1.1 When a user sends a presence subscription request to a potential instant messaging and presence contact, the value of the 'to' attribute MUST be a bare JID <contact@domainpart> rather than a full JID <contact@domainpart/resourcepart>,… Also some further Roster API changes regarding JIDs.
This commit is contained in:
parent
c125a3b055
commit
1d1ea5dd10
11 changed files with 109 additions and 84 deletions
|
@ -63,6 +63,7 @@ import org.jivesoftware.smack.roster.packet.RosterPacket.Item;
|
||||||
import org.jivesoftware.smack.roster.packet.SubscriptionPreApproval;
|
import org.jivesoftware.smack.roster.packet.SubscriptionPreApproval;
|
||||||
import org.jivesoftware.smack.roster.rosterstore.RosterStore;
|
import org.jivesoftware.smack.roster.rosterstore.RosterStore;
|
||||||
import org.jivesoftware.smack.util.Objects;
|
import org.jivesoftware.smack.util.Objects;
|
||||||
|
import org.jxmpp.jid.BareJid;
|
||||||
import org.jxmpp.jid.EntityBareJid;
|
import org.jxmpp.jid.EntityBareJid;
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.Jid;
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
@ -104,7 +105,7 @@ public final class Roster extends Manager {
|
||||||
* <p>
|
* <p>
|
||||||
* This method will never return <code>null</code>, instead if the user has not yet logged into
|
* This method will never return <code>null</code>, instead if the user has not yet logged into
|
||||||
* the server all modifying methods of the returned roster object
|
* the server all modifying methods of the returned roster object
|
||||||
* like {@link Roster#createEntry(Jid, String, String[])},
|
* like {@link Roster#createEntry(BareJid, String, String[])},
|
||||||
* {@link Roster#removeEntry(RosterEntry)} , etc. except adding or removing
|
* {@link Roster#removeEntry(RosterEntry)} , etc. except adding or removing
|
||||||
* {@link RosterListener}s will throw an IllegalStateException.
|
* {@link RosterListener}s will throw an IllegalStateException.
|
||||||
* </p>
|
* </p>
|
||||||
|
@ -136,7 +137,7 @@ public final class Roster extends Manager {
|
||||||
/**
|
/**
|
||||||
* Concurrent hash map from JID to its roster entry.
|
* Concurrent hash map from JID to its roster entry.
|
||||||
*/
|
*/
|
||||||
private final Map<Jid, RosterEntry> entries = new ConcurrentHashMap<>();
|
private final Map<BareJid, RosterEntry> entries = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final Set<RosterEntry> unfiledEntries = new CopyOnWriteArraySet<>();
|
private final Set<RosterEntry> unfiledEntries = new CopyOnWriteArraySet<>();
|
||||||
private final Set<RosterListener> rosterListeners = new LinkedHashSet<>();
|
private final Set<RosterListener> rosterListeners = new LinkedHashSet<>();
|
||||||
|
@ -497,7 +498,7 @@ public final class Roster extends Manager {
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
public void createEntry(Jid user, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
public void createEntry(BareJid user, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
final XMPPConnection connection = getAuthenticatedConnectionOrThrow();
|
final XMPPConnection connection = getAuthenticatedConnectionOrThrow();
|
||||||
|
|
||||||
// Create and send roster entry creation packet.
|
// Create and send roster entry creation packet.
|
||||||
|
@ -536,7 +537,7 @@ public final class Roster extends Manager {
|
||||||
* @throws FeatureNotSupportedException if pre-approving is not supported.
|
* @throws FeatureNotSupportedException if pre-approving is not supported.
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
public void preApproveAndCreateEntry(Jid user, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, FeatureNotSupportedException {
|
public void preApproveAndCreateEntry(BareJid user, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, FeatureNotSupportedException {
|
||||||
preApprove(user);
|
preApprove(user);
|
||||||
createEntry(user, name, groups);
|
createEntry(user, name, groups);
|
||||||
}
|
}
|
||||||
|
@ -608,7 +609,7 @@ public final class Roster extends Manager {
|
||||||
|
|
||||||
// Only remove the entry if it's in the entry list.
|
// Only remove the entry if it's in the entry list.
|
||||||
// The actual removal logic takes place in RosterPacketListenerprocess>>Packet(Packet)
|
// The actual removal logic takes place in RosterPacketListenerprocess>>Packet(Packet)
|
||||||
if (!entries.containsKey(entry.getUser())) {
|
if (!entries.containsKey(entry.getJid())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RosterPacket packet = new RosterPacket();
|
RosterPacket packet = new RosterPacket();
|
||||||
|
@ -1125,18 +1126,18 @@ public final class Roster extends Manager {
|
||||||
Collection<Jid> unchangedEntries, RosterPacket.Item item, RosterEntry entry) {
|
Collection<Jid> unchangedEntries, RosterPacket.Item item, RosterEntry entry) {
|
||||||
RosterEntry oldEntry;
|
RosterEntry oldEntry;
|
||||||
synchronized (rosterListenersAndEntriesLock) {
|
synchronized (rosterListenersAndEntriesLock) {
|
||||||
oldEntry = entries.put(item.getUser(), entry);
|
oldEntry = entries.put(item.getJid(), entry);
|
||||||
}
|
}
|
||||||
if (oldEntry == null) {
|
if (oldEntry == null) {
|
||||||
addedEntries.add(item.getUser());
|
addedEntries.add(item.getJid());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
RosterPacket.Item oldItem = RosterEntry.toRosterItem(oldEntry);
|
RosterPacket.Item oldItem = RosterEntry.toRosterItem(oldEntry);
|
||||||
if (!oldEntry.equalsDeep(entry) || !item.getGroupNames().equals(oldItem.getGroupNames())) {
|
if (!oldEntry.equalsDeep(entry) || !item.getGroupNames().equals(oldItem.getGroupNames())) {
|
||||||
updatedEntries.add(item.getUser());
|
updatedEntries.add(item.getJid());
|
||||||
} else {
|
} else {
|
||||||
// Record the entry as unchanged, so that it doesn't end up as deleted entry
|
// Record the entry as unchanged, so that it doesn't end up as deleted entry
|
||||||
unchangedEntries.add(item.getUser());
|
unchangedEntries.add(item.getJid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1181,7 +1182,7 @@ public final class Roster extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteEntry(Collection<Jid> deletedEntries, RosterEntry entry) {
|
private void deleteEntry(Collection<Jid> deletedEntries, RosterEntry entry) {
|
||||||
Jid user = entry.getUser();
|
Jid user = entry.getJid();
|
||||||
entries.remove(user);
|
entries.remove(user);
|
||||||
unfiledEntries.remove(entry);
|
unfiledEntries.remove(entry);
|
||||||
presenceMap.remove(user);
|
presenceMap.remove(user);
|
||||||
|
@ -1393,7 +1394,7 @@ public final class Roster extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RosterPacket.Item item : validItems) {
|
for (RosterPacket.Item item : validItems) {
|
||||||
RosterEntry entry = new RosterEntry(item.getUser(), item.getName(),
|
RosterEntry entry = new RosterEntry(item.getJid(), item.getName(),
|
||||||
item.getItemType(), item.getItemStatus(), item.isApproved(), Roster.this, connection);
|
item.getItemType(), item.getItemStatus(), item.isApproved(), Roster.this, connection);
|
||||||
addUpdateEntry(addedEntries, updatedEntries, unchangedEntries, item, entry);
|
addUpdateEntry(addedEntries, updatedEntries, unchangedEntries, item, entry);
|
||||||
}
|
}
|
||||||
|
@ -1401,7 +1402,7 @@ public final class Roster extends Manager {
|
||||||
// Delete all entries which where not added or updated
|
// Delete all entries which where not added or updated
|
||||||
Set<Jid> toDelete = new HashSet<>();
|
Set<Jid> toDelete = new HashSet<>();
|
||||||
for (RosterEntry entry : entries.values()) {
|
for (RosterEntry entry : entries.values()) {
|
||||||
toDelete.add(entry.getUser());
|
toDelete.add(entry.getJid());
|
||||||
}
|
}
|
||||||
toDelete.removeAll(addedEntries);
|
toDelete.removeAll(addedEntries);
|
||||||
toDelete.removeAll(updatedEntries);
|
toDelete.removeAll(updatedEntries);
|
||||||
|
@ -1423,7 +1424,7 @@ public final class Roster extends Manager {
|
||||||
// version we presented the server. So we simply load the roster from the store and
|
// version we presented the server. So we simply load the roster from the store and
|
||||||
// await possible further roster pushes.
|
// await possible further roster pushes.
|
||||||
for (RosterPacket.Item item : rosterStore.getEntries()) {
|
for (RosterPacket.Item item : rosterStore.getEntries()) {
|
||||||
RosterEntry entry = new RosterEntry(item.getUser(), item.getName(),
|
RosterEntry entry = new RosterEntry(item.getJid(), item.getName(),
|
||||||
item.getItemType(), item.getItemStatus(), item.isApproved(), Roster.this, connection);
|
item.getItemType(), item.getItemStatus(), item.isApproved(), Roster.this, connection);
|
||||||
addUpdateEntry(addedEntries, updatedEntries, unchangedEntries, item, entry);
|
addUpdateEntry(addedEntries, updatedEntries, unchangedEntries, item, entry);
|
||||||
}
|
}
|
||||||
|
@ -1493,14 +1494,14 @@ public final class Roster extends Manager {
|
||||||
// We assured above that the size of items is exaclty 1, therefore we are able to
|
// We assured above that the size of items is exaclty 1, therefore we are able to
|
||||||
// safely retrieve this single item here.
|
// safely retrieve this single item here.
|
||||||
Item item = items.iterator().next();
|
Item item = items.iterator().next();
|
||||||
RosterEntry entry = new RosterEntry(item.getUser(), item.getName(),
|
RosterEntry entry = new RosterEntry(item.getJid(), item.getName(),
|
||||||
item.getItemType(), item.getItemStatus(), item.isApproved(), Roster.this, connection);
|
item.getItemType(), item.getItemStatus(), item.isApproved(), Roster.this, connection);
|
||||||
String version = rosterPacket.getVersion();
|
String version = rosterPacket.getVersion();
|
||||||
|
|
||||||
if (item.getItemType().equals(RosterPacket.ItemType.remove)) {
|
if (item.getItemType().equals(RosterPacket.ItemType.remove)) {
|
||||||
deleteEntry(deletedEntries, entry);
|
deleteEntry(deletedEntries, entry);
|
||||||
if (rosterStore != null) {
|
if (rosterStore != null) {
|
||||||
rosterStore.removeEntry(entry.getUser(), version);
|
rosterStore.removeEntry(entry.getJid(), version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (hasValidSubscriptionType(item)) {
|
else if (hasValidSubscriptionType(item)) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.roster.packet.RosterPacket;
|
import org.jivesoftware.smack.roster.packet.RosterPacket;
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.BareJid;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +43,7 @@ public final class RosterEntry extends Manager {
|
||||||
/**
|
/**
|
||||||
* The JID of the entity/user.
|
* The JID of the entity/user.
|
||||||
*/
|
*/
|
||||||
private final Jid user;
|
private final BareJid jid;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private RosterPacket.ItemType type;
|
private RosterPacket.ItemType type;
|
||||||
|
@ -61,10 +61,10 @@ public final class RosterEntry extends Manager {
|
||||||
* @param approved the pre-approval flag.
|
* @param approved the pre-approval flag.
|
||||||
* @param connection a connection to the XMPP server.
|
* @param connection a connection to the XMPP server.
|
||||||
*/
|
*/
|
||||||
RosterEntry(Jid user, String name, RosterPacket.ItemType type,
|
RosterEntry(BareJid user, String name, RosterPacket.ItemType type,
|
||||||
RosterPacket.ItemStatus status, boolean approved, Roster roster, XMPPConnection connection) {
|
RosterPacket.ItemStatus status, boolean approved, Roster roster, XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
this.user = user;
|
this.jid = user;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
@ -76,9 +76,20 @@ public final class RosterEntry extends Manager {
|
||||||
* Returns the JID of the user associated with this entry.
|
* Returns the JID of the user associated with this entry.
|
||||||
*
|
*
|
||||||
* @return the user associated with this entry.
|
* @return the user associated with this entry.
|
||||||
|
* @deprecated use {@link #getJid()} instead.
|
||||||
*/
|
*/
|
||||||
public Jid getUser() {
|
@Deprecated
|
||||||
return user;
|
public String getUser() {
|
||||||
|
return jid.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the JID associated with this entry.
|
||||||
|
*
|
||||||
|
* @return the user associated with this entry.
|
||||||
|
*/
|
||||||
|
public BareJid getJid() {
|
||||||
|
return jid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -184,7 +195,7 @@ public final class RosterEntry extends Manager {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
buf.append(name).append(": ");
|
buf.append(name).append(": ");
|
||||||
}
|
}
|
||||||
buf.append(user);
|
buf.append(jid);
|
||||||
Collection<RosterGroup> groups = getGroups();
|
Collection<RosterGroup> groups = getGroups();
|
||||||
if (!groups.isEmpty()) {
|
if (!groups.isEmpty()) {
|
||||||
buf.append(" [");
|
buf.append(" [");
|
||||||
|
@ -203,7 +214,7 @@ public final class RosterEntry extends Manager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return (user == null ? 0 : user.hashCode());
|
return (jid == null ? 0 : jid.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
|
@ -211,7 +222,7 @@ public final class RosterEntry extends Manager {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (object != null && object instanceof RosterEntry) {
|
if (object != null && object instanceof RosterEntry) {
|
||||||
return user.equals(((RosterEntry)object).getUser());
|
return jid.equals(((RosterEntry)object).getUser());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -253,11 +264,11 @@ public final class RosterEntry extends Manager {
|
||||||
}
|
}
|
||||||
else if (!type.equals(other.type))
|
else if (!type.equals(other.type))
|
||||||
return false;
|
return false;
|
||||||
if (user == null) {
|
if (jid == null) {
|
||||||
if (other.user != null)
|
if (other.jid != null)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (!user.equals(other.user))
|
else if (!jid.equals(other.jid))
|
||||||
return false;
|
return false;
|
||||||
if (approved != other.approved)
|
if (approved != other.approved)
|
||||||
return false;
|
return false;
|
||||||
|
@ -269,7 +280,7 @@ public final class RosterEntry extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RosterPacket.Item toRosterItem(RosterEntry entry, String name) {
|
private static RosterPacket.Item toRosterItem(RosterEntry entry, String name) {
|
||||||
RosterPacket.Item item = new RosterPacket.Item(entry.getUser(), name);
|
RosterPacket.Item item = new RosterPacket.Item(entry.getJid(), name);
|
||||||
item.setItemType(entry.getType());
|
item.setItemType(entry.getType());
|
||||||
item.setItemStatus(entry.getStatus());
|
item.setItemStatus(entry.getStatus());
|
||||||
item.setApproved(entry.isApproved());
|
item.setApproved(entry.isApproved());
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jivesoftware.smack.roster;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jivesoftware.smack.PacketCollector;
|
import org.jivesoftware.smack.PacketCollector;
|
||||||
|
@ -30,7 +29,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.roster.packet.RosterPacket;
|
import org.jivesoftware.smack.roster.packet.RosterPacket;
|
||||||
import org.jxmpp.util.XmppStringUtils;
|
import org.jxmpp.jid.Jid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A group of roster entries.
|
* A group of roster entries.
|
||||||
|
@ -120,17 +119,16 @@ public class RosterGroup {
|
||||||
* @param user the XMPP address of the user (eg "jsmith@example.com").
|
* @param user the XMPP address of the user (eg "jsmith@example.com").
|
||||||
* @return the roster entry or <tt>null</tt> if it does not exist in the group.
|
* @return the roster entry or <tt>null</tt> if it does not exist in the group.
|
||||||
*/
|
*/
|
||||||
public RosterEntry getEntry(String user) {
|
public RosterEntry getEntry(Jid user) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Roster entries never include a resource so remove the resource
|
// Roster entries never include a resource so remove the resource
|
||||||
// if it's a part of the XMPP address.
|
// if it's a part of the XMPP address.
|
||||||
user = XmppStringUtils.parseBareJid(user);
|
user = user.withoutResource();
|
||||||
String userLowerCase = user.toLowerCase(Locale.US);
|
|
||||||
synchronized (entries) {
|
synchronized (entries) {
|
||||||
for (RosterEntry entry : entries) {
|
for (RosterEntry entry : entries) {
|
||||||
if (entry.getUser().equals(userLowerCase)) {
|
if (entry.getJid().equals(user)) {
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +154,7 @@ public class RosterGroup {
|
||||||
* @param user the XMPP address of the user.
|
* @param user the XMPP address of the user.
|
||||||
* @return true if the XMPP address is an entry in this group.
|
* @return true if the XMPP address is an entry in this group.
|
||||||
*/
|
*/
|
||||||
public boolean contains(String user) {
|
public boolean contains(Jid user) {
|
||||||
return getEntry(user) != null;
|
return getEntry(user) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,9 @@ package org.jivesoftware.smack.roster.packet;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
|
import org.jivesoftware.smack.util.Objects;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.BareJid;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -107,7 +108,7 @@ public class RosterPacket extends IQ {
|
||||||
|
|
||||||
public static final String GROUP = "group";
|
public static final String GROUP = "group";
|
||||||
|
|
||||||
private final Jid user;
|
private final BareJid jid;
|
||||||
private String name;
|
private String name;
|
||||||
private ItemType itemType;
|
private ItemType itemType;
|
||||||
private ItemStatus itemStatus;
|
private ItemStatus itemStatus;
|
||||||
|
@ -117,11 +118,11 @@ public class RosterPacket extends IQ {
|
||||||
/**
|
/**
|
||||||
* Creates a new roster item.
|
* Creates a new roster item.
|
||||||
*
|
*
|
||||||
* @param user the user.
|
* @param jid the jid.
|
||||||
* @param name the user's name.
|
* @param name the user's name.
|
||||||
*/
|
*/
|
||||||
public Item(Jid user, String name) {
|
public Item(BareJid jid, String name) {
|
||||||
this.user = user;
|
this.jid = Objects.requireNonNull(jid);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
itemType = null;
|
itemType = null;
|
||||||
itemStatus = null;
|
itemStatus = null;
|
||||||
|
@ -132,9 +133,20 @@ public class RosterPacket extends IQ {
|
||||||
* Returns the user.
|
* Returns the user.
|
||||||
*
|
*
|
||||||
* @return the user.
|
* @return the user.
|
||||||
|
* @deprecated use {@link #getJid()} instead.
|
||||||
*/
|
*/
|
||||||
public Jid getUser() {
|
@Deprecated
|
||||||
return user;
|
public String getUser() {
|
||||||
|
return jid.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the JID of this item.
|
||||||
|
*
|
||||||
|
* @return the JID.
|
||||||
|
*/
|
||||||
|
public BareJid getJid() {
|
||||||
|
return jid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -240,7 +252,7 @@ public class RosterPacket extends IQ {
|
||||||
|
|
||||||
public XmlStringBuilder toXML() {
|
public XmlStringBuilder toXML() {
|
||||||
XmlStringBuilder xml = new XmlStringBuilder();
|
XmlStringBuilder xml = new XmlStringBuilder();
|
||||||
xml.halfOpenElement(Stanza.ITEM).attribute("jid", user);
|
xml.halfOpenElement(Stanza.ITEM).attribute("jid", jid);
|
||||||
xml.optAttribute("name", name);
|
xml.optAttribute("name", name);
|
||||||
xml.optAttribute("subscription", itemType);
|
xml.optAttribute("subscription", itemType);
|
||||||
xml.optAttribute("ask", itemStatus);
|
xml.optAttribute("ask", itemStatus);
|
||||||
|
@ -262,7 +274,7 @@ public class RosterPacket extends IQ {
|
||||||
result = prime * result + ((itemStatus == null) ? 0 : itemStatus.hashCode());
|
result = prime * result + ((itemStatus == null) ? 0 : itemStatus.hashCode());
|
||||||
result = prime * result + ((itemType == null) ? 0 : itemType.hashCode());
|
result = prime * result + ((itemType == null) ? 0 : itemType.hashCode());
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
result = prime * result + ((user == null) ? 0 : user.hashCode());
|
result = prime * result + ((jid == null) ? 0 : jid.hashCode());
|
||||||
result = prime * result + ((approved == false) ? 0 : 1);
|
result = prime * result + ((approved == false) ? 0 : 1);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -292,11 +304,11 @@ public class RosterPacket extends IQ {
|
||||||
}
|
}
|
||||||
else if (!name.equals(other.name))
|
else if (!name.equals(other.name))
|
||||||
return false;
|
return false;
|
||||||
if (user == null) {
|
if (jid == null) {
|
||||||
if (other.user != null)
|
if (other.jid != null)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (!user.equals(other.user))
|
else if (!jid.equals(other.jid))
|
||||||
return false;
|
return false;
|
||||||
if (approved != other.approved)
|
if (approved != other.approved)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.provider.IQProvider;
|
import org.jivesoftware.smack.provider.IQProvider;
|
||||||
import org.jivesoftware.smack.roster.packet.RosterPacket;
|
import org.jivesoftware.smack.roster.packet.RosterPacket;
|
||||||
import org.jivesoftware.smack.util.ParserUtils;
|
import org.jivesoftware.smack.util.ParserUtils;
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.BareJid;
|
||||||
import org.jxmpp.jid.impl.JidCreate;
|
import org.jxmpp.jid.impl.JidCreate;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
@ -49,7 +49,7 @@ public class RosterPacketProvider extends IQProvider<RosterPacket> {
|
||||||
case "item":
|
case "item":
|
||||||
String jidString = parser.getAttributeValue("", "jid");
|
String jidString = parser.getAttributeValue("", "jid");
|
||||||
String name = parser.getAttributeValue("", "name");
|
String name = parser.getAttributeValue("", "name");
|
||||||
Jid jid = JidCreate.from(jidString);
|
BareJid jid = JidCreate.bareFrom(jidString);
|
||||||
// Create packet.
|
// Create packet.
|
||||||
item = new RosterPacket.Item(jid, name);
|
item = new RosterPacket.Item(jid, name);
|
||||||
// Set status.
|
// Set status.
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.jivesoftware.smack.roster.packet.RosterPacket.Item;
|
||||||
import org.jivesoftware.smack.util.FileUtils;
|
import org.jivesoftware.smack.util.FileUtils;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
import org.jivesoftware.smack.util.stringencoder.Base32;
|
import org.jivesoftware.smack.util.stringencoder.Base32;
|
||||||
|
import org.jxmpp.jid.BareJid;
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.Jid;
|
||||||
import org.jxmpp.jid.impl.JidCreate;
|
import org.jxmpp.jid.impl.JidCreate;
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
import org.xmlpull.v1.XmlPullParserFactory;
|
||||||
|
@ -184,7 +185,7 @@ public final class DirectoryRosterStore implements RosterStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
String parserName;
|
String parserName;
|
||||||
Jid user = null;
|
BareJid user = null;
|
||||||
String name = null;
|
String name = null;
|
||||||
String type = null;
|
String type = null;
|
||||||
String status = null;
|
String status = null;
|
||||||
|
@ -207,7 +208,7 @@ public final class DirectoryRosterStore implements RosterStore {
|
||||||
}
|
}
|
||||||
else if (parserName.equals("user")) {
|
else if (parserName.equals("user")) {
|
||||||
parser.next();
|
parser.next();
|
||||||
user = JidCreate.from(parser.getText());
|
user = JidCreate.bareFrom(parser.getText());
|
||||||
}
|
}
|
||||||
else if (parserName.equals("name")) {
|
else if (parserName.equals("name")) {
|
||||||
parser.next();
|
parser.next();
|
||||||
|
@ -291,7 +292,7 @@ public final class DirectoryRosterStore implements RosterStore {
|
||||||
private boolean addEntryRaw (Item item) {
|
private boolean addEntryRaw (Item item) {
|
||||||
XmlStringBuilder xml = new XmlStringBuilder();
|
XmlStringBuilder xml = new XmlStringBuilder();
|
||||||
xml.openElement("item");
|
xml.openElement("item");
|
||||||
xml.element("user", item.getUser());
|
xml.element("user", item.getJid());
|
||||||
xml.optElement("name", item.getName());
|
xml.optElement("name", item.getName());
|
||||||
xml.optElement("type", item.getItemType());
|
xml.optElement("type", item.getItemType());
|
||||||
xml.optElement("status", item.getItemStatus());
|
xml.optElement("status", item.getItemStatus());
|
||||||
|
@ -303,7 +304,7 @@ public final class DirectoryRosterStore implements RosterStore {
|
||||||
}
|
}
|
||||||
xml.closeElement("item");
|
xml.closeElement("item");
|
||||||
|
|
||||||
return FileUtils.writeFile(getBareJidFile(item.getUser()), xml.toString());
|
return FileUtils.writeFile(getBareJidFile(item.getJid()), xml.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.jxmpp.jid.BareJid;
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.Jid;
|
||||||
import org.jxmpp.jid.impl.JidCreate;
|
import org.jxmpp.jid.impl.JidCreate;
|
||||||
import org.jxmpp.stringprep.XmppStringprepException;
|
import org.jxmpp.stringprep.XmppStringprepException;
|
||||||
|
@ -133,7 +134,7 @@ public class RosterTest extends InitSmackIm {
|
||||||
@Test
|
@Test
|
||||||
public void testAddRosterItem() throws Throwable {
|
public void testAddRosterItem() throws Throwable {
|
||||||
// Constants for the new contact
|
// Constants for the new contact
|
||||||
final Jid contactJID = JidCreate.from("nurse@example.com");
|
final BareJid contactJID = JidCreate.bareFrom("nurse@example.com");
|
||||||
final String contactName = "Nurse";
|
final String contactName = "Nurse";
|
||||||
final String[] contactGroup = {"Servants"};
|
final String[] contactGroup = {"Servants"};
|
||||||
|
|
||||||
|
@ -146,9 +147,9 @@ public class RosterTest extends InitSmackIm {
|
||||||
final RosterUpdateResponder serverSimulator = new RosterUpdateResponder() {
|
final RosterUpdateResponder serverSimulator = new RosterUpdateResponder() {
|
||||||
void verifyUpdateRequest(final RosterPacket updateRequest) {
|
void verifyUpdateRequest(final RosterPacket updateRequest) {
|
||||||
final Item item = updateRequest.getRosterItems().iterator().next();
|
final Item item = updateRequest.getRosterItems().iterator().next();
|
||||||
assertSame("The provided JID doesn't match the requested!",
|
assertEquals("The provided JID doesn't match the requested!",
|
||||||
contactJID,
|
contactJID,
|
||||||
item.getUser());
|
item.getJid());
|
||||||
assertSame("The provided name doesn't match the requested!",
|
assertSame("The provided name doesn't match the requested!",
|
||||||
contactName,
|
contactName,
|
||||||
item.getName());
|
item.getName());
|
||||||
|
@ -217,9 +218,9 @@ public class RosterTest extends InitSmackIm {
|
||||||
final RosterUpdateResponder serverSimulator = new RosterUpdateResponder() {
|
final RosterUpdateResponder serverSimulator = new RosterUpdateResponder() {
|
||||||
void verifyUpdateRequest(final RosterPacket updateRequest) {
|
void verifyUpdateRequest(final RosterPacket updateRequest) {
|
||||||
final Item item = updateRequest.getRosterItems().iterator().next();
|
final Item item = updateRequest.getRosterItems().iterator().next();
|
||||||
assertSame("The provided JID doesn't match the requested!",
|
assertEquals("The provided JID doesn't match the requested!",
|
||||||
contactJID,
|
contactJID,
|
||||||
item.getUser());
|
item.getJid());
|
||||||
assertSame("The provided name doesn't match the requested!",
|
assertSame("The provided name doesn't match the requested!",
|
||||||
contactName,
|
contactName,
|
||||||
item.getName());
|
item.getName());
|
||||||
|
@ -290,9 +291,9 @@ public class RosterTest extends InitSmackIm {
|
||||||
final RosterUpdateResponder serverSimulator = new RosterUpdateResponder() {
|
final RosterUpdateResponder serverSimulator = new RosterUpdateResponder() {
|
||||||
void verifyUpdateRequest(final RosterPacket updateRequest) {
|
void verifyUpdateRequest(final RosterPacket updateRequest) {
|
||||||
final Item item = updateRequest.getRosterItems().iterator().next();
|
final Item item = updateRequest.getRosterItems().iterator().next();
|
||||||
assertSame("The provided JID doesn't match the requested!",
|
assertEquals("The provided JID doesn't match the requested!",
|
||||||
contactJID,
|
contactJID,
|
||||||
item.getUser());
|
item.getJid());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
serverSimulator.start();
|
serverSimulator.start();
|
||||||
|
@ -370,7 +371,7 @@ public class RosterTest extends InitSmackIm {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIgnoreInvalidFrom() throws XmppStringprepException {
|
public void testIgnoreInvalidFrom() throws XmppStringprepException {
|
||||||
final Jid spammerJid = JidCreate.from("spam@example.com");
|
final BareJid spammerJid = JidCreate.bareFrom("spam@example.com");
|
||||||
RosterPacket packet = new RosterPacket();
|
RosterPacket packet = new RosterPacket();
|
||||||
packet.setType(Type.set);
|
packet.setType(Type.set);
|
||||||
packet.setTo(connection.getUser());
|
packet.setTo(connection.getUser());
|
||||||
|
@ -398,7 +399,7 @@ public class RosterTest extends InitSmackIm {
|
||||||
@Test(timeout=5000)
|
@Test(timeout=5000)
|
||||||
public void testAddEmptyGroupEntry() throws Throwable {
|
public void testAddEmptyGroupEntry() throws Throwable {
|
||||||
// Constants for the new contact
|
// Constants for the new contact
|
||||||
final Jid contactJID = JidCreate.from("nurse@example.com");
|
final BareJid contactJID = JidCreate.bareFrom("nurse@example.com");
|
||||||
final String contactName = "Nurse";
|
final String contactName = "Nurse";
|
||||||
final String[] contactGroup = {""};
|
final String[] contactGroup = {""};
|
||||||
|
|
||||||
|
@ -413,7 +414,7 @@ public class RosterTest extends InitSmackIm {
|
||||||
final Item item = updateRequest.getRosterItems().iterator().next();
|
final Item item = updateRequest.getRosterItems().iterator().next();
|
||||||
assertSame("The provided JID doesn't match the requested!",
|
assertSame("The provided JID doesn't match the requested!",
|
||||||
contactJID,
|
contactJID,
|
||||||
item.getUser());
|
item.getJid());
|
||||||
assertSame("The provided name doesn't match the requested!",
|
assertSame("The provided name doesn't match the requested!",
|
||||||
contactName,
|
contactName,
|
||||||
item.getName());
|
item.getName());
|
||||||
|
@ -518,7 +519,7 @@ public class RosterTest extends InitSmackIm {
|
||||||
rosterPush.setTo(connection.getUser());
|
rosterPush.setTo(connection.getUser());
|
||||||
|
|
||||||
// prepare the buddy's item entry which should be removed
|
// prepare the buddy's item entry which should be removed
|
||||||
final RosterPacket.Item item = new RosterPacket.Item(entry.getUser(), entry.getName());
|
final RosterPacket.Item item = new RosterPacket.Item(entry.getJid(), entry.getName());
|
||||||
item.setItemType(ItemType.remove);
|
item.setItemType(ItemType.remove);
|
||||||
rosterPush.addRosterItem(item);
|
rosterPush.addRosterItem(item);
|
||||||
|
|
||||||
|
@ -555,18 +556,18 @@ public class RosterTest extends InitSmackIm {
|
||||||
rosterResult.setStanzaId(rosterRequest.getStanzaId());
|
rosterResult.setStanzaId(rosterRequest.getStanzaId());
|
||||||
|
|
||||||
// prepare romeo's roster entry
|
// prepare romeo's roster entry
|
||||||
final Item romeo = new Item(JidCreate.from("romeo@example.net"), "Romeo");
|
final Item romeo = new Item(JidCreate.bareFrom("romeo@example.net"), "Romeo");
|
||||||
romeo.addGroupName("Friends");
|
romeo.addGroupName("Friends");
|
||||||
romeo.setItemType(ItemType.both);
|
romeo.setItemType(ItemType.both);
|
||||||
rosterResult.addRosterItem(romeo);
|
rosterResult.addRosterItem(romeo);
|
||||||
|
|
||||||
// prepare mercutio's roster entry
|
// prepare mercutio's roster entry
|
||||||
final Item mercutio = new Item(JidCreate.from("mercutio@example.com"), "Mercutio");
|
final Item mercutio = new Item(JidCreate.bareFrom("mercutio@example.com"), "Mercutio");
|
||||||
mercutio.setItemType(ItemType.from);
|
mercutio.setItemType(ItemType.from);
|
||||||
rosterResult.addRosterItem(mercutio);
|
rosterResult.addRosterItem(mercutio);
|
||||||
|
|
||||||
// prepare benvolio's roster entry
|
// prepare benvolio's roster entry
|
||||||
final Item benvolio = new Item(JidCreate.from("benvolio@example.net"), "Benvolio");
|
final Item benvolio = new Item(JidCreate.bareFrom("benvolio@example.net"), "Benvolio");
|
||||||
benvolio.setItemType(ItemType.both);
|
benvolio.setItemType(ItemType.both);
|
||||||
rosterResult.addRosterItem(benvolio);
|
rosterResult.addRosterItem(benvolio);
|
||||||
|
|
||||||
|
|
|
@ -160,13 +160,13 @@ public class RosterVersioningTest {
|
||||||
|
|
||||||
Roster roster = Roster.getInstanceFor(connection);
|
Roster roster = Roster.getInstanceFor(connection);
|
||||||
assertEquals("Size of roster", 1, roster.getEntries().size());
|
assertEquals("Size of roster", 1, roster.getEntries().size());
|
||||||
RosterEntry entry = roster.getEntry(vaglafItem.getUser());
|
RosterEntry entry = roster.getEntry(vaglafItem.getJid());
|
||||||
assertNotNull("Roster contains vaglaf entry", entry);
|
assertNotNull("Roster contains vaglaf entry", entry);
|
||||||
assertEquals("vaglaf entry in roster equals the sent entry", vaglafItem, RosterEntry.toRosterItem(entry));
|
assertEquals("vaglaf entry in roster equals the sent entry", vaglafItem, RosterEntry.toRosterItem(entry));
|
||||||
|
|
||||||
RosterStore store = roster.getRosterStore();
|
RosterStore store = roster.getRosterStore();
|
||||||
assertEquals("Size of store", 1, store.getEntries().size());
|
assertEquals("Size of store", 1, store.getEntries().size());
|
||||||
Item item = store.getEntry(vaglafItem.getUser());
|
Item item = store.getEntry(vaglafItem.getJid());
|
||||||
assertNotNull("Store contains vaglaf entry");
|
assertNotNull("Store contains vaglaf entry");
|
||||||
assertEquals("vaglaf entry in store equals the sent entry", vaglafItem, item);
|
assertEquals("vaglaf entry in store equals the sent entry", vaglafItem, item);
|
||||||
}
|
}
|
||||||
|
@ -214,20 +214,20 @@ public class RosterVersioningTest {
|
||||||
rosterPush.setType(Type.set);
|
rosterPush.setType(Type.set);
|
||||||
rosterPush.setVersion("v98");
|
rosterPush.setVersion("v98");
|
||||||
|
|
||||||
Item item = new Item(JidCreate.from("vaglaf@example.com"), "vaglaf the only");
|
Item item = new Item(JidCreate.bareFrom("vaglaf@example.com"), "vaglaf the only");
|
||||||
item.setItemType(ItemType.remove);
|
item.setItemType(ItemType.remove);
|
||||||
rosterPush.addRosterItem(item);
|
rosterPush.addRosterItem(item);
|
||||||
rosterListener.reset();
|
rosterListener.reset();
|
||||||
connection.processPacket(rosterPush);
|
connection.processPacket(rosterPush);
|
||||||
rosterListener.waitAndReset();
|
rosterListener.waitAndReset();
|
||||||
|
|
||||||
assertNull("Store doses not contain vaglaf", store.getEntry(JidCreate.from("vaglaf@example.com")));
|
assertNull("Store doses not contain vaglaf", store.getEntry(JidCreate.bareFrom("vaglaf@example.com")));
|
||||||
assertEquals("Expect store version after push", "v98", store.getRosterVersion());
|
assertEquals("Expect store version after push", "v98", store.getRosterVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Item vaglafItem() throws XmppStringprepException {
|
private static Item vaglafItem() throws XmppStringprepException {
|
||||||
Item item = new Item(JidCreate.from("vaglaf@example.com"), "vaglaf the only");
|
Item item = new Item(JidCreate.bareFrom("vaglaf@example.com"), "vaglaf the only");
|
||||||
item.setItemType(ItemType.both);
|
item.setItemType(ItemType.both);
|
||||||
item.addGroupName("all");
|
item.addGroupName("all");
|
||||||
item.addGroupName("friends");
|
item.addGroupName("friends");
|
||||||
|
@ -236,14 +236,14 @@ public class RosterVersioningTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void populateStore(RosterStore store) throws IOException {
|
private static void populateStore(RosterStore store) throws IOException {
|
||||||
store.addEntry(new RosterPacket.Item(JidCreate.from("geoff@example.com"), "geoff hurley"), "");
|
store.addEntry(new RosterPacket.Item(JidCreate.bareFrom("geoff@example.com"), "geoff hurley"), "");
|
||||||
|
|
||||||
RosterPacket.Item item = new RosterPacket.Item(JidCreate.from("joe@example.com"), "joe stevens");
|
RosterPacket.Item item = new RosterPacket.Item(JidCreate.bareFrom("joe@example.com"), "joe stevens");
|
||||||
item.addGroupName("friends");
|
item.addGroupName("friends");
|
||||||
item.addGroupName("partners");
|
item.addGroupName("partners");
|
||||||
store.addEntry(item, "");
|
store.addEntry(item, "");
|
||||||
|
|
||||||
item = new RosterPacket.Item(JidCreate.from("higgins@example.com"), "higgins mcmann");
|
item = new RosterPacket.Item(JidCreate.bareFrom("higgins@example.com"), "higgins mcmann");
|
||||||
item.addGroupName("all");
|
item.addGroupName("all");
|
||||||
item.addGroupName("friends");
|
item.addGroupName("friends");
|
||||||
store.addEntry(item, "v96");
|
store.addEntry(item, "v96");
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.jivesoftware.smack.roster.packet.SubscriptionPreApproval;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.jxmpp.jid.BareJid;
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.Jid;
|
||||||
import org.jxmpp.jid.impl.JidCreate;
|
import org.jxmpp.jid.impl.JidCreate;
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ public class SubscriptionPreApprovalTest extends InitSmackIm {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPreApproveAndCreate() throws Throwable {
|
public void testPreApproveAndCreate() throws Throwable {
|
||||||
final Jid contactJID = JidCreate.from("preapproval@example.com");
|
final BareJid contactJID = JidCreate.bareFrom("preapproval@example.com");
|
||||||
final String contactName = "PreApproval";
|
final String contactName = "PreApproval";
|
||||||
final String[] contactGroup = {};
|
final String[] contactGroup = {};
|
||||||
connection.enableStreamFeature(SubscriptionPreApproval.INSTANCE);
|
connection.enableStreamFeature(SubscriptionPreApproval.INSTANCE);
|
||||||
|
@ -88,7 +89,7 @@ public class SubscriptionPreApprovalTest extends InitSmackIm {
|
||||||
final Item item = updateRequest.getRosterItems().iterator().next();
|
final Item item = updateRequest.getRosterItems().iterator().next();
|
||||||
assertSame("The provided JID doesn't match the requested!",
|
assertSame("The provided JID doesn't match the requested!",
|
||||||
contactJID,
|
contactJID,
|
||||||
item.getUser());
|
item.getJid());
|
||||||
assertSame("The provided name doesn't match the requested!",
|
assertSame("The provided name doesn't match the requested!",
|
||||||
contactName,
|
contactName,
|
||||||
item.getName());
|
item.getName());
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.BareJid;
|
||||||
import org.jxmpp.jid.JidTestUtil;
|
import org.jxmpp.jid.JidTestUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +88,7 @@ public class DirectoryRosterStoreTest {
|
||||||
|
|
||||||
assertEquals("Initial roster version", "", store.getRosterVersion());
|
assertEquals("Initial roster version", "", store.getRosterVersion());
|
||||||
|
|
||||||
Jid userName = JidTestUtil.DUMMY_AT_EXAMPLE_ORG;
|
BareJid userName = JidTestUtil.DUMMY_AT_EXAMPLE_ORG;
|
||||||
|
|
||||||
final RosterPacket.Item item1 = new Item(userName, null);
|
final RosterPacket.Item item1 = new Item(userName, null);
|
||||||
final String version1 = "1";
|
final String version1 = "1";
|
||||||
|
@ -99,7 +99,7 @@ public class DirectoryRosterStoreTest {
|
||||||
RosterPacket.Item storedItem = store.getEntry(userName);
|
RosterPacket.Item storedItem = store.getEntry(userName);
|
||||||
assertNotNull("Added entry not found found", storedItem);
|
assertNotNull("Added entry not found found", storedItem);
|
||||||
assertEquals("User of added entry",
|
assertEquals("User of added entry",
|
||||||
item1.getUser(), storedItem.getUser());
|
item1.getJid(), storedItem.getJid());
|
||||||
assertEquals("Name of added entry",
|
assertEquals("Name of added entry",
|
||||||
item1.getName(), storedItem.getName());
|
item1.getName(), storedItem.getName());
|
||||||
assertEquals("Groups", item1.getGroupNames(), storedItem.getGroupNames());
|
assertEquals("Groups", item1.getGroupNames(), storedItem.getGroupNames());
|
||||||
|
@ -123,7 +123,7 @@ public class DirectoryRosterStoreTest {
|
||||||
storedItem = store.getEntry(userName);
|
storedItem = store.getEntry(userName);
|
||||||
assertNotNull("Added entry not found", storedItem);
|
assertNotNull("Added entry not found", storedItem);
|
||||||
assertEquals("User of added entry",
|
assertEquals("User of added entry",
|
||||||
item2.getUser(), storedItem.getUser());
|
item2.getJid(), storedItem.getJid());
|
||||||
assertEquals("Name of added entry",
|
assertEquals("Name of added entry",
|
||||||
item2.getName(), storedItem.getName());
|
item2.getName(), storedItem.getName());
|
||||||
assertEquals("Groups", item2.getGroupNames(), storedItem.getGroupNames());
|
assertEquals("Groups", item2.getGroupNames(), storedItem.getGroupNames());
|
||||||
|
@ -160,7 +160,7 @@ public class DirectoryRosterStoreTest {
|
||||||
storedItem = store.getEntry(JidTestUtil.BARE_JID_1);
|
storedItem = store.getEntry(JidTestUtil.BARE_JID_1);
|
||||||
assertNotNull("Added entry not found", storedItem);
|
assertNotNull("Added entry not found", storedItem);
|
||||||
assertEquals("User of added entry",
|
assertEquals("User of added entry",
|
||||||
item3.getUser(), storedItem.getUser());
|
item3.getJid(), storedItem.getJid());
|
||||||
assertEquals("Name of added entry",
|
assertEquals("Name of added entry",
|
||||||
item3.getName(), storedItem.getName());
|
item3.getName(), storedItem.getName());
|
||||||
assertEquals("Groups", item3.getGroupNames(), storedItem.getGroupNames());
|
assertEquals("Groups", item3.getGroupNames(), storedItem.getGroupNames());
|
||||||
|
@ -175,7 +175,7 @@ public class DirectoryRosterStoreTest {
|
||||||
storedItem = store.getEntry(JidTestUtil.BARE_JID_2);
|
storedItem = store.getEntry(JidTestUtil.BARE_JID_2);
|
||||||
assertNotNull("Added entry not found", storedItem);
|
assertNotNull("Added entry not found", storedItem);
|
||||||
assertEquals("User of added entry",
|
assertEquals("User of added entry",
|
||||||
item4.getUser(), storedItem.getUser());
|
item4.getJid(), storedItem.getJid());
|
||||||
assertEquals("Name of added entry",
|
assertEquals("Name of added entry",
|
||||||
item4.getName(), storedItem.getName());
|
item4.getName(), storedItem.getName());
|
||||||
assertEquals("Groups", item4.getGroupNames(), storedItem.getGroupNames());
|
assertEquals("Groups", item4.getGroupNames(), storedItem.getGroupNames());
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class RosterExchange implements ExtensionElement {
|
||||||
groupNames = groupNamesList.toArray(new String[groupNamesList.size()]);
|
groupNames = groupNamesList.toArray(new String[groupNamesList.size()]);
|
||||||
|
|
||||||
// Create a new Entry based on the rosterEntry and add it to the packet
|
// Create a new Entry based on the rosterEntry and add it to the packet
|
||||||
RemoteRosterEntry remoteRosterEntry = new RemoteRosterEntry(rosterEntry.getUser(),
|
RemoteRosterEntry remoteRosterEntry = new RemoteRosterEntry(rosterEntry.getJid(),
|
||||||
rosterEntry.getName(), groupNames);
|
rosterEntry.getName(), groupNames);
|
||||||
|
|
||||||
addRosterEntry(remoteRosterEntry);
|
addRosterEntry(remoteRosterEntry);
|
||||||
|
|
Loading…
Reference in a new issue