server-session-row.jspf 6.26 KB
Newer Older
1 2 3 4 5
 <%--
  -	$Revision$
  -	$Date$
--%>

6 7
<%@ page import="org.jivesoftware.openfire.session.IncomingServerSession,
                 org.jivesoftware.util.JiveGlobals,
Sven Tantau's avatar
Sven Tantau committed
8
                 org.jivesoftware.util.StringUtils,
9
                 java.net.URLEncoder,
10
                 java.util.Calendar,
11
                 java.util.Date"%>
Gaston Dombiak's avatar
Gaston Dombiak committed
12

13
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
14

15 16 17 18 19 20 21
 <%--
   - This page is meant to be included in other pages. It assumes 4 variables:
   -     * 'host', the name of the remote server
   -     * 'inSession', an  IncomingServerSession object
   -     * 'outSession', an OutgoingServerSession object
   -     * 'count', an int representing the row number we're on.
 --%>
Gaston Dombiak's avatar
Gaston Dombiak committed
22

23
<% // Show the secured icon only if ALL sessions are secure
24 25
    boolean isSecured = true;
    // Check if all incoming sessions are secured
26
    for (org.jivesoftware.openfire.session.IncomingServerSession inSession : inSessions) {
27
        if (!inSession.isSecure()) {
28 29 30 31 32 33
            isSecured = false;
            break;
        }
    }
    // Check if outgoing session is secured (only if incoming sessions are secured)
    if (isSecured && outSession != null) {
34
        isSecured = outSession.isSecure();
35 36
    }
%>
Gaston Dombiak's avatar
Gaston Dombiak committed
37 38 39
<tr class="jive-<%= (((count % 2) == 0) ? "even" : "odd") %>">
    <td width="1%" nowrap><%= count %></td>
    <td width="47%" nowrap>
40 41
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>
Sven Tantau's avatar
Sven Tantau committed
42 43
            <td width="1%" ><img src="getFavicon?host=<%=URLEncoder.encode(host, "UTF-8")%>" width="16" height="16" alt=""></td>
            <td><a href="server-session-details.jsp?hostname=<%= URLEncoder.encode(host, "UTF-8") %>" title="<fmt:message key='session.row.cliked' />"><%= StringUtils.escapeHTMLTags(host) %></a></td>
44 45
            </tr>
        </table>
Gaston Dombiak's avatar
Gaston Dombiak committed
46
    </td>
47 48
    <%  if (isSecured) { %>
    <td width="1%">
49
        <img src="images/lock.gif" width="16" height="16" border="0" alt="">
50 51
    </td>
     <% } else { %>
52
    <td width="1%"><img src="images/blank.gif" width="1" height="1" alt=""></td>
53
     <% } %>
54
    <% if (!inSessions.isEmpty() && outSession == null) { %>
Gaston Dombiak's avatar
Gaston Dombiak committed
55
        <td width="1%">
56
            <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
57 58
        </td>
        <td width="10%"><fmt:message key="server.session.connection.incoming" /></td>
59
    <% } else if (inSessions.isEmpty() && outSession != null) { %>
Gaston Dombiak's avatar
Gaston Dombiak committed
60
        <td width="1%">
61
            <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
62 63 64 65
        </td>
        <td width="10%"><fmt:message key="server.session.connection.outgoing" /></td>
    <% } else { %>
        <td width="1%">
66
            <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
67 68 69 70 71 72
        </td>
        <td width="10%"><fmt:message key="server.session.connection.both" /></td>
    <% } %>

    <% Date creationDate = null;
        Date lastActiveDate = null;
73 74 75 76 77 78 79 80 81 82 83
        if (!inSessions.isEmpty() && outSession == null) {
            for (IncomingServerSession inSession : inSessions) {
                if (creationDate == null || creationDate.after(inSession.getCreationDate())) {
                    // Use the creation date of the oldest incoming session
                    creationDate = inSession.getCreationDate();
                }
                if (lastActiveDate == null || lastActiveDate.before(inSession.getLastActiveDate())) {
                    // Use the last active date of the newest incoming session
                    lastActiveDate = inSession.getLastActiveDate();
                }
            }
Gaston Dombiak's avatar
Gaston Dombiak committed
84
        }
85
        else if (inSessions.isEmpty() && outSession != null) {
Gaston Dombiak's avatar
Gaston Dombiak committed
86 87 88 89
            creationDate = outSession.getCreationDate();
            lastActiveDate = outSession.getLastActiveDate();
        }
        else {
90 91 92 93 94 95 96 97 98 99 100 101
            for (IncomingServerSession inSession : inSessions) {
                if (creationDate == null || creationDate.after(inSession.getCreationDate())) {
                    // Use the creation date of the oldest incoming session
                    creationDate = inSession.getCreationDate();
                }
                if (lastActiveDate == null || lastActiveDate.before(inSession.getLastActiveDate())) {
                    // Use the last active date of the newest incoming session
                    lastActiveDate = inSession.getLastActiveDate();
                }
            }
            creationDate = creationDate.before(outSession.getCreationDate()) ? creationDate : outSession.getCreationDate();
            lastActiveDate = lastActiveDate.after(outSession.getLastActiveDate()) ? lastActiveDate : outSession.getLastActiveDate();
Gaston Dombiak's avatar
Gaston Dombiak committed
102
        }
103 104 105 106 107 108 109 110 111 112
        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
113 114 115
    %>

    <td align="center" width="20%" nowrap>
116
        <%= sameCreationDay ? JiveGlobals.formatTime(creationDate) : JiveGlobals.formatDateTime(creationDate) %>
Gaston Dombiak's avatar
Gaston Dombiak committed
117 118
    </td>
    <td align="center" width="20%" nowrap>
119
        <%= sameActiveDay ? JiveGlobals.formatTime(lastActiveDate) : JiveGlobals.formatDateTime(lastActiveDate) %>
Gaston Dombiak's avatar
Gaston Dombiak committed
120 121 122 123 124 125 126 127
    </td>

    <td width="1%" nowrap align="center" style="border-right:1px #ccc solid;">
        <a href="server-session-summary.jsp?hostname=<%= URLEncoder.encode(host, "UTF-8") %>&close=true"
         title="<fmt:message key="session.row.cliked_kill_session" />"
         onclick="return confirm('<fmt:message key="session.row.confirm_close" />');"
         ><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
    </td>
Sven Tantau's avatar
Sven Tantau committed
128
</tr>