Commit 3c263498 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Sort allowed room creators and sysadmin lists.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3685 b35dd754-fafc-0310-a699-88a17e54d16e
parent 38259b3a
...@@ -138,13 +138,13 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -138,13 +138,13 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
* Bare jids of users that are allowed to create MUC rooms. An empty list means that anyone can * Bare jids of users that are allowed to create MUC rooms. An empty list means that anyone can
* create a room. * create a room.
*/ */
private Collection<String> allowedToCreate = new CopyOnWriteArrayList<String>(); private List<String> allowedToCreate = new CopyOnWriteArrayList<String>();
/** /**
* Bare jids of users that are system administrators of the MUC service. A sysadmin has the same * Bare jids of users that are system administrators of the MUC service. A sysadmin has the same
* permissions as a room owner. * permissions as a room owner.
*/ */
private Collection<String> sysadmins = new CopyOnWriteArrayList<String>(); private List<String> sysadmins = new CopyOnWriteArrayList<String>();
/** /**
* Queue that holds the messages to log for the rooms that need to log their conversations. * Queue that holds the messages to log for the rooms that need to log their conversations.
...@@ -341,8 +341,8 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -341,8 +341,8 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
} }
private void logConversation() { private void logConversation() {
ConversationLogEntry entry = null; ConversationLogEntry entry;
boolean success = false; boolean success;
for (int index = 0; index <= log_batch_size && !logQueue.isEmpty(); index++) { for (int index = 0; index <= log_batch_size && !logQueue.isEmpty(); index++) {
entry = logQueue.poll(); entry = logQueue.poll();
if (entry != null) { if (entry != null) {
...@@ -359,7 +359,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -359,7 +359,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
* saving all the conversation log entries before the service becomes unavailable. * saving all the conversation log entries before the service becomes unavailable.
*/ */
private void logAllConversation() { private void logAllConversation() {
ConversationLogEntry entry = null; ConversationLogEntry entry;
while (!logQueue.isEmpty()) { while (!logQueue.isEmpty()) {
entry = logQueue.poll(); entry = logQueue.poll();
if (entry != null) { if (entry != null) {
...@@ -392,7 +392,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -392,7 +392,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
} }
public MUCRoom getChatRoom(String roomName, JID userjid) throws NotAllowedException { public MUCRoom getChatRoom(String roomName, JID userjid) throws NotAllowedException {
MUCRoom room = null; MUCRoom room;
synchronized (roomName.intern()) { synchronized (roomName.intern()) {
room = rooms.get(roomName); room = rooms.get(roomName);
if (room == null) { if (room == null) {
...@@ -493,7 +493,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -493,7 +493,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
if (router == null) { if (router == null) {
throw new IllegalStateException("Not initialized"); throw new IllegalStateException("Not initialized");
} }
MUCUser user = null; MUCUser user;
synchronized (userjid.toString().intern()) { synchronized (userjid.toString().intern()) {
user = users.get(userjid); user = users.get(userjid);
if (user == null) { if (user == null) {
...@@ -599,9 +599,13 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -599,9 +599,13 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
public void addSysadmin(String userJID) { public void addSysadmin(String userJID) {
sysadmins.add(userJID.trim().toLowerCase()); sysadmins.add(userJID.trim().toLowerCase());
// CopyOnWriteArray does not allow sorting, so do sorting in temp list.
ArrayList<String> tempList = new ArrayList<String>(sysadmins);
Collections.sort(tempList);
sysadmins = new CopyOnWriteArrayList<String>(tempList);
// Update the config. // Update the config.
String[] jids = new String[sysadmins.size()]; String[] jids = new String[sysadmins.size()];
jids = (String[])sysadmins.toArray(jids); jids = sysadmins.toArray(jids);
JiveGlobals.setProperty("xmpp.muc.sysadmin.jid", fromArray(jids)); JiveGlobals.setProperty("xmpp.muc.sysadmin.jid", fromArray(jids));
} }
...@@ -609,7 +613,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -609,7 +613,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
sysadmins.remove(userJID.trim().toLowerCase()); sysadmins.remove(userJID.trim().toLowerCase());
// Update the config. // Update the config.
String[] jids = new String[sysadmins.size()]; String[] jids = new String[sysadmins.size()];
jids = (String[])sysadmins.toArray(jids); jids = sysadmins.toArray(jids);
JiveGlobals.setProperty("xmpp.muc.sysadmin.jid", fromArray(jids)); JiveGlobals.setProperty("xmpp.muc.sysadmin.jid", fromArray(jids));
} }
...@@ -651,9 +655,13 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -651,9 +655,13 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
// Update the list of allowed JIDs to create MUC rooms. Since we are updating the instance // Update the list of allowed JIDs to create MUC rooms. Since we are updating the instance
// variable there is no need to restart the service // variable there is no need to restart the service
allowedToCreate.add(userJID.trim().toLowerCase()); allowedToCreate.add(userJID.trim().toLowerCase());
// CopyOnWriteArray does not allow sorting, so do sorting in temp list.
ArrayList<String> tempList = new ArrayList<String>(allowedToCreate);
Collections.sort(tempList);
allowedToCreate = new CopyOnWriteArrayList<String>(tempList);
// Update the config. // Update the config.
String[] jids = new String[allowedToCreate.size()]; String[] jids = new String[allowedToCreate.size()];
jids = (String[])allowedToCreate.toArray(jids); jids = allowedToCreate.toArray(jids);
JiveGlobals.setProperty("xmpp.muc.create.jid", fromArray(jids)); JiveGlobals.setProperty("xmpp.muc.create.jid", fromArray(jids));
} }
...@@ -663,7 +671,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -663,7 +671,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
allowedToCreate.remove(userJID.trim().toLowerCase()); allowedToCreate.remove(userJID.trim().toLowerCase());
// Update the config. // Update the config.
String[] jids = new String[allowedToCreate.size()]; String[] jids = new String[allowedToCreate.size()];
jids = (String[])allowedToCreate.toArray(jids); jids = allowedToCreate.toArray(jids);
JiveGlobals.setProperty("xmpp.muc.create.jid", fromArray(jids)); JiveGlobals.setProperty("xmpp.muc.create.jid", fromArray(jids));
} }
...@@ -678,8 +686,8 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -678,8 +686,8 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
String[] jids; String[] jids;
if (property != null) { if (property != null) {
jids = property.split(","); jids = property.split(",");
for (int i = 0; i < jids.length; i++) { for (String jid : jids) {
sysadmins.add(jids[i].trim().toLowerCase()); sysadmins.add(jid.trim().toLowerCase());
} }
} }
allowToDiscoverLockedRooms = allowToDiscoverLockedRooms =
...@@ -690,8 +698,8 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -690,8 +698,8 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
property = JiveGlobals.getProperty("xmpp.muc.create.jid"); property = JiveGlobals.getProperty("xmpp.muc.create.jid");
if (property != null) { if (property != null) {
jids = property.split(","); jids = property.split(",");
for (int i = 0; i < jids.length; i++) { for (String jid : jids) {
allowedToCreate.add(jids[i].trim().toLowerCase()); allowedToCreate.add(jid.trim().toLowerCase());
} }
} }
String value = JiveGlobals.getProperty("xmpp.muc.tasks.user.timeout"); String value = JiveGlobals.getProperty("xmpp.muc.tasks.user.timeout");
......
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