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

11
<%@ page import="java.util.*,
Bill Lynch's avatar
Bill Lynch committed
12 13
                 org.jivesoftware.util.*,
                 org.jivesoftware.util.ParamUtils,
14
                 org.jivesoftware.util.JiveGlobals"
Bill Lynch's avatar
Bill Lynch committed
15 16
    errorPage="error.jsp"
%>
17
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
Bill Lynch's avatar
Bill Lynch committed
18 19
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />

20 21 22
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"  />
<% webManager.init(request, response, session, application, out ); %>

Bill Lynch's avatar
Bill Lynch committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36
<%!
    /**
     * Make sure the String can wrap at 80 chars.
     *
     * @param str the string.
     * @return a wrappable string.
     */
    String wrappableString(String str) {
        if (str.length() <= 60) {
            return str;
        }
        int count = 0;
        StringBuffer buf = new StringBuffer();
        char [] strChars = str.toCharArray();
37 38
        for (char strChar : strChars) {
            if (Character.isWhitespace(strChar)) {
Bill Lynch's avatar
Bill Lynch committed
39 40 41
                count = 0;
            }
            count++;
42
            buf.append(strChar);
Bill Lynch's avatar
Bill Lynch committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
            if (count >= 60) {
                buf.append(" ");
                count = 0;
            }
        }
        return buf.toString();
    }

 %>

<%
    String propName = ParamUtils.getParameter(request,"propName");
    String propValue = ParamUtils.getParameter(request,"propValue",true);
    boolean edit = ParamUtils.getBooleanParameter(request,"edit");
    boolean save = request.getParameter("save") != null;
    boolean delete = ParamUtils.getBooleanParameter(request,"del");

    if (request.getParameter("cancel") != null) {
        response.sendRedirect("server-properties.jsp");
        return;
    }

    if (delete) {
        if (propName != null) {
            JiveGlobals.deleteProperty(propName);
68 69
            // Log the event
            webManager.logEvent("deleted server property "+propName, null);
Bill Lynch's avatar
Bill Lynch committed
70 71 72 73 74
            response.sendRedirect("server-properties.jsp?deletesuccess=true");
            return;
        }
    }

75
    Map<String, String> errors = new HashMap<String, String>();
Bill Lynch's avatar
Bill Lynch committed
76 77 78 79 80 81 82 83 84 85 86 87
    if (save) {
        if (propName == null || "".equals(propName.trim())) {
            errors.put("propName","");
        }
        if (propValue == null) {
            errors.put("propValue","");
        }
        else if (propValue.length() > 4000) {
            errors.put("propValueLength","");
        }
        if (errors.size() == 0) {
            JiveGlobals.setProperty(propName, propValue);
88 89
            // Log the event
            webManager.logEvent("set server property "+propName, propName+" = "+propValue);
Bill Lynch's avatar
Bill Lynch committed
90 91 92 93 94
            response.sendRedirect("server-properties.jsp?success=true");
            return;
        }
    }

95 96 97
    List<String> properties = JiveGlobals.getPropertyNames();
    Collections.sort(properties, new Comparator<String>() {
        public int compare(String s1, String s2) {
Bill Lynch's avatar
Bill Lynch committed
98 99 100 101 102 103 104 105 106
            return s1.toLowerCase().compareTo(s2.toLowerCase());
        }
    });

    if (edit) {
        propValue = JiveGlobals.getProperty(propName);
    }
%>

107 108 109 110 111 112 113
<html>
    <head>
        <title><fmt:message key="server.properties.title"/></title>
        <meta name="pageID" content="server-props"/>
        <meta name="helpPage" content="manage_system_properties.html"/>
    </head>
    <body>
Bill Lynch's avatar
Bill Lynch committed
114 115

<p>
116
<fmt:message key="server.properties.info" />
Bill Lynch's avatar
Bill Lynch committed
117 118
</p>

119
<p><b><fmt:message key="server.properties.system" /></b></p>
Bill Lynch's avatar
Bill Lynch committed
120 121 122 123 124 125

<%  if (errors.size() > 0) { %>

    <div class="jive-error">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
126
        <tr><td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
127
        <td class="jive-icon-label">
128
        <fmt:message key="server.properties.error" />
Bill Lynch's avatar
Bill Lynch committed
129 130 131 132 133 134 135 136 137 138
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } else if ("true".equals(request.getParameter("success"))) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
139
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
140
        <td class="jive-icon-label">
141
        <fmt:message key="server.properties.saved" />
Bill Lynch's avatar
Bill Lynch committed
142 143 144 145 146 147 148 149 150 151
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } else if ("true".equals(request.getParameter("deletesuccess"))) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
152
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
153
        <td class="jive-icon-label">
154
        <fmt:message key="server.properties.deleted" />
Bill Lynch's avatar
Bill Lynch committed
155 156 157 158 159 160 161 162 163 164 165 166
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

<%  if (edit) { %>

    <div class="jive-info">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
167
        <tr><td class="jive-icon"><img src="images/info-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
168
        <td class="jive-icon-label">
169
        <fmt:message key="server.properties.edit_property" />
Bill Lynch's avatar
Bill Lynch committed
170 171 172 173 174 175 176 177 178 179 180 181
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

<%  if (request.getParameter("delerror") != null) { %>

    <div class="jive-error">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
182
        <tr><td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
183
        <td class="jive-icon-label">
184
        <fmt:message key="server.properties.error_deleting" />
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 229
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

<script language="JavaScript" type="text/javascript">
function doedit(propName) {
    document.propform.propName.value = propName;
    document.propform.edit.value = 'true';
    document.propform.action = document.propform.action + '#edit';
    document.propform.submit();
}
function dodelete(propName) {
    var dodelete = confirm('Are you sure you want to delete this property?');
    if (dodelete) {
        document.propform.propName.value = propName;
        document.propform.del.value = 'true';
        document.propform.submit();
        return true;
    }
    else {
        return false;
    }
}
</script>

<form action="server-properties.jsp" method="post" name="propform">
<input type="hidden" name="edit" value="">
<input type="hidden" name="del" value="">
<input type="hidden" name="propName" value="">

<style type="text/css">
.hidebox {
    text-overflow : ellipsis;
    overflow : hidden;
    white-space : nowrap;
}
</style>

<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
230 231 232
        <th nowrap><fmt:message key="server.properties.name" /></th>
        <th nowrap><fmt:message key="server.properties.value" /></th>
        <th style="text-align:center;"><fmt:message key="server.properties.edit" /></th>
233
        <th style="text-align:center;"><fmt:message key="global.delete" /></th>
Bill Lynch's avatar
Bill Lynch committed
234 235 236 237 238 239 240 241
    </tr>
</thead>
<tbody>

    <%  if (properties.size() == 0) { %>

        <tr>
            <td colspan="4">
242
                <fmt:message key="server.properties.no_property" />
Bill Lynch's avatar
Bill Lynch committed
243 244 245 246 247
            </td>
        </tr>

    <%  } %>

248 249 250
    <% for (String n : properties) {
        String v = JiveGlobals.getProperty(n);
        v = StringUtils.replace(StringUtils.escapeHTMLTags(v), "\n", "<br>");
Bill Lynch's avatar
Bill Lynch committed
251
    %>
252
    <tr class="<%= (n.equals(propName) ? "hilite" : "") %>">
Bill Lynch's avatar
Bill Lynch committed
253

254 255
        <td>
            <div class="hidebox" style="width:200px;">
Bill Lynch's avatar
Bill Lynch committed
256 257 258
                <span title="<%= StringUtils.escapeHTMLTags(n) %>">
                <%= StringUtils.escapeHTMLTags(n) %>
                </span>
259 260 261 262 263 264 265 266 267 268 269 270 271 272
            </div>
        </td>
        <td>
            <div class="hidebox" style="width:300px;">
                <% if (n.indexOf("passwd") > -1 || n.indexOf("password") > -1 || n.indexOf("cookieKey") > -1) { %>
                <span style="color:#999;"><i>hidden</i></span>
                <% } else { %>
                <span title="<%= ("".equals(v) ? "&nbsp;" : v) %>"><%= ("".equals(v) ? "&nbsp;" : v) %></span>
                <% } %>
            </div>
        </td>
        <td align="center"><a href="#" onclick="doedit('<%= StringUtils.replace(n,"'","''") %>');"
                ><img src="images/edit-16x16.gif" width="16" height="16"
                      alt="<fmt:message key="server.properties.alt_edit" />" border="0"></a
Bill Lynch's avatar
Bill Lynch committed
273
                >
274 275 276 277
        </td>
        <td align="center"><a href="#" onclick="return dodelete('<%= StringUtils.replace(n,"'","''") %>');"
                ><img src="images/delete-16x16.gif" width="16" height="16"
                      alt="<fmt:message key="server.properties.alt_delete" />" border="0"></a
Bill Lynch's avatar
Bill Lynch committed
278
                >
279 280
        </td>
    </tr>
Bill Lynch's avatar
Bill Lynch committed
281

282
    <% } %>
Bill Lynch's avatar
Bill Lynch committed
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300

</tbody>
</table>
</div>

</form>

<br><br>

<a name="edit"></a>
<form action="server-properties.jsp" method="post" name="editform">

<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th colspan="2">
            <%  if (edit) { %>
301
                <fmt:message key="server.properties.edit_property_title" />
Bill Lynch's avatar
Bill Lynch committed
302
            <%  } else { %>
303
                <fmt:message key="server.properties.new_property" />
Bill Lynch's avatar
Bill Lynch committed
304 305 306 307 308 309 310
            <%  } %>
        </th>
    </tr>
</thead>
<tbody>
    <tr valign="top">
        <td>
311
            <fmt:message key="server.properties.name" />:
Bill Lynch's avatar
Bill Lynch committed
312 313 314 315 316 317 318 319 320 321 322 323 324
        </td>
        <td>
            <%  if (edit) { %>

                <input type="hidden" name="propName" value="<%= StringUtils.escapeHTMLTags(propName) %>">
                <%= StringUtils.escapeHTMLTags(propName) %>

            <%  } else { %>

                <input type="text" name="propName" size="40" maxlength="100" value="<%= (propName != null ? StringUtils.escapeHTMLTags(propName) : "") %>">

                <%  if (errors.containsKey("propName")) { %>

325
                    <br><span class="jive-error-text"><fmt:message key="server.properties.enter_property_name" /></span>
Bill Lynch's avatar
Bill Lynch committed
326 327 328 329 330 331 332 333

                <%  } %>

            <%  } %>
        </td>
    </tr>
    <tr valign="top">
        <td>
334
            <fmt:message key="server.properties.value" />:
Bill Lynch's avatar
Bill Lynch committed
335 336 337 338 339 340
        </td>
        <td>
            <textarea cols="45" rows="5" name="propValue" wrap="virtual"><%= (propValue != null ? StringUtils.escapeHTMLTags(propValue) : "") %></textarea>

            <%  if (errors.containsKey("propValue")) { %>

341
                <br><span class="jive-error-text"><fmt:message key="server.properties.enter_property_value" /></span>
Bill Lynch's avatar
Bill Lynch committed
342 343 344

            <%  } else if (errors.containsKey("propValueLength")) { %>

345
                <br><span class="jive-error-text"><fmt:message key="server.properties.max_character" /></span>
Bill Lynch's avatar
Bill Lynch committed
346 347 348 349 350 351 352 353

            <%  } %>
        </td>
    </tr>
</tbody>
<tfoot>
    <tr>
        <td colspan="2">
354 355
            <input type="submit" name="save" value="<fmt:message key="global.save_property" />">
            <input type="submit" name="cancel" value="<fmt:message key="global.cancel" />">
Bill Lynch's avatar
Bill Lynch committed
356 357 358 359 360 361 362 363 364 365 366 367 368
        </td>
    </tr>
</tfoot>
</table>
</div>

</form>

<br><br><br><br><br><br>
<br><br><br><br><br><br>
<br><br><br><br><br><br>
<br><br><br><br><br><br>

369 370
    </body>
</html>