Commit 6fa51d80 authored by Armando Jagucki's avatar Armando Jagucki Committed by ajagucki

ClearspaceMUCEventDelegate is now operational supporting on-demand room...

ClearspaceMUCEventDelegate is now operational supporting on-demand room creation and permissions-limited room joins/deletions. Along with that work came an optimization to the user creation process (JM-1313).

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10163 b35dd754-fafc-0310-a699-88a17e54d16e
parent bfaccdb4
...@@ -277,9 +277,11 @@ public class IQRouter extends BasicModule { ...@@ -277,9 +277,11 @@ public class IQRouter extends BasicModule {
multicastRouter.route(packet); multicastRouter.route(packet);
return; return;
} }
else if (IQ.Type.result == packet.getType() || IQ.Type.error == packet.getType()) { }
// The server got an answer to an IQ packet that was sent from the server if (IQ.Type.result == packet.getType() || IQ.Type.error == packet.getType()) {
IQResultListener iqResultListener = resultListeners.remove(packet.getID()); // The server got an answer to an IQ packet that was sent from the server
IQResultListener iqResultListener = resultListeners.remove(packet.getID());
if (iqResultListener != null) {
resultTimeout.remove(packet.getID()); resultTimeout.remove(packet.getID());
if (iqResultListener != null) { if (iqResultListener != null) {
try { try {
......
...@@ -26,12 +26,7 @@ public class ClearspaceAuthProvider implements AuthProvider { ...@@ -26,12 +26,7 @@ public class ClearspaceAuthProvider implements AuthProvider {
// Service url prefix // Service url prefix
protected static final String URL_PREFIX = "permissionService/"; protected static final String URL_PREFIX = "permissionService/";
private ClearspaceManager manager;
public ClearspaceAuthProvider() { public ClearspaceAuthProvider() {
// gets the manager
manager = ClearspaceManager.getInstance();
// Add SASL mechanism for use with Clearspace's group chat integration // Add SASL mechanism for use with Clearspace's group chat integration
SASLAuthentication.addSupportedMechanism("CLEARSPACE"); SASLAuthentication.addSupportedMechanism("CLEARSPACE");
} }
...@@ -65,7 +60,7 @@ public class ClearspaceAuthProvider implements AuthProvider { ...@@ -65,7 +60,7 @@ public class ClearspaceAuthProvider implements AuthProvider {
public void authenticate(String username, String password) throws UnauthorizedException { public void authenticate(String username, String password) throws UnauthorizedException {
try { try {
String path = URL_PREFIX + "authenticate/" + username + "/" + password; String path = URL_PREFIX + "authenticate/" + username + "/" + password;
manager.executeRequest(GET, path); ClearspaceManager.getInstance().executeRequest(GET, path);
} catch (UnauthorizedException ue) { } catch (UnauthorizedException ue) {
throw ue; throw ue;
} catch (Exception e) { } catch (Exception e) {
......
...@@ -35,12 +35,9 @@ import java.util.List; ...@@ -35,12 +35,9 @@ import java.util.List;
public class ClearspaceGroupProvider implements GroupProvider { public class ClearspaceGroupProvider implements GroupProvider {
protected static final String URL_PREFIX = "groupService/"; protected static final String URL_PREFIX = "groupService/";
private ClearspaceManager manager;
private Boolean readOnly; private Boolean readOnly;
public ClearspaceGroupProvider() { public ClearspaceGroupProvider() {
// gets the manager
manager = ClearspaceManager.getInstance();
} }
public Group createGroup(String name) throws UnsupportedOperationException, GroupAlreadyExistsException { public Group createGroup(String name) throws UnsupportedOperationException, GroupAlreadyExistsException {
...@@ -60,7 +57,7 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -60,7 +57,7 @@ public class ClearspaceGroupProvider implements GroupProvider {
nameE.addText(name); nameE.addText(name);
rootE.addElement("description"); rootE.addElement("description");
Element group = manager.executeRequest(POST, path, groupDoc.asXML()); Element group = ClearspaceManager.getInstance().executeRequest(POST, path, groupDoc.asXML());
return translateGroup(group); return translateGroup(group);
...@@ -79,9 +76,9 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -79,9 +76,9 @@ public class ClearspaceGroupProvider implements GroupProvider {
} }
try { try {
long groupID = manager.getGroupID(name); long groupID = ClearspaceManager.getInstance().getGroupID(name);
String path = URL_PREFIX + "groups/" + groupID; String path = URL_PREFIX + "groups/" + groupID;
manager.executeRequest(DELETE, path); ClearspaceManager.getInstance().executeRequest(DELETE, path);
} catch (GroupNotFoundException gnfe) { } catch (GroupNotFoundException gnfe) {
Log.error(gnfe); Log.error(gnfe);
...@@ -102,7 +99,7 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -102,7 +99,7 @@ public class ClearspaceGroupProvider implements GroupProvider {
WSUtils.modifyElementText(group, "name", newName); WSUtils.modifyElementText(group, "name", newName);
String path = URL_PREFIX + "groups"; String path = URL_PREFIX + "groups";
manager.executeRequest(PUT, path); ClearspaceManager.getInstance().executeRequest(PUT, path);
} catch (GroupNotFoundException gnfe) { } catch (GroupNotFoundException gnfe) {
Log.error(gnfe); Log.error(gnfe);
...@@ -120,7 +117,7 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -120,7 +117,7 @@ public class ClearspaceGroupProvider implements GroupProvider {
WSUtils.modifyElementText(group, "description", description); WSUtils.modifyElementText(group, "description", description);
String path = URL_PREFIX + "groups"; String path = URL_PREFIX + "groups";
manager.executeRequest(PUT, path); ClearspaceManager.getInstance().executeRequest(PUT, path);
} catch (GroupNotFoundException gnfe) { } catch (GroupNotFoundException gnfe) {
Log.error(gnfe); Log.error(gnfe);
...@@ -134,7 +131,7 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -134,7 +131,7 @@ public class ClearspaceGroupProvider implements GroupProvider {
public int getGroupCount() { public int getGroupCount() {
try { try {
String path = URL_PREFIX + "groupCount"; String path = URL_PREFIX + "groupCount";
Element element = manager.executeRequest(GET, path); Element element = ClearspaceManager.getInstance().executeRequest(GET, path);
return Integer.valueOf(getReturn(element)); return Integer.valueOf(getReturn(element));
} catch (Exception e) { } catch (Exception e) {
// It is not supported exception, wrap it into an UnsupportedOperationException // It is not supported exception, wrap it into an UnsupportedOperationException
...@@ -145,7 +142,7 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -145,7 +142,7 @@ public class ClearspaceGroupProvider implements GroupProvider {
public Collection<String> getGroupNames() { public Collection<String> getGroupNames() {
try { try {
String path = URL_PREFIX + "groupNames"; String path = URL_PREFIX + "groupNames";
Element element = manager.executeRequest(GET, path); Element element = ClearspaceManager.getInstance().executeRequest(GET, path);
return parseStringArray(element); return parseStringArray(element);
} catch (Exception e) { } catch (Exception e) {
...@@ -157,7 +154,7 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -157,7 +154,7 @@ public class ClearspaceGroupProvider implements GroupProvider {
public Collection<String> getGroupNames(int startIndex, int numResults) { public Collection<String> getGroupNames(int startIndex, int numResults) {
try { try {
String path = URL_PREFIX + "groupNamesBounded/" + startIndex + "/" + numResults; String path = URL_PREFIX + "groupNamesBounded/" + startIndex + "/" + numResults;
Element element = manager.executeRequest(GET, path); Element element = ClearspaceManager.getInstance().executeRequest(GET, path);
return parseStringArray(element); return parseStringArray(element);
} catch (Exception e) { } catch (Exception e) {
...@@ -168,9 +165,9 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -168,9 +165,9 @@ public class ClearspaceGroupProvider implements GroupProvider {
public Collection<String> getGroupNames(JID user) { public Collection<String> getGroupNames(JID user) {
try { try {
long userID = manager.getUserID(user); long userID = ClearspaceManager.getInstance().getUserID(user);
String path = URL_PREFIX + "userGroupNames/" + userID; String path = URL_PREFIX + "userGroupNames/" + userID;
Element element = manager.executeRequest(GET, path); Element element = ClearspaceManager.getInstance().executeRequest(GET, path);
return parseStringArray(element); return parseStringArray(element);
} catch (UserNotFoundException e) { } catch (UserNotFoundException e) {
...@@ -183,8 +180,8 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -183,8 +180,8 @@ public class ClearspaceGroupProvider implements GroupProvider {
public void addMember(String groupName, JID user, boolean administrator) throws UnsupportedOperationException { public void addMember(String groupName, JID user, boolean administrator) throws UnsupportedOperationException {
try { try {
long userID = manager.getUserID(user); long userID = ClearspaceManager.getInstance().getUserID(user);
long groupID = manager.getGroupID(groupName); long groupID = ClearspaceManager.getInstance().getGroupID(groupName);
String path = URL_PREFIX; String path = URL_PREFIX;
...@@ -202,7 +199,7 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -202,7 +199,7 @@ public class ClearspaceGroupProvider implements GroupProvider {
rootE.addElement("groupID"); rootE.addElement("groupID");
nameE.addText(String.valueOf(groupID)); nameE.addText(String.valueOf(groupID));
manager.executeRequest(POST, path, groupDoc.asXML()); ClearspaceManager.getInstance().executeRequest(POST, path, groupDoc.asXML());
} catch (GroupNotFoundException e) { } catch (GroupNotFoundException e) {
...@@ -225,8 +222,8 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -225,8 +222,8 @@ public class ClearspaceGroupProvider implements GroupProvider {
long userID; long userID;
long groupID; long groupID;
try { try {
userID = manager.getUserID(user); userID = ClearspaceManager.getInstance().getUserID(user);
groupID = manager.getGroupID(groupName); groupID = ClearspaceManager.getInstance().getGroupID(groupName);
} catch (GroupNotFoundException e) { } catch (GroupNotFoundException e) {
// It's ok, that not existing group doesn't contains that memeber, :) // It's ok, that not existing group doesn't contains that memeber, :)
...@@ -243,10 +240,10 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -243,10 +240,10 @@ public class ClearspaceGroupProvider implements GroupProvider {
//for user. Therefore one of them could throw an exception. //for user. Therefore one of them could throw an exception.
try { try {
String path = URL_PREFIX + "groupAdmins/" + groupID + "/" + userID; String path = URL_PREFIX + "groupAdmins/" + groupID + "/" + userID;
manager.executeRequest(DELETE, path); ClearspaceManager.getInstance().executeRequest(DELETE, path);
path = URL_PREFIX + "groupMembers/" + groupID + "/" + userID; path = URL_PREFIX + "groupMembers/" + groupID + "/" + userID;
manager.executeRequest(DELETE, path); ClearspaceManager.getInstance().executeRequest(DELETE, path);
} catch (GroupNotFoundException e) { } catch (GroupNotFoundException e) {
//won't happend, the group exist //won't happend, the group exist
} catch (UserNotFoundException e) { } catch (UserNotFoundException e) {
...@@ -270,7 +267,7 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -270,7 +267,7 @@ public class ClearspaceGroupProvider implements GroupProvider {
try { try {
// See if the is read only // See if the is read only
String path = URL_PREFIX + "isReadOnly"; String path = URL_PREFIX + "isReadOnly";
Element element = manager.executeRequest(GET, path); Element element = ClearspaceManager.getInstance().executeRequest(GET, path);
readOnly = Boolean.valueOf(getReturn(element)); readOnly = Boolean.valueOf(getReturn(element));
} catch (Exception e) { } catch (Exception e) {
// if there is a problem, keep it null, maybe in the next call succes. // if there is a problem, keep it null, maybe in the next call succes.
...@@ -328,7 +325,7 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -328,7 +325,7 @@ public class ClearspaceGroupProvider implements GroupProvider {
try { try {
String path = URL_PREFIX + "groups/" + name; String path = URL_PREFIX + "groups/" + name;
return manager.executeRequest(GET, path); return ClearspaceManager.getInstance().executeRequest(GET, path);
} catch (GroupNotFoundException gnfe) { } catch (GroupNotFoundException gnfe) {
// It is a supported exception, throw it again // It is a supported exception, throw it again
throw gnfe; throw gnfe;
...@@ -350,7 +347,7 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -350,7 +347,7 @@ public class ClearspaceGroupProvider implements GroupProvider {
} else { } else {
path = URL_PREFIX + "groupMembers/" + groupID; path = URL_PREFIX + "groupMembers/" + groupID;
} }
Element element = manager.executeRequest(GET, path); Element element = ClearspaceManager.getInstance().executeRequest(GET, path);
// Gets the JID from the response // Gets the JID from the response
List<Node> users = (List<Node>) element.selectNodes("return"); List<Node> users = (List<Node>) element.selectNodes("return");
......
...@@ -36,14 +36,10 @@ public class ClearspaceLockOutProvider implements LockOutProvider { ...@@ -36,14 +36,10 @@ public class ClearspaceLockOutProvider implements LockOutProvider {
protected static final String USER_URL_PREFIX = "userService/"; protected static final String USER_URL_PREFIX = "userService/";
private ClearspaceManager manager;
/** /**
* Generate a ClearspaceLockOutProvider instance. * Generate a ClearspaceLockOutProvider instance.
*/ */
public ClearspaceLockOutProvider() { public ClearspaceLockOutProvider() {
// Gets the manager
manager = ClearspaceManager.getInstance();
} }
/** /**
...@@ -123,7 +119,7 @@ public class ClearspaceLockOutProvider implements LockOutProvider { ...@@ -123,7 +119,7 @@ public class ClearspaceLockOutProvider implements LockOutProvider {
Element modifiedUser = modifyUser(user.element("return"), "enabled", enabled ? "true" : "false"); Element modifiedUser = modifyUser(user.element("return"), "enabled", enabled ? "true" : "false");
String path = USER_URL_PREFIX + "users"; String path = USER_URL_PREFIX + "users";
manager.executeRequest(PUT, path, modifiedUser.asXML()); ClearspaceManager.getInstance().executeRequest(PUT, path, modifiedUser.asXML());
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
Log.error("User with name " + username + " not found.", e); Log.error("User with name " + username + " not found.", e);
...@@ -206,7 +202,7 @@ public class ClearspaceLockOutProvider implements LockOutProvider { ...@@ -206,7 +202,7 @@ public class ClearspaceLockOutProvider implements LockOutProvider {
// Requests the user // Requests the user
String path = USER_URL_PREFIX + "users/" + username; String path = USER_URL_PREFIX + "users/" + username;
// return the response // return the response
return manager.executeRequest(GET, path); return ClearspaceManager.getInstance().executeRequest(GET, path);
} }
catch (Exception e) { catch (Exception e) {
// It is not supported exception, wrap it into an UserNotFoundException // It is not supported exception, wrap it into an UserNotFoundException
......
...@@ -2,27 +2,38 @@ package org.jivesoftware.openfire.clearspace; ...@@ -2,27 +2,38 @@ package org.jivesoftware.openfire.clearspace;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.muc.MUCEventDelegate; import org.jivesoftware.openfire.muc.MUCEventDelegate;
import org.jivesoftware.openfire.muc.MUCRoom;
import org.jivesoftware.util.StringUtils;
import org.jivesoftware.util.Log;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.DocumentHelper; import org.dom4j.Attribute;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Collection;
import java.util.Iterator;
/** /**
* Handles checking with Clearspace regarding whether a user can join a particular chatroom (based * Handles checking with Clearspace regarding whether a user can join a particular MUC room (based
* on their permissions with the document/whatever the chatroom is associated with), as well as setting * on their permissions with the Clearspace JiveObject (eg. Community/Space) that the room is associated with).
* up room configurations. *
* In addition, this MUCEventDelegate provides a means to obtain room configuration details from Clearspace
* in the event that the Clearspace MUC service needs to create a room on-demand (eg. when a user first joins the room).
* *
* @author Armando Jagucki * @author Armando Jagucki
*/ */
public class ClearspaceMUCEventDelegate extends MUCEventDelegate { public class ClearspaceMUCEventDelegate extends MUCEventDelegate {
private String csMucDomain; private String csMucDomain;
private String csComponentAddress;
private final String GET_ROOM_CONFIG_WARNING ="Clearspace sent an unexpected reply to a get-room-config request.";
public ClearspaceMUCEventDelegate() { public ClearspaceMUCEventDelegate() {
csMucDomain = ClearspaceManager.MUC_SUBDOMAIN+"@"+XMPPServer.getInstance().getServerInfo().getXMPPDomain(); String xmppDomain = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
csMucDomain = ClearspaceManager.MUC_SUBDOMAIN + "." + xmppDomain;
csComponentAddress = ClearspaceManager.CLEARSPACE_COMPONENT + "." + xmppDomain;
} }
/** /**
...@@ -30,25 +41,33 @@ public class ClearspaceMUCEventDelegate extends MUCEventDelegate { ...@@ -30,25 +41,33 @@ public class ClearspaceMUCEventDelegate extends MUCEventDelegate {
* <p/> * <p/>
* Returns true if the user is allowed to join the room. * Returns true if the user is allowed to join the room.
* *
* @param roomName the name of the MUC room. * @param room the room the user is attempting to join.
* @param userjid the JID of the user attempting to join the room. * @param userjid the JID of the user attempting to join the room.
* @return true if the user is allowed to join the room. * @return true if the user is allowed to join the room.
*/ */
public boolean joiningRoom(String roomName, JID userjid) { public boolean joiningRoom(MUCRoom room, JID userjid) {
// Packet should look like: // Packet should look like:
// <iq to="clearspace.example.org" from="clearspace-conference.example.org"> // <iq to="clearspace.example.org" from="clearspace-conference.example.org">
// <join-check xmlns="http://jivesoftware.com/clearspace"> // <join-check xmlns="http://jivesoftware.com/clearspace">
// <userjid>username@example.org</userjid> // <userjid>username@example.org</userjid>
// <roomjid>DOC-1234@clearspace-conference.example.org</roomjid> // <roomjid>14-1234@clearspace-conference.example.org</roomjid>
// </join-check> // </join-check>
// </iq> // </iq>
// Always allow an owner to join the room (especially since they need to join to configure the
// room on initial creation).
Collection<String> owners = room.getOwners();
if (owners != null && owners.contains(userjid.toBareJID())) {
return true;
}
IQ query = new IQ(); IQ query = new IQ();
query.setFrom(csMucDomain); query.setFrom(csMucDomain);
Element cmd = DocumentHelper.createElement("join-check"); Element cmd = query.setChildElement("join-check", "http://jivesoftware.com/clearspace");
cmd.addElement("userjid").addText(userjid.toBareJID()); Element userjidElement = cmd.addElement("userjid");
cmd.addElement("roomjid").addText(roomName+"@"+csMucDomain); userjidElement.setText(userjid.toBareJID());
query.setChildElement(cmd); Element roomjidElement = cmd.addElement("roomjid");
roomjidElement.setText(room.getJID().toBareJID());
IQ result = ClearspaceManager.getInstance().query(query, 15000); IQ result = ClearspaceManager.getInstance().query(query, 15000);
if (result == null) { if (result == null) {
...@@ -68,35 +87,49 @@ public class ClearspaceMUCEventDelegate extends MUCEventDelegate { ...@@ -68,35 +87,49 @@ public class ClearspaceMUCEventDelegate extends MUCEventDelegate {
public Map<String, String> getRoomConfig(String roomName) { public Map<String, String> getRoomConfig(String roomName) {
Map<String, String> roomConfig = new HashMap<String, String>(); Map<String, String> roomConfig = new HashMap<String, String>();
// TODO: Create query packet asking for the room config and in CS create a handler for that packet IQ iq = new IQ(IQ.Type.get);
IQ query = null; iq.setFrom(csMucDomain);
IQ result = ClearspaceManager.getInstance().query(query, 15000); iq.setID("get_room_config_" + StringUtils.randomString(3));
Element child = iq.setChildElement("get-room-config", "http://jivesoftware.com/clearspace");
Element roomjidElement = child.addElement("roomjid");
JID roomJid = new JID(roomName + "@" + csMucDomain);
roomjidElement.setText(roomJid.toBareJID());
IQ result = ClearspaceManager.getInstance().query(iq, 15000);
if (result == null) { if (result == null) {
// TODO No answer was received from Clearspace so return null // No answer was received from Clearspace, so return null.
Log.warn(GET_ROOM_CONFIG_WARNING);
return null;
}
else if (result.getType() != IQ.Type.result) {
// The reply was not a valid result containing the room configuration, so return null.
Log.warn(GET_ROOM_CONFIG_WARNING);
return null; return null;
} }
// TODO Check that the IQ is of type RESULT (and not ERROR) otherwise return null
// Setup room configuration based on the configuration values in the result packet.
// TODO: Setup roomConfig based on the result packet containing config values Element query = result.getChildElement();
JID roomJid = new JID(roomName); if (query == null) {
roomConfig.put("muc#roomconfig_roomname", roomJid.getNode()); Log.warn(GET_ROOM_CONFIG_WARNING);
roomConfig.put("muc#roomconfig_roomdesc", ""); return null;
roomConfig.put("muc#roomconfig_changesubject", "1"); }
roomConfig.put("muc#roomconfig_maxusers", "0"); Element xElement = query.element("x");
roomConfig.put("muc#roomconfig_publicroom", "1"); if (xElement == null) {
roomConfig.put("muc#roomconfig_moderatedroom", "0"); Log.warn(GET_ROOM_CONFIG_WARNING);
roomConfig.put("muc#roomconfig_membersonly", "0"); return null;
roomConfig.put("muc#roomconfig_allowinvites", "1"); }
roomConfig.put("muc#roomconfig_roomsecret", ""); Iterator fields = xElement.elementIterator("field");
roomConfig.put("muc#roomconfig_whois", "anyone"); while (fields.hasNext()) {
roomConfig.put("muc#roomconfig_enablelogging", "0"); Element field = (Element) fields.next();
roomConfig.put("x-muc#roomconfig_reservednick", "0"); Attribute varAttribute = field.attribute("var");
roomConfig.put("x-muc#roomconfig_canchangenick", "1"); if (varAttribute != null) {
roomConfig.put("x-muc#roomconfig_registration", "1"); Element value = field.element("value");
roomConfig.put("muc#roomconfig_persistentroom", "1"); if (value != null) {
roomConfig.put(varAttribute.getValue(), value.getText());
String ownerJid = roomJid.getNode() + "@" }
+ "clearspace." + XMPPServer.getInstance().getServerInfo().getXMPPDomain(); }
}
String ownerJid = roomJid.getNode() + "@" + csComponentAddress;
roomConfig.put("muc#roomconfig_roomowners", ownerJid); roomConfig.put("muc#roomconfig_roomowners", ownerJid);
return roomConfig; return roomConfig;
...@@ -113,6 +146,6 @@ public class ClearspaceMUCEventDelegate extends MUCEventDelegate { ...@@ -113,6 +146,6 @@ public class ClearspaceMUCEventDelegate extends MUCEventDelegate {
*/ */
public boolean destroyingRoom(String roomName, JID userjid) { public boolean destroyingRoom(String roomName, JID userjid) {
// We never allow destroying a room as a user, but clearspace components are permitted. // We never allow destroying a room as a user, but clearspace components are permitted.
return ClearspaceManager.getInstance().isClearspace(userjid); return ClearspaceManager.getInstance().isFromClearspace(userjid);
} }
} }
...@@ -66,6 +66,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -66,6 +66,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
protected static final String IM_URL_PREFIX = "imService/"; protected static final String IM_URL_PREFIX = "imService/";
public static final String MUC_SUBDOMAIN = "clearspace-conference"; public static final String MUC_SUBDOMAIN = "clearspace-conference";
private static final String MUC_DESCRIPTION = "Clearspace Conference Services"; private static final String MUC_DESCRIPTION = "Clearspace Conference Services";
public static final String CLEARSPACE_COMPONENT = "clearspace";
private static ThreadLocal<XMPPPacketReader> localParser = null; private static ThreadLocal<XMPPPacketReader> localParser = null;
private static XmlPullParserFactory factory = null; private static XmlPullParserFactory factory = null;
...@@ -74,7 +75,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -74,7 +75,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
*/ */
private static final Map<String, String> exceptionMap; private static final Map<String, String> exceptionMap;
private static ClearspaceManager instance = new ClearspaceManager(); private static ClearspaceManager instance;
static { static {
try { try {
...@@ -205,6 +206,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -205,6 +206,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
}; };
init(); init();
instance = this;
} }
private void init() { private void init() {
...@@ -832,23 +834,18 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -832,23 +834,18 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
} }
/** /**
* Returns true if a given JID represents a known Clearspace component domain. * Returns true if a given JID belongs to a known Clearspace component domain.
* @param address Address to check. * @param address Address to check.
* @return True if the specified address is a Clearspace component. * @return True if the specified address is a Clearspace component.
*/ */
public boolean isClearspace(JID address) { public boolean isFromClearspace(JID address) {
return address.getNode() == null && clearspaces.contains(address.getDomain()); return clearspaces.contains(address.getDomain());
} }
/** /**
* Sends an IQ packet to the Clearspace external component and returns the IQ packet * Sends an IQ packet to the Clearspace external component and returns the IQ packet
* returned by CS or <tt>null</tt> if no answer was received before the specified * returned by CS or <tt>null</tt> if no answer was received before the specified
* timeout.<p> * timeout.
*
* The returned packet will be handled by the server and routed to the entity that sent
* the original IQ packet. Since this method block and listen to the replied IQ packet
* then the entity that sent the original IQ packet should ignore any reply related to
* the originating IQ packet.
* *
* @param packet IQ packet to send. * @param packet IQ packet to send.
* @param timeout milliseconds to wait before timing out. * @param timeout milliseconds to wait before timing out.
......
...@@ -32,14 +32,10 @@ public class ClearspaceSecurityAuditProvider implements SecurityAuditProvider { ...@@ -32,14 +32,10 @@ public class ClearspaceSecurityAuditProvider implements SecurityAuditProvider {
protected static final String AUDIT_URL_PREFIX = "auditService/"; protected static final String AUDIT_URL_PREFIX = "auditService/";
private ClearspaceManager manager;
/** /**
* Generate a ClearspaceSecurityAuditProvider instance. * Generate a ClearspaceSecurityAuditProvider instance.
*/ */
public ClearspaceSecurityAuditProvider() { public ClearspaceSecurityAuditProvider() {
// Gets the manager
manager = ClearspaceManager.getInstance();
} }
/** /**
...@@ -72,7 +68,7 @@ public class ClearspaceSecurityAuditProvider implements SecurityAuditProvider { ...@@ -72,7 +68,7 @@ public class ClearspaceSecurityAuditProvider implements SecurityAuditProvider {
detlE.addText("No details provided."); detlE.addText("No details provided.");
} }
manager.executeRequest(POST, path, auditDoc.asXML()); ClearspaceManager.getInstance().executeRequest(POST, path, auditDoc.asXML());
} }
catch (Exception e) { catch (Exception e) {
// Error while setting properties? // Error while setting properties?
......
...@@ -35,14 +35,10 @@ public class ClearspaceUserProvider implements UserProvider { ...@@ -35,14 +35,10 @@ public class ClearspaceUserProvider implements UserProvider {
// The ProfileSearchService webservice url prefix // The ProfileSearchService webservice url prefix
protected static final String SEARCH_URL_PREFIX = "profileSearchService/"; protected static final String SEARCH_URL_PREFIX = "profileSearchService/";
private ClearspaceManager manager;
// Used to know it CS is a read only user provider // Used to know it CS is a read only user provider
private Boolean readOnly; private Boolean readOnly;
public ClearspaceUserProvider() { public ClearspaceUserProvider() {
// Gets the manager
manager = ClearspaceManager.getInstance();
} }
/** /**
...@@ -117,7 +113,7 @@ public class ClearspaceUserProvider implements UserProvider { ...@@ -117,7 +113,7 @@ public class ClearspaceUserProvider implements UserProvider {
enabledE.addText("true"); enabledE.addText("true");
Element user = manager.executeRequest(POST, path, groupDoc.asXML()); Element user = ClearspaceManager.getInstance().executeRequest(POST, path, groupDoc.asXML());
return translate(user); return translate(user);
} catch (UserAlreadyExistsException uaee) { } catch (UserAlreadyExistsException uaee) {
...@@ -139,9 +135,9 @@ public class ClearspaceUserProvider implements UserProvider { ...@@ -139,9 +135,9 @@ public class ClearspaceUserProvider implements UserProvider {
} }
try { try {
long userID = manager.getUserID(username); long userID = ClearspaceManager.getInstance().getUserID(username);
String path = USER_URL_PREFIX + "users/" + userID; String path = USER_URL_PREFIX + "users/" + userID;
manager.executeRequest(DELETE, path); ClearspaceManager.getInstance().executeRequest(DELETE, path);
} catch (UserNotFoundException gnfe) { } catch (UserNotFoundException gnfe) {
// it is OK, the user doesn't exist "anymore" // it is OK, the user doesn't exist "anymore"
...@@ -159,7 +155,7 @@ public class ClearspaceUserProvider implements UserProvider { ...@@ -159,7 +155,7 @@ public class ClearspaceUserProvider implements UserProvider {
public int getUserCount() { public int getUserCount() {
try { try {
String path = USER_URL_PREFIX + "users/count"; String path = USER_URL_PREFIX + "users/count";
Element element = manager.executeRequest(GET, path); Element element = ClearspaceManager.getInstance().executeRequest(GET, path);
int count = Integer.valueOf(getReturn(element)); int count = Integer.valueOf(getReturn(element));
return count; return count;
} catch (Exception e) { } catch (Exception e) {
...@@ -186,7 +182,7 @@ public class ClearspaceUserProvider implements UserProvider { ...@@ -186,7 +182,7 @@ public class ClearspaceUserProvider implements UserProvider {
public Collection<String> getUsernames() { public Collection<String> getUsernames() {
try { try {
String path = USER_URL_PREFIX + "userNames"; String path = USER_URL_PREFIX + "userNames";
Element element = manager.executeRequest(GET, path); Element element = ClearspaceManager.getInstance().executeRequest(GET, path);
return parseStringArray(element); return parseStringArray(element);
} catch (Exception e) { } catch (Exception e) {
...@@ -345,7 +341,7 @@ public class ClearspaceUserProvider implements UserProvider { ...@@ -345,7 +341,7 @@ public class ClearspaceUserProvider implements UserProvider {
protected void updateUser(Element userUpdateParams) throws UserNotFoundException { protected void updateUser(Element userUpdateParams) throws UserNotFoundException {
try { try {
String path = USER_URL_PREFIX + "users"; String path = USER_URL_PREFIX + "users";
manager.executeRequest(PUT, path, userUpdateParams.asXML()); ClearspaceManager.getInstance().executeRequest(PUT, path, userUpdateParams.asXML());
} catch (UserNotFoundException e) { } catch (UserNotFoundException e) {
throw new UserNotFoundException("User not found."); throw new UserNotFoundException("User not found.");
...@@ -392,7 +388,7 @@ public class ClearspaceUserProvider implements UserProvider { ...@@ -392,7 +388,7 @@ public class ClearspaceUserProvider implements UserProvider {
//TODO create a service on CS to get only the username field //TODO create a service on CS to get only the username field
String path = SEARCH_URL_PREFIX + "searchProfile"; String path = SEARCH_URL_PREFIX + "searchProfile";
Element element = manager.executeRequest(POST, path, paramsE.asXML()); Element element = ClearspaceManager.getInstance().executeRequest(POST, path, paramsE.asXML());
List<Node> userNodes = (List<Node>) element.selectNodes("return"); List<Node> userNodes = (List<Node>) element.selectNodes("return");
for (Node userNode : userNodes) { for (Node userNode : userNodes) {
...@@ -439,7 +435,7 @@ public class ClearspaceUserProvider implements UserProvider { ...@@ -439,7 +435,7 @@ public class ClearspaceUserProvider implements UserProvider {
//TODO create a service on CS to get only the username field //TODO create a service on CS to get only the username field
String path = SEARCH_URL_PREFIX + "searchProfile"; String path = SEARCH_URL_PREFIX + "searchProfile";
Element element = manager.executeRequest(POST, path, paramsE.asXML()); Element element = ClearspaceManager.getInstance().executeRequest(POST, path, paramsE.asXML());
List<Node> userNodes = (List<Node>) element.selectNodes("return"); List<Node> userNodes = (List<Node>) element.selectNodes("return");
for (Node userNode : userNodes) { for (Node userNode : userNodes) {
...@@ -496,7 +492,7 @@ public class ClearspaceUserProvider implements UserProvider { ...@@ -496,7 +492,7 @@ public class ClearspaceUserProvider implements UserProvider {
try { try {
// See if the is read only // See if the is read only
String path = USER_URL_PREFIX + "isReadOnly"; String path = USER_URL_PREFIX + "isReadOnly";
Element element = manager.executeRequest(GET, path); Element element = ClearspaceManager.getInstance().executeRequest(GET, path);
readOnly = Boolean.valueOf(getReturn(element)); readOnly = Boolean.valueOf(getReturn(element));
} catch (Exception e) { } catch (Exception e) {
// if there is a problem, keep it null, maybe in the next call success. // if there is a problem, keep it null, maybe in the next call success.
...@@ -571,7 +567,7 @@ public class ClearspaceUserProvider implements UserProvider { ...@@ -571,7 +567,7 @@ public class ClearspaceUserProvider implements UserProvider {
// Requests the user // Requests the user
String path = USER_URL_PREFIX + "users/" + username; String path = USER_URL_PREFIX + "users/" + username;
Element response = manager.executeRequest(GET, path); Element response = ClearspaceManager.getInstance().executeRequest(GET, path);
// return the response // return the response
return response; return response;
......
...@@ -41,12 +41,10 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -41,12 +41,10 @@ public class ClearspaceVCardProvider implements VCardProvider {
protected static final String PROFILE_FIELDS_URL_PREFIX = "profileFieldService/"; protected static final String PROFILE_FIELDS_URL_PREFIX = "profileFieldService/";
protected static final String AVATAR_URL_PREFIX = "avatarService/"; protected static final String AVATAR_URL_PREFIX = "avatarService/";
private ClearspaceManager manager;
private Boolean avatarReadOnly; private Boolean avatarReadOnly;
private boolean fieldsIDLoaded; private boolean fieldsIDLoaded;
public ClearspaceVCardProvider() { public ClearspaceVCardProvider() {
this.manager = ClearspaceManager.getInstance();
} }
/** /**
...@@ -77,7 +75,7 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -77,7 +75,7 @@ public class ClearspaceVCardProvider implements VCardProvider {
// Gets the user // Gets the user
User user = UserManager.getInstance().getUser(username); User user = UserManager.getInstance().getUser(username);
long userID = manager.getUserID(username); long userID = ClearspaceManager.getInstance().getUserID(username);
// Gets the profiles information // Gets the profiles information
Element profiles = getProfiles(userID); Element profiles = getProfiles(userID);
...@@ -187,7 +185,7 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -187,7 +185,7 @@ public class ClearspaceVCardProvider implements VCardProvider {
try { try {
long userID = manager.getUserID(username); long userID = ClearspaceManager.getInstance().getUserID(username);
ClearspaceUserProvider userProvider = (ClearspaceUserProvider) UserManager.getUserProvider(); ClearspaceUserProvider userProvider = (ClearspaceUserProvider) UserManager.getUserProvider();
// Gets the user params that can be used to update it // Gets the user params that can be used to update it
...@@ -255,7 +253,7 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -255,7 +253,7 @@ public class ClearspaceVCardProvider implements VCardProvider {
long userID; long userID;
try { try {
userID = manager.getUserID(username); userID = ClearspaceManager.getInstance().getUserID(username);
} catch (UserNotFoundException gnfe) { } catch (UserNotFoundException gnfe) {
// it is OK, the user doesn't exist "anymore" // it is OK, the user doesn't exist "anymore"
return; return;
...@@ -274,7 +272,7 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -274,7 +272,7 @@ public class ClearspaceVCardProvider implements VCardProvider {
private void deleteProfiles(long userID) { private void deleteProfiles(long userID) {
try { try {
String path = PROFILE_URL_PREFIX + "profiles/" + userID; String path = PROFILE_URL_PREFIX + "profiles/" + userID;
manager.executeRequest(ClearspaceManager.HttpType.DELETE, path); ClearspaceManager.getInstance().executeRequest(ClearspaceManager.HttpType.DELETE, path);
} catch (Exception e) { } catch (Exception e) {
// It is not supported exception, wrap it into an UnsupportedOperationException // It is not supported exception, wrap it into an UnsupportedOperationException
throw new UnsupportedOperationException("Unexpected error", e); throw new UnsupportedOperationException("Unexpected error", e);
...@@ -289,7 +287,7 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -289,7 +287,7 @@ public class ClearspaceVCardProvider implements VCardProvider {
private void deleteAvatar(long userID) { private void deleteAvatar(long userID) {
try { try {
String path = AVATAR_URL_PREFIX + "avatar/" + userID; String path = AVATAR_URL_PREFIX + "avatar/" + userID;
manager.executeRequest(ClearspaceManager.HttpType.DELETE, path); ClearspaceManager.getInstance().executeRequest(ClearspaceManager.HttpType.DELETE, path);
} catch (Exception e) { } catch (Exception e) {
// It is not supported exception, wrap it into an UnsupportedOperationException // It is not supported exception, wrap it into an UnsupportedOperationException
throw new UnsupportedOperationException("Unexpected error", e); throw new UnsupportedOperationException("Unexpected error", e);
...@@ -305,7 +303,7 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -305,7 +303,7 @@ public class ClearspaceVCardProvider implements VCardProvider {
// Try to save the profile changes // Try to save the profile changes
try { try {
String path = PROFILE_URL_PREFIX + "profiles"; String path = PROFILE_URL_PREFIX + "profiles";
manager.executeRequest(POST, path, profilesUpdateParams.asXML()); ClearspaceManager.getInstance().executeRequest(POST, path, profilesUpdateParams.asXML());
} catch (Exception e) { } catch (Exception e) {
// It is not supported exception, wrap it into an UnsupportedOperationException // It is not supported exception, wrap it into an UnsupportedOperationException
throw new UnsupportedOperationException("Unexpected error", e); throw new UnsupportedOperationException("Unexpected error", e);
...@@ -328,7 +326,7 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -328,7 +326,7 @@ public class ClearspaceVCardProvider implements VCardProvider {
// Requests the user active avatar // Requests the user active avatar
String path = AVATAR_URL_PREFIX + "activeAvatar/" + userID; String path = AVATAR_URL_PREFIX + "activeAvatar/" + userID;
manager.executeRequest(POST, path, rootE.asXML()); ClearspaceManager.getInstance().executeRequest(POST, path, rootE.asXML());
} catch (Exception e) { } catch (Exception e) {
throw new UnsupportedOperationException("Error setting the user's " + userID + " active avatar " + avatarID, e); throw new UnsupportedOperationException("Error setting the user's " + userID + " active avatar " + avatarID, e);
} }
...@@ -345,7 +343,7 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -345,7 +343,7 @@ public class ClearspaceVCardProvider implements VCardProvider {
// Requests the user active avatar // Requests the user active avatar
String path = AVATAR_URL_PREFIX + "createAvatar"; String path = AVATAR_URL_PREFIX + "createAvatar";
Element avatar = manager.executeRequest(POST, path, avatarCreateParams.asXML()); Element avatar = ClearspaceManager.getInstance().executeRequest(POST, path, avatarCreateParams.asXML());
return Long.valueOf(avatar.element("return").element("WSAvatar").elementTextTrim("id")); return Long.valueOf(avatar.element("return").element("WSAvatar").elementTextTrim("id"));
} catch (Exception e) { } catch (Exception e) {
...@@ -363,7 +361,7 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -363,7 +361,7 @@ public class ClearspaceVCardProvider implements VCardProvider {
try { try {
// Requests the user profile // Requests the user profile
String path = PROFILE_URL_PREFIX + "profiles/" + userID; String path = PROFILE_URL_PREFIX + "profiles/" + userID;
return manager.executeRequest(GET, path); return ClearspaceManager.getInstance().executeRequest(GET, path);
} catch (Exception e) { } catch (Exception e) {
throw new UnsupportedOperationException("Error getting the profiles of user: " + userID, e); throw new UnsupportedOperationException("Error getting the profiles of user: " + userID, e);
} }
...@@ -379,7 +377,7 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -379,7 +377,7 @@ public class ClearspaceVCardProvider implements VCardProvider {
try { try {
// Requests the user active avatar // Requests the user active avatar
String path = AVATAR_URL_PREFIX + "activeAvatar/" + userID; String path = AVATAR_URL_PREFIX + "activeAvatar/" + userID;
return manager.executeRequest(GET, path); return ClearspaceManager.getInstance().executeRequest(GET, path);
} catch (Exception e) { } catch (Exception e) {
throw new UnsupportedOperationException("Error getting the avatar of user: " + userID, e); throw new UnsupportedOperationException("Error getting the avatar of user: " + userID, e);
} }
...@@ -392,7 +390,7 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -392,7 +390,7 @@ public class ClearspaceVCardProvider implements VCardProvider {
try { try {
// See if the is read only // See if the is read only
String path = AVATAR_URL_PREFIX + "userAvatarsEnabled"; String path = AVATAR_URL_PREFIX + "userAvatarsEnabled";
Element element = manager.executeRequest(GET, path); Element element = ClearspaceManager.getInstance().executeRequest(GET, path);
avatarReadOnly = !Boolean.valueOf(getReturn(element)); avatarReadOnly = !Boolean.valueOf(getReturn(element));
} catch (Exception e) { } catch (Exception e) {
// if there is a problem, keep it null, maybe next call success. // if there is a problem, keep it null, maybe next call success.
...@@ -406,7 +404,7 @@ public class ClearspaceVCardProvider implements VCardProvider { ...@@ -406,7 +404,7 @@ public class ClearspaceVCardProvider implements VCardProvider {
private void loadDefaultProfileFields() { private void loadDefaultProfileFields() {
try { try {
String path = PROFILE_FIELDS_URL_PREFIX + "fields"; String path = PROFILE_FIELDS_URL_PREFIX + "fields";
Element defaultFields = manager.executeRequest(GET, path); Element defaultFields = ClearspaceManager.getInstance().executeRequest(GET, path);
ClearspaceVCardTranslator.getInstance().initClearspaceFieldsId(defaultFields); ClearspaceVCardTranslator.getInstance().initClearspaceFieldsId(defaultFields);
fieldsIDLoaded = true; fieldsIDLoaded = true;
......
...@@ -69,7 +69,12 @@ public class WSUtils { ...@@ -69,7 +69,12 @@ public class WSUtils {
protected static void modifyElementText(Element element, String[] path, String newValue) { protected static void modifyElementText(Element element, String[] path, String newValue) {
Element e = element; Element e = element;
for (String s : path) { for (String s : path) {
e = e.element(s); Element subElement = e.element(s);
if (subElement == null) {
// Add the element if associated string was not in path.
subElement = e.addElement(s);
}
e = subElement;
} }
e.setText(newValue); e.setText(newValue);
} }
......
...@@ -376,11 +376,11 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -376,11 +376,11 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
} }
else { else {
// Create the new account // Create the new account
newUser = userManager.createUser(username, password, null, email); newUser = userManager.createUser(username, password, name, email);
} }
} }
// Set and save the extra user info (e.g. full name, etc.) // Set and save the extra user info (e.g. full name, etc.)
if (newUser != null && name != null) { if (newUser != null && name != null && !name.equals(newUser.getName())) {
newUser.setName(name); newUser.setName(name);
} }
......
package org.jivesoftware.openfire.muc; package org.jivesoftware.openfire.muc;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.jivesoftware.openfire.muc.spi.LocalMUCRoom;
import java.util.Map; import java.util.Map;
...@@ -20,13 +21,18 @@ public abstract class MUCEventDelegate { ...@@ -20,13 +21,18 @@ public abstract class MUCEventDelegate {
* *
* Returns true if the user is allowed to join the room. * Returns true if the user is allowed to join the room.
* *
* @param roomName the name of the MUC room. * @param room the MUC room.
* @param userjid the JID of the user attempting to join the room. * @param userjid the JID of the user attempting to join the room.
* @return true if the user is allowed to join the room. * @return true if the user is allowed to join the room.
*/ */
public abstract boolean joiningRoom(String roomName, JID userjid); public abstract boolean joiningRoom(MUCRoom room, JID userjid);
/**
* Returns a map containing room configuration variables and values.
*
* @param roomName the name of the room the configuration map is associated with.
* @returna map containing room configuration variables and values, or null if roomName was not valid.
*/
public abstract Map<String, String> getRoomConfig(String roomName); public abstract Map<String, String> getRoomConfig(String roomName);
/** /**
...@@ -40,28 +46,33 @@ public abstract class MUCEventDelegate { ...@@ -40,28 +46,33 @@ public abstract class MUCEventDelegate {
*/ */
public abstract boolean destroyingRoom(String roomName, JID userjid); public abstract boolean destroyingRoom(String roomName, JID userjid);
/**
* Loads a delegate provided room configuration for the room specified.
*
* @param room the room to load the configuration for.
* @return true if the room configuration was received from the delegate and applied to the room.
*/
public boolean loadConfig(MUCRoom room) { public boolean loadConfig(MUCRoom room) {
Map<String, String> roomConfig = getRoomConfig(room.getName()); Map<String, String> roomConfig = getRoomConfig(room.getName());
if (roomConfig != null) { if (roomConfig != null) {
room.setNaturalLanguageName(roomConfig.get("muc#roomconfig_roomname")); room.setNaturalLanguageName(roomConfig.get("muc#roomconfig_roomname"));
room.setDescription(roomConfig.get("muc#roomconfig_roomdesc")); room.setDescription(roomConfig.get("muc#roomconfig_roomdesc"));
room.setCanOccupantsChangeSubject("1".equals(roomConfig.get("muc#roomconfig_changesubject"))); room.setCanOccupantsChangeSubject("1".equals(roomConfig.get("muc#roomconfig_changesubject")));
room.setMaxUsers(Integer.parseInt(roomConfig.get("muc#roomconfig_maxusers"))); room.setMaxUsers(Integer.parseInt(roomConfig.get("muc#roomconfig_maxusers")));
room.setPublicRoom("1".equals(roomConfig.get("muc#roomconfig_publicroom"))); room.setPublicRoom("1".equals(roomConfig.get("muc#roomconfig_publicroom")));
room.setModerated("1".equals(roomConfig.get("muc#roomconfig_moderatedroom")));
room.setMembersOnly("1".equals(roomConfig.get("muc#roomconfig_membersonly")));
room.setCanOccupantsInvite("1".equals(roomConfig.get("muc#roomconfig_allowinvites"))); room.setCanOccupantsInvite("1".equals(roomConfig.get("muc#roomconfig_allowinvites")));
room.setPassword(roomConfig.get("muc#roomconfig_roomsecret"));
room.setCanAnyoneDiscoverJID("anyone".equals(roomConfig.get("muc#roomconfig_whois"))); room.setCanAnyoneDiscoverJID("anyone".equals(roomConfig.get("muc#roomconfig_whois")));
room.setLogEnabled("1".equals(roomConfig.get("muc#roomconfig_enablelogging")));
room.setLoginRestrictedToNickname("1".equals(roomConfig.get("x-muc#roomconfig_reservednick")));
room.setChangeNickname("1".equals(roomConfig.get("x-muc#roomconfig_canchangenick"))); room.setChangeNickname("1".equals(roomConfig.get("x-muc#roomconfig_canchangenick")));
room.setRegistrationEnabled("1".equals(roomConfig.get("x-muc#roomconfig_registration"))); room.setRegistrationEnabled("1".equals(roomConfig.get("x-muc#roomconfig_registration")));
room.setPersistent("1".equals(roomConfig.get("muc#roomconfig_persistentroom"))); room.setPersistent("1".equals(roomConfig.get("muc#roomconfig_persistentroom")));
room.addFirstOwner(roomConfig.get("muc#roomconfig_roomowners")); room.addFirstOwner(roomConfig.get("muc#roomconfig_roomowners"));
try {
room.unlock(room.getRole());
} catch (ForbiddenException e) {
return false;
}
} }
return roomConfig != null; return roomConfig != null;
} }
......
...@@ -454,7 +454,7 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -454,7 +454,7 @@ public class LocalMUCRoom implements MUCRoom {
RegistrationRequiredException, ConflictException, ServiceUnavailableException, RegistrationRequiredException, ConflictException, ServiceUnavailableException,
NotAcceptableException { NotAcceptableException {
if (((MultiUserChatServiceImpl)mucService).getMUCDelegate() != null) { if (((MultiUserChatServiceImpl)mucService).getMUCDelegate() != null) {
if (!((MultiUserChatServiceImpl)mucService).getMUCDelegate().joiningRoom(this.getName(), user.getAddress())) { if (!((MultiUserChatServiceImpl)mucService).getMUCDelegate().joiningRoom(this, user.getAddress())) {
// Delegate said no, reject join. // Delegate said no, reject join.
throw new UnauthorizedException(); throw new UnauthorizedException();
} }
......
...@@ -14,7 +14,14 @@ ...@@ -14,7 +14,14 @@
boolean save = request.getParameter("save") != null; boolean save = request.getParameter("save") != null;
boolean test = request.getParameter("test") != null; boolean test = request.getParameter("test") != null;
ClearspaceManager manager = ClearspaceManager.getInstance(); ClearspaceManager manager = null;
if (ClearspaceManager.getInstance() != null) {
// Use the existing manager. This will be the case after setup was completed
manager = ClearspaceManager.getInstance();
}
else {
manager = new ClearspaceManager();
}
Map<String, String> errors = new HashMap<String, String>(); Map<String, String> errors = new HashMap<String, String>();
if (save || test) { if (save || test) {
......
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