Commit 839ce8f1 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Improved shared group pre-loading logic.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5252 b35dd754-fafc-0310-a699-88a17e54d16e
parent 7d2a5879
......@@ -16,6 +16,8 @@ import org.jivesoftware.wildfire.XMPPServer;
import org.jivesoftware.wildfire.event.GroupEventDispatcher;
import org.jivesoftware.wildfire.event.GroupEventListener;
import org.jivesoftware.wildfire.user.User;
import org.jivesoftware.wildfire.user.UserManager;
import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.xmpp.packet.JID;
import java.util.*;
......@@ -55,7 +57,7 @@ public class GroupManager {
// A cache for meta-data around groups: count, group names, groups associated with
// a particular user
groupMetaCache = CacheManager.initializeCache("Group Metadata Cache", "groupMeta",
512 * 1024, JiveConstants.MINUTE*10);
512 * 1024, JiveConstants.MINUTE*15);
// Load a group provider.
String className = JiveGlobals.getXMLProperty("provider.group.className",
......@@ -105,7 +107,21 @@ public class GroupManager {
// TODO: use a task engine instead of creating a thread directly.
Runnable task = new Runnable() {
public void run() {
getSharedGroups();
Collection<Group> groups = getSharedGroups();
// Load each group into cache.
for (Group group : groups) {
// Load each user in the group into cache.
for (JID jid : group.getMembers()) {
try {
if (XMPPServer.getInstance().isLocal(jid)) {
UserManager.getInstance().getUser(jid.getNode());
}
}
catch (UserNotFoundException unfe) {
// Ignore.
}
}
}
}
};
Thread thread = new Thread(task);
......
......@@ -162,6 +162,9 @@ public class UserManager implements IQResultListener {
* @throws UserNotFoundException if the user does not exist.
*/
public User getUser(String username) throws UserNotFoundException {
if (username == null) {
throw new UserNotFoundException("Username cannot be null");
}
// Make sure that the username is valid.
username = username.trim().toLowerCase();
User user = userCache.get(username);
......
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