%--
- $Revision$
- $Date$
-
- Copyright (C) 2004-2008 Jive Software. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--%>
<%@ page import="org.jivesoftware.util.ParamUtils,
org.jivesoftware.util.AlreadyExistsException,
java.util.*"
errorPage="error.jsp"
%>
<%@ page import="java.net.URLEncoder" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%
// Handle a cancel
if (request.getParameter("cancel") != null) {
response.sendRedirect("muc-service-edit-form.jsp");
return;
}
%>
<%-- Define Administration Bean --%>
<% webManager.init(request, response, session, application, out ); %>
<% // Get parameters
boolean create = ParamUtils.getBooleanParameter(request,"create");
boolean save = request.getParameter("save") != null;
boolean success = request.getParameter("success") != null;
String mucname = ParamUtils.getParameter(request,"mucname");
String mucdesc = ParamUtils.getParameter(request,"mucdesc");
// Load the service object
if (!create && !webManager.getMultiUserChatManager().isServiceRegistered(mucname)) {
// The requested service name does not exist so return to the list of the existing rooms
response.sendRedirect("muc-service-summary.jsp");
return;
}
if (!create && mucdesc == null) {
mucdesc = webManager.getMultiUserChatManager().getMultiUserChatService(mucname).getDescription();
}
// Handle a save
Map errors = new HashMap();
if (save) {
// Make sure that the MUC Service is lower cased.
mucname = mucname.toLowerCase();
// do validation
if (mucname == null || mucname.indexOf('.') >= 0 || mucname.length() < 1) {
errors.put("mucname","mucname");
}
if (errors.size() == 0) {
if (!create) {
webManager.getMultiUserChatManager().updateMultiUserChatService(mucname, mucname, mucdesc);
// Log the event
webManager.logEvent("updated MUC service configuration for "+mucname, "name = "+mucname+"\ndescription = "+mucdesc);
response.sendRedirect("muc-service-edit-form.jsp?success=true&mucname="+mucname);
return;
}
else {
try {
webManager.getMultiUserChatManager().createMultiUserChatService(mucname, mucdesc, false);
// Log the event
webManager.logEvent("created MUC service "+mucname, "name = "+mucname+"\ndescription = "+mucdesc);
response.sendRedirect("muc-service-edit-form.jsp?success=true&mucname="+mucname);
return;
}
catch (IllegalArgumentException e) {
errors.put("mucname","mucname");
}
catch (AlreadyExistsException e) {
errors.put("already_exists","already_exists");
}
}
}
}
%>
<% if (create) { %>
<% } else { %>
"/>
<% } %>
<% if (success) { %>
<% } else if (errors.size() > 0) { %>
<% if (errors.get("mucname") != null) { %>
<% } %>
<% if (errors.get("already_exists") != null) { %>
<% } %>