some more minor mods to the module manager, and implementation of the module
uninstallation page
This commit is contained in:
parent
0f0f4a4a4e
commit
c8b6a513b9
|
@ -1444,18 +1444,19 @@ INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link, perm_ns
|
|||
(8, 6, 'TEXT', 'Edit Password Reminder E-Mail Message', 'SERVLET', 'sysadmin/pwremind_email.js.vs', 12,
|
||||
'set.property');
|
||||
|
||||
# Create the sysadmin modules menu. (ID #9)
|
||||
INSERT INTO menus (menuid, menu_nsid, menu_name, title, subtitle)
|
||||
VALUES (9, 13, 'system.admin.module', 'Manage Modules', NULL);
|
||||
INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link, perm_nsid, perm_name) VALUES
|
||||
(9, 0, 'TEXT', 'Return to Previous Menu', 'SERVLET', 'sysadmin/main.js.vs', NULL,
|
||||
(9, 0, 'TEXT', 'Return to Previous Menu', 'SERVLET', 'sysadmin/main.js.vs', NULL,
|
||||
NULL ),
|
||||
(9, 1, 'TEXT', 'Install New Modules', 'SERVLET', 'sysadmin/module_install.js.vs', 13,
|
||||
(9, 1, 'TEXT', 'Install New Modules', 'SERVLET', 'sysadmin/module_install.js.vs', 13,
|
||||
'install.modules' ),
|
||||
(9, 2, 'TEXT', 'Uninstall Modules', 'SERVLET', 'sysadmin/TODO', 13,
|
||||
(9, 2, 'TEXT', 'Uninstall Modules', 'SERVLET', 'sysadmin/module_uninstall.js.vs', 13,
|
||||
'uninstall.modules'),
|
||||
(9, 100, 'MARKER', 'begin-module-sysadmin', NULL, NULL, NULL,
|
||||
(9, 100, 'MARKER', 'begin-module-sysadmin', NULL, NULL, NULL,
|
||||
NULL ),
|
||||
(9, 65000, 'MARKER', 'end-module-sysadmin', NULL, NULL, NULL,
|
||||
(9, 65000, 'MARKER', 'end-module-sysadmin', NULL, NULL, NULL,
|
||||
NULL );
|
||||
|
||||
# Create the sideboxes tables.
|
||||
|
|
|
@ -26,6 +26,8 @@ public interface Module
|
|||
{
|
||||
public QualifiedNameKey getModuleID();
|
||||
|
||||
public String getDescription();
|
||||
|
||||
public void install(Principal installer, DynamoLog log) throws DatabaseException, ModuleException;
|
||||
|
||||
public void uninstall(Principal uninstaller, DynamoLog log) throws DatabaseException, ModuleException;
|
||||
|
|
|
@ -25,6 +25,8 @@ public interface ModuleFunctions
|
|||
{
|
||||
public QualifiedNameKey getModuleID();
|
||||
|
||||
public String getDescription();
|
||||
|
||||
public void initialize(ModuleSite site, ServiceProvider services) throws ModuleException;
|
||||
|
||||
public void shutdown();
|
||||
|
|
|
@ -298,7 +298,7 @@ class IndexServiceImpl implements IndexService
|
|||
|
||||
private final List doQuery(Query query, int offset, int count) throws IndexException
|
||||
{
|
||||
SubsetCollector subc = new SubsetCollector(offset,count);
|
||||
SubsetCollector subc = new SubsetCollector(offset,count+1);
|
||||
List rc = null;
|
||||
IndexReader irdr = null;
|
||||
IndexSearcher srch = null;
|
||||
|
|
|
@ -284,6 +284,12 @@ class ModuleLoader extends URLClassLoader implements Module
|
|||
|
||||
} // end getModuleID
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return m_modfuncs.getDescription();
|
||||
|
||||
} // end getDescription
|
||||
|
||||
public synchronized void install(Principal installer, DynamoLog log) throws DatabaseException, ModuleException
|
||||
{
|
||||
if (m_ops.isModuleInstalled(m_filename))
|
||||
|
|
|
@ -261,16 +261,19 @@ public class ModuleManager implements NamedObject, ComponentInitialize, Componen
|
|||
QualifiedNameKey qname = new QualifiedNameKey(namespace,name);
|
||||
synchronized (this)
|
||||
{ // look up module in hash table
|
||||
ModuleLoader rc = (ModuleLoader)(m_qname_to_module.get(qname));
|
||||
if (rc!=null)
|
||||
return (Module)rc;
|
||||
return (Module)(m_qname_to_module.get(qname));
|
||||
|
||||
} // end synchronized block
|
||||
|
||||
return null;
|
||||
|
||||
} // end findModule
|
||||
|
||||
public synchronized Module findModuleByFilename(String filename)
|
||||
{
|
||||
// look for the right module already in the map
|
||||
return (Module)(m_jar_to_module.get(filename));
|
||||
|
||||
} // end findModuleByFilename
|
||||
|
||||
public Module loadModule(String name, boolean initialize) throws ModuleException
|
||||
{
|
||||
ModuleLoader rc = null;
|
||||
|
|
|
@ -29,6 +29,8 @@ public interface ModuleOperations
|
|||
{
|
||||
public Module findModule(String namespace, String name);
|
||||
|
||||
public Module findModuleByFilename(String filename);
|
||||
|
||||
public Module loadModule(String name, boolean initialize) throws ModuleException;
|
||||
|
||||
public void freeUnusedModules();
|
||||
|
|
|
@ -35,6 +35,8 @@ public class Main implements ModuleFunctions
|
|||
private static final QualifiedNameKey ID =
|
||||
new QualifiedNameKey("http://www.silverwrist.com/NS/dynamo/2003/05/18/testapp","testmodule");
|
||||
|
||||
private static final String DESCR = "Dynamo Test Module";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
|
@ -62,6 +64,12 @@ public class Main implements ModuleFunctions
|
|||
|
||||
} // end getModuleID
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return DESCR;
|
||||
|
||||
} // end getDescription
|
||||
|
||||
public void initialize(ModuleSite site, ServiceProvider services) throws ModuleException
|
||||
{
|
||||
m_site = site;
|
||||
|
|
|
@ -29,6 +29,12 @@ req = bsf.lookupBean("request");
|
|||
req_help = bsf.lookupBean("request_help");
|
||||
user = vlib.getUser(req);
|
||||
|
||||
// Make sure we are permitted to be here.
|
||||
srm = cast.querySecurityReferenceMonitor(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"srm"));
|
||||
acl = srm.getGlobalAcl();
|
||||
if (!(acl.testPermission(user,VeniceNamespaces.SYSTEM_PERMS_NAMESPACE,"install.modules")))
|
||||
dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error","You are not permitted to install modules."));
|
||||
|
||||
modops = cast.queryModuleOperations(req);
|
||||
|
||||
the_module = req_help.getParameterString("mod");
|
||||
|
|
109
venice-data/scripts/sysadmin/module_uninstall.js
Normal file
109
venice-data/scripts/sysadmin/module_uninstall.js
Normal file
|
@ -0,0 +1,109 @@
|
|||
// 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):
|
||||
|
||||
importPackage(java.util);
|
||||
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||
importPackage(Packages.com.silverwrist.dynamo.except);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.module);
|
||||
importPackage(Packages.com.silverwrist.dynamo.security);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
importPackage(Packages.com.silverwrist.venice.content);
|
||||
importPackage(Packages.com.silverwrist.venice.iface);
|
||||
|
||||
req = bsf.lookupBean("request");
|
||||
req_help = bsf.lookupBean("request_help");
|
||||
user = vlib.getUser(req);
|
||||
|
||||
// Make sure we are permitted to be here.
|
||||
srm = cast.querySecurityReferenceMonitor(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"srm"));
|
||||
acl = srm.getGlobalAcl();
|
||||
if (!(acl.testPermission(user,VeniceNamespaces.SYSTEM_PERMS_NAMESPACE,"uninstall.modules")))
|
||||
dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error","You are not permitted to uninstall modules."));
|
||||
|
||||
modops = cast.queryModuleOperations(req);
|
||||
|
||||
the_module = rhelp.getParameterString("mod");
|
||||
if (the_module!=null)
|
||||
{ // we want to uninstall this module
|
||||
rc = null;
|
||||
if (vlib.confirmed(req,"/sysadmin/module_uninstall.js.vs","confirmation","confnum"))
|
||||
{ // OK, they have confirmed they want to uninstall the module...do it!
|
||||
mod = modops.findModuleByFilename(n);
|
||||
except = null;
|
||||
log = new SimpleMemoryLog();
|
||||
try
|
||||
{ // uninstall the module
|
||||
mod.uninstall(user,log);
|
||||
modops.freeUnusedModules(); // GC the module list, as it were
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // save the exception
|
||||
except = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
// Return the results.
|
||||
rc = new VelocityView("Module Uninstallation","sysadmin/module_uninstall_result.vm");
|
||||
rc.setParameter("module",the_module);
|
||||
rc.setParameter("log",log.getLog());
|
||||
if (except!=null)
|
||||
rc.setParameter("except",except);
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // generate a confirmation number box
|
||||
msg = "You are about to uninstall module '" + the_module + "'! This will cause any and all data associated with "
|
||||
+ "this module (such as database tables and their contents) to be <b>DESTROYED AND IRREVOCABLY LOST!</b> "
|
||||
+ "Are you <em>really</em> sure you want to do this?";
|
||||
ok_url = "sysadmin/module_uninstall.js.vs?mod=" + stringutils.encodeURL(the_module);
|
||||
rc = new ConfirmBox(req,"/sysadmin/module_uninstall.js.vs","confirmation","confnum",
|
||||
"Module Uninstall Confirmation",msg,"SERVLET",ok_url,"SERVLET",
|
||||
"sysadmin/module_uninstall.js.vs");
|
||||
|
||||
} // end else
|
||||
|
||||
dynamo.scriptReturn(rc);
|
||||
|
||||
} // end if
|
||||
|
||||
// Get the set of all installed module files.
|
||||
instmod = modops.listInstalledModuleNames();
|
||||
|
||||
// Turn it into a list of name/description pairs.
|
||||
namelist = new ArrayList();
|
||||
it = instmod.iterator();
|
||||
while (it.hasNext())
|
||||
{ // get each module name in turn, and get the module reference
|
||||
n = it.next() + "";
|
||||
mod = modops.findModuleByFilename(n);
|
||||
if (mod!=null)
|
||||
{ // get the module's description and add it
|
||||
tmp = new HashMap();
|
||||
tmp.put("name",n);
|
||||
tmp.put("descr",mod.getDescription());
|
||||
namelist.add(tmp);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end while
|
||||
|
||||
// Return the Velocity view.
|
||||
rc = new VelocityView("Uninstall Modules","sysadmin/module_uninstall.vm");
|
||||
rc.setParameter("modlist",namelist);
|
||||
dynamo.scriptOutput(rc);
|
41
venice-data/velocity/sysadmin/module_uninstall.vm
Normal file
41
venice-data/velocity/sysadmin/module_uninstall.vm
Normal file
|
@ -0,0 +1,41 @@
|
|||
#*
|
||||
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):
|
||||
*#
|
||||
#*
|
||||
Parameters:
|
||||
modlist = List of module file names which are not yet installed.
|
||||
*#
|
||||
#header1( "Uninstall Modules" )
|
||||
<p><a href="#formatURL( "SERVLET" "sysadmin/modules.js.vs" )">Return to Previous Menu</a></p>
|
||||
#if( $modlist.isEmpty() )
|
||||
<p><em>No modules are curently installed in the system.</em></p>
|
||||
#else
|
||||
<p>The following modules are presently installed on the system. Click a module's name to uninstall it.</p>
|
||||
<div align="center"><table border="1" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<th><b>Name</b></th>
|
||||
<th><b>Description</b></th>
|
||||
</tr>
|
||||
#foreach( $x in $modlist )
|
||||
#set( $en = "#encodeURL( $x.name )" )
|
||||
<tr>
|
||||
<td><a href="#formatURL( "SERVLET" "sysadmin/module_uninstall.js.vs?mod=$en" )">#encodeHTML( $x.name )</a></td>
|
||||
<td>#encodeHTML( $x.descr )</td>
|
||||
</tr>
|
||||
#end
|
||||
</table></div>
|
||||
#end
|
39
venice-data/velocity/sysadmin/module_uninstall_result.vm
Normal file
39
venice-data/velocity/sysadmin/module_uninstall_result.vm
Normal file
|
@ -0,0 +1,39 @@
|
|||
#*
|
||||
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):
|
||||
*#
|
||||
#*
|
||||
Parameters:
|
||||
module = The name of the module we were uninstalling
|
||||
except = The exception that occurred if uninstall failed (null on success)
|
||||
log = List containing log messages from the uninstallation
|
||||
*#
|
||||
#header2( "Uninstall Module:" $module )
|
||||
#if( $except )
|
||||
<p>The uninstallation of module <b>#encodeHTML( $module )</b> failed. The following is the exception that was
|
||||
thrown by uninstallation:</p>
|
||||
<pre>#stacktrace( $except )</pre>
|
||||
#else
|
||||
<p>The uninstallation of module <b>#encodeHTML( $module )</b> was completed successfully.</p>
|
||||
#end
|
||||
<p>The following are the log messages generated by module uninstallation:</p>
|
||||
<table border="1" width="100%" cellpadding="3" cellspacing="0"><tr><td class="content">
|
||||
#foreach( $x in $log )
|
||||
#encodeHTML( $x )<br />
|
||||
#end
|
||||
</td></tr></table>
|
||||
<p><a href="sysadmin/module_uninstall.js.vs">Uninstall more modules</a></p>
|
||||
<p><a href="sysadmin/modules.js.vs">Return to previous menu</a></p>
|
Loading…
Reference in New Issue
Block a user