Commit 7ad8dbd8 authored by Axel Brand's avatar Axel Brand Committed by daeva

Gojara

- refactor how we track configurations, 2 sets instead of one so we know which are configured to and not only which are NOT configured
- Show Admin-Configured? in Overview of existing Registrations, display mouseover explanation
- also do this in session details



git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13700 b35dd754-fafc-0310-a699-88a17e54d16e
parent 460d4160
......@@ -27,7 +27,8 @@ public class GojaraAdminManager {
private static final Logger Log = LoggerFactory.getLogger(GojaraAdminManager.class);
private JID adminUser;
private XMPPServer _server;
private Set<String> testGateways;
private Set<String> unconfiguredGateways;
private Set<String> configuredGateways;
private boolean areGatewaysConfigured = true;
private GojaraAdminManager() {
......@@ -41,7 +42,8 @@ public class GojaraAdminManager {
Log.info("gojaraAdmin User already created.");
}
adminUser = _server.createJID("gojaraadmin", null);
testGateways = new HashSet<String>();
unconfiguredGateways = new HashSet<String>();
configuredGateways = new HashSet<String>();
}
public static GojaraAdminManager getInstance() {
......@@ -66,7 +68,7 @@ public class GojaraAdminManager {
*/
public void testAdminConfiguration(String gateway) {
areGatewaysConfigured = false;
testGateways.add(gateway);
unconfiguredGateways.add(gateway);
Message message = new Message();
message.setFrom(adminUser);
message.setTo(gateway);
......@@ -79,34 +81,46 @@ public class GojaraAdminManager {
/**
* Gets called from Interceptor to confirm that a Gateway responded to our config_check message.
*
* @param gateway
*/
public void confirmGatewayConfig(String gateway) {
testGateways.remove(gateway);
if (testGateways.isEmpty())
unconfiguredGateways.remove(gateway);
configuredGateways.add(gateway);
if (unconfiguredGateways.isEmpty())
areGatewaysConfigured = true;
}
/**
* If a gateway disconnects we have to check if it was not configured as we may want to alter boolean areGatewaysConfigured.
* If a gateway disconnects we have to check if it was not configured as we may want to alter boolean
* areGatewaysConfigured.
*/
public void gatewayUnregistered(String gateway) {
if (testGateways.contains(gateway)) {
testGateways.remove(gateway);
if (testGateways.isEmpty())
unconfiguredGateways.remove(gateway);
configuredGateways.remove(gateway);
if (unconfiguredGateways.isEmpty())
areGatewaysConfigured = true;
}
}
public boolean areGatewaysConfigured() {
return areGatewaysConfigured;
}
public boolean isGatewayConfigured(String gateway) {
return configuredGateways.contains(gateway);
}
/**
* Sends the command online_users to specified Spectrum2 transport. We set the ID specific to the command so we can
* identify the response.
* identify the response. Transport has to be configured for admin_jid = gojaraadmin@domain
*
* @param transport
*/
public void getOnlineUsersOf(String transport) {
// no use in sending the message if not configured for gojaraadmin
if (unconfiguredGateways.contains(transport))
return;
Message message = new Message();
message.setFrom(adminUser);
message.setTo(transport);
......@@ -119,11 +133,14 @@ public class GojaraAdminManager {
/**
* Sends the unregister <bare_jid> command to specified Spectrum2 transport. We set the ID specific to the command
* so we can identify the response.
* so we can identify the response. Transport has to be configured for admin_jid = gojaraadmin@domain
*
* @param transport
*/
public void unregisterUserFrom(String transport, String user) {
if (unconfiguredGateways.contains(transport))
return;
Message message = new Message();
message.setFrom(adminUser);
message.setTo(transport);
......
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.sessions.TransportSessionManager"%>
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.sessions.GojaraAdminManager"%>
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.database.SessionEntry"%>
<%@ page
......@@ -13,6 +15,7 @@
<%
TransportSessionManager transportManager = TransportSessionManager.getInstance();
GojaraAdminManager gojaraAdminManager = GojaraAdminManager.getInstance();
//Helper object for generation of sorting links, column restriction is done in DatabaseManager
Map<String, String> sortParams = new HashMap<String, String>();
......@@ -103,7 +106,8 @@
<tr>
<th nowrap><%=JspHelper.sortingHelperRegistrations("username", sortParams)%></th>
<th nowrap><%=JspHelper.sortingHelperRegistrations("transport", sortParams)%></th>
<th nowrap>Resource active?</th>
<th nowrap>Active?</th>
<th nowrap>Admin Configured?</th>
<th nowrap><%=JspHelper.sortingHelperRegistrations("lastActivity", sortParams)%></th>
<th nowrap>Unregister?</th>
</tr>
......@@ -121,10 +125,17 @@
<%
if (transportManager.isTransportActive(registration.getTransport())) {
%> <img alt="Yes" src="/images/success-16x16.gif"> <%
} else {
%> <img alt="No" src="/images/error-16x16.gif"> <%
}
%>
} else {
%> <img alt="No" src="/images/error-16x16.gif" title="Sending unregister to inactive transport will result in NOT UNREGISTERING the registration."> <%
}
%>
</td>
<td>
<% if (gojaraAdminManager.isGatewayConfigured(registration.getTransport())) { %>
<img alt="Yes" src="/images/success-16x16.gif">
<% } else { %>
<img alt="No" src="/images/error-16x16.gif" title="Sending unregister to unconfigured transport will result in NOT UNREGISTERING the registration.">
<% }%>
</td>
<td
title="<%=JspHelper.dateDifferenceHelper(registration.getLast_activityAsDate())%>"><%=registration.getLast_activityAsDate()%></td>
......
......@@ -2,6 +2,8 @@
import="org.jivesoftware.openfire.plugin.gojara.sessions.GatewaySession"%>
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.sessions.TransportSessionManager"%>
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.sessions.GojaraAdminManager"%>
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.database.SessionEntry"%>
<%@ page
......@@ -13,6 +15,7 @@
<%
TransportSessionManager transportManager = TransportSessionManager.getInstance();
GojaraAdminManager gojaraAdminManager = GojaraAdminManager.getInstance();
String username = request.getParameter("username");
%>
<html>
......@@ -122,10 +125,17 @@
<%
if (transportManager.isTransportActive(registration.getTransport())) {
%> <img alt="Yes" src="/images/success-16x16.gif"> <%
} else {
%> <img alt="No" src="/images/error-16x16.gif"> <%
}
%>
} else {
%> <img alt="No" src="/images/error-16x16.gif" title="Sending unregister to inactive transport will result in NOT UNREGISTERING the registration."> <%
}
%>
</td>
<td>
<% if (gojaraAdminManager.isGatewayConfigured(registration.getTransport())) { %>
<img alt="Yes" src="/images/success-16x16.gif">
<% } else { %>
<img alt="No" src="/images/error-16x16.gif" title="Sending unregister to unconfigured transport will result in NOT UNREGISTERING the registration.">
<% }%>
</td>
<td
title="<%=JspHelper.dateDifferenceHelper(registration.getLast_activityAsDate())%>"><%=registration.getLast_activityAsDate()%></td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment