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 { ...@@ -27,7 +27,8 @@ public class GojaraAdminManager {
private static final Logger Log = LoggerFactory.getLogger(GojaraAdminManager.class); private static final Logger Log = LoggerFactory.getLogger(GojaraAdminManager.class);
private JID adminUser; private JID adminUser;
private XMPPServer _server; private XMPPServer _server;
private Set<String> testGateways; private Set<String> unconfiguredGateways;
private Set<String> configuredGateways;
private boolean areGatewaysConfigured = true; private boolean areGatewaysConfigured = true;
private GojaraAdminManager() { private GojaraAdminManager() {
...@@ -41,7 +42,8 @@ public class GojaraAdminManager { ...@@ -41,7 +42,8 @@ public class GojaraAdminManager {
Log.info("gojaraAdmin User already created."); Log.info("gojaraAdmin User already created.");
} }
adminUser = _server.createJID("gojaraadmin", null); adminUser = _server.createJID("gojaraadmin", null);
testGateways = new HashSet<String>(); unconfiguredGateways = new HashSet<String>();
configuredGateways = new HashSet<String>();
} }
public static GojaraAdminManager getInstance() { public static GojaraAdminManager getInstance() {
...@@ -66,7 +68,7 @@ public class GojaraAdminManager { ...@@ -66,7 +68,7 @@ public class GojaraAdminManager {
*/ */
public void testAdminConfiguration(String gateway) { public void testAdminConfiguration(String gateway) {
areGatewaysConfigured = false; areGatewaysConfigured = false;
testGateways.add(gateway); unconfiguredGateways.add(gateway);
Message message = new Message(); Message message = new Message();
message.setFrom(adminUser); message.setFrom(adminUser);
message.setTo(gateway); message.setTo(gateway);
...@@ -79,34 +81,46 @@ public class GojaraAdminManager { ...@@ -79,34 +81,46 @@ public class GojaraAdminManager {
/** /**
* Gets called from Interceptor to confirm that a Gateway responded to our config_check message. * Gets called from Interceptor to confirm that a Gateway responded to our config_check message.
*
* @param gateway * @param gateway
*/ */
public void confirmGatewayConfig(String gateway) { public void confirmGatewayConfig(String gateway) {
testGateways.remove(gateway); unconfiguredGateways.remove(gateway);
if (testGateways.isEmpty()) configuredGateways.add(gateway);
if (unconfiguredGateways.isEmpty())
areGatewaysConfigured = true; 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) { public void gatewayUnregistered(String gateway) {
if (testGateways.contains(gateway)) { unconfiguredGateways.remove(gateway);
testGateways.remove(gateway); configuredGateways.remove(gateway);
if (testGateways.isEmpty()) if (unconfiguredGateways.isEmpty())
areGatewaysConfigured = true; areGatewaysConfigured = true;
}
} }
public boolean areGatewaysConfigured() { public boolean areGatewaysConfigured() {
return 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 * 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 * @param transport
*/ */
public void getOnlineUsersOf(String 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 message = new Message();
message.setFrom(adminUser); message.setFrom(adminUser);
message.setTo(transport); message.setTo(transport);
...@@ -119,11 +133,14 @@ public class GojaraAdminManager { ...@@ -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 * 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 * @param transport
*/ */
public void unregisterUserFrom(String transport, String user) { public void unregisterUserFrom(String transport, String user) {
if (unconfiguredGateways.contains(transport))
return;
Message message = new Message(); Message message = new Message();
message.setFrom(adminUser); message.setFrom(adminUser);
message.setTo(transport); message.setTo(transport);
......
<%@ page <%@ page
import="org.jivesoftware.openfire.plugin.gojara.sessions.TransportSessionManager"%> import="org.jivesoftware.openfire.plugin.gojara.sessions.TransportSessionManager"%>
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.sessions.GojaraAdminManager"%>
<%@ page <%@ page
import="org.jivesoftware.openfire.plugin.gojara.database.SessionEntry"%> import="org.jivesoftware.openfire.plugin.gojara.database.SessionEntry"%>
<%@ page <%@ page
...@@ -13,6 +15,7 @@ ...@@ -13,6 +15,7 @@
<% <%
TransportSessionManager transportManager = TransportSessionManager.getInstance(); TransportSessionManager transportManager = TransportSessionManager.getInstance();
GojaraAdminManager gojaraAdminManager = GojaraAdminManager.getInstance();
//Helper object for generation of sorting links, column restriction is done in DatabaseManager //Helper object for generation of sorting links, column restriction is done in DatabaseManager
Map<String, String> sortParams = new HashMap<String, String>(); Map<String, String> sortParams = new HashMap<String, String>();
...@@ -103,7 +106,8 @@ ...@@ -103,7 +106,8 @@
<tr> <tr>
<th nowrap><%=JspHelper.sortingHelperRegistrations("username", sortParams)%></th> <th nowrap><%=JspHelper.sortingHelperRegistrations("username", sortParams)%></th>
<th nowrap><%=JspHelper.sortingHelperRegistrations("transport", 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><%=JspHelper.sortingHelperRegistrations("lastActivity", sortParams)%></th>
<th nowrap>Unregister?</th> <th nowrap>Unregister?</th>
</tr> </tr>
...@@ -121,10 +125,17 @@ ...@@ -121,10 +125,17 @@
<% <%
if (transportManager.isTransportActive(registration.getTransport())) { if (transportManager.isTransportActive(registration.getTransport())) {
%> <img alt="Yes" src="/images/success-16x16.gif"> <% %> <img alt="Yes" src="/images/success-16x16.gif"> <%
} else { } else {
%> <img alt="No" src="/images/error-16x16.gif"> <% %> <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>
<td <td
title="<%=JspHelper.dateDifferenceHelper(registration.getLast_activityAsDate())%>"><%=registration.getLast_activityAsDate()%></td> title="<%=JspHelper.dateDifferenceHelper(registration.getLast_activityAsDate())%>"><%=registration.getLast_activityAsDate()%></td>
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
import="org.jivesoftware.openfire.plugin.gojara.sessions.GatewaySession"%> import="org.jivesoftware.openfire.plugin.gojara.sessions.GatewaySession"%>
<%@ page <%@ page
import="org.jivesoftware.openfire.plugin.gojara.sessions.TransportSessionManager"%> import="org.jivesoftware.openfire.plugin.gojara.sessions.TransportSessionManager"%>
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.sessions.GojaraAdminManager"%>
<%@ page <%@ page
import="org.jivesoftware.openfire.plugin.gojara.database.SessionEntry"%> import="org.jivesoftware.openfire.plugin.gojara.database.SessionEntry"%>
<%@ page <%@ page
...@@ -13,6 +15,7 @@ ...@@ -13,6 +15,7 @@
<% <%
TransportSessionManager transportManager = TransportSessionManager.getInstance(); TransportSessionManager transportManager = TransportSessionManager.getInstance();
GojaraAdminManager gojaraAdminManager = GojaraAdminManager.getInstance();
String username = request.getParameter("username"); String username = request.getParameter("username");
%> %>
<html> <html>
...@@ -122,10 +125,17 @@ ...@@ -122,10 +125,17 @@
<% <%
if (transportManager.isTransportActive(registration.getTransport())) { if (transportManager.isTransportActive(registration.getTransport())) {
%> <img alt="Yes" src="/images/success-16x16.gif"> <% %> <img alt="Yes" src="/images/success-16x16.gif"> <%
} else { } else {
%> <img alt="No" src="/images/error-16x16.gif"> <% %> <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>
<td <td
title="<%=JspHelper.dateDifferenceHelper(registration.getLast_activityAsDate())%>"><%=registration.getLast_activityAsDate()%></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