Commit 7cfc4ad5 authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

broadcast plugin is now using IOC

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8598 b35dd754-fafc-0310-a699-88a17e54d16e
parent 9c833a72
......@@ -110,9 +110,7 @@ public class InternalComponentManager extends BasicModule implements ComponentMa
}
public void addComponent(String subdomain, Component component) throws ComponentException {
ComponentLifecycleImpl componentLifecycle
= (ComponentLifecycleImpl) addComponent(subdomain, component, null);
startComponent(componentLifecycle.subdomain, componentLifecycle.component);
addComponent(subdomain, component, null);
}
private void startComponent(String subdomain, Component component) {
......@@ -148,7 +146,8 @@ public class InternalComponentManager extends BasicModule implements ComponentMa
}
public ComponentLifecycle addComponent(String subdomain, Component component, String jiveProperty)
public ComponentLifecycle addComponent(String subdomain, Component component,
String jiveProperty)
throws ComponentException
{
ComponentLifecycleImpl componentLifecycle = new ComponentLifecycleImpl(subdomain, component);
......@@ -170,6 +169,7 @@ public class InternalComponentManager extends BasicModule implements ComponentMa
throw e;
}
componentLifecycle.setJiveProperty(jiveProperty);
return componentLifecycle;
}
......
/**
* $Revision:$
* $Date:$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.openfire.container;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import java.io.File;
import org.xmpp.component.ComponentManager;
/**
*
*/
public abstract class AbstractPlugin implements Plugin {
protected ComponentManager componentManager;
@Inject
public void setComponentManager(ComponentManager componentManager) {
this.componentManager = componentManager;
}
public void initializePlugin(PluginManager manager, File pluginDirectory) {
initializePlugin();
}
public abstract void initializePlugin();
public void destroyPlugin() {
}
}
......@@ -18,6 +18,10 @@ import org.dom4j.io.SAXReader;
import org.jivesoftware.admin.AdminConsole;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.container.plugin.AbstractPlugin;
import org.jivesoftware.openfire.container.plugin.PluginName;
import org.jivesoftware.openfire.container.plugin.PluginDescription;
import org.jivesoftware.openfire.container.plugin.PluginDir;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.Version;
......@@ -33,6 +37,7 @@ import java.util.zip.ZipFile;
import com.google.inject.Guice;
import com.google.inject.AbstractModule;
import com.google.inject.Provider;
/**
* Loads and manages plugins. The <tt>plugins</tt> directory is monitored for any
......@@ -398,7 +403,8 @@ public class PluginManager {
moduleClazz = null;
}
//noinspection unchecked
plugin = instantiateAbstractPlugin(pluginLoader, pluginClazz, moduleClazz);
plugin = instantiateAbstractPlugin(pluginDir, pluginLoader, pluginClazz,
moduleClazz);
}
else {
plugin = (Plugin) pluginClazz.newInstance();
......@@ -526,7 +532,7 @@ public class PluginManager {
}
}
private Plugin instantiateAbstractPlugin(PluginClassLoader pluginLoader,
private Plugin instantiateAbstractPlugin(final File pluginDir, PluginClassLoader pluginLoader,
final Class<? extends AbstractPlugin> pluginClazz,
Class<? extends com.google.inject.Module> moduleClazz)
throws IllegalAccessException, InstantiationException
......@@ -549,6 +555,28 @@ public class PluginManager {
if (pluginModule != null) {
install(pluginModule);
}
bind(String.class).annotatedWith(PluginName.class).toProvider(
new Provider<String>() {
public String get() {
return getName(pluginDir);
}
}
);
bind(String.class).annotatedWith(PluginDescription.class).toProvider(
new Provider<String>() {
public String get() {
return getDescription(pluginDir);
}
}
);
bind(File.class).annotatedWith(PluginDir.class).toProvider(
new Provider<File>() {
public File get() {
return pluginDir;
}
}
);
bind(pluginClazz);
}
}).getInstance(pluginClazz);
......@@ -679,8 +707,12 @@ public class PluginManager {
* @return the plugin's name.
*/
public String getName(Plugin plugin) {
String name = getElementValue(plugin, "/plugin/name");
String pluginName = pluginDirs.get(plugin).getName();
return getName(pluginDirs.get(plugin));
}
private String getName(File pluginDir) {
String name = getElementValue(pluginDir, "/plugin/name");
String pluginName = pluginDir.getName();
if (name != null) {
return AdminConsole.getAdminText(name, pluginName);
}
......@@ -697,8 +729,13 @@ public class PluginManager {
* @return the plugin's description.
*/
public String getDescription(Plugin plugin) {
String pluginName = pluginDirs.get(plugin).getName();
return AdminConsole.getAdminText(getElementValue(plugin, "/plugin/description"), pluginName);
return getDescription(pluginDirs.get(plugin));
}
private String getDescription(File pluginDir) {
String pluginName = pluginDir.getName();
return AdminConsole.getAdminText(getElementValue(pluginDirs.get(pluginDir),
"/plugin/description"), pluginName);
}
/**
......@@ -709,7 +746,7 @@ public class PluginManager {
* @return the plugin's author.
*/
public String getAuthor(Plugin plugin) {
return getElementValue(plugin, "/plugin/author");
return getElementValue(pluginDirs.get(plugin), "/plugin/author");
}
/**
......@@ -720,7 +757,7 @@ public class PluginManager {
* @return the plugin's version.
*/
public String getVersion(Plugin plugin) {
return getElementValue(plugin, "/plugin/version");
return getElementValue(pluginDirs.get(plugin), "/plugin/version");
}
/**
......@@ -731,7 +768,7 @@ public class PluginManager {
* @return the plugin's version.
*/
public String getMinServerVersion(Plugin plugin) {
return getElementValue(plugin, "/plugin/minServerVersion");
return getElementValue(pluginDirs.get(plugin), "/plugin/minServerVersion");
}
/**
......@@ -743,7 +780,7 @@ public class PluginManager {
* @return the plugin's database schema key or <tt>null</tt> if it doesn't exist.
*/
public String getDatabaseKey(Plugin plugin) {
return getElementValue(plugin, "/plugin/databaseKey");
return getElementValue(pluginDirs.get(plugin), "/plugin/databaseKey");
}
/**
......@@ -755,7 +792,7 @@ public class PluginManager {
* @return the plugin's database schema version or <tt>-1</tt> if it doesn't exist.
*/
public int getDatabaseVersion(Plugin plugin) {
String versionString = getElementValue(plugin, "/plugin/databaseVersion");
String versionString = getElementValue(pluginDirs.get(plugin), "/plugin/databaseVersion");
if (versionString != null) {
try {
return Integer.parseInt(versionString.trim());
......@@ -776,7 +813,7 @@ public class PluginManager {
* @return the plugin's license agreement.
*/
public License getLicense(Plugin plugin) {
String licenseString = getElementValue(plugin, "/plugin/licenseType");
String licenseString = getElementValue(pluginDirs.get(plugin), "/plugin/licenseType");
if (licenseString != null) {
try {
// Attempt to load the get the license type. We lower-case and
......@@ -806,12 +843,11 @@ public class PluginManager {
* Returns the value of an element selected via an xpath expression from
* a Plugin's plugin.xml file.
*
* @param plugin the plugin.
* @param pluginDir the plugin directory.
* @param xpath the xpath expression.
* @return the value of the element selected by the xpath expression.
*/
private String getElementValue(Plugin plugin, String xpath) {
File pluginDir = pluginDirs.get(plugin);
private String getElementValue(File pluginDir, String xpath) {
if (pluginDir == null) {
return null;
}
......
......@@ -9,6 +9,7 @@ package org.jivesoftware.openfire.container;
import com.google.inject.*;
import org.jivesoftware.openfire.*;
import org.jivesoftware.openfire.group.GroupManager;
import org.jivesoftware.openfire.session.RemoteSessionLocator;
import org.jivesoftware.openfire.vcard.VCardManager;
import org.jivesoftware.openfire.stun.STUNService;
......@@ -28,6 +29,8 @@ import org.jivesoftware.openfire.handler.PresenceUpdateHandler;
import org.jivesoftware.openfire.handler.PresenceSubscribeHandler;
import org.jivesoftware.openfire.roster.RosterManager;
import org.jivesoftware.util.JiveProperties;
import org.jivesoftware.util.Logger;
import org.jivesoftware.util.Log;
import org.xmpp.component.ComponentManager;
import org.xmpp.component.ComponentManagerFactory;
......@@ -38,6 +41,7 @@ public class PluginModule extends AbstractModule {
protected void configure() {
bind(JiveProperties.class).toInstance(JiveProperties.getInstance());
bind(Logger.class).toInstance(getLogger());
XMPPServer server = XMPPServer.getInstance();
bind(XMPPServer.class).toInstance(server);
......@@ -72,6 +76,7 @@ public class PluginModule extends AbstractModule {
bind(MediaProxyService.class).toInstance(server.getMediaProxyService());
bind(STUNService.class).toInstance(server.getSTUNService());
bind(VCardManager.class).toInstance(server.getVCardManager());
bind(GroupManager.class).toInstance(GroupManager.getInstance());
bind(RemoteSessionLocator.class).toProvider(new Provider<RemoteSessionLocator>() {
private XMPPServer xmppServer;
......@@ -91,4 +96,57 @@ public class PluginModule extends AbstractModule {
}
});
}
private Logger getLogger() {
return new Logger() {
public void error(String msg) {
Log.error(msg);
}
public void error(String msg, Throwable throwable) {
Log.error(msg, throwable);
}
public void error(Throwable throwable) {
Log.error(throwable);
}
public void warn(String msg) {
Log.warn(msg);
}
public void warn(String msg, Throwable throwable) {
Log.warn(msg, throwable);
}
public void warn(Throwable throwable) {
Log.warn(throwable);
}
public void info(String msg) {
Log.info(msg);
}
public void info(String msg, Throwable throwable) {
Log.info(msg, throwable);
}
public void info(Throwable throwable) {
Log.info(throwable);
}
public void debug(String msg) {
Log.debug(msg);
}
public void debug(String msg, Throwable throwable) {
Log.debug(msg, throwable);
}
public void debug(Throwable throwable) {
Log.debug(throwable);
}
};
}
}
/**
* $Revision:$
* $Date:$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.openfire.container.plugin;
import com.google.inject.Inject;
import java.io.File;
import java.util.concurrent.FutureTask;
import java.util.concurrent.Callable;
import java.util.Set;
import java.util.List;
import java.util.ArrayList;
import org.jivesoftware.util.Logger;
import org.jivesoftware.util.PropertyEventListener;
import org.jivesoftware.util.PropertyEventDispatcher;
import org.xmpp.component.ComponentManager;
import org.xmpp.component.Component;
import org.xmpp.component.ComponentException;
import org.jivesoftware.openfire.component.ComponentLifecycle;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
/**
*
*/
public abstract class AbstractPlugin implements Plugin {
private final List<FutureTask> destroyTasks = new ArrayList<FutureTask>();
protected ComponentManager componentManager;
protected Logger log;
@Inject
public void setComponentManager(ComponentManager componentManager) {
this.componentManager = componentManager;
}
@Inject
public void setLog(Logger log) {
this.log = log;
}
protected ComponentLifecycle addComponent(String domain, Component component)
throws ComponentException
{
return addComponent(domain, component, null);
}
protected ComponentLifecycle addComponent(final String domain, Component component,
String jiveProperty) throws ComponentException
{
ComponentLifecycle componentLifecycle
= componentManager.addComponent(domain, component, jiveProperty);
destroyTasks.add(new FutureTask<Boolean>(new Callable<Boolean>() {
public Boolean call() throws Exception {
componentManager.removeComponent(domain);
return true;
}
}));
return componentLifecycle;
}
protected void addPropertyEventListener(final PropertyEventListener listener) {
PropertyEventDispatcher.addListener(listener);
destroyTasks.add(new FutureTask<Boolean>(new Runnable() {
public void run() {
PropertyEventDispatcher.removeListener(listener);
}
}, Boolean.TRUE));
}
public final void initializePlugin(PluginManager manager, File pluginDirectory) {
initialize();
}
public abstract void initialize();
public final void destroyPlugin() {
destroy();
for(FutureTask destroyTask : destroyTasks) {
try {
destroyTask.run();
}
catch(Exception ex) {
log.error("Error unloading plugin", ex);
}
}
}
public void destroy() {
}
}
/**
* $Revision:$
* $Date:$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.openfire.container.plugin;
import com.google.inject.BindingAnnotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
/**
* Binding for a plugin description.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER})
@BindingAnnotation
public @interface PluginDescription {
}
/**
* $Revision:$
* $Date:$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.openfire.container.plugin;
import com.google.inject.BindingAnnotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
/**
* Binding for a plugin directory.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER})
@BindingAnnotation
public @interface PluginDir {
}
/**
* $Revision:$
* $Date:$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.openfire.container.plugin;
import com.google.inject.BindingAnnotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
/**
* Binding for a plugin name.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER})
@BindingAnnotation
public @interface PluginName {
}
......@@ -203,6 +203,30 @@ public class JiveProperties implements Map<String, String> {
return result;
}
public String getProperty(String name, String defaultValue) {
String value = properties.get(name);
if (value != null) {
return value;
}
else {
return defaultValue;
}
}
public boolean getBooleanProperty(String name) {
return Boolean.valueOf(get(name));
}
public boolean getBooleanProperty(String name, boolean defaultValue) {
String value = get(name);
if (value != null) {
return Boolean.valueOf(value);
}
else {
return defaultValue;
}
}
private void insertProperty(String name, String value) {
Connection con = null;
PreparedStatement pstmt = null;
......
/**
* Copyright (C) 2004-2007 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.util;
/**
* A simple logging service for components. Four log levels are provided:<ul>
*
* <li>Error -- an error occured in the component.
* <li>Warn -- a condition occured that an administrator should be warned about.
* <li>Info -- used to send information messages, such as a version or license notice.
* <li>Debug -- used to send debugging information. Most Log implementations will
* disable debug output by default.
* </ul>
*
* Log implementations will attempt use the native logging service of the component host
* server. However, this may not be possible in some cases -- for example, when using an
* external component that is not currently connected to the server.
*
* @author Matt Tucker
*/
public interface Logger {
/**
* Logs an error.
*
* @param message the error message.
*/
public void error(String message);
/**
* Logs an error.
*
* @param message the error message.
* @param throwable the Throwable that caused the error.
*/
public void error(String message, Throwable throwable);
/**
* Logs an error.
*
* @param throwable the Throwable that caused the error.
*/
public void error(Throwable throwable);
/**
* Logs a warning.
*
* @param message the warning message.
*/
public void warn(String message);
/**
* Logs a warning.
*
* @param message the warning message.
* @param throwable the Throwable that caused the error.
*/
public void warn(String message, Throwable throwable);
/**
* Logs a warning.
*
* @param throwable the Throwable that caused the error.
*/
public void warn(Throwable throwable);
/**
* Logs an info message.
*
* @param message the info message.
*/
public void info(String message);
/**
* Logs an info message.
*
* @param message the info message.
* @param throwable the Throwable that caused the info message.
*/
public void info(String message, Throwable throwable);
/**
* Logs an info message.
*
* @param throwable the Throwable that caused the info message.
*/
public void info(Throwable throwable);
/**
* Logs a debug message.
*
* @param message the debug message.
*/
public void debug(String message);
/**
* Logs a debug message.
*
* @param message the debug message.
* @param throwable the Throwable that caused the debug message.
*/
public void debug(String message, Throwable throwable);
/**
* Logs a debug message.
*
* @param throwable the Throwable the caused the debug message.
*/
public void debug(Throwable throwable);
}
\ No newline at end of file
......@@ -14,23 +14,26 @@ package org.jivesoftware.openfire.plugin;
import org.dom4j.Element;
import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.container.plugin.AbstractPlugin;
import org.jivesoftware.openfire.container.plugin.PluginName;
import org.jivesoftware.openfire.container.plugin.PluginDescription;
import org.jivesoftware.openfire.group.Group;
import org.jivesoftware.openfire.group.GroupManager;
import org.jivesoftware.openfire.group.GroupNotFoundException;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.PropertyEventDispatcher;
import org.jivesoftware.util.PropertyEventListener;
import org.jivesoftware.util.JiveProperties;
import org.xmpp.component.Component;
import org.xmpp.component.ComponentException;
import org.xmpp.component.ComponentManager;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.packet.*;
import java.io.File;
import java.util.*;
import com.google.inject.Inject;
/**
* Broadcast service plugin. It accepts messages and broadcasts them out to
* groups of connected users. The address <tt>all@[serviceName].[server]</tt> is
......@@ -40,61 +43,54 @@ import java.util.*;
*
* @author Matt Tucker
*/
public class BroadcastPlugin implements Plugin, Component, PropertyEventListener {
public class BroadcastPlugin extends AbstractPlugin implements Component, PropertyEventListener {
private String serviceName;
private SessionManager sessionManager;
private GroupManager groupManager;
private List<JID> allowedUsers;
private boolean groupMembersAllowed;
private boolean disableGroupPermissions;
private ComponentManager componentManager;
private PluginManager pluginManager;
private final String pluginName;
private final String pluginDescription;
private final JiveProperties jiveProperties;
private String serviceName;
/**
* Constructs a new broadcast plugin.
*
* @param pluginName the name configured for this plugin.
* @param pluginDescription the description configured for this plugin.
* @param jiveProperties system properties which stores the configuration paramters for the
* broadcast plugin.
*/
public BroadcastPlugin() {
serviceName = JiveGlobals.getProperty("plugin.broadcast.serviceName", "broadcast");
disableGroupPermissions = JiveGlobals.getBooleanProperty(
"plugin.broadcast.disableGroupPermissions");
groupMembersAllowed = JiveGlobals.getBooleanProperty(
"plugin.broadcast.groupMembersAllowed", true);
allowedUsers = stringToList(JiveGlobals.getProperty("plugin.broadcast.allowedUsers", ""));
@Inject
public BroadcastPlugin(@PluginName String pluginName,
@PluginDescription String pluginDescription,
JiveProperties jiveProperties)
{
this.pluginName = pluginName;
this.pluginDescription = pluginDescription;
this.jiveProperties = jiveProperties;
this.serviceName = jiveProperties.getProperty("plugin.broadcast.serviceName", "broadcast");
}
// Plugin Interface
public void initializePlugin(PluginManager manager, File pluginDirectory) {
pluginManager = manager;
sessionManager = SessionManager.getInstance();
groupManager = GroupManager.getInstance();
@Inject
public void setSessionManager(SessionManager sessionManager) {
this.sessionManager = sessionManager;
}
// Register as a component.
componentManager = ComponentManagerFactory.getComponentManager();
try {
componentManager.addComponent(serviceName, this);
}
catch (Exception e) {
componentManager.getLog().error(e);
}
PropertyEventDispatcher.addListener(this);
@Inject
public void setGroupManager(GroupManager groupManager) {
this.groupManager = groupManager;
}
public void destroyPlugin() {
PropertyEventDispatcher.removeListener(this);
// Unregister component.
public void initialize() {
// Register as a component.
try {
componentManager.removeComponent(serviceName);
addComponent(getServiceName(), this);
}
catch (Exception e) {
componentManager.getLog().error(e);
throw new RuntimeException("Error initializing internal broadcast component", e);
}
componentManager = null;
pluginManager = null;
sessionManager = null;
groupManager = null;
allowedUsers.clear();
addPropertyEventListener(this);
}
public void initialize(JID jid, ComponentManager componentManager) {
......@@ -107,15 +103,12 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
}
// Component Interface
public String getName() {
// Get the name from the plugin.xml file.
return pluginManager.getName(this);
return pluginName;
}
public String getDescription() {
// Get the description from the plugin.xml file.
return pluginManager.getDescription(this);
return pluginDescription;
}
public void processPacket(Packet packet) {
......@@ -124,6 +117,7 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
String toNode = packet.getTo().getNode();
// Check if user is allowed to send packet to this service[+group]
boolean targetAll = "all".equals(toNode);
Collection<JID> allowedUsers = getGlobalAllowedUsers();
if (targetAll) {
// See if the user is allowed to send the packet.
JID address = new JID(packet.getFrom().toBareJID());
......@@ -137,7 +131,7 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
group = groupManager.getGroup(toNode);
boolean isGroupUser = group.isUser(packet.getFrom()) ||
group.isUser(new JID(packet.getFrom().toBareJID()));
if (disableGroupPermissions || (groupMembersAllowed && isGroupUser) ||
if (isGroupPermissionsDisabled() || (isGroupMembersAllowed() && isGroupUser) ||
allowedUsers.contains(new JID(packet.getFrom().toBareJID()))) {
canProceed = true;
}
......@@ -344,6 +338,7 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
// Return the list of groups hosted by the service that can be used by the user
Collection<Group> groups;
JID address = new JID(iq.getFrom().toBareJID());
Collection<JID> allowedUsers = getGlobalAllowedUsers();
if (allowedUsers.contains(address)) {
groups = groupManager.getGroups();
}
......@@ -409,7 +404,7 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
* @return the users allowed to send broadcast messages.
*/
public Collection<JID> getGlobalAllowedUsers() {
return allowedUsers;
return stringToList(JiveGlobals.getProperty("plugin.broadcast.allowedUsers", ""));
}
/**
......@@ -437,7 +432,8 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
* @return true if group permission checking is disabled.
*/
public boolean isGroupPermissionsDisabled() {
return disableGroupPermissions;
return jiveProperties.getBooleanProperty(
"plugin.broadcast.disableGroupPermissions");
}
/**
......@@ -447,8 +443,7 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
* @param disableGroupPermissions true if group permission checking should be disabled.
*/
public void setGroupPermissionsDisabled(boolean disableGroupPermissions) {
this.disableGroupPermissions = disableGroupPermissions;
JiveGlobals.setProperty("plugin.broadcast.disableGroupPermissions",
jiveProperties.put("plugin.broadcast.disableGroupPermissions",
Boolean.toString(disableGroupPermissions));
}
......@@ -462,7 +457,8 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
* group admins are allowed.
*/
public boolean isGroupMembersAllowed() {
return groupMembersAllowed;
return jiveProperties.getBooleanProperty(
"plugin.broadcast.groupMembersAllowed", true);
}
/**
......@@ -475,38 +471,19 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
* group admins are allowed.
*/
public void setGroupMembersAllowed(boolean allowed) {
this.groupMembersAllowed = allowed;
JiveGlobals.setProperty("plugin.broadcast.groupMembersAllowed", Boolean.toString(allowed));
jiveProperties.put("plugin.broadcast.groupMembersAllowed", Boolean.toString(allowed));
}
// PropertyEventListener Methods
public void propertySet(String property, Map params) {
if (property.equals("plugin.broadcast.groupMembersAllowed")) {
this.groupMembersAllowed = Boolean.parseBoolean((String)params.get("value"));
}
else if (property.equals("plugin.broadcast.disableGroupPermissions")) {
this.disableGroupPermissions = Boolean.parseBoolean((String)params.get("value"));
}
else if (property.equals("plugin.broadcast.allowedUsers")) {
this.allowedUsers = stringToList((String)params.get("value"));
}
else if (property.equals("plugin.broadcast.serviceName")) {
if (property.equals("plugin.broadcast.serviceName")) {
changeServiceName((String)params.get("value"));
}
}
public void propertyDeleted(String property, Map params) {
if (property.equals("plugin.broadcast.groupMembersAllowed")) {
this.groupMembersAllowed = true;
}
else if (property.equals("plugin.broadcast.disableGroupPermissions")) {
this.disableGroupPermissions = false;
}
else if (property.equals("plugin.broadcast.allowedUsers")) {
this.allowedUsers = Collections.emptyList();
}
else if (property.equals("plugin.broadcast.serviceName")) {
if (property.equals("plugin.broadcast.serviceName")) {
changeServiceName("broadcast");
}
}
......
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