server-session-details.jsp 8.32 KB
Newer Older
Gaston Dombiak's avatar
Gaston Dombiak committed
1 2 3 4
<%--
  -	$Revision$
  -	$Date$
  -
5
  - Copyright (C) 2004-2008 Jive Software. All rights reserved.
Gaston Dombiak's avatar
Gaston Dombiak committed
6 7
  -
  - This software is published under the terms of the GNU Public License (GPL),
8 9
  - a copy of which is included in this distribution, or a commercial license
  - agreement with Jive.
Gaston Dombiak's avatar
Gaston Dombiak committed
10 11
--%>

12
<%@ page import="org.jivesoftware.openfire.SessionManager,
13 14
                 org.jivesoftware.openfire.session.IncomingServerSession,
                 org.jivesoftware.openfire.session.OutgoingServerSession,
15 16
                 org.jivesoftware.util.JiveGlobals,
                 org.jivesoftware.util.ParamUtils,
17
                java.text.NumberFormat"
Gaston Dombiak's avatar
Gaston Dombiak committed
18 19
    errorPage="error.jsp"
%>
20 21 22
<%@ page import="java.util.Calendar" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.List" %>
Gaston Dombiak's avatar
Gaston Dombiak committed
23 24 25

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

Gaston Dombiak's avatar
Gaston Dombiak committed
27
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
28
<% webManager.init(request, response, session, application, out ); %>
Gaston Dombiak's avatar
Gaston Dombiak committed
29

30
<% // Get parameters
Gaston Dombiak's avatar
Gaston Dombiak committed
31 32 33 34 35 36 37 38 39 40
    String hostname = ParamUtils.getParameter(request, "hostname");

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

    // Get the session & address objects
    SessionManager sessionManager = webManager.getSessionManager();
41
    List<IncomingServerSession> inSessions = sessionManager.getIncomingServerSessions(hostname);
Gaston Dombiak's avatar
Gaston Dombiak committed
42 43 44 45 46 47
    OutgoingServerSession outSession = sessionManager.getOutgoingServerSession(hostname);

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

48 49 50 51 52 53
<html>
    <head>
        <title><fmt:message key="server.session.details.title"/></title>
        <meta name="pageID" content="server-session-summary"/>
    </head>
    <body>
Gaston Dombiak's avatar
Gaston Dombiak committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

<p>
<fmt:message key="server.session.details.info">
    <fmt:param value="<%= "<b>"+hostname+"</b>" %>" />
</fmt:message>

</p>

<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th colspan="2">
            <fmt:message key="server.session.details.title" />
        </th>
    </tr>
</thead>
<tbody>
    <tr>
        <td class="c1">
            <fmt:message key="server.session.label.connection" />
        </td>
        <td>
77
        <% if (!inSessions.isEmpty() && outSession == null) { %>
78
            <img src="images/incoming_32x16.gif" width="32" height="16" border="0" title="<fmt:message key='server.session.connection.incoming' />" alt="<fmt:message key='server.session.connection.incoming' />">
Gaston Dombiak's avatar
Gaston Dombiak committed
79
            <fmt:message key="server.session.connection.incoming" />
80
        <% } else if (inSessions.isEmpty() && outSession != null) { %>
81
            <img src="images/outgoing_32x16.gif" width="32" height="16" border="0" title="<fmt:message key='server.session.connection.outgoing' />" alt="<fmt:message key='server.session.connection.outgoing' />">
Gaston Dombiak's avatar
Gaston Dombiak committed
82 83
            <fmt:message key="server.session.connection.outgoing" />
        <% } else { %>
84
            <img src="images/both_32x16.gif" width="32" height="16" border="0" title="<fmt:message key='server.session.connection.both' />" alt="<fmt:message key='server.session.connection.both' />">
Gaston Dombiak's avatar
Gaston Dombiak committed
85 86 87 88 89 90 91 92 93
            <fmt:message key="server.session.connection.both" />
        <% } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
            <fmt:message key="server.session.details.hostname" />
        </td>
        <td>
94
        <% if (!inSessions.isEmpty()) { %>
95
            <%= inSessions.get(0).getHostAddress() %>
Gaston Dombiak's avatar
Gaston Dombiak committed
96
            /
97
            <%= inSessions.get(0).getHostName() %>
Gaston Dombiak's avatar
Gaston Dombiak committed
98
        <% } else if (outSession != null) { %>
99
            <%= outSession.getHostAddress() %>
Gaston Dombiak's avatar
Gaston Dombiak committed
100
            /
101
            <%= outSession.getHostName() %>
Gaston Dombiak's avatar
Gaston Dombiak committed
102 103 104 105 106 107 108 109
        <% } %>
        </td>
    </tr>
</tbody>
</table>
</div>
<br>

110 111
<%  // Show details of the incoming sessions
    for (IncomingServerSession inSession : inSessions) {
Gaston Dombiak's avatar
Gaston Dombiak committed
112 113 114 115 116
%>
    <b><fmt:message key="server.session.details.incoming_session" /></b>
    <div class="jive-table">
    <table cellpadding="3" cellspacing="1" border="0" width="100%">
    <tr>
117
        <th width="35%" colspan="2"><fmt:message key="server.session.details.streamid" /></th>
Gaston Dombiak's avatar
Gaston Dombiak committed
118 119
        <th width="20%"><fmt:message key="server.session.label.creation" /></th>
        <th width="20%"><fmt:message key="server.session.label.last_active" /></th>
120
        <th width="25%" nowrap><fmt:message key="server.session.details.incoming_statistics" /></th>
Gaston Dombiak's avatar
Gaston Dombiak committed
121 122
    </tr>
    <tr>
123
        <%  if (inSession.isSecure()) { %>
124
            <td width="1%">
125
                <img src="images/lock.gif" width="16" height="16" border="0" alt="">
126 127
            </td>
         <% } else { %>
128
            <td width="1%"><img src="images/blank.gif" width="1" height="1" alt=""></td>
129
         <% } %>
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
        <%
            Date creationDate = inSession.getCreationDate();
            Date lastActiveDate = inSession.getLastActiveDate();

            Calendar creationCal = Calendar.getInstance();
            creationCal.setTime(creationDate);

            Calendar lastActiveCal = Calendar.getInstance();
            lastActiveCal.setTime(lastActiveDate);

            Calendar nowCal = Calendar.getInstance();

            boolean sameCreationDay = nowCal.get(Calendar.DAY_OF_YEAR) == creationCal.get(Calendar.DAY_OF_YEAR) && nowCal.get(Calendar.YEAR) == creationCal.get(Calendar.YEAR);
            boolean sameActiveDay = nowCal.get(Calendar.DAY_OF_YEAR) == lastActiveCal.get(Calendar.DAY_OF_YEAR) && nowCal.get(Calendar.YEAR) == lastActiveCal.get(Calendar.YEAR);
        %>
Gaston Dombiak's avatar
Gaston Dombiak committed
145
        <td><%= inSession.getStreamID()%></td>
146 147
        <td align="center"><%= sameCreationDay ? JiveGlobals.formatTime(creationDate) : JiveGlobals.formatDateTime(creationDate) %></td>
        <td align="center"><%= sameActiveDay ? JiveGlobals.formatTime(lastActiveDate) : JiveGlobals.formatDateTime(lastActiveDate) %></td>
148
        <td align="center"><%= numFormatter.format(inSession.getNumClientPackets()) %></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162
    </tr>
    </table>
    </div>

    <br>
<%  } %>

<%  // Show details of the incoming session
    if (outSession != null) {
%>
    <b><fmt:message key="server.session.details.outgoing_session" /></b>
    <div class="jive-table">
    <table cellpadding="3" cellspacing="1" border="0" width="100%">
    <tr>
163
        <th width="35%" colspan="2"><fmt:message key="server.session.details.streamid" /></th>
Gaston Dombiak's avatar
Gaston Dombiak committed
164 165
        <th width="20%"><fmt:message key="server.session.label.creation" /></th>
        <th width="20%"><fmt:message key="server.session.label.last_active" /></th>
166
        <th width="25%" nowrap><fmt:message key="server.session.details.outgoing_statistics" /></th>
Gaston Dombiak's avatar
Gaston Dombiak committed
167 168
    </tr>
    <tr>
169
        <%  if (outSession.isSecure()) { %>
170
        <td width="1%">
171
            <img src="images/lock.gif" width="16" height="16" border="0" alt="">
172 173
        </td>
         <% } else { %>
174
        <td width="1%"><img src="images/blank.gif" width="1" height="1" alt=""></td>
175
         <% } %>
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
        <%
            Date creationDate = outSession.getCreationDate();
            Date lastActiveDate = outSession.getLastActiveDate();

            Calendar creationCal = Calendar.getInstance();
            creationCal.setTime(creationDate);

            Calendar lastActiveCal = Calendar.getInstance();
            lastActiveCal.setTime(lastActiveDate);

            Calendar nowCal = Calendar.getInstance();

            boolean sameCreationDay = nowCal.get(Calendar.DAY_OF_YEAR) == creationCal.get(Calendar.DAY_OF_YEAR) && nowCal.get(Calendar.YEAR) == creationCal.get(Calendar.YEAR);
            boolean sameActiveDay = nowCal.get(Calendar.DAY_OF_YEAR) == lastActiveCal.get(Calendar.DAY_OF_YEAR) && nowCal.get(Calendar.YEAR) == lastActiveCal.get(Calendar.YEAR);
        %>
Gaston Dombiak's avatar
Gaston Dombiak committed
191
        <td><%= outSession.getStreamID()%></td>
192 193
        <td align="center"><%= sameCreationDay ? JiveGlobals.formatTime(creationDate) : JiveGlobals.formatDateTime(creationDate) %></td>
        <td align="center"><%= sameActiveDay ? JiveGlobals.formatTime(lastActiveDate) : JiveGlobals.formatDateTime(lastActiveDate) %></td>
194
        <td align="center"><%= numFormatter.format(outSession.getNumServerPackets()) %></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
    </tr>
    </table>
    </div>

    <br>
<%  } %>

<br>

<form action="server-session-details.jsp">
<center>
<input type="submit" name="back" value="<fmt:message key="session.details.back_button" />">
</center>
</form>

210 211
    </body>
</html>