Commit 44c82d5d authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Refactoring work.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@580 b35dd754-fafc-0310-a699-88a17e54d16e
parent fe4a0418
...@@ -458,8 +458,8 @@ public class SessionResultFilter { ...@@ -458,8 +458,8 @@ public class SessionResultFilter {
break; break;
case SessionResultFilter.SORT_USER: case SessionResultFilter.SORT_USER:
// sort first by name, then by resource // sort first by name, then by resource
comparison = compareString(lhs.getAddress().getName(), comparison = compareString(lhs.getAddress().getNode(),
rhs.getAddress().getName()); rhs.getAddress().getNode());
if (comparison == 0) { if (comparison == 0) {
comparison = compareString(lhs.getAddress().getResource(), comparison = compareString(lhs.getAddress().getResource(),
rhs.getAddress().getResource()); rhs.getAddress().getResource());
......
...@@ -11,17 +11,16 @@ ...@@ -11,17 +11,16 @@
package org.jivesoftware.messenger.user; package org.jivesoftware.messenger.user;
import org.jivesoftware.util.CacheSizes;
import org.jivesoftware.messenger.XMPPAddress;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.util.Cacheable;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.util.CacheSizes;
import org.jivesoftware.util.Cacheable;
import org.xmpp.packet.JID;
/** /**
* <p>Implements the basic Roster interface storing all roster items into a simple hash table.</p> * <p>Implements the basic Roster interface storing all roster items into a simple hash table.</p>
...@@ -47,10 +46,10 @@ public class BasicRoster implements Roster, Cacheable { ...@@ -47,10 +46,10 @@ public class BasicRoster implements Roster, Cacheable {
public BasicRoster() { public BasicRoster() {
} }
public boolean isRosterItem(XMPPAddress user) { public boolean isRosterItem(JID user) {
itemLock.readLock().lock(); itemLock.readLock().lock();
try { try {
return rosterItems.containsKey(user.toBareStringPrep()); return rosterItems.containsKey(user.toBareJID());
} }
finally { finally {
itemLock.readLock().unlock(); itemLock.readLock().unlock();
...@@ -82,12 +81,12 @@ public class BasicRoster implements Roster, Cacheable { ...@@ -82,12 +81,12 @@ public class BasicRoster implements Roster, Cacheable {
} }
} }
public RosterItem getRosterItem(XMPPAddress user) throws UnauthorizedException, UserNotFoundException { public RosterItem getRosterItem(JID user) throws UnauthorizedException, UserNotFoundException {
itemLock.readLock().lock(); itemLock.readLock().lock();
try { try {
RosterItem item = (RosterItem)rosterItems.get(user.toBareStringPrep()); RosterItem item = (RosterItem)rosterItems.get(user.toBareJID());
if (item == null) { if (item == null) {
throw new UserNotFoundException(user.toBareStringPrep()); throw new UserNotFoundException(user.toBareJID());
} }
return item; return item;
} }
...@@ -96,15 +95,15 @@ public class BasicRoster implements Roster, Cacheable { ...@@ -96,15 +95,15 @@ public class BasicRoster implements Roster, Cacheable {
} }
} }
public RosterItem createRosterItem(XMPPAddress user) throws UnauthorizedException, UserAlreadyExistsException { public RosterItem createRosterItem(JID user) throws UnauthorizedException, UserAlreadyExistsException {
return createRosterItem(user, null, null); return createRosterItem(user, null, null);
} }
public RosterItem createRosterItem(XMPPAddress user, String nickname, List groups) throws UnauthorizedException, UserAlreadyExistsException { public RosterItem createRosterItem(JID user, String nickname, List groups) throws UnauthorizedException, UserAlreadyExistsException {
RosterItem item = provideRosterItem(user, nickname, groups); RosterItem item = provideRosterItem(user, nickname, groups);
itemLock.writeLock().lock(); itemLock.writeLock().lock();
try { try {
rosterItems.put(item.getJid().toBareStringPrep(), item); rosterItems.put(item.getJid().toBareJID(), item);
return item; return item;
} }
finally { finally {
...@@ -116,7 +115,7 @@ public class BasicRoster implements Roster, Cacheable { ...@@ -116,7 +115,7 @@ public class BasicRoster implements Roster, Cacheable {
item = provideRosterItem(item); item = provideRosterItem(item);
itemLock.writeLock().lock(); itemLock.writeLock().lock();
try { try {
rosterItems.put(item.getJid().toBareStringPrep(), item); rosterItems.put(item.getJid().toBareJID(), item);
return item; return item;
} }
finally { finally {
...@@ -135,7 +134,7 @@ public class BasicRoster implements Roster, Cacheable { ...@@ -135,7 +134,7 @@ public class BasicRoster implements Roster, Cacheable {
* @param groups The groups the item belongs to (or null for none) * @param groups The groups the item belongs to (or null for none)
* @return The newly created roster items ready to be stored by the BasicRoster item's hash table * @return The newly created roster items ready to be stored by the BasicRoster item's hash table
*/ */
protected RosterItem provideRosterItem(XMPPAddress user, String nickname, List groups) protected RosterItem provideRosterItem(JID user, String nickname, List groups)
throws UserAlreadyExistsException, UnauthorizedException { throws UserAlreadyExistsException, UnauthorizedException {
return new BasicRosterItem(user, nickname, groups); return new BasicRosterItem(user, nickname, groups);
} }
...@@ -157,22 +156,22 @@ public class BasicRoster implements Roster, Cacheable { ...@@ -157,22 +156,22 @@ public class BasicRoster implements Roster, Cacheable {
public void updateRosterItem(RosterItem item) throws UnauthorizedException, UserNotFoundException { public void updateRosterItem(RosterItem item) throws UnauthorizedException, UserNotFoundException {
itemLock.writeLock().lock(); itemLock.writeLock().lock();
try { try {
if (rosterItems.get(item.getJid().toBareStringPrep()) == null) { if (rosterItems.get(item.getJid().toBareJID()) == null) {
throw new UserNotFoundException(item.getJid().toBareStringPrep()); throw new UserNotFoundException(item.getJid().toBareJID());
} }
rosterItems.put(item.getJid().toBareStringPrep(), item); rosterItems.put(item.getJid().toBareJID(), item);
} }
finally { finally {
itemLock.writeLock().unlock(); itemLock.writeLock().unlock();
} }
} }
public RosterItem deleteRosterItem(XMPPAddress user) throws UnauthorizedException { public RosterItem deleteRosterItem(JID user) throws UnauthorizedException {
itemLock.writeLock().lock(); itemLock.writeLock().lock();
try { try {
// If removing the user was successful, remove the user from the subscriber list: // If removing the user was successful, remove the user from the subscriber list:
return (RosterItem)rosterItems.remove(user.toBareStringPrep()); return (RosterItem)rosterItems.remove(user.toBareJID());
} }
finally { finally {
itemLock.writeLock().unlock(); itemLock.writeLock().unlock();
......
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