From 80d4ba4212d24861d7a1e5d18f51b24593c41aab Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Sun, 15 Jun 2003 19:02:26 +0000 Subject: [PATCH] some of the underpinnings of community services --- conf/venice-db-init-mysql.sql | 33 ++++ .../dynamo/app/ApplicationContainer.java | 58 +++++- .../ApplicationContainerMessages.properties | 1 + .../dynamo/iface/FinalStageInitHook.java | 26 +++ .../dynamo/iface/FinalStageRegistration.java | 26 +++ .../silverwrist/dynamo/iface/ModuleSite.java | 2 + .../dynamo/module/ModuleLoader.java | 18 +- .../dynamo/module/ModuleManager.java | 2 +- .../venice/community/CommunityImpl.java | 47 ++++- .../venice/community/CommunityManager.java | 169 +++++++++++++++++- .../venice/community/CommunityManagerOps.java | 9 + .../community/CommunityManagerOps_mysql.java | 49 +++++ .../community/CommunityMessages.properties | 2 + .../venice/community/CommunityOps.java | 2 + .../venice/community/CommunityOps_mysql.java | 41 +++++ .../venice/community/CommunityProxy.java | 6 + .../venice/community/CommunityService.java | 4 + .../community/CommunityServiceDescriptor.java | 83 +++++++++ .../except/CommunityServiceException.java | 60 +++++++ .../iface/CommunityServiceController.java | 27 +++ .../venice/iface/VeniceCommunity.java | 3 + 21 files changed, 657 insertions(+), 11 deletions(-) create mode 100644 src/dynamo-framework/com/silverwrist/dynamo/iface/FinalStageInitHook.java create mode 100644 src/dynamo-framework/com/silverwrist/dynamo/iface/FinalStageRegistration.java create mode 100644 src/venice-base/com/silverwrist/venice/community/CommunityServiceDescriptor.java create mode 100644 src/venice-base/com/silverwrist/venice/except/CommunityServiceException.java create mode 100644 src/venice-base/com/silverwrist/venice/iface/CommunityServiceController.java diff --git a/conf/venice-db-init-mysql.sql b/conf/venice-db-init-mysql.sql index e0bc6ad..b949375 100644 --- a/conf/venice-db-init-mysql.sql +++ b/conf/venice-db-init-mysql.sql @@ -434,6 +434,28 @@ CREATE TABLE commprops ( PRIMARY KEY (cid, nsid, prop_name) ); +# The master table of community services. +CREATE TABLE commsvc_master ( + svcid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # internal ID number for service + svc_nsid INT NOT NULL, # service namespace ID + svc_name VARCHAR(255) BINARY NOT NULL, # service name + mod_nsid INT NOT NULL, # namespace ID of module containing this service + mod_name VARCHAR(255) BINARY NOT NULL, # name of module containing this service + mod_filename VARCHAR(255) NOT NULL, # filename of module containing this service + obj_nsid INT NOT NULL, # namespace ID of object implementing service controller + obj_name VARCHAR(255) BINARY NOT NULL, # name of object implementing service controller + shortvar VARCHAR(255) NOT NULL, # short variable name for service + UNIQUE INDEX by_name (svc_nsid, svc_name) +); + +# Indicates which services are enabled for which communities. +CREATE TABLE commsvc ( + cid INT NOT NULL, # community ID + svcid INT NOT NULL, # ID number of enabled service + PRIMARY KEY (cid, svcid), + UNIQUE INDEX rev_index (svcid, cid) +); + # The master table of sideboxes. CREATE TABLE sbox_master ( sbid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # sidebox identifier @@ -1328,6 +1350,17 @@ INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link) VALUES (4, 2, 'TEXT', 'Categories', 'SERVLET', 'find_categories.js.vs' ); UPDATE menuitems SET ifdef_var = 'use_categories' WHERE menuid = 4 AND sequence = 2; +# Create the standard community menu. (ID #5) +INSERT INTO menus (menuid, menu_nsid, menu_name, title, subtitle) + VALUES (5, 16, 'community.menu', '', NULL); +INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link) VALUES + (5, 0, 'TEXT', 'Home Page', 'SERVLET', 'TODO'), + (5, 60000, 'TEXT', 'Members', 'SERVLET', 'TODO'), + (5, 60100, 'TEXT', 'Profile', 'SERVLET', 'TODO'), + (5, 60200, 'TEXT', 'Administration', 'SERVLET', 'TODO'), + (5, 60300, 'SEPARATOR', NULL, NULL, NULL ), + (5, 60400, 'TEXT', 'Unjoin', 'SERVLET', 'TODO'); + # Create the sideboxes tables. INSERT INTO sbox_master (sbid, sb_nsid, sb_name, type_nsid, type_name, descr) VALUES (1, 19, 'community.list', 19, 'community.list', 'Community Membership List'), diff --git a/src/dynamo-framework/com/silverwrist/dynamo/app/ApplicationContainer.java b/src/dynamo-framework/com/silverwrist/dynamo/app/ApplicationContainer.java index 5f9be58..a2c0f61 100644 --- a/src/dynamo-framework/com/silverwrist/dynamo/app/ApplicationContainer.java +++ b/src/dynamo-framework/com/silverwrist/dynamo/app/ApplicationContainer.java @@ -47,7 +47,8 @@ import com.silverwrist.dynamo.util.*; public class ApplicationContainer implements ResourceProvider, ResourceProviderManager, RendererRegistration, ObjectProvider, EventListenerRegistration, OutputObjectFilterRegistration, QueryRenderer, PostDynamicUpdate, - RenderImmediate, RequestPreprocessorRegistration, ExceptionTranslatorRegistration + RenderImmediate, RequestPreprocessorRegistration, ExceptionTranslatorRegistration, + FinalStageRegistration { /*-------------------------------------------------------------------------------- * Internal class recording renderer registrations and providing a @@ -178,6 +179,8 @@ public class ApplicationContainer private HashMap m_update_listeners = new HashMap(); // update listeners private Vector m_request_preprocessors = new Vector(); // request preprocessors private Vector m_exception_xlators = new Vector(); // exception translators + private LinkedList m_final_stage_inits = new LinkedList(); // final-stage initialization hooks + private LinkedList m_prestage_shutdown = new LinkedList(); // pre-stage shutdown hooks /*-------------------------------------------------------------------------------- * Constructor @@ -219,6 +222,7 @@ public class ApplicationContainer m_app_sm.addInitService(PostDynamicUpdate.class,(PostDynamicUpdate)this); m_app_sm.addInitService(RequestPreprocessorRegistration.class,(RequestPreprocessorRegistration)this); m_app_sm.addInitService(ExceptionTranslatorRegistration.class,(ExceptionTranslatorRegistration)this); + m_app_sm.addInitService(FinalStageRegistration.class,(FinalStageRegistration)this); m_app_sm.addRuntimeService(ResourceProvider.class,(ResourceProvider)this); m_app_sm.addRuntimeService(ObjectProvider.class,(ObjectProvider)this); @@ -327,6 +331,28 @@ public class ApplicationContainer m_identity = buf.toString(); logger.info("Server: " + m_identity); + try + { // Call the "final stage" initialization hooks. + logger.info(m_final_stage_inits.size() + " final-stage init hook(s) to call"); + while (!(m_final_stage_inits.isEmpty())) + { // call the hooks in FIFO order + FinalStageInitHook hook = (FinalStageInitHook)(m_final_stage_inits.removeFirst()); + hook.initialize(m_application,init_svcs); + + } // end while + + m_final_stage_inits = null; // done with this list + + } // end try + catch (DynamoException e) + { // final-stage initialization failed - post an error + ConfigException ce = new ConfigException(ApplicationContainer.class,"ApplicationContainerMessages", + "finalinit.fail",e); + ce.setParameter(0,e.getMessage()); + throw ce; + + } // end catch + // Fire the "application initialized" events. ApplicationListener[] listeners = (ApplicationListener[])(m_application_listeners.toArray(APP_LISTENER_TEMPLATE)); @@ -390,6 +416,16 @@ public class ApplicationContainer } // end if + if (logger.isDebugEnabled()) + logger.debug("ApplicationContainer.destroy(): " + m_prestage_shutdown.size() + + " pre-stage shutdown hooks to call"); + while (m_prestage_shutdown.size()>0) + { // call the appropriate pre-stage shutdown hooks + ComponentShutdown sd = (ComponentShutdown)(m_prestage_shutdown.removeFirst()); + sd.shutdown(); + + } // end while + if (logger.isDebugEnabled()) logger.debug("ApplicationContainer.destroy(): " + m_shutdown_list.size() + " objects to blow away"); @@ -981,6 +1017,26 @@ public class ApplicationContainer } // end registerExceptionTranslator + /*-------------------------------------------------------------------------------- + * Implementations from interface FinalStageRegistration + *-------------------------------------------------------------------------------- + */ + + public synchronized boolean registerFinalStageInitHook(FinalStageInitHook hook) + { + if ((m_final_stage_inits==null) || (m_application!=null)) + return false; // too late to register + m_final_stage_inits.addLast(hook); + return true; + + } // end registerFinalStageInitHook + + public synchronized void registerPreStageShutdown(ComponentShutdown cs) + { + m_prestage_shutdown.addFirst(cs); + + } // end registerPreStageShutdown + /*-------------------------------------------------------------------------------- * External operations *-------------------------------------------------------------------------------- diff --git a/src/dynamo-framework/com/silverwrist/dynamo/app/ApplicationContainerMessages.properties b/src/dynamo-framework/com/silverwrist/dynamo/app/ApplicationContainerMessages.properties index 17f1c65..2ee576c 100644 --- a/src/dynamo-framework/com/silverwrist/dynamo/app/ApplicationContainerMessages.properties +++ b/src/dynamo-framework/com/silverwrist/dynamo/app/ApplicationContainerMessages.properties @@ -25,3 +25,4 @@ resource.rootErr=The resource root directory {0} does not exist. mountRP.badName=Invalid mount path for resources: {0} mountRP.already=Resource provider already mounted on path {0}. registerRenderer.already=Renderer already registered for class {0}. +finalinit.fail=Final-stage initialization failed: {0} diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/FinalStageInitHook.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/FinalStageInitHook.java new file mode 100644 index 0000000..5a95898 --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/FinalStageInitHook.java @@ -0,0 +1,26 @@ +/* + * 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 . + * + * 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 , + * 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): + */ +package com.silverwrist.dynamo.iface; + +import com.silverwrist.dynamo.except.DynamoException; + +public interface FinalStageInitHook +{ + public void initialize(Application application, ServiceProvider services) throws DynamoException; + +} // end interface FinalStageInitHook diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/FinalStageRegistration.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/FinalStageRegistration.java new file mode 100644 index 0000000..e5658de --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/FinalStageRegistration.java @@ -0,0 +1,26 @@ +/* + * 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 . + * + * 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 , + * 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): + */ +package com.silverwrist.dynamo.iface; + +public interface FinalStageRegistration +{ + public boolean registerFinalStageInitHook(FinalStageInitHook hook); + + public void registerPreStageShutdown(ComponentShutdown cs); + +} // end interface FinalStageRegistration diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/ModuleSite.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/ModuleSite.java index 1210941..27696d8 100644 --- a/src/dynamo-framework/com/silverwrist/dynamo/iface/ModuleSite.java +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/ModuleSite.java @@ -19,6 +19,8 @@ package com.silverwrist.dynamo.iface; public interface ModuleSite { + public String getFilename(); + public ResourceProvider getResourceProvider(); } // end interface ModuleSite diff --git a/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleLoader.java b/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleLoader.java index dd69045..3e4d6c6 100644 --- a/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleLoader.java +++ b/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleLoader.java @@ -49,6 +49,12 @@ class ModuleLoader extends URLClassLoader implements Module *==================================================================== */ + public String getFilename() + { + return m_filename; + + } // end getFilename + public ResourceProvider getResourceProvider() { return (ResourceProvider)this; @@ -106,20 +112,22 @@ class ModuleLoader extends URLClassLoader implements Module *-------------------------------------------------------------------------------- */ - private URL m_jar_url; - private String m_resource_path; - private ModuleFunctions m_modfuncs; - private boolean m_initialized = false; + private URL m_jar_url; // URL to the module JAR file + private String m_filename; // filename of the original JAR file relative to module directory + private String m_resource_path; // resource path for the JAR file + private ModuleFunctions m_modfuncs; // module functions (the bridge into the module) + private boolean m_initialized = false; // have we been initialized? /*-------------------------------------------------------------------------------- * Constructor *-------------------------------------------------------------------------------- */ - ModuleLoader(File modfile) throws ModuleException, MalformedURLException + ModuleLoader(File modfile, String filename) throws ModuleException, MalformedURLException { super(new URL[] { modfile.toURL() },ModuleLoader.class.getClassLoader()); logger.info("Loading module " + modfile.getAbsolutePath()); + m_filename = filename; String main_class_name = null; try { // create a JAR URL and use it to get the JAR attributes diff --git a/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleManager.java b/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleManager.java index 0fc42b3..096406e 100644 --- a/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleManager.java +++ b/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleManager.java @@ -198,7 +198,7 @@ public class ModuleManager implements NamedObject, ComponentInitialize, Componen try { // create a new ModuleLoader - rc = new ModuleLoader(mod_file); + rc = new ModuleLoader(mod_file,name); } // end try catch (MalformedURLException e) diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityImpl.java b/src/venice-base/com/silverwrist/venice/community/CommunityImpl.java index 39e2c26..0df4412 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityImpl.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityImpl.java @@ -94,6 +94,7 @@ class CommunityImpl implements VeniceCommunity *-------------------------------------------------------------------------------- */ + private CommunityManager m_base; // base object private CommunityOps m_ops; // community operations object private NamespaceCache m_nscache; // namespace cache object private SecurityReferenceMonitor m_srm; // security reference monitor @@ -114,6 +115,7 @@ class CommunityImpl implements VeniceCommunity private java.util.Date m_lastaccessed; // date last accessed private java.util.Date m_lastupdate; // date last updated private ReferenceMap m_properties; // properties cache + private List m_service_list = null; // cached service list /*-------------------------------------------------------------------------------- * Constructors @@ -141,9 +143,11 @@ class CommunityImpl implements VeniceCommunity * corresponding to static fields of the * {@link com.silverwrist.venice.community.CommunityManagerOps CommunityManagerOps} object. */ - CommunityImpl(CommunityOps ops, NamespaceCache nscache, SecurityReferenceMonitor srm, UserManagement users, - AuthenticatorLookup alook, PostDynamicUpdate post, CategoryService cats, Map data) + CommunityImpl(CommunityManager base, CommunityOps ops, NamespaceCache nscache, SecurityReferenceMonitor srm, + UserManagement users, AuthenticatorLookup alook, PostDynamicUpdate post, CategoryService cats, + Map data) { + m_base = base; m_ops = ops; m_nscache = nscache; m_srm = srm; @@ -1065,4 +1069,43 @@ class CommunityImpl implements VeniceCommunity } // end isAdministrator + public List getServices() throws DatabaseException + { + if (m_service_list==null) + { // need to fake up the service list + int[] svcids = m_ops.getServiceIDs(m_id); + if (svcids.length>0) + { // convert this to a list of ServiceDescriptors + ArrayList rc = new ArrayList(svcids.length); + for (int i=0; i0) + { // shut down this community service + CommunityServiceController csc = ((CommunityServiceDescriptor)(shut_list.removeFirst())).getController(); + csc.shutdown(); + + } // end while + + } // end shutdown + + } // end class ServiceShutdown + /*-------------------------------------------------------------------------------- * Static data members *-------------------------------------------------------------------------------- @@ -162,6 +287,8 @@ public class CommunityManager private CategoryService m_cats; // category service object private ReferenceMap m_id_to_comm; // ReferenceMap of community IDs to communities private ReferenceMap m_alias_to_comm; // ReferenceMap of community aliases to communities + private Hashtable m_qname_to_service; // maps service QualifiedNameKeys to descriptord + private Hashtable m_index_to_service; // maps service index numbers to descriptors private ComponentShutdown m_pszreg; // property serializer registration /*-------------------------------------------------------------------------------- @@ -173,6 +300,8 @@ public class CommunityManager { m_id_to_comm = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT); m_alias_to_comm = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT); + m_qname_to_service = new Hashtable(); + m_index_to_service = new Hashtable(); } // end constructor @@ -307,6 +436,10 @@ public class CommunityManager (PropertySerializerRegistration)(services.queryService(PropertySerializerRegistration.class)); m_pszreg = psreg.registerPropertySerializer(new CommunitySerializer()); + // Register our ServiceInit class as a pre-stage init hook. + FinalStageRegistration fsreg = (FinalStageRegistration)(services.queryService(FinalStageRegistration.class)); + fsreg.registerFinalStageInitHook(new ServiceInit()); + } // end initialize /*-------------------------------------------------------------------------------- @@ -379,7 +512,7 @@ public class CommunityManager rc = (CommunityImpl)(m_alias_to_comm.get(data.get(CommunityManagerOps.KEY_ALIAS))); if (rc==null) { // create the CommunityImpl object - rc = new CommunityImpl(m_ops.getCommunityOps(),m_ns_cache,m_srm,m_users,m_alook,m_post,m_cats,data); + rc = new CommunityImpl(this,m_ops.getCommunityOps(),m_ns_cache,m_srm,m_users,m_alook,m_post,m_cats,data); // poke the maps with the new object m_id_to_comm.put(key,rc); @@ -416,7 +549,7 @@ public class CommunityManager rc = (CommunityImpl)(m_id_to_comm.get(key)); if (rc==null) { // create the CommunityImpl object - rc = new CommunityImpl(m_ops.getCommunityOps(),m_ns_cache,m_srm,m_users,m_alook,m_post,m_cats,data); + rc = new CommunityImpl(this,m_ops.getCommunityOps(),m_ns_cache,m_srm,m_users,m_alook,m_post,m_cats,data); // poke the maps with the new object m_id_to_comm.put(key,rc); @@ -495,6 +628,38 @@ public class CommunityManager } // end getNumCommunitiesInCategory + public List getAvailableServices() + { + if (m_qname_to_service.isEmpty()) + return Collections.EMPTY_LIST; + ArrayList rc = new ArrayList(m_qname_to_service.values()); + Collections.sort(rc,new Comparator() + { + public int compare(Object o1, Object o2) + { + String s1 = ((CommunityServiceDescriptor)o1).getDescription(); + String s2 = ((CommunityServiceDescriptor)o2).getDescription(); + return s1.compareTo(s2); + + } // end compare + + public boolean equals(Object obj) + { + return false; + + } // end equals + + }); // end Comparator object + return Collections.unmodifiableList(rc); + + } // end getAvailableServices + + public CommunityServiceDescriptor getServiceForID(int id) + { + return (CommunityServiceDescriptor)(m_index_to_service.get(new Integer(id))); + + } // end getServiceForID + /*-------------------------------------------------------------------------------- * Implementations from interface CommunityProxyService *-------------------------------------------------------------------------------- diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityManagerOps.java b/src/venice-base/com/silverwrist/venice/community/CommunityManagerOps.java index 6fac0ee..19c5029 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityManagerOps.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityManagerOps.java @@ -43,6 +43,13 @@ abstract class CommunityManagerOps extends OpsBase static final String KEY_ACCESS = "access"; static final String KEY_UPDATE = "update"; + static final String KEY_SVCID = "svcid"; + static final String KEY_SVCNAME = "svcname"; + static final String KEY_MODNAME = "modname"; + static final String KEY_MODFILENAME = "modfilename"; + static final String KEY_OBJNAME = "objname"; + static final String KEY_SHORTVAR = "shortvar"; + /*-------------------------------------------------------------------------------- * Constructor *-------------------------------------------------------------------------------- @@ -83,6 +90,8 @@ abstract class CommunityManagerOps extends OpsBase abstract int searchNameCount(SearchMode mode, String term, boolean show_all) throws DatabaseException; + abstract List getMasterServiceList() throws DatabaseException; + /*-------------------------------------------------------------------------------- * External static operations *-------------------------------------------------------------------------------- diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityManagerOps_mysql.java b/src/venice-base/com/silverwrist/venice/community/CommunityManagerOps_mysql.java index 5a5879b..20ccb21 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityManagerOps_mysql.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityManagerOps_mysql.java @@ -22,6 +22,7 @@ import java.util.*; import com.silverwrist.util.*; import com.silverwrist.dynamo.except.*; import com.silverwrist.dynamo.iface.*; +import com.silverwrist.dynamo.util.*; import com.silverwrist.venice.CommunityVisibility; import com.silverwrist.venice.SearchMode; @@ -543,4 +544,52 @@ public class CommunityManagerOps_mysql extends CommunityManagerOps } // end searchNameCount + List getMasterServiceList() throws DatabaseException + { + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; + try + { // get a connection + conn = getConnection(); + + // create and execute the statement + stmt = conn.prepareStatement("SELECT svcid, svc_nsid, svc_name, mod_nsid, mod_name, mod_filename, obj_nsid, " + + "obj_name, shortvar FROM commsvc_master;"); + rs = stmt.executeQuery(); + + // prepare the return value + ArrayList rc = new ArrayList(); + while (rs.next()) + { // load values into a Map + HashMap tmp = new HashMap(); + tmp.put(KEY_SVCID,new Integer(rs.getInt(1))); + tmp.put(KEY_SVCNAME,new PropertyKey(rs.getInt(2),rs.getString(3))); + tmp.put(KEY_MODNAME,new PropertyKey(rs.getInt(4),rs.getString(5))); + tmp.put(KEY_MODFILENAME,rs.getString(6)); + tmp.put(KEY_OBJNAME,new PropertyKey(rs.getInt(7),rs.getString(8))); + tmp.put(KEY_SHORTVAR,rs.getString(9)); + rc.add(tmp); + + } // end while + + rc.trimToSize(); + return rc; + + } // end try + catch (SQLException e) + { // translate to a general DatabaseException + throw generalException(e); + + } // end catch + finally + { // shut everything down + SQLUtils.shutdown(rs); + SQLUtils.shutdown(stmt); + SQLUtils.shutdown(conn); + + } // end finally + + } // end getMasterServiceList + } // end class CommunityManagerOps_mysql diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityMessages.properties b/src/venice-base/com/silverwrist/venice/community/CommunityMessages.properties index c65b89c..36f66bc 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityMessages.properties +++ b/src/venice-base/com/silverwrist/venice/community/CommunityMessages.properties @@ -31,3 +31,5 @@ auth.grantAccess=You are not authorized to grant access to community "{0}." auth.revokeAccess=You are not authorized to revoke access grants in community "{0}." join.disallowed=You are not permitted to join community "{0}." join.authFail=Unable to authenticate to community "{0}"; cannot join. +svc.modname.mismatch=The name of the service module "{0}" did not match the name stored in the database. +svc.object.badType=The service controller object {0}::{1} was of the wrong type. diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityOps.java b/src/venice-base/com/silverwrist/venice/community/CommunityOps.java index 73075d2..8cc04c6 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityOps.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityOps.java @@ -80,4 +80,6 @@ abstract class CommunityOps extends OpsBase abstract void deleteSingleUseAuthData(int cid, int ugid, boolean is_group) throws DatabaseException; + abstract int[] getServiceIDs(int cid) throws DatabaseException; + } // end class CommunityOps diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityOps_mysql.java b/src/venice-base/com/silverwrist/venice/community/CommunityOps_mysql.java index eda7ce1..30758da 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityOps_mysql.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityOps_mysql.java @@ -1011,4 +1011,45 @@ class CommunityOps_mysql extends CommunityOps } // end deleteSingleUseAuthData + int[] getServiceIDs(int cid) throws DatabaseException + { + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; + try + { // get a connection + conn = getConnection(); + + // create and execute the statement + stmt = conn.prepareStatement("SELECT svcid FROM commsvc WHERE cid = ?;"); + stmt.setInt(1,cid); + rs = stmt.executeQuery(); + + // extract the initial results + ArrayList tmp = new ArrayList(); + while (rs.next()) + tmp.add(new Integer(rs.getInt(1))); + + // create the actual return value + int[] rc = new int[tmp.size()]; + for (int i=0; i. + * + * 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 , + * 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): + */ +package com.silverwrist.venice.community; + +import com.silverwrist.dynamo.util.*; +import com.silverwrist.venice.iface.*; + +public final class CommunityServiceDescriptor +{ + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + private int m_index; + private QualifiedNameKey m_qname; + private String m_shortvar; + private CommunityServiceController m_csc; + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + CommunityServiceDescriptor(Integer index, QualifiedNameKey qname, String shortvar, CommunityServiceController csc) + { + m_index = index.intValue(); + m_qname = qname; + m_shortvar = shortvar; + m_csc = csc; + + } // end constructor + + /*-------------------------------------------------------------------------------- + * Package-internal operations + *-------------------------------------------------------------------------------- + */ + + CommunityServiceController getController() + { + return m_csc; + + } // end getController + + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + + public int getIndex() + { + return m_index; + + } // end getindex + + public QualifiedNameKey getName() + { + return m_qname; + + } // end getName + + public String getDescription() + { + return m_csc.getDescription(); + + } // end getDescription + +} // end class CommunityServiceDescriptor diff --git a/src/venice-base/com/silverwrist/venice/except/CommunityServiceException.java b/src/venice-base/com/silverwrist/venice/except/CommunityServiceException.java new file mode 100644 index 0000000..e995da7 --- /dev/null +++ b/src/venice-base/com/silverwrist/venice/except/CommunityServiceException.java @@ -0,0 +1,60 @@ +/* + * 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 . + * + * 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 , + * 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): + */ +package com.silverwrist.venice.except; + +import com.silverwrist.dynamo.except.ExternalException; + +public class CommunityServiceException extends ExternalException +{ + /*-------------------------------------------------------------------------------- + * Constructors + *-------------------------------------------------------------------------------- + */ + + /** + * Constructs a new CommunityServiceException instance. + * + * @param caller The classname of the class that's creating the exception. Its class loader + * and package name will be used, together with bundle, to find the + * resource bundle. + * @param bundle The name of the resource bundle to be loaded. + * @param message_id The identifier of the message to be loaded from the bundle. + */ + public CommunityServiceException(Class caller, String bundle, String message_id) + { + super(caller,bundle,message_id); + + } // end constructor + + /** + * Constructs a new CommunityServiceException instance. + * + * @param caller The classname of the class that's creating the exception. Its class loader + * and package name will be used, together with bundle, to find the + * resource bundle. + * @param bundle The name of the resource bundle to be loaded. + * @param message_id The identifier of the message to be loaded from the bundle. + * @param inner The exception to be nested inside this one. + */ + public CommunityServiceException(Class caller, String bundle, String message_id, Throwable inner) + { + super(caller,bundle,message_id,inner); + + } // end constructor + +} // end class CommunityServiceException diff --git a/src/venice-base/com/silverwrist/venice/iface/CommunityServiceController.java b/src/venice-base/com/silverwrist/venice/iface/CommunityServiceController.java new file mode 100644 index 0000000..6628e67 --- /dev/null +++ b/src/venice-base/com/silverwrist/venice/iface/CommunityServiceController.java @@ -0,0 +1,27 @@ +/* + * 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 . + * + * 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 , + * 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): + */ +package com.silverwrist.venice.iface; + +import com.silverwrist.dynamo.iface.ComponentShutdown; +import com.silverwrist.dynamo.iface.DynamicObject; + +public interface CommunityServiceController extends DynamicObject, ComponentShutdown +{ + public String getDescription(); + +} // end interface CommunityServiceController diff --git a/src/venice-base/com/silverwrist/venice/iface/VeniceCommunity.java b/src/venice-base/com/silverwrist/venice/iface/VeniceCommunity.java index 2a9bc80..fd89f12 100644 --- a/src/venice-base/com/silverwrist/venice/iface/VeniceCommunity.java +++ b/src/venice-base/com/silverwrist/venice/iface/VeniceCommunity.java @@ -20,6 +20,7 @@ package com.silverwrist.venice.iface; import java.security.Principal; import java.security.acl.AclNotFoundException; import java.util.Date; +import java.util.List; import com.silverwrist.dynamo.except.AuthenticationException; import com.silverwrist.dynamo.except.DatabaseException; import com.silverwrist.dynamo.except.DynamoSecurityException; @@ -313,4 +314,6 @@ public interface VeniceCommunity extends NamedObject, SecureObjectStore public boolean isAdministrator(DynamoUser user); + public List getServices() throws DatabaseException; + } // end interface VeniceCommunity