server-session-details.jsp 8.7 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 8 9 10 11 12 13 14 15 16 17
  - 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.
Gaston Dombiak's avatar
Gaston Dombiak committed
18 19
--%>

20
<%@ page import="org.jivesoftware.openfire.SessionManager,
21 22
                 org.jivesoftware.openfire.session.IncomingServerSession,
                 org.jivesoftware.openfire.session.OutgoingServerSession,
23 24
                 org.jivesoftware.util.JiveGlobals,
                 org.jivesoftware.util.ParamUtils,
25
                java.text.NumberFormat"
Gaston Dombiak's avatar
Gaston Dombiak committed
26 27
    errorPage="error.jsp"
%>
28 29 30
<%@ page import="java.util.Calendar" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.List" %>
Gaston Dombiak's avatar
Gaston Dombiak committed
31 32 33

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

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

38
<% // Get parameters
Gaston Dombiak's avatar
Gaston Dombiak committed
39 40 41 42 43 44 45 46 47 48
    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();
49
    List<IncomingServerSession> inSessions = sessionManager.getIncomingServerSessions(hostname);
Gaston Dombiak's avatar
Gaston Dombiak committed
50 51 52 53 54 55
    OutgoingServerSession outSession = sessionManager.getOutgoingServerSession(hostname);

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

56 57 58 59 60 61
<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
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

<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>
85
        <% if (!inSessions.isEmpty() && outSession == null) { %>
86
            <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
87
            <fmt:message key="server.session.connection.incoming" />
88
        <% } else if (inSessions.isEmpty() && outSession != null) { %>
89
            <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
90 91
            <fmt:message key="server.session.connection.outgoing" />
        <% } else { %>
92
            <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
93 94 95 96 97 98 99 100 101
            <fmt:message key="server.session.connection.both" />
        <% } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
            <fmt:message key="server.session.details.hostname" />
        </td>
        <td>
102
        <% if (!inSessions.isEmpty()) { %>
103
            <%= inSessions.get(0).getHostAddress() %>
Gaston Dombiak's avatar
Gaston Dombiak committed
104
            /
105
            <%= inSessions.get(0).getHostName() %>
Gaston Dombiak's avatar
Gaston Dombiak committed
106
        <% } else if (outSession != null) { %>
107
            <%= outSession.getHostAddress() %>
Gaston Dombiak's avatar
Gaston Dombiak committed
108
            /
109
            <%= outSession.getHostName() %>
Gaston Dombiak's avatar
Gaston Dombiak committed
110 111 112 113 114 115 116 117
        <% } %>
        </td>
    </tr>
</tbody>
</table>
</div>
<br>

118 119
<%  // Show details of the incoming sessions
    for (IncomingServerSession inSession : inSessions) {
Gaston Dombiak's avatar
Gaston Dombiak committed
120 121 122 123 124
%>
    <b><fmt:message key="server.session.details.incoming_session" /></b>
    <div class="jive-table">
    <table cellpadding="3" cellspacing="1" border="0" width="100%">
    <tr>
125
        <th width="35%" colspan="2"><fmt:message key="server.session.details.streamid" /></th>
Gaston Dombiak's avatar
Gaston Dombiak committed
126 127
        <th width="20%"><fmt:message key="server.session.label.creation" /></th>
        <th width="20%"><fmt:message key="server.session.label.last_active" /></th>
128
        <th width="25%" nowrap><fmt:message key="server.session.details.incoming_statistics" /></th>
Gaston Dombiak's avatar
Gaston Dombiak committed
129 130
    </tr>
    <tr>
131
        <%  if (inSession.isSecure()) { %>
132
            <td width="1%">
133
                <img src="images/lock.gif" width="16" height="16" border="0" alt="">
134 135
            </td>
         <% } else { %>
136
            <td width="1%"><img src="images/blank.gif" width="1" height="1" alt=""></td>
137
         <% } %>
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
        <%
            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
153
        <td><%= inSession.getStreamID()%></td>
154 155
        <td align="center"><%= sameCreationDay ? JiveGlobals.formatTime(creationDate) : JiveGlobals.formatDateTime(creationDate) %></td>
        <td align="center"><%= sameActiveDay ? JiveGlobals.formatTime(lastActiveDate) : JiveGlobals.formatDateTime(lastActiveDate) %></td>
156
        <td align="center"><%= numFormatter.format(inSession.getNumClientPackets()) %></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
157 158 159 160 161 162 163 164 165 166 167 168 169 170
    </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>
171
        <th width="35%" colspan="2"><fmt:message key="server.session.details.streamid" /></th>
Gaston Dombiak's avatar
Gaston Dombiak committed
172 173
        <th width="20%"><fmt:message key="server.session.label.creation" /></th>
        <th width="20%"><fmt:message key="server.session.label.last_active" /></th>
174
        <th width="25%" nowrap><fmt:message key="server.session.details.outgoing_statistics" /></th>
Gaston Dombiak's avatar
Gaston Dombiak committed
175 176
    </tr>
    <tr>
177
        <%  if (outSession.isSecure()) { %>
178
        <td width="1%">
179
            <img src="images/lock.gif" width="16" height="16" border="0" alt="">
180 181
        </td>
         <% } else { %>
182
        <td width="1%"><img src="images/blank.gif" width="1" height="1" alt=""></td>
183
         <% } %>
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
        <%
            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
199
        <td><%= outSession.getStreamID()%></td>
200 201
        <td align="center"><%= sameCreationDay ? JiveGlobals.formatTime(creationDate) : JiveGlobals.formatDateTime(creationDate) %></td>
        <td align="center"><%= sameActiveDay ? JiveGlobals.formatTime(lastActiveDate) : JiveGlobals.formatDateTime(lastActiveDate) %></td>
202
        <td align="center"><%= numFormatter.format(outSession.getNumServerPackets()) %></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
    </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>

218 219
    </body>
</html>