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

View File

@ -184,6 +184,7 @@ public class CommunityManager
PropertyKey pk2 = new PropertyKey(m_ns_cache.namespaceNameToId(modid.getNamespace()),modid.getName()); PropertyKey pk2 = new PropertyKey(m_ns_cache.namespaceNameToId(modid.getNamespace()),modid.getName());
if (!(pk.equals(pk2))) if (!(pk.equals(pk2)))
{ // module name does not match what we expect - throw exception { // 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", CommunityServiceException cse = new CommunityServiceException(CommunityManager.class,"CommunityMessages",
"svc.modname.mismatch"); "svc.modname.mismatch");
cse.setParameter(0,filename); cse.setParameter(0,filename);
@ -220,6 +221,10 @@ public class CommunityManager
} // end while } // 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. // Now register our ServiceShutdown class as a pre-stage shutdown hook.
FinalStageRegistration fsreg = (FinalStageRegistration)(services.queryService(FinalStageRegistration.class)); FinalStageRegistration fsreg = (FinalStageRegistration)(services.queryService(FinalStageRegistration.class));
fsreg.registerPreStageShutdown(new ServiceShutdown()); fsreg.registerPreStageShutdown(new ServiceShutdown());
@ -254,6 +259,8 @@ public class CommunityManager
LinkedList shut_list = new LinkedList(m_qname_to_service.values()); LinkedList shut_list = new LinkedList(m_qname_to_service.values());
m_qname_to_service.clear(); m_qname_to_service.clear();
m_index_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) while (shut_list.size()>0)
{ // shut down this community service { // shut down this community service
CommunityServiceController csc = ((CommunityServiceDescriptor)(shut_list.removeFirst())).getController(); 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) " stmt = conn.prepareStatement("INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link) "
+ "VALUES (?, ?, ?, ?, ?, ?);"); + "VALUES (?, ?, ?, ?, ?, ?);");
stmt.setInt(1,id); stmt.setInt(1,id);
stmt.setString(2,type); stmt.setInt(2,seq);
stmt.setInt(3,seq); stmt.setString(3,type);
stmt.setString(4,text); stmt.setString(4,text);
stmt.setString(5,linktype); stmt.setString(5,linktype);
stmt.setString(6,link); stmt.setString(6,link);

View File

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

View File

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

View File

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

View File

@ -17,6 +17,7 @@
*/ */
package com.silverwrist.venice.util; package com.silverwrist.venice.util;
import org.apache.log4j.Logger;
import com.silverwrist.dynamo.except.*; import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*; import com.silverwrist.dynamo.iface.*;
import com.silverwrist.venice.VeniceNamespaces; 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; 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"); MenuEditObject menu = m_provider.getEditMenu(caller,VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.menu");
MenuEditItemObject end_marker = menu.getItemByTypeText("MARKER","end-services"); 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); 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; 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()) if (new_sequence>=end_marker.getSequence())
{ // need to renumber the menu items { // need to renumber the menu items
if (logger.isDebugEnabled())
logger.debug("renumbering existing items...");
MenuEditItemObject item = menu.getItemByTypeText("MARKER","begin-services"); MenuEditItemObject item = menu.getItemByTypeText("MARKER","begin-services");
new_sequence = item.getSequence(); new_sequence = item.getSequence();
item = menu.getNextItem(item); item = menu.getNextItem(item);
new_sequence += STD_GAP; new_sequence += STD_GAP;
while (!(item.getItemType().equals("MARKER"))) while (!(item.getItemType().equals("MARKER")))
{ // reset the numbers for the sequence { // 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.setSequence(new_sequence);
item = menu.getNextItem(item); item = menu.getNextItem(item);
new_sequence += STD_GAP; new_sequence += STD_GAP;
} // end while } // end while
if (logger.isDebugEnabled())
logger.debug("new item sequence is " + new_sequence);
} // end if } // end if
MenuEditItemObject new_object = menu.addItem("TEXT",new_sequence,text,linktype,link); 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, MenuEditObject menu = m_provider.getEditMenu(caller,VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,
"community.admin.service"); "community.admin.service");
MenuEditItemObject end_marker = menu.getItemByTypeText("MARKER","end-service-admin"); 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); 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; 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()) if (new_sequence>=end_marker.getSequence())
{ // need to renumber the menu items { // need to renumber the menu items
if (logger.isDebugEnabled())
logger.debug("renumbering existing items...");
MenuEditItemObject item = menu.getItemByTypeText("MARKER","begin-service-admin"); MenuEditItemObject item = menu.getItemByTypeText("MARKER","begin-service-admin");
new_sequence = item.getSequence(); new_sequence = item.getSequence();
item = menu.getNextItem(item); item = menu.getNextItem(item);
new_sequence += STD_GAP; new_sequence += STD_GAP;
while (!(item.getItemType().equals("MARKER"))) while (!(item.getItemType().equals("MARKER")))
{ // reset the numbers for the sequence { // 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.setSequence(new_sequence);
item = menu.getNextItem(item); item = menu.getNextItem(item);
new_sequence += STD_GAP; new_sequence += STD_GAP;
} // end while } // end while
if (logger.isDebugEnabled())
logger.debug("new item sequence is " + new_sequence);
} // end if } // end if
MenuEditItemObject new_object = menu.addItem("TEXT",new_sequence,text,linktype,link); MenuEditItemObject new_object = menu.addItem("TEXT",new_sequence,text,linktype,link);

View File

@ -50,6 +50,7 @@ if (csd==null)
// Now add the service! // Now add the service!
comm.addService(user,req,csd.name.namespace,csd.name.name); comm.addService(user,req,csd.name.namespace,csd.name.name);
vlib.forceReloadMenu(req);
// Bounce back to the services list. // 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")) if (vlib.confirmed(req,"/comm/admin/svc_remove.js.vs","confirmation","confnum"))
{ // remove the service! { // remove the service!
comm.removeService(user,req,csd.name.namespace,csd.name.name); 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 } // end if
else else
{ // create the confirmation dialog { // create the confirmation dialog
msg = "You are about to remove the service " + csd.name.namespace + "::" + csd.name.name + " from the community '" msg = "You are about to remove the service " + stringutils.encodeHTML(csd.name.namespace) + "::"
+ comm.name + "'! This may cause any and all data associated with this service in the community (such as " + stringutils.encodeHTML(csd.name.name) + " from the community '" + stringutils.encodeHTML(comm.name)
+ "database table contents) to be <b>DESTROYED AND IRREVOCABLY LOST!</b> Are you <em>really</em> sure you " + "'! This may cause any and all data associated with this service in the community (such as database table "
+ "want to do this?"; + "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, 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", "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 } // end else

View File

@ -36,6 +36,7 @@ if (vlib.confirmed(req,"/comm/unjoin.js.vs","confirmation","confnum"))
} // end if } // end if
dynamo.scriptOutput(new ConfirmBox(req,"/comm/unjoin.js.vs","confirmation","confnum","Unjoin Confirmation", msg = "You are about to unjoin the '" + stringutils.encodeHTML(comm.name) + "' community! Are you sure you want "
"You are about to unjoin the '" + comm.name + "' community! Are you sure you want to do this?", + "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)); "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); modops = cast.queryModuleOperations(req);
the_module = rhelp.getParameterString("mod"); the_module = req_help.getParameterString("mod");
if (the_module!=null) if (the_module!=null)
{ // we want to uninstall this module { // we want to uninstall this module
logger.debug("Want to uninstall " + the_module);
rc = null; rc = null;
if (vlib.confirmed(req,"/sysadmin/module_uninstall.js.vs","confirmation","confnum")) if (vlib.confirmed(req,"/sysadmin/module_uninstall.js.vs","confirmation","confnum"))
{ // OK, they have confirmed they want to uninstall the module...do it! { // OK, they have confirmed they want to uninstall the module...do it!
logger.debug("confirmed - do the uninstall!");
mod = modops.findModuleByFilename(n); mod = modops.findModuleByFilename(n);
except = null; except = null;
log = new SimpleMemoryLog(); log = new SimpleMemoryLog();
@ -68,9 +70,10 @@ if (the_module!=null)
} // end if } // end if
else else
{ // generate a confirmation number box { // generate a confirmation number box
msg = "You are about to uninstall module '" + the_module + "'! This will cause any and all data associated with " logger.debug("need confirmation number");
+ "this module (such as database tables and their contents) to be <b>DESTROYED AND IRREVOCABLY LOST!</b> " msg = "You are about to uninstall module '" + stringutils.encodeHTML(the_module) + "'! This will cause any and "
+ "Are you <em>really</em> sure you want to do this?"; + "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); ok_url = "sysadmin/module_uninstall.js.vs?mod=" + stringutils.encodeURL(the_module);
rc = new ConfirmBox(req,"/sysadmin/module_uninstall.js.vs","confirmation","confnum", rc = new ConfirmBox(req,"/sysadmin/module_uninstall.js.vs","confirmation","confnum",
"Module Uninstall Confirmation",msg,"SERVLET",ok_url,"SERVLET", "Module Uninstall Confirmation",msg,"SERVLET",ok_url,"SERVLET",

View File

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

View File

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

View File

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

View File

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