session-details.jsp 8.85 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.*,
Bill Lynch's avatar
Bill Lynch committed
18 19 20
                 org.jivesoftware.messenger.user.User"
    errorPage="error.jsp"
%>
Matt Tucker's avatar
Matt Tucker committed
21

22
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
Matt Tucker's avatar
Matt Tucker committed
23

Bill Lynch's avatar
Bill Lynch committed
24
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
Matt Tucker's avatar
Matt Tucker committed
25 26 27 28 29 30 31 32 33 34 35

<%  // 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
36
    SessionManager sessionManager = webManager.getSessionManager();
Matt Tucker's avatar
Matt Tucker committed
37 38 39 40 41
    XMPPAddress address = XMPPAddress.parseJID(jid);
    Session currentSess = sessionManager.getSession(address);
    boolean isAnonymous = address.getName() == null || "".equals(address.getName());

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

    // Get user object
    User user = null;
    if (!isAnonymous) {
Derek DeMoro's avatar
Derek DeMoro committed
47
        user = webManager.getUserManager().getUser(address.getName());
Matt Tucker's avatar
Matt Tucker committed
48 49 50 51
    }

    // Handle a "message" click:
    if (request.getParameter("message") != null) {
52
        response.sendRedirect("user-message.jsp?username=" + user.getUsername());
Matt Tucker's avatar
Matt Tucker committed
53 54 55 56
        return;
    }

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

    // Date dateFormatter for all dates on this page:
    DateFormat dateFormatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.SHORT);

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

Derek DeMoro's avatar
Derek DeMoro committed
70 71 72 73
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<%  // Title of this page and breadcrumbs
    String title = "Session Details";
    pageinfo.setTitle(title);
Bill Lynch's avatar
Bill Lynch committed
74
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("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 82 83 84 85 86

<p>
Below are session details for the session <b><%= address.toString() %></b>. If the
user <b><%= address.getName() %></b> has multiple sessions open, they will appear below.
</p>

<div class="jive-table">
Bill Lynch's avatar
Bill Lynch committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th colspan="2">
            Session Details
        </th>
    </tr>
</thead>
<tbody>
    <tr>
        <td class="c1">
            Session ID:
        </td>
        <td>
            <%= address.toString() %>
        </td>
    </tr>
    <tr>
        <td class="c1">
            User Name &amp; Resource:
        </td>
        <td>
            <%  String n = address.getName(); %>
            <%  if (n == null || "".equals(n)) { %>

                <i>Anonymous</i> - <%= address.getResource() %>

            <%  } else { %>

                <a href="user-properties.jsp?username=<%= n %>"><%= n %></a>
                - <%= address.getResource() %>

            <%  } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
            Status:
        </td>
        <td>
            <%
                int status = currentSess.getStatus();
                if (status == Session.STATUS_CLOSED) {
            %>
                Closed

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

                Connected

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

                Streaming

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

                Authenticated

            <%
                } else {
            %>

                Unknown

            <%
                }
            %>
        </td>
    </tr>
    <tr>
        <td class="c1">
            Presence:
        </td>
        <td>
            <%
                int show = currentSess.getPresence().getShow();
169 170 171 172 173 174 175
                String statusTxt = currentSess.getPresence().getStatus();
                if (statusTxt != null) {
                    statusTxt = " -- " + statusTxt;
                }
                else {
                    statusTxt = "";
                }
Bill Lynch's avatar
Bill Lynch committed
176 177 178 179
                if (show == Presence.SHOW_AWAY) {
            %>

                <img src="images/bullet-yellow-14x14.gif" width="14" height="14" border="0" title="Away">
180
                Away <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
181 182 183 184 185

            <%
                } else if (show == Presence.SHOW_CHAT) {
            %>
                <img src="images/bullet-green-14x14.gif" width="14" height="14" border="0" title="Available to Chat">
186
                Available to Chat <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
187 188 189 190 191
            <%
                } else if (show == Presence.SHOW_DND) {
            %>

                <img src="images/bullet-red-14x14.gif" width="14" height="14" border="0" title="Do not Disturb">
192
                Do Not Disturb <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
193 194 195 196 197 198

            <%
                } else if (show == Presence.SHOW_NONE) {
            %>

                <img src="images/bullet-green-14x14.gif" width="14" height="14" border="0" title="Online">
199
                Online <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
200 201 202 203 204 205

            <%
                } else if (show == Presence.SHOW_XA) {
            %>

                <img src="images/bullet-red-14x14.gif" width="14" height="14" border="0" title="Extended Away">
206
                Extended Away <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254

            <%
                } else {
            %>

                Unknown/Not Recognized

            <%
                }
            %>
        </td>
    </tr>
    <tr>
        <td class="c1">
            Session Created:
        </td>
        <td>
            <%= dateFormatter.format(currentSess.getCreationDate()) %>
        </td>
    </tr>
    <tr>
        <td class="c1">
            Session Last Active:
        </td>
        <td>
            <%= dateFormatter.format(currentSess.getLastActiveDate()) %>
        </td>
    </tr>
    <tr>
        <td class="c1">
            Session Statistics:
        </td>
        <td>
            Packets Received/Sent:
            <%= numFormatter.format(currentSess.getNumClientPackets()) %>/<%= numFormatter.format(currentSess.getNumServerPackets()) %>
        </td>
    </tr>
    <tr>
        <td class="c1">
            Client IP / Hostname:
        </td>
        <td>
            <%= currentSess.getConnection().getInetAddress().getHostAddress() %>
            /
            <%= currentSess.getConnection().getInetAddress().getHostName() %>
        </td>
    </tr>
</tbody>
Matt Tucker's avatar
Matt Tucker committed
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
</table>
</div>

<%  // Show a list of multiple user sessions if there is more than 1 session:
    if (sessionCount > 1) {
%>
    <p>
    <b>Multiple User Sessions</b>
    </p>

    <div class="jive-table">
    <table cellpadding="3" cellspacing="1" border="0" width="100%">
    <tr>
        <th>&nbsp;</th>
        <th>Name</th>
        <th>Resource</th>
        <th>Status</th>
        <th nowrap colspan="2">Presence (if authenticated)</th>
        <th nowrap>Client IP</th>
        <th nowrap>Close Connection</th>
    </tr>

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

    <%  } %>

    </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%">

            &nbsp; = Current session details above.

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

<%  } %>

<br>

<form action="session-details.jsp">
<input type="hidden" name="jid" value="<%= jid %>">
<center>
Bill Lynch's avatar
Bill Lynch committed
318 319 320 321 322
<%--<%  if (!isAnonymous && presenceManager.isAvailable(user)) { %>--%>
<%----%>
<%--    <input type="submit" name="message" value="Message this Session">--%>
<%----%>
<%--<%  } %>--%>
Matt Tucker's avatar
Matt Tucker committed
323 324 325 326
<input type="submit" name="back" value="Back to Summary">
</center>
</form>

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