some of the underpinnings of community services

This commit is contained in:
Eric J. Bowersox 2003-06-15 19:02:26 +00:00
parent ce27befa54
commit 80d4ba4212
21 changed files with 657 additions and 11 deletions

View File

@ -434,6 +434,28 @@ CREATE TABLE commprops (
PRIMARY KEY (cid, nsid, prop_name) 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. # The master table of sideboxes.
CREATE TABLE sbox_master ( CREATE TABLE sbox_master (
sbid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # sidebox identifier 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' ); (4, 2, 'TEXT', 'Categories', 'SERVLET', 'find_categories.js.vs' );
UPDATE menuitems SET ifdef_var = 'use_categories' WHERE menuid = 4 AND sequence = 2; 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. # Create the sideboxes tables.
INSERT INTO sbox_master (sbid, sb_nsid, sb_name, type_nsid, type_name, descr) VALUES 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'), (1, 19, 'community.list', 19, 'community.list', 'Community Membership List'),

View File

@ -47,7 +47,8 @@ import com.silverwrist.dynamo.util.*;
public class ApplicationContainer public class ApplicationContainer
implements ResourceProvider, ResourceProviderManager, RendererRegistration, ObjectProvider, implements ResourceProvider, ResourceProviderManager, RendererRegistration, ObjectProvider,
EventListenerRegistration, OutputObjectFilterRegistration, QueryRenderer, PostDynamicUpdate, EventListenerRegistration, OutputObjectFilterRegistration, QueryRenderer, PostDynamicUpdate,
RenderImmediate, RequestPreprocessorRegistration, ExceptionTranslatorRegistration RenderImmediate, RequestPreprocessorRegistration, ExceptionTranslatorRegistration,
FinalStageRegistration
{ {
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Internal class recording renderer registrations and providing a * 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 HashMap m_update_listeners = new HashMap(); // update listeners
private Vector m_request_preprocessors = new Vector(); // request preprocessors private Vector m_request_preprocessors = new Vector(); // request preprocessors
private Vector m_exception_xlators = new Vector(); // exception translators 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 * Constructor
@ -219,6 +222,7 @@ public class ApplicationContainer
m_app_sm.addInitService(PostDynamicUpdate.class,(PostDynamicUpdate)this); m_app_sm.addInitService(PostDynamicUpdate.class,(PostDynamicUpdate)this);
m_app_sm.addInitService(RequestPreprocessorRegistration.class,(RequestPreprocessorRegistration)this); m_app_sm.addInitService(RequestPreprocessorRegistration.class,(RequestPreprocessorRegistration)this);
m_app_sm.addInitService(ExceptionTranslatorRegistration.class,(ExceptionTranslatorRegistration)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(ResourceProvider.class,(ResourceProvider)this);
m_app_sm.addRuntimeService(ObjectProvider.class,(ObjectProvider)this); m_app_sm.addRuntimeService(ObjectProvider.class,(ObjectProvider)this);
@ -327,6 +331,28 @@ public class ApplicationContainer
m_identity = buf.toString(); m_identity = buf.toString();
logger.info("Server: " + m_identity); 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. // Fire the "application initialized" events.
ApplicationListener[] listeners = ApplicationListener[] listeners =
(ApplicationListener[])(m_application_listeners.toArray(APP_LISTENER_TEMPLATE)); (ApplicationListener[])(m_application_listeners.toArray(APP_LISTENER_TEMPLATE));
@ -390,6 +416,16 @@ public class ApplicationContainer
} // end if } // 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()) if (logger.isDebugEnabled())
logger.debug("ApplicationContainer.destroy(): " + m_shutdown_list.size() + " objects to blow away"); logger.debug("ApplicationContainer.destroy(): " + m_shutdown_list.size() + " objects to blow away");
@ -981,6 +1017,26 @@ public class ApplicationContainer
} // end registerExceptionTranslator } // 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 * External operations
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -25,3 +25,4 @@ resource.rootErr=The resource root directory {0} does not exist.
mountRP.badName=Invalid mount path for resources: {0} mountRP.badName=Invalid mount path for resources: {0}
mountRP.already=Resource provider already mounted on path {0}. mountRP.already=Resource provider already mounted on path {0}.
registerRenderer.already=Renderer already registered for class {0}. registerRenderer.already=Renderer already registered for class {0}.
finalinit.fail=Final-stage initialization failed: {0}

View File

@ -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 <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):
*/
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

View File

@ -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 <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):
*/
package com.silverwrist.dynamo.iface;
public interface FinalStageRegistration
{
public boolean registerFinalStageInitHook(FinalStageInitHook hook);
public void registerPreStageShutdown(ComponentShutdown cs);
} // end interface FinalStageRegistration

View File

@ -19,6 +19,8 @@ package com.silverwrist.dynamo.iface;
public interface ModuleSite public interface ModuleSite
{ {
public String getFilename();
public ResourceProvider getResourceProvider(); public ResourceProvider getResourceProvider();
} // end interface ModuleSite } // end interface ModuleSite

View File

@ -49,6 +49,12 @@ class ModuleLoader extends URLClassLoader implements Module
*==================================================================== *====================================================================
*/ */
public String getFilename()
{
return m_filename;
} // end getFilename
public ResourceProvider getResourceProvider() public ResourceProvider getResourceProvider()
{ {
return (ResourceProvider)this; return (ResourceProvider)this;
@ -106,20 +112,22 @@ class ModuleLoader extends URLClassLoader implements Module
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private URL m_jar_url; private URL m_jar_url; // URL to the module JAR file
private String m_resource_path; private String m_filename; // filename of the original JAR file relative to module directory
private ModuleFunctions m_modfuncs; private String m_resource_path; // resource path for the JAR file
private boolean m_initialized = false; private ModuleFunctions m_modfuncs; // module functions (the bridge into the module)
private boolean m_initialized = false; // have we been initialized?
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructor * Constructor
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
ModuleLoader(File modfile) throws ModuleException, MalformedURLException ModuleLoader(File modfile, String filename) throws ModuleException, MalformedURLException
{ {
super(new URL[] { modfile.toURL() },ModuleLoader.class.getClassLoader()); super(new URL[] { modfile.toURL() },ModuleLoader.class.getClassLoader());
logger.info("Loading module " + modfile.getAbsolutePath()); logger.info("Loading module " + modfile.getAbsolutePath());
m_filename = filename;
String main_class_name = null; String main_class_name = null;
try try
{ // create a JAR URL and use it to get the JAR attributes { // create a JAR URL and use it to get the JAR attributes

View File

@ -198,7 +198,7 @@ public class ModuleManager implements NamedObject, ComponentInitialize, Componen
try try
{ // create a new ModuleLoader { // create a new ModuleLoader
rc = new ModuleLoader(mod_file); rc = new ModuleLoader(mod_file,name);
} // end try } // end try
catch (MalformedURLException e) catch (MalformedURLException e)

View File

@ -94,6 +94,7 @@ class CommunityImpl implements VeniceCommunity
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private CommunityManager m_base; // base object
private CommunityOps m_ops; // community operations object private CommunityOps m_ops; // community operations object
private NamespaceCache m_nscache; // namespace cache object private NamespaceCache m_nscache; // namespace cache object
private SecurityReferenceMonitor m_srm; // security reference monitor 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_lastaccessed; // date last accessed
private java.util.Date m_lastupdate; // date last updated private java.util.Date m_lastupdate; // date last updated
private ReferenceMap m_properties; // properties cache private ReferenceMap m_properties; // properties cache
private List m_service_list = null; // cached service list
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructors * Constructors
@ -141,9 +143,11 @@ class CommunityImpl implements VeniceCommunity
* corresponding to static fields of the * corresponding to static fields of the
* {@link com.silverwrist.venice.community.CommunityManagerOps CommunityManagerOps} object. * {@link com.silverwrist.venice.community.CommunityManagerOps CommunityManagerOps} object.
*/ */
CommunityImpl(CommunityOps ops, NamespaceCache nscache, SecurityReferenceMonitor srm, UserManagement users, CommunityImpl(CommunityManager base, CommunityOps ops, NamespaceCache nscache, SecurityReferenceMonitor srm,
AuthenticatorLookup alook, PostDynamicUpdate post, CategoryService cats, Map data) UserManagement users, AuthenticatorLookup alook, PostDynamicUpdate post, CategoryService cats,
Map data)
{ {
m_base = base;
m_ops = ops; m_ops = ops;
m_nscache = nscache; m_nscache = nscache;
m_srm = srm; m_srm = srm;
@ -1065,4 +1069,43 @@ class CommunityImpl implements VeniceCommunity
} // end isAdministrator } // 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; i<svcids.length; i++)
rc.add(m_base.getServiceForID(svcids[i]));
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
m_service_list = Collections.unmodifiableList(rc);
} // end if
else // just use the empty list as a return value
m_service_list = Collections.EMPTY_LIST;
} // end if
return m_service_list;
} // end getServices
} // end class CommunityImpl } // end class CommunityImpl

View File

@ -27,11 +27,13 @@ import com.silverwrist.dynamo.db.NamespaceCache;
import com.silverwrist.dynamo.db.UserManagement; import com.silverwrist.dynamo.db.UserManagement;
import com.silverwrist.dynamo.except.*; import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*; import com.silverwrist.dynamo.iface.*;
import com.silverwrist.dynamo.module.ModuleOperations;
import com.silverwrist.dynamo.security.SecurityReferenceMonitor; import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
import com.silverwrist.dynamo.util.*; import com.silverwrist.dynamo.util.*;
import com.silverwrist.venice.CommunitySearchField; import com.silverwrist.venice.CommunitySearchField;
import com.silverwrist.venice.SearchMode; import com.silverwrist.venice.SearchMode;
import com.silverwrist.venice.VeniceNamespaces; import com.silverwrist.venice.VeniceNamespaces;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.iface.*; import com.silverwrist.venice.iface.*;
public class CommunityManager public class CommunityManager
@ -140,6 +142,129 @@ public class CommunityManager
} // end class CommunitySerializer } // end class CommunitySerializer
/*--------------------------------------------------------------------------------
* Internal class that initializes the services
*--------------------------------------------------------------------------------
*/
private class ServiceInit implements FinalStageInitHook
{
/*====================================================================
* Constructor
*====================================================================
*/
ServiceInit()
{ // do nothing
} // end constructor
/*====================================================================
* Implementations from interface FinalStageInitHook
*====================================================================
*/
public void initialize(Application application, ServiceProvider services) throws DynamoException
{
logger.info("Initializing community service list");
List svclist = m_ops.getMasterServiceList();
ModuleOperations module_ops = (ModuleOperations)(services.queryService(ModuleOperations.class));
Iterator it = svclist.iterator();
while (it.hasNext())
{ // get the Map full of data
Map item = (Map)(it.next());
// make sure we have the module
PropertyKey pk = (PropertyKey)(item.get(CommunityManagerOps.KEY_MODNAME));
Module module = module_ops.findModule(m_ns_cache.namespaceIdToName(pk.getNamespaceID()),pk.getName());
if (module==null)
{ // the module is not loaded - we have to load it
String filename = (String)(item.get(CommunityManagerOps.KEY_MODFILENAME));
module = module_ops.loadModule(filename,true);
QualifiedNameKey modid = module.getModuleID();
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
CommunityServiceException cse = new CommunityServiceException(CommunityManager.class,"CommunityMessages",
"svc.modname.mismatch");
cse.setParameter(0,filename);
throw cse;
} // end if
} // end if
// now get the CommunityServiceController from the module
pk = (PropertyKey)(item.get(CommunityManagerOps.KEY_OBJNAME));
DynamicObject dobj = module.getProvidedObject(m_ns_cache.namespaceIdToName(pk.getNamespaceID()),pk.getName());
if (!(dobj instanceof CommunityServiceController))
{ // invalid controller object - throw exception
CommunityServiceException cse = new CommunityServiceException(CommunityManager.class,"CommunityMessages",
"svc.object.badType");
cse.setParameter(0,m_ns_cache.namespaceIdToName(pk.getNamespaceID()));
cse.setParameter(1,pk.getName());
throw cse;
} // end if
CommunityServiceController csc = (CommunityServiceController)dobj;
// preserve the descriptors
pk = (PropertyKey)(item.get(CommunityManagerOps.KEY_SVCNAME));
CommunityServiceDescriptor csdesc =
new CommunityServiceDescriptor((Integer)(item.get(CommunityManagerOps.KEY_SVCID)),
new QualifiedNameKey(m_ns_cache.namespaceIdToName(pk.getNamespaceID()),
pk.getName()),
(String)(item.get(CommunityManagerOps.KEY_SHORTVAR)),csc);
m_qname_to_service.put(csdesc.getName(),csdesc);
m_index_to_service.put(item.get(CommunityManagerOps.KEY_SVCID),csdesc);
} // end while
// Now register our ServiceShutdown class as a pre-stage shutdown hook.
FinalStageRegistration fsreg = (FinalStageRegistration)(services.queryService(FinalStageRegistration.class));
fsreg.registerPreStageShutdown(new ServiceShutdown());
} // end initialize
} // end class ServiceInit
/*--------------------------------------------------------------------------------
* Internal class that shuts down the services
*--------------------------------------------------------------------------------
*/
private class ServiceShutdown implements ComponentShutdown
{
/*====================================================================
* Constructor
*====================================================================
*/
ServiceShutdown()
{ // do nothing
} // end constructor
/*====================================================================
* Implementations from interface ComponentShutdown
*====================================================================
*/
public void shutdown()
{
LinkedList shut_list = new LinkedList(m_qname_to_service.values());
m_qname_to_service.clear();
m_index_to_service.clear();
while (shut_list.size()>0)
{ // shut down this community service
CommunityServiceController csc = ((CommunityServiceDescriptor)(shut_list.removeFirst())).getController();
csc.shutdown();
} // end while
} // end shutdown
} // end class ServiceShutdown
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Static data members * Static data members
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -162,6 +287,8 @@ public class CommunityManager
private CategoryService m_cats; // category service object private CategoryService m_cats; // category service object
private ReferenceMap m_id_to_comm; // ReferenceMap of community IDs to communities 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 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 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_id_to_comm = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT);
m_alias_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 } // end constructor
@ -307,6 +436,10 @@ public class CommunityManager
(PropertySerializerRegistration)(services.queryService(PropertySerializerRegistration.class)); (PropertySerializerRegistration)(services.queryService(PropertySerializerRegistration.class));
m_pszreg = psreg.registerPropertySerializer(new CommunitySerializer()); 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 } // end initialize
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
@ -379,7 +512,7 @@ public class CommunityManager
rc = (CommunityImpl)(m_alias_to_comm.get(data.get(CommunityManagerOps.KEY_ALIAS))); rc = (CommunityImpl)(m_alias_to_comm.get(data.get(CommunityManagerOps.KEY_ALIAS)));
if (rc==null) if (rc==null)
{ // create the CommunityImpl object { // 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 // poke the maps with the new object
m_id_to_comm.put(key,rc); m_id_to_comm.put(key,rc);
@ -416,7 +549,7 @@ public class CommunityManager
rc = (CommunityImpl)(m_id_to_comm.get(key)); rc = (CommunityImpl)(m_id_to_comm.get(key));
if (rc==null) if (rc==null)
{ // create the CommunityImpl object { // 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 // poke the maps with the new object
m_id_to_comm.put(key,rc); m_id_to_comm.put(key,rc);
@ -495,6 +628,38 @@ public class CommunityManager
} // end getNumCommunitiesInCategory } // 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 * Implementations from interface CommunityProxyService
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -43,6 +43,13 @@ abstract class CommunityManagerOps extends OpsBase
static final String KEY_ACCESS = "access"; static final String KEY_ACCESS = "access";
static final String KEY_UPDATE = "update"; 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 * Constructor
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -83,6 +90,8 @@ abstract class CommunityManagerOps extends OpsBase
abstract int searchNameCount(SearchMode mode, String term, boolean show_all) throws DatabaseException; abstract int searchNameCount(SearchMode mode, String term, boolean show_all) throws DatabaseException;
abstract List getMasterServiceList() throws DatabaseException;
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* External static operations * External static operations
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -22,6 +22,7 @@ import java.util.*;
import com.silverwrist.util.*; import com.silverwrist.util.*;
import com.silverwrist.dynamo.except.*; import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*; import com.silverwrist.dynamo.iface.*;
import com.silverwrist.dynamo.util.*;
import com.silverwrist.venice.CommunityVisibility; import com.silverwrist.venice.CommunityVisibility;
import com.silverwrist.venice.SearchMode; import com.silverwrist.venice.SearchMode;
@ -543,4 +544,52 @@ public class CommunityManagerOps_mysql extends CommunityManagerOps
} // end searchNameCount } // 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 } // end class CommunityManagerOps_mysql

View File

@ -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}." auth.revokeAccess=You are not authorized to revoke access grants in community "{0}."
join.disallowed=You are not permitted to join community "{0}." join.disallowed=You are not permitted to join community "{0}."
join.authFail=Unable to authenticate to community "{0}"; cannot join. 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.

View File

@ -80,4 +80,6 @@ abstract class CommunityOps extends OpsBase
abstract void deleteSingleUseAuthData(int cid, int ugid, boolean is_group) throws DatabaseException; abstract void deleteSingleUseAuthData(int cid, int ugid, boolean is_group) throws DatabaseException;
abstract int[] getServiceIDs(int cid) throws DatabaseException;
} // end class CommunityOps } // end class CommunityOps

View File

@ -1011,4 +1011,45 @@ class CommunityOps_mysql extends CommunityOps
} // end deleteSingleUseAuthData } // 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<tmp.size(); i++)
rc[i] = ((Integer)(tmp.get(i))).intValue();
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 getServiceIDs
} // end class CommunityOps_mysql } // end class CommunityOps_mysql

View File

@ -609,6 +609,12 @@ abstract class CommunityProxy implements VeniceCommunity, DynamicWrapper
} // end isAdministrator } // end isAdministrator
public List getServices() throws DatabaseException
{
return getRealCommunity().getServices();
} // end getServices
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface DynamicWrapper * Implementations from interface DynamicWrapper
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -50,4 +50,8 @@ public interface CommunityService
public int getNumCommunitiesInCategory(DynamoUser caller, VeniceCategory cat) throws DatabaseException; public int getNumCommunitiesInCategory(DynamoUser caller, VeniceCategory cat) throws DatabaseException;
public List getAvailableServices();
public CommunityServiceDescriptor getServiceForID(int id);
} // end interface CommunityService } // end interface CommunityService

View File

@ -0,0 +1,83 @@
/*
* 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):
*/
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

View File

@ -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 <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):
*/
package com.silverwrist.venice.except;
import com.silverwrist.dynamo.except.ExternalException;
public class CommunityServiceException extends ExternalException
{
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
/**
* Constructs a new <CODE>CommunityServiceException</CODE> instance.
*
* @param caller The classname of the class that's creating the exception. Its class loader
* and package name will be used, together with <CODE>bundle</CODE>, 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 <CODE>CommunityServiceException</CODE> instance.
*
* @param caller The classname of the class that's creating the exception. Its class loader
* and package name will be used, together with <CODE>bundle</CODE>, 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

View File

@ -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 <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):
*/
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

View File

@ -20,6 +20,7 @@ package com.silverwrist.venice.iface;
import java.security.Principal; import java.security.Principal;
import java.security.acl.AclNotFoundException; import java.security.acl.AclNotFoundException;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.silverwrist.dynamo.except.AuthenticationException; import com.silverwrist.dynamo.except.AuthenticationException;
import com.silverwrist.dynamo.except.DatabaseException; import com.silverwrist.dynamo.except.DatabaseException;
import com.silverwrist.dynamo.except.DynamoSecurityException; import com.silverwrist.dynamo.except.DynamoSecurityException;
@ -313,4 +314,6 @@ public interface VeniceCommunity extends NamedObject, SecureObjectStore
public boolean isAdministrator(DynamoUser user); public boolean isAdministrator(DynamoUser user);
public List getServices() throws DatabaseException;
} // end interface VeniceCommunity } // end interface VeniceCommunity