server-properties.jsp 11.1 KB
Newer Older
Bill Lynch's avatar
Bill Lynch committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<%--
  -	$RCSfile$
  -	$Revision$
  -	$Date$
  -
  - 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.
--%>

<%@ page import="java.io.File,
                 java.util.*,
                 org.jivesoftware.util.*,
                 org.jivesoftware.util.ParamUtils,
16
                 org.jivesoftware.util.JiveGlobals,
Bill Lynch's avatar
Bill Lynch committed
17 18 19
                 org.jivesoftware.admin.AdminPageBean"
    errorPage="error.jsp"
%>
20
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
Bill Lynch's avatar
Bill Lynch committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />

<%!
    /**
     * 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();
        for (int i=0; i<strChars.length; i++) {
            if (Character.isWhitespace(strChars[i])) {
                count = 0;
            }
            count++;
            buf.append(strChars[i]);
            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);
            response.sendRedirect("server-properties.jsp?deletesuccess=true");
            return;
        }
    }

    Map errors = new HashMap();
    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);
            response.sendRedirect("server-properties.jsp?success=true");
            return;
        }
    }

    List properties = JiveGlobals.getPropertyNames();
    Collections.sort(properties, new Comparator() {
        public int compare(Object o1, Object o2) {
            String s1 = (String)o1;
            String s2 = (String)o2;
            return s1.toLowerCase().compareTo(s2.toLowerCase());
        }
    });

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

<%  // Title of this page and breadcrumbs
106
    String title = LocaleUtils.getLocalizedString("server.properties.title");
Bill Lynch's avatar
Bill Lynch committed
107
    pageinfo.setTitle(title);
108
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(LocaleUtils.getLocalizedString("global.main"), "index.jsp"));
Bill Lynch's avatar
Bill Lynch committed
109 110 111 112 113 114 115 116
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "server-properties.jsp"));
    pageinfo.setPageID("server-props");
%>

<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />

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

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

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

    <div class="jive-error">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
        <tr><td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
        <td class="jive-icon-label">
129
        <fmt:message key="server.properties.error" />
Bill Lynch's avatar
Bill Lynch committed
130 131 132 133 134 135 136 137 138 139 140 141
        </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>
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
        <td class="jive-icon-label">
142
        <fmt:message key="server.properties.saved" />
Bill Lynch's avatar
Bill Lynch committed
143 144 145 146 147 148 149 150 151 152 153 154
        </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>
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
        <td class="jive-icon-label">
155
        <fmt:message key="server.properties.deleted" />
Bill Lynch's avatar
Bill Lynch committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

<%  if (edit) { %>

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

<%  } %>

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

    <div class="jive-error">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
        <tr><td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
        <td class="jive-icon-label">
185
        <fmt:message key="server.properties.error_deleting" />
Bill Lynch's avatar
Bill Lynch committed
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 230
        </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>
231 232 233
        <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>
234
        <th style="text-align:center;"><fmt:message key="global.delete" /></th>
Bill Lynch's avatar
Bill Lynch committed
235 236 237 238 239 240 241 242
    </tr>
</thead>
<tbody>

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

        <tr>
            <td colspan="4">
243
                <fmt:message key="server.properties.no_property" />
Bill Lynch's avatar
Bill Lynch committed
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
            </td>
        </tr>

    <%  } %>

    <%  for (int i=0; i<properties.size(); i++) {
            String n = (String)properties.get(i);
            String v = JiveGlobals.getProperty(n);
            v = StringUtils.replace(StringUtils.escapeHTMLTags(v), "\n", "<br>");
    %>
        <tr class="<%= (n.equals(propName) ? "hilite" : "") %>">

            <td>
                <div class="hidebox" style="width:150px;">
                <span title="<%= StringUtils.escapeHTMLTags(n) %>">
                <%= StringUtils.escapeHTMLTags(n) %>
                </span>
                </div>
            </td>
            <td>
                <div class="hidebox" style="width:350px;">
                    <%  if (n.indexOf("passwd") > -1 || n.indexOf("password") > -1 || n.indexOf("cookieKey") > -1) { %>
                        <span style="color:#999;"><i>hidden</i></span>
                    <%  } else { %>
                        <%= ("".equals(v) ? "&nbsp;" : v) %>
                    <%  } %>
                </div>
            </td>
            <td align="center"><a href="#" onclick="doedit('<%= StringUtils.replace(n,"'","''") %>');"
273
                ><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
274 275 276
                >
            </td>
            <td align="center"><a href="#" onclick="return dodelete('<%= StringUtils.replace(n,"'","''") %>');"
277
                ><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 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
                >
            </td>
        </tr>

    <%  } %>

</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 369
        </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>

<jsp:include page="bottom.jsp" flush="true" />