Commit 7abf5583 authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Use better error message.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@814 b35dd754-fafc-0310-a699-88a17e54d16e
parent 5c09dd96
...@@ -10,7 +10,8 @@ import="java.text.DateFormat, ...@@ -10,7 +10,8 @@ import="java.text.DateFormat,
java.net.URLEncoder, java.net.URLEncoder,
java.net.URLDecoder, java.net.URLDecoder,
org.jivesoftware.messenger.user.UserManager, org.jivesoftware.messenger.user.UserManager,
org.jivesoftware.messenger.user.UserNotFoundException"%> org.jivesoftware.messenger.user.UserNotFoundException,
org.jivesoftware.stringprep.Stringprep"%>
<!-- Define Administration Bean --> <!-- Define Administration Bean -->
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/> <jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/>
<% <%
...@@ -29,17 +30,24 @@ import="java.text.DateFormat, ...@@ -29,17 +30,24 @@ import="java.text.DateFormat,
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"); String newDescription = ParamUtils.getParameter(request, "newDescription");
boolean groupInfoChanged = ParamUtils.getBooleanParameter(request, "groupChanged", false);
Group group = groupManager.getGroup(groupName); Group group = groupManager.getGroup(groupName);
boolean success = false;
StringBuffer errorBuf = new StringBuffer();
boolean groupInfoChanged = false;
if (newName != null && newName.length() > 0) { if (newName != null && newName.length() > 0) {
group.setName(newName); group.setName(newName);
group.setDescription(newDescription); group.setDescription(newDescription);
groupName = newName; groupName = newName;
groupInfoChanged = true; groupInfoChanged = true;
// Get admin list and compare it the admin posted list.
response.sendRedirect("group-edit.jsp?group=" + URLEncoder.encode(groupName, "UTF-8") + "&groupChanged=true");
return;
} }
if (update) { if (update) {
Set adminIDSet = new HashSet(); Set adminIDSet = new HashSet();
for (int i = 0; i < adminIDs.length; i++) { for (int i = 0; i < adminIDs.length; i++) {
...@@ -75,26 +83,37 @@ import="java.text.DateFormat, ...@@ -75,26 +83,37 @@ import="java.text.DateFormat,
int count = 0; int count = 0;
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
String username = tokenizer.nextToken(); String username = tokenizer.nextToken();
username = username.trim();
username = username.toLowerCase();
// Add to group as member by default. // Add to group as member by default.
if (!group.getMembers().contains(username) && !group.getAdmins().contains(username)) { if (!group.getMembers().contains(username) && !group.getAdmins().contains(username)) {
// Ensure that the user is valid // Ensure that the user is valid
try { try {
UserManager.getInstance().getUser(username);
group.getMembers().add(username); group.getMembers().add(username);
count++; count++;
} }
catch (UserNotFoundException unfe) { } catch (IllegalArgumentException unfe) {
errorBuf.append("<br>"+username + " is not a registered user.");
}
}
else {
errorBuf.append("<br>"+username+" is already in group.");
} }
} }
if (count > 0) { if (count > 0) {
response.sendRedirect("group-edit.jsp?group=" + response.sendRedirect("group-edit.jsp?group=" +
URLEncoder.encode(groupName, "UTF-8") + "&success=true"); URLEncoder.encode(groupName, "UTF-8") + "&success=true");
return;
} }
else { else {
response.sendRedirect("group-edit.jsp?group=" + success = false;
URLEncoder.encode(groupName, "UTF-8") + "&success=false&add=true"); add = true;
} }
return;
}
else if(add && users == null){
add = false;
} }
else if (delete) { else if (delete) {
for (int i = 0; i < deleteMembers.length; i++) { for (int i = 0; i < deleteMembers.length; i++) {
...@@ -105,7 +124,7 @@ import="java.text.DateFormat, ...@@ -105,7 +124,7 @@ 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;
} }
boolean success = groupInfoChanged || "true".equals(request.getParameter("success")) || success = groupInfoChanged || "true".equals(request.getParameter("success")) ||
"true".equals(request.getParameter("deletesuccess")) || "true".equals(request.getParameter("deletesuccess")) ||
"true".equals(request.getParameter("updatesuccess")); "true".equals(request.getParameter("updatesuccess"));
%> %>
...@@ -149,7 +168,7 @@ import="java.text.DateFormat, ...@@ -149,7 +168,7 @@ import="java.text.DateFormat,
</div><br> </div><br>
<% <%
} }
else if(request.getParameter("success") != null && request.getParameter("success").equals("false")) { else if(!success && add){
%> %>
<div class="jive-error"> <div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0"> <table cellpadding="0" cellspacing="0" border="0">
...@@ -158,6 +177,7 @@ import="java.text.DateFormat, ...@@ -158,6 +177,7 @@ import="java.text.DateFormat,
<td class="jive-icon-label"> <td class="jive-icon-label">
<% if(add) { %> <% if(add) { %>
User(s) not added successfully. User(s) not added successfully.
<%= errorBuf %>
<% } %> <% } %>
</td></tr> </td></tr>
</tbody> </tbody>
......
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