From cb7b327da80c830deb701b8dba9f085042c4364f Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Tue, 24 Jun 2003 00:38:19 +0000 Subject: [PATCH] worked out bugs in the module install and community service add --- conf/venice-db-init-mysql.sql | 6 +++- .../venice/community/CommunityManager.java | 7 +++++ .../venice/menu/MenuDatabaseOps_mysql.java | 4 +-- .../venice/menu/MenuDefinition.java | 2 +- .../silverwrist/venice/menu/MenuEditImpl.java | 11 +++++++ .../venice/menu/MenuEditItemImpl.java | 6 +++- .../venice/menu/MenuItemDefinition.java | 2 +- .../venice/util/CommunityMenuInstaller.java | 31 +++++++++++++++++++ venice-data/scripts/comm/admin/svc_add.js | 3 +- venice-data/scripts/comm/admin/svc_remove.js | 13 ++++---- venice-data/scripts/comm/unjoin.js | 5 +-- .../scripts/sysadmin/module_uninstall.js | 11 ++++--- venice-data/velocity/comm/admin/services.vm | 2 +- .../velocity/sysadmin/module_install.vm | 2 +- .../sysadmin/module_install_result.vm | 4 +-- .../sysadmin/module_uninstall_result.vm | 4 +-- 16 files changed, 88 insertions(+), 25 deletions(-) diff --git a/conf/venice-db-init-mysql.sql b/conf/venice-db-init-mysql.sql index 2594800..77cb82b 100644 --- a/conf/venice-db-init-mysql.sql +++ b/conf/venice-db-init-mysql.sql @@ -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: '), #encodeHTML( $title ) -

#encodeHTML( $message )

+

$message

#button( "IMAGE" "yes" )    diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityManager.java b/src/venice-base/com/silverwrist/venice/community/CommunityManager.java index b4b92a9..b28b519 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityManager.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityManager.java @@ -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(); diff --git a/src/venice-base/com/silverwrist/venice/menu/MenuDatabaseOps_mysql.java b/src/venice-base/com/silverwrist/venice/menu/MenuDatabaseOps_mysql.java index 4982e68..416e423 100644 --- a/src/venice-base/com/silverwrist/venice/menu/MenuDatabaseOps_mysql.java +++ b/src/venice-base/com/silverwrist/venice/menu/MenuDatabaseOps_mysql.java @@ -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); diff --git a/src/venice-base/com/silverwrist/venice/menu/MenuDefinition.java b/src/venice-base/com/silverwrist/venice/menu/MenuDefinition.java index dc7ec1f..da7b720 100644 --- a/src/venice-base/com/silverwrist/venice/menu/MenuDefinition.java +++ b/src/venice-base/com/silverwrist/venice/menu/MenuDefinition.java @@ -175,7 +175,7 @@ class MenuDefinition for (int i=0; i=0) + if ((md.getLink()!=null) && (md.getLink().indexOf(text)>=0)) return i; } // end for diff --git a/src/venice-base/com/silverwrist/venice/menu/MenuEditImpl.java b/src/venice-base/com/silverwrist/venice/menu/MenuEditImpl.java index 8c6a0de..54fb9fb 100644 --- a/src/venice-base/com/silverwrist/venice/menu/MenuEditImpl.java +++ b/src/venice-base/com/silverwrist/venice/menu/MenuEditImpl.java @@ -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, diff --git a/src/venice-base/com/silverwrist/venice/menu/MenuEditItemImpl.java b/src/venice-base/com/silverwrist/venice/menu/MenuEditItemImpl.java index d90aecf..e1084d2 100644 --- a/src/venice-base/com/silverwrist/venice/menu/MenuEditItemImpl.java +++ b/src/venice-base/com/silverwrist/venice/menu/MenuEditItemImpl.java @@ -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 diff --git a/src/venice-base/com/silverwrist/venice/menu/MenuItemDefinition.java b/src/venice-base/com/silverwrist/venice/menu/MenuItemDefinition.java index 4949464..a8b80cb 100644 --- a/src/venice-base/com/silverwrist/venice/menu/MenuItemDefinition.java +++ b/src/venice-base/com/silverwrist/venice/menu/MenuItemDefinition.java @@ -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 diff --git a/src/venice-base/com/silverwrist/venice/util/CommunityMenuInstaller.java b/src/venice-base/com/silverwrist/venice/util/CommunityMenuInstaller.java index a922469..cf8ee52 100644 --- a/src/venice-base/com/silverwrist/venice/util/CommunityMenuInstaller.java +++ b/src/venice-base/com/silverwrist/venice/util/CommunityMenuInstaller.java @@ -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); diff --git a/venice-data/scripts/comm/admin/svc_add.js b/venice-data/scripts/comm/admin/svc_add.js index 26cfdd0..fecde2c 100644 --- a/venice-data/scripts/comm/admin/svc_add.js +++ b/venice-data/scripts/comm/admin/svc_add.js @@ -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())); diff --git a/venice-data/scripts/comm/admin/svc_remove.js b/venice-data/scripts/comm/admin/svc_remove.js index 9dc93e9..9d9ee6c 100644 --- a/venice-data/scripts/comm/admin/svc_remove.js +++ b/venice-data/scripts/comm/admin/svc_remove.js @@ -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 DESTROYED AND IRREVOCABLY LOST! Are you really 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 DESTROYED AND IRREVOCABLY LOST! Are you really 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 diff --git a/venice-data/scripts/comm/unjoin.js b/venice-data/scripts/comm/unjoin.js index 3cf068f..bf04ebf 100644 --- a/venice-data/scripts/comm/unjoin.js +++ b/venice-data/scripts/comm/unjoin.js @@ -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)); diff --git a/venice-data/scripts/sysadmin/module_uninstall.js b/venice-data/scripts/sysadmin/module_uninstall.js index bf42c3d..5a96948 100644 --- a/venice-data/scripts/sysadmin/module_uninstall.js +++ b/venice-data/scripts/sysadmin/module_uninstall.js @@ -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 DESTROYED AND IRREVOCABLY LOST! " - + "Are you really 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 DESTROYED AND " + + "IRREVOCABLY LOST! Are you really 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", diff --git a/venice-data/velocity/comm/admin/services.vm b/venice-data/velocity/comm/admin/services.vm index 9ee9b70..0e71da9 100644 --- a/venice-data/velocity/comm/admin/services.vm +++ b/venice-data/velocity/comm/admin/services.vm @@ -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 )

Return to Previous Menu

#if( $services.isEmpty() )

There are no community-level services currently defined.

diff --git a/venice-data/velocity/sysadmin/module_install.vm b/venice-data/velocity/sysadmin/module_install.vm index 89490bf..8410156 100644 --- a/venice-data/velocity/sysadmin/module_install.vm +++ b/venice-data/velocity/sysadmin/module_install.vm @@ -28,7 +28,7 @@ to install it.

#foreach( $m in $modlist ) - #set( $em = "#encodeURL( $m )" + #set( $em = "#encodeURL( $m )" ) diff --git a/venice-data/velocity/sysadmin/module_install_result.vm b/venice-data/velocity/sysadmin/module_install_result.vm index 066d9be..265aaeb 100644 --- a/venice-data/velocity/sysadmin/module_install_result.vm +++ b/venice-data/velocity/sysadmin/module_install_result.vm @@ -35,5 +35,5 @@ #encodeHTML( $x )
#end
#encodeHTML( $m )
-

Install more modules

-

Return to previous menu

+

Install more modules

+

Return to previous menu

diff --git a/venice-data/velocity/sysadmin/module_uninstall_result.vm b/venice-data/velocity/sysadmin/module_uninstall_result.vm index 5a46d3b..12756c5 100644 --- a/venice-data/velocity/sysadmin/module_uninstall_result.vm +++ b/venice-data/velocity/sysadmin/module_uninstall_result.vm @@ -35,5 +35,5 @@ #encodeHTML( $x )
#end -

Uninstall more modules

-

Return to previous menu

+

Uninstall more modules

+

Return to previous menu