session-details.jsp 10.1 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4
<%--
  -	$RCSfile$
  -	$Revision$
  -	$Date$
Bill Lynch's avatar
Bill Lynch committed
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
--%>
Bill Lynch's avatar
Bill Lynch committed
11

Matt Tucker's avatar
Matt Tucker committed
12
<%@ page import="org.jivesoftware.util.*,
Matt Tucker's avatar
Matt Tucker committed
13
                 java.util.*,
Matt Tucker's avatar
Matt Tucker committed
14 15 16
                 org.jivesoftware.messenger.*,
                 java.text.DateFormat,
                 java.text.NumberFormat,
Derek DeMoro's avatar
Derek DeMoro committed
17
                 org.jivesoftware.admin.*,
Derek DeMoro's avatar
Derek DeMoro committed
18 19
                 org.jivesoftware.messenger.user.User,
                 org.xmpp.packet.JID,
20 21
                 org.xmpp.packet.Presence,
                 java.net.URLEncoder"
Bill Lynch's avatar
Bill Lynch committed
22 23
    errorPage="error.jsp"
%>
Matt Tucker's avatar
Matt Tucker committed
24

25
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
26
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
Bill Lynch's avatar
Bill Lynch committed
27
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
Matt Tucker's avatar
Matt Tucker committed
28 29 30 31 32 33 34 35 36 37 38

<%  // Get parameters
    String jid = ParamUtils.getParameter(request, "jid");

    // Handle a "go back" click:
    if (request.getParameter("back") != null) {
        response.sendRedirect("session-summary.jsp");
        return;
    }

    // Get the session & address objects
Derek DeMoro's avatar
Derek DeMoro committed
39
    SessionManager sessionManager = webManager.getSessionManager();
Derek DeMoro's avatar
Derek DeMoro committed
40
    JID address = new JID(jid);
41
    ClientSession currentSess = sessionManager.getSession(address);
Derek DeMoro's avatar
Derek DeMoro committed
42
    boolean isAnonymous = address.getNode() == null || "".equals(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
43 44

    // Get a presence manager
Derek DeMoro's avatar
Derek DeMoro committed
45
    PresenceManager presenceManager = webManager.getPresenceManager();
Matt Tucker's avatar
Matt Tucker committed
46 47 48 49

    // Get user object
    User user = null;
    if (!isAnonymous) {
Derek DeMoro's avatar
Derek DeMoro committed
50
        user = webManager.getUserManager().getUser(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
51 52 53 54
    }

    // Handle a "message" click:
    if (request.getParameter("message") != null) {
55
        response.sendRedirect("user-message.jsp?username=" + URLEncoder.encode(user.getUsername(), "UTF-8"));
Matt Tucker's avatar
Matt Tucker committed
56 57 58 59
        return;
    }

    // See if there are multiple sessions for this user:
60
    Collection<ClientSession> sessions = null;
Derek DeMoro's avatar
Derek DeMoro committed
61
    int sessionCount = sessionManager.getSessionCount(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
62
    if (!isAnonymous && sessionCount > 1) {
Derek DeMoro's avatar
Derek DeMoro committed
63
        sessions = sessionManager.getSessions(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
64 65 66 67 68 69
    }

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

Derek DeMoro's avatar
Derek DeMoro committed
70 71
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<%  // Title of this page and breadcrumbs
72
    String title = LocaleUtils.getLocalizedString("session.details.title");
Derek DeMoro's avatar
Derek DeMoro committed
73
    pageinfo.setTitle(title);
74
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(LocaleUtils.getLocalizedString("global.main"), "index.jsp"));
Derek DeMoro's avatar
Derek DeMoro committed
75
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "session-details.jsp"));
Bill Lynch's avatar
Bill Lynch committed
76
    pageinfo.setPageID("session-summary");
Derek DeMoro's avatar
Derek DeMoro committed
77
%>
Bill Lynch's avatar
Bill Lynch committed
78
<jsp:include page="top.jsp" flush="true" />
Derek DeMoro's avatar
Derek DeMoro committed
79
<jsp:include page="title.jsp" flush="true" />
Matt Tucker's avatar
Matt Tucker committed
80 81

<p>
82 83
<fmt:message key="session.details.info">
    <fmt:param value="<%= "<b>"+address.toString()+"</b>" %>" />
84
    <fmt:param value="<%= address.getNode() == null ? "" : "<b>"+address.getNode()+"</b>" %>" />
85 86
</fmt:message>

Matt Tucker's avatar
Matt Tucker committed
87 88 89
</p>

<div class="jive-table">
Bill Lynch's avatar
Bill Lynch committed
90 91 92 93
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th colspan="2">
94
            <fmt:message key="session.details.title" />
Bill Lynch's avatar
Bill Lynch committed
95 96 97 98 99 100
        </th>
    </tr>
</thead>
<tbody>
    <tr>
        <td class="c1">
101
            <fmt:message key="session.details.session_id" />
Bill Lynch's avatar
Bill Lynch committed
102 103 104 105 106 107 108
        </td>
        <td>
            <%= address.toString() %>
        </td>
    </tr>
    <tr>
        <td class="c1">
109
            <fmt:message key="session.details.username" />
Bill Lynch's avatar
Bill Lynch committed
110 111
        </td>
        <td>
Derek DeMoro's avatar
Derek DeMoro committed
112
            <%  String n = address.getNode(); %>
Bill Lynch's avatar
Bill Lynch committed
113 114
            <%  if (n == null || "".equals(n)) { %>

115
                <i> <fmt:message key="session.details.anonymous" /> </i> - <%= address.getResource()==null?"":address.getResource() %>
Bill Lynch's avatar
Bill Lynch committed
116 117 118 119

            <%  } else { %>

                <a href="user-properties.jsp?username=<%= n %>"><%= n %></a>
Matt Tucker's avatar
Matt Tucker committed
120
                - <%= address.getResource()==null?"":address.getResource() %>
Bill Lynch's avatar
Bill Lynch committed
121 122 123 124 125 126

            <%  } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
127
            <fmt:message key="session.details.status" />:
Bill Lynch's avatar
Bill Lynch committed
128 129 130 131 132 133
        </td>
        <td>
            <%
                int status = currentSess.getStatus();
                if (status == Session.STATUS_CLOSED) {
            %>
134
                <fmt:message key="session.details.close" />
Bill Lynch's avatar
Bill Lynch committed
135 136 137 138 139

            <%
                } else if (status == Session.STATUS_CONNECTED) {
            %>

140
                <fmt:message key="session.details.connect" />
Bill Lynch's avatar
Bill Lynch committed
141 142 143 144 145

            <%
                } else if (status == Session.STATUS_STREAMING) {
            %>

146
                <fmt:message key="session.details.streaming" />
Bill Lynch's avatar
Bill Lynch committed
147 148 149 150 151

            <%
                } else if (status == Session.STATUS_AUTHENTICATED) {
            %>

152
                <fmt:message key="session.details.authenticated" />
Bill Lynch's avatar
Bill Lynch committed
153 154 155 156 157

            <%
                } else {
            %>

158
                <fmt:message key="session.details.unknown" />
Bill Lynch's avatar
Bill Lynch committed
159 160 161 162 163 164 165 166

            <%
                }
            %>
        </td>
    </tr>
    <tr>
        <td class="c1">
167
            <fmt:message key="session.details.presence" />:
Bill Lynch's avatar
Bill Lynch committed
168 169 170
        </td>
        <td>
            <%
Derek DeMoro's avatar
Derek DeMoro committed
171
                Presence.Show show = currentSess.getPresence().getShow();
172 173 174 175 176 177 178
                String statusTxt = currentSess.getPresence().getStatus();
                if (statusTxt != null) {
                    statusTxt = " -- " + statusTxt;
                }
                else {
                    statusTxt = "";
                }
Derek DeMoro's avatar
Derek DeMoro committed
179
                if (show == Presence.Show.away) {
Bill Lynch's avatar
Bill Lynch committed
180 181 182
            %>

                <img src="images/bullet-yellow-14x14.gif" width="14" height="14" border="0" title="Away">
183
                <fmt:message key="session.details.away" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
184 185

            <%
Derek DeMoro's avatar
Derek DeMoro committed
186
                } else if (show == Presence.Show.chat) {
Bill Lynch's avatar
Bill Lynch committed
187 188
            %>
                <img src="images/bullet-green-14x14.gif" width="14" height="14" border="0" title="Available to Chat">
189
                <fmt:message key="session.details.chat_available" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
190
            <%
Derek DeMoro's avatar
Derek DeMoro committed
191
                } else if (show == Presence.Show.dnd) {
Bill Lynch's avatar
Bill Lynch committed
192 193 194
            %>

                <img src="images/bullet-red-14x14.gif" width="14" height="14" border="0" title="Do not Disturb">
195
                <fmt:message key="session.details.not_disturb" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
196 197

            <%
Derek DeMoro's avatar
Derek DeMoro committed
198
                } else if (show == null) {
Bill Lynch's avatar
Bill Lynch committed
199 200 201
            %>

                <img src="images/bullet-green-14x14.gif" width="14" height="14" border="0" title="Online">
202
                <fmt:message key="session.details.online" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
203 204

            <%
Derek DeMoro's avatar
Derek DeMoro committed
205
                } else if (show == Presence.Show.xa) {
Bill Lynch's avatar
Bill Lynch committed
206 207
            %>

208
                <img src="images/bullet-yellow-14x14.gif" width="14" height="14" border="0" title="Extended Away">
209
                <fmt:message key="session.details.extended" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
210 211 212 213 214

            <%
                } else {
            %>

215
                <fmt:message key="session.details.unknown" />
Bill Lynch's avatar
Bill Lynch committed
216 217 218 219 220 221 222 223

            <%
                }
            %>
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
224
            <fmt:message key="session.details.session_created" />
Bill Lynch's avatar
Bill Lynch committed
225 226
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
227
            <%= JiveGlobals.formatDateTime(currentSess.getCreationDate()) %>
Bill Lynch's avatar
Bill Lynch committed
228 229 230 231
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
232
            <fmt:message key="session.details.last_active" />
Bill Lynch's avatar
Bill Lynch committed
233 234
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
235
            <%= JiveGlobals.formatDateTime(currentSess.getLastActiveDate()) %>
Bill Lynch's avatar
Bill Lynch committed
236 237 238 239
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
240
            <fmt:message key="session.details.statistics" />
Bill Lynch's avatar
Bill Lynch committed
241 242
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
243
            <fmt:message key="session.details.received" />
Bill Lynch's avatar
Bill Lynch committed
244 245 246 247 248
            <%= numFormatter.format(currentSess.getNumClientPackets()) %>/<%= numFormatter.format(currentSess.getNumServerPackets()) %>
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
249
            <fmt:message key="session.details.hostname" />
Bill Lynch's avatar
Bill Lynch committed
250 251 252 253 254 255 256 257
        </td>
        <td>
            <%= currentSess.getConnection().getInetAddress().getHostAddress() %>
            /
            <%= currentSess.getConnection().getInetAddress().getHostName() %>
        </td>
    </tr>
</tbody>
Matt Tucker's avatar
Matt Tucker committed
258 259 260 261 262 263 264
</table>
</div>

<%  // Show a list of multiple user sessions if there is more than 1 session:
    if (sessionCount > 1) {
%>
    <p>
265
    <b><fmt:message key="session.details.multiple_session" /></b>
Matt Tucker's avatar
Matt Tucker committed
266 267 268 269 270 271
    </p>

    <div class="jive-table">
    <table cellpadding="3" cellspacing="1" border="0" width="100%">
    <tr>
        <th>&nbsp;</th>
272 273 274 275 276 277
        <th><fmt:message key="session.details.name" /></th>
        <th><fmt:message key="session.details.resource" /></th>
        <th><fmt:message key="session.details.status" /></th>
        <th nowrap colspan="2"><fmt:message key="session.details.if_presence" /></th>
        <th nowrap><fmt:message key="session.details.clientip" /></th>
        <th nowrap><fmt:message key="session.details.close_connect" /></th>
Matt Tucker's avatar
Matt Tucker committed
278 279 280 281
    </tr>

    <%  int count = 0;
        String linkURL = "session-details.jsp";
282
        for (ClientSession sess : sessions) {
Matt Tucker's avatar
Matt Tucker committed
283 284 285
            count++;
            boolean current = sess.getAddress().equals(address);
    %>
286
        <%@ include file="session-row.jspf" %>
Matt Tucker's avatar
Matt Tucker committed
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307

    <%  } %>

    </table>
    </div>

    <br>

    <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
        <td width="1%" nowrap>

            <div class="jive-table">
            <table cellpadding="0" cellspacing="0" border="0">
            <tr class="jive-current"><td><img src="images/blank.gif" width="12" height="12" border="0"></td></tr>
            </table>
            </div>

        </td>
        <td width="99%">

308
            &nbsp; = <fmt:message key="session.details.session_detail" />
Matt Tucker's avatar
Matt Tucker committed
309 310 311 312 313 314 315 316 317 318 319 320

        </td>
    </tr>
    </table>

<%  } %>

<br>

<form action="session-details.jsp">
<input type="hidden" name="jid" value="<%= jid %>">
<center>
Bill Lynch's avatar
Bill Lynch committed
321 322 323 324 325
<%--<%  if (!isAnonymous && presenceManager.isAvailable(user)) { %>--%>
<%----%>
<%--    <input type="submit" name="message" value="Message this Session">--%>
<%----%>
<%--<%  } %>--%>
Matt Tucker's avatar
Matt Tucker committed
326
<input type="submit" name="back" value="<fmt:message key="session.details.back_button" />">   
Matt Tucker's avatar
Matt Tucker committed
327 328 329
</center>
</form>

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