Commit bd47b35a authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Modified to use UserNameManager to get the contact's nickname. JM-581

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3504 b35dd754-fafc-0310-a699-88a17e54d16e
parent c7acbc48
/** /**
* $RCSfile$ * $RCSfile$
* $Revision: 3117 $ * $Revision: $
* $Date: 2005-11-25 22:57:29 -0300 (Fri, 25 Nov 2005) $ * $Date: $
* *
* Copyright (C) 2004 Jive Software. All rights reserved. * Copyright (C) 2006 Jive Software. All rights reserved.
* *
* This software is published under the terms of the GNU Public License (GPL), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
...@@ -22,10 +22,7 @@ import org.jivesoftware.wildfire.group.Group; ...@@ -22,10 +22,7 @@ import org.jivesoftware.wildfire.group.Group;
import org.jivesoftware.wildfire.group.GroupManager; import org.jivesoftware.wildfire.group.GroupManager;
import org.jivesoftware.wildfire.privacy.PrivacyList; import org.jivesoftware.wildfire.privacy.PrivacyList;
import org.jivesoftware.wildfire.privacy.PrivacyListManager; import org.jivesoftware.wildfire.privacy.PrivacyListManager;
import org.jivesoftware.wildfire.user.User; import org.jivesoftware.wildfire.user.*;
import org.jivesoftware.wildfire.user.UserAlreadyExistsException;
import org.jivesoftware.wildfire.user.UserManager;
import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
...@@ -114,7 +111,7 @@ public class Roster implements Cacheable { ...@@ -114,7 +111,7 @@ public class Roster implements Cacheable {
for (JID jid : sharedUsers.keySet()) { for (JID jid : sharedUsers.keySet()) {
try { try {
Collection<Group> itemGroups = new ArrayList<Group>(); Collection<Group> itemGroups = new ArrayList<Group>();
String nickname = getContactNickname(jid); String nickname = UserNameManager.getUserName(jid);
RosterItem item = new RosterItem(jid, RosterItem.SUB_TO, RosterItem.ASK_NONE, RosterItem item = new RosterItem(jid, RosterItem.SUB_TO, RosterItem.ASK_NONE,
RosterItem.RECV_NONE, nickname , null); RosterItem.RECV_NONE, nickname , null);
// Add the shared groups to the new roster item // Add the shared groups to the new roster item
...@@ -607,7 +604,7 @@ public class Roster implements Cacheable { ...@@ -607,7 +604,7 @@ public class Roster implements Cacheable {
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
try { try {
// Create a new RosterItem for this new user // Create a new RosterItem for this new user
String nickname = getContactNickname(addedUser); String nickname = UserNameManager.getUserName(addedUser);
item = item =
new RosterItem(addedUser, RosterItem.SUB_BOTH, RosterItem.ASK_NONE, new RosterItem(addedUser, RosterItem.SUB_BOTH, RosterItem.ASK_NONE,
RosterItem.RECV_NONE, nickname, null); RosterItem.RECV_NONE, nickname, null);
...@@ -696,7 +693,7 @@ public class Roster implements Cacheable { ...@@ -696,7 +693,7 @@ public class Roster implements Cacheable {
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
try { try {
// Create a new RosterItem for this new user // Create a new RosterItem for this new user
String nickname = getContactNickname(addedUser); String nickname = UserNameManager.getUserName(addedUser);
item = item =
new RosterItem(addedUser, RosterItem.SUB_BOTH, RosterItem.ASK_NONE, new RosterItem(addedUser, RosterItem.SUB_BOTH, RosterItem.ASK_NONE,
RosterItem.RECV_NONE, nickname, null); RosterItem.RECV_NONE, nickname, null);
...@@ -921,20 +918,6 @@ public class Roster implements Cacheable { ...@@ -921,20 +918,6 @@ public class Roster implements Cacheable {
} }
} }
private String getContactNickname(JID jid) throws UserNotFoundException {
String nickname;
if (server.isLocal(jid)) {
// Contact is a local user so search for his user name
User user = UserManager.getInstance().getUser(jid.getNode());
nickname = "".equals(user.getName()) ? jid.getNode() : user.getName();
}
else {
// Contact is a remote user so use his JID as his nickname
nickname = jid.toString();
}
return nickname;
}
private JID getUserJID() { private JID getUserJID() {
return XMPPServer.getInstance().createJID(getUsername(), null); return XMPPServer.getInstance().createJID(getUsername(), null);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment