added the CommunityManager, the initial implementation of community objects,

and related supporting code and database material
This commit is contained in:
Eric J. Bowersox 2003-05-30 08:35:35 +00:00
parent 9218e24591
commit 4f62066e6b
23 changed files with 2902 additions and 106 deletions

View File

@ -169,6 +169,13 @@
<database connection="data"/> <database connection="data"/>
</object> </object>
<object name="communities" classname="com.silverwrist.venice.community.CommunityManager" priority="101">
<database connection="data" namespaces="nscache"/>
<security object="srm"/>
<user-manager object="users"/>
<providers categories="categories"/>
</object>
<!-- Additional objects for SourceID interface --> <!-- Additional objects for SourceID interface -->
<object name="sso" classname="com.silverwrist.venice.sourceid.FederationManagerObject" priority="20"> <object name="sso" classname="com.silverwrist.venice.sourceid.FederationManagerObject" priority="20">

View File

@ -168,6 +168,13 @@
<database connection="data"/> <database connection="data"/>
</object> </object>
<object name="communities" classname="com.silverwrist.venice.community.CommunityManager" priority="101">
<database connection="data" namespaces="nscache"/>
<security object="srm"/>
<user-manager object="users"/>
<providers categories="categories"/>
</object>
<!-- The Venice application layer --> <!-- The Venice application layer -->
<application name="venice" classname="com.silverwrist.venice.app.VeniceApplication"> <application name="venice" classname="com.silverwrist.venice.app.VeniceApplication">
<stylesheet-mappings> <stylesheet-mappings>

View File

@ -336,7 +336,9 @@ INSERT INTO namespaces (nsid, namespace) VALUES
(10, 'http://www.silverwrist.com/NS/venice/2002/12/31/user.settings' ), (10, 'http://www.silverwrist.com/NS/venice/2002/12/31/user.settings' ),
(11, 'http://www.silverwrist.com/NS/venice/2002/12/31/user.profile' ), (11, 'http://www.silverwrist.com/NS/venice/2002/12/31/user.profile' ),
(12, 'http://www.silverwrist.com/NS/venice/2003/01/03/system.mail.messages' ), (12, 'http://www.silverwrist.com/NS/venice/2003/01/03/system.mail.messages' ),
(13, 'http://www.silverwrist.com/NS/venice/2003/05/24/system.permissions' ); (13, 'http://www.silverwrist.com/NS/venice/2003/05/24/system.permissions' ),
(14, 'http://www.silverwrist.com/NS/venice/2003/05/28/community.permissions'),
(15, 'http://www.silverwrist.com/NS/venice/2003/05/29/community.profile' );
# Initial global properties setup # Initial global properties setup
INSERT INTO globalprop (nsid, prop_name, prop_value) VALUES INSERT INTO globalprop (nsid, prop_name, prop_value) VALUES
@ -359,7 +361,7 @@ INSERT INTO globalprop (nsid, prop_name, prop_value) VALUES
(2, 'sheet.base.normal', '!stylesheets/normal_base.vm' ), (2, 'sheet.base.normal', '!stylesheets/normal_base.vm' ),
(2, 'sheet.adv.normal', '!stylesheets/adv_base.vm' ), (2, 'sheet.adv.normal', '!stylesheets/adv_base.vm' ),
(5, 'smtp.host', '!localhost' ), (5, 'smtp.host', '!localhost' ),
(5, 'system.mail.from.addr', '!nobody@delenn.silverwrist.internal'), (5, 'system.mail.from.addr', '!nobody@delenn.silverwrist.internal' ),
(5, 'system.mail.from.name', '!Venice Mail System' ), (5, 'system.mail.from.name', '!Venice Mail System' ),
(5, 'mailer.name', '!Venice AutoMail System' ), (5, 'mailer.name', '!Venice AutoMail System' ),
(5, 'user.info.header', '!X-Venice-User-Info' ), (5, 'user.info.header', '!X-Venice-User-Info' ),
@ -414,7 +416,10 @@ INSERT INTO globalprop (nsid, prop_name, prop_value) VALUES
(11, 'privacy', '_OS:' ), (11, 'privacy', '_OS:' ),
(12, 'confirm.message.title', '!Venice E-Mail Confirmation' ), (12, 'confirm.message.title', '!Venice E-Mail Confirmation' ),
(12, 'password.change.message.title', '!Venice Password Changed' ), (12, 'password.change.message.title', '!Venice Password Changed' ),
(12, 'reminder.message.title', '!Venice Password Reminder Message' ); (12, 'reminder.message.title', '!Venice Password Reminder Message' ),
(15, 'rules', '!Please treat one another with courtesy and respect.'),
(15, 'language', '_LANG:en-US' ),
(15, 'country', '_CTRY:US' );
# Initial global blocks setup # Initial global blocks setup
INSERT INTO globalblock (nsid, block_name, block) VALUES INSERT INTO globalblock (nsid, block_name, block) VALUES
@ -583,7 +588,7 @@ INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES
(2, 1, 'set.block' ), (2, 1, 'set.block' ),
(2, 2, 'set.property' ), (2, 2, 'set.property' ),
(2, 3, 'edit.all' ), (2, 3, 'edit.all' ),
(2, 3, 'bypass.email.verify'), (2, 3, 'bypass.email.verify' ),
(2, 3, 'view.all' ), (2, 3, 'view.all' ),
(2, 5, 'set.property' ), (2, 5, 'set.property' ),
(2, 5, 'set.block' ), (2, 5, 'set.block' ),
@ -596,7 +601,10 @@ INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES
(2, 11, 'remove.property' ), (2, 11, 'remove.property' ),
(2, 12, 'set.property' ), (2, 12, 'set.property' ),
(2, 12, 'set.block' ), (2, 12, 'set.block' ),
(2, 13, 'show.admin.menu' ); (2, 13, 'show.admin.menu' ),
(2, 14, 'see.member.community.lists'),
(2, 14, 'community.directory.all' ),
(2, 14, 'community.search.all' );
INSERT INTO ace (aceid, pri, flags) VALUES (3, 2, 0); INSERT INTO ace (aceid, pri, flags) VALUES (3, 2, 0);
INSERT INTO acldata (aclid, seq, aceid) VALUES (2, 1, 3); INSERT INTO acldata (aclid, seq, aceid) VALUES (2, 1, 3);
INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES
@ -631,6 +639,68 @@ INSERT INTO auditevent (eventid, event_nsid, event_name, descr) VALUES
INSERT INTO imagetype (typecode, nsid, name) VALUES INSERT INTO imagetype (typecode, nsid, name) VALUES
(1, 11, 'user.photo'); (1, 11, 'user.photo');
# Create the "members" group for the initial community.
# (GID 4)
INSERT INTO groups (gid, groupname) VALUES (4, 'Members:piazza');
INSERT INTO groupmembers (gid, uid) VALUES (4, 1), (4, 2);
# Create the "hosts" group for the initial community.
# (GID 5)
INSERT INTO groups (gid, groupname) VALUES (5, 'Hosts:piazza');
INSERT INTO groupmembers (gid, uid) VALUES (5, 2);
# Create the ACL for the initial community members group. Only the community hosts and
# system administrators can add or remove members (without going through the "join" process).
# (ACL 3, ACEs 4 and 5)
INSERT INTO acl (aclid, aclname) VALUES (3, 'Members:piazza');
INSERT INTO aclowner (aclid, ownerid, flags) VALUES (3, 2, 0);
INSERT INTO ace (aceid, pri, flags) VALUES (4, 5, 1);
INSERT INTO acldata (aclid, seq, aceid) VALUES (3, 0, 4);
INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES
(4, 4, 'add.member' ),
(4, 4, 'remove.member');
INSERT INTO ace (aceid, pri, flags) VALUES (5, 1, 1);
INSERT INTO acldata (aclid, seq, aceid) VALUES (3, 1, 5);
INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES
(5, 4, 'add.member' ),
(5, 4, 'remove.member');
UPDATE groups SET gaclid = 3 WHERE gid = 4;
# Create the ACL for the initial community hosts group. Only the community "main host"
# and system administrators can add or remove members.
# (ACL 4, ACEs 6 and 7)
INSERT INTO acl (aclid, aclname) VALUES (4, 'Hosts:piazza');
INSERT INTO aclowner (aclid, ownerid, flags) VALUES (4, 2, 0);
INSERT INTO ace (aceid, pri, flags) VALUES (6, 2, 0);
INSERT INTO acldata (aclid, seq, aceid) VALUES (4, 0, 6);
INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES
(6, 4, 'add.member' ),
(6, 4, 'remove.member');
INSERT INTO ace (aceid, pri, flags) VALUES (7, 1, 1);
INSERT INTO acldata (aclid, seq, aceid) VALUES (4, 1, 7);
INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES
(7, 4, 'add.member' ),
(7, 4, 'remove.member');
UPDATE groups SET gaclid = 4 WHERE gid = 5;
# Create the ACL for the initial community.
# (ACL 5, ACEs 8, 9)
INSERT INTO acl (aclid, aclname) VALUES (5, 'ACL:piazza');
INSERT INTO aclowner (aclid, ownerid, flags) VALUES (5, 5, 1);
INSERT INTO ace (aceid, pri, flags) VALUES (8, 2, 0);
INSERT INTO acldata (aclid, seq, aceid) VALUES (5, 0, 8);
INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES
(8, 15, 'remove.property');
INSERT INTO ace (aceid, pri, flags) VALUES (9, 5, 1);
INSERT INTO acldata (aclid, seq, aceid) VALUES (5, 1, 9);
INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES
(9, 14, 'grant.revoke.access'),
(9, 15, 'set.category' ),
(9, 15, 'set.visibility' ),
(9, 15, 'set.name' ),
(9, 15, 'set.alias' ),
(9, 15, 'set.property' );
#### following this line is initialization of Venice-specific tables #### #### following this line is initialization of Venice-specific tables ####
# Populate the Category table. # Populate the Category table.
@ -1005,6 +1075,22 @@ INSERT INTO refcategory (catid, parent, symlink, name) VALUES
UPDATE refcategory SET dontuse = 1 WHERE catid = 15; UPDATE refcategory SET dontuse = 1 WHERE catid = 15;
# Create the initial community entry.
# (CID 1)
INSERT INTO communities (cid, member_gid, host_gid, host_uid, aclid, name, alias, createdate)
VALUES (1, 4, 5, 2, 5, 'La Piazza', 'piazza', '05-27-2003 09:00:00');
# Create the properties for the initial community.
INSERT INTO commprops (cid, nsid, prop_name, prop_value) VALUES
(1, 15, 'synopsis', '!A gathering place for Venice users.' ),
(1, 15, 'rules', '!Please treat one another with courtesy and respect.'),
(1, 15, 'language', '_LANG:en-US' ),
(1, 15, 'locality', '!Anywhere' ),
(1, 15, 'region', '!XX' ),
(1, 15, 'postal.code', '!00000' ),
(1, 15, 'country', '_CTRY:US' ),
(1, 15, 'url.homepage', '!http://venice.sourceforge.net' );
# Create the "global" menu. (ID #1) # Create the "global" menu. (ID #1)
INSERT INTO menus (menuid, menu_nsid, menu_name, title, subtitle) INSERT INTO menus (menuid, menu_nsid, menu_name, title, subtitle)
VALUES (1, 1, 'fixed.menu', 'About This Site', NULL); VALUES (1, 1, 'fixed.menu', 'About This Site', NULL);

View File

@ -11,7 +11,7 @@
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
@ -33,7 +33,7 @@ class DefaultHashAuthenticator implements Authenticator
} // end constructor } // end constructor
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* IMplementations from interface Authenticator * Implementations from interface Authenticator
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */

View File

@ -11,7 +11,7 @@
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
@ -30,7 +30,7 @@ import com.silverwrist.dynamo.util.*;
public class UserManagerObject public class UserManagerObject
implements NamedObject, ComponentInitialize, ComponentShutdown, UserManagement, UserProxyManagement, implements NamedObject, ComponentInitialize, ComponentShutdown, UserManagement, UserProxyManagement,
AuthenticatorRegistration, UserInfoNamespace, UserPropertyTranslatorInstall AuthenticatorLookup, AuthenticatorRegistration, UserInfoNamespace, UserPropertyTranslatorInstall
{ {
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Internal class implementing user proxies * Internal class implementing user proxies
@ -341,6 +341,7 @@ public class UserManagerObject
private Object m_groups_sync = new Object(); // synchronization for group HashMaps private Object m_groups_sync = new Object(); // synchronization for group HashMaps
private Hashtable m_authenticators = new Hashtable(); // authenticators list private Hashtable m_authenticators = new Hashtable(); // authenticators list
private ComponentShutdown m_hook_init; // hook for init service provider private ComponentShutdown m_hook_init; // hook for init service provider
private ComponentShutdown m_hook_rt; // hook for runtime service provider
private ComponentShutdown m_pszreg; // property serializer registration private ComponentShutdown m_pszreg; // property serializer registration
private ComponentShutdown m_evt_user; // event registration private ComponentShutdown m_evt_user; // event registration
@ -443,10 +444,15 @@ public class UserManagerObject
// Add us to the initialization services. // Add us to the initialization services.
HookServiceProviders hooker = (HookServiceProviders)(services.queryService(HookServiceProviders.class)); HookServiceProviders hooker = (HookServiceProviders)(services.queryService(HookServiceProviders.class));
SingletonServiceProvider ssp = new SingletonServiceProvider("UserManagerObject", SimpleServiceProvider esp = new SimpleServiceProvider("UserManagerObject");
AuthenticatorRegistration.class, esp.addService(AuthenticatorRegistration.class,(AuthenticatorRegistration)this);
(AuthenticatorRegistration)this); esp.addService(AuthenticatorLookup.class,(AuthenticatorLookup)this);
m_hook_init = hooker.hookInitServiceProvider(ssp); m_hook_init = hooker.hookInitServiceProvider(esp);
// Add us to the runtime services as well.
SingletonServiceProvider ssp = new SingletonServiceProvider("UserManagerObject",AuthenticatorLookup.class,
(AuthenticatorLookup)this);
m_hook_rt = hooker.hookRuntimeServiceProvider(ssp);
} // end initialize } // end initialize
@ -461,6 +467,8 @@ public class UserManagerObject
m_evt_user = null; m_evt_user = null;
m_pszreg.shutdown(); m_pszreg.shutdown();
m_pszreg = null; m_pszreg = null;
m_hook_rt.shutdown();
m_hook_rt = null;
m_hook_init.shutdown(); m_hook_init.shutdown();
m_hook_init = null; m_hook_init = null;
m_authenticators.clear(); m_authenticators.clear();

View File

@ -0,0 +1,61 @@
/*
* 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.util;
import java.util.*;
public final class DateObjectPair
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private Object m_object;
private java.util.Date m_date;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public DateObjectPair(Object obj, java.util.Date date)
{
m_object = obj;
m_date = date;
} // end constructor
/*--------------------------------------------------------------------------------
* Public getters
*--------------------------------------------------------------------------------
*/
public Object getObject()
{
return m_object;
} // end getObject
public java.util.Date getDate()
{
return m_date;
} // end getDate
} // end class DateObjectPair

View File

@ -58,4 +58,10 @@ public interface VeniceNamespaces
public static final String SYSTEM_PERMS_NAMESPACE = public static final String SYSTEM_PERMS_NAMESPACE =
"http://www.silverwrist.com/NS/venice/2003/05/24/system.permissions"; "http://www.silverwrist.com/NS/venice/2003/05/24/system.permissions";
public static final String COMMUNITY_PERMS_NAMESPACE =
"http://www.silverwrist.com/NS/venice/2003/05/28/community.permissions";
public static final String COMMUNITY_PROFILE_NAMESPACE =
"http://www.silverwrist.com/NS/venice/2003/05/29/community.profile";
} // end interface VeniceNamespaces } // end interface VeniceNamespaces

View File

@ -146,7 +146,7 @@ public class CategoryManager implements NamedObject, ComponentInitialize, Compon
} // end try } // end try
catch (XMLLoadException e) catch (XMLLoadException e)
{ // error loading XML config data { // error loading XML config data
logger.fatal("XML loader exception in StandardContentSupplier",e); logger.fatal("XML loader exception in CategoryManager",e);
throw new ConfigException(e); throw new ConfigException(e);
} // end catch } // end catch
@ -167,6 +167,7 @@ public class CategoryManager implements NamedObject, ComponentInitialize, Compon
public void shutdown() public void shutdown()
{ {
m_categories.clear(); m_categories.clear();
m_ops.dispose();
m_ops = null; m_ops = null;
} // end shutdown } // end shutdown

View File

@ -0,0 +1,541 @@
/*
* 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 java.security.Principal;
import java.security.acl.AclNotFoundException;
import java.util.*;
import org.apache.commons.collections.*;
import org.apache.log4j.Logger;
import com.silverwrist.dynamo.db.NamespaceCache;
import com.silverwrist.dynamo.db.UserManagement;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
import com.silverwrist.dynamo.util.*;
import com.silverwrist.venice.CommunityVisibility;
import com.silverwrist.venice.VeniceNamespaces;
import com.silverwrist.venice.event.*;
import com.silverwrist.venice.iface.*;
class CommunityImpl implements VeniceCommunity
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Logger logger = Logger.getLogger(CommunityImpl.class);
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityOps m_ops; // community operations object
private NamespaceCache m_nscache; // namespace cache object
private SecurityReferenceMonitor m_srm; // security reference monitor
private UserManagement m_users; // user management object
private AuthenticatorLookup m_alook; // authenticator lookup object
private PostDynamicUpdate m_post; // where we post dynamic update events
private CategoryService m_cats; // category service object
private int m_id; // community ID
private int m_member_gid; // member group ID
private int m_host_gid; // hosts group ID
private int m_host_uid; // primary host UID
private int m_aclid; // ID of the community ACL
private int m_catid; // category ID for the community
private CommunityVisibility m_visibility; // community visibility
private String m_name; // community name
private String m_alias; // community alias
private java.util.Date m_created; // date created
private java.util.Date m_lastaccessed; // date last accessed
private java.util.Date m_lastupdate; // date last updated
private ReferenceMap m_properties; // properties cache
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
CommunityImpl(CommunityOps ops, NamespaceCache nscache, SecurityReferenceMonitor srm, UserManagement users,
AuthenticatorLookup alook, PostDynamicUpdate post, CategoryService cats, Map data)
{
m_ops = ops;
m_nscache = nscache;
m_srm = srm;
m_users = users;
m_alook = alook;
m_post = post;
m_cats = cats;
m_id = ((Integer)(data.get(CommunityManagerOps.KEY_CID))).intValue();
m_member_gid = ((Integer)(data.get(CommunityManagerOps.KEY_MEMBER_GID))).intValue();
m_host_gid = ((Integer)(data.get(CommunityManagerOps.KEY_HOST_GID))).intValue();
m_host_uid = ((Integer)(data.get(CommunityManagerOps.KEY_HOST_UID))).intValue();
m_aclid = ((Integer)(data.get(CommunityManagerOps.KEY_ACLID))).intValue();
m_catid = ((Integer)(data.get(CommunityManagerOps.KEY_CATID))).intValue();
m_visibility = (CommunityVisibility)(data.get(CommunityManagerOps.KEY_VISIBILITY));
m_name = (String)(data.get(CommunityManagerOps.KEY_NAME));
m_alias = (String)(data.get(CommunityManagerOps.KEY_ALIAS));
m_created = (java.util.Date)(data.get(CommunityManagerOps.KEY_CREATE));
m_lastaccessed = (java.util.Date)(data.get(CommunityManagerOps.KEY_ACCESS));
m_lastupdate = (java.util.Date)(data.get(CommunityManagerOps.KEY_UPDATE));
m_properties = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT);
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private final void testPermission(DynamoUser caller, String perm_namespace, String perm_name,
String fail_message) throws DatabaseException, DynamoSecurityException
{
try
{ // perform security tests...
if (caller.equals(m_srm.getAdminUser()))
return; // Administrator can do anything
if (m_srm.getAcl(m_aclid).testPermission(caller,perm_namespace,perm_name))
return; // we have the right permission in the community ACL
if (m_srm.getGlobalAcl().testPermission(caller,perm_namespace,perm_name))
return; // or we can be authorized by the global ACL
} // end try
catch (AclNotFoundException e)
{ // just fall through and throw the exception
} // end catch
// throw the DynamoSecurityException
DynamoSecurityException d = new DynamoSecurityException(CommunityImpl.class,"CommunityMessages",fail_message);
d.setParameter(0,m_name);
throw d;
} // end testPermission
/*--------------------------------------------------------------------------------
* Overrides from class Object
*--------------------------------------------------------------------------------
*/
public boolean equals(Object o)
{
if (o==null)
return false;
if (o instanceof VeniceCommunity)
return (((VeniceCommunity)o).getCID()==m_id);
return false;
} // end equals
public int hashCode()
{
return m_id;
} // end hashCode
public String toString()
{
return "Community \"" + m_name + "\"";
} // end toString
/*--------------------------------------------------------------------------------
* Implementations from interface NamedObject
*--------------------------------------------------------------------------------
*/
/**
* Returns the name of this community.
*
* @return The name of this community.
*/
public String getName()
{
return m_name;
} // end getName
/*--------------------------------------------------------------------------------
* Implementations from interface ObjectProvider
*--------------------------------------------------------------------------------
*/
/**
* Retrieves an object from this <CODE>ObjectProvider</CODE>.
*
* @param namespace The namespace to interpret the name relative to.
* @param name The name of the object to be retrieved.
* @return The object reference specified.
*/
public Object getObject(String namespace, String name)
{
try
{ // convert the namespace name to an ID here
PropertyKey key = new PropertyKey(m_nscache.namespaceNameToId(namespace),name);
Object rc = null;
synchronized (this)
{ // start by looking in the properties map
rc = m_properties.get(key);
if (rc==null)
{ // no use - need to try the database
rc = m_ops.getProperty(m_id,key);
if (rc!=null)
m_properties.put(key,rc);
} // end if
} // end synchronized block
if (rc==null)
throw new NoSuchObjectException(this.toString(),namespace,name);
return rc;
} // end try
catch (DatabaseException e)
{ // translate into our NoSuchObjectException but retain the DatabaseException
throw new NoSuchObjectException(this.toString(),namespace,name,e);
} // end catch
} // end getObject
/*--------------------------------------------------------------------------------
* Implementations from interface SecureObjectStore
*--------------------------------------------------------------------------------
*/
public Object setObject(DynamoUser caller, String namespace, String name, Object value)
throws DatabaseException, DynamoSecurityException
{
testPermission(caller,namespace,"set.property","auth.setProperty");
DateObjectPair rc = null;
// convert the namespace name to an ID here
PropertyKey key = new PropertyKey(m_nscache.namespaceNameToId(namespace),name);
synchronized (this)
{ // start by setting the database value
rc = m_ops.setProperty(m_id,key,value);
// and cache it, too
m_properties.put(key,value);
// and save off the update date/time
m_lastaccessed = m_lastupdate = rc.getDate();
} // end synchronized block
m_post.postUpdate(new CommunityPropertyUpdateEvent(this,namespace,name));
return rc.getObject();
} // end setObject
public Object removeObject(DynamoUser caller, String namespace, String name)
throws DatabaseException, DynamoSecurityException
{
testPermission(caller,namespace,"remove.property","sec.removeGlobalProperty");
DateObjectPair rc = null;
// convert the namespace name to an ID here
PropertyKey key = new PropertyKey(m_nscache.namespaceNameToId(namespace),name);
synchronized (this)
{ // start by killing the database value
rc = m_ops.removeProperty(m_id,key);
// and remove the cached value, too
m_properties.remove(key);
if (rc!=null) // save off update date.time
m_lastaccessed = m_lastupdate = rc.getDate();
} // end synchronized block
m_post.postUpdate(new CommunityPropertyUpdateEvent(this,namespace,name));
return (rc==null) ? null : rc.getObject();
} // end removeObject
public Collection getNamespaces() throws DatabaseException
{
// call through to the database to get the list of namespace IDs
int[] ids = m_ops.getPropertyNamespaceIDs(m_id);
ArrayList rc = new ArrayList(ids.length);
for (int i=0; i<ids.length; i++)
rc.add(m_nscache.namespaceIdToName(ids[i]));
return Collections.unmodifiableList(rc);
} // end getNamespaces
public Collection getNamesForNamespace(String namespace) throws DatabaseException
{
// call through to the database to get the data for this namespace
int nsid = m_nscache.namespaceNameToId(namespace);
Map data = m_ops.getAllProperties(m_id,nsid);
// we both create the return value and cache the data values
ArrayList rc = new ArrayList(data.size());
synchronized (this)
{ // do the transfer...
Iterator it = data.entrySet().iterator();
while (it.hasNext())
{ // copy one entry at a time
Map.Entry ntry = (Map.Entry)(it.next());
rc.add(ntry.getKey().toString());
m_properties.put(new PropertyKey(nsid,ntry.getKey().toString()),ntry.getValue());
} // end while
} // end synchronized block
return Collections.unmodifiableList(rc);
} // end getNamesForNamespace
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceCommunity
*--------------------------------------------------------------------------------
*/
public int getCID()
{
return m_id;
} // end getCID
public int getMemberGID()
{
return m_member_gid;
} // end getMemberGID
public DynamoGroup getMemberGroup() throws DatabaseException
{
return m_users.getGroup(m_member_gid);
} // end getMemberGroup
public int getHostGID()
{
return m_host_gid;
} // end getHostGID
public DynamoGroup getHostGroup() throws DatabaseException
{
return m_users.getGroup(m_host_gid);
} // end getHostGroup
public int getHostUID()
{
return m_host_uid;
} // end getHostUID
public DynamoUser getHostUser() throws DatabaseException
{
return m_users.getUser(m_host_uid);
} // end getHostUser
public DynamoAcl getAcl() throws DatabaseException, AclNotFoundException
{
return m_srm.getAcl(m_aclid);
} // end getAcl
public int getCategoryID()
{
return m_catid;
} // end getCategoryID
public VeniceCategory getCategory() throws DatabaseException
{
return m_cats.getCategory(m_catid);
} // end getCategory
public synchronized void setCategoryID(DynamoUser caller, int catid)
throws DatabaseException, DynamoSecurityException
{
testPermission(caller,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"set.category","auth.setCategory");
java.util.Date update = m_ops.setCategoryID(m_id,catid);
m_catid = catid;
m_lastaccessed = m_lastupdate = update;
m_post.postUpdate(new CommunityBaseUpdateEvent(this,"category"));
} // end setCategoryID
public void setCategory(DynamoUser caller, VeniceCategory cat) throws DatabaseException, DynamoSecurityException
{
this.setCategoryID(caller,cat.getCategoryID());
} // end setCategory
public CommunityVisibility getVisibility()
{
return m_visibility;
} // end getVisibility
public synchronized void setVisibility(DynamoUser caller, CommunityVisibility vis)
throws DatabaseException, DynamoSecurityException
{
testPermission(caller,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"set.visibility","auth.setVisibility");
java.util.Date update = m_ops.setVisibility(m_id,vis);
m_visibility = vis;
m_lastaccessed = m_lastupdate = update;
m_post.postUpdate(new CommunityBaseUpdateEvent(this,"visibility"));
} // end setVisibility
public synchronized void setName(DynamoUser caller, String name) throws DatabaseException, DynamoSecurityException
{
testPermission(caller,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"set.name","auth.setName");
java.util.Date update = m_ops.setName(m_id,name);
m_name = name;
m_lastaccessed = m_lastupdate = update;
m_post.postUpdate(new CommunityBaseUpdateEvent(this,"name"));
} // end setName
public String getAlias()
{
return m_alias;
} // end getAlias
public synchronized void setAlias(DynamoUser caller, String alias) throws DatabaseException, DynamoSecurityException
{
testPermission(caller,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"set.alias","auth.setAlias");
java.util.Date update = m_ops.setAlias(m_id,alias);
m_alias = alias;
m_lastaccessed = m_lastupdate = update;
m_post.postUpdate(new CommunityBaseUpdateEvent(this,"alias"));
} // end setAlias
public java.util.Date getCreationDate()
{
return m_created;
} // end getCreationDate
public java.util.Date getLastAccessDate()
{
return m_lastaccessed;
} // end getLastAccessDate
public synchronized void setLastAccessDate(DynamoUser caller, java.util.Date date) throws DatabaseException
{
m_ops.setLastAccessDate(m_id,date);
m_lastaccessed = date;
} // end setLastAccessedDate
public java.util.Date getLastUpdateDate()
{
return m_lastupdate;
} // end getLastUpdateDate
public synchronized void setLastUpdateDate(DynamoUser caller, java.util.Date date) throws DatabaseException
{
m_ops.setLastUpdateDate(m_id,date);
m_lastaccessed = m_lastupdate = date;
} // end setLastUpdateDate
public void grantAccess(DynamoUser caller, Principal subject, String auth_namespace, String auth_name,
String source_info, String auth_info, boolean single_use)
throws AuthenticationException, DatabaseException, DynamoSecurityException
{
testPermission(caller,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,"grant.revoke.access","auth.grantAccess");
// Translate the subject into an ID and group flag.
int ugid = -1;
boolean is_group = false;
if (subject instanceof DynamoUser)
ugid = ((DynamoUser)subject).getUID();
else if (subject instanceof DynamoGroup)
{ // it's a group
ugid = ((DynamoGroup)subject).getGID();
is_group = true;
} // end else if
else
throw new IllegalArgumentException("invalid subject");
// Make sure the authenticator is valid.
int auth_nsid = 0;
Authenticator auth = null;
if ((auth_namespace!=null) || (auth_name!=null))
{ // look up the authenticator to make sure it's registered
auth = m_alook.findAuthenticator(auth_namespace,auth_name);
if (auth==null)
throw new IllegalArgumentException("invalid authenticator");
auth_nsid = m_nscache.namespaceNameToId(auth_namespace);
} // end if
// Preprocess the authentication information through the authenticator.
String real_auth_info = auth_info;
if ((auth_info!=null) && (auth!=null))
real_auth_info = auth.processInputData(auth_info);
synchronized (this)
{ // update the access table and touch the community
java.util.Date update = m_ops.grantAccess(m_id,ugid,is_group,single_use,auth_nsid,auth_name,source_info,
real_auth_info);
m_lastaccessed = m_lastupdate = update;
} // end synchronized block
} // end grantAccess
public void revokeAccess(DynamoUser caller, Principal subject) throws DatabaseException, DynamoSecurityException
{
testPermission(caller,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,"grant.revoke.access","auth.revokeAccess");
// Translate the subject into an ID and group flag.
int ugid = -1;
boolean is_group = false;
if (subject instanceof DynamoUser)
ugid = ((DynamoUser)subject).getUID();
else if (subject instanceof DynamoGroup)
{ // it's a group
ugid = ((DynamoGroup)subject).getGID();
is_group = true;
} // end else if
else
throw new IllegalArgumentException("invalid subject");
synchronized (this)
{ // update the access table and touch the community
java.util.Date update = m_ops.revokeAccess(m_id,ugid,is_group);
m_lastaccessed = m_lastupdate = update;
} // end synchronized block
} // end revokeAccess
} // end class CommunityImpl

View File

@ -0,0 +1,373 @@
/*
* 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 java.util.*;
import org.apache.commons.collections.*;
import org.apache.log4j.Logger;
import org.w3c.dom.*;
import com.silverwrist.util.*;
import com.silverwrist.util.xml.*;
import com.silverwrist.dynamo.db.NamespaceCache;
import com.silverwrist.dynamo.db.UserManagement;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
import com.silverwrist.dynamo.util.*;
import com.silverwrist.venice.CommunitySearchField;
import com.silverwrist.venice.SearchMode;
import com.silverwrist.venice.VeniceNamespaces;
import com.silverwrist.venice.iface.*;
public class CommunityManager implements NamedObject, ComponentInitialize, ComponentShutdown, CommunityService
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Logger logger = Logger.getLogger(CommunityManager.class);
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String m_name; // this object's name
private CommunityManagerOps m_ops; // database operations object
private NamespaceCache m_ns_cache; // namespace cache object
private SecurityReferenceMonitor m_srm; // security reference monitor
private UserManagement m_users; // user management object
private AuthenticatorLookup m_alook; // authenticator lookup
private PostDynamicUpdate m_post; // where we post dynamic updates
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
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public CommunityManager()
{
m_id_to_comm = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT);
m_alias_to_comm = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT);
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private final List translateCIDArray(int[] array) throws DatabaseException
{
if (array.length==0)
return Collections.EMPTY_LIST;
ArrayList rc = new ArrayList(array.length);
for (int i=0; i<array.length; i++)
rc.add(this.getCommunity(array[i]));
return Collections.unmodifiableList(rc);
} // end translateCIDArray
private final boolean canGetMemberCommunityList(DynamoUser caller, DynamoUser user) throws DatabaseException
{
if (caller.equals(user))
return true; // a user can always get his OWN member community list
if (m_srm.getGlobalAcl().testPermission(caller,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,
"see.member.community.lists"))
return true; // this user is permitted to see all member community lists
// Get the user's privacy flags and see if they're allowing others to see their member community list.
OptionSet oset = (OptionSet)(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"privacy"));
return oset.get(5);
} // end canGetMemberCommunityList
/*--------------------------------------------------------------------------------
* Implementations from interface NamedObject
*--------------------------------------------------------------------------------
*/
public String getName()
{
return m_name;
} // end getName
/*--------------------------------------------------------------------------------
* Implementations from interface ComponentInitialize
*--------------------------------------------------------------------------------
*/
/**
* Initialize the component.
*
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
* particular component. This is to be considered "read-only" by the component.
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
* which provides initialization services to the component. This will include an implementation
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
* get information about other objects previously initialized by the application.
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
* configuration.
*/
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
{
logger.info("CommunityManager initializing");
XMLLoader loader = XMLLoader.get();
String name_pool = null, name_nscache = null, name_srm = null, name_users = null, name_cats = null;
try
{ // verify the right node name
loader.verifyNodeName(config_root,"object");
// get the object's name
m_name = loader.getAttribute(config_root,"name");
// get the name of the database pool and namespace cache
DOMElementHelper config_root_h = new DOMElementHelper(config_root);
Element foo = loader.getSubElement(config_root_h,"database");
name_pool = loader.getAttribute(foo,"connection");
name_nscache = loader.getAttribute(foo,"namespaces");
// get the name of the security reference monitor
foo = loader.getSubElement(config_root_h,"security");
name_srm = loader.getAttribute(foo,"object");
// get the name of the user manager
foo = loader.getSubElement(config_root_h,"user-manager");
name_users = loader.getAttribute(foo,"object");
// get the name of the categories object
foo = loader.getSubElement(config_root_h,"providers");
name_cats = loader.getAttribute(foo,"categories");
} // end try
catch (XMLLoadException e)
{ // error loading XML config data
logger.fatal("XML loader exception in CommunityManager",e);
throw new ConfigException(e);
} // end catch
// Get the database connection pool.
DBConnectionPool pool = GetObjectUtils.getDatabaseConnection(services,name_pool);
// Get the operations object.
m_ops = CommunityManagerOps.get(pool);
// Get the namespace cache.
m_ns_cache = (NamespaceCache)(GetObjectUtils.getDynamoComponent(services,NamespaceCache.class,name_nscache));
// Get the security reference monitor.
m_srm = (SecurityReferenceMonitor)(GetObjectUtils.getDynamoComponent(services,SecurityReferenceMonitor.class,
name_srm));
// Get the user management object.
m_users = (UserManagement)(GetObjectUtils.getDynamoComponent(services,UserManagement.class,name_users));
// Get the category service object.
m_cats = (CategoryService)(GetObjectUtils.getDynamoComponent(services,CategoryService.class,name_cats));
// Get the authenticator lookup service.
m_alook = (AuthenticatorLookup)(services.queryService(AuthenticatorLookup.class));
// Get the dynamic update poster.
m_post = (PostDynamicUpdate)(services.queryService(PostDynamicUpdate.class));
} // end initialize
/*--------------------------------------------------------------------------------
* Implementations from interface ComponentShutdown
*--------------------------------------------------------------------------------
*/
public void shutdown()
{
m_id_to_comm.clear();
m_alias_to_comm.clear();
m_cats = null;
m_users = null;
m_srm = null;
m_ns_cache = null;
m_ops.dispose();
m_ops = null;
} // end shutdown
/*--------------------------------------------------------------------------------
* Implementations from interface CommunityService
*--------------------------------------------------------------------------------
*/
public List getMemberCommunities(DynamoUser caller, DynamoUser user)
throws DatabaseException, DynamoSecurityException
{
if (!(canGetMemberCommunityList(caller,user)))
{ // not permitted - bye!
DynamoSecurityException dse = new DynamoSecurityException(CommunityManager.class,"CommunityMessages",
"auth.getCommList");
dse.setParameter(0,user.getName());
throw dse;
} // end if
// call down to ops object, then translate the returned CIDs into VeniceCommunity objects
return translateCIDArray(m_ops.getMemberCommunityIDs(user.getUID()));
} // end getMemberCommunities
public synchronized VeniceCommunity getCommunity(int cid) throws DatabaseException
{
Integer key = new Integer(cid);
CommunityImpl rc = (CommunityImpl)(m_id_to_comm.get(key));
if (rc==null)
{ // look up the community's information in the database
Map data = m_ops.lookupCommunity(cid);
if (data==null)
{ // community not found
DatabaseException de = new DatabaseException(CommunityManager.class,"CommunityMessages","cid.notfound");
de.setParameter(0,String.valueOf(cid));
throw de;
} // end if
// The object might have been erased from the ID map but not the alias map. Check there.
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);
// poke the maps with the new object
m_id_to_comm.put(key,rc);
m_alias_to_comm.put(rc.getAlias(),rc);
} // end if
else // put it back into the ID map
m_id_to_comm.put(key,rc);
} // end if
else // put it into the "alias" map, as it might have been removed from there
m_alias_to_comm.put(rc.getAlias(),rc);
return (VeniceCommunity)rc;
} // end getCommunity
public VeniceCommunity getCommunity(String alias) throws DatabaseException
{
CommunityImpl rc = (CommunityImpl)(m_alias_to_comm.get(alias));
if (rc==null)
{ // look up the community's information in the database
Map data = m_ops.lookupCommunity(alias);
if (data==null)
{ // community not found
DatabaseException de = new DatabaseException(CommunityManager.class,"CommunityMessages","alias.notfound");
de.setParameter(0,alias);
throw de;
} // end if
// The object might have been erased from the alias map but not the ID map. Check there.
Integer key = (Integer)(data.get(CommunityManagerOps.KEY_CID));
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);
// poke the maps with the new object
m_id_to_comm.put(key,rc);
m_alias_to_comm.put(rc.getAlias(),rc);
} // end if
else // put it back into the alias map
m_alias_to_comm.put(rc.getAlias(),rc);
} // end if
else // put it into the "ID" map, as it might have been removed from there
m_id_to_comm.put(new Integer(rc.getCID()),rc);
return (VeniceCommunity)rc;
} // end getCommunity
public List searchForCommunities(DynamoUser caller, CommunitySearchField field, SearchMode mode, String term,
int offset, int count) throws DatabaseException
{
boolean show_all = m_srm.getGlobalAcl().testPermission(caller,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,
"community.search.all");
int[] rc = null;
if (CommunitySearchField.NAME.equals(field))
rc = m_ops.searchName(mode,term,show_all,offset,count);
else if (CommunitySearchField.SYNOPSIS.equals(field))
rc = m_ops.searchProperty(m_ns_cache.namespaceNameToId(VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE),"synopsis",
mode,term,show_all,offset,count);
else
throw new IllegalArgumentException("invalid search field (shouldn't happen)");
return translateCIDArray(rc);
} // end searchForCommunities
public int getSearchCommunityCount(DynamoUser caller, CommunitySearchField field, SearchMode mode, String term)
throws DatabaseException
{
boolean show_all = m_srm.getGlobalAcl().testPermission(caller,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,
"community.search.all");
if (CommunitySearchField.NAME.equals(field))
return m_ops.searchNameCount(mode,term,show_all);
else if (CommunitySearchField.SYNOPSIS.equals(field))
return m_ops.searchPropertyCount(m_ns_cache.namespaceNameToId(VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE),
"synopsis",mode,term,show_all);
else
throw new IllegalArgumentException("invalid search field (shouldn't happen)");
} // end getSearchCommunityCount
public List getCommunitiesInCategory(DynamoUser caller, int catid, int offset, int count) throws DatabaseException
{
boolean show_all = m_srm.getGlobalAcl().testPermission(caller,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,
"community.directory.all");
return translateCIDArray(m_ops.getCommunityIDsInCategory(catid,show_all,offset,count));
} // end getCommunitiesInCategory
public List getCommunitiesInCategory(DynamoUser caller, VeniceCategory cat, int offset, int count)
throws DatabaseException
{
return this.getCommunitiesInCategory(caller,cat.getCategoryID(),offset,count);
} // end getCommunitiesInCategory
public int getNumCommunitiesInCategory(DynamoUser caller, int catid) throws DatabaseException
{
boolean show_all = m_srm.getGlobalAcl().testPermission(caller,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,
"community.directory.all");
return m_ops.getNumCommunityIDsInCategory(catid,show_all);
} // end getNumCommunitiesInCategory
public int getNumCommunitiesInCategory(DynamoUser caller, VeniceCategory cat) throws DatabaseException
{
return this.getNumCommunitiesInCategory(caller,cat.getCategoryID());
} // end getNumCommunitiesInCategory
} // end class CommunityManager

View File

@ -0,0 +1,98 @@
/*
* 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 java.util.*;
import com.silverwrist.dynamo.db.OpsBase;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.venice.SearchMode;
abstract class CommunityManagerOps extends OpsBase
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
static final String KEY_CID = "cid";
static final String KEY_MEMBER_GID = "member_gid";
static final String KEY_HOST_GID = "host_gid";
static final String KEY_HOST_UID = "host_uid";
static final String KEY_ACLID = "aclid";
static final String KEY_CATID = "catid";
static final String KEY_VISIBILITY = "visibility";
static final String KEY_NAME = "name";
static final String KEY_ALIAS = "alias";
static final String KEY_CREATE = "created";
static final String KEY_ACCESS = "access";
static final String KEY_UPDATE = "update";
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
protected CommunityManagerOps(DBConnectionPool pool)
{
super(pool);
} // end constructor
/*--------------------------------------------------------------------------------
* Abstract operations
*--------------------------------------------------------------------------------
*/
abstract CommunityOps getCommunityOps();
abstract Map lookupCommunity(int cid) throws DatabaseException;
abstract Map lookupCommunity(String alias) throws DatabaseException;
abstract int[] getMemberCommunityIDs(int uid) throws DatabaseException;
abstract int[] getCommunityIDsInCategory(int catid, boolean show_all, int offset, int count)
throws DatabaseException;
abstract int getNumCommunityIDsInCategory(int catid, boolean show_all) throws DatabaseException;
abstract int[] searchProperty(int nsid, String name, SearchMode mode, String term, boolean show_all, int offset,
int count) throws DatabaseException;
abstract int searchPropertyCount(int nsid, String name, SearchMode mode, String term, boolean show_all)
throws DatabaseException;
abstract int[] searchName(SearchMode mode, String term, boolean show_all, int offset, int count)
throws DatabaseException;
abstract int searchNameCount(SearchMode mode, String term, boolean show_all) throws DatabaseException;
/*--------------------------------------------------------------------------------
* External static operations
*--------------------------------------------------------------------------------
*/
static CommunityManagerOps get(DBConnectionPool pool) throws ConfigException
{
return (CommunityManagerOps)get(pool,CommunityManagerOps.class.getClassLoader(),
CommunityManagerOps.class.getName() + "_","CommunityManagerOps");
} // end get
} // end class CommunityManagerOps

View File

@ -0,0 +1,546 @@
/*
* 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 java.sql.*;
import java.util.*;
import com.silverwrist.util.*;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.venice.CommunityVisibility;
import com.silverwrist.venice.SearchMode;
public class CommunityManagerOps_mysql extends CommunityManagerOps
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private DBUtilities m_utils;
private CommunityOps m_cops = null;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public CommunityManagerOps_mysql(DBConnectionPool pool)
{
super(pool);
m_utils = (DBUtilities)(pool.queryService(DBUtilities.class));
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private final String preparePropertySearchTerm(SearchMode mode, String term)
{
StringBuffer buf = new StringBuffer();
if (SearchMode.PREFIX.equals(mode))
buf.append("LIKE '!").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.SUBSTRING.equals(mode))
buf.append("LIKE '!%").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.REGEXP.equals(mode))
{ // for regular expressions, if we're matching the start of the string, we have to inlcude the ! prefix
buf.append("REGEXP '");
if (term.startsWith("^"))
buf.append("^!").append(m_utils.encodeString(term.substring(1)));
else
buf.append(m_utils.encodeString(term));
buf.append('\'');
} // end else if
return buf.toString();
} // end preparePropertySearchTerm
/*--------------------------------------------------------------------------------
* Overrides from class OpsBase
*--------------------------------------------------------------------------------
*/
public void dispose()
{
if (m_cops!=null)
{ // dispose the subobject
m_cops.dispose();
m_cops = null;
} // end if
m_utils = null;
super.dispose();
} // end dispose
/*--------------------------------------------------------------------------------
* Abstract implementations from class CommunityManagerOps
*--------------------------------------------------------------------------------
*/
synchronized CommunityOps getCommunityOps()
{
if (m_cops==null)
m_cops = new CommunityOps_mysql(getPool());
return m_cops;
} // end getCommunityOps
Map lookupCommunity(int cid) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute the query
stmt = conn.prepareStatement("SELECT member_gid, host_gid, host_uid, aclid, catid, hide_dir, hide_search, name, "
+ "alias, createdate, lastaccess, lastupdate FROM communities WHERE cid = ?;");
stmt.setInt(1,cid);
rs = stmt.executeQuery();
if (!(rs.next()))
return null;
// create and return the data structure
HashMap rc = new HashMap();
rc.put(KEY_CID,new Integer(cid));
rc.put(KEY_MEMBER_GID,new Integer(rs.getInt(1)));
rc.put(KEY_HOST_GID,new Integer(rs.getInt(2)));
rc.put(KEY_HOST_UID,new Integer(rs.getInt(3)));
rc.put(KEY_ACLID,new Integer(rs.getInt(4)));
rc.put(KEY_CATID,new Integer(rs.getInt(5)));
if (rs.getInt(6)==0)
rc.put(KEY_VISIBILITY,CommunityVisibility.SEARCHDIR);
else if (rs.getInt(7)==0)
rc.put(KEY_VISIBILITY,CommunityVisibility.SEARCHONLY);
else
rc.put(KEY_VISIBILITY,CommunityVisibility.NONE);
rc.put(KEY_NAME,rs.getString(8));
rc.put(KEY_ALIAS,rs.getString(9));
rc.put(KEY_CREATE,m_utils.getDateTime(rs,10));
rc.put(KEY_ACCESS,m_utils.getDateTime(rs,11));
rc.put(KEY_UPDATE,m_utils.getDateTime(rs,12));
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 lookupCommunity
Map lookupCommunity(String alias) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute the query
stmt = conn.prepareStatement("SELECT cid, member_gid, host_gid, host_uid, aclid, catid, hide_dir, hide_search, "
+ "name, createdate, lastaccess, lastupdate FROM communities WHERE alias = ?;");
stmt.setString(1,alias);
rs = stmt.executeQuery();
if (!(rs.next()))
return null;
// create and return the data structure
HashMap rc = new HashMap();
rc.put(KEY_CID,new Integer(rs.getInt(1)));
rc.put(KEY_MEMBER_GID,new Integer(rs.getInt(2)));
rc.put(KEY_HOST_GID,new Integer(rs.getInt(3)));
rc.put(KEY_HOST_UID,new Integer(rs.getInt(4)));
rc.put(KEY_ACLID,new Integer(rs.getInt(5)));
rc.put(KEY_CATID,new Integer(rs.getInt(6)));
if (rs.getInt(7)==0)
rc.put(KEY_VISIBILITY,CommunityVisibility.SEARCHDIR);
else if (rs.getInt(8)==0)
rc.put(KEY_VISIBILITY,CommunityVisibility.SEARCHONLY);
else
rc.put(KEY_VISIBILITY,CommunityVisibility.NONE);
rc.put(KEY_NAME,rs.getString(9));
rc.put(KEY_ALIAS,alias);
rc.put(KEY_CREATE,m_utils.getDateTime(rs,10));
rc.put(KEY_ACCESS,m_utils.getDateTime(rs,11));
rc.put(KEY_UPDATE,m_utils.getDateTime(rs,12));
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 lookupCommunity
int[] getMemberCommunityIDs(int uid) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute the statement
stmt = conn.prepareStatement("SELECT c.cid FROM communities c, groupmembers g WHERE c.member_gid = g.gid "
+ "AND g.uid = ? ORDER BY c.name;");
stmt.setInt(1,uid);
rs = stmt.executeQuery();
// Since we don't know how many communities we need to allocate slots for, we allocate smaller arrays
// in blocks and stash the small blocks in a LinkedList, keeping track of the total size.
LinkedList olist = new LinkedList();
int[] current = new int[16];
int curptr = 0;
int total = 0;
while (rs.next())
{ // fill array segments with community IDs
if (curptr==16)
{ // stack the filled array segment and begin a new one
olist.addLast(current);
curptr = 0;
current = new int[16];
} // end if
current[curptr++] = rs.getInt(1);
total++;
} // end while
olist.addLast(current); // add last array to list
// allocate and copy the return array
int rc[] = new int[total];
curptr = 0;
while (total>0)
{ // get each segment and copy it into return array
current = (int[])(olist.removeFirst());
int ct = Math.min(current.length,total);
System.arraycopy(current,0,rc,curptr,ct);
curptr += ct;
total -= ct;
} // end while
olist.clear();
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 getMemberCommunityIDs
int[] getCommunityIDsInCategory(int catid, boolean show_all, int offset, int count) throws DatabaseException
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute the statement (note that we assemble it in SQL form);
StringBuffer sql = new StringBuffer("SELECT cid FROM communities WHERE catid = ");
sql.append(catid);
if (!show_all)
sql.append(" AND hide_dir = 0");
sql.append(" ORDER BY name LIMIT ").append(offset).append(", ").append(count+1).append(';');
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
// We *know* the maximum number of indexes that can be returned, so allocate a temporary array big
// enough to hold them all.
int[] tmp = new int[count+1];
int ct = 0;
while (rs.next())
tmp[ct++] = rs.getInt(1);
// Create the actual return array and fill it.
int[] rc = new int[ct];
System.arraycopy(tmp,0,rc,0,ct);
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 getCommunityIDsInCategory
int getNumCommunityIDsInCategory(int catid, boolean show_all) throws DatabaseException
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute the statement (note that we assemble it in SQL form);
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM communities WHERE catid = ");
sql.append(catid);
if (!show_all)
sql.append(" AND hide_dir = 0");
sql.append(';');
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
return SQLUtils.getReturnCountInt(rs,1);
} // 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 getNumCommunityIDsInCategory
int[] searchProperty(int nsid, String name, SearchMode mode, String term, boolean show_all, int offset, int count)
throws DatabaseException
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute a query (note that we assemble it in SQL form)
StringBuffer sql = new StringBuffer("SELECT c.cid FROM communities c, commprops p WHERE c.cid = p.cid "
+ "AND p.nsid = ");
sql.append(nsid).append(" AND p.prop_name = '").append(m_utils.encodeString(name)).append("' AND p.prop_value ");
sql.append(preparePropertySearchTerm(mode,term));
if (!show_all)
sql.append(" AND c.hide_search = 0");
sql.append(" ORDER BY c.name LIMIT ").append(offset).append(", ").append(count+1).append(';');
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
// We *know* the maximum number of indexes that can be returned, so allocate a temporary array big
// enough to hold them all.
int[] tmp = new int[count+1];
int ct = 0;
while (rs.next())
tmp[ct++] = rs.getInt(1);
// Create the actual return array and fill it.
int[] rc = new int[ct];
System.arraycopy(tmp,0,rc,0,ct);
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 searchProperty
int searchPropertyCount(int nsid, String name, SearchMode mode, String term, boolean show_all)
throws DatabaseException
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute a query (note that we assemble it in SQL form)
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM communities c, commprops p WHERE c.cid = p.cid "
+ "AND p.nsid = ");
sql.append(nsid).append(" AND p.prop_name = '").append(m_utils.encodeString(name)).append("' AND p.prop_value ");
sql.append(preparePropertySearchTerm(mode,term));
if (!show_all)
sql.append(" AND c.hide_search = 0");
sql.append(';');
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
return SQLUtils.getReturnCountInt(rs,1);
} // 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 searchPropertyCount
int[] searchName(SearchMode mode, String term, boolean show_all, int offset, int count) throws DatabaseException
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute a query (note that we assemble it in SQL form)
StringBuffer sql = new StringBuffer("SELECT cid FROM communities WHERE name ");
if (SearchMode.PREFIX.equals(mode))
sql.append("LIKE '").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.SUBSTRING.equals(mode))
sql.append("LIKE '%").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.REGEXP.equals(mode))
sql.append("REGEXP '").append(m_utils.encodeString(term)).append('\'');
if (!show_all)
sql.append(" AND hide_search = 0");
sql.append(" ORDER BY name LIMIT ").append(offset).append(", ").append(count+1).append(';');
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
// We *know* the maximum number of indexes that can be returned, so allocate a temporary array big
// enough to hold them all.
int[] tmp = new int[count+1];
int ct = 0;
while (rs.next())
tmp[ct++] = rs.getInt(1);
// Create the actual return array and fill it.
int[] rc = new int[ct];
System.arraycopy(tmp,0,rc,0,ct);
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 searchName
int searchNameCount(SearchMode mode, String term, boolean show_all) throws DatabaseException
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute a query (note that we assemble it in SQL form)
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM communities WHERE name ");
if (SearchMode.PREFIX.equals(mode))
sql.append("LIKE '").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.SUBSTRING.equals(mode))
sql.append("LIKE '%").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.REGEXP.equals(mode))
sql.append("REGEXP '").append(m_utils.encodeString(term)).append('\'');
if (!show_all)
sql.append(" AND hide_search = 0");
sql.append(';');
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
return SQLUtils.getReturnCountInt(rs,1);
} // 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 searchNameCount
} // end class CommunityManagerOps_mysql

View File

@ -16,3 +16,16 @@
# --------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------
# This file has been localized for the en_US locale # This file has been localized for the en_US locale
cat.notfound=The category with ID#{0} does not exist in the database. cat.notfound=The category with ID#{0} does not exist in the database.
cid.notfound=The community with ID#{0} does not exist in the database.
alias.notfound=The community with alias "{0}" does not exist in the database.
auth.getCommList=You are not authorized to get the member community list for user "{0}."
auth.setCategory=You are not authorized to set the category for community "{0}."
property.serialize=The value of property "{0}" could not be serialized.
property.deserialize=The value of property "{0}" could not be deserialized.
auth.setProperty=You are not authorized to set properties on the community "{0}."
auth.removeProperty=You are not authorized to remove properties from the community "{0}."
auth.setVisibility=You are not authorized to set the visibility for community "{0}."
auth.setName=You are not authorized to change the name of community "{0}."
auth.setAlias=You are not authorized to change the alias of community "{0}."
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}."

View File

@ -0,0 +1,72 @@
/*
* 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 java.util.*;
import com.silverwrist.dynamo.db.OpsBase;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.dynamo.util.*;
import com.silverwrist.venice.CommunityVisibility;
abstract class CommunityOps extends OpsBase
{
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
protected CommunityOps(DBConnectionPool pool)
{
super(pool);
} // end constructor
/*--------------------------------------------------------------------------------
* Abstract operations
*--------------------------------------------------------------------------------
*/
abstract java.util.Date setCategoryID(int cid, int catid) throws DatabaseException;
abstract Object getProperty(int cid, PropertyKey key) throws DatabaseException;
abstract DateObjectPair setProperty(int cid, PropertyKey key, Object value) throws DatabaseException;
abstract DateObjectPair removeProperty(int cid, PropertyKey key) throws DatabaseException;
abstract int[] getPropertyNamespaceIDs(int cid) throws DatabaseException;
abstract Map getAllProperties(int cid, int namespace) throws DatabaseException;
abstract java.util.Date setVisibility(int cid, CommunityVisibility visibility) throws DatabaseException;
abstract java.util.Date setName(int cid, String name) throws DatabaseException;
abstract java.util.Date setAlias(int cid, String alias) throws DatabaseException;
abstract void setLastAccessDate(int cid, java.util.Date date) throws DatabaseException;
abstract void setLastUpdateDate(int cid, java.util.Date date) throws DatabaseException;
abstract java.util.Date grantAccess(int cid, int ugid, boolean is_group, boolean single_use, int auth_nsid,
String auth_name, String source_data, String auth_data) throws DatabaseException;
abstract java.util.Date revokeAccess(int cid, int ugid, boolean is_group) throws DatabaseException;
} // end class CommunityOps

View File

@ -0,0 +1,733 @@
/*
* 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 java.sql.*;
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;
class CommunityOps_mysql extends CommunityOps
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private DBUtilities m_utils; // reference to utilities object
private PropertySerializer m_psz; // reference to property serializer
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
CommunityOps_mysql(DBConnectionPool pool)
{
super(pool);
m_utils = (DBUtilities)(pool.queryService(DBUtilities.class));
m_psz = (PropertySerializer)(pool.queryService(PropertySerializer.class));
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private final java.util.Date touchCommunity(Connection conn, int cid, java.util.Date date) throws SQLException
{
PreparedStatement stmt = null;
try
{ // prepare and execute the update statement
stmt = conn.prepareStatement("UPDATE communities SET lastaccess = ?, lastupdate = ? WHERE cid = ?;");
m_utils.setDateTime(stmt,1,date);
m_utils.setDateTime(stmt,2,date);
stmt.setInt(3,cid);
stmt.executeUpdate();
return date;
} // end try
finally
{ // make sure and close out the statement
SQLUtils.shutdown(stmt);
} // end finally
} // end touchCommunity
private final java.util.Date touchCommunity(Connection conn, int cid) throws SQLException
{
return this.touchCommunity(conn,cid,new java.util.Date());
} // end touchCommunity
/*--------------------------------------------------------------------------------
* Overrides from class OpsBase
*--------------------------------------------------------------------------------
*/
public void dispose()
{
m_psz = null;
m_utils = null;
super.dispose();
} // end dispose
/*--------------------------------------------------------------------------------
* Abstract implementations from class CommunityOps
*--------------------------------------------------------------------------------
*/
java.util.Date setCategoryID(int cid, int catid) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
Statement stmt2 = null;
java.util.Date lastupd = null;
try
{ // get a connection
conn = getConnection();
// lock the table
stmt2 = conn.createStatement();
stmt2.executeUpdate("LOCK TABLES communities WRITE;");
// prepare and execute the statement
stmt = conn.prepareStatement("UPDATE communities SET catid = ?, lastaccess = ?, lastupdate = ? WHERE cid = ?;");
stmt.setInt(1,catid);
lastupd = new java.util.Date();
m_utils.setDateTime(stmt,2,lastupd);
m_utils.setDateTime(stmt,3,lastupd);
stmt.setInt(4,cid);
stmt.executeUpdate();
return lastupd;
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
MySQLUtils.unlockTables(conn);
SQLUtils.shutdown(stmt2);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(conn);
} // end finally
} // end setCategoryID
Object getProperty(int cid, PropertyKey key) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
String rc_str = null;
try
{ // get a connection
conn = getConnection();
// look up the property
stmt = conn.prepareStatement("SELECT prop_value FROM commprop WHERE cid = ? AND nsid = ? AND prop_name = ?;");
stmt.setInt(1,cid);
stmt.setInt(2,key.getNamespaceID());
stmt.setString(3,key.getName());
rs = stmt.executeQuery();
if (!(rs.next()))
return null; // property not found
rc_str = rs.getString(1);
} // 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
// Deserialize the property value.
Object rc = m_psz.deserializeProperty(rc_str);
if (rc!=null)
return rc;
// deserialization exception - throw it
DatabaseException de = new DatabaseException(CommunityOps_mysql.class,"CommunityMessages","property.deserialize");
de.setParameter(0,key.getName());
throw de;
} // end getProperty
DateObjectPair setProperty(int cid, PropertyKey key, Object value) throws DatabaseException
{
String serialized_value = m_psz.serializeProperty(value);
if (serialized_value==null)
{ // serialization exception - throw it
DatabaseException de = new DatabaseException(CommunityOps_mysql.class,"CommunityMessages","property.serialize");
de.setParameter(0,key.getName());
throw de;
} // end if
String old_value = null;
Connection conn = null;
PreparedStatement stmt = null;
Statement stmt2 = null;
ResultSet rs = null;
java.util.Date update = null;
try
{ // get a connection
conn = getConnection();
// lock the table
stmt2 = conn.createStatement();
stmt2.executeUpdate("LOCK TABLES commprop WRITE, communities WRITE;");
// look to see if the property value is already there
stmt = conn.prepareStatement("SELECT prop_value FROM commprop WHERE cid = ? AND nsid = ? AND prop_name = ?;");
stmt.setInt(1,cid);
stmt.setInt(2,key.getNamespaceID());
stmt.setString(3,key.getName());
rs = stmt.executeQuery();
if (rs.next())
old_value = rs.getString(1);
SQLUtils.shutdown(rs);
rs = null;
SQLUtils.shutdown(stmt);
if (old_value!=null)
{ // prepare the statement to update the existing record
stmt = conn.prepareStatement("UPDATE commprop SET prop_value = ? WHERE cid = ? AND nsid = ? "
+ "AND prop_name = ?;");
stmt.setString(1,serialized_value);
stmt.setInt(2,cid);
stmt.setInt(3,key.getNamespaceID());
stmt.setString(4,key.getName());
} // end if
else
{ // prepare the statement to insert a new record
stmt = conn.prepareStatement("INSERT INTO commprop (cid, nsid, prop_name, prop_value) VALUES (?, ?, ?, ?);");
stmt.setInt(1,cid);
stmt.setInt(2,key.getNamespaceID());
stmt.setString(3,key.getName());
stmt.setString(4,serialized_value);
} // end else
stmt.executeUpdate(); // execute it!
// Touch the community entry.
update = touchCommunity(conn,cid);
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
MySQLUtils.unlockTables(conn);
SQLUtils.shutdown(rs);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(stmt2);
SQLUtils.shutdown(conn);
} // end finally
if (old_value==null)
return new DateObjectPair(null,update); // no previous value
// Deserialize the property value.
Object rc = m_psz.deserializeProperty(old_value);
if (rc!=null)
return new DateObjectPair(rc,update);
// deserialization exception - throw it
DatabaseException de = new DatabaseException(CommunityOps_mysql.class,"CommunityMessages","property.deserialize");
de.setParameter(0,key.getName());
throw de;
} // end setProperty
DateObjectPair removeProperty(int cid, PropertyKey key) throws DatabaseException
{
String old_value = null;
Connection conn = null;
PreparedStatement stmt = null;
Statement stmt2 = null;
ResultSet rs = null;
java.util.Date update = null;
try
{ // get a connection
conn = getConnection();
// lock the table
stmt2 = conn.createStatement();
stmt2.executeUpdate("LOCK TABLES commprop WRITE, communities WRITE;");
// look to see if the property value is already there
stmt = conn.prepareStatement("SELECT prop_value FROM commprop WHERE cid = ? AND nsid = ? AND prop_name = ?;");
stmt.setInt(1,cid);
stmt.setInt(2,key.getNamespaceID());
stmt.setString(3,key.getName());
rs = stmt.executeQuery();
if (rs.next())
old_value = rs.getString(1);
else
return null; // no need to remove anything
SQLUtils.shutdown(rs);
rs = null;
SQLUtils.shutdown(stmt);
// delete the database row
stmt = conn.prepareStatement("DELETE FROM commprop WHERE cid = ? AND nsid = ? AND prop_name = ?;");
stmt.setInt(1,cid);
stmt.setInt(2,key.getNamespaceID());
stmt.setString(3,key.getName());
stmt.executeUpdate();
// Touch the community entry.
update = touchCommunity(conn,cid);
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
MySQLUtils.unlockTables(conn);
SQLUtils.shutdown(rs);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(stmt2);
SQLUtils.shutdown(conn);
} // end finally
// Deserialize the property value.
Object rc = m_psz.deserializeProperty(old_value);
if (rc!=null)
return new DateObjectPair(rc,update);
// deserialization exception - throw it
DatabaseException de = new DatabaseException(CommunityOps_mysql.class,"DatabaseMessages","property.deserialize");
de.setParameter(0,key.getName());
throw de;
} // end removeProperty
int[] getPropertyNamespaceIDs(int cid) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// execute the query!
stmt = conn.prepareStatement("SELECT DISTINCT nsid FROM commprop WHERE cid = ?;");
stmt.setInt(1,cid);
rs = stmt.executeQuery();
// read out a list of the namespace IDs
ArrayList tmp = new ArrayList();
while (rs.next())
tmp.add(new Integer(rs.getInt(1)));
// create and return the array
int[] rc = new int[tmp.size()];
for (int i=0; i<tmp.size(); i++)
rc[i] = ((Integer)(tmp.get(i))).intValue();
tmp.clear();
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 getPropertyNamespaceIDs
Map getAllProperties(int cid, int namespace) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// execute the query!
stmt = conn.prepareStatement("SELECT prop_name, prop_value FROM commprop WHERE cid = ? AND nsid = ?;");
stmt.setInt(1,cid);
stmt.setInt(2,namespace);
rs = stmt.executeQuery();
// prepare the return value
HashMap rc = new HashMap();
while (rs.next())
{ // copy data out, deserializing properties as we go
String key = rs.getString(1);
Object value = m_psz.deserializeProperty(rs.getString(2));
if (value==null)
{ // deserialization exception - throw it
DatabaseException de = new DatabaseException(CommunityOps_mysql.class,"CommunityMessages",
"property.deserialize");
de.setParameter(0,key);
throw de;
} // end if
rc.put(key,value);
} // end while
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 getAllProperties
java.util.Date setVisibility(int cid, CommunityVisibility visibility) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
Statement stmt2 = null;
java.util.Date lastupd = null;
try
{ // get a connection
conn = getConnection();
// lock the table
stmt2 = conn.createStatement();
stmt2.executeUpdate("LOCK TABLES communities WRITE;");
// prepare and execute the statement
stmt = conn.prepareStatement("UPDATE communities SET hide_dir = ?, hide_search = ?, lastaccess = ?, "
+ "lastupdate = ? WHERE cid = ?;");
stmt.setInt(1,(CommunityVisibility.SEARCHDIR.equals(visibility) ? 1 : 0));
stmt.setInt(2,(CommunityVisibility.NONE.equals(visibility) ? 0 : 1));
lastupd = new java.util.Date();
m_utils.setDateTime(stmt,3,lastupd);
m_utils.setDateTime(stmt,4,lastupd);
stmt.setInt(5,cid);
stmt.executeUpdate();
return lastupd;
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
MySQLUtils.unlockTables(conn);
SQLUtils.shutdown(stmt2);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(conn);
} // end finally
} // end setVisibility
java.util.Date setName(int cid, String name) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
Statement stmt2 = null;
java.util.Date lastupd = null;
try
{ // get a connection
conn = getConnection();
// lock the table
stmt2 = conn.createStatement();
stmt2.executeUpdate("LOCK TABLES communities WRITE;");
// prepare and execute the statement
stmt = conn.prepareStatement("UPDATE communities SET name = ?, lastaccess = ?, lastupdate = ? WHERE cid = ?;");
stmt.setString(1,name);
lastupd = new java.util.Date();
m_utils.setDateTime(stmt,2,lastupd);
m_utils.setDateTime(stmt,3,lastupd);
stmt.setInt(4,cid);
stmt.executeUpdate();
return lastupd;
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
MySQLUtils.unlockTables(conn);
SQLUtils.shutdown(stmt2);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(conn);
} // end finally
} // end setName
java.util.Date setAlias(int cid, String alias) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
Statement stmt2 = null;
java.util.Date lastupd = null;
try
{ // get a connection
conn = getConnection();
// lock the table
stmt2 = conn.createStatement();
stmt2.executeUpdate("LOCK TABLES communities WRITE;");
// prepare and execute the statement
stmt = conn.prepareStatement("UPDATE communities SET alias = ?, lastaccess = ?, lastupdate = ? WHERE cid = ?;");
stmt.setString(1,alias);
lastupd = new java.util.Date();
m_utils.setDateTime(stmt,2,lastupd);
m_utils.setDateTime(stmt,3,lastupd);
stmt.setInt(4,cid);
stmt.executeUpdate();
return lastupd;
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
MySQLUtils.unlockTables(conn);
SQLUtils.shutdown(stmt2);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(conn);
} // end finally
} // end setAlias
void setLastAccessDate(int cid, java.util.Date date) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
Statement stmt2 = null;
try
{ // get a connection
conn = getConnection();
// lock the table
stmt2 = conn.createStatement();
stmt2.executeUpdate("LOCK TABLES communities WRITE;");
// prepare and execute the statement
stmt = conn.prepareStatement("UPDATE communities SET lastaccess = ? WHERE cid = ?;");
m_utils.setDateTime(stmt,1,date);
stmt.setInt(2,cid);
stmt.executeUpdate();
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
MySQLUtils.unlockTables(conn);
SQLUtils.shutdown(stmt2);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(conn);
} // end finally
} // end setLastAccessDate
void setLastUpdateDate(int cid, java.util.Date date) throws DatabaseException
{
Connection conn = null;
Statement stmt = null;
try
{ // get a connection
conn = getConnection();
// lock the table
stmt = conn.createStatement();
stmt.executeUpdate("LOCK TABLES communities WRITE;");
// touch the community
touchCommunity(conn,cid,date);
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
MySQLUtils.unlockTables(conn);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(conn);
} // end finally
} // end setLastUpdateDate
java.util.Date grantAccess(int cid, int ugid, boolean is_group, boolean single_use, int auth_nsid,
String auth_name, String source_data, String auth_data) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
Statement stmt2 = null;
ResultSet rs = null;
java.util.Date update = null;
try
{ // get a connection
conn = getConnection();
// lock the table
stmt2 = conn.createStatement();
stmt2.executeUpdate("LOCK TABLES commaccess WRITE, communities WRITE;");
// create the insert statement and execute it
stmt = conn.prepareStatement("INSERT INTO commaccess (cid, ugid, is_group, single_use, auth_nsid, auth_name, "
+ "source_data, auth_data) VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
stmt.setInt(1,cid);
stmt.setInt(2,ugid);
stmt.setInt(3,(is_group ? 1 : 0));
stmt.setInt(4,(single_use ? 1 : 0));
if (auth_nsid==0)
stmt.setNull(5,Types.INTEGER);
else
stmt.setInt(5,auth_nsid);
stmt.setString(6,auth_name);
stmt.setString(7,source_data);
stmt.setString(8,auth_data);
stmt.executeUpdate();
// Touch the community entry.
return touchCommunity(conn,cid);
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
MySQLUtils.unlockTables(conn);
SQLUtils.shutdown(rs);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(stmt2);
SQLUtils.shutdown(conn);
} // end finally
} // end grantAccess
java.util.Date revokeAccess(int cid, int ugid, boolean is_group) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
Statement stmt2 = null;
ResultSet rs = null;
java.util.Date update = null;
try
{ // get a connection
conn = getConnection();
// lock the table
stmt2 = conn.createStatement();
stmt2.executeUpdate("LOCK TABLES commaccess WRITE, communities WRITE;");
// create the delete statement and execute it
stmt = conn.prepareStatement("DELETE FROM commaccess WHERE cid = ? AND ugid = ? AND is_group = ?;");
stmt.setInt(1,cid);
stmt.setInt(2,ugid);
stmt.setInt(3,(is_group ? 1 : 0));
stmt.executeUpdate();
// Touch the community entry.
return touchCommunity(conn,cid);
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
MySQLUtils.unlockTables(conn);
SQLUtils.shutdown(rs);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(stmt2);
SQLUtils.shutdown(conn);
} // end finally
} // end revokeAccess
} // end class CommunityOps_mysql

View File

@ -0,0 +1,65 @@
/*
* 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.event;
import com.silverwrist.venice.iface.VeniceCommunity;
public class CommunityBaseUpdateEvent extends CommunityUpdateEvent
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private transient String m_what;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public CommunityBaseUpdateEvent(VeniceCommunity src, String what)
{
super(src);
m_what = what;
} // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class CommunityUpdateEvent
*--------------------------------------------------------------------------------
*/
public String toString()
{
return "CommunityBaseUpdateEvent: community = \"" + ((VeniceCommunity)source).getName() + "\", what = " + m_what;
} // end toString
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public String getUpdatedItem()
{
return m_what;
} // end getUpdatedItem
} // end class CommunityBaseUpdateEvent

View File

@ -0,0 +1,74 @@
/*
* 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.event;
import com.silverwrist.venice.iface.VeniceCommunity;
public class CommunityPropertyUpdateEvent extends CommunityUpdateEvent
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private transient String m_namespace;
private transient String m_name;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public CommunityPropertyUpdateEvent(VeniceCommunity src, String namespace, String name)
{
super(src);
m_namespace = namespace;
m_name = name;
} // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class CommunityUpdateEvent
*--------------------------------------------------------------------------------
*/
public String toString()
{
return "CommunityPropertyUpdateEvent: community = \"" + ((VeniceCommunity)source).getName() + "\", namespace = "
+ m_namespace + ", name = " + m_name;
} // end toString
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public String getPropertyNamespace()
{
return m_namespace;
} // end getPropertyNamespace
public String getPropertyName()
{
return m_name;
} // end getPropertyName
} // end class CommunityPropertyUpdateEvent

View File

@ -0,0 +1,46 @@
/*
* 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.event;
import com.silverwrist.venice.iface.VeniceCommunity;
public class CommunityUpdateEvent extends VeniceUpdateEvent
{
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public CommunityUpdateEvent(VeniceCommunity src)
{
super(src);
} // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class VeniceUpdateEvent
*--------------------------------------------------------------------------------
*/
public String toString()
{
return "CommunityUpdateEvent: community = \"" + ((VeniceCommunity)source).getName() + "\"";
} // end toString
} // end class CommunityUpdateEvent

View File

@ -0,0 +1,46 @@
/*
* 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.event;
import com.silverwrist.dynamo.event.DynamicUpdateEvent;
public class VeniceUpdateEvent extends DynamicUpdateEvent
{
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public VeniceUpdateEvent(Object src)
{
super(src);
} // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class DynamicUpdateEvent
*--------------------------------------------------------------------------------
*/
public String toString()
{
return "VeniceUpdateEvent: source = " + source;
} // end toString
} // end class VeniceUpdateEvent

View File

@ -17,12 +17,14 @@
*/ */
package com.silverwrist.venice.frame; package com.silverwrist.venice.frame;
import java.text.MessageFormat;
import java.util.*; import java.util.*;
import java.util.regex.*; import java.util.regex.*;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.w3c.dom.*; import org.w3c.dom.*;
import com.silverwrist.util.*; import com.silverwrist.util.*;
import com.silverwrist.util.xml.*; import com.silverwrist.util.xml.*;
import com.silverwrist.dynamo.DynamoVersion;
import com.silverwrist.dynamo.RequestType; import com.silverwrist.dynamo.RequestType;
import com.silverwrist.dynamo.event.*; import com.silverwrist.dynamo.event.*;
import com.silverwrist.dynamo.except.*; import com.silverwrist.dynamo.except.*;
@ -32,6 +34,7 @@ import com.silverwrist.dynamo.util.*;
import com.silverwrist.dynamo.velocity.VelocityParamSupplier; import com.silverwrist.dynamo.velocity.VelocityParamSupplier;
import com.silverwrist.dynamo.velocity.VelocityRendererConfig; import com.silverwrist.dynamo.velocity.VelocityRendererConfig;
import com.silverwrist.venice.VeniceNamespaces; import com.silverwrist.venice.VeniceNamespaces;
import com.silverwrist.venice.VeniceVersion;
import com.silverwrist.venice.iface.*; import com.silverwrist.venice.iface.*;
import com.silverwrist.venice.session.SessionInfoParams; import com.silverwrist.venice.session.SessionInfoParams;
@ -140,7 +143,13 @@ public class FrameAssembler
*/ */
public FrameAssembler() public FrameAssembler()
{ // do nothing {
// Load the "generator" text output as a META tag.
ResourceBundle b = ResourceBundle.getBundle("com.silverwrist.venice.frame.FrameMessages",Locale.getDefault(),
FrameAssembler.class.getClassLoader());
String[] args = new String[] { VeniceVersion.VERSION, DynamoVersion.VERSION };
m_globals.put("generator",MessageFormat.format(b.getString("generator"),args));
} // end constructor } // end constructor
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------

View File

@ -21,3 +21,4 @@ property.wrongClass=Value of property "{0}" is not of class "{1}".
ss.noPrefix=Configuration error: no stylesheet prefix configured for servlet path {0}. ss.noPrefix=Configuration error: no stylesheet prefix configured for servlet path {0}.
ss.noTemplate=No stylesheet template name found for property "{0}". ss.noTemplate=No stylesheet template name found for property "{0}".
ss.renderFail=Unable to render stylesheet template {0}: {1} ss.renderFail=Unable to render stylesheet template {0}: {1}
generator=Venice Web Communities System {0}; Dynamo Application Framework {1}

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 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;
import com.silverwrist.dynamo.iface.DynamoAcl; import com.silverwrist.dynamo.iface.DynamoAcl;
@ -80,7 +81,7 @@ public interface VeniceCommunity extends NamedObject, SecureObjectStore
public void grantAccess(DynamoUser caller, Principal subject, String auth_namespace, String auth_name, public void grantAccess(DynamoUser caller, Principal subject, String auth_namespace, String auth_name,
String source_info, String auth_info, boolean single_use) String source_info, String auth_info, boolean single_use)
throws DatabaseException, DynamoSecurityException; throws AuthenticationException, DatabaseException, DynamoSecurityException;
public void revokeAccess(DynamoUser caller, Principal subject) throws DatabaseException, DynamoSecurityException; public void revokeAccess(DynamoUser caller, Principal subject) throws DatabaseException, DynamoSecurityException;

View File

@ -39,12 +39,14 @@
favicon_url = URL to the MSIE-style FAVICON favicon_url = URL to the MSIE-style FAVICON
favicon_ltyp = Linkage type of the MSIE-style FAVICON favicon_ltyp = Linkage type of the MSIE-style FAVICON
lbar_width = Left bar width in pixels lbar_width = Left bar width in pixels
ms_copyright_violations = True to prevent adding anti-Smart Tags META tag ms_copyright_violations = True to prevent adding anti-Microsoft Smart Tags META tag
generator = Page generator (Venice and Dynamo versions)
*# *#
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> <html>
<head> <head>
<title>#encodeHTML( $pagetitle ) - #encodeHTML( $sitetitle )</title> <title>#encodeHTML( $pagetitle ) - #encodeHTML( $sitetitle )</title>
<meta name="GENERATOR" content="$generator" />
#if( $pgicon_url && $pgicon_ltyp && $pgicon_mime ) #if( $pgicon_url && $pgicon_ltyp && $pgicon_mime )
<link rel="icon" href="#formatURL( $pgicon_ltyp $pgicon_url )" type="$pgicon_mime" /> <link rel="icon" href="#formatURL( $pgicon_ltyp $pgicon_url )" type="$pgicon_mime" />
#end #end