Commit 3327c4e3 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Switched autoLoad to isHidden to simplify concept.

ClearspaceMultiUserChatService is being replaced with a standard MultiUserChatServiceImpl with some adjusted options.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10106 b35dd754-fafc-0310-a699-88a17e54d16e
parent c360bb4d
...@@ -182,7 +182,7 @@ CREATE TABLE mucService ( ...@@ -182,7 +182,7 @@ CREATE TABLE mucService (
serviceID INTEGER NOT NULL, serviceID INTEGER NOT NULL,
subdomain VARCHAR(255) NOT NULL, subdomain VARCHAR(255) NOT NULL,
description VARCHAR(255), description VARCHAR(255),
autoLoad INTEGER NOT NULL, isHidden INTEGER NOT NULL,
CONSTRAINT mucService_pk PRIMARY KEY (subdomain) CONSTRAINT mucService_pk PRIMARY KEY (subdomain)
); );
CREATE INDEX mucService_serviceid_idx ON mucService(serviceID); CREATE INDEX mucService_serviceid_idx ON mucService(serviceID);
...@@ -392,4 +392,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi ...@@ -392,4 +392,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0'); VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
-- Entry for default conference service -- Entry for default conference service
INSERT INTO mucService (serviceID, subdomain) VALUES (1, 'conference'); INSERT INTO mucService (serviceID, subdomain, isHidden) VALUES (1, 'conference', 0);
...@@ -178,7 +178,7 @@ CREATE TABLE mucService ( ...@@ -178,7 +178,7 @@ CREATE TABLE mucService (
serviceID BIGINT NOT NULL, serviceID BIGINT NOT NULL,
subdomain VARCHAR(255) NOT NULL, subdomain VARCHAR(255) NOT NULL,
description VARCHAR(255), description VARCHAR(255),
autoLoad INTEGER NOT NULL, isHidden INTEGER NOT NULL,
CONSTRAINT mucService_pk PRIMARY KEY (subdomain) CONSTRAINT mucService_pk PRIMARY KEY (subdomain)
); );
CREATE INDEX mucService_serviceid_idx ON mucService(serviceID); CREATE INDEX mucService_serviceid_idx ON mucService(serviceID);
...@@ -378,4 +378,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi ...@@ -378,4 +378,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0'); VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
// Entry for default conference service // Entry for default conference service
INSERT INTO mucService (serviceID, subdomain) VALUES (1, 'conference'); INSERT INTO mucService (serviceID, subdomain, isHidden) VALUES (1, 'conference', 0);
...@@ -167,7 +167,7 @@ CREATE TABLE mucService ( ...@@ -167,7 +167,7 @@ CREATE TABLE mucService (
serviceID BIGINT NOT NULL, serviceID BIGINT NOT NULL,
subdomain VARCHAR(255) NOT NULL, subdomain VARCHAR(255) NOT NULL,
description VARCHAR(255), description VARCHAR(255),
autoLoad TINYINT NOT NULL, isHidden TINYINT NOT NULL,
PRIMARY KEY (subdomain), PRIMARY KEY (subdomain),
INDEX mucService_serviceid_idx (serviceID) INDEX mucService_serviceid_idx (serviceID)
); );
...@@ -367,4 +367,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi ...@@ -367,4 +367,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0'); VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
# Entry for default conference service # Entry for default conference service
INSERT INTO mucService (serviceID, subdomain) VALUES (1, 'conference'); INSERT INTO mucService (serviceID, subdomain, isHidden) VALUES (1, 'conference', 0);
...@@ -175,7 +175,7 @@ CREATE TABLE mucService ( ...@@ -175,7 +175,7 @@ CREATE TABLE mucService (
serviceID INT NOT NULL, serviceID INT NOT NULL,
subdomain VARCHAR2(255) NOT NULL, subdomain VARCHAR2(255) NOT NULL,
description VARCHAR2(255), description VARCHAR2(255),
autoLoad INTEGER NOT NULL, isHidden INTEGER NOT NULL,
CONSTRAINT mucService_pk PRIMARY KEY (subdomain) CONSTRAINT mucService_pk PRIMARY KEY (subdomain)
); );
CREATE INDEX mucService_serviceid_idx ON mucService(serviceID); CREATE INDEX mucService_serviceid_idx ON mucService(serviceID);
...@@ -375,6 +375,6 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi ...@@ -375,6 +375,6 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0'); VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
-- Entry for default conference service -- Entry for default conference service
INSERT INTO mucService (serviceID, subdomain) VALUES (1, 'conference'); INSERT INTO mucService (serviceID, subdomain, isHidden) VALUES (1, 'conference', 0);
commit; commit;
...@@ -183,7 +183,7 @@ CREATE TABLE mucService ( ...@@ -183,7 +183,7 @@ CREATE TABLE mucService (
serviceID INTEGER NOT NULL, serviceID INTEGER NOT NULL,
subdomain VARCHAR(255) NOT NULL, subdomain VARCHAR(255) NOT NULL,
description VARCHAR(255), description VARCHAR(255),
autoLoad INTEGER NOT NULL, isHidden INTEGER NOT NULL,
CONSTRAINT mucService_pk PRIMARY KEY (subdomain) CONSTRAINT mucService_pk PRIMARY KEY (subdomain)
); );
CREATE INDEX mucService_serviceid_idx ON mucService(serviceID); CREATE INDEX mucService_serviceid_idx ON mucService(serviceID);
...@@ -383,4 +383,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi ...@@ -383,4 +383,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0'); VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
-- Entry for default conference service -- Entry for default conference service
INSERT INTO mucService (serviceID, subdomain) VALUES (1, 'conference'); INSERT INTO mucService (serviceID, subdomain, isHidden) VALUES (1, 'conference', 0);
...@@ -181,7 +181,7 @@ CREATE TABLE mucService ( ...@@ -181,7 +181,7 @@ CREATE TABLE mucService (
serviceID INT NOT NULL, serviceID INT NOT NULL,
subdomain NVARCHAR(255) NOT NULL, subdomain NVARCHAR(255) NOT NULL,
description NVARCHAR(255), description NVARCHAR(255),
autoLoad INT NOT NULL, isHidden INT NOT NULL,
CONSTRAINT mucService_pk PRIMARY KEY (subdomain) CONSTRAINT mucService_pk PRIMARY KEY (subdomain)
); );
CREATE INDEX mucService_serviceid_idx ON mucService(serviceID); CREATE INDEX mucService_serviceid_idx ON mucService(serviceID);
...@@ -381,4 +381,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi ...@@ -381,4 +381,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0'); VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
/* Entry for default conference service */ /* Entry for default conference service */
INSERT INTO mucService (serviceID, subdomain) VALUES (1, 'conference'); INSERT INTO mucService (serviceID, subdomain, isHidden) VALUES (1, 'conference', 0);
...@@ -180,7 +180,7 @@ CREATE TABLE mucService ( ...@@ -180,7 +180,7 @@ CREATE TABLE mucService (
serviceID INT NOT NULL, serviceID INT NOT NULL,
subdomain NVARCHAR(255) NOT NULL, subdomain NVARCHAR(255) NOT NULL,
description NVARCHAR(255), description NVARCHAR(255),
autoLoad INT NOT NULL, isHidden INT NOT NULL,
CONSTRAINT mucService_pk PRIMARY KEY (subdomain) CONSTRAINT mucService_pk PRIMARY KEY (subdomain)
); );
CREATE INDEX mucService_serviceid_idx ON mucService(serviceID); CREATE INDEX mucService_serviceid_idx ON mucService(serviceID);
...@@ -380,4 +380,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi ...@@ -380,4 +380,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0'); VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
/* Entry for default conference service */ /* Entry for default conference service */
INSERT INTO mucService (serviceID, subdomain) VALUES (1, 'conference'); INSERT INTO mucService (serviceID, subdomain, isHidden) VALUES (1, 'conference', 0);
-- add autoLoad column to mucService -- add isHidden column to mucService
ALTER TABLE mucService ADD COLUMN autoLoad INTEGER NOT NULL; ALTER TABLE mucService ADD COLUMN isHidden INTEGER NOT NULL;
-- set all current services to autoLoad = true -- set all current services to isHidden = false
UPDATE mucService set autoLoad = 1; UPDATE mucService set isHidden = 0;
UPDATE jiveVersion set version=18 where name = 'openfire'; UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
// add autoLoad column to mucService // add isHidden column to mucService
ALTER TABLE mucService ADD COLUMN autoLoad INTEGER NOT NULL; ALTER TABLE mucService ADD COLUMN isHidden INTEGER NOT NULL;
// set all current services to autoLoad = true // set all current services to isHidden = false
UPDATE mucService set autoLoad = 1; UPDATE mucService set isHidden = 0;
UPDATE jiveVersion set version=18 where name = 'openfire'; UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
# add autoLoad column to mucService # add isHidden column to mucService
ALTER TABLE mucService ADD COLUMN autoLoad TINYINT NOT NULL; ALTER TABLE mucService ADD COLUMN isHidden TINYINT NOT NULL;
# set all current services to autoLoad = true # set all current services to isHidden = false
UPDATE mucService set autoLoad = 1; UPDATE mucService set isHidden = 0;
UPDATE jiveVersion set version=18 where name = 'openfire'; UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
-- add autoLoad column to mucService -- add isHidden column to mucService
ALTER TABLE mucService ADD autoLoad INTEGER NOT NULL; ALTER TABLE mucService ADD isHidden INTEGER NOT NULL;
-- set all current services to autoLoad = true -- set all current services to isHidden = false
UPDATE mucService set autoLoad = 1; UPDATE mucService set isHidden = 0;
UPDATE jiveVersion set version=18 where name = 'openfire'; UPDATE jiveVersion set version=18 where name = 'openfire';
......
-- add autoLoad column to mucService -- add isHidden column to mucService
ALTER TABLE mucService ADD COLUMN autoLoad INTEGER NOT NULL; ALTER TABLE mucService ADD COLUMN isHidden INTEGER NOT NULL;
-- set all current services to autoLoad = true -- set all current services to isHidden = false
UPDATE mucService set autoLoad = 1; UPDATE mucService set isHidden = 0;
UPDATE jiveVersion set version=18 where name = 'openfire'; UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
/* add autoLoad column to mucService */ /* add isHidden column to mucService */
ALTER TABLE mucService ADD autoLoad INT NOT NULL; ALTER TABLE mucService ADD isHidden INT NOT NULL;
/* set all current services to autoLoad = true */ /* set all current services to isHidden = false */
UPDATE mucService set autoLoad = 1; UPDATE mucService set isHidden = 0;
UPDATE jiveVersion set version=18 where name = 'openfire'; UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
/* add autoLoad column to mucService */ /* add isHidden column to mucService */
ALTER TABLE mucService ADD COLUMN autoLoad INT NOT NULL; ALTER TABLE mucService ADD COLUMN isHidden INT NOT NULL;
/* set all current services to autoLoad = true */ /* set all current services to isHidden = false */
UPDATE mucService set autoLoad = 1; UPDATE mucService set isHidden = 0;
UPDATE jiveVersion set version=18 where name = 'openfire'; UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
...@@ -18,6 +18,7 @@ import org.dom4j.*; ...@@ -18,6 +18,7 @@ import org.dom4j.*;
import org.dom4j.io.XMPPPacketReader; import org.dom4j.io.XMPPPacketReader;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.XMPPServerInfo; import org.jivesoftware.openfire.XMPPServerInfo;
import org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl;
import org.jivesoftware.openfire.auth.AuthFactory; import org.jivesoftware.openfire.auth.AuthFactory;
import org.jivesoftware.openfire.auth.UnauthorizedException; import org.jivesoftware.openfire.auth.UnauthorizedException;
import static org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET; import static org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET;
...@@ -412,8 +413,18 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -412,8 +413,18 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
// Listen for changes to external component settings // Listen for changes to external component settings
ExternalComponentManager.addListener(this); ExternalComponentManager.addListener(this);
// Set up custom clearspace MUC service // Set up custom clearspace MUC service
ClearspaceMultiUserChatService mucService = new ClearspaceMultiUserChatService(MUC_SUBDOMAIN, MUC_DESCRIPTION); // Create service if it doesn't exist, load if it does.
XMPPServer.getInstance().getMultiUserChatManager().registerMultiUserChatService(mucService); MultiUserChatServiceImpl muc = (MultiUserChatServiceImpl)XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(MUC_SUBDOMAIN);
if (muc == null) {
try {
muc = XMPPServer.getInstance().getMultiUserChatManager().createMultiUserChatService(MUC_SUBDOMAIN, MUC_DESCRIPTION, true);
}
catch (AlreadyExistsException e) {
Log.error("ClearspaceManager: Found no "+MUC_SUBDOMAIN+" service, but got already exists when creation attempted? Service probably not started!");
}
}
// TODO: Set up special delegate for Clearspace MUC service
// TODO: Set up additional identity/features for disco for Clearspace MUC service
// Starts the clearspace configuration task // Starts the clearspace configuration task
startClearspaceConfig(); startClearspaceConfig();
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.openfire.clearspace;
import org.jivesoftware.openfire.muc.*;
import org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl;
import org.dom4j.Element;
import org.xmpp.packet.JID;
import java.util.Iterator;
import java.util.ArrayList;
/**
* This ia an extension of a standard MultiUserChatService implementation that accounts for
* Clearspace interactions, restrictions, and special rules.
*
* @author Daniel Henninger
*/
public class ClearspaceMultiUserChatService extends MultiUserChatServiceImpl implements MultiUserChatService {
/**
* Create a new clearspace group chat service.
*
* @param subdomain Subdomain portion of the conference services (for example, conference for conference.example.org)
* @param description Short description of service for disco and such.
*/
public ClearspaceMultiUserChatService(String subdomain, String description) {
super(subdomain, description);
// TODO: enable when CS MUC works (should create a protected setter method)
//mucEventDelegate = new ClearspaceMUCEventDelegate();
}
@Override
public void enableService(boolean enabled, boolean persistent) {
// Ignore
}
@Override
public boolean isServiceEnabled() {
return true;
}
@Override
public boolean isServicePrivate() {
return true;
}
@Override
public Iterator<Element> getIdentities(String name, String node, JID senderJID) {
Iterator identitiesIterator = super.getIdentities(name, node, senderJID);
// TODO: Add custom identities
return identitiesIterator;
}
}
...@@ -38,8 +38,8 @@ import java.sql.*; ...@@ -38,8 +38,8 @@ import java.sql.*;
*/ */
public class MultiUserChatManager extends BasicModule implements ClusterEventListener, MUCServicePropertyEventListener { public class MultiUserChatManager extends BasicModule implements ClusterEventListener, MUCServicePropertyEventListener {
private static final String LOAD_SERVICES = "SELECT subdomain,description FROM mucService WHERE autoLoad=1"; private static final String LOAD_SERVICES = "SELECT subdomain,description,isHidden FROM mucService";
private static final String CREATE_SERVICE = "INSERT INTO mucService(serviceID,subdomain,description,autoLoad) VALUES(?,?,?,?)"; private static final String CREATE_SERVICE = "INSERT INTO mucService(serviceID,subdomain,description,isHidden) VALUES(?,?,?,?)";
private static final String UPDATE_SERVICE = "UPDATE mucService SET subdomain=?,description=? WHERE serviceID=?"; private static final String UPDATE_SERVICE = "UPDATE mucService SET subdomain=?,description=? WHERE serviceID=?";
private static final String DELETE_SERVICE = "DELETE FROM mucService WHERE serviceID=?"; private static final String DELETE_SERVICE = "DELETE FROM mucService WHERE serviceID=?";
private static final String LOAD_SERVICE_ID = "SELECT serviceID FROM mucService WHERE subdomain=?"; private static final String LOAD_SERVICE_ID = "SELECT serviceID FROM mucService WHERE subdomain=?";
...@@ -118,16 +118,6 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis ...@@ -118,16 +118,6 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
*/ */
public void registerMultiUserChatService(MultiUserChatService service) { public void registerMultiUserChatService(MultiUserChatService service) {
Log.debug("MultiUserChatManager: Registering MUC service "+service.getServiceName()); Log.debug("MultiUserChatManager: Registering MUC service "+service.getServiceName());
if (!(service instanceof MultiUserChatServiceImpl)) {
// This is not a standard implementation. We need to store a mapping of it to a
// service ID for future reference, but the service itself won't need to know about
// it. First we will check if we already know about it.
Long serviceID = getMultiUserChatServiceID(service.getServiceName());
if (serviceID == null) {
// Nope, lets register it.
insertService(service.getServiceName(), null, false);
}
}
mucServices.put(service.getServiceName(), service); mucServices.put(service.getServiceName(), service);
try { try {
ComponentManagerFactory.getComponentManager().addComponent(service.getServiceName(), service); ComponentManagerFactory.getComponentManager().addComponent(service.getServiceName(), service);
...@@ -169,7 +159,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis ...@@ -169,7 +159,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
Integer servicesCnt = mucServices.size(); Integer servicesCnt = mucServices.size();
if (!includePrivate) { if (!includePrivate) {
for (MultiUserChatService service : mucServices.values()) { for (MultiUserChatService service : mucServices.values()) {
if (service.isServicePrivate()) { if (service.isHidden()) {
servicesCnt--; servicesCnt--;
} }
} }
...@@ -182,13 +172,16 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis ...@@ -182,13 +172,16 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
* *
* @param subdomain Subdomain of the MUC service. * @param subdomain Subdomain of the MUC service.
* @param description Description of the MUC service (can be null for default description) * @param description Description of the MUC service (can be null for default description)
* @param isHidden True if the service is hidden from view in services lists.
* @return MultiUserChatService implementation that was just created.
* @throws AlreadyExistsException if the service already exists. * @throws AlreadyExistsException if the service already exists.
*/ */
public void createMultiUserChatService(String subdomain, String description) throws AlreadyExistsException { public MultiUserChatServiceImpl createMultiUserChatService(String subdomain, String description, Boolean isHidden) throws AlreadyExistsException {
if (getMultiUserChatServiceID(subdomain) != null) throw new AlreadyExistsException(); if (getMultiUserChatServiceID(subdomain) != null) throw new AlreadyExistsException();
insertService(subdomain, description, true); insertService(subdomain, description, isHidden);
MultiUserChatServiceImpl muc = new MultiUserChatServiceImpl(subdomain, description); MultiUserChatServiceImpl muc = new MultiUserChatServiceImpl(subdomain, description, isHidden);
registerMultiUserChatService(muc); registerMultiUserChatService(muc);
return muc;
} }
/** /**
...@@ -223,7 +216,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis ...@@ -223,7 +216,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
// Update the information stored about the MUC service // Update the information stored about the MUC service
updateService(serviceID, subdomain, description); updateService(serviceID, subdomain, description);
// Create new MUC service with new settings // Create new MUC service with new settings
muc = new MultiUserChatServiceImpl(subdomain, description); muc = new MultiUserChatServiceImpl(subdomain, description, muc.isHidden());
// Register to new service // Register to new service
registerMultiUserChatService(muc); registerMultiUserChatService(muc);
} }
...@@ -385,7 +378,8 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis ...@@ -385,7 +378,8 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
while (rs.next()) { while (rs.next()) {
String subdomain = rs.getString(1); String subdomain = rs.getString(1);
String description = rs.getString(2); String description = rs.getString(2);
MultiUserChatServiceImpl muc = new MultiUserChatServiceImpl(subdomain, description); Boolean isHidden = Boolean.valueOf(rs.getString(3));
MultiUserChatServiceImpl muc = new MultiUserChatServiceImpl(subdomain, description, isHidden);
mucServices.put(subdomain, muc); mucServices.put(subdomain, muc);
} }
rs.close(); rs.close();
...@@ -470,14 +464,12 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis ...@@ -470,14 +464,12 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
} }
/** /**
* Inserts a new MUC service into the database. If autoLoad is true, then this service is a * Inserts a new MUC service into the database.
* MultiUserChatServiceImpl (ie, a default conference implementation). If it's not, it's some
* other implementation that we are expecting to load itself when the time is right.
* @param subdomain Subdomain of new service. * @param subdomain Subdomain of new service.
* @param description Description of MUC service. Can be null for default description. * @param description Description of MUC service. Can be null for default description.
* @param autoLoad True if the service should be automatically loaded as a MultiUserChatServiceImpl. * @param isHidden True if the service should be hidden from service listing.
*/ */
private void insertService(String subdomain, String description, Boolean autoLoad) { private void insertService(String subdomain, String description, Boolean isHidden) {
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
Long serviceID = SequenceManager.nextID(JiveConstants.MUC_SERVICE); Long serviceID = SequenceManager.nextID(JiveConstants.MUC_SERVICE);
...@@ -492,7 +484,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis ...@@ -492,7 +484,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
else { else {
pstmt.setNull(3, Types.VARCHAR); pstmt.setNull(3, Types.VARCHAR);
} }
pstmt.setInt(4, (autoLoad ? 1 : 0)); pstmt.setInt(4, (isHidden ? 1 : 0));
pstmt.executeUpdate(); pstmt.executeUpdate();
} }
catch (SQLException e) { catch (SQLException e) {
...@@ -751,7 +743,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis ...@@ -751,7 +743,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
service = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceInfo.getSubdomain()); service = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceInfo.getSubdomain());
if (service == null) { if (service == null) {
// This is a service we don't know about yet, create it locally and register it; // This is a service we don't know about yet, create it locally and register it;
service = new MultiUserChatServiceImpl(serviceInfo.getSubdomain(), serviceInfo.getDescription()); service = new MultiUserChatServiceImpl(serviceInfo.getSubdomain(), serviceInfo.getDescription(), serviceInfo.isHidden());
XMPPServer.getInstance().getMultiUserChatManager().registerMultiUserChatService(service); XMPPServer.getInstance().getMultiUserChatManager().registerMultiUserChatService(service);
} }
......
...@@ -346,14 +346,12 @@ public interface MultiUserChatService extends Component { ...@@ -346,14 +346,12 @@ public interface MultiUserChatService extends Component {
boolean isServiceEnabled(); boolean isServiceEnabled();
/** /**
* Returns true if the MUC service is a private, externally managed, service. This is typically * Returns true if the MUC service is a hidden, externally managed, service. This is typically
* set to true when the implementation is not the default one, and is not to be managed by * set to true when the implementation is not the default one, and is not to be managed by
* the standard Openfire interface. If this is set to true, the service will not show up in * the standard Openfire interface. If this is set to true, the service will not show up in
* the service list in the admin console. * the service list in the admin console.
* *
* TODO: Anything else? Should it show up in Disco browsing? * @return true if the MUC service is hidden and externally managed.
*
* @return true if the MUC service is private and externally managed.
*/ */
boolean isServicePrivate(); boolean isHidden();
} }
\ No newline at end of file
...@@ -35,6 +35,7 @@ import java.util.List; ...@@ -35,6 +35,7 @@ import java.util.List;
public class ServiceInfo implements Externalizable { public class ServiceInfo implements Externalizable {
private String subdomain; private String subdomain;
private String description; private String description;
private Boolean isHidden;
private List<RoomInfo> rooms = new ArrayList<RoomInfo>(); private List<RoomInfo> rooms = new ArrayList<RoomInfo>();
/** /**
...@@ -46,6 +47,7 @@ public class ServiceInfo implements Externalizable { ...@@ -46,6 +47,7 @@ public class ServiceInfo implements Externalizable {
public ServiceInfo(MultiUserChatService service) { public ServiceInfo(MultiUserChatService service) {
this.subdomain = service.getServiceName(); this.subdomain = service.getServiceName();
this.description = service.getDescription(); this.description = service.getDescription();
this.isHidden = service.isHidden();
rooms = new ArrayList<RoomInfo>(); rooms = new ArrayList<RoomInfo>();
// Get rooms that have occupants and include them in the reply // Get rooms that have occupants and include them in the reply
for (MUCRoom room : service.getChatRooms()) { for (MUCRoom room : service.getChatRooms()) {
...@@ -64,6 +66,10 @@ public class ServiceInfo implements Externalizable { ...@@ -64,6 +66,10 @@ public class ServiceInfo implements Externalizable {
return description; return description;
} }
public Boolean isHidden() {
return isHidden;
}
public List<RoomInfo> getRooms() { public List<RoomInfo> getRooms() {
return rooms; return rooms;
} }
...@@ -71,12 +77,14 @@ public class ServiceInfo implements Externalizable { ...@@ -71,12 +77,14 @@ public class ServiceInfo implements Externalizable {
public void writeExternal(ObjectOutput out) throws IOException { public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeSafeUTF(out, subdomain); ExternalizableUtil.getInstance().writeSafeUTF(out, subdomain);
ExternalizableUtil.getInstance().writeSafeUTF(out, description); ExternalizableUtil.getInstance().writeSafeUTF(out, description);
ExternalizableUtil.getInstance().writeBoolean(out, isHidden);
ExternalizableUtil.getInstance().writeExternalizableCollection(out, rooms); ExternalizableUtil.getInstance().writeExternalizableCollection(out, rooms);
} }
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
subdomain = ExternalizableUtil.getInstance().readSafeUTF(in); subdomain = ExternalizableUtil.getInstance().readSafeUTF(in);
description = ExternalizableUtil.getInstance().readSafeUTF(in); description = ExternalizableUtil.getInstance().readSafeUTF(in);
isHidden = ExternalizableUtil.getInstance().readBoolean(in);
ExternalizableUtil.getInstance().readExternalizableCollection(in, rooms, getClass().getClassLoader()); ExternalizableUtil.getInstance().readExternalizableCollection(in, rooms, getClass().getClassLoader());
} }
} }
...@@ -198,6 +198,11 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService ...@@ -198,6 +198,11 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService
*/ */
private boolean serviceEnabled = true; private boolean serviceEnabled = true;
/**
* Flag that indicates if MUC service is hidden from services views.
*/
private boolean isHidden = true;
/** /**
* Delegate responds to events for the MUC service. * Delegate responds to events for the MUC service.
*/ */
...@@ -208,8 +213,9 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService ...@@ -208,8 +213,9 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService
* *
* @param subdomain Subdomain portion of the conference services (for example, conference for conference.example.org) * @param subdomain Subdomain portion of the conference services (for example, conference for conference.example.org)
* @param description Short description of service for disco and such. * @param description Short description of service for disco and such.
* @param isHidden True if this service should be hidden from services views.
*/ */
public MultiUserChatServiceImpl(String subdomain, String description) { public MultiUserChatServiceImpl(String subdomain, String description, Boolean isHidden) {
this.chatServiceName = subdomain; this.chatServiceName = subdomain;
if (description != null && description.trim().length() > 0) { if (description != null && description.trim().length() > 0) {
this.chatDescription = description; this.chatDescription = description;
...@@ -217,6 +223,7 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService ...@@ -217,6 +223,7 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService
else { else {
this.chatDescription = LocaleUtils.getLocalizedString("muc.service-name"); this.chatDescription = LocaleUtils.getLocalizedString("muc.service-name");
} }
this.isHidden = isHidden;
historyStrategy = new HistoryStrategy(null); historyStrategy = new HistoryStrategy(null);
initialize(XMPPServer.getInstance()); initialize(XMPPServer.getInstance());
} }
...@@ -1298,8 +1305,8 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService ...@@ -1298,8 +1305,8 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService
return buf.toString(); return buf.toString();
} }
public boolean isServicePrivate() { public boolean isHidden() {
return false; return isHidden;
} }
} }
\ No newline at end of file
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