added the module configuration data and made use of it in the canInstall
method in the conferencing module
This commit is contained in:
parent
145509a886
commit
f8bba8b124
|
@ -51,6 +51,9 @@
|
|||
<object name="module-manager" classname="com.silverwrist.dynamo.module.ModuleManager" priority="2">
|
||||
<module-directory>${code.path}/modules</module-directory>
|
||||
<database connection="data" namespaces="nscache"/>
|
||||
<config-db>
|
||||
<item ns="http://www.silverwrist.com/NS/dynamo/2002/12/07/dynamo.objects" name="security">srm</item>
|
||||
</config-db>
|
||||
</object>
|
||||
|
||||
<!-- Data-driven objects -->
|
||||
|
|
|
@ -51,6 +51,9 @@
|
|||
<object name="module-manager" classname="com.silverwrist.dynamo.module.ModuleManager" priority="2">
|
||||
<module-directory>${code.path}/modules</module-directory>
|
||||
<database connection="data" namespaces="nscache"/>
|
||||
<config-db>
|
||||
<item ns="http://www.silverwrist.com/NS/dynamo/2002/12/07/dynamo.objects" name="security">srm</item>
|
||||
</config-db>
|
||||
</object>
|
||||
|
||||
<!-- Data-driven objects -->
|
||||
|
|
|
@ -19,9 +19,13 @@ package com.silverwrist.venice.conf.module;
|
|||
|
||||
import java.security.Principal;
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.Namespaces;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.module.ModuleConfigurationData;
|
||||
import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.community.CommunityServiceInstall;
|
||||
import com.silverwrist.venice.util.*;
|
||||
import com.silverwrist.venice.conf.ConfNamespaces;
|
||||
|
@ -120,8 +124,26 @@ public class ModuleMain implements ModuleFunctions, UseCount
|
|||
|
||||
public boolean canInstall(ServiceProvider services, Principal installer)
|
||||
{
|
||||
return true; // TEMP
|
||||
}
|
||||
try
|
||||
{ // get the module configuration data to get the SRM name, then use that to get the actual SRM, then get
|
||||
// the global ACL, then test permissions
|
||||
ModuleConfigurationData conf_data =
|
||||
(ModuleConfigurationData)(services.queryService(ModuleConfigurationData.class));
|
||||
String srm_name = conf_data.getValue(Namespaces.DYNAMO_OBJECT_NAMESPACE,"security");
|
||||
SecurityReferenceMonitor srm =
|
||||
(SecurityReferenceMonitor)(GetObjectUtils.getDynamoComponent(services,SecurityReferenceMonitor.class,
|
||||
srm_name));
|
||||
DynamoAcl gacl = srm.getGlobalAcl();
|
||||
return gacl.testPermission((DynamoUser)installer,VeniceNamespaces.SYSTEM_PERMS_NAMESPACE,"edit.menus");
|
||||
|
||||
} // end try
|
||||
catch (Exception e)
|
||||
{ // unable to test permission
|
||||
return false;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end canInstall
|
||||
|
||||
public void install(ModuleSite site, ServiceProvider services, Principal installer, DynamoLog log)
|
||||
throws ModuleException
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.dynamo.module;
|
||||
|
||||
import java.util.*;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
|
||||
class ConfigData implements ModuleConfigurationData
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private Hashtable m_store = new Hashtable();
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ConfigData(Element elt) throws ConfigException
|
||||
{
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
try
|
||||
{ // get a list of all <item/> sub-elements
|
||||
List l = loader.getMatchingSubElements(elt,"item");
|
||||
Iterator it = l.iterator();
|
||||
while (it.hasNext())
|
||||
{ // get each <item/> and decode it
|
||||
Element n = (Element)(it.next());
|
||||
String tmp = loader.getAttribute(n,"ns");
|
||||
Hashtable tab = (Hashtable)(m_store.get(tmp));
|
||||
if (tab==null)
|
||||
{ // create a Hashtable for this namespace
|
||||
tab = new Hashtable();
|
||||
m_store.put(tmp,tab);
|
||||
|
||||
} // end if
|
||||
|
||||
tmp = loader.getAttribute(n,"name");
|
||||
tab.put(tmp,loader.getText(n));
|
||||
|
||||
} // end while
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // translate XML loader exception
|
||||
throw new ConfigException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ModuleConfigurationData
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getValue(String namespace, String name)
|
||||
{
|
||||
Hashtable tab = (Hashtable)(m_store.get(namespace));
|
||||
if (tab==null)
|
||||
return null;
|
||||
return (String)(tab.get(name));
|
||||
|
||||
} // end getValue
|
||||
|
||||
} // end class ConfigData
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.dynamo.module;
|
||||
|
||||
public interface ModuleConfigurationData
|
||||
{
|
||||
public String getValue(String namespace, String name);
|
||||
|
||||
} // end interface ModuleConfigurationData
|
|
@ -154,6 +154,7 @@ public class ModuleManager implements NamedObject, ComponentInitialize, Componen
|
|||
{
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
String mod_dir = null, conn_name = null, nscache_name = null;
|
||||
ConfigData cfg_data = null;
|
||||
try
|
||||
{ // verify the right node name
|
||||
loader.verifyNodeName(config_root,"object");
|
||||
|
@ -170,6 +171,10 @@ public class ModuleManager implements NamedObject, ComponentInitialize, Componen
|
|||
conn_name = loader.getAttribute(elt,"connection");
|
||||
nscache_name = loader.getAttribute(elt,"namespaces");
|
||||
|
||||
// get the module configuration data
|
||||
elt = loader.getSubElement(config_root_h,"config-db");
|
||||
cfg_data = new ConfigData(elt);
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // error loading XML config data
|
||||
|
@ -201,6 +206,7 @@ public class ModuleManager implements NamedObject, ComponentInitialize, Componen
|
|||
|
||||
// Get the install service manager and set up the install service provider.
|
||||
m_instservice = new InstallServiceManager();
|
||||
m_instservice.addService(ModuleConfigurationData.class,(ModuleConfigurationData)cfg_data);
|
||||
m_install_services = m_instservice.getServiceProvider(m_appcon.getInitServices());
|
||||
|
||||
// Hook this into the service providers.
|
||||
|
|
Loading…
Reference in New Issue
Block a user