worked out bugs in the module install and community service add

This commit is contained in:
Eric J. Bowersox 2003-06-24 00:38:19 +00:00
parent 278ad880bb
commit cb7b327da8
16 changed files with 88 additions and 25 deletions

View File

@ -598,6 +598,8 @@ INSERT INTO globalprop (nsid, prop_name, prop_value) VALUES
(6, 'bnc.logout', '!Log Out' ),
(6, 'bn.next', '!arrow_next.jpg' ),
(6, 'bnc.next', '!Next' ),
(6, 'bn.no', '!no.jpg' ),
(6, 'bnc.no', '!No' ),
(6, 'bn.ok', '!ok.jpg' ),
(6, 'bnc.ok', '!OK' ),
(6, 'bn.previous', '!arrow_previous.jpg' ),
@ -618,6 +620,8 @@ INSERT INTO globalprop (nsid, prop_name, prop_value) VALUES
(6, 'bnc.terminate', '!Terminate' ),
(6, 'bn.update', '!update.jpg' ),
(6, 'bnc.update', '!Update' ),
(6, 'bn.yes', '!yes.jpg' ),
(6, 'bnc.yes', '!Yes' ),
(6, 'user.agreement.title', '!Venice User Agreement' ),
(6, 'user.photo.width', 'I100' ),
(6, 'user.photo.height', 'I100' ),
@ -692,7 +696,7 @@ Report abuses to: <abuse@example.com>'),
#encodeHTML( $title )
</td></tr>
<tr valign="middle"><td class="confirmbody">
<p>#encodeHTML( $message )</p>
<p>$message</p>
<p>
<a href="#formatURL( $yes_type $yes_url )">#button( "IMAGE" "yes" )</a>
&nbsp;&nbsp;

View File

@ -184,6 +184,7 @@ public class CommunityManager
PropertyKey pk2 = new PropertyKey(m_ns_cache.namespaceNameToId(modid.getNamespace()),modid.getName());
if (!(pk.equals(pk2)))
{ // module name does not match what we expect - throw exception
logger.error("Loaded module name " + pk2 + " does not match expected module name " + pk);
CommunityServiceException cse = new CommunityServiceException(CommunityManager.class,"CommunityMessages",
"svc.modname.mismatch");
cse.setParameter(0,filename);
@ -220,6 +221,10 @@ public class CommunityManager
} // end while
if (logger.isDebugEnabled())
logger.debug("Community service list initialized: " + m_index_to_service.size() + " "
+ ((m_index_to_service.size()==1) ? "entry" : "entries"));
// Now register our ServiceShutdown class as a pre-stage shutdown hook.
FinalStageRegistration fsreg = (FinalStageRegistration)(services.queryService(FinalStageRegistration.class));
fsreg.registerPreStageShutdown(new ServiceShutdown());
@ -254,6 +259,8 @@ public class CommunityManager
LinkedList shut_list = new LinkedList(m_qname_to_service.values());
m_qname_to_service.clear();
m_index_to_service.clear();
if (logger.isDebugEnabled())
logger.debug("ServiceShutdown: " + shut_list.size() + " item(s) to shut down");
while (shut_list.size()>0)
{ // shut down this community service
CommunityServiceController csc = ((CommunityServiceDescriptor)(shut_list.removeFirst())).getController();

View File

@ -727,8 +727,8 @@ public class MenuDatabaseOps_mysql extends MenuDatabaseOps
stmt = conn.prepareStatement("INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link) "
+ "VALUES (?, ?, ?, ?, ?, ?);");
stmt.setInt(1,id);
stmt.setString(2,type);
stmt.setInt(3,seq);
stmt.setInt(2,seq);
stmt.setString(3,type);
stmt.setString(4,text);
stmt.setString(5,linktype);
stmt.setString(6,link);

View File

@ -175,7 +175,7 @@ class MenuDefinition
for (int i=0; i<m_items.size(); i++)
{ // simple linear search through menu items
MenuItemDefinition md = (MenuItemDefinition)(m_items.get(i));
if (md.getLink().indexOf(text)>=0)
if ((md.getLink()!=null) && (md.getLink().indexOf(text)>=0))
return i;
} // end for

View File

@ -18,11 +18,19 @@
package com.silverwrist.venice.menu;
import java.util.*;
import org.apache.log4j.Logger;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.venice.iface.*;
class MenuEditImpl implements MenuEditObject
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Logger logger = Logger.getLogger(MenuEditImpl.class);
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
@ -188,6 +196,9 @@ class MenuEditImpl implements MenuEditObject
public MenuEditItemObject addItem(String type, int sequence, String text, String linktype, String link)
throws DatabaseException
{
if (logger.isDebugEnabled())
logger.debug("MenuEditImpl.addItem(type=\"" + type + "\", sequence=" + sequence + ", text=\"" + text
+ "\", linktype=\"" + linktype + "\", link=\"" + link + "\")");
baleeted();
m_ops.addItem(m_mdef.getID(),type,sequence,text,linktype,link);
MenuItemDefinition item = new MenuItemDefinition(type,sequence,true,0,text,linktype,link,null,null,null,null,

View File

@ -78,7 +78,11 @@ class MenuEditItemImpl implements MenuEditItemObject
public int getIndexOfItem()
{
return m_mdef.getIndexOf(m_item);
if ((m_item==null) || (m_mdef==null))
return -1;
int rc = m_mdef.getIndexOf(m_item);
assert (m_mdef.getItem(rc)==m_item);
return rc;
} // end getIndexOfItem

View File

@ -105,7 +105,7 @@ class MenuItemDefinition implements Comparable
if (!(o instanceof MenuItemDefinition))
throw new ClassCastException("MenuItemDefinition.compareTo");
MenuItemDefinition other = (MenuItemDefinition)o;
return other.m_sequence - this.m_sequence;
return this.m_sequence - other.m_sequence;
} // end compareTo

View File

@ -17,6 +17,7 @@
*/
package com.silverwrist.venice.util;
import org.apache.log4j.Logger;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.venice.VeniceNamespaces;
@ -29,6 +30,8 @@ public class CommunityMenuInstaller
*--------------------------------------------------------------------------------
*/
private static Logger logger = Logger.getLogger(CommunityMenuInstaller.class);
private static final int STD_GAP = 100;
/*--------------------------------------------------------------------------------
@ -59,22 +62,36 @@ public class CommunityMenuInstaller
{
MenuEditObject menu = m_provider.getEditMenu(caller,VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.menu");
MenuEditItemObject end_marker = menu.getItemByTypeText("MARKER","end-services");
if (logger.isDebugEnabled())
logger.debug("located end marker, sequence is: " + end_marker.getSequence());
MenuEditItemObject insert_after = menu.getPreviousItem(end_marker);
if (logger.isDebugEnabled())
logger.debug("insert-after item is " + insert_after.getItemType() + ":" + insert_after.getText() + ", seq = "
+ insert_after.getSequence());
int new_sequence = insert_after.getSequence() + STD_GAP;
if (logger.isDebugEnabled())
logger.debug("new item sequence is " + new_sequence);
if (new_sequence>=end_marker.getSequence())
{ // need to renumber the menu items
if (logger.isDebugEnabled())
logger.debug("renumbering existing items...");
MenuEditItemObject item = menu.getItemByTypeText("MARKER","begin-services");
new_sequence = item.getSequence();
item = menu.getNextItem(item);
new_sequence += STD_GAP;
while (!(item.getItemType().equals("MARKER")))
{ // reset the numbers for the sequence
if (logger.isDebugEnabled())
logger.debug("new sequence for item " + item.getItemType() + ":" + item.getText() + " is " + new_sequence);
item.setSequence(new_sequence);
item = menu.getNextItem(item);
new_sequence += STD_GAP;
} // end while
if (logger.isDebugEnabled())
logger.debug("new item sequence is " + new_sequence);
} // end if
MenuEditItemObject new_object = menu.addItem("TEXT",new_sequence,text,linktype,link);
@ -101,22 +118,36 @@ public class CommunityMenuInstaller
MenuEditObject menu = m_provider.getEditMenu(caller,VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,
"community.admin.service");
MenuEditItemObject end_marker = menu.getItemByTypeText("MARKER","end-service-admin");
if (logger.isDebugEnabled())
logger.debug("located end marker, sequence is: " + end_marker.getSequence());
MenuEditItemObject insert_after = menu.getPreviousItem(end_marker);
if (logger.isDebugEnabled())
logger.debug("insert-after item is " + insert_after.getItemType() + ":" + insert_after.getText() + ", seq = "
+ insert_after.getSequence());
int new_sequence = insert_after.getSequence() + STD_GAP;
if (logger.isDebugEnabled())
logger.debug("new item sequence is " + new_sequence);
if (new_sequence>=end_marker.getSequence())
{ // need to renumber the menu items
if (logger.isDebugEnabled())
logger.debug("renumbering existing items...");
MenuEditItemObject item = menu.getItemByTypeText("MARKER","begin-service-admin");
new_sequence = item.getSequence();
item = menu.getNextItem(item);
new_sequence += STD_GAP;
while (!(item.getItemType().equals("MARKER")))
{ // reset the numbers for the sequence
if (logger.isDebugEnabled())
logger.debug("new sequence for item " + item.getItemType() + ":" + item.getText() + " is " + new_sequence);
item.setSequence(new_sequence);
item = menu.getNextItem(item);
new_sequence += STD_GAP;
} // end while
if (logger.isDebugEnabled())
logger.debug("new item sequence is " + new_sequence);
} // end if
MenuEditItemObject new_object = menu.addItem("TEXT",new_sequence,text,linktype,link);

View File

@ -50,6 +50,7 @@ if (csd==null)
// Now add the service!
comm.addService(user,req,csd.name.namespace,csd.name.name);
vlib.forceReloadMenu(req);
// Bounce back to the services list.
dynamo.scriptOutput(new Redirect("SERVLET","comm/admin/services.js.vs"));
dynamo.scriptOutput(new Redirect("SERVLET","comm/admin/services.js.vs?cc=" + comm.getCID()));

View File

@ -52,18 +52,19 @@ rc = null;
if (vlib.confirmed(req,"/comm/admin/svc_remove.js.vs","confirmation","confnum"))
{ // remove the service!
comm.removeService(user,req,csd.name.namespace,csd.name.name);
rc = new Redirect("SERVLET","comm/admin/services.js.vs");
vlib.forceReloadMenu(req);
rc = new Redirect("SERVLET","comm/admin/services.js.vs?cc=" + comm.getCID());
} // end if
else
{ // create the confirmation dialog
msg = "You are about to remove the service " + csd.name.namespace + "::" + csd.name.name + " from the community '"
+ comm.name + "'! This may cause any and all data associated with this service in the community (such as "
+ "database table contents) to be <b>DESTROYED AND IRREVOCABLY LOST!</b> Are you <em>really</em> sure you "
+ "want to do this?";
msg = "You are about to remove the service " + stringutils.encodeHTML(csd.name.namespace) + "::"
+ stringutils.encodeHTML(csd.name.name) + " from the community '" + stringutils.encodeHTML(comm.name)
+ "'! This may cause any and all data associated with this service in the community (such as database table "
+ "contents) to be <b>DESTROYED AND IRREVOCABLY LOST!</b> Are you <em>really</em> sure you want to do this?";
rc = new ConfirmBox(req,"/comm/admin/svc_remove.js.vs","confirmation","confnum","Service Remove Confirmation",msg,
"SERVLET","comm/admin/svc_remove.js.vs?cc=" + comm.getCID() + "&id=" + ndx,"SERVLET",
"comm/admin/services.js.vs");
"comm/admin/services.js.vs?cc=" + comm.getCID());
} // end else

View File

@ -36,6 +36,7 @@ if (vlib.confirmed(req,"/comm/unjoin.js.vs","confirmation","confnum"))
} // end if
dynamo.scriptOutput(new ConfirmBox(req,"/comm/unjoin.js.vs","confirmation","confnum","Unjoin Confirmation",
"You are about to unjoin the '" + comm.name + "' community! Are you sure you want to do this?",
msg = "You are about to unjoin the '" + stringutils.encodeHTML(comm.name) + "' community! Are you sure you want "
+ "to do this?";
dynamo.scriptOutput(new ConfirmBox(req,"/comm/unjoin.js.vs","confirmation","confnum","Unjoin Confirmation",msg,
"SERVLET","comm/unjoin.js.vs?cc=" + comm.getCID(),"SERVLET","community/" + comm.alias));

View File

@ -37,12 +37,14 @@ if (!(acl.testPermission(user,VeniceNamespaces.SYSTEM_PERMS_NAMESPACE,"uninstall
modops = cast.queryModuleOperations(req);
the_module = rhelp.getParameterString("mod");
the_module = req_help.getParameterString("mod");
if (the_module!=null)
{ // we want to uninstall this module
logger.debug("Want to uninstall " + the_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!
logger.debug("confirmed - do the uninstall!");
mod = modops.findModuleByFilename(n);
except = null;
log = new SimpleMemoryLog();
@ -68,9 +70,10 @@ if (the_module!=null)
} // 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?";
logger.debug("need confirmation number");
msg = "You are about to uninstall module '" + stringutils.encodeHTML(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",

View File

@ -20,7 +20,7 @@
community = Community we're displaying the services of.
services = List of all available services, with an indication as to whether we're using them.
*#
#header2( "Community Services", $community.Name )
#header2( "Community Services" $community.Name )
<p><a href="#formatURL( "SERVLET" "comm/admin/main.js.vs" )">Return to Previous Menu</a></p>
#if( $services.isEmpty() )
<p><em>There are no community-level services currently defined.</em></p>

View File

@ -28,7 +28,7 @@
to install it.</p>
<div align="left"><table border="0" cellpadding="0" cellspacing="2">
#foreach( $m in $modlist )
#set( $em = "#encodeURL( $m )"
#set( $em = "#encodeURL( $m )" )
<tr><td class="content">
<a href="#formatURL( "SERVLET" "sysadmin/module_install.js.vs?mod=$em" )">#encodeHTML( $m )</a>
</td></tr>

View File

@ -35,5 +35,5 @@
#encodeHTML( $x )<br />
#end
</td></tr></table>
<p><a href="sysadmin/module_install.js.vs">Install more modules</a></p>
<p><a href="sysadmin/modules.js.vs">Return to previous menu</a></p>
<p><a href="#formatURL( "SERVLET" "sysadmin/module_install.js.vs" )">Install more modules</a></p>
<p><a href="#formatURL( "SERVLET" "sysadmin/modules.js.vs" )">Return to previous menu</a></p>

View File

@ -35,5 +35,5 @@
#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>
<p><a href="#formatURL( "SERVLET" "sysadmin/module_uninstall.js.vs" )">Uninstall more modules</a></p>
<p><a href="#formatURL( "SERVLET" "sysadmin/modules.js.vs" )">Return to previous menu</a></p>