clearspace-status.jsp 8.77 KB
Newer Older
1
<%--
2
  - Copyright (C) 2005-2008 Jive Software. All rights reserved.
3
  -
4 5 6 7 8 9 10 11 12 13 14
  - 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.
15 16
--%>

17
<%@ page import="org.jivesoftware.openfire.SessionManager"
18 19
    errorPage="error.jsp"
%>
20 21 22
<%@ page import="org.jivesoftware.openfire.clearspace.ClearspaceManager" %>
<%@ page import="org.jivesoftware.openfire.session.ComponentSession" %>
<%@ page import="org.jivesoftware.util.JiveGlobals" %>
Sven Tantau's avatar
Sven Tantau committed
23
<%@ page import="org.jivesoftware.util.StringUtils" %>
24 25 26
<%@ page import="java.text.NumberFormat" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.Date" %>
27 28 29 30 31 32 33 34 35

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>

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

<%

36 37 38 39 40 41 42 43 44 45
    boolean test = request.getParameter("test") != null;
    boolean configure = request.getParameter("configure") != null;
    String testPage = "setup/setup-clearspace-integration_test.jsp";
    ClearspaceManager manager = ClearspaceManager.getInstance();
    boolean configured = false;

    // Checks if CS and OF are currently connected
    boolean connectedCS = manager.isClearspaceConnected();
    boolean connectedOF = manager.isOpenfireConnected();

46 47 48 49 50
    // If OF is connected to CS and there is a configure action, configure clearspace
    if (connectedOF && configure) {
        configured = manager.configClearspace();
    }

51
    // This fields will hold the status information of the connection
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
    Date creationDate = null;
    Date lastActivity = null;
    int numServerPackets = 0;
    int numClientPackets = 0;
    int numComponents = 0;
    Collection<ComponentSession> componentSessions = null;

    // If connected collects stats from Clearspace sessions
    if (connectedCS && connectedOF) {
        SessionManager sessionManager = webManager.getSessionManager();
        componentSessions = sessionManager.getComponentSessions();
        for (ComponentSession cs : componentSessions) {
            // All Clearspace sessions start with "clearspace"
            if (cs.getAddress().getDomain().startsWith("clearspace")) {
                if (creationDate == null || cs.getCreationDate().before(creationDate)) {
                    creationDate = cs.getCreationDate();
                }
                if (lastActivity == null || cs.getLastActiveDate().after(lastActivity)) {
                    lastActivity = cs.getLastActiveDate();
                }
                numClientPackets += cs.getNumClientPackets();
                numServerPackets += cs.getNumServerPackets();
                numComponents++;
                break;
            }
        }
    }

    // Number dateFormatter for all numbers on this page:
    NumberFormat numFormatter = NumberFormat.getNumberInstance();
    
83 84 85 86
%>

<html>
<head>
87 88
<title><fmt:message key="clearspace.status.title"/></title>
<meta name="pageID" content="clearspace-status"/>
89

90 91 92 93 94 95 96 97 98 99
<style type="text/css" title="setupStyle" media="screen">
    @import "style/lightbox.css";
    @import "style/ldap.css";
</style>

<script language="JavaScript" type="text/javascript" src="js/prototype.js"></script>
<script language="JavaScript" type="text/javascript" src="js/scriptaculous.js"></script>
<script language="JavaScript" type="text/javascript" src="js/lightbox.js"></script>
<script language="javascript" type="text/javascript" src="js/tooltips/domLib.js"></script>
<script language="javascript" type="text/javascript" src="js/tooltips/domTT.js"></script>
100 101 102 103 104 105
<script src="dwr/engine.js" type="text/javascript"></script>
<script src="dwr/util.js" type="text/javascript"></script>
</head>

<body>

106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
<% if (test) { %>

    <a href="<%= testPage%>" id="lbmessage" title="<fmt:message key="global.test" />" style="display:none;"></a>
    <script type="text/javascript">
        function loadMsg() {
            var lb = new lightbox(document.getElementById('lbmessage'));
            lb.activate();
        }
        setTimeout('loadMsg()', 250);
    </script>

<% } %>

<% if (configure && !configured) { %>

<div class="error">
122
    <fmt:message key="clearspace.status.error.config"/>
123 124 125 126
</div>

<% } %>

127
<% if (connectedCS && connectedOF) { %>
128
<p>
129
<fmt:message key="clearspace.status.connected.description"/>
130 131 132 133 134 135
</p>
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th colspan="2">
136
            <fmt:message key="clearspace.status.connected.table.title" />
137 138 139 140 141 142
        </th>
    </tr>
</thead>
<tbody>
    <tr>
        <td class="c1">
143 144 145 146 147 148 149 150 151 152
            <fmt:message key="clearspace.status.connected.table.label.connected" />
        </td>
        <td>
            <fmt:message key="clearspace.status.connected.table.value.connected" />
        </td>
    </tr>
        <% if (numComponents > 1) { %>
    <tr>
        <td class="c1">
            <fmt:message key="clearspace.status.connected.table.label.num_components" />
153 154 155 156 157
        </td>
        <td>
            <%= numFormatter.format(numComponents) %>
        </td>
    </tr>
158
        <% } %>
159 160
    <tr>
        <td class="c1">
161
            <fmt:message key="clearspace.status.connected.table.label.creation" />
162 163 164 165 166 167 168
        </td>
        <td>
            <%= JiveGlobals.formatDateTime(creationDate) %>
        </td>
    </tr>
    <tr>
        <td class="c1">
169
            <fmt:message key="clearspace.status.connected.table.label.last_active" />
170 171 172 173 174 175 176
        </td>
        <td>
            <%= JiveGlobals.formatDateTime(lastActivity) %>
        </td>
    </tr>
    <tr>
        <td class="c1">
177
            <fmt:message key="clearspace.status.connected.table.label.statistics" />
178 179
        </td>
        <td>
180
            <fmt:message key="clearspace.status.connected.table.label.received" />
181 182 183 184
            <%= numFormatter.format(numClientPackets) %>/<%= numFormatter.format(numServerPackets) %>
        </td>
    </tr>
    <% boolean first = true;
185 186 187
        for (ComponentSession cs : componentSessions) {
            if (first) {
                first = false;  %>
188 189
    <tr>
        <td rowsapn="<%= componentSessions.size() %>" class="c1">
190
            <fmt:message key="clearspace.status.connected.table.label.hostname" />
191 192
        </td>
        <td>
Sven Tantau's avatar
Sven Tantau committed
193
            <%= StringUtils.escapeHTMLTags(cs.getHostAddress()) %>
194
            /
Sven Tantau's avatar
Sven Tantau committed
195
            <%= StringUtils.escapeHTMLTags(cs.getHostName()) %>
196 197
        </td>
    </tr>
198
        <% } else { %>
199 200
    <tr>
        <td>
Sven Tantau's avatar
Sven Tantau committed
201
            <%= StringUtils.escapeHTMLTags(cs.getHostAddress()) %>
202
            /
Sven Tantau's avatar
Sven Tantau committed
203
            <%= StringUtils.escapeHTMLTags(cs.getHostName()) %>
204 205
        </td>
    </tr>
206
        <% } %>
207 208 209 210
</tbody>
</table>
</div>

211
    <% } %>
212 213


214
<% } else { %>
215

216 217 218 219
    <% if (!connectedCS && !connectedOF) { %>
<div class="error">
    <fmt:message key="clearspace.status.error.disconnected.of_and_cs"/>
</div>
220

221 222 223 224 225
<p>
<fmt:message key="clearspace.status.disconnected.of_and_cs.description">
    <fmt:param value="<%= "<a href='clearspace-integration.jsp'>" %>" />
    <fmt:param value="<%= "</a>" %>" />
</fmt:message>
226

227 228 229 230
    <% } else if (!connectedCS) { %>
<div class="error">
    <fmt:message key="clearspace.status.error.disconnected.cs"/>
</div>
231

232 233 234 235 236 237 238 239 240
<p>
<fmt:message key="clearspace.status.disconnected.cs.description">
    <fmt:param value="<%= "<a href='clearspace-integration.jsp'>" %>" />
    <fmt:param value="<%= "</a>" %>" />
</fmt:message>
    <% } else if (!connectedOF) { %>
<div class="error">
    <fmt:message key="clearspace.status.error.disconnected.of"/>
</div>
241

242 243 244 245 246 247 248 249 250 251 252 253
<p>
<fmt:message key="clearspace.status.disconnected.of.description">
    <fmt:param value="<%= "<a href='clearspace-integration.jsp'>" %>" />
    <fmt:param value="<%= "</a>" %>" />
</fmt:message>
    <% } %>
<p>
<fmt:message key="clearspace.status.disconnected.buttons.description"/>
</p>
<form action="clearspace-status.jsp" method="post">
    <!-- BEGIN jive-buttons -->
    <div class="jive-buttons">
254

255 256 257 258 259 260 261 262 263 264 265 266 267
        <!-- BEGIN right-aligned buttons -->
        <div align="left">

            <input type="Submit" name="test" value="<fmt:message key="clearspace.status.disconnected.testbutton" />" id="jive-clearspace-test" border="0">

            <input type="Submit" name="configure" value="<fmt:message key="clearspace.status.disconnected.configbutton" />" id="jive-clearspace-configure" border="0">
        </div>
        <!-- END right-aligned buttons -->

    </div>
    <!-- END jive-buttons -->

</form>
268 269

<% } %>
270 271

</body>
Sven Tantau's avatar
Sven Tantau committed
272
</html>