Commit a351f20e authored by Gabriel Guardincerri's avatar Gabriel Guardincerri Committed by gguardin

[CS-3691] Use Social Groups as the backend of the shared groups

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10222 b35dd754-fafc-0310-a699-88a17e54d16e
parent 914ead40
......@@ -902,6 +902,8 @@ group.edit.update_user=User(s) updated successfully.
group.edit.update_success=Group created successfully.
group.edit.not_update=User(s) not added successfully.
group.edit.share_title=Contact List (Roster) Sharing
group.edit.share_status_disabled=Contact list group sharing is disabled
group.edit.share_status_enabled=Contact list group sharing is enebled
group.edit.share_content=You can use the form below to automatically add this group to users' contact \
lists. <strong>By default</strong>, <em>this group will only appear in the contact lists of the \
group's members.</em>. However, you can share this group with all users or members of other groups.
......
......@@ -30,6 +30,7 @@ import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.openfire.group.GroupNotFoundException;
import org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl;
import org.jivesoftware.openfire.net.MXParser;
import org.jivesoftware.openfire.session.ComponentSession;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.*;
import org.jivesoftware.util.cache.Cache;
......@@ -105,6 +106,8 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
exceptionMap.put("com.jivesoftware.base.GroupNotFoundException", "org.jivesoftware.openfire.group.GroupNotFoundException");
exceptionMap.put("com.jivesoftware.base.GroupAlreadyExistsException", "org.jivesoftware.openfire.group.GroupAlreadyExistsException");
exceptionMap.put("org.acegisecurity.BadCredentialsException", "org.jivesoftware.openfire.auth.UnauthorizedException");
exceptionMap.put("com.jivesoftware.base.UnauthorizedException", "org.jivesoftware.openfire.auth.UnauthorizedException");
exceptionMap.put("com.jivesoftware.community.NotFoundException", "org.jivesoftware.util.NotFoundException");
}
private ConfigClearspaceTask configClearspaceTask;
......@@ -342,6 +345,37 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
return false;
}
/**
* Returns true if Openfire is connected to Clearspace.
* This method may delay some time since it has to ping Clearspace to know if
* Openfire is able to connect to it.
*
* @return true if Openfire is connected to Clearspace.
*/
public Boolean isOpenfireConnected() {
return testConnection();
}
/**
* Returns true if Clearspce is connected to Openfire.
*
* @return true if Clearspce is connected to Openfire.
*/
public Boolean isClearspaceConnected() {
XMPPServer server = XMPPServer.getInstance();
if (server == null) {
return false;
}
Collection<ComponentSession> componentSessions = server.getSessionManager().getComponentSessions();
for (ComponentSession cs : componentSessions) {
// All Clearspace sessions start with "clearspace"
if (cs.getAddress().getDomain().startsWith("clearspace")) {
return true;
}
}
return false;
}
/**
* Returns the Clearspace service URI; e.g. <tt>https://localhost:80/clearspace</tt>.
* This value is stored as the Jive Property <tt>clearspace.uri</tt>.
......@@ -545,6 +579,15 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
}
}
/**
* Returns true if Clerspace was configured at least one time since Openfire startup.
*
* @return true if Clerspace was configured at least one time since Openfire startup.
*/
public boolean isClearspaceConfigured() {
return configClearspaceTask == null;
}
private List<String> getServerInterfaces() {
List<String> bindInterfaces = new ArrayList<String>();
......
......@@ -81,7 +81,7 @@ public class GroupAdminAdded extends AdHocCommand {
// Sends the event
Group group;
try {
group = GroupManager.getInstance().getGroup(groupname);
group = GroupManager.getInstance().getGroup(groupname, true);
// Fire event.
GroupEventDispatcher.dispatchEvent(group, GroupEventDispatcher.EventType.admin_added, params);
......
......@@ -81,7 +81,7 @@ public class GroupAdminRemoved extends AdHocCommand {
// Sends the event
Group group;
try {
group = GroupManager.getInstance().getGroup(groupname);
group = GroupManager.getInstance().getGroup(groupname, true);
// Fire event.
GroupEventDispatcher.dispatchEvent(group, GroupEventDispatcher.EventType.admin_removed, params);
......
......@@ -63,7 +63,7 @@ public class GroupCreated extends AdHocCommand {
// Sends the event
Group group;
try {
group = GroupManager.getInstance().getGroup(groupname);
group = GroupManager.getInstance().getGroup(groupname, true);
// Fire event.
Map<String, Object> params = Collections.emptyMap();
......
......@@ -63,7 +63,7 @@ public class GroupDeleting extends AdHocCommand {
// Sends the event
Group group;
try {
group = GroupManager.getInstance().getGroup(groupname);
group = GroupManager.getInstance().getGroup(groupname, true);
// Fire event.
Map<String, Object> params = Collections.emptyMap();
......
......@@ -81,7 +81,7 @@ public class GroupMemberAdded extends AdHocCommand {
// Sends the event
Group group;
try {
group = GroupManager.getInstance().getGroup(groupname);
group = GroupManager.getInstance().getGroup(groupname, true);
// Fire event.
GroupEventDispatcher.dispatchEvent(group, GroupEventDispatcher.EventType.member_added, params);
......
......@@ -81,7 +81,7 @@ public class GroupMemberRemoved extends AdHocCommand {
// Sends the event
Group group;
try {
group = GroupManager.getInstance().getGroup(groupname);
group = GroupManager.getInstance().getGroup(groupname, true);
// Fire event.
GroupEventDispatcher.dispatchEvent(group, GroupEventDispatcher.EventType.member_removed, params);
......
......@@ -113,7 +113,7 @@ public class GroupModified extends AdHocCommand {
// Sends the event
Group group;
try {
group = GroupManager.getInstance().getGroup(groupname);
group = GroupManager.getInstance().getGroup(groupname, true);
// Fire event.
GroupEventDispatcher.dispatchEvent(group, GroupEventDispatcher.EventType.group_modified, params);
......
......@@ -448,6 +448,11 @@ public class Group implements Cacheable, Externalizable {
synchronized (keyString.intern()) {
if (properties.containsKey(keyString)) {
String originalValue = properties.get(keyString);
// if is the same value don't update it.
if (originalValue != null && originalValue.equals(value)) {
return value;
}
answer = properties.put(keyString, (String)value);
updateProperty(keyString, (String)value);
// Configure event.
......
......@@ -13,6 +13,7 @@
package org.jivesoftware.openfire.group;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.clearspace.ClearspaceManager;
import org.jivesoftware.openfire.event.GroupEventDispatcher;
import org.jivesoftware.openfire.event.GroupEventListener;
import org.jivesoftware.openfire.event.UserEventDispatcher;
......@@ -70,6 +71,15 @@ public class GroupManager {
GroupEventDispatcher.addListener(new GroupEventListener() {
public void groupCreated(Group group, Map params) {
// Adds default properties if they don't exists, since the creator of
// the group could set them.
if (group.getProperties().get("sharedRoster.showInRoster") == null) {
group.getProperties().put("sharedRoster.showInRoster", "nobody");
group.getProperties().put("sharedRoster.displayName", "");
group.getProperties().put("sharedRoster.groupList", "");
}
// Since the group could be created by the provider, add it possible again
groupCache.put(group.getName(), group);
......@@ -244,7 +254,21 @@ public class GroupManager {
* @throws GroupNotFoundException if the group does not exist.
*/
public Group getGroup(String name) throws GroupNotFoundException {
Group group = groupCache.get(name);
return getGroup(name, false);
}
/**
* Returns a Group by name.
*
* @param name The name of the group to retrieve
* @return The group corresponding to that name
* @throws GroupNotFoundException if the group does not exist.
*/
public Group getGroup(String name, boolean forceLookup) throws GroupNotFoundException {
Group group = null;
if (!forceLookup) {
group = groupCache.get(name);
}
// If ID wan't found in cache, load it up and put it there.
if (group == null) {
synchronized (name.intern()) {
......@@ -425,6 +449,16 @@ public class GroupManager {
return provider.isReadOnly();
}
/**
* Returns true if properties of groups are read only.
* They are read only if Clearspace is the group provider.
*
* @return true if properties of groups are read only.
*/
public boolean isPropertyReadOnly() {
return ClearspaceManager.isEnabled();
}
/**
* Returns true if searching for groups is supported.
*
......
......@@ -9,16 +9,16 @@
- agreement with Jive.
--%>
<%@ page import="org.jivesoftware.util.Log,
org.jivesoftware.util.ParamUtils,
org.jivesoftware.openfire.group.Group,
org.jivesoftware.openfire.group.GroupAlreadyExistsException"
<%@ page import="org.jivesoftware.openfire.group.Group,
org.jivesoftware.openfire.group.GroupAlreadyExistsException,
org.jivesoftware.openfire.security.SecurityAuditManager,
org.jivesoftware.util.Log"
errorPage="error.jsp"
%>
<%@ page import="org.jivesoftware.util.ParamUtils"%>
<%@ page import="java.net.URLEncoder"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Map"%>
<%@ page import="org.jivesoftware.openfire.security.SecurityAuditManager" %>
<%@ page import="java.util.Map" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
......@@ -61,10 +61,6 @@
newGroup.setDescription(description);
}
newGroup.getProperties().put("sharedRoster.showInRoster", "nobody");
newGroup.getProperties().put("sharedRoster.displayName", "");
newGroup.getProperties().put("sharedRoster.groupList", "");
if (!SecurityAuditManager.getSecurityAuditProvider().blockGroupEvents()) {
// Log the event
webManager.logEvent("created new group "+name, "description = "+description);
......@@ -161,6 +157,12 @@
</div><br>
<% } %>
<% if (webManager.getGroupManager().isReadOnly()) { %>
<div class="error">
<fmt:message key="group.read_only"/>
</div>
<% } %>
<p>
<%
// If editing the group.
......@@ -273,5 +275,19 @@
document.f.name.focus();
</script>
<% // Disable the form if a read-only user provider.
if (webManager.getGroupManager().isReadOnly()) { %>
<script language="Javascript" type="text/javascript">
function disable() {
var limit = document.forms[0].elements.length;
for (i=0;i<limit;i++) {
document.forms[0].elements[i].disabled = true;
}
}
disable();
</script>
<% } %>
</body>
</html>%>
\ No newline at end of file
......@@ -9,24 +9,24 @@
- agreement with Jive.
--%>
<%@ page import="org.jivesoftware.stringprep.Stringprep,
org.jivesoftware.util.LocaleUtils,
org.jivesoftware.util.Log,
org.jivesoftware.util.ParamUtils,
org.jivesoftware.openfire.PresenceManager,
<%@ page import="org.jivesoftware.openfire.PresenceManager,
org.jivesoftware.openfire.group.Group,
org.jivesoftware.openfire.group.GroupManager"
org.jivesoftware.openfire.group.GroupManager,
org.jivesoftware.openfire.security.SecurityAuditManager,
org.jivesoftware.openfire.user.User,
org.jivesoftware.openfire.user.UserManager,
org.jivesoftware.openfire.user.UserNotFoundException"
%>
<%@ page import="org.jivesoftware.openfire.user.User"%>
<%@ page import="org.jivesoftware.openfire.user.UserManager"%>
<%@ page import="org.jivesoftware.openfire.user.UserNotFoundException"%>
<%@ page import="org.jivesoftware.stringprep.Stringprep"%>
<%@ page import="org.jivesoftware.util.LocaleUtils"%>
<%@ page import="org.jivesoftware.util.Log"%>
<%@ page import="org.jivesoftware.util.ParamUtils"%>
<%@ page import="org.xmpp.packet.JID"%>
<%@ page import="org.xmpp.packet.Presence"%>
<%@ page import="java.io.UnsupportedEncodingException"%>
<%@ page import="java.net.URLDecoder"%>
<%@ page import="java.net.URLEncoder"%>
<%@ page import="java.util.*"%>
<%@ page import="org.jivesoftware.openfire.security.SecurityAuditManager" %>
<%@ page import="java.util.*" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
......@@ -255,6 +255,12 @@
</head>
<body>
<% if (webManager.getGroupManager().isReadOnly() && webManager.getGroupManager().isPropertyReadOnly()) { %>
<div class="error">
<fmt:message key="group.read_only"/>
</div>
<% } %>
<p>
<fmt:message key="group.edit.form_info" />
</p>
......@@ -339,6 +345,16 @@
</div>
<div class="jive-contentBox">
<% if (webManager.getGroupManager().isPropertyReadOnly()) { %>
<p>
<% if (enableRosterGroups) { %>
<fmt:message key="group.edit.share_status_enabled" />
<% } else { %>
<fmt:message key="group.edit.share_status_disabled" />
<% } %>
</p>
<% } else { %>
<p>
<fmt:message key="group.edit.share_content" />
</p>
......@@ -444,8 +460,7 @@
</tr>
</tbody>
</table>
<% } %>
</div>
<!-- END contact list settings -->
......
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