Commit 2c4f22a2 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Refactoring.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@810 b35dd754-fafc-0310-a699-88a17e54d16e
parent b456e649
...@@ -589,6 +589,8 @@ public class XMPPServer { ...@@ -589,6 +589,8 @@ public class XMPPServer {
if (pluginManager != null) { if (pluginManager != null) {
pluginManager.shutdown(); pluginManager.shutdown();
} }
// Stop the Db connection manager.
DbConnectionManager.getConnectionProvider().destroy();
// TODO: hack to allow safe stopping // TODO: hack to allow safe stopping
Log.info("Jive Messenger stopped"); Log.info("Jive Messenger stopped");
} }
......
...@@ -216,7 +216,7 @@ public class Group implements Cacheable { ...@@ -216,7 +216,7 @@ public class Group implements Cacheable {
throw new IllegalStateException(); throw new IllegalStateException();
} }
iter.remove(); iter.remove();
String user = (String) current; String user = (String)current;
// Remove the group user from the backend store // Remove the group user from the backend store
provider.deleteMember(name, user); provider.deleteMember(name, user);
// Update the group users' roster // Update the group users' roster
......
...@@ -23,7 +23,9 @@ import ="org.jivesoftware.util.*, ...@@ -23,7 +23,9 @@ import ="org.jivesoftware.util.*,
org.dom4j.xpath.DefaultXPath, org.dom4j.xpath.DefaultXPath,
org.dom4j.*, org.dom4j.*,
org.jivesoftware.messenger.group.*, org.jivesoftware.messenger.group.*,
java.net.URLEncoder" java.net.URLEncoder,
org.jivesoftware.messenger.user.UserManager,
org.jivesoftware.messenger.user.UserNotFoundException"
errorPage="error.jsp"%> errorPage="error.jsp"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/> <jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/>
...@@ -57,15 +59,14 @@ errorPage="error.jsp"%> ...@@ -57,15 +59,14 @@ errorPage="error.jsp"%>
} }
if(users.length() > 0){ if(users.length() > 0){
String hostName = webManager.getXMPPServer().getServerInfo().getName();
StringTokenizer tokenizer = new StringTokenizer(users, ","); StringTokenizer tokenizer = new StringTokenizer(users, ",");
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
String tok = tokenizer.nextToken(); String username = tokenizer.nextToken();
String address = tok; try {
if (address.indexOf("@") == -1) { UserManager.getInstance().getUser(username);
address = address + "@" + hostName; newGroup.getMembers().add(username);
} }
newGroup.getMembers().add(address); catch (UserNotFoundException unfe) { }
} }
} }
// Successful, so redirect // Successful, so redirect
...@@ -166,19 +167,13 @@ errorPage="error.jsp"%> ...@@ -166,19 +167,13 @@ errorPage="error.jsp"%>
</tr> </tr>
<tr> <tr>
<td nowrap width="1%"> <td nowrap width="1%">
Add User(s): Initial Member(s):
</td> </td>
<td nowrap class="c1" align="left"> <td nowrap class="c1" align="left">
<input type="text" size="40" name="users"/> <input type="text" size="40" name="users"/>
&nbsp; &nbsp;
</td> </td>
</tr> </tr>
<td width="1%">
</td>
<td nowrap align="left" class="jive-description">
Comma delimited list. Example: "user1@site.com", "user2@site.com"
</td>
</tr>
</table> </table>
<br> <br>
<span class="jive-description"> * Required fields </span> <span class="jive-description"> * Required fields </span>
......
...@@ -8,7 +8,9 @@ import="java.text.DateFormat, ...@@ -8,7 +8,9 @@ import="java.text.DateFormat,
org.jivesoftware.messenger.group.GroupManager, org.jivesoftware.messenger.group.GroupManager,
org.jivesoftware.messenger.group.Group, org.jivesoftware.messenger.group.Group,
java.net.URLEncoder, java.net.URLEncoder,
java.net.URLDecoder"%> java.net.URLDecoder,
org.jivesoftware.messenger.user.UserManager,
org.jivesoftware.messenger.user.UserNotFoundException"%>
<!-- Define Administration Bean --> <!-- Define Administration Bean -->
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/> <jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/>
<% <%
...@@ -19,21 +21,23 @@ import="java.text.DateFormat, ...@@ -19,21 +21,23 @@ import="java.text.DateFormat,
boolean add = request.getParameter("add") != null; boolean add = request.getParameter("add") != null;
boolean delete = request.getParameter("remove") != null; boolean delete = request.getParameter("remove") != null;
boolean update = request.getParameter("update") != null; boolean update = request.getParameter("update") != null;
String users = ParamUtils.getParameter(request, "users"); String users = ParamUtils.getParameter(request, "users");
String [] adminIDs = ParamUtils.getParameters(request, "admin"); String [] adminIDs = ParamUtils.getParameters(request, "admin");
String [] deleteMembers = ParamUtils.getParameters(request, "delete"); String [] deleteMembers = ParamUtils.getParameters(request, "delete");
String groupName = ParamUtils.getParameter(request, "group"); String groupName = ParamUtils.getParameter(request, "group");
GroupManager groupManager = webManager.getGroupManager(); GroupManager groupManager = webManager.getGroupManager();
boolean edit = ParamUtils.getBooleanParameter(request, "edit", false); boolean edit = ParamUtils.getBooleanParameter(request, "edit", false);
String newName = ParamUtils.getParameter(request, "newName"); String newName = ParamUtils.getParameter(request, "newName");
String newDescription = ParamUtils.getParameter(request, "newDescription");
Group group = groupManager.getGroup(groupName); Group group = groupManager.getGroup(groupName);
boolean nameChanged = false; boolean groupInfoChanged = false;
if(newName != null && newName.length() > 0){ if (newName != null && newName.length() > 0) {
group.setName(newName); group.setName(newName);
group.setDescription(newDescription);
groupName = newName; groupName = newName;
nameChanged = true; groupInfoChanged = true;
} }
if (update) { if (update) {
...@@ -49,7 +53,7 @@ import="java.text.DateFormat, ...@@ -49,7 +53,7 @@ import="java.text.DateFormat,
} }
} }
Iterator groupIter = Collections.unmodifiableCollection(group.getAdmins()).iterator(); Iterator groupIter = Collections.unmodifiableCollection(group.getAdmins()).iterator();
Set removeList = new HashSet(); Set removeList = new HashSet();
while (groupIter.hasNext()) { while (groupIter.hasNext()) {
String m = (String) groupIter.next(); String m = (String) groupIter.next();
if (!adminIDSet.contains(m)) { if (!adminIDSet.contains(m)) {
...@@ -67,20 +71,29 @@ import="java.text.DateFormat, ...@@ -67,20 +71,29 @@ import="java.text.DateFormat,
return; return;
} }
else if (add && users != null) { else if (add && users != null) {
String hostName = webManager.getXMPPServer().getServerInfo().getName();
StringTokenizer tokenizer = new StringTokenizer(users, ","); StringTokenizer tokenizer = new StringTokenizer(users, ",");
int count = 0;
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
String tok = tokenizer.nextToken(); String username = tokenizer.nextToken();
String address = tok; // Add to group as member by default.
if (address.indexOf("@") == -1) { if (!group.getMembers().contains(username) && !group.getAdmins().contains(username)) {
address = address + "@" + hostName; // Ensure that the user is valid
} try {
// Add To Group as member by default. UserManager.getInstance().getUser(username);
if (!group.getMembers().contains(address) && !group.getAdmins().contains(address)) { group.getMembers().add(username);
group.getMembers().add(address); count++;
}
catch (UserNotFoundException unfe) { }
} }
} }
response.sendRedirect("group-edit.jsp?group=" + URLEncoder.encode(groupName, "UTF-8") + "&success=true"); if (count > 0) {
response.sendRedirect("group-edit.jsp?group=" +
URLEncoder.encode(groupName, "UTF-8") + "&success=true");
}
else {
response.sendRedirect("group-edit.jsp?group=" +
URLEncoder.encode(groupName, "UTF-8") + "&success=false");
}
return; return;
} }
else if (delete) { else if (delete) {
...@@ -92,11 +105,13 @@ import="java.text.DateFormat, ...@@ -92,11 +105,13 @@ import="java.text.DateFormat,
response.sendRedirect("group-edit.jsp?group=" + URLEncoder.encode(groupName, "UTF-8") + "&deletesuccess=true"); response.sendRedirect("group-edit.jsp?group=" + URLEncoder.encode(groupName, "UTF-8") + "&deletesuccess=true");
return; return;
} }
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.MEDIUM); boolean success = groupInfoChanged || "true".equals(request.getParameter("success")) ||
"true".equals(request.getParameter("deletesuccess")) ||
"true".equals(request.getParameter("updatesuccess"));
%> %>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean"/> <jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean"/>
<% // Title of this page and breadcrumbs <% // Title of this page and breadcrumbs
String title = "Edit Group"; String title = "Edit Group";
pageinfo.setTitle(title); pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp")); pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "group-edit.jsp")); pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "group-edit.jsp"));
...@@ -105,49 +120,37 @@ import="java.text.DateFormat, ...@@ -105,49 +120,37 @@ import="java.text.DateFormat,
%> %>
<jsp:include page="top.jsp" flush="true"/> <jsp:include page="top.jsp" flush="true"/>
<jsp:include page="title.jsp" flush="true"/> <jsp:include page="title.jsp" flush="true"/>
<script language="JavaScript" type="text/javascript">
function openWin(el) {
var win = window.open(
'user-browser.jsp?formName=f&elName=agents', 'newWin',
'width=500,height=550,menubar=yes,location=no,personalbar=no,scrollbars=yes,resize=yes');
}
</script>
<p> <p>
Below is a summary of properties for the group as well as admins and members. Use the forms on the page to add Edit group settings and add or remove group members and administrators
members and optionally designate them as groups administrators. using the forms below.
</p> </p>
<% <%
if (nameChanged){ if (success) {
%> %>
<p class="jive-success-text"> <div class="jive-success">
Name has been changed successfully. <table cellpadding="0" cellspacing="0" border="0">
</p> <tbody>
<% <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
} <td class="jive-icon-label">
%> <% if (groupInfoChanged) { %>
<% Group information updated successfully.
if ("true".equals(request.getParameter("success"))) { <% } else if ("true".equals(request.getParameter("success"))) { %>
%>
<p class="jive-success-text">
User(s) added successfully. User(s) added successfully.
</p> <% } else if ("true".equals(request.getParameter("deletesuccess"))) { %>
<%
}
else if ("true".equals(request.getParameter("deletesuccess"))) {
%>
<p class="jive-success-text">
User(s) deleted successfully. User(s) deleted successfully.
</p> <% } else if ("true".equals(request.getParameter("updatesuccess"))) { %>
<%
}
else if ("true".equals(request.getParameter("updatesuccess"))) {
%>
<p class="jive-success-text">
User(s) updated successfully. User(s) updated successfully.
</p> <%
}
%>
</td></tr>
</tbody>
</table>
</div><br>
<% <%
} }
%> %>
<form name="ff" action="group-edit.jsp"> <form name="ff" action="group-edit.jsp">
<input type="hidden" name="group" value="<%= groupName %>"/> <input type="hidden" name="group" value="<%= groupName %>"/>
...@@ -161,31 +164,48 @@ import="java.text.DateFormat, ...@@ -161,31 +164,48 @@ import="java.text.DateFormat,
<td width="1%"> <td width="1%">
Name: Name:
</td> </td>
<% if(!edit) { %>
<td align=left nowrap width="1%"> <td align=left nowrap width="1%">
<b><%= group.getName() %></b> <b><%= group.getName() %></b>
</td> </td>
<% if(!edit) { %>
<td> <td>
<a href="group-edit.jsp?edit=true&group=<%= URLEncoder.encode(groupName, "UTF-8") %>"> <a href="group-edit.jsp?edit=true&group=<%= URLEncoder.encode(groupName, "UTF-8") %>">
<img src="images/edit-16x16.gif" border="0"> <img src="images/edit-16x16.gif" border="0">
</a> </a>
</td> </td>
<% }else { %> <% } else { %>
<td> <td>
New Name:<input type="text" name="newName"><input type="submit" value="Change"> <input type="text" name="newName" value="<%= group.getName() %>">
</td> </td>
<% } %> <% } %>
</tr>
<tr> <tr>
<td width="1%"> <td width="1%">
Description: Description:
</td> </td>
<% if(!edit) { %>
<td colspan="3"> <td colspan="3">
<%= ((group.getDescription() != null) ? group.getDescription() : "No Description") %> <%= ((group.getDescription() != null) ? group.getDescription() : "<i>No Description</i>") %>
</td> </td>
<% } else { %>
<td>
<input type="text" name="newDescription" value="<%= group.getDescription() != null ? group.getDescription() : "" %>">
</td>
<% } %>
</tr> </tr>
<% if(edit) { %>
<tr>
<td colspan="3">
<input type="submit" value="Change">
</td>
</tr>
<% } %>
</table> </table>
</fieldset> </form> </fieldset> </form>
<br> <br>
...@@ -202,12 +222,6 @@ import="java.text.DateFormat, ...@@ -202,12 +222,6 @@ import="java.text.DateFormat,
&nbsp;<input type="submit" name="addbutton" value="Add"> &nbsp;<input type="submit" name="addbutton" value="Add">
</td> </td>
</tr> </tr>
<td width="1%">
</td>
<td nowrap align="left" class="jive-description">
Comma delimited list. Example: "user1@site.com", "user2@site.com"
</td>
</tr>
</table> </table>
</form> </form>
...@@ -215,11 +229,11 @@ import="java.text.DateFormat, ...@@ -215,11 +229,11 @@ import="java.text.DateFormat,
<input type="hidden" name="group" value="<%= groupName %>"> <input type="hidden" name="group" value="<%= groupName %>">
<table class="jive-table" cellpadding="3" cellspacing="0" border="0" width="600"> <table class="jive-table" cellpadding="3" cellspacing="0" border="0" width="600">
<tr> <tr>
<th width="10%">Name</th> <th width="60%">Address</th> <th>Admin</th> <th>Remove</th> <th>Username</th><th width="1%">Admin</th><th width="1%">Remove</th>
</tr> </tr>
<!-- Add admins first --> <!-- Add admins first -->
<% <%
int memberCount = group.getCachedSize(); int memberCount = group.getMembers().size() + group.getAdmins().size();
Iterator members = group.getMembers().iterator(); Iterator members = group.getMembers().iterator();
Iterator admins = group.getAdmins().iterator(); Iterator admins = group.getAdmins().iterator();
%> %>
...@@ -227,7 +241,7 @@ import="java.text.DateFormat, ...@@ -227,7 +241,7 @@ import="java.text.DateFormat,
if (memberCount == 0) { if (memberCount == 0) {
%> %>
<tr> <tr>
<td align="center" colspan="4"> <td align="center" colspan="3">
<br> <br>
No members in this group. Use the form above to add some. No members in this group. Use the form above to add some.
<br> <br>
...@@ -240,19 +254,15 @@ import="java.text.DateFormat, ...@@ -240,19 +254,15 @@ import="java.text.DateFormat,
<% <%
boolean showUpdateButtons = memberCount > 0; boolean showUpdateButtons = memberCount > 0;
while (admins.hasNext()) { while (admins.hasNext()) {
String adminName = (String) admins.next(); String username = (String)admins.next();
JID adminJID = new JID(adminName);
%> %>
<tr> <tr>
<td><%= adminJID.getNode() %> <td><%= username %></td>
</td> <td align="center">
<td><%= adminName %> <input type="checkbox" name="admin" value="<%= username %>" checked>
</td>
<td>
<input type="checkbox" name="admin" value="<%= adminName %>" checked>
</td> </td>
<td align="center"> <td align="center">
<input type="checkbox" name="delete" value="<%= adminName %>"> <input type="checkbox" name="delete" value="<%= username %>">
</td> </td>
</tr> </tr>
<% <%
...@@ -260,19 +270,15 @@ import="java.text.DateFormat, ...@@ -260,19 +270,15 @@ import="java.text.DateFormat,
%> %>
<% <%
while (members.hasNext()) { while (members.hasNext()) {
String member = (String) members.next(); String username = (String)members.next();
JID memberJID = new JID(member);
%> %>
<tr> <tr>
<td><%= memberJID.getNode() %> <td><%= username %></td>
</td> <td align="center">
<td><%= member %> <input type="checkbox" name="admin" value="<%= username %>">
</td>
<td>
<input type="checkbox" name="admin" value="<%= member %>">
</td> </td>
<td align="center"> <td align="center">
<input type="checkbox" name="delete" value="<%= member %>"> <input type="checkbox" name="delete" value="<%= username %>">
</td> </td>
</tr> </tr>
<% <%
...@@ -282,7 +288,7 @@ import="java.text.DateFormat, ...@@ -282,7 +288,7 @@ import="java.text.DateFormat,
if (showUpdateButtons) { if (showUpdateButtons) {
%> %>
<tr> <tr>
<td colspan="2"> <td>
&nbsp; &nbsp;
</td> </td>
<td align="center"> <td align="center">
......
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