server-props.jsp 8.7 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4
<%--
  -	$RCSfile$
  -	$Revision$
  -	$Date$
5 6 7 8 9
  -
  - Copyright (C) 2004 Jive Software. All rights reserved.
  -
  - This software is published under the terms of the GNU Public License (GPL),
  - a copy of which is included in this distribution.
Matt Tucker's avatar
Matt Tucker committed
10 11 12 13
--%>

<%@ page import="org.jivesoftware.util.*,
                 org.jivesoftware.messenger.XMPPServerInfo,
14
                 org.jivesoftware.messenger.ServerPort,
15 16
                 org.jivesoftware.admin.AdminPageBean,
                 java.util.*,
Bill Lynch's avatar
Bill Lynch committed
17 18 19
                 org.jivesoftware.messenger.XMPPServer,
                 java.net.InetAddress,
                 org.jivesoftware.messenger.JiveGlobals"
Matt Tucker's avatar
Matt Tucker committed
20
%>
21 22 23 24 25 26

<%@ taglib uri="core" prefix="c" %>
<%@ taglib uri="fmt" prefix="fmt" %>

<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />

Bill Lynch's avatar
Bill Lynch committed
27
<%-- Define Administration Bean --%>
Matt Tucker's avatar
Matt Tucker committed
28 29 30 31
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager"  />
<% admin.init(request, response, session, application, out ); %>
<c:set var="admin" value="${admin.manager}" />

32 33 34
<%
    // Get parameters
    String serverName = ParamUtils.getParameter(request,"serverName");
Bill Lynch's avatar
Bill Lynch committed
35 36 37 38
    int port = ParamUtils.getIntParameter(request,"port",-1);
    int sslPort = ParamUtils.getIntParameter(request,"sslPort",-1);
    int embeddedPort = ParamUtils.getIntParameter(request,"embeddedPort",-1);
    boolean sslEnabled = ParamUtils.getBooleanParameter(request,"sslEnabled");
39
    boolean save = request.getParameter("save") != null;
Bill Lynch's avatar
Bill Lynch committed
40
    boolean defaults = request.getParameter("defaults") != null;
41 42 43 44 45 46 47
    boolean cancel = request.getParameter("cancel") != null;

    if (cancel) {
        response.sendRedirect("index.jsp");
        return;
    }

Bill Lynch's avatar
Bill Lynch committed
48 49 50 51 52 53 54 55 56
    if (defaults) {
        serverName = InetAddress.getLocalHost().getHostName();
        port = 5222;
        sslPort = 5223;
        embeddedPort = 9090;
        sslEnabled = true;
        save = true;
    }

57 58 59 60 61 62
    XMPPServer server = admin.getXMPPServer();
    Map errors = new HashMap();
    if (save) {
        if (serverName == null) {
            errors.put("serverName","");
        }
Bill Lynch's avatar
Bill Lynch committed
63 64 65
        if (port < 1) {
            errors.put("port","");
        }
66
        if (sslPort < 1 && sslEnabled) {
Bill Lynch's avatar
Bill Lynch committed
67 68 69 70 71 72 73 74 75 76
            errors.put("sslPort","");
        }
        if (embeddedPort < 1) {
            errors.put("embeddedPort","");
        }
        if (port > 0 && sslPort > 0) {
            if (port == sslPort) {
                errors.put("portsEqual","");
            }
        }
77 78
        if (errors.size() == 0) {
            server.getServerInfo().setName(serverName);
Bill Lynch's avatar
Bill Lynch committed
79 80 81 82 83
            JiveGlobals.setProperty("xmpp.socket.plain.port", String.valueOf(port));
            JiveGlobals.setProperty("embedded-web.port", String.valueOf(embeddedPort));
            JiveGlobals.setProperty("xmpp.socket.ssl.active", String.valueOf(sslEnabled));
            JiveGlobals.setProperty("xmpp.socket.ssl.port", String.valueOf(sslPort));
            response.sendRedirect("server-props.jsp?success=true");
84 85 86 87 88 89
            return;
        }
    }

    if (errors.size() == 0) {
        serverName = server.getServerInfo().getName();
Bill Lynch's avatar
Bill Lynch committed
90 91 92 93
        sslEnabled = "true".equals(JiveGlobals.getProperty("xmpp.socket.ssl.active"));
        try { port = Integer.parseInt(JiveGlobals.getProperty("xmpp.socket.plain.port")); } catch (Exception ignored) {}
        try { embeddedPort = Integer.parseInt(JiveGlobals.getProperty("embedded-web.port")); } catch (Exception ignored) {}
        try { sslPort = Integer.parseInt(JiveGlobals.getProperty("xmpp.socket.ssl.port")); } catch (Exception ignored) {}
94 95 96
    }
%>

97
<%  // Title of this page and breadcrumbs
98
    String title = "Edit Server Properties";
99
    pageinfo.setTitle(title);
Bill Lynch's avatar
Bill Lynch committed
100
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
101 102
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Server Properties", "index.jsp"));
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Edit", "server-props.jsp"));
103 104
    pageinfo.setPageID("server-props");
%>
Bill Lynch's avatar
Bill Lynch committed
105
<jsp:include page="top.jsp" flush="true" />
106
<jsp:include page="title.jsp" flush="true" />
Matt Tucker's avatar
Matt Tucker committed
107

Bill Lynch's avatar
Bill Lynch committed
108 109 110 111 112 113
<style type="text/css">
.c1 {
    width : 30%;
}
</style>

Matt Tucker's avatar
Matt Tucker committed
114
<p>
115
Use the form below to edit server properties.
Matt Tucker's avatar
Matt Tucker committed
116 117
</p>

Bill Lynch's avatar
Bill Lynch committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
<%  if ("true".equals(request.getParameter("success"))) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
        <td class="jive-icon-label">
        Server properties updated successfully. You'll need to <b>restart</b> the server to have
        the changes take effect.
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

<form action="server-props.jsp" name="editform" method="post">
Matt Tucker's avatar
Matt Tucker committed
135

136 137 138 139 140 141 142 143 144 145 146 147 148
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th colspan="2">
            Server Properties
        </th>
    </tr>
</thead>
<tbody>
    <tr>
        <td class="c1">
            Server Name:
Matt Tucker's avatar
Matt Tucker committed
149
        </td>
150 151 152
        <td class="c2">
            <input type="text" name="serverName" value="<%= (serverName != null) ? serverName : "" %>"
             size="30" maxlength="40">
Bill Lynch's avatar
Bill Lynch committed
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
            <%  if (errors.containsKey("serverName")) { %>
                <br>
                <span class="jive-error-text">
                Please enter a valid server host name or
                <a href="#" onclick="document.editform.serverName.value='<%= InetAddress.getLocalHost().getHostName() %>';"
                 >restore the default</a>.
                </span>
            <%  } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
             Port:
        </td>
        <td class="c2">
            <input type="text" name="port" value="<%= (port > 0 ? String.valueOf(port) : "") %>"
             size="5" maxlength="5">
            <%  if (errors.containsKey("port")) { %>
                <br>
                <span class="jive-error-text">
                Please enter a valid port number or
                <a href="#" onclick="document.editform.port.value='5222';"
                 >restore the default</a>.
                </span>
            <%  } else if (errors.containsKey("portsEqual")) { %>
                <br>
                <span class="jive-error-text">
                Error -- this port and the SSL port can not be equal.
                </span>
            <%  } %>
Matt Tucker's avatar
Matt Tucker committed
183 184
        </td>
    </tr>
Bill Lynch's avatar
Bill Lynch committed
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
    <tr>
        <td class="c1">
             SSL Enabled:
        </td>
        <td class="c2">
            <table cellpadding="0" cellspacing="0" border="0">
            <tbody>
                <tr>
                    <td>
                        <input type="radio" name="sslEnabed" value="true" <%= (sslEnabled ? "checked" : "") %>
                         id="SSL01">
                    </td>
                    <td><label for="SSL01">Enabled</label></td>
                </tr>
                <tr>
                    <td>
                        <input type="radio" name="sslEnabed" value="false" <%= (!sslEnabled ? "checked" : "") %>
                         id="SSL02">
                    </td>
                    <td><label for="SSL02">Disabled</label></td>
                </tr>
            </tbody>
            </table>
        </td>
    </tr>
    <tr>
        <td class="c1">
             SSL Port:
        </td>
        <td class="c2">
            <input type="text" name="sslPort" value="<%= (sslPort > 0 ? String.valueOf(sslPort) : "") %>"
             size="5" maxlength="5">
            <%  if (errors.containsKey("sslPort")) { %>
                <br>
                <span class="jive-error-text">
                Please enter a valid SSL port number or
                <a href="#" onclick="document.editform.sslPort.value='5223';"
                 >restore the default</a>.
                </span>
            <%  } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
229
             Admin Console Port:
Bill Lynch's avatar
Bill Lynch committed
230 231 232 233 234 235 236 237 238 239 240 241
        </td>
        <td class="c2">
            <input type="text" name="embeddedPort" value="<%= (embeddedPort > 0 ? String.valueOf(embeddedPort) : "") %>"
             size="5" maxlength="5">
            <%  if (errors.containsKey("embeddedPort")) { %>
                <br>
                <span class="jive-error-text">
                Please enter a valid port number or
                <a href="#" onclick="document.editform.embeddedPort.value='9090';"
                 >restore the default</a>.
                </span>
            <%  } %>
Matt Tucker's avatar
Matt Tucker committed
242 243
        </td>
    </tr>
244 245 246 247 248
</tbody>
<tfoot>
    <tr>
        <td colspan="2">
            <input type="submit" name="save" value="Save">
Bill Lynch's avatar
Bill Lynch committed
249
            <input type="submit" name="defaults" value="Restore Defaults">
250
            <input type="submit" name="cancel" value="Cancel">
Matt Tucker's avatar
Matt Tucker committed
251 252
        </td>
    </tr>
253 254 255 256 257
</tfoot>
</table>
</div>

</form>
Matt Tucker's avatar
Matt Tucker committed
258

Bill Lynch's avatar
Bill Lynch committed
259
<jsp:include page="bottom.jsp" flush="true" />