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 (
serviceID INTEGER NOT NULL,
subdomain VARCHAR(255) NOT NULL,
description VARCHAR(255),
autoLoad INTEGER NOT NULL,
isHidden INTEGER NOT NULL,
CONSTRAINT mucService_pk PRIMARY KEY (subdomain)
);
CREATE INDEX mucService_serviceid_idx ON mucService(serviceID);
......@@ -392,4 +392,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
-- 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 (
serviceID BIGINT NOT NULL,
subdomain VARCHAR(255) NOT NULL,
description VARCHAR(255),
autoLoad INTEGER NOT NULL,
isHidden INTEGER NOT NULL,
CONSTRAINT mucService_pk PRIMARY KEY (subdomain)
);
CREATE INDEX mucService_serviceid_idx ON mucService(serviceID);
......@@ -378,4 +378,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
// 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 (
serviceID BIGINT NOT NULL,
subdomain VARCHAR(255) NOT NULL,
description VARCHAR(255),
autoLoad TINYINT NOT NULL,
isHidden TINYINT NOT NULL,
PRIMARY KEY (subdomain),
INDEX mucService_serviceid_idx (serviceID)
);
......@@ -367,4 +367,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
# 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 (
serviceID INT NOT NULL,
subdomain VARCHAR2(255) NOT NULL,
description VARCHAR2(255),
autoLoad INTEGER NOT NULL,
isHidden INTEGER NOT NULL,
CONSTRAINT mucService_pk PRIMARY KEY (subdomain)
);
CREATE INDEX mucService_serviceid_idx ON mucService(serviceID);
......@@ -375,6 +375,6 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
-- Entry for default conference service
INSERT INTO mucService (serviceID, subdomain) VALUES (1, 'conference');
INSERT INTO mucService (serviceID, subdomain, isHidden) VALUES (1, 'conference', 0);
commit;
......@@ -183,7 +183,7 @@ CREATE TABLE mucService (
serviceID INTEGER NOT NULL,
subdomain VARCHAR(255) NOT NULL,
description VARCHAR(255),
autoLoad INTEGER NOT NULL,
isHidden INTEGER NOT NULL,
CONSTRAINT mucService_pk PRIMARY KEY (subdomain)
);
CREATE INDEX mucService_serviceid_idx ON mucService(serviceID);
......@@ -383,4 +383,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
-- 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 (
serviceID INT NOT NULL,
subdomain NVARCHAR(255) NOT NULL,
description NVARCHAR(255),
autoLoad INT NOT NULL,
isHidden INT NOT NULL,
CONSTRAINT mucService_pk PRIMARY KEY (subdomain)
);
CREATE INDEX mucService_serviceid_idx ON mucService(serviceID);
......@@ -381,4 +381,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
/* 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 (
serviceID INT NOT NULL,
subdomain NVARCHAR(255) NOT NULL,
description NVARCHAR(255),
autoLoad INT NOT NULL,
isHidden INT NOT NULL,
CONSTRAINT mucService_pk PRIMARY KEY (subdomain)
);
CREATE INDEX mucService_serviceid_idx ON mucService(serviceID);
......@@ -380,4 +380,4 @@ INSERT INTO jiveUser (username, plainPassword, name, email, creationDate, modifi
VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');
/* 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
ALTER TABLE mucService ADD COLUMN autoLoad INTEGER NOT NULL;
-- add isHidden column to mucService
ALTER TABLE mucService ADD COLUMN isHidden INTEGER NOT NULL;
-- set all current services to autoLoad = true
UPDATE mucService set autoLoad = 1;
-- set all current services to isHidden = false
UPDATE mucService set isHidden = 0;
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;
// add isHidden column to mucService
ALTER TABLE mucService ADD COLUMN isHidden INTEGER NOT NULL;
// set all current services to autoLoad = true
UPDATE mucService set autoLoad = 1;
// set all current services to isHidden = false
UPDATE mucService set isHidden = 0;
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;
# add isHidden column to mucService
ALTER TABLE mucService ADD COLUMN isHidden TINYINT NOT NULL;
# set all current services to autoLoad = true
UPDATE mucService set autoLoad = 1;
# set all current services to isHidden = false
UPDATE mucService set isHidden = 0;
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;
-- add isHidden column to mucService
ALTER TABLE mucService ADD isHidden INTEGER NOT NULL;
-- set all current services to autoLoad = true
UPDATE mucService set autoLoad = 1;
-- set all current services to isHidden = false
UPDATE mucService set isHidden = 0;
UPDATE jiveVersion set version=18 where name = 'openfire';
......
-- add autoLoad column to mucService
ALTER TABLE mucService ADD COLUMN autoLoad INTEGER NOT NULL;
-- add isHidden column to mucService
ALTER TABLE mucService ADD COLUMN isHidden INTEGER NOT NULL;
-- set all current services to autoLoad = true
UPDATE mucService set autoLoad = 1;
-- set all current services to isHidden = false
UPDATE mucService set isHidden = 0;
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;
/* add isHidden column to mucService */
ALTER TABLE mucService ADD isHidden INT NOT NULL;
/* set all current services to autoLoad = true */
UPDATE mucService set autoLoad = 1;
/* set all current services to isHidden = false */
UPDATE mucService set isHidden = 0;
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;
/* add isHidden column to mucService */
ALTER TABLE mucService ADD COLUMN isHidden INT NOT NULL;
/* set all current services to autoLoad = true */
UPDATE mucService set autoLoad = 1;
/* set all current services to isHidden = false */
UPDATE mucService set isHidden = 0;
UPDATE jiveVersion set version=18 where name = 'openfire';
\ No newline at end of file
......@@ -18,6 +18,7 @@ import org.dom4j.*;
import org.dom4j.io.XMPPPacketReader;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.XMPPServerInfo;
import org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl;
import org.jivesoftware.openfire.auth.AuthFactory;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import static org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET;
......@@ -412,8 +413,18 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
// Listen for changes to external component settings
ExternalComponentManager.addListener(this);
// Set up custom clearspace MUC service
ClearspaceMultiUserChatService mucService = new ClearspaceMultiUserChatService(MUC_SUBDOMAIN, MUC_DESCRIPTION);
XMPPServer.getInstance().getMultiUserChatManager().registerMultiUserChatService(mucService);
// Create service if it doesn't exist, load if it does.
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
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.*;
*/
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 CREATE_SERVICE = "INSERT INTO mucService(serviceID,subdomain,description,autoLoad) VALUES(?,?,?,?)";
private static final String LOAD_SERVICES = "SELECT subdomain,description,isHidden FROM mucService";
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 DELETE_SERVICE = "DELETE FROM mucService WHERE serviceID=?";
private static final String LOAD_SERVICE_ID = "SELECT serviceID FROM mucService WHERE subdomain=?";
......@@ -118,16 +118,6 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
*/
public void registerMultiUserChatService(MultiUserChatService service) {
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);
try {
ComponentManagerFactory.getComponentManager().addComponent(service.getServiceName(), service);
......@@ -169,7 +159,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
Integer servicesCnt = mucServices.size();
if (!includePrivate) {
for (MultiUserChatService service : mucServices.values()) {
if (service.isServicePrivate()) {
if (service.isHidden()) {
servicesCnt--;
}
}
......@@ -182,13 +172,16 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
*
* @param subdomain Subdomain of the MUC service.
* @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.
*/
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();
insertService(subdomain, description, true);
MultiUserChatServiceImpl muc = new MultiUserChatServiceImpl(subdomain, description);
insertService(subdomain, description, isHidden);
MultiUserChatServiceImpl muc = new MultiUserChatServiceImpl(subdomain, description, isHidden);
registerMultiUserChatService(muc);
return muc;
}
/**
......@@ -223,7 +216,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
// Update the information stored about the MUC service
updateService(serviceID, subdomain, description);
// Create new MUC service with new settings
muc = new MultiUserChatServiceImpl(subdomain, description);
muc = new MultiUserChatServiceImpl(subdomain, description, muc.isHidden());
// Register to new service
registerMultiUserChatService(muc);
}
......@@ -385,7 +378,8 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
while (rs.next()) {
String subdomain = rs.getString(1);
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);
}
rs.close();
......@@ -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
* 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.
* Inserts a new MUC service into the database.
* @param subdomain Subdomain of new service.
* @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;
PreparedStatement pstmt = null;
Long serviceID = SequenceManager.nextID(JiveConstants.MUC_SERVICE);
......@@ -492,7 +484,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
else {
pstmt.setNull(3, Types.VARCHAR);
}
pstmt.setInt(4, (autoLoad ? 1 : 0));
pstmt.setInt(4, (isHidden ? 1 : 0));
pstmt.executeUpdate();
}
catch (SQLException e) {
......@@ -751,7 +743,7 @@ public class MultiUserChatManager extends BasicModule implements ClusterEventLis
service = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceInfo.getSubdomain());
if (service == null) {
// 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);
}
......
......@@ -346,14 +346,12 @@ public interface MultiUserChatService extends Component {
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
* the standard Openfire interface. If this is set to true, the service will not show up in
* the service list in the admin console.
*
* TODO: Anything else? Should it show up in Disco browsing?
*
* @return true if the MUC service is private and externally managed.
* @return true if the MUC service is hidden and externally managed.
*/
boolean isServicePrivate();
boolean isHidden();
}
\ No newline at end of file
......@@ -35,6 +35,7 @@ import java.util.List;
public class ServiceInfo implements Externalizable {
private String subdomain;
private String description;
private Boolean isHidden;
private List<RoomInfo> rooms = new ArrayList<RoomInfo>();
/**
......@@ -46,6 +47,7 @@ public class ServiceInfo implements Externalizable {
public ServiceInfo(MultiUserChatService service) {
this.subdomain = service.getServiceName();
this.description = service.getDescription();
this.isHidden = service.isHidden();
rooms = new ArrayList<RoomInfo>();
// Get rooms that have occupants and include them in the reply
for (MUCRoom room : service.getChatRooms()) {
......@@ -64,6 +66,10 @@ public class ServiceInfo implements Externalizable {
return description;
}
public Boolean isHidden() {
return isHidden;
}
public List<RoomInfo> getRooms() {
return rooms;
}
......@@ -71,12 +77,14 @@ public class ServiceInfo implements Externalizable {
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeSafeUTF(out, subdomain);
ExternalizableUtil.getInstance().writeSafeUTF(out, description);
ExternalizableUtil.getInstance().writeBoolean(out, isHidden);
ExternalizableUtil.getInstance().writeExternalizableCollection(out, rooms);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
subdomain = ExternalizableUtil.getInstance().readSafeUTF(in);
description = ExternalizableUtil.getInstance().readSafeUTF(in);
isHidden = ExternalizableUtil.getInstance().readBoolean(in);
ExternalizableUtil.getInstance().readExternalizableCollection(in, rooms, getClass().getClassLoader());
}
}
......@@ -198,6 +198,11 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService
*/
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.
*/
......@@ -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 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;
if (description != null && description.trim().length() > 0) {
this.chatDescription = description;
......@@ -217,6 +223,7 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService
else {
this.chatDescription = LocaleUtils.getLocalizedString("muc.service-name");
}
this.isHidden = isHidden;
historyStrategy = new HistoryStrategy(null);
initialize(XMPPServer.getInstance());
}
......@@ -1298,8 +1305,8 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService
return buf.toString();
}
public boolean isServicePrivate() {
return false;
public boolean isHidden() {
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