Commit 206824ac authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Adjust MultiMUC support so that it stores database info about non-default MUC...

Adjust MultiMUC support so that it stores database info about non-default MUC implementations.  This assigns a service ID, necessary for various functions/mappings, and should make for a cleaner implementation.
Also tweaked the way columns are added for SQL Server and Oracle in update 17, based off some reading on proper ALTER TABLE calls.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10101 b35dd754-fafc-0310-a699-88a17e54d16e
parent 9ce8ec5a
...@@ -182,6 +182,7 @@ CREATE TABLE mucService ( ...@@ -182,6 +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,
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);
...@@ -384,7 +385,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1); ...@@ -384,7 +385,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveID (idType, id) VALUES (26, 1); INSERT INTO jiveID (idType, id) VALUES (26, 1);
INSERT INTO jiveVersion (name, version) VALUES ('openfire', 17); INSERT INTO jiveVersion (name, version) VALUES ('openfire', 18);
-- Entry for admin user -- Entry for admin user
INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -178,6 +178,7 @@ CREATE TABLE mucService ( ...@@ -178,6 +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,
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);
...@@ -370,7 +371,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1); ...@@ -370,7 +371,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveID (idType, id) VALUES (26, 1); INSERT INTO jiveID (idType, id) VALUES (26, 1);
INSERT INTO jiveVersion (name, version) VALUES ('openfire', 17); INSERT INTO jiveVersion (name, version) VALUES ('openfire', 18);
// Entry for admin user // Entry for admin user
INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -167,6 +167,7 @@ CREATE TABLE mucService ( ...@@ -167,6 +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,
PRIMARY KEY (subdomain), PRIMARY KEY (subdomain),
INDEX mucService_serviceid_idx (serviceID) INDEX mucService_serviceid_idx (serviceID)
); );
...@@ -359,7 +360,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1); ...@@ -359,7 +360,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveID (idType, id) VALUES (26, 1); INSERT INTO jiveID (idType, id) VALUES (26, 1);
INSERT INTO jiveVersion (name, version) VALUES ('openfire', 17); INSERT INTO jiveVersion (name, version) VALUES ('openfire', 18);
# Entry for admin user # Entry for admin user
INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -175,6 +175,7 @@ CREATE TABLE mucService ( ...@@ -175,6 +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,
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);
...@@ -367,7 +368,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1); ...@@ -367,7 +368,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveID (idType, id) VALUES (26, 1); INSERT INTO jiveID (idType, id) VALUES (26, 1);
INSERT INTO jiveVersion (name, version) VALUES ('openfire', 17); INSERT INTO jiveVersion (name, version) VALUES ('openfire', 18);
-- Entry for admin user -- Entry for admin user
INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -183,6 +183,7 @@ CREATE TABLE mucService ( ...@@ -183,6 +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,
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,7 +376,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1); ...@@ -375,7 +376,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveID (idType, id) VALUES (26, 1); INSERT INTO jiveID (idType, id) VALUES (26, 1);
INSERT INTO jiveVersion (name, version) VALUES ('openfire', 17); INSERT INTO jiveVersion (name, version) VALUES ('openfire', 18);
-- Entry for admin user -- Entry for admin user
INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -181,6 +181,7 @@ CREATE TABLE mucService ( ...@@ -181,6 +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,
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);
...@@ -373,7 +374,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1); ...@@ -373,7 +374,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveID (idType, id) VALUES (26, 1); INSERT INTO jiveID (idType, id) VALUES (26, 1);
INSERT INTO jiveVersion (name, version) VALUES ('openfire', 17); INSERT INTO jiveVersion (name, version) VALUES ('openfire', 18);
/* Entry for admin user */ /* Entry for admin user */
INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -180,6 +180,7 @@ CREATE TABLE mucService ( ...@@ -180,6 +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,
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);
...@@ -372,7 +373,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1); ...@@ -372,7 +373,7 @@ INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveID (idType, id) VALUES (26, 1); INSERT INTO jiveID (idType, id) VALUES (26, 1);
INSERT INTO jiveVersion (name, version) VALUES ('openfire', 17); INSERT INTO jiveVersion (name, version) VALUES ('openfire', 18);
/* Entry for admin user */ /* Entry for admin user */
INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -16,7 +16,7 @@ CREATE TABLE mucServiceProp ( ...@@ -16,7 +16,7 @@ CREATE TABLE mucServiceProp (
); );
-- add new indexed column to mucRoom -- add new indexed column to mucRoom
ALTER TABLE mucRoom ADD COLUMN serviceID INT NOT NULL; ALTER TABLE mucRoom ADD serviceID INT NOT NULL;
CREATE INDEX mucRm_serviceid_idx ON mucRoom (serviceID); CREATE INDEX mucRm_serviceid_idx ON mucRoom (serviceID);
-- change mucRoom primary key to be referenced around serviceID -- change mucRoom primary key to be referenced around serviceID
......
...@@ -16,7 +16,7 @@ CREATE TABLE mucServiceProp ( ...@@ -16,7 +16,7 @@ CREATE TABLE mucServiceProp (
); );
/* add new indexed column to mucRoom */ /* add new indexed column to mucRoom */
ALTER TABLE mucRoom ADD COLUMN serviceID INT NOT NULL; ALTER TABLE mucRoom ADD serviceID INT NOT NULL;
CREATE INDEX mucRoom_serviceid_idx ON mucRoom(serviceID); CREATE INDEX mucRoom_serviceid_idx ON mucRoom(serviceID);
/* change mucRoom primary key to be referenced around serviceID */ /* change mucRoom primary key to be referenced around serviceID */
......
-- add autoLoad column to mucService
ALTER TABLE mucService ADD COLUMN autoLoad INTEGER NOT NULL;
-- set all current services to autoLoad = true
UPDATE mucService set autoLoad = 1;
UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
// add autoLoad column to mucService
ALTER TABLE mucService ADD COLUMN autoLoad INTEGER NOT NULL;
// set all current services to autoLoad = true
UPDATE mucService set autoLoad = 1;
UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
# add autoLoad column to mucService
ALTER TABLE mucService ADD COLUMN autoLoad TINYINT NOT NULL;
# set all current services to autoLoad = true
UPDATE mucService set autoLoad = 1;
UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
-- add autoLoad column to mucService
ALTER TABLE mucService ADD autoLoad INTEGER NOT NULL;
-- set all current services to autoLoad = true
UPDATE mucService set autoLoad = 1;
UPDATE jiveVersion set version=18 where name = 'openfire';
commit;
\ No newline at end of file
-- add autoLoad column to mucService
ALTER TABLE mucService ADD COLUMN autoLoad INTEGER NOT NULL;
-- set all current services to autoLoad = true
UPDATE mucService set autoLoad = 1;
UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
/* add autoLoad column to mucService */
ALTER TABLE mucService ADD autoLoad INT NOT NULL;
/* set all current services to autoLoad = true */
UPDATE mucService set autoLoad = 1;
UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
/* add autoLoad column to mucService */
ALTER TABLE mucService ADD COLUMN autoLoad INT NOT NULL;
/* set all current services to autoLoad = true */
UPDATE mucService set autoLoad = 1;
UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
...@@ -44,7 +44,7 @@ public class SchemaManager { ...@@ -44,7 +44,7 @@ public class SchemaManager {
/** /**
* Current Openfire database schema version. * Current Openfire database schema version.
*/ */
private static final int DATABASE_VERSION = 17; private static final int DATABASE_VERSION = 18;
/** /**
* Creates a new Schema manager. * Creates a new Schema manager.
......
...@@ -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"; private static final String LOAD_SERVICES = "SELECT subdomain,description FROM mucService WHERE autoLoad=1";
private static final String CREATE_SERVICE = "INSERT INTO mucService(serviceID,subdomain,description) VALUES(?,?,?)"; private static final String CREATE_SERVICE = "INSERT INTO mucService(serviceID,subdomain,description,autoLoad) 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,6 +118,16 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis ...@@ -118,6 +118,16 @@ 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);
...@@ -176,7 +186,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis ...@@ -176,7 +186,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
*/ */
public void createMultiUserChatService(String subdomain, String description) throws AlreadyExistsException { public void createMultiUserChatService(String subdomain, String description) throws AlreadyExistsException {
if (getMultiUserChatServiceID(subdomain) != null) throw new AlreadyExistsException(); if (getMultiUserChatServiceID(subdomain) != null) throw new AlreadyExistsException();
insertService(subdomain, description); insertService(subdomain, description, true);
MultiUserChatServiceImpl muc = new MultiUserChatServiceImpl(subdomain, description); MultiUserChatServiceImpl muc = new MultiUserChatServiceImpl(subdomain, description);
registerMultiUserChatService(muc); registerMultiUserChatService(muc);
} }
...@@ -460,11 +470,14 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis ...@@ -460,11 +470,14 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
} }
/** /**
* Inserts a new MUC service into the database. * Inserts a new MUC service into the database. If autoLoad is true, then this service is a
* 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.
*/ */
private void insertService(String subdomain, String description) { private void insertService(String subdomain, String description, Boolean autoLoad) {
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);
...@@ -479,6 +492,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis ...@@ -479,6 +492,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.executeUpdate(); pstmt.executeUpdate();
} }
catch (SQLException e) { catch (SQLException e) {
......
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