some more minor mods to the module manager, and implementation of the module

uninstallation page
This commit is contained in:
Eric J. Bowersox
2003-06-19 20:21:20 +00:00
parent 0f0f4a4a4e
commit c8b6a513b9
12 changed files with 230 additions and 11 deletions

View File

@@ -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");

View 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);

View 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

View 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>