use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.
the class MultiUserChatManager method removeMultiUserChatService.
/**
* Deletes a configured MultiUserChatService by ID, and shuts it down.
*
* @param serviceID The ID opf the service to be deleted.
* @throws NotFoundException if the service was not found.
*/
public void removeMultiUserChatService(final long serviceID) throws NotFoundException {
final MultiUserChatServiceImpl muc = (MultiUserChatServiceImpl) getMultiUserChatService(serviceID);
if (muc == null) {
Log.info("Unable to find service to remove for service ID {}", serviceID);
throw new NotFoundException();
}
final String subdomain = muc.getServiceName();
Log.info("Removing MUC service '{}'", subdomain);
unregisterMultiUserChatService(subdomain);
deleteService(serviceID);
}
use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.
the class MultiUserChatManager method refreshService.
/**
* Updates the in-memory representation of a previously loaded services from the database.
*
* This call will modify database-stored characteristics for a service previously loaded to memory on the local
* cluster node. An exception will be thrown if used for a service that's not in memory.
*
* Note that this method will not cause MUCServiceProperties to be reloaded. It only operates on fields like the
* service description.
*
* This method is primarily useful to cause a service to reload its state from the database after it was changed on
* another cluster node.
*
* @param subdomain the domain of the service to refresh
*/
public void refreshService(String subdomain) {
Log.debug("Refreshing MUC service {} from the database.", subdomain);
if (!mucServices.containsKey(subdomain)) {
throw new IllegalArgumentException("Cannot refresh a MUC service that is not loaded: " + subdomain);
}
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(LOAD_SERVICE);
pstmt.setString(1, subdomain);
rs = pstmt.executeQuery();
if (rs.next()) {
String description = rs.getString(1);
Boolean isHidden = Boolean.valueOf(rs.getString(2));
((MultiUserChatServiceImpl) mucServices.get(subdomain)).setDescription(description);
((MultiUserChatServiceImpl) mucServices.get(subdomain)).setHidden(isHidden);
} else {
throw new Exception("Unable to locate database row for subdomain " + subdomain);
}
} catch (Exception e) {
Log.error("A database exception occurred while trying to refresh MUC service '{}' from the database.", subdomain, e);
} finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
Log.trace("Refreshed MUC service '{}'", subdomain);
}
use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.
the class MultiUserChatManager method loadServices.
/**
* Loads the list of configured services stored in the database.
*
* This call will add the services to memory on the local cluster node, but will not propagate them to other nodes
* in the cluster.
*/
private void loadServices() {
Log.debug("Loading all MUC services from the database.");
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(LOAD_SERVICES);
rs = pstmt.executeQuery();
while (rs.next()) {
String subdomain = rs.getString(1);
String description = rs.getString(2);
Boolean isHidden = Boolean.valueOf(rs.getString(3));
final MultiUserChatServiceImpl muc = new MultiUserChatServiceImpl(subdomain, description, isHidden);
Log.trace("... loaded '{}' MUC service from the database.", subdomain);
mucServices.put(subdomain, muc);
}
} catch (Exception e) {
Log.error("An unexpected exception occurred while trying to load all MUC services from the database.", e);
} finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
}
use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.
the class ServiceAddedEvent method run.
@Override
public void run() {
// should really never occur.
if (!XMPPServer.getInstance().getMultiUserChatManager().isServiceRegistered(subdomain)) {
MultiUserChatService service = new MultiUserChatServiceImpl(subdomain, description, isHidden);
XMPPServer.getInstance().getMultiUserChatManager().registerMultiUserChatService(service, false);
}
}
Aggregations