MAJOR restructuring of the engine code to get the execution environment info

separated from the internal objects (as well as separating the internal
interfaces), some prep work for modularizing the SIG-to-service interface so
it'll be easier to add chat and stuff.  Also fixed up a display issue with
1-character CDTextFormFields.
This commit is contained in:
Eric J. Bowersox 2001-11-17 06:37:30 +00:00
parent 313a46818f
commit 47b88efd75
44 changed files with 1616 additions and 1535 deletions

View File

@ -21,6 +21,7 @@ import java.sql.*;
import java.util.*; import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.security.AuditRecord; import com.silverwrist.venice.security.AuditRecord;
import com.silverwrist.venice.security.SecLevels; import com.silverwrist.venice.security.SecLevels;
@ -39,20 +40,16 @@ class AdminOperationsImpl implements AdminOperations
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; // the back end of the engine private EnvUser env; // the execution environment
private UserBackend user; // the UserContext that created this object
private DataPool datapool; // the data pool used by this object
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructor * Constructor
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
AdminOperationsImpl(EngineBackend engine, UserBackend user, DataPool datapool) AdminOperationsImpl(EnvUser env)
{ {
this.engine = engine; this.env = env;
this.user = user;
this.datapool = datapool;
} // end constructor } // end constructor
@ -63,7 +60,7 @@ class AdminOperationsImpl implements AdminOperations
public boolean isGlobalAdmin() public boolean isGlobalAdmin()
{ {
return (user.realBaseLevel()==SecLevels.GLOBAL_BOFH); return (env.getUser().realBaseLevel()==SecLevels.GLOBAL_BOFH);
} // end isGlobalAdmin } // end isGlobalAdmin
@ -74,7 +71,7 @@ class AdminOperationsImpl implements AdminOperations
try try
{ // retrieve a connection from the data pool and get the audit records { // retrieve a connection from the data pool and get the audit records
conn = datapool.getConnection(); conn = env.getConnection();
rc = AuditRecord.getAuditRecords(conn,-1,offset,count); rc = AuditRecord.getAuditRecords(conn,-1,offset,count);
} // end try } // end try
@ -86,8 +83,7 @@ class AdminOperationsImpl implements AdminOperations
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -102,7 +98,7 @@ class AdminOperationsImpl implements AdminOperations
try try
{ // retrieve a connection from the data pool and get the audit records { // retrieve a connection from the data pool and get the audit records
conn = datapool.getConnection(); conn = env.getConnection();
rc = AuditRecord.getAuditRecordCount(conn,-1); rc = AuditRecord.getAuditRecordCount(conn,-1);
} // end try } // end try
@ -114,8 +110,7 @@ class AdminOperationsImpl implements AdminOperations
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -125,25 +120,25 @@ class AdminOperationsImpl implements AdminOperations
public AdminUserContext getUserContext(int uid) throws DataException public AdminUserContext getUserContext(int uid) throws DataException
{ {
return AdminUserContextImpl.getAdminUserContext(engine,user,datapool,uid); return AdminUserContextImpl.getAdminUserContext(env,uid);
} // end getUserContext } // end getUserContext
public AdminUserContext getUserContext(String username) throws DataException public AdminUserContext getUserContext(String username) throws DataException
{ {
return AdminUserContextImpl.getAdminUserContext(engine,user,datapool,username); return AdminUserContextImpl.getAdminUserContext(env,username);
} // end getUserContext } // end getUserContext
public GlobalProperties getProperties() public GlobalProperties getProperties()
{ {
return engine.getProperties(); return env.getEngine().getProperties();
} // end getProperties } // end getProperties
public void setProperties(GlobalProperties props) throws DataException public void setProperties(GlobalProperties props) throws DataException
{ {
engine.setProperties(props); env.getEngine().setProperties(props);
} // end setProperties } // end setProperties

View File

@ -22,6 +22,7 @@ import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.util.International; import com.silverwrist.util.International;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.security.PasswordHash; import com.silverwrist.venice.security.PasswordHash;
import com.silverwrist.venice.security.AuditRecord; import com.silverwrist.venice.security.AuditRecord;
@ -40,9 +41,7 @@ class AdminUserContextImpl implements AdminUserContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; // the back end of the engine private EnvUser env; // the local environment
private UserBackend user; // the controlling administrative user
private DataPool datapool; // the data pool used by this object
private int uid; // the user ID of this user private int uid; // the user ID of this user
private int contactid; // ID of associated contact information private int contactid; // ID of associated contact information
private int level; // base security level for this user private int level; // base security level for this user
@ -60,12 +59,9 @@ class AdminUserContextImpl implements AdminUserContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
protected AdminUserContextImpl(EngineBackend engine, UserBackend user, DataPool datapool, ResultSet rs) protected AdminUserContextImpl(EnvUser env, ResultSet rs) throws SQLException
throws SQLException
{ {
this.engine = engine; this.env = env;
this.user = user;
this.datapool = datapool;
this.uid = rs.getInt("uid"); this.uid = rs.getInt("uid");
this.contactid = rs.getInt("contactid"); this.contactid = rs.getInt("contactid");
this.level = rs.getInt("base_lvl"); this.level = rs.getInt("base_lvl");
@ -119,15 +115,14 @@ class AdminUserContextImpl implements AdminUserContext
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE users SET description = '"); StringBuffer sql = new StringBuffer("UPDATE users SET description = '");
sql.append(SQLUtil.encodeString(new_descr)).append("' WHERE uid = ").append(uid).append(';'); sql.append(SQLUtil.encodeString(new_descr)).append("' WHERE uid = ").append(uid).append(';');
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
description = new_descr; // change stored information description = new_descr; // change stored information
ar = new AuditRecord(AuditRecord.ADMIN_ACCOUNT_CHANGE,user.realUID(),user.userRemoteAddress(),0, ar = env.newAudit(AuditRecord.ADMIN_ACCOUNT_CHANGE,"uid=" + uid,"field=description");
"uid=" + uid,"field=description");
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -150,8 +145,7 @@ class AdminUserContextImpl implements AdminUserContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -173,15 +167,14 @@ class AdminUserContextImpl implements AdminUserContext
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE users SET base_lvl = "); StringBuffer sql = new StringBuffer("UPDATE users SET base_lvl = ");
sql.append(new_level).append(" WHERE uid = ").append(uid).append(';'); sql.append(new_level).append(" WHERE uid = ").append(uid).append(';');
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
level = new_level; level = new_level;
ar = new AuditRecord(AuditRecord.ADMIN_SET_SECURITY,user.realUID(),user.userRemoteAddress(),0, ar = env.newAudit(AuditRecord.ADMIN_SET_SECURITY,"uid=" + uid,"level=" + new_level);
"uid=" + uid,"level=" + new_level);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -204,8 +197,7 @@ class AdminUserContextImpl implements AdminUserContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -227,15 +219,14 @@ class AdminUserContextImpl implements AdminUserContext
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = "); StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = ");
sql.append(flag ? '1' : '0').append(" WHERE uid = ").append(uid).append(';'); sql.append(flag ? '1' : '0').append(" WHERE uid = ").append(uid).append(';');
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
email_verified = flag; email_verified = flag;
ar = new AuditRecord(AuditRecord.ADMIN_ACCOUNT_CHANGE,user.realUID(),user.userRemoteAddress(),0, ar = env.newAudit(AuditRecord.ADMIN_ACCOUNT_CHANGE,"uid=" + uid,"field=verify_email");
"uid=" + uid,"field=verify_email");
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -258,8 +249,7 @@ class AdminUserContextImpl implements AdminUserContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -281,15 +271,14 @@ class AdminUserContextImpl implements AdminUserContext
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE users SET lockout = "); StringBuffer sql = new StringBuffer("UPDATE users SET lockout = ");
sql.append(flag ? '1' : '0').append(" WHERE uid = ").append(uid).append(';'); sql.append(flag ? '1' : '0').append(" WHERE uid = ").append(uid).append(';');
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
lockout = flag; lockout = flag;
ar = new AuditRecord(AuditRecord.ADMIN_LOCK_OUT,user.realUID(),user.userRemoteAddress(),0, ar = env.newAudit(AuditRecord.ADMIN_LOCK_OUT,"uid=" + uid,flag ? "locked" : "unlocked");
"uid=" + uid,flag ? "locked" : "unlocked");
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -312,8 +301,7 @@ class AdminUserContextImpl implements AdminUserContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -326,7 +314,7 @@ class AdminUserContextImpl implements AdminUserContext
ContactInfoImpl rc; ContactInfoImpl rc;
if (contactid>=0) if (contactid>=0)
rc = new ContactInfoImpl(datapool,contactid); rc = new ContactInfoImpl(env,contactid);
else else
rc = new ContactInfoImpl(uid); rc = new ContactInfoImpl(uid);
return rc; return rc;
@ -351,7 +339,7 @@ class AdminUserContextImpl implements AdminUserContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Stashable obj = (Stashable)ci; Stashable obj = (Stashable)ci;
// save the contact information // save the contact information
@ -365,8 +353,7 @@ class AdminUserContextImpl implements AdminUserContext
} // end if } // end if
ar = new AuditRecord(AuditRecord.ADMIN_USER_CONTACT_INFO,user.realUID(),user.userRemoteAddress(), ar = env.newAudit(AuditRecord.ADMIN_USER_CONTACT_INFO,"uid=" + uid,"contactid=" + contactid);
"uid=" + uid,"contactid=" + contactid);
} // end try } // end try
catch (ClassCastException cce) catch (ClassCastException cce)
@ -395,8 +382,7 @@ class AdminUserContextImpl implements AdminUserContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end if } // end if
@ -409,7 +395,7 @@ class AdminUserContextImpl implements AdminUserContext
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
PasswordHash phash = new PasswordHash(password); PasswordHash phash = new PasswordHash(password);
StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '"); StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '");
@ -418,8 +404,7 @@ class AdminUserContextImpl implements AdminUserContext
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
// record an audit record for this user // record an audit record for this user
ar = new AuditRecord(AuditRecord.ADMIN_PASSWORD_CHANGE,user.realUID(),user.userRemoteAddress(), ar = env.newAudit(AuditRecord.ADMIN_PASSWORD_CHANGE,"uid=" + uid);
"uid=" + uid);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -442,8 +427,7 @@ class AdminUserContextImpl implements AdminUserContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -462,7 +446,7 @@ class AdminUserContextImpl implements AdminUserContext
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the update statement // create the update statement
@ -474,8 +458,7 @@ class AdminUserContextImpl implements AdminUserContext
// replace the locale here // replace the locale here
my_locale = locale; my_locale = locale;
ar = new AuditRecord(AuditRecord.ADMIN_ACCOUNT_CHANGE,user.realUID(),user.userRemoteAddress(),0, ar = env.newAudit(AuditRecord.ADMIN_ACCOUNT_CHANGE,"uid=" + uid,"field=localeid");
"uid=" + uid,"field=localeid");
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -498,8 +481,7 @@ class AdminUserContextImpl implements AdminUserContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -518,7 +500,7 @@ class AdminUserContextImpl implements AdminUserContext
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the update statement // create the update statement
@ -530,8 +512,7 @@ class AdminUserContextImpl implements AdminUserContext
// replace the locale here // replace the locale here
my_tz = timezone; my_tz = timezone;
ar = new AuditRecord(AuditRecord.ADMIN_ACCOUNT_CHANGE,user.realUID(),user.userRemoteAddress(),0, ar = env.newAudit(AuditRecord.ADMIN_ACCOUNT_CHANGE,"uid=" + uid,"field=tzid");
"uid=" + uid,"field=tzid");
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -554,8 +535,7 @@ class AdminUserContextImpl implements AdminUserContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -578,14 +558,13 @@ class AdminUserContextImpl implements AdminUserContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
static AdminUserContext getAdminUserContext(EngineBackend engine, UserBackend user, DataPool datapool, static AdminUserContext getAdminUserContext(EnvUser env, int uid) throws DataException
int uid) throws DataException
{ {
Connection conn = null; Connection conn = null;
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM users INNER JOIN userprefs " ResultSet rs = stmt.executeQuery("SELECT * FROM users INNER JOIN userprefs "
+ "ON users.uid = userprefs.uid WHERE users.uid = " + uid + ";"); + "ON users.uid = userprefs.uid WHERE users.uid = " + uid + ";");
@ -594,7 +573,7 @@ class AdminUserContextImpl implements AdminUserContext
if (rs.getBoolean("is_anon")) if (rs.getBoolean("is_anon"))
throw new DataException("Cannot modify the defaults for the anonymous user."); throw new DataException("Cannot modify the defaults for the anonymous user.");
return new AdminUserContextImpl(engine,user,datapool,rs); return new AdminUserContextImpl(env,rs);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -605,21 +584,19 @@ class AdminUserContextImpl implements AdminUserContext
} // end catch } // end catch
finally finally
{ // release the connection where necessary { // release the connection where necessary
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end getAdminUserContext } // end getAdminUserContext
static AdminUserContext getAdminUserContext(EngineBackend engine, UserBackend user, DataPool datapool, static AdminUserContext getAdminUserContext(EnvUser env, String username) throws DataException
String username) throws DataException
{ {
Connection conn = null; Connection conn = null;
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM users INNER JOIN userprefs " ResultSet rs = stmt.executeQuery("SELECT * FROM users INNER JOIN userprefs "
+ "ON users.uid = userprefs.uid WHERE users.username = '" + "ON users.uid = userprefs.uid WHERE users.username = '"
@ -629,7 +606,7 @@ class AdminUserContextImpl implements AdminUserContext
if (rs.getBoolean("is_anon")) if (rs.getBoolean("is_anon"))
throw new DataException("Cannot modify the defaults for the anonymous user."); throw new DataException("Cannot modify the defaults for the anonymous user.");
return new AdminUserContextImpl(engine,user,datapool,rs); return new AdminUserContextImpl(env,rs);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -640,8 +617,7 @@ class AdminUserContextImpl implements AdminUserContext
} // end catch } // end catch
finally finally
{ // release the connection where necessary { // release the connection where necessary
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -21,6 +21,7 @@ import java.sql.*;
import java.util.Random; import java.util.Random;
import com.silverwrist.util.cache.CacheMap; import com.silverwrist.util.cache.CacheMap;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.EnvEngine;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
class AdvertisementImpl implements Advertisement class AdvertisementImpl implements Advertisement
@ -38,7 +39,7 @@ class AdvertisementImpl implements Advertisement
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private DataPool datapool; // data pool reference private EnvEngine env; // execution environment
private int adid; // ad ID private int adid; // ad ID
private String imagepath; // image path private String imagepath; // image path
private short style; // ad style private short style; // ad style
@ -50,9 +51,9 @@ class AdvertisementImpl implements Advertisement
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
protected AdvertisementImpl(DataPool datapool, ResultSet rs) throws SQLException protected AdvertisementImpl(EnvEngine env, ResultSet rs) throws SQLException
{ {
this.datapool = datapool; this.env = env;
this.adid = rs.getInt("adid"); this.adid = rs.getInt("adid");
this.imagepath = rs.getString("imagepath"); this.imagepath = rs.getString("imagepath");
this.style = rs.getShort("pathstyle"); this.style = rs.getShort("pathstyle");
@ -66,7 +67,7 @@ class AdvertisementImpl implements Advertisement
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private static Advertisement getTheAd(DataPool datapool, Statement stmt, int ad_id) throws SQLException private static Advertisement getTheAd(EnvEngine env, Statement stmt, int ad_id) throws SQLException
{ {
Integer my_ad_id = new Integer(ad_id); Integer my_ad_id = new Integer(ad_id);
Advertisement rc = (Advertisement)(ad_cache.get(my_ad_id)); Advertisement rc = (Advertisement)(ad_cache.get(my_ad_id));
@ -76,7 +77,7 @@ class AdvertisementImpl implements Advertisement
ResultSet rs = stmt.executeQuery("SELECT * From adverts WHERE adid = " + ad_id + ";"); ResultSet rs = stmt.executeQuery("SELECT * From adverts WHERE adid = " + ad_id + ";");
if (!(rs.next())) if (!(rs.next()))
return null; return null;
rc = new AdvertisementImpl(datapool,rs); rc = new AdvertisementImpl(env,rs);
ad_cache.put(my_ad_id,rc); ad_cache.put(my_ad_id,rc);
return rc; return rc;
@ -126,15 +127,15 @@ class AdvertisementImpl implements Advertisement
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
static Advertisement getAdByID(DataPool datapool, int id) static Advertisement getAdByID(EnvEngine env, int id)
{ {
Connection conn = null; Connection conn = null;
try try
{ // get a database connection and call the internal function { // get a database connection and call the internal function
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
return getTheAd(datapool,stmt,id); return getTheAd(env,stmt,id);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -144,20 +145,19 @@ class AdvertisementImpl implements Advertisement
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end getAdByID } // end getAdByID
static Advertisement getRandomAd(DataPool datapool) static Advertisement getRandomAd(EnvEngine env)
{ {
Connection conn = null; Connection conn = null;
try try
{ // get a database connection and call the internal function { // get a database connection and call the internal function
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT MAX(adid) FROM adverts;"); ResultSet rs = stmt.executeQuery("SELECT MAX(adid) FROM adverts;");
if (!(rs.next())) if (!(rs.next()))
@ -167,7 +167,7 @@ class AdvertisementImpl implements Advertisement
for (int i=0; i<100; i++) for (int i=0; i<100; i++)
{ // select an ad ID { // select an ad ID
int ad_id = rng.nextInt(maximum) + 1; int ad_id = rng.nextInt(maximum) + 1;
Advertisement rc = getTheAd(datapool,stmt,ad_id); Advertisement rc = getTheAd(env,stmt,ad_id);
if (rc!=null) if (rc!=null)
return rc; return rc;
@ -183,8 +183,7 @@ class AdvertisementImpl implements Advertisement
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -22,9 +22,10 @@ import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.util.ParallelRunQueue; import com.silverwrist.util.ParallelRunQueue;
import com.silverwrist.util.cache.ObjectCache; import com.silverwrist.util.cache.ObjectCache;
import com.silverwrist.venice.db.*;
import com.silverwrist.venice.core.DataException; import com.silverwrist.venice.core.DataException;
import com.silverwrist.venice.core.InternalStateError; import com.silverwrist.venice.core.InternalStateError;
import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*;
class BackgroundCommunityPurge implements Runnable class BackgroundCommunityPurge implements Runnable
{ {
@ -40,9 +41,7 @@ class BackgroundCommunityPurge implements Runnable
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; private EnvCommunity env;
private DataPool datapool;
private UserBackend user;
private int cid; private int cid;
private int num_confs; private int num_confs;
private int max_confid; private int max_confid;
@ -53,12 +52,9 @@ class BackgroundCommunityPurge implements Runnable
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
BackgroundCommunityPurge(EngineBackend engine, DataPool datapool, UserBackend user, int cid, int num_confs, BackgroundCommunityPurge(EnvCommunity env, int cid, int num_confs, int max_confid, ObjectCache conf_objcache)
int max_confid, ObjectCache conf_objcache)
{ {
this.engine = engine; this.env = env;
this.datapool = datapool;
this.user = user;
this.cid = cid; this.cid = cid;
this.num_confs = num_confs; this.num_confs = num_confs;
this.max_confid = max_confid; this.max_confid = max_confid;
@ -81,7 +77,7 @@ class BackgroundCommunityPurge implements Runnable
try try
{ // get a database connection from the pool { // get a database connection from the pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// run some "lower priority" deletes // run some "lower priority" deletes
@ -106,7 +102,7 @@ class BackgroundCommunityPurge implements Runnable
if (confobj!=null) if (confobj!=null)
{ // OK, there's an object - do the delete internally and release the object { // OK, there's an object - do the delete internally and release the object
conf_objcache.detach(key); conf_objcache.detach(key);
confobj.delete(user); confobj.delete(env);
} // end if } // end if
else else
@ -141,7 +137,7 @@ class BackgroundCommunityPurge implements Runnable
rs = stmt.executeQuery(sql.toString()); rs = stmt.executeQuery(sql.toString());
if (!(rs.next())) if (!(rs.next()))
throw new InternalStateError("BackgroundCommunityPurge.run screwup on conference SELECT"); throw new InternalStateError("BackgroundCommunityPurge.run screwup on conference SELECT");
rq.queue(new BackgroundConferencePurge(engine,datapool,key.intValue(),rs.getInt(1),rs.getInt(2))); rq.queue(new BackgroundConferencePurge(env,key.intValue(),rs.getInt(1),rs.getInt(2)));
} // end if (have to delete conference data) } // end if (have to delete conference data)
@ -167,8 +163,7 @@ class BackgroundCommunityPurge implements Runnable
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -22,6 +22,7 @@ import org.apache.log4j.*;
import com.silverwrist.util.ParallelRunQueue; import com.silverwrist.util.ParallelRunQueue;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.core.InternalStateError; import com.silverwrist.venice.core.InternalStateError;
import com.silverwrist.venice.core.internals.*;
class BackgroundConferencePurge implements Runnable class BackgroundConferencePurge implements Runnable
{ {
@ -30,15 +31,14 @@ class BackgroundConferencePurge implements Runnable
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private static Category logger = Category.getInstance(BackgroundConferencePurge.class.getName()); private static Category logger = Category.getInstance(BackgroundConferencePurge.class);
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Attributes * Attributes
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; private EnvEngine env; // the environment
private DataPool datapool;
private int confid; private int confid;
private int num_topics; private int num_topics;
private int max_topicid; private int max_topicid;
@ -48,11 +48,9 @@ class BackgroundConferencePurge implements Runnable
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
BackgroundConferencePurge(EngineBackend engine, DataPool datapool, int confid, int num_topics, BackgroundConferencePurge(EnvEngine env, int confid, int num_topics, int max_topicid)
int max_topicid)
{ {
this.engine = engine; this.env = env;
this.datapool = datapool;
this.confid = confid; this.confid = confid;
this.num_topics = num_topics; this.num_topics = num_topics;
this.max_topicid = max_topicid; this.max_topicid = max_topicid;
@ -74,7 +72,7 @@ class BackgroundConferencePurge implements Runnable
try try
{ // get a database connection from the pool { // get a database connection from the pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// purge out some auxiliary tables first // purge out some auxiliary tables first
@ -104,7 +102,7 @@ class BackgroundConferencePurge implements Runnable
rs = stmt.executeQuery(sql.toString()); rs = stmt.executeQuery(sql.toString());
if (!(rs.next())) if (!(rs.next()))
throw new InternalStateError("BackgroundConferencePurge.run screwup on post SELECT"); throw new InternalStateError("BackgroundConferencePurge.run screwup on post SELECT");
rq.queue(new BackgroundTopicPurge(engine,datapool,topicids[i],rs.getInt(1),rs.getLong(2))); rq.queue(new BackgroundTopicPurge(env,topicids[i],rs.getInt(1),rs.getLong(2)));
} // end for } // end for
@ -120,8 +118,7 @@ class BackgroundConferencePurge implements Runnable
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -20,6 +20,7 @@ package com.silverwrist.venice.core.impl;
import java.sql.*; import java.sql.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.core.internals.*;
class BackgroundTopicPurge implements Runnable class BackgroundTopicPurge implements Runnable
{ {
@ -28,15 +29,14 @@ class BackgroundTopicPurge implements Runnable
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private static Category logger = Category.getInstance(BackgroundTopicPurge.class.getName()); private static Category logger = Category.getInstance(BackgroundTopicPurge.class);
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Attributes * Attributes
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; private EnvEngine env; // the environment block
private DataPool datapool;
private int topicid; private int topicid;
private int num_posts; private int num_posts;
private long max_postid; private long max_postid;
@ -46,10 +46,9 @@ class BackgroundTopicPurge implements Runnable
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
BackgroundTopicPurge(EngineBackend engine, DataPool datapool, int topicid, int num_posts, long max_postid) BackgroundTopicPurge(EnvEngine env, int topicid, int num_posts, long max_postid)
{ {
this.engine = engine; this.env = env;
this.datapool = datapool;
this.topicid = topicid; this.topicid = topicid;
this.num_posts = num_posts; this.num_posts = num_posts;
this.max_postid = max_postid; this.max_postid = max_postid;
@ -71,7 +70,7 @@ class BackgroundTopicPurge implements Runnable
try try
{ // get a database connection from the pool { // get a database connection from the pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// look up all the post IDs that are present for this topic // look up all the post IDs that are present for this topic
@ -89,7 +88,7 @@ class BackgroundTopicPurge implements Runnable
stmt.executeUpdate("DELETE FROM postattach WHERE postid = " + postids[i] + ";"); stmt.executeUpdate("DELETE FROM postattach WHERE postid = " + postids[i] + ";");
stmt.executeUpdate("DELETE FROM postdogear WHERE postid = " + postids[i] + ";"); stmt.executeUpdate("DELETE FROM postdogear WHERE postid = " + postids[i] + ";");
if (stmt.executeUpdate("DELETE FROM postpublish WHERE postid = " + postids[i] + ";")>0) if (stmt.executeUpdate("DELETE FROM postpublish WHERE postid = " + postids[i] + ";")>0)
engine.unpublish(postids[i]); env.getEngine().unpublish(postids[i]);
} // end for } // end for
@ -105,8 +104,7 @@ class BackgroundTopicPurge implements Runnable
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -22,6 +22,7 @@ import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.EnvEngine;
class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
{ {
@ -61,14 +62,14 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private static Category logger = Category.getInstance(CategoryDescriptorImpl.class.getName()); private static Category logger = Category.getInstance(CategoryDescriptorImpl.class);
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Attributes * Attributes
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private DataPool datapool; // used for doing database lookups private EnvEngine env; // the execution environment
private LinkedList cats; // the actual category segments private LinkedList cats; // the actual category segments
private int symlink = -1; // if our category is actually a symlink private int symlink = -1; // if our category is actually a symlink
private boolean do_hide = true; // do we hide subcategories marked hide_dir? private boolean do_hide = true; // do we hide subcategories marked hide_dir?
@ -78,9 +79,9 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
CategoryDescriptorImpl(DataPool datapool, int catid, boolean do_hide) throws DataException CategoryDescriptorImpl(EnvEngine env, int catid, boolean do_hide) throws DataException
{ {
this.datapool = datapool; this.env = env;
cats = new LinkedList(); cats = new LinkedList();
this.do_hide = do_hide; this.do_hide = do_hide;
@ -91,7 +92,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
try try
{ // get a connection and a prepared statement { // get a connection and a prepared statement
conn = datapool.getConnection(); conn = env.getConnection();
doFillFromTop(conn,catid); doFillFromTop(conn,catid);
} // end try } // end try
@ -102,17 +103,16 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
} // end catch } // end catch
finally finally
{ // make sure and release the connection before we go { // make sure and release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end constructor } // end constructor
protected CategoryDescriptorImpl(DataPool datapool, Connection conn, int catid, boolean do_hide) protected CategoryDescriptorImpl(EnvEngine env, Connection conn, int catid, boolean do_hide)
throws SQLException, DataException throws SQLException, DataException
{ {
this.datapool = datapool; this.env = env;
cats = new LinkedList(); cats = new LinkedList();
this.do_hide = do_hide; this.do_hide = do_hide;
@ -123,9 +123,9 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
} // end constructor } // end constructor
protected CategoryDescriptorImpl(DataPool datapool, int id, int symlink, String name, boolean do_hide) protected CategoryDescriptorImpl(EnvEngine env, int id, int symlink, String name, boolean do_hide)
{ {
this.datapool = datapool; this.env = env;
this.cats = new LinkedList(); this.cats = new LinkedList();
this.symlink = symlink; this.symlink = symlink;
this.do_hide = do_hide; this.do_hide = do_hide;
@ -136,7 +136,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
protected CategoryDescriptorImpl(CategoryDescriptorImpl other, int copy_levels) protected CategoryDescriptorImpl(CategoryDescriptorImpl other, int copy_levels)
{ {
this.datapool = other.datapool; this.env = other.env;
this.cats = new LinkedList(); this.cats = new LinkedList();
this.symlink = ((copy_levels==other.cats.size()) ? other.symlink : -1); this.symlink = ((copy_levels==other.cats.size()) ? other.symlink : -1);
this.do_hide = other.do_hide; this.do_hide = other.do_hide;
@ -152,7 +152,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
protected CategoryDescriptorImpl(CategoryDescriptorImpl other, int id, int symlink, String name) protected CategoryDescriptorImpl(CategoryDescriptorImpl other, int id, int symlink, String name)
{ {
this.datapool = other.datapool; this.env = other.env;
this.cats = new LinkedList(); this.cats = new LinkedList();
this.symlink = symlink; this.symlink = symlink;
this.do_hide = other.do_hide; this.do_hide = other.do_hide;
@ -164,18 +164,6 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
} // end constructor } // end constructor
/*--------------------------------------------------------------------------------
* finalize() function
*--------------------------------------------------------------------------------
*/
protected void finalize()
{
datapool = null;
cats = null;
} // end finalize
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Internal functions * Internal functions
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -248,7 +236,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
{ {
if (symlink!=-1) if (symlink!=-1)
{ // "snap" the symlink before getting subcategories { // "snap" the symlink before getting subcategories
CategoryDescriptorImpl real_obj = new CategoryDescriptorImpl(datapool,symlink,do_hide); CategoryDescriptorImpl real_obj = new CategoryDescriptorImpl(env,symlink,do_hide);
return real_obj.getSubCategories(); return real_obj.getSubCategories();
} // end if } // end if
@ -257,7 +245,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
ArrayList rc = new ArrayList(); ArrayList rc = new ArrayList();
try try
{ // get a connection and create a statement { // get a connection and create a statement
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT catid, symlink, name FROM refcategory WHERE parent = "); StringBuffer sql = new StringBuffer("SELECT catid, symlink, name FROM refcategory WHERE parent = ");
sql.append(getCategoryID()); sql.append(getCategoryID());
@ -283,8 +271,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
} // end catch } // end catch
finally finally
{ // make sure and release the connection before we go { // make sure and release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -324,7 +311,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
public CategoryDescriptor getLinkedCategory() throws DataException public CategoryDescriptor getLinkedCategory() throws DataException
{ {
if (symlink!=-1) if (symlink!=-1)
return new CategoryDescriptorImpl(datapool,symlink,do_hide); return new CategoryDescriptorImpl(env,symlink,do_hide);
else else
return this; return this;
@ -383,13 +370,13 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
static List getTopLevelCategoryList(DataPool datapool, boolean do_hide) throws DataException static List getTopLevelCategoryList(EnvEngine env, boolean do_hide) throws DataException
{ {
Connection conn = null; Connection conn = null;
ArrayList rc = new ArrayList(); ArrayList rc = new ArrayList();
try try
{ // get a connection and create a statement { // get a connection and create a statement
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT catid, symlink, name FROM refcategory WHERE parent = -1"); StringBuffer sql = new StringBuffer("SELECT catid, symlink, name FROM refcategory WHERE parent = -1");
if (do_hide) if (do_hide)
@ -400,8 +387,8 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next()) while (rs.next())
{ // turn data values into CategoryDescriptor objects { // turn data values into CategoryDescriptor objects
CategoryDescriptor ncd = new CategoryDescriptorImpl(datapool,rs.getInt("catid"),rs.getInt("symlink"), CategoryDescriptor ncd = new CategoryDescriptorImpl(env,rs.getInt(1),rs.getInt(2),rs.getString(3),
rs.getString("name"),do_hide); do_hide);
rc.add(ncd); rc.add(ncd);
} // end while } // end while
@ -414,8 +401,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
} // end catch } // end catch
finally finally
{ // make sure and release the connection before we go { // make sure and release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -423,7 +409,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
} // end getTopLevelCategoryList } // end getTopLevelCategoryList
static List searchForCategories(DataPool datapool, boolean do_hide, boolean search_all, int mode, static List searchForCategories(EnvEngine env, boolean do_hide, boolean search_all, int mode,
String term, int offset, int count) throws DataException String term, int offset, int count) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
@ -435,7 +421,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT catid FROM refcategory WHERE name "); StringBuffer sql = new StringBuffer("SELECT catid FROM refcategory WHERE name ");
@ -478,7 +464,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
for (int i=0; i<n; i++) for (int i=0; i<n; i++)
{ // convert all the simple category IDs into full-blown CategoryDescriptor objects { // convert all the simple category IDs into full-blown CategoryDescriptor objects
CategoryDescriptor tmp = new CategoryDescriptorImpl(datapool,conn,rc_raw[i],do_hide); CategoryDescriptor tmp = new CategoryDescriptorImpl(env,conn,rc_raw[i],do_hide);
rc.add(tmp); rc.add(tmp);
} // end for } // end for
@ -492,8 +478,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -501,7 +486,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
} // end searchForCategories } // end searchForCategories
static int getSearchCategoryCount(DataPool datapool, boolean do_hide, boolean search_all, int mode, static int getSearchCategoryCount(EnvEngine env, boolean do_hide, boolean search_all, int mode,
String term) throws DataException String term) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
@ -511,7 +496,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM refcategory WHERE name "); StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM refcategory WHERE name ");
@ -560,8 +545,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -25,6 +25,7 @@ import com.silverwrist.util.StringUtil;
import com.silverwrist.util.cache.*; import com.silverwrist.util.cache.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.security.AuditRecord; import com.silverwrist.venice.security.AuditRecord;
import com.silverwrist.venice.security.Capability; import com.silverwrist.venice.security.Capability;
import com.silverwrist.venice.security.DefaultLevels; import com.silverwrist.venice.security.DefaultLevels;
@ -47,7 +48,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
Integer xconf = (Integer)key; Integer xconf = (Integer)key;
try try
{ // create the desired object { // create the desired object
return new ConferenceCommunityContextImpl(engine,CommunityCoreData.this,datapool,xconf.intValue()); return new ConferenceCommunityContextImpl(env,xconf.intValue());
} // end try } // end try
catch (DataException e) catch (DataException e)
@ -77,8 +78,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; // pointer to engine back end private EnvCommunityData env; // the environment
private DataPool datapool; // pointer to data pool
private int cid; // ID of this community private int cid; // ID of this community
private java.util.Date created; // date/time of database creation private java.util.Date created; // date/time of database creation
private java.util.Date last_access; // date/time of last access private java.util.Date last_access; // date/time of last access
@ -112,19 +112,18 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
CommunityCoreData(EngineBackend engine, DataPool datapool, int cid) throws DataException CommunityCoreData(EnvEngine env, int cid) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("new CommunityCoreData for community " + cid); logger.debug("new CommunityCoreData for community " + cid);
this.engine = engine; this.env = new EnvCommunityData(env,this);
this.datapool = datapool;
this.cid = cid; this.cid = cid;
Connection conn = null; Connection conn = null;
try try
{ // get a database connection from this object { // get a database connection from this object
conn = datapool.getConnection(); conn = env.getConnection();
// get the community basic data from the database // get the community basic data from the database
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -171,22 +170,20 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end constructor } // end constructor
protected CommunityCoreData(EngineBackend engine, DataPool datapool, int cid, java.util.Date creation, protected CommunityCoreData(EnvEngine env, int cid, java.util.Date creation,
String name, String alias, int host_uid, String language, String synopsis, String name, String alias, int host_uid, String language, String synopsis,
String rules, String joinkey, boolean hide_dir, boolean hide_search, String rules, String joinkey, boolean hide_dir, boolean hide_search,
BitSet features) BitSet features)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("new CommunityCoreData for BRAND NEW COMMUNITY " + cid); logger.debug("new CommunityCoreData for BRAND NEW COMMUNITY " + cid);
this.engine = engine; this.env = new EnvCommunityData(env,this);
this.datapool = datapool;
this.cid = cid; this.cid = cid;
this.created = creation; this.created = creation;
this.last_access = creation; this.last_access = creation;
@ -212,31 +209,11 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
this.public_comm = StringUtil.isStringEmpty(joinkey); this.public_comm = StringUtil.isStringEmpty(joinkey);
this.features = (BitSet)(features.clone()); this.features = (BitSet)(features.clone());
this.flags = new OptionSet(); this.flags = new OptionSet();
if (engine.getParamBoolean(EngineBackend.BP_POSTPICTURES)) if (env.getEngine().getParamBoolean(EngineBackend.BP_POSTPICTURES))
flags.set(BP_POSTPICTURES); flags.set(BP_POSTPICTURES);
} // end constructor } // end constructor
/*--------------------------------------------------------------------------------
* finalize() function
*--------------------------------------------------------------------------------
*/
protected void finalize()
{
engine = null;
datapool = null;
created = null;
last_access = null;
last_update = null;
name = null;
language = null;
synopsis = null;
rules = null;
alias = null;
} // end finalize
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Internal functions * Internal functions
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -313,7 +290,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
Connection conn = null; Connection conn = null;
try try
{ // get a connection and create a statement { // get a connection and create a statement
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
@ -335,8 +312,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -516,7 +492,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// check to see if the UID is listed in "sigban" table... // check to see if the UID is listed in "sigban" table...
@ -534,8 +510,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -543,7 +518,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end canJoinCommunity } // end canJoinCommunity
public synchronized void putContactInfo(UserBackend user, ContactInfo ci) throws DataException public synchronized void putContactInfo(EnvCommunity outer, ContactInfo ci) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This community has been deleted."); throw new DataException("This community has been deleted.");
@ -553,7 +528,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Stashable obj = (Stashable)ci; Stashable obj = (Stashable)ci;
// save the contact information // save the contact information
@ -568,8 +543,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end if } // end if
touchUpdate(conn); touchUpdate(conn);
ar = new AuditRecord(AuditRecord.COMMUNITY_CONTACT_INFO,user.realUID(),user.userRemoteAddress(),cid, ar = outer.newAudit(AuditRecord.COMMUNITY_CONTACT_INFO,"contactid=" + contactid);
"contactid=" + contactid);
} // end try } // end try
catch (ClassCastException cce) catch (ClassCastException cce)
@ -598,8 +572,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -611,7 +584,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end getFeatureSet } // end getFeatureSet
public synchronized void putFeatureSet(UserBackend user, BitSet set) throws DataException public synchronized void putFeatureSet(EnvCommunity outer, BitSet set) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This community has been deleted."); throw new DataException("This community has been deleted.");
@ -621,7 +594,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
stmt.executeUpdate("LOCK TABLES sigftrs WRITE;"); stmt.executeUpdate("LOCK TABLES sigftrs WRITE;");
@ -665,7 +638,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end finally } // end finally
touchUpdate(conn); touchUpdate(conn);
ar = new AuditRecord(AuditRecord.COMMUNITY_FEATURE_SET,user.realUID(),user.userRemoteAddress(),cid); ar = outer.newAudit(AuditRecord.COMMUNITY_FEATURE_SET);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -688,8 +661,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -697,19 +669,19 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
public List getCommunityFeaturesList(int level) public List getCommunityFeaturesList(int level)
{ {
return engine.getCommunityFeatureSet(features,level,canReadCommunitySubObjects(level)); return env.getEngine().getCommunityFeatureSet(features,level,canReadCommunitySubObjects(level));
} // end getCommunityFeaturesList } // end getCommunityFeaturesList
public String getDefaultApplet() public String getDefaultApplet()
{ {
StringBuffer buf = new StringBuffer(engine.getAppletForFeature(initial_feature)); StringBuffer buf = new StringBuffer(env.getEngine().getAppletForFeature(initial_feature));
buf.append("?sig=").append(cid); buf.append("?sig=").append(cid);
return buf.toString(); return buf.toString();
} // end getDefaultApplet } // end getDefaultApplet
public synchronized void setName(UserBackend user, String name) throws DataException public synchronized void setName(EnvCommunity outer, String name) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This community has been deleted."); throw new DataException("This community has been deleted.");
@ -719,7 +691,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigs SET signame = '"); StringBuffer sql = new StringBuffer("UPDATE sigs SET signame = '");
sql.append(SQLUtil.encodeString(name)).append("', lastupdate = '"); sql.append(SQLUtil.encodeString(name)).append("', lastupdate = '");
@ -728,8 +700,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
this.name = name; this.name = name;
last_update = now; last_update = now;
ar = new AuditRecord(AuditRecord.COMMUNITY_NAME,user.realUID(),user.userRemoteAddress(),cid, ar = outer.newAudit(AuditRecord.COMMUNITY_NAME,"name=" + name);
"name=" + name);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -752,14 +723,13 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end setName } // end setName
public synchronized void setAlias(UserBackend user, String alias) throws DataException public synchronized void setAlias(EnvCommunity outer, String alias) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This community has been deleted."); throw new DataException("This community has been deleted.");
@ -769,7 +739,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigs SET alias = '"); StringBuffer sql = new StringBuffer("UPDATE sigs SET alias = '");
sql.append(alias).append("', lastupdate = '"); sql.append(alias).append("', lastupdate = '");
@ -778,8 +748,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
this.alias = alias; this.alias = alias;
last_update = now; last_update = now;
ar = new AuditRecord(AuditRecord.COMMUNITY_ALIAS,user.realUID(),user.userRemoteAddress(),cid, ar = outer.newAudit(AuditRecord.COMMUNITY_ALIAS,"alias=" + alias);
"alias=" + alias);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -802,14 +771,13 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end setAlias } // end setAlias
public synchronized void setCategoryID(UserBackend user, int catid) throws DataException public synchronized void setCategoryID(EnvCommunity outer, int catid) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This community has been deleted."); throw new DataException("This community has been deleted.");
@ -819,7 +787,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigs SET catid = "); StringBuffer sql = new StringBuffer("UPDATE sigs SET catid = ");
sql.append(catid).append(", lastupdate = '"); sql.append(catid).append(", lastupdate = '");
@ -828,8 +796,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
this.category_id = catid; this.category_id = catid;
last_update = now; last_update = now;
ar = new AuditRecord(AuditRecord.COMMUNITY_CATEGORY,user.realUID(),user.userRemoteAddress(),cid, ar = outer.newAudit(AuditRecord.COMMUNITY_CATEGORY,"catid=" + catid);
"catid=" + catid);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -852,8 +819,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -868,7 +834,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigs SET synopsis = "); StringBuffer sql = new StringBuffer("UPDATE sigs SET synopsis = ");
sql.append(SQLUtil.encodeStringArg(synopsis)).append(", lastupdate = '"); sql.append(SQLUtil.encodeStringArg(synopsis)).append(", lastupdate = '");
@ -887,8 +853,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -903,7 +868,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigs SET language = '"); StringBuffer sql = new StringBuffer("UPDATE sigs SET language = '");
sql.append(SQLUtil.encodeString(language)).append("', lastupdate = '"); sql.append(SQLUtil.encodeString(language)).append("', lastupdate = '");
@ -922,8 +887,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -938,7 +902,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigs SET rules = "); StringBuffer sql = new StringBuffer("UPDATE sigs SET rules = ");
sql.append(SQLUtil.encodeStringArg(rules)).append(", lastupdate = '"); sql.append(SQLUtil.encodeStringArg(rules)).append(", lastupdate = '");
@ -957,8 +921,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -973,7 +936,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigs SET lastaccess = '"); StringBuffer sql = new StringBuffer("UPDATE sigs SET lastaccess = '");
java.util.Date now = new java.util.Date(); java.util.Date now = new java.util.Date();
@ -990,8 +953,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1009,7 +971,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end getHideSearch } // end getHideSearch
public synchronized void setHideFlags(UserBackend user, boolean directory, boolean search) public synchronized void setHideFlags(EnvCommunity outer, boolean directory, boolean search)
throws DataException throws DataException
{ {
if (deleted) if (deleted)
@ -1020,7 +982,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigs SET hide_dir = "); StringBuffer sql = new StringBuffer("UPDATE sigs SET hide_dir = ");
sql.append(directory ? '1' : '0').append(", hide_search = ").append(search ? '1' : '0'); sql.append(directory ? '1' : '0').append(", hide_search = ").append(search ? '1' : '0');
@ -1031,8 +993,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
hidden_directory = directory; hidden_directory = directory;
hidden_search = search; hidden_search = search;
last_update = now; last_update = now;
ar = new AuditRecord(AuditRecord.COMMUNITY_HIDE_INFO,user.realUID(),user.userRemoteAddress(),cid, ar = outer.newAudit(AuditRecord.COMMUNITY_HIDE_INFO,"dir=" + directory + ",search=" + search);
"dir=" + directory + ",search=" + search);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -1055,8 +1016,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1068,7 +1028,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end getMembersOnly } // end getMembersOnly
public synchronized void setMembersOnly(UserBackend user, boolean flag) throws DataException public synchronized void setMembersOnly(EnvCommunity outer, boolean flag) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This community has been deleted."); throw new DataException("This community has been deleted.");
@ -1078,7 +1038,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigs SET membersonly = "); StringBuffer sql = new StringBuffer("UPDATE sigs SET membersonly = ");
sql.append(flag ? '1' : '0').append(", lastupdate = '"); sql.append(flag ? '1' : '0').append(", lastupdate = '");
@ -1087,8 +1047,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
members_only = flag; members_only = flag;
last_update = now; last_update = now;
ar = new AuditRecord(AuditRecord.COMMUNITY_MEMBERS_ONLY,user.realUID(),user.userRemoteAddress(),cid, ar = outer.newAudit(AuditRecord.COMMUNITY_MEMBERS_ONLY,"flag=" + flag);
"flag=" + flag);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -1111,8 +1070,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1133,7 +1091,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigs SET init_ftr = "); StringBuffer sql = new StringBuffer("UPDATE sigs SET init_ftr = ");
sql.append(ndx).append(", lastupdate = '"); sql.append(ndx).append(", lastupdate = '");
@ -1152,8 +1110,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1168,7 +1125,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT joinkey FROM sigs WHERE sigid = "); StringBuffer sql = new StringBuffer("SELECT joinkey FROM sigs WHERE sigid = ");
sql.append(cid).append(';'); sql.append(cid).append(';');
@ -1191,14 +1148,13 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end getJoinKey } // end getJoinKey
public synchronized void setJoinKey(UserBackend user, String key) throws DataException public synchronized void setJoinKey(EnvCommunity outer, String key) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This community has been deleted."); throw new DataException("This community has been deleted.");
@ -1208,7 +1164,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigs SET joinkey = "); StringBuffer sql = new StringBuffer("UPDATE sigs SET joinkey = ");
sql.append(SQLUtil.encodeStringArg(key)).append(", lastupdate = '"); sql.append(SQLUtil.encodeStringArg(key)).append(", lastupdate = '");
@ -1217,7 +1173,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
public_comm = StringUtil.isStringEmpty(key); public_comm = StringUtil.isStringEmpty(key);
last_update = now; last_update = now;
ar = new AuditRecord(AuditRecord.COMMUNITY_JOIN_KEY,user.realUID(),user.userRemoteAddress(),cid); ar = outer.newAudit(AuditRecord.COMMUNITY_JOIN_KEY);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -1240,8 +1196,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1277,7 +1232,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end getJoinLevel } // end getJoinLevel
public synchronized void setSecurityLevels(UserBackend user, int read, int write, int create, int delete, public synchronized void setSecurityLevels(EnvCommunity outer, int read, int write, int create, int delete,
int join) throws DataException int join) throws DataException
{ {
if (deleted) if (deleted)
@ -1288,7 +1243,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
// create the SQL statement // create the SQL statement
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -1311,7 +1266,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
last_update = now; last_update = now;
// create an audit record reflecting what was done // create an audit record reflecting what was done
ar = new AuditRecord(AuditRecord.COMMUNITY_SECURITY,user.realUID(),user.userRemoteAddress(),cid); ar = outer.newAudit(AuditRecord.COMMUNITY_SECURITY);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -1334,8 +1289,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1347,7 +1301,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end isAdminCommunity } // end isAdminCommunity
public synchronized void setMembership(UserBackend user, int uid, int grant_level, boolean locked, public synchronized void setMembership(EnvCommunity outer, int uid, int grant_level, boolean locked,
boolean hidden) throws DataException boolean hidden) throws DataException
{ {
if (deleted) if (deleted)
@ -1358,7 +1312,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
boolean did_it = false; boolean did_it = false;
stmt.executeUpdate("LOCK TABLES sigmember WRITE;"); stmt.executeUpdate("LOCK TABLES sigmember WRITE;");
@ -1411,8 +1365,8 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
if (did_it) if (did_it)
{ // update the community data and generate an audit record { // update the community data and generate an audit record
touchUpdate(conn); touchUpdate(conn);
ar = new AuditRecord(AuditRecord.SET_MEMBERSHIP,user.realUID(),user.userRemoteAddress(),cid, ar = outer.newAudit(AuditRecord.SET_MEMBERSHIP,"uid=" + uid,"level=" + grant_level);
"uid=" + uid,"level=" + grant_level);
} // end if } // end if
} // end try } // end try
@ -1436,8 +1390,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1452,7 +1405,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection and create the appropriate SELECT statement { // get a database connection and create the appropriate SELECT statement
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM sigmember WHERE sigid = "); StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM sigmember WHERE sigid = ");
sql.append(cid); sql.append(cid);
@ -1476,8 +1429,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1487,7 +1439,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
{ {
if (deleted) if (deleted)
return false; return false;
int ndx = engine.getFeatureIndexBySymbol(symbol); int ndx = env.getEngine().getFeatureIndexBySymbol(symbol);
if (ndx>=0) if (ndx>=0)
return features.get(ndx); return features.get(ndx);
else else
@ -1530,23 +1482,22 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end detachConferenceDataObject } // end detachConferenceDataObject
public ConferenceCommunityContext createConference(CommunityBackend comm, String name, String alias, public ConferenceCommunityContext createConference(EnvCommunity outer, String name, String alias,
String description, boolean pvt, boolean hide_list) String description, boolean pvt, boolean hide_list)
throws DataException throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This community has been deleted."); throw new DataException("This community has been deleted.");
ReturnConfSeq rcs = ConferenceCoreData.createConference(engine,comm,datapool,name,alias,description, ReturnConfSeq rcs = ConferenceCoreData.createConference(outer,env,name,alias,description,pvt,hide_list,
pvt,hide_list,host_uid); host_uid);
ConferenceData cdata = rcs.getConference(); ConferenceData cdata = rcs.getConference();
if (comm.realUID()!=host_uid) // make the creating user a conference host too if (outer.getUserID()!=host_uid) // make the creating user a conference host too
cdata.setMembership(comm,comm.realUID(),DefaultLevels.hostConference()); cdata.setMembership(outer,outer.getUserID(),DefaultLevels.hostConference());
// Wrap the returned ConferenceData object in a ConferenceCommunityContextImpl object and release the // Wrap the returned ConferenceData object in a ConferenceCommunityContextImpl object.
// extra reference on it.
ConferenceCommunityContextImpl conf = ConferenceCommunityContextImpl conf =
new ConferenceCommunityContextImpl(engine,this,datapool,rcs.getSequence(),hide_list,cdata); new ConferenceCommunityContextImpl(env,rcs.getSequence(),hide_list,cdata);
rcs = null; rcs = null;
conf_objcache.register(new Integer(conf.getConfID()),conf); // register this object with our local cache conf_objcache.register(new Integer(conf.getConfID()),conf); // register this object with our local cache
@ -1570,7 +1521,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create a new SQL statement // create a new SQL statement
@ -1651,8 +1602,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1674,7 +1624,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM users u, contacts c, sigmember m WHERE " StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM users u, contacts c, sigmember m WHERE "
+ "u.contactid = c.contactid AND u.uid = m.uid AND m.sigid = "); + "u.contactid = c.contactid AND u.uid = m.uid AND m.sigid = ");
@ -1746,8 +1696,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1766,7 +1715,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create a new SQL statement // create a new SQL statement
@ -1804,8 +1753,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1825,7 +1773,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// a relatively simple search // a relatively simple search
@ -1848,14 +1796,13 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end getMemberLevel } // end getMemberLevel
public void delete(UserBackend user) throws DataException public void delete(EnvCommunity outer) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This community has been deleted."); throw new DataException("This community has been deleted.");
@ -1869,7 +1816,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// lock the tables we need to reference immediately // lock the tables we need to reference immediately
@ -1914,7 +1861,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end finally } // end finally
// create an audit record indicating what happened // create an audit record indicating what happened
ar = new AuditRecord(AuditRecord.DELETE_COMMUNITY,user.realUID(),user.userRemoteAddress(),cid); ar = outer.newAudit(AuditRecord.DELETE_COMMUNITY);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -1937,14 +1884,13 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
// Delete the rest of the gunk in the background; use another thread to do it. // Delete the rest of the gunk in the background; use another thread to do it.
BackgroundCommunityPurge purger = new BackgroundCommunityPurge(engine,datapool,user,cid,conf_count, BackgroundCommunityPurge purger = new BackgroundCommunityPurge(outer,cid,conf_count,conf_max,
conf_max,conf_objcache); conf_objcache);
Thread thrd = new Thread(purger); Thread thrd = new Thread(purger);
thrd.setPriority(Thread.NORM_PRIORITY-1); thrd.setPriority(Thread.NORM_PRIORITY-1);
thrd.start(); thrd.start();
@ -2002,13 +1948,12 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
static CommunityData createCommunity(EngineBackend engine, UserBackend user, DataPool datapool, String name, static CommunityData createCommunity(EnvUser env, String name, String alias, int host_uid, String language,
String alias, int host_uid, String language, String synopsis, String synopsis, String rules, String joinkey, boolean hide_dir,
String rules, String joinkey, boolean hide_dir, boolean hide_search) boolean hide_search) throws DataException, AccessError
throws DataException, AccessError
{ {
Connection conn = null; // database connection Connection conn = null; // database connection
BitSet def_features = engine.getDefaultFeaturesMask(); BitSet def_features = env.getEngine().getDefaultFeaturesMask();
int new_cid; // ID of the new community int new_cid; // ID of the new community
java.util.Date creation; // creation date! java.util.Date creation; // creation date!
AuditRecord ar = null; // the audit record AuditRecord ar = null; // the audit record
@ -2016,7 +1961,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
try try
{ // get a database connection and create the appropriate SELECT statement { // get a database connection and create the appropriate SELECT statement
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
stmt.executeUpdate("LOCK TABLES sigs WRITE, sigftrs WRITE, propcomm WRITE, sigmember WRITE;"); stmt.executeUpdate("LOCK TABLES sigs WRITE, sigftrs WRITE, propcomm WRITE, sigmember WRITE;");
@ -2100,8 +2045,8 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
// Create the CommunityCoreData object representing this community and register it with the engine's // Create the CommunityCoreData object representing this community and register it with the engine's
// community data object cache. // community data object cache.
comm = new CommunityCoreData(engine,datapool,new_cid,creation,name,alias,host_uid,language,synopsis, comm = new CommunityCoreData(env,new_cid,creation,name,alias,host_uid,language,synopsis,rules,joinkey,
rules,joinkey,hide_dir,hide_search,def_features); hide_dir,hide_search,def_features);
comm.newProperties(conn); comm.newProperties(conn);
} // end try } // end try
@ -2112,10 +2057,10 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end finally } // end finally
engine.registerNewCommunity(comm); env.getEngine().registerNewCommunity(comm);
// create an audit record indicating we were successful // create an audit record indicating we were successful
ar = new AuditRecord(AuditRecord.CREATE_COMMUNITY,host_uid,user.userRemoteAddress(),new_cid, ar = new AuditRecord(AuditRecord.CREATE_COMMUNITY,host_uid,env.getUser().userRemoteAddress(),new_cid,
"name=" + name,"alias=" + alias); "name=" + name,"alias=" + alias);
} // end try } // end try
@ -2139,8 +2084,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -21,11 +21,12 @@ import java.sql.*;
import java.util.*; import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.util.*; import com.silverwrist.util.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.security.AuditRecord; import com.silverwrist.venice.security.AuditRecord;
import com.silverwrist.venice.security.Capability; import com.silverwrist.venice.security.Capability;
import com.silverwrist.venice.security.DefaultLevels; import com.silverwrist.venice.security.DefaultLevels;
import com.silverwrist.venice.core.*;
class CommunityUserContextImpl implements CommunityContext, CommunityBackend class CommunityUserContextImpl implements CommunityContext, CommunityBackend
{ {
@ -72,9 +73,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; // pointer to the engine back end private EnvCommunity env; // the environment
private UserBackend user; // pointer to the user back end
private DataPool datapool; // pointer to the main data pool
private int cid; // ID of the underlying community private int cid; // ID of the underlying community
private int level; // access level we have to the community private int level; // access level we have to the community
private boolean is_member; // are we a member of the community? private boolean is_member; // are we a member of the community?
@ -89,30 +88,25 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
protected CommunityUserContextImpl(EngineBackend engine, UserBackend user, DataPool datapool, int cid, protected CommunityUserContextImpl(EnvUser env, int cid, int granted_level, boolean locked, String name,
int granted_level, boolean locked, String name, String alias) String alias)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("CommunityUserContextImpl constructor:member"); logger.debug("CommunityUserContextImpl constructor:member");
this.engine = engine; this.env = new EnvCommunity(env,this);
this.user = user;
this.datapool = datapool;
this.cid = cid; this.cid = cid;
setMemberValues(granted_level,true,locked); setMemberValues(granted_level,true,locked);
this.cache = new CommunitySimpleDataCache(name,alias); this.cache = new CommunitySimpleDataCache(name,alias);
} // end constructor } // end constructor
protected CommunityUserContextImpl(EngineBackend engine, UserBackend user, DataPool datapool, int cid, protected CommunityUserContextImpl(EnvUser env, int cid, String name, String alias)
String name, String alias)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("CommunityUserContextImpl constructor:ordinary"); logger.debug("CommunityUserContextImpl constructor:ordinary");
this.engine = engine; this.env = new EnvCommunity(env,this);
this.user = user;
this.datapool = datapool;
this.cid = cid; this.cid = cid;
this.level = user.realBaseLevel(); this.level = env.getUser().realBaseLevel();
this.is_member = false; this.is_member = false;
this.show_admin = false; this.show_admin = false;
this.locked = false; this.locked = false;
@ -120,13 +114,11 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end constructor } // end constructor
CommunityUserContextImpl(EngineBackend engine, UserBackend user, DataPool datapool, CommunityData data) CommunityUserContextImpl(EnvUser env, CommunityData data)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("CommunityUserContextImpl constructor:newCommunity"); logger.debug("CommunityUserContextImpl constructor:newCommunity");
this.engine = engine; this.env = new EnvCommunity(env,this);
this.user = user;
this.datapool = datapool;
this.cid = data.getID(); this.cid = data.getID();
this.cache = null; // no cache required - we have the CommunityData this.cache = null; // no cache required - we have the CommunityData
this.data = data; this.data = data;
@ -145,10 +137,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
logger.debug("setMemberValues(" + String.valueOf(granted_level) + ", " + String.valueOf(member) logger.debug("setMemberValues(" + String.valueOf(granted_level) + ", " + String.valueOf(member)
+ ", " + String.valueOf(locked) + ")"); + ", " + String.valueOf(locked) + ")");
if (user.realBaseLevel()>granted_level) this.level = Math.max(env.getUser().realBaseLevel(),granted_level);
this.level = user.realBaseLevel();
else
this.level = granted_level;
this.is_member = member; this.is_member = member;
this.show_admin = Capability.isCommunityAdmin(granted_level); this.show_admin = Capability.isCommunityAdmin(granted_level);
this.locked = locked; this.locked = locked;
@ -161,9 +150,9 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
{ // attempt to load the CommunityData object { // attempt to load the CommunityData object
if (deleted) if (deleted)
throw new DataException("This community has been deleted."); throw new DataException("This community has been deleted.");
data = engine.getCommunityDataObject(cid); data = env.getEngine().getCommunityDataObject(cid);
if (data!=null) if (data!=null)
user.saveMRU("community",data); env.getUser().saveMRU("community",data);
// clear cache when we get the real data // clear cache when we get the real data
cache = null; cache = null;
@ -182,9 +171,9 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
return null; // we're deleted return null; // we're deleted
try try
{ // attempt to load the CommunityDataObject { // attempt to load the CommunityDataObject
data = engine.getCommunityDataObject(cid); data = env.getEngine().getCommunityDataObject(cid);
if (data!=null) if (data!=null)
user.saveMRU("community",data); env.getUser().saveMRU("community",data);
} // end try } // end try
catch (DataException e) catch (DataException e)
@ -216,7 +205,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
getData().testMembership(level,is_member); getData().testMembership(level,is_member);
if (!(engine.canAccessFeature("CONF",level,getData().canReadCommunitySubObjects(level)))) if (!(env.getEngine().canAccessFeature("CONF",level,getData().canReadCommunitySubObjects(level))))
{ // you can't access the conferences! { // you can't access the conferences!
logger.error("user not permitted to read confs from this community"); logger.error("user not permitted to read confs from this community");
throw new AccessError("You are not permitted to access this community's conferences."); throw new AccessError("You are not permitted to access this community's conferences.");
@ -225,8 +214,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end testConferenceAccess } // end testConferenceAccess
private static CommunityUserContextImpl getCommunityPrivate(EngineBackend engine, UserBackend user, private static CommunityUserContextImpl getCommunityPrivate(EnvUser env, Connection conn, int cid)
DataPool datapool, Connection conn, int cid)
throws DataException throws DataException
{ {
try try
@ -243,8 +231,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
// initialize the object and check membership info // initialize the object and check membership info
CommunityUserContextImpl sc = new CommunityUserContextImpl(engine,user,datapool,cid, CommunityUserContextImpl sc = new CommunityUserContextImpl(env,cid,rs.getString(1),rs.getString(2));
rs.getString(1),rs.getString(2));
sc.checkMembership(conn); sc.checkMembership(conn);
return sc; return sc;
@ -339,8 +326,8 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
{ {
if (deleted) if (deleted)
throw new DataException("This community has been deleted."); throw new DataException("This community has been deleted.");
return new CategoryDescriptorImpl(datapool,getData().getCategoryID(), return new CategoryDescriptorImpl(env,getData().getCategoryID(),
Capability.hideHiddenCategories(user.realBaseLevel())); Capability.hideHiddenCategories(env.getUser().realBaseLevel()));
} // end getCategory } // end getCategory
@ -373,11 +360,11 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
// load the profile for the user // load the profile for the user
return new UserProfileImpl(engine,user,conn,getData().getHostUID(), return new UserProfileImpl(env,conn,getData().getHostUID(),
Capability.canSeeHiddenContactFields(user.realBaseLevel())); Capability.canSeeHiddenContactFields(env.getUser().realBaseLevel()));
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -387,8 +374,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -463,7 +449,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
int id = getData().getContactID(); int id = getData().getContactID();
ContactInfo rc; ContactInfo rc;
if (id>=0) if (id>=0)
rc = new ContactInfoImpl(datapool,id); rc = new ContactInfoImpl(env,id);
else else
rc = new ContactInfoImpl(getData().getHostUID(),cid); rc = new ContactInfoImpl(getData().getHostUID(),cid);
getData().touch(); getData().touch();
@ -489,7 +475,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
getData().putContactInfo(user,ci); getData().putContactInfo(env,ci);
} // end putContactInfo } // end putContactInfo
@ -515,7 +501,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
// Adjust the "mask"...this function cannot affect the set of "locked" features. // Adjust the "mask"...this function cannot affect the set of "locked" features.
BitSet real_mask = (BitSet)(mask.clone()); BitSet real_mask = (BitSet)(mask.clone());
real_mask.andNot(engine.getLockedFeaturesMask()); real_mask.andNot(env.getEngine().getLockedFeaturesMask());
// Figure out which bits are being carried over from the old feature set. // Figure out which bits are being carried over from the old feature set.
BitSet new_features = getData().getFeatureSet(); BitSet new_features = getData().getFeatureSet();
@ -528,7 +514,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
// Put the features together to result in the final feature set, which we set down in // Put the features together to result in the final feature set, which we set down in
// the "back end" class. // the "back end" class.
new_features.or(update_bits); new_features.or(update_bits);
getData().putFeatureSet(user,new_features); getData().putFeatureSet(env,new_features);
} // end setFeatures } // end setFeatures
@ -562,7 +548,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
getData().setName(user,name); getData().setName(env,name);
} // end setName } // end setName
@ -576,7 +562,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
getData().setAlias(user,alias); getData().setAlias(env,alias);
} // end setAlias } // end setAlias
@ -597,7 +583,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
getData().setCategoryID(user,catid); getData().setCategoryID(env,catid);
} // end setCategoryID } // end setCategoryID
@ -689,7 +675,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
boolean hide_dir = (mode!=HIDE_NONE); boolean hide_dir = (mode!=HIDE_NONE);
boolean hide_search = (mode==HIDE_BOTH); boolean hide_search = (mode==HIDE_BOTH);
getData().setHideFlags(user,hide_dir,hide_search); getData().setHideFlags(env,hide_dir,hide_search);
} // end setHideMode } // end setHideMode
@ -720,7 +706,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
getData().setMembersOnly(user,flag); getData().setMembersOnly(env,flag);
} // end setMembersOnly } // end setMembersOnly
@ -736,7 +722,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
public void setInitialFeatureIndex(short ndx) throws DataException, AccessError public void setInitialFeatureIndex(short ndx) throws DataException, AccessError
{ {
if (!(engine.isValidInitialFeatureIndex(ndx))) if (!(env.getEngine().isValidInitialFeatureIndex(ndx)))
{ // the mode is not valid { // the mode is not valid
logger.error("feature index value " + String.valueOf(ndx) + " is not valid"); logger.error("feature index value " + String.valueOf(ndx) + " is not valid");
throw new IllegalArgumentException("invalid initial feature index"); throw new IllegalArgumentException("invalid initial feature index");
@ -786,7 +772,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
getData().setJoinKey(user,key); getData().setJoinKey(env,key);
} // end setJoinKey } // end setJoinKey
@ -905,7 +891,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
getData().setSecurityLevels(user,read,write,create,delete,join); getData().setSecurityLevels(env,read,write,create,delete,join);
} // end setSecurityLevels } // end setSecurityLevels
@ -958,7 +944,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
if (!(getData().canJoinCommunity(user.realUID(),level))) if (!(getData().canJoinCommunity(env.getUserID(),level)))
{ // this user can't join up! { // this user can't join up!
logger.error("user not permitted to join community"); logger.error("user not permitted to join community");
throw new AccessError("You are not permitted to join this community."); throw new AccessError("You are not permitted to join this community.");
@ -984,7 +970,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
// else we can join without specifying a key // else we can join without specifying a key
// actually set the data in the database // actually set the data in the database
getData().setMembership(user,user.realUID(),DefaultLevels.memberCommunity(),false,false); getData().setMembership(env,env.getUserID(),DefaultLevels.memberCommunity(),false,false);
// and update our internal data store // and update our internal data store
setMemberValues(DefaultLevels.memberCommunity(),true,false); setMemberValues(DefaultLevels.memberCommunity(),true,false);
@ -1013,7 +999,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
// actually set the data in the database // actually set the data in the database
getData().setMembership(user,user.realUID(),-1,false,false); getData().setMembership(env,env.getUserID(),-1,false,false);
// and update our internal data store // and update our internal data store
setMemberValues(-1,false,false); setMemberValues(-1,false,false);
@ -1038,7 +1024,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
return false; return false;
CommunityData d = getDataNE(); CommunityData d = getDataNE();
if (d!=null) if (d!=null)
return d.canJoinCommunity(user.realUID(),level); return d.canJoinCommunity(env.getUserID(),level);
else else
return false; return false;
@ -1047,21 +1033,21 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
public List getConferences() throws DataException, AccessError public List getConferences() throws DataException, AccessError
{ {
testConferenceAccess(); testConferenceAccess();
return ConferenceUserContextImpl.getCommunityConferences(engine,this,datapool); return ConferenceUserContextImpl.getCommunityConferences(env);
} // end getConferences } // end getConferences
public ConferenceContext getConferenceContext(int confid) throws DataException, AccessError public ConferenceContext getConferenceContext(int confid) throws DataException, AccessError
{ {
testConferenceAccess(); testConferenceAccess();
return ConferenceUserContextImpl.getConference(engine,this,datapool,confid); return ConferenceUserContextImpl.getConference(env,confid);
} // end getConferenceContext } // end getConferenceContext
public ConferenceContext getConferenceContext(String alias) throws DataException, AccessError public ConferenceContext getConferenceContext(String alias) throws DataException, AccessError
{ {
testConferenceAccess(); testConferenceAccess();
return ConferenceUserContextImpl.getConference(engine,this,datapool,alias); return ConferenceUserContextImpl.getConference(env,alias);
} // end getConferenceContext } // end getConferenceContext
@ -1084,10 +1070,10 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
// call down to the community core data to create the conference // call down to the community core data to create the conference
ConferenceCommunityContext cdata = getData().createConference(this,name,alias,description,pvt,hide_list); ConferenceCommunityContext cdata = getData().createConference(env,name,alias,description,pvt,hide_list);
// wrap the returned object in a conference user context object and release the extra reference // wrap the returned object in a conference user context object and release the extra reference
return new ConferenceUserContextImpl(engine,this,datapool,cdata); return new ConferenceUserContextImpl(env,cdata);
} // end createConference } // end createConference
@ -1160,9 +1146,9 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
// actually set the data in the database // actually set the data in the database
getData().setMembership(user,uid,new_level,false,false); getData().setMembership(env,uid,new_level,false,false);
if (uid==user.realUID()) // and update our internal data store if (uid==env.getUserID()) // and update our internal data store
setMemberValues(new_level,(new_level>0),false); setMemberValues(new_level,(new_level>0),false);
} // end setMembership } // end setMembership
@ -1190,8 +1176,8 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
// call the methods required to delete the community // call the methods required to delete the community
my_comm.delete(user); my_comm.delete(env);
engine.detachCommunityDataObject(cid); env.getEngine().detachCommunityDataObject(cid);
// flag that we've been deleted // flag that we've been deleted
cache = null; cache = null;
@ -1205,14 +1191,14 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
public void sendInvitation(String address, String personal_message) public void sendInvitation(String address, String personal_message)
throws AccessError, DataException, EmailException throws AccessError, DataException, EmailException
{ {
if (user.userIsAnonymous()) if (env.getUser().userIsAnonymous())
throw new AccessError("You must be logged in to send an invitation."); throw new AccessError("You must be logged in to send an invitation.");
CommunityData my_comm = getData(); CommunityData my_comm = getData();
my_comm.testMembership(level,is_member); my_comm.testMembership(level,is_member);
// Prepare the subject line to be sent to the user. // Prepare the subject line to be sent to the user.
String subject = engine.getStockMessage("subj-invite"); String subject = env.getEngine().getStockMessage("subj-invite");
HashMap vars = new HashMap(5); HashMap vars = new HashMap(5);
vars.put("community.name",my_comm.getName()); vars.put("community.name",my_comm.getName());
subject = StringUtil.replaceAllVariables(subject,vars); subject = StringUtil.replaceAllVariables(subject,vars);
@ -1220,10 +1206,10 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
// Prepare the message text to be sent to the user. // Prepare the message text to be sent to the user.
String msg; String msg;
if (my_comm.isPublicCommunity()) if (my_comm.isPublicCommunity())
msg = engine.getStockMessage("invite-public"); msg = env.getEngine().getStockMessage("invite-public");
else else
{ // get the private invite message and set the join key variable { // get the private invite message and set the join key variable
msg = engine.getStockMessage("invite-private"); msg = env.getEngine().getStockMessage("invite-private");
vars.put("joinkey",my_comm.getJoinKey()); vars.put("joinkey",my_comm.getJoinKey());
} // end else } // end else
@ -1231,16 +1217,16 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
// Set the remaining variables and replace them. // Set the remaining variables and replace them.
vars.put("community.alias",my_comm.getAlias()); vars.put("community.alias",my_comm.getAlias());
vars.put("personal",personal_message); vars.put("personal",personal_message);
vars.put("fullname",user.realFullName()); vars.put("fullname",env.getUser().realFullName());
String uname = user.realUserName(); String uname = env.getUser().realUserName();
vars.put("username",uname); vars.put("username",uname);
msg = StringUtil.replaceAllVariables(msg,vars); msg = StringUtil.replaceAllVariables(msg,vars);
StringBuffer msg_buf = new StringBuffer(msg); StringBuffer msg_buf = new StringBuffer(msg);
msg_buf.append("\n\n--\n").append(engine.getStockMessage("signature")); msg_buf.append("\n\n--\n").append(env.getEngine().getStockMessage("signature"));
// Get a SimpleEmailer object, set it up, and send it. // Get a Emailer object, set it up, and send it.
SimpleEmailer em = engine.createEmailer(); Emailer em = env.getEngine().createEmailer();
em.setFrom(uname,user.realEmailAddress()); em.setFrom(uname,env.getUser().realEmailAddress());
em.setTo(address); em.setTo(address);
em.setSubject(subject); em.setSubject(subject);
em.setText(msg_buf.toString()); em.setText(msg_buf.toString());
@ -1250,7 +1236,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
public boolean canSendInvitation() public boolean canSendInvitation()
{ {
if (user.userIsAnonymous()) if (env.getUser().userIsAnonymous())
return false; return false;
CommunityData d = getDataNE(); CommunityData d = getDataNE();
if (d==null) if (d==null)
@ -1275,7 +1261,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
try try
{ // retrieve a connection from the data pool and get the audit records { // retrieve a connection from the data pool and get the audit records
conn = datapool.getConnection(); conn = env.getConnection();
rc = AuditRecord.getAuditRecords(conn,cid,offset,count); rc = AuditRecord.getAuditRecords(conn,cid,offset,count);
} // end try } // end try
@ -1288,7 +1274,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) if (conn!=null)
datapool.releaseConnection(conn); env.releaseConnection(conn);
} // end finally } // end finally
@ -1312,7 +1298,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
try try
{ // retrieve a connection from the data pool and get the audit records { // retrieve a connection from the data pool and get the audit records
conn = datapool.getConnection(); conn = env.getConnection();
rc = AuditRecord.getAuditRecordCount(conn,cid); rc = AuditRecord.getAuditRecordCount(conn,cid);
} // end try } // end try
@ -1325,7 +1311,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) if (conn!=null)
datapool.releaseConnection(conn); env.releaseConnection(conn);
} // end finally } // end finally
@ -1363,65 +1349,6 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end setProperties } // end setProperties
/*--------------------------------------------------------------------------------
* Implementations from interface UserBackend
*--------------------------------------------------------------------------------
*/
public int realUID()
{
return user.realUID();
} // end realUID
public int realBaseLevel()
{
return user.realBaseLevel();
} // end realBaseLevel
public String userRemoteAddress()
{
return user.userRemoteAddress();
} // end userRemoteAddress
public String userDefaultPseud() throws DataException
{
return user.userDefaultPseud();
} // end userDefaultPseud
public boolean userIsAnonymous()
{
return user.userIsAnonymous();
} // end userIsAnonymous
public String realUserName()
{
return user.realUserName();
} // end realUserName
public String realEmailAddress() throws DataException
{
return user.realEmailAddress();
} // end realEmailAddress
public String realFullName() throws DataException
{
return user.realFullName();
} // end realFullName
public void saveMRU(String tag, Object data)
{
user.saveMRU(tag,data);
} // end saveMRU
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface CommunityBackend * Implementations from interface CommunityBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -1498,30 +1425,29 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
static List getMemberCommunityEntries(EngineBackend engine, UserBackend user, DataPool datapool) static List getMemberCommunityEntries(EnvUser env) throws DataException
throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("getMemberCommunityEntries for user #" + String.valueOf(user.realUID())); logger.debug("getMemberCommunityEntries for user #" + String.valueOf(env.getUserID()));
ArrayList rc = new ArrayList(); // return from this function ArrayList rc = new ArrayList(); // return from this function
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT sm.sigid, sm.granted_lvl, sm.locked, s.signame, s.alias " StringBuffer sql = new StringBuffer("SELECT sm.sigid, sm.granted_lvl, sm.locked, s.signame, s.alias "
+ "FROM sigmember sm, sigs s WHERE sm.sigid = s.sigid " + "FROM sigmember sm, sigs s WHERE sm.sigid = s.sigid "
+ "AND sm.uid = "); + "AND sm.uid = ");
sql.append(user.realUID()).append(" ORDER BY s.signame;"); sql.append(env.getUserID()).append(" ORDER BY s.signame;");
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next()) while (rs.next())
{ // create the user contexts and add them to the return vector { // create the user contexts and add them to the return vector
int the_cid = rs.getInt(1); int the_cid = rs.getInt(1);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("...found community #" + the_cid); logger.debug("...found community #" + the_cid);
CommunityContext tmp = new CommunityUserContextImpl(engine,user,datapool,the_cid,rs.getInt(2), CommunityContext tmp = new CommunityUserContextImpl(env,the_cid,rs.getInt(2),rs.getBoolean(3),
rs.getBoolean(3),rs.getString(4),rs.getString(5)); rs.getString(4),rs.getString(5));
rc.add(tmp); rc.add(tmp);
} // end while } // end while
@ -1535,8 +1461,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1544,17 +1469,16 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end getMemberCommunityEntries } // end getMemberCommunityEntries
static CommunityContext getCommunityContext(EngineBackend engine, UserBackend user, DataPool datapool, static CommunityContext getCommunityContext(EnvUser env, int cid) throws DataException
int cid) throws DataException
{ {
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
// return the community we want // return the community we want
return getCommunityPrivate(engine,user,datapool,conn,cid); return getCommunityPrivate(env,conn,cid);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -1565,21 +1489,19 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end getCommunityContext } // end getCommunityContext
static CommunityContext getCommunityContext(EngineBackend engine, UserBackend user, DataPool datapool, static CommunityContext getCommunityContext(EnvUser env, String alias) throws DataException
String alias) throws DataException
{ {
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
// create the query to find the community in the table // create the query to find the community in the table
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -1594,8 +1516,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end if } // end if
// initialize the object and check membership info // initialize the object and check membership info
CommunityUserContextImpl c = new CommunityUserContextImpl(engine,user,datapool,rs.getInt(1), CommunityUserContextImpl c = new CommunityUserContextImpl(env,rs.getInt(1),rs.getString(2),alias);
rs.getString(2),alias);
c.checkMembership(conn); c.checkMembership(conn);
return c; return c;
@ -1608,22 +1529,20 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end getCommunityContext } // end getCommunityContext
static CommunityBackend getCommunityBackend(EngineBackend engine, UserBackend user, DataPool datapool, static CommunityBackend getCommunityBackend(EnvUser env, Connection conn, int cid) throws DataException
Connection conn, int cid) throws DataException
{ {
return getCommunityPrivate(engine,user,datapool,conn,cid); return getCommunityPrivate(env,conn,cid);
} // end getCommunityBackend } // end getCommunityBackend
static List searchForCommunities(EngineBackend engine, UserBackend user, DataPool datapool, int field, static List searchForCommunities(EnvUser env, int field, int mode, String term, int offset, int count)
int mode, String term, int offset, int count) throws DataException throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Community search: field = " + field + ", mode = " + mode + ", term '" + term logger.debug("Community search: field = " + field + ", mode = " + mode + ", term '" + term
@ -1634,7 +1553,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT sigid, signame, alias FROM sigs WHERE "); StringBuffer sql = new StringBuffer("SELECT sigid, signame, alias FROM sigs WHERE ");
@ -1672,7 +1591,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end switch } // end switch
if (Capability.hideHiddenSearchCommunities(user.realBaseLevel())) if (Capability.hideHiddenSearchCommunities(env.getUser().realBaseLevel()))
sql.append(" AND hide_search = 0"); sql.append(" AND hide_search = 0");
sql.append(" ORDER BY signame LIMIT ").append(offset).append(", ").append(count+1).append(';'); sql.append(" ORDER BY signame LIMIT ").append(offset).append(", ").append(count+1).append(';');
@ -1684,8 +1603,8 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
while (rs.next()) while (rs.next())
{ // load all matching communities into the recordset { // load all matching communities into the recordset
CommunityUserContextImpl c = new CommunityUserContextImpl(engine,user,datapool,rs.getInt(1), CommunityUserContextImpl c = new CommunityUserContextImpl(env,rs.getInt(1),rs.getString(2),
rs.getString(2),rs.getString(3)); rs.getString(3));
c.checkMembership(conn); c.checkMembership(conn);
CommunityContext tmp = c; CommunityContext tmp = c;
rc.add(tmp); rc.add(tmp);
@ -1701,8 +1620,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1710,7 +1628,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end searchForCommunities } // end searchForCommunities
static int getSearchCommunityCount(UserBackend user, DataPool datapool, int field, int mode, String term) static int getSearchCommunityCount(EnvUser env, int field, int mode, String term)
throws DataException throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
@ -1720,7 +1638,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM sigs WHERE "); StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM sigs WHERE ");
@ -1758,7 +1676,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end switch } // end switch
if (Capability.hideHiddenSearchCommunities(user.realBaseLevel())) if (Capability.hideHiddenSearchCommunities(env.getUser().realBaseLevel()))
sql.append(" AND hide_search = 0"); sql.append(" AND hide_search = 0");
sql.append(';'); sql.append(';');
@ -1782,15 +1700,13 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end getSearchCommunityCount } // end getSearchCommunityCount
static List getCommunitiesInCategory(EngineBackend engine, UserBackend user, DataPool datapool, int catid, static List getCommunitiesInCategory(EnvUser env, int catid, int offset, int count) throws DataException
int offset, int count) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("reading communities in category " + catid + ", offset = " + offset + ", count = " + count); logger.debug("reading communities in category " + catid + ", offset = " + offset + ", count = " + count);
@ -1800,11 +1716,11 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT sigid, signame, alias FROM sigs WHERE catid = "); StringBuffer sql = new StringBuffer("SELECT sigid, signame, alias FROM sigs WHERE catid = ");
sql.append(catid); sql.append(catid);
if (Capability.hideHiddenDirectoryCommunities(user.realBaseLevel())) if (Capability.hideHiddenDirectoryCommunities(env.getUser().realBaseLevel()))
sql.append(" AND hide_dir = 0"); sql.append(" AND hide_dir = 0");
sql.append(" ORDER BY signame LIMIT ").append(offset).append(", ").append(count+1).append(';'); sql.append(" ORDER BY signame LIMIT ").append(offset).append(", ").append(count+1).append(';');
@ -1816,8 +1732,8 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
while (rs.next()) while (rs.next())
{ // load all matching communities into the recordset { // load all matching communities into the recordset
CommunityUserContextImpl c = new CommunityUserContextImpl(engine,user,datapool,rs.getInt(1), CommunityUserContextImpl c = new CommunityUserContextImpl(env,rs.getInt(1),rs.getString(2),
rs.getString(2),rs.getString(3)); rs.getString(3));
c.checkMembership(conn); c.checkMembership(conn);
CommunityContext tmp = c; CommunityContext tmp = c;
rc.add(tmp); rc.add(tmp);
@ -1833,8 +1749,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1842,7 +1757,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end getCommunitiesInCategory } // end getCommunitiesInCategory
static int getNumCommunitiesInCategory(UserBackend user, DataPool datapool, int catid) throws DataException static int getNumCommunitiesInCategory(EnvUser env, int catid) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("reading communities in category " + catid); logger.debug("reading communities in category " + catid);
@ -1851,11 +1766,11 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM sigs WHERE catid = "); StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM sigs WHERE catid = ");
sql.append(catid); sql.append(catid);
if (Capability.hideHiddenDirectoryCommunities(user.realBaseLevel())) if (Capability.hideHiddenDirectoryCommunities(env.getUser().realBaseLevel()))
sql.append(" AND hide_dir = 0"); sql.append(" AND hide_dir = 0");
sql.append(';'); sql.append(';');
@ -1879,8 +1794,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1895,7 +1809,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
{ {
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT granted_lvl, locked FROM sigmember WHERE sigid = "); StringBuffer sql = new StringBuffer("SELECT granted_lvl, locked FROM sigmember WHERE sigid = ");
sql.append(cid).append(" AND uid = ").append(user.realUID()).append(';'); sql.append(cid).append(" AND uid = ").append(env.getUserID()).append(';');
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
if (rs.next()) if (rs.next())
{ // we are a member... { // we are a member...

View File

@ -20,10 +20,11 @@ package com.silverwrist.venice.core.impl;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.htmlcheck.*; import com.silverwrist.venice.htmlcheck.*;
import com.silverwrist.venice.security.AuditRecord; import com.silverwrist.venice.security.AuditRecord;
import com.silverwrist.venice.core.*;
class ConferenceCommunityContextImpl implements ConferenceCommunityContext class ConferenceCommunityContextImpl implements ConferenceCommunityContext
{ {
@ -78,9 +79,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; // engine object reference private EnvConferenceCommunity env; // the environment
private CommunityDataBackend comm; // community object reference
private DataPool datapool; // data pool object
private int confid; // ID of this conference private int confid; // ID of this conference
private int level; // level granted in conference to members of the community private int level; // level granted in conference to members of the community
private short sequence; // sequence number this conference appears in list private short sequence; // sequence number this conference appears in list
@ -94,23 +93,20 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
ConferenceCommunityContextImpl(EngineBackend engine, CommunityDataBackend comm, DataPool datapool, ConferenceCommunityContextImpl(EnvCommunityData env, int confid) throws DataException
int confid) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("new ConferenceCommunityContextImpl(#" + String.valueOf(confid) + ") for community # " logger.debug("new ConferenceCommunityContextImpl(#" + confid + ") for community # "
+ comm.realCommunityID()); + env.getCommunityID());
this.engine = engine; this.env = new EnvConferenceCommunity(env);
this.comm = comm;
this.datapool = datapool;
this.confid = confid; this.confid = confid;
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// Build a monster query! This is like the query for retrieving the ConferenceUserContextImpl // Build a monster query! This is like the query for retrieving the ConferenceUserContextImpl
@ -118,7 +114,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
StringBuffer sql = StringBuffer sql =
new StringBuffer("SELECT c.createdate, c.name, c.descr, s.granted_lvl, s.sequence, s.hide_list " new StringBuffer("SELECT c.createdate, c.name, c.descr, s.granted_lvl, s.sequence, s.hide_list "
+ "FROM sigtoconf s, confs c WHERE s.confid = c.confid AND s.sigid = "); + "FROM sigtoconf s, confs c WHERE s.confid = c.confid AND s.sigid = ");
sql.append(comm.realCommunityID()).append(" AND c.confid = ").append(confid).append(';'); sql.append(env.getCommunityID()).append(" AND c.confid = ").append(confid).append(';');
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString()); logger.debug("SQL: " + sql.toString());
@ -126,7 +122,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
if (!(rs.next())) if (!(rs.next()))
throw new DataException("conference ID#" + confid + " not found in community#" throw new DataException("conference ID#" + confid + " not found in community#"
+ comm.realCommunityID()); + env.getCommunityID());
// fill in the "cache" and "level" indicators // fill in the "cache" and "level" indicators
this.cache = new ConfCache(rs.getString(2),rs.getString(3),SQLUtil.getFullDateTime(rs,1)); this.cache = new ConfCache(rs.getString(2),rs.getString(3),SQLUtil.getFullDateTime(rs,1));
@ -143,23 +139,19 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end constructor } // end constructor
ConferenceCommunityContextImpl(EngineBackend engine, CommunityDataBackend comm, DataPool datapool, ConferenceCommunityContextImpl(EnvCommunityData env, short sequence, boolean hide_list, ConferenceData cdata)
short sequence, boolean hide_list, ConferenceData cdata)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("new ConferenceCommunityContextImpl(NEW#" + confid + ") for community # " logger.debug("new ConferenceCommunityContextImpl(NEW#" + confid + ") for community # "
+ comm.realCommunityID()); + env.getCommunityID());
this.engine = engine; this.env = new EnvConferenceCommunity(env);
this.comm = comm;
this.datapool = datapool;
this.confid = cdata.getID(); this.confid = cdata.getID();
this.level = 0; this.level = 0;
this.sequence = sequence; this.sequence = sequence;
@ -180,7 +172,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
{ // attempt to load the ConferenceCommunityContext { // attempt to load the ConferenceCommunityContext
if (deleted) if (deleted)
throw new DataException("This conference has been deleted."); throw new DataException("This conference has been deleted.");
confdata = engine.getConferenceDataObject(confid); confdata = env.getEngine().getConferenceDataObject(confid);
// clear cache when we get the real confdata // clear cache when we get the real confdata
cache = null; cache = null;
@ -200,7 +192,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
try try
{ // attempt to load the ConferenceCommunityContext { // attempt to load the ConferenceCommunityContext
confdata = engine.getConferenceDataObject(confid); confdata = env.getEngine().getConferenceDataObject(confid);
} // end try } // end try
catch (DataException e) catch (DataException e)
@ -384,16 +376,16 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
} // end getDeleteLevel } // end getDeleteLevel
public synchronized void setSecurityLevels(CommunityBackend comm, int read, int post, int create, int hide, public synchronized void setSecurityLevels(EnvCommunity outer, int read, int post, int create, int hide,
int nuke, int change, int delete) throws DataException int nuke, int change, int delete) throws DataException
{ {
getConferenceData().setSecurityLevels(comm,read,post,create,hide,nuke,change,delete); getConferenceData().setSecurityLevels(outer,read,post,create,hide,nuke,change,delete);
} // end setSecurityLevels } // end setSecurityLevels
public synchronized void setName(CommunityBackend comm, String val) throws DataException public synchronized void setName(EnvCommunity outer, String val) throws DataException
{ {
getConferenceData().setName(comm,val); getConferenceData().setName(outer,val);
} // end setName } // end setName
@ -403,25 +395,25 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
} // end setDescription } // end setDescription
public synchronized void addAlias(CommunityBackend comm, String alias) throws DataException public synchronized void addAlias(EnvCommunity outer, String alias) throws DataException
{ {
getConferenceData().addAlias(comm,alias); getConferenceData().addAlias(outer,alias);
} // end addAlias } // end addAlias
public synchronized void removeAlias(CommunityBackend comm, String alias) throws DataException public synchronized void removeAlias(EnvCommunity outer, String alias) throws DataException
{ {
getConferenceData().removeAlias(comm,alias); getConferenceData().removeAlias(outer,alias);
} // end removeAlias } // end removeAlias
public synchronized void setMembership(CommunityBackend comm, int uid, int grant_level) throws DataException public synchronized void setMembership(EnvCommunity outer, int uid, int grant_level) throws DataException
{ {
getConferenceData().setMembership(comm,uid,grant_level); getConferenceData().setMembership(outer,uid,grant_level);
} // end setMembership } // end setMembership
public synchronized void setCommunityGrantedLevel(CommunityBackend comm, int new_level) throws DataException public synchronized void setCommunityGrantedLevel(EnvCommunity outer, int new_level) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This conference has been deleted."); throw new DataException("This conference has been deleted.");
@ -431,12 +423,12 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
// create the SQL statement // create the SQL statement
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigtoconf SET granted_lvl = "); StringBuffer sql = new StringBuffer("UPDATE sigtoconf SET granted_lvl = ");
sql.append(new_level).append(" WHERE sigid = ").append(this.comm.realCommunityID()); sql.append(new_level).append(" WHERE sigid = ").append(this.env.getCommunityID());
sql.append(" AND confid = ").append(confid).append(';'); sql.append(" AND confid = ").append(confid).append(';');
// execute the update // execute the update
@ -446,8 +438,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
level = new_level; level = new_level;
// create an audit record reflecting the change // create an audit record reflecting the change
ar = new AuditRecord(AuditRecord.CONF_SECURITY,comm.realUID(),comm.userRemoteAddress(), ar = outer.newAudit(AuditRecord.CONF_SECURITY,"conf=" + confid);
comm.realCommunityID(),"conf=" + confid);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -470,8 +461,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -492,12 +482,12 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
// create the SQL statement // create the SQL statement
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigtoconf SET sequence = "); StringBuffer sql = new StringBuffer("UPDATE sigtoconf SET sequence = ");
sql.append(seq).append(" WHERE sigid = ").append(this.comm.realCommunityID()).append(" AND confid = "); sql.append(seq).append(" WHERE sigid = ").append(env.getCommunityID()).append(" AND confid = ");
sql.append(confid).append(';'); sql.append(confid).append(';');
// execute the update // execute the update
@ -515,8 +505,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -528,7 +517,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
} // end getHideList } // end getHideList
public void setHideList(CommunityBackend comm, boolean flag) throws DataException public void setHideList(EnvCommunity outer, boolean flag) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("setHideList(conf #" + confid + ", " + flag + ")"); logger.debug("setHideList(conf #" + confid + ", " + flag + ")");
@ -552,12 +541,12 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
// create the SQL statement // create the SQL statement
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigtoconf SET hide_list = "); StringBuffer sql = new StringBuffer("UPDATE sigtoconf SET hide_list = ");
sql.append(flag ? '1' : '0').append(" WHERE sigid = ").append(this.comm.realCommunityID()); sql.append(flag ? '1' : '0').append(" WHERE sigid = ").append(env.getCommunityID());
sql.append(" AND confid = ").append(confid).append(';'); sql.append(" AND confid = ").append(confid).append(';');
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString()); logger.debug("SQL: " + sql.toString());
@ -569,8 +558,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
hide_list = flag; hide_list = flag;
// create an audit record reflecting the change // create an audit record reflecting the change
ar = new AuditRecord(AuditRecord.CONF_SECURITY,comm.realUID(),comm.userRemoteAddress(), ar = outer.newAudit(AuditRecord.CONF_SECURITY,"conf=" + confid);
comm.realCommunityID(),"conf=" + confid);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -593,8 +581,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -618,7 +605,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
} // end getAnAlias } // end getAnAlias
public ReturnTopicInfo createNewTopic(CommunityBackend comm, String title, String pseud, String body) public ReturnTopicInfo createNewTopic(EnvCommunity outer, String title, String pseud, String body)
throws DataException throws DataException
{ {
ConferenceData d = getConferenceData(); ConferenceData d = getConferenceData();
@ -627,9 +614,10 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
try try
{ // preprocess the body argument through the HTML checker { // preprocess the body argument through the HTML checker
HTMLChecker text_ch = engine.createCheckerObject(engine.HTMLC_POST_BODY); HTMLChecker text_ch = env.getEngine().createCheckerObject(EngineBackend.HTMLC_POST_BODY);
text_ch.setContextValue("PostLinkDecoderContext", text_ch.setContextValue("PostLinkDecoderContext",
new PostLinkDecoderContext(comm.realCommunityAlias(),conf_alias,new_topic)); new PostLinkDecoderContext(outer.getCommunity().realCommunityAlias(),conf_alias,
new_topic));
try try
{ // run through the HTML checker { // run through the HTML checker
@ -645,7 +633,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
try try
{ // call down to create the new topic! { // call down to create the new topic!
return d.createNewTopic(comm,title,pseud,text_ch.getValue(),text_ch.getLines()); return d.createNewTopic(outer,title,pseud,text_ch.getValue(),text_ch.getLines());
} // end try } // end try
catch (NotYetFinishedException e) catch (NotYetFinishedException e)
@ -727,7 +715,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
} // end canDeleteConference } // end canDeleteConference
public void delete(UserBackend user) throws DataException public void delete(EnvCommunity outer) throws DataException
{ {
ConferenceData c = getConferenceData(); ConferenceData c = getConferenceData();
Connection conn = null; Connection conn = null;
@ -735,12 +723,12 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// see if we have to delete the core object as well // see if we have to delete the core object as well
StringBuffer sql = new StringBuffer("SELECT sigid FROM sigtoconf WHERE confid = "); StringBuffer sql = new StringBuffer("SELECT sigid FROM sigtoconf WHERE confid = ");
sql.append(confid).append(" AND sigid <> ").append(comm.realCommunityID()).append(" LIMIT 1;"); sql.append(confid).append(" AND sigid <> ").append(env.getCommunityID()).append(" LIMIT 1;");
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
if (rs.next()) if (rs.next())
delete_core = false; // we don't delete the core yet delete_core = false; // we don't delete the core yet
@ -748,7 +736,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
// remove the row that links this conference to this community // remove the row that links this conference to this community
sql.setLength(0); sql.setLength(0);
sql.append("DELETE FROM sigtoconf WHERE confid = ").append(confid).append(" AND sigid = "); sql.append("DELETE FROM sigtoconf WHERE confid = ").append(confid).append(" AND sigid = ");
sql.append(comm.realCommunityID()).append(';'); sql.append(env.getCommunityID()).append(';');
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
// record that we've been deleted // record that we've been deleted
@ -767,15 +755,14 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
if (delete_core) if (delete_core)
{ // the conference is not linked to any other communities - we need to delete the core as well { // the conference is not linked to any other communities - we need to delete the core as well
c.delete(user,comm.realCommunityID()); c.delete(outer);
engine.detachConferenceDataObject(confid); env.getEngine().detachConferenceDataObject(confid);
} // end if } // end if

View File

@ -21,10 +21,11 @@ import java.sql.*;
import java.util.*; import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.util.OptionSet; import com.silverwrist.util.OptionSet;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.security.AuditRecord; import com.silverwrist.venice.security.AuditRecord;
import com.silverwrist.venice.security.DefaultLevels; import com.silverwrist.venice.security.DefaultLevels;
import com.silverwrist.venice.core.*;
class ConferenceCoreData implements ConferenceData class ConferenceCoreData implements ConferenceData
{ {
@ -48,8 +49,7 @@ class ConferenceCoreData implements ConferenceData
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; // pointer to engine back end private EnvConferenceData env; // the environment
private DataPool datapool; // pointer to data pool
private int confid; // ID of this conference private int confid; // ID of this conference
private java.util.Date create_date; // creation date of this conference private java.util.Date create_date; // creation date of this conference
private java.util.Date last_update; // last update date of conference private java.util.Date last_update; // last update date of conference
@ -73,19 +73,18 @@ class ConferenceCoreData implements ConferenceData
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
ConferenceCoreData(EngineBackend engine, DataPool datapool, int confid) throws DataException ConferenceCoreData(EnvEngine env, int confid) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("new ConferenceCoreData for conference " + confid); logger.debug("new ConferenceCoreData for conference " + confid);
this.engine = engine; this.env = new EnvConferenceData(env);
this.datapool = datapool;
this.confid = confid; this.confid = confid;
Connection conn = null; Connection conn = null;
try try
{ // get a database connection from this object { // get a database connection from this object
conn = datapool.getConnection(); conn = env.getConnection();
// get the conference basic data from the database // get the conference basic data from the database
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -108,20 +107,18 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end constructor } // end constructor
protected ConferenceCoreData(EngineBackend engine, CommunityDataBackend comm, DataPool datapool, int confid, protected ConferenceCoreData(EnvCommunityData env, int confid, java.util.Date created, boolean pvt,
java.util.Date created, boolean pvt, String name, String descr) String name, String descr)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("new ConferenceCoreData for NEW conference " + confid); logger.debug("new ConferenceCoreData for NEW conference " + confid);
this.engine = engine; this.env = new EnvConferenceData(env);
this.datapool = datapool;
this.confid = confid; this.confid = confid;
this.create_date = created; this.create_date = created;
this.last_update = null; this.last_update = null;
@ -136,7 +133,7 @@ class ConferenceCoreData implements ConferenceData
this.name = name; this.name = name;
this.description = descr; this.description = descr;
this.flags = new OptionSet(); this.flags = new OptionSet();
if (comm.getParamBoolean(CommunityDataBackend.BP_POSTPICTURES)) if (env.getCommunityData().getParamBoolean(CommunityDataBackend.BP_POSTPICTURES))
flags.set(BP_POSTPICTURES); flags.set(BP_POSTPICTURES);
} // end constructor } // end constructor
@ -219,7 +216,7 @@ class ConferenceCoreData implements ConferenceData
Connection conn = null; Connection conn = null;
try try
{ // get a connection and create a statement { // get a connection and create a statement
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
@ -241,8 +238,7 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -318,7 +314,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection from this object { // get a database connection from this object
conn = datapool.getConnection(); conn = env.getConnection();
// get a list of all aliases // get a list of all aliases
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -339,8 +335,7 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -358,7 +353,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection from this object { // get a database connection from this object
conn = datapool.getConnection(); conn = env.getConnection();
// get a list of all hosts (with user info) // get a list of all hosts (with user info)
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -388,8 +383,7 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -471,7 +465,7 @@ class ConferenceCoreData implements ConferenceData
} // end getDeleteLevel } // end getDeleteLevel
public synchronized void setSecurityLevels(CommunityBackend comm, int read, int post, int create, int hide, public synchronized void setSecurityLevels(EnvCommunity outer, int read, int post, int create, int hide,
int nuke, int change, int delete) throws DataException int nuke, int change, int delete) throws DataException
{ {
if (deleted) if (deleted)
@ -482,7 +476,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
// create the SQL statement // create the SQL statement
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -507,8 +501,7 @@ class ConferenceCoreData implements ConferenceData
last_update = now; last_update = now;
// create an audit record reflecting the change // create an audit record reflecting the change
ar = new AuditRecord(AuditRecord.CONF_SECURITY,comm.realUID(),comm.userRemoteAddress(), ar = outer.newAudit(AuditRecord.CONF_SECURITY,"conf=" + confid);
comm.realCommunityID(),"conf=" + confid);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -531,14 +524,13 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end setSecurityLevels } // end setSecurityLevels
public synchronized void setName(CommunityBackend comm, String val) throws DataException public synchronized void setName(EnvCommunity outer, String val) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This conference has been deleted."); throw new DataException("This conference has been deleted.");
@ -548,7 +540,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
// create the SQL statement // create the SQL statement
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -565,8 +557,7 @@ class ConferenceCoreData implements ConferenceData
last_update = now; last_update = now;
// create an audit record reflecting the change // create an audit record reflecting the change
ar = new AuditRecord(AuditRecord.CONF_SECURITY,comm.realUID(),comm.userRemoteAddress(), ar = outer.newAudit(AuditRecord.CONF_SECURITY,"conf=" + confid);
comm.realCommunityID(),"conf=" + confid);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -589,8 +580,7 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -605,7 +595,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
// create the SQL statement // create the SQL statement
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -629,14 +619,13 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end setDescription } // end setDescription
public synchronized void addAlias(CommunityBackend comm, String alias) throws DataException public synchronized void addAlias(EnvCommunity outer, String alias) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This conference has been deleted."); throw new DataException("This conference has been deleted.");
@ -646,7 +635,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
stmt.executeUpdate("LOCK TABLES confalias WRITE;"); stmt.executeUpdate("LOCK TABLES confalias WRITE;");
@ -680,8 +669,7 @@ class ConferenceCoreData implements ConferenceData
// set the database's update date and generate a new audit record // set the database's update date and generate a new audit record
touchUpdate(conn); touchUpdate(conn);
ar = new AuditRecord(AuditRecord.CONF_ALIAS,comm.realUID(),comm.userRemoteAddress(), ar = outer.newAudit(AuditRecord.CONF_ALIAS,"conf=" + confid,"add=" + alias);
comm.realCommunityID(),"conf=" + confid,"add=" + alias);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -704,14 +692,13 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end addAlias } // end addAlias
public synchronized void removeAlias(CommunityBackend comm, String alias) throws DataException public synchronized void removeAlias(EnvCommunity outer, String alias) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This conference has been deleted."); throw new DataException("This conference has been deleted.");
@ -721,7 +708,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
boolean did_it = false; boolean did_it = false;
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -768,8 +755,7 @@ class ConferenceCoreData implements ConferenceData
touchUpdate(conn); touchUpdate(conn);
if ((cached_alias!=null) && cached_alias.equals(alias)) if ((cached_alias!=null) && cached_alias.equals(alias))
cached_alias = null; // also release the cached alias and force a re-get cached_alias = null; // also release the cached alias and force a re-get
ar = new AuditRecord(AuditRecord.CONF_ALIAS,comm.realUID(),comm.userRemoteAddress(), ar = outer.newAudit(AuditRecord.CONF_ALIAS,"conf=" + confid,"remove=" + alias);
comm.realCommunityID(),"conf=" + confid,"remove=" + alias);
} // end if } // end if
@ -794,14 +780,13 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end removeAlias } // end removeAlias
public synchronized void setMembership(CommunityBackend comm, int uid, int grant_level) throws DataException public synchronized void setMembership(EnvCommunity outer, int uid, int grant_level) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This conference has been deleted."); throw new DataException("This conference has been deleted.");
@ -811,7 +796,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
boolean did_it = false; boolean did_it = false;
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -862,8 +847,7 @@ class ConferenceCoreData implements ConferenceData
if (did_it) if (did_it)
{ // set the database's update date and generate a new audit record { // set the database's update date and generate a new audit record
touchUpdate(conn); touchUpdate(conn);
ar = new AuditRecord(AuditRecord.CONF_MEMBERSHIP,comm.realUID(),comm.userRemoteAddress(), ar = outer.newAudit(AuditRecord.CONF_MEMBERSHIP,"conf=" + confid,"uid=" + uid,"level=" + grant_level);
comm.realCommunityID(),"conf=" + confid,"uid=" + uid,"level=" + grant_level);
} // end if } // end if
@ -888,8 +872,7 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -915,7 +898,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the SQL statement and execute it // create the SQL statement and execute it
@ -936,14 +919,13 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end getAnAlias } // end getAnAlias
public synchronized ReturnTopicInfo createNewTopic(CommunityBackend comm, String title, String pseud, public synchronized ReturnTopicInfo createNewTopic(EnvCommunity outer, String title, String pseud,
String body, int body_lines) throws DataException String body, int body_lines) throws DataException
{ {
if (deleted) if (deleted)
@ -957,7 +939,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// lock the tables we need to use so we can update them // lock the tables we need to use so we can update them
@ -970,7 +952,7 @@ class ConferenceCoreData implements ConferenceData
// add the topic row to the database // add the topic row to the database
StringBuffer sql = new StringBuffer("INSERT INTO topics (confid, num, creator_uid, createdate, " StringBuffer sql = new StringBuffer("INSERT INTO topics (confid, num, creator_uid, createdate, "
+ "lastupdate, name) VALUES ("); + "lastupdate, name) VALUES (");
sql.append(confid).append(", ").append(new_topic_num).append(", ").append(comm.realUID()); sql.append(confid).append(", ").append(new_topic_num).append(", ").append(outer.getUserID());
creation = new java.util.Date(); creation = new java.util.Date();
String now_str = SQLUtil.encodeDate(creation); String now_str = SQLUtil.encodeDate(creation);
sql.append(", '").append(now_str).append("', '").append(now_str).append("', '").append(title); sql.append(", '").append(now_str).append("', '").append(now_str).append("', '").append(title);
@ -988,7 +970,7 @@ class ConferenceCoreData implements ConferenceData
// insert the "header" for the "zero post" in the topic // insert the "header" for the "zero post" in the topic
sql.setLength(0); sql.setLength(0);
sql.append("INSERT INTO posts (topicid, num, linecount, creator_uid, posted, pseud) VALUES ("); sql.append("INSERT INTO posts (topicid, num, linecount, creator_uid, posted, pseud) VALUES (");
sql.append(new_topic_id).append(", 0, ").append(body_lines).append(", ").append(comm.realUID()); sql.append(new_topic_id).append(", 0, ").append(body_lines).append(", ").append(outer.getUserID());
sql.append(", '").append(now_str).append("', '").append(pseud).append("');"); sql.append(", '").append(now_str).append("', '").append(pseud).append("');");
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString()); logger.debug("SQL: " + sql.toString());
@ -1019,9 +1001,8 @@ class ConferenceCoreData implements ConferenceData
last_update = creation; last_update = creation;
// create an audit record indicating we were successful // create an audit record indicating we were successful
ar = new AuditRecord(AuditRecord.CREATE_TOPIC,comm.realUID(),comm.userRemoteAddress(), ar = outer.newAudit(AuditRecord.CREATE_TOPIC,"confid=" + confid,"num=" + new_topic_num,
comm.realCommunityID(),"confid=" + confid,"num=" + new_topic_num, "title=" + title);
"title=" + title);
} // end try } // end try
finally finally
@ -1052,8 +1033,7 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1147,7 +1127,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create a new SQL statement // create a new SQL statement
@ -1182,8 +1162,7 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1200,7 +1179,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the statement // create the statement
@ -1221,8 +1200,7 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1244,7 +1222,7 @@ class ConferenceCoreData implements ConferenceData
} // end canDeleteConference } // end canDeleteConference
public synchronized void delete(UserBackend user, int the_cid) throws DataException public synchronized void delete(EnvCommunity outer) throws DataException
{ {
if (deleted) if (deleted)
throw new DataException("This conference has been deleted."); throw new DataException("This conference has been deleted.");
@ -1255,7 +1233,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// lock tables on the critical stuff that MUST be deleted now // lock tables on the critical stuff that MUST be deleted now
@ -1298,8 +1276,7 @@ class ConferenceCoreData implements ConferenceData
} // end finally } // end finally
// create an audit record indicating we were successful // create an audit record indicating we were successful
ar = new AuditRecord(AuditRecord.DELETE_CONF,user.realUID(),user.userRemoteAddress(),the_cid, ar = outer.newAudit(AuditRecord.DELETE_CONF,"confid=" + confid);
"confid=" + confid);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -1322,14 +1299,12 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
// Delete the rest of the gunk in the background; spin off another thread to handle it. // Delete the rest of the gunk in the background; spin off another thread to handle it.
BackgroundConferencePurge purger = new BackgroundConferencePurge(engine,datapool,confid,topic_count, BackgroundConferencePurge purger = new BackgroundConferencePurge(env,confid,topic_count,topic_max);
topic_max);
Thread thrd = new Thread(purger); Thread thrd = new Thread(purger);
thrd.setPriority(Thread.NORM_PRIORITY-1); thrd.setPriority(Thread.NORM_PRIORITY-1);
thrd.start(); thrd.start();
@ -1376,11 +1351,10 @@ class ConferenceCoreData implements ConferenceData
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
static ReturnConfSeq createConference(EngineBackend engine, CommunityBackend comm, DataPool datapool, static ReturnConfSeq createConference(EnvCommunity outer, EnvCommunityData env, String name, String alias,
String name, String alias, String description, boolean pvt, String description, boolean pvt, boolean hide_list, int host_uid)
boolean hide_list, int host_uid) throws DataException throws DataException
{ {
CommunityDataBackend data_backend = comm.getDataBackend();
Connection conn = null; // database connection Connection conn = null; // database connection
AuditRecord ar = null; // audit record AuditRecord ar = null; // audit record
int new_confid; // new conference ID int new_confid; // new conference ID
@ -1393,7 +1367,7 @@ class ConferenceCoreData implements ConferenceData
try try
{ // start by locking all the tables we need { // start by locking all the tables we need
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
stmt.executeUpdate("LOCK TABLES confs WRITE, sigtoconf WRITE, confalias WRITE, confmember WRITE, " stmt.executeUpdate("LOCK TABLES confs WRITE, sigtoconf WRITE, confalias WRITE, confmember WRITE, "
+ "propconf WRITE;"); + "propconf WRITE;");
@ -1411,7 +1385,7 @@ class ConferenceCoreData implements ConferenceData
// compute our new sequence number // compute our new sequence number
sql.setLength(0); sql.setLength(0);
sql.append("SELECT MAX(sequence) FROM sigtoconf WHERE sigid = ").append(comm.realCommunityID()); sql.append("SELECT MAX(sequence) FROM sigtoconf WHERE sigid = ").append(env.getCommunityID());
sql.append(';'); sql.append(';');
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString()); logger.debug("SQL: " + sql.toString());
@ -1453,7 +1427,7 @@ class ConferenceCoreData implements ConferenceData
// Link the community to the conference by adding a row to sigtoconf. // Link the community to the conference by adding a row to sigtoconf.
sql.setLength(0); sql.setLength(0);
sql.append("INSERT INTO sigtoconf (sigid, confid, sequence, hide_list) VALUES ("); sql.append("INSERT INTO sigtoconf (sigid, confid, sequence, hide_list) VALUES (");
sql.append(comm.realCommunityID()).append(", ").append(new_confid).append(", ").append(new_sequence); sql.append(env.getCommunityID()).append(", ").append(new_confid).append(", ").append(new_sequence);
sql.append(", ").append(hide_list ? '1' : '0').append(");"); sql.append(", ").append(hide_list ? '1' : '0').append(");");
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString()); logger.debug("SQL: " + sql.toString());
@ -1469,7 +1443,7 @@ class ConferenceCoreData implements ConferenceData
// Create a new ConferenceCoreData object representing this conference and register it with the // Create a new ConferenceCoreData object representing this conference and register it with the
// engine's conference data object cache. // engine's conference data object cache.
conf = new ConferenceCoreData(engine,data_backend,datapool,new_confid,created,pvt,name,description); conf = new ConferenceCoreData(env,new_confid,created,pvt,name,description);
conf.newProperties(conn); conf.newProperties(conn);
} // end try } // end try
@ -1480,11 +1454,10 @@ class ConferenceCoreData implements ConferenceData
} // end finally } // end finally
engine.registerNewConference(conf); env.getEngine().registerNewConference(conf);
// create an audit record indicating we were successful // create an audit record indicating we were successful
ar = new AuditRecord(AuditRecord.CREATE_CONF,comm.realUID(),comm.userRemoteAddress(), ar = outer.newAudit(AuditRecord.CREATE_CONF,"confid=" + new_confid,"name=" + name,"alias=" + alias);
comm.realCommunityID(),"confid=" + new_confid,"name=" + name,"alias=" + alias);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -1507,8 +1480,7 @@ class ConferenceCoreData implements ConferenceData
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -22,6 +22,7 @@ import java.sql.*;
import java.util.*; import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.EnvEngine;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
class ContactInfoImpl implements ContactInfo, Stashable class ContactInfoImpl implements ContactInfo, Stashable
@ -170,11 +171,11 @@ class ContactInfoImpl implements ContactInfo, Stashable
/** /**
* Loads a <CODE>ContactInfoImpl</CODE> object out of the database. * Loads a <CODE>ContactInfoImpl</CODE> object out of the database.
* *
* @param dp Database connection pool to get a Venice database connection from. * @param env Engine environment to get a database connection from.
* @param contactid ID of the contact to load. * @param contactid ID of the contact to load.
* @exception DataException The contact could not be loaded for some reason. * @exception DataException The contact could not be loaded for some reason.
*/ */
ContactInfoImpl(DataPool dp, int contactid) throws DataException ContactInfoImpl(EnvEngine env, int contactid) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("new ContactInfoImpl (loading CID " + contactid + ")"); logger.debug("new ContactInfoImpl (loading CID " + contactid + ")");
@ -182,7 +183,7 @@ class ContactInfoImpl implements ContactInfo, Stashable
try try
{ // get a connection and call loadData { // get a connection and call loadData
conn = dp.getConnection(); conn = env.getConnection();
loadData(conn,contactid); loadData(conn,contactid);
} // end try } // end try
@ -194,8 +195,7 @@ class ContactInfoImpl implements ContactInfo, Stashable
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
dp.releaseConnection(conn);
} // end finally } // end finally

View File

@ -24,6 +24,7 @@ import org.apache.log4j.*;
import com.silverwrist.util.IOUtil; import com.silverwrist.util.IOUtil;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.EnvEngine;
class ImageStore implements BinaryData class ImageStore implements BinaryData
{ {
@ -42,7 +43,7 @@ class ImageStore implements BinaryData
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private DataPool datapool; private EnvEngine env; // the execution environment
private int imgid; private int imgid;
private String type; private String type;
private int length; private int length;
@ -52,9 +53,9 @@ class ImageStore implements BinaryData
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
protected ImageStore(DataPool datapool, int imgid, String type, int length) protected ImageStore(EnvEngine env, int imgid, String type, int length)
{ {
this.datapool = datapool; this.env = env;
this.imgid = imgid; this.imgid = imgid;
this.type = type; this.type = type;
this.length = length; this.length = length;
@ -91,7 +92,7 @@ class ImageStore implements BinaryData
try try
{ // open up a database connection { // open up a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// Create the SQL we need to retrieve the image. // Create the SQL we need to retrieve the image.
@ -126,8 +127,7 @@ class ImageStore implements BinaryData
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -140,7 +140,7 @@ class ImageStore implements BinaryData
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
static ImageStore loadImageByID(DataPool datapool, int id) throws DataException static ImageStore loadImageByID(EnvEngine env, int id) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("loadImageByID # " + id); logger.debug("loadImageByID # " + id);
@ -149,7 +149,7 @@ class ImageStore implements BinaryData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT mimetype, length FROM imagestore WHERE imgid = "); StringBuffer sql = new StringBuffer("SELECT mimetype, length FROM imagestore WHERE imgid = ");
@ -159,7 +159,7 @@ class ImageStore implements BinaryData
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
if (rs.next()) // create an object reference and return it if (rs.next()) // create an object reference and return it
return new ImageStore(datapool,id,rs.getString(1),rs.getInt(2)); return new ImageStore(env,id,rs.getString(1),rs.getInt(2));
return null; // no such image return null; // no such image
@ -172,8 +172,7 @@ class ImageStore implements BinaryData
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -204,7 +203,7 @@ class ImageStore implements BinaryData
} // end storeNewImage } // end storeNewImage
static int storeNewImage(DataPool datapool, short type, int owner, String mime, int length, InputStream data) static int storeNewImage(EnvEngine env, short type, int owner, String mime, int length, InputStream data)
throws DataException throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
@ -214,7 +213,7 @@ class ImageStore implements BinaryData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
return storeNewImage(conn,type,owner,mime,length,data); return storeNewImage(conn,type,owner,mime,length,data);
} // end try } // end try
@ -226,8 +225,7 @@ class ImageStore implements BinaryData
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -250,7 +248,7 @@ class ImageStore implements BinaryData
} // end replaceImage } // end replaceImage
static void replaceImage(DataPool datapool, int imgid, String mime, int length, InputStream data) static void replaceImage(EnvEngine env, int imgid, String mime, int length, InputStream data)
throws DataException throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
@ -260,7 +258,7 @@ class ImageStore implements BinaryData
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
replaceImage(conn,imgid,mime,length,data); replaceImage(conn,imgid,mime,length,data);
} // end try } // end try
@ -272,8 +270,7 @@ class ImageStore implements BinaryData
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -24,6 +24,7 @@ import org.apache.log4j.*;
import com.silverwrist.util.StringUtil; import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.EnvEngine;
class PublishedMessageImpl implements TopicMessageContext class PublishedMessageImpl implements TopicMessageContext
{ {
@ -32,14 +33,14 @@ class PublishedMessageImpl implements TopicMessageContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private static Category logger = Category.getInstance(PublishedMessageImpl.class.getName()); private static Category logger = Category.getInstance(PublishedMessageImpl.class);
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Attributes * Attributes
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private DataPool datapool; private EnvEngine env; // the execution environment
private long postid; private long postid;
private long parent; private long parent;
private int num; private int num;
@ -55,10 +56,10 @@ class PublishedMessageImpl implements TopicMessageContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
PublishedMessageImpl(DataPool datapool, long postid, long parent, int num, int linecount, int creator_uid, PublishedMessageImpl(EnvEngine env, long postid, long parent, int num, int linecount, int creator_uid,
java.util.Date posted, String pseud, String creator_cache, String text_cache) java.util.Date posted, String pseud, String creator_cache, String text_cache)
{ {
this.datapool = datapool; this.env = env;
this.postid = postid; this.postid = postid;
this.parent = parent; this.parent = parent;
this.num = num; this.num = num;
@ -71,10 +72,10 @@ class PublishedMessageImpl implements TopicMessageContext
} // end constructor } // end constructor
protected PublishedMessageImpl(DataPool datapool, long postid, long parent, int num, int linecount, protected PublishedMessageImpl(EnvEngine env, long postid, long parent, int num, int linecount,
int creator_uid, java.util.Date posted, String pseud) int creator_uid, java.util.Date posted, String pseud)
{ {
this.datapool = datapool; this.env = env;
this.postid = postid; this.postid = postid;
this.parent = parent; this.parent = parent;
this.num = num; this.num = num;
@ -144,7 +145,7 @@ class PublishedMessageImpl implements TopicMessageContext
try try
{ // use a database connection to get the user name { // use a database connection to get the user name
conn = datapool.getConnection(); conn = env.getConnection();
creator_cache = quickGetUserName(conn,creator_uid); creator_cache = quickGetUserName(conn,creator_uid);
} // end try } // end try
@ -156,8 +157,7 @@ class PublishedMessageImpl implements TopicMessageContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -211,7 +211,7 @@ class PublishedMessageImpl implements TopicMessageContext
try try
{ // use a database connection to get the body text { // use a database connection to get the body text
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT data FROM postdata WHERE postid = " ResultSet rs = stmt.executeQuery("SELECT data FROM postdata WHERE postid = "
@ -230,8 +230,7 @@ class PublishedMessageImpl implements TopicMessageContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -332,13 +331,13 @@ class PublishedMessageImpl implements TopicMessageContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
static void backfillCache(List cache_list, int desired_size, DataPool datapool) throws DataException static void backfillCache(List cache_list, int desired_size, EnvEngine env) throws DataException
{ {
Connection conn = null; Connection conn = null;
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the statement to retrieve the post information // create the statement to retrieve the post information
@ -351,8 +350,13 @@ class PublishedMessageImpl implements TopicMessageContext
// execute the statement! // execute the statement!
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next()) while (rs.next())
cache_list.add(new PublishedMessageImpl(datapool,rs.getLong(1),rs.getLong(2),rs.getInt(3),rs.getInt(4), { // create PublishedMessageImpl objects to backfill the cache
rs.getInt(5),SQLUtil.getFullDateTime(rs,6),rs.getString(7))); TopicMessageContext tmc = new PublishedMessageImpl(env,rs.getLong(1),rs.getLong(2),rs.getInt(3),
rs.getInt(4),rs.getInt(5),
SQLUtil.getFullDateTime(rs,6),rs.getString(7));
cache_list.add(tmc);
} // end while
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -363,20 +367,19 @@ class PublishedMessageImpl implements TopicMessageContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end backfillCache } // end backfillCache
static void backfillReturn(List return_list, DataPool datapool) throws DataException static void backfillReturn(List return_list, EnvEngine env) throws DataException
{ {
Connection conn = null; Connection conn = null;
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// How many posts have been published anyway? // How many posts have been published anyway?
@ -399,7 +402,7 @@ class PublishedMessageImpl implements TopicMessageContext
if ((ctr--)<=0) if ((ctr--)<=0)
{ // append context, please { // append context, please
TopicMessageContext ctxt = TopicMessageContext ctxt =
new PublishedMessageImpl(datapool,rs.getLong(1),rs.getLong(2),rs.getInt(3),rs.getInt(4), new PublishedMessageImpl(env,rs.getLong(1),rs.getLong(2),rs.getInt(3),rs.getInt(4),
rs.getInt(5),SQLUtil.getFullDateTime(rs,6),rs.getString(7)); rs.getInt(5),SQLUtil.getFullDateTime(rs,6),rs.getString(7));
return_list.add(ctxt); return_list.add(ctxt);
@ -416,8 +419,7 @@ class PublishedMessageImpl implements TopicMessageContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -21,6 +21,7 @@ import java.sql.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.core.internals.*;
class SideBoxDescriptorImpl implements UserSideBoxDescriptor class SideBoxDescriptorImpl implements UserSideBoxDescriptor
{ {
@ -36,9 +37,8 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private int uid; // the user ID private EnvUser env; // the execution environment
private SideBoxDescriptor parent; // the master side box descriptor private SideBoxDescriptor parent; // the master side box descriptor
private DataPool datapool; // the data pool used by this object
private int sequence; // the sequence number private int sequence; // the sequence number
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
@ -46,11 +46,10 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
SideBoxDescriptorImpl(int uid, SideBoxDescriptor parent, DataPool datapool, int sequence) SideBoxDescriptorImpl(EnvUser env, SideBoxDescriptor parent, int sequence)
{ {
this.uid = uid; this.env = env;
this.parent = parent; this.parent = parent;
this.datapool = datapool;
this.sequence = sequence; this.sequence = sequence;
} // end constructor } // end constructor
@ -94,15 +93,15 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor
Connection conn = null; Connection conn = null;
try try
{ // retrieve a connection from the datapool { // retrieve a connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the UPDATE statement and just execute it blind (if this sidebox is not in the list, // create the UPDATE statement and just execute it blind (if this sidebox is not in the list,
// the UPDATE is a no-op). // the UPDATE is a no-op).
StringBuffer sql = new StringBuffer("UPDATE sideboxes SET sequence = "); StringBuffer sql = new StringBuffer("UPDATE sideboxes SET sequence = ");
sql.append(seq).append(" WHERE uid = ").append(uid).append(" AND boxid = ").append(parent.getID()); sql.append(seq).append(" WHERE uid = ").append(env.getUserID()).append(" AND boxid = ");
sql.append(';'); sql.append(parent.getID()).append(';');
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
this.sequence = seq; this.sequence = seq;
@ -115,8 +114,7 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -127,14 +125,14 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor
Connection conn = null; Connection conn = null;
try try
{ // retrieve a connection from the datapool { // retrieve a connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the DELETE statement and just execute it blind (if this conference is not in the hotlist, // create the DELETE statement and just execute it blind (if this conference is not in the hotlist,
// the DELETE is a no-op). // the DELETE is a no-op).
StringBuffer sql = new StringBuffer("DELETE FROM sideboxes WHERE uid = "); StringBuffer sql = new StringBuffer("DELETE FROM sideboxes WHERE uid = ");
sql.append(uid).append(" AND boxid = ").append(parent.getID()).append(';'); sql.append(env.getUserID()).append(" AND boxid = ").append(parent.getID()).append(';');
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
} // end try } // end try
@ -146,8 +144,7 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -22,8 +22,9 @@ import javax.mail.*;
import javax.mail.internet.*; import javax.mail.internet.*;
import com.silverwrist.venice.core.EmailException; import com.silverwrist.venice.core.EmailException;
import com.silverwrist.venice.core.InternalStateError; import com.silverwrist.venice.core.InternalStateError;
import com.silverwrist.venice.core.internals.Emailer;
class SimpleEmailer class SimpleEmailer implements Emailer
{ {
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Attributes * Attributes
@ -65,7 +66,7 @@ class SimpleEmailer
} // end constructor } // end constructor
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* External operations * Implementations from interface Emailer
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */

View File

@ -24,10 +24,11 @@ import java.util.zip.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.util.IOUtil; import com.silverwrist.util.IOUtil;
import com.silverwrist.util.StringUtil; import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.security.AuditRecord; import com.silverwrist.venice.security.AuditRecord;
import com.silverwrist.venice.security.Capability; import com.silverwrist.venice.security.Capability;
import com.silverwrist.venice.core.*;
class TopicMessageUserContextImpl implements TopicMessageContext class TopicMessageUserContextImpl implements TopicMessageContext
{ {
@ -45,9 +46,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; private EnvConference env; // the conference environment
private ConferenceBackend conf;
private DataPool datapool;
private long postid; private long postid;
private long parent; private long parent;
private int num; private int num;
@ -71,15 +70,12 @@ class TopicMessageUserContextImpl implements TopicMessageContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
protected TopicMessageUserContextImpl(EngineBackend engine, ConferenceBackend conf, DataPool datapool, protected TopicMessageUserContextImpl(EnvConference env, long postid, long parent, int num, int linecount,
long postid, long parent, int num, int linecount, int creator_uid, int creator_uid, java.util.Date posted, boolean hidden,
java.util.Date posted, boolean hidden, int scribble_uid, int scribble_uid, java.util.Date scribble_date, String pseud,
java.util.Date scribble_date, String pseud, int datalen, int datalen, String filename, String mimetype, int stgmethod)
String filename, String mimetype, int stgmethod)
{ {
this.engine = engine; this.env = env;
this.conf = conf;
this.datapool = datapool;
this.postid = postid; this.postid = postid;
this.parent = parent; this.parent = parent;
this.num = num; this.num = num;
@ -97,13 +93,10 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end constructor } // end constructor
TopicMessageUserContextImpl(EngineBackend engine, ConferenceBackend conf, DataPool datapool, TopicMessageUserContextImpl(EnvConference env, long postid, long parent, int num, int linecount,
long postid, long parent, int num, int linecount, int creator_uid, int creator_uid, java.util.Date posted, String pseud)
java.util.Date posted, String pseud)
{ {
this.engine = engine; this.env = env;
this.conf = conf;
this.datapool = datapool;
this.postid = postid; this.postid = postid;
this.parent = parent; this.parent = parent;
this.num = num; this.num = num;
@ -227,7 +220,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
try try
{ // use a database connection to get the user name { // use a database connection to get the user name
conn = datapool.getConnection(); conn = env.getConnection();
refresh(conn); refresh(conn);
if (nuked) if (nuked)
return null; // post nuked! return null; // post nuked!
@ -242,8 +235,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -299,7 +291,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
try try
{ // use a database connection to get the body text { // use a database connection to get the body text
conn = datapool.getConnection(); conn = env.getConnection();
refresh(conn); refresh(conn);
if (nuked) if (nuked)
@ -327,8 +319,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -375,7 +366,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
InputStream rc = null; InputStream rc = null;
try try
{ // open up a database connection { // open up a database connection
conn = datapool.getConnection(); conn = env.getConnection();
// make sure we have current data // make sure we have current data
refresh(conn); refresh(conn);
@ -451,8 +442,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -462,27 +452,29 @@ class TopicMessageUserContextImpl implements TopicMessageContext
public boolean canHide() public boolean canHide()
{ {
return (((creator_uid==conf.realUID()) && (!conf.userIsAnonymous())) || conf.userCanHide()); return ( ((creator_uid==env.getUserID()) && (!env.getUser().userIsAnonymous()))
|| env.getConference().userCanHide());
} // end canHide } // end canHide
public boolean canScribble() public boolean canScribble()
{ {
return (((creator_uid==conf.realUID()) && (!conf.userIsAnonymous())) || conf.userCanScribble()); return ( ((creator_uid==env.getUserID()) && (!env.getUser().userIsAnonymous()))
|| env.getConference().userCanScribble());
} // end canScribble } // end canScribble
public boolean canNuke() public boolean canNuke()
{ {
return conf.userCanNuke(); return env.getConference().userCanNuke();
} // end canNuke } // end canNuke
public void setHidden(boolean flag) throws DataException, AccessError public void setHidden(boolean flag) throws DataException, AccessError
{ {
if (conf.userIsAnonymous()) if (env.getUser().userIsAnonymous())
return; // no-op return; // no-op
if ((creator_uid!=conf.realUID()) && !(conf.userCanHide())) if ((creator_uid!=env.getUserID()) && !(env.getConference().userCanHide()))
{ // we can't change the hidden status! { // we can't change the hidden status!
logger.error("trying to set hidden status of post w/o permission!"); logger.error("trying to set hidden status of post w/o permission!");
throw new AccessError("You are not permitted to change the hidden status of this message."); throw new AccessError("You are not permitted to change the hidden status of this message.");
@ -497,7 +489,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
try try
{ // open up a database connection { // open up a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// lock the tables we reference // lock the tables we reference
@ -526,9 +518,8 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end finally } // end finally
// record what we did in an audit record // record what we did in an audit record
ar = new AuditRecord(AuditRecord.HIDE_MESSAGE,conf.realUID(),conf.userRemoteAddress(), ar = env.newAudit(AuditRecord.HIDE_MESSAGE,"conf=" + env.getConfID() + ",post=" + postid,
conf.realCommunityID(),"conf=" + conf.realConfID() + ",post=" + postid, flag ? "hide" : "unhide");
flag ? "hide" : "unhide");
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -551,8 +542,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -560,9 +550,9 @@ class TopicMessageUserContextImpl implements TopicMessageContext
public void scribble() throws DataException, AccessError public void scribble() throws DataException, AccessError
{ {
if (conf.userIsAnonymous()) if (env.getUser().userIsAnonymous())
return; // no-op return; // no-op
if ((creator_uid!=conf.realUID()) && !(conf.userCanScribble())) if ((creator_uid!=env.getUserID()) && !(env.getConference().userCanScribble()))
{ // we can't scribble this post { // we can't scribble this post
logger.error("trying to scribble post w/o permission!"); logger.error("trying to scribble post w/o permission!");
throw new AccessError("You are not permitted to scribble this message."); throw new AccessError("You are not permitted to scribble this message.");
@ -577,7 +567,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
try try
{ // open up a database connection { // open up a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// lock the tables we reference // lock the tables we reference
@ -590,7 +580,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
// First, set the appropriate "scribbled" information in the "header". // First, set the appropriate "scribbled" information in the "header".
StringBuffer sql = new StringBuffer("UPDATE posts SET linecount = 0, hidden = 0, scribble_uid = "); StringBuffer sql = new StringBuffer("UPDATE posts SET linecount = 0, hidden = 0, scribble_uid = ");
sql.append(conf.realUID()).append(", scribble_date = '"); sql.append(env.getUserID()).append(", scribble_date = '");
java.util.Date now = new java.util.Date(); java.util.Date now = new java.util.Date();
final String scribble_pseud = "<EM><B>(Scribbled)</B></EM>"; // TODO: configurable option final String scribble_pseud = "<EM><B>(Scribbled)</B></EM>"; // TODO: configurable option
sql.append(SQLUtil.encodeDate(now)).append("', pseud = '").append(scribble_pseud); sql.append(SQLUtil.encodeDate(now)).append("', pseud = '").append(scribble_pseud);
@ -639,12 +629,12 @@ class TopicMessageUserContextImpl implements TopicMessageContext
sql.setLength(0); sql.setLength(0);
sql.append("DELETE FROM postpublish WHERE postid = ").append(postid).append(';'); sql.append("DELETE FROM postpublish WHERE postid = ").append(postid).append(';');
if (stmt.executeUpdate(sql.toString())>0) if (stmt.executeUpdate(sql.toString())>0)
engine.unpublish(postid); env.getEngine().unpublish(postid);
// Update our internal data fields. // Update our internal data fields.
linecount = 0; linecount = 0;
hidden = false; hidden = false;
scribble_uid = conf.realUID(); scribble_uid = env.getUserID();
scribble_date = now; scribble_date = now;
pseud = scribble_pseud; pseud = scribble_pseud;
text_cache = null; text_cache = null;
@ -658,8 +648,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end finally } // end finally
// record what we did in an audit record // record what we did in an audit record
ar = new AuditRecord(AuditRecord.SCRIBBLE_MESSAGE,conf.realUID(),conf.userRemoteAddress(), ar = env.newAudit(AuditRecord.SCRIBBLE_MESSAGE,"conf=" + env.getConfID() + ",post=" + postid);
conf.realCommunityID(),"conf=" + conf.realConfID() + ",post=" + postid);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -682,8 +671,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -691,7 +679,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
public void nuke() throws DataException, AccessError public void nuke() throws DataException, AccessError
{ {
if (!(conf.userCanNuke())) if (!(env.getConference().userCanNuke()))
{ // we can't scribble this post { // we can't scribble this post
logger.error("trying to nuke post w/o permission!"); logger.error("trying to nuke post w/o permission!");
throw new AccessError("You are not permitted to nuke this message."); throw new AccessError("You are not permitted to nuke this message.");
@ -706,7 +694,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
try try
{ // open up a database connection { // open up a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// lock the tables we reference // lock the tables we reference
@ -732,7 +720,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
stmt.executeUpdate("DELETE FROM postattach WHERE postid = " + postid + ";"); stmt.executeUpdate("DELETE FROM postattach WHERE postid = " + postid + ";");
stmt.executeUpdate("DELETE FROM postdogear WHERE postid = " + postid + ";"); stmt.executeUpdate("DELETE FROM postdogear WHERE postid = " + postid + ";");
if (stmt.executeUpdate("DELETE FROM postpublish WHERE postid = " + postid + ";")>0) if (stmt.executeUpdate("DELETE FROM postpublish WHERE postid = " + postid + ";")>0)
engine.unpublish(postid); env.getEngine().unpublish(postid);
// Phase 1 of renumber - Renumber all posts IN THIS TOPIC that had a number higher than the one // Phase 1 of renumber - Renumber all posts IN THIS TOPIC that had a number higher than the one
// we just blew to hell. (Must have the "topicid =" clause in there - see Bug #415473) // we just blew to hell. (Must have the "topicid =" clause in there - see Bug #415473)
@ -767,8 +755,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end finally } // end finally
// record what we did in an audit record // record what we did in an audit record
ar = new AuditRecord(AuditRecord.NUKE_MESSAGE,conf.realUID(),conf.userRemoteAddress(), ar = env.newAudit(AuditRecord.NUKE_MESSAGE,"conf=" + env.getConfID() + ",post=" + postid);
conf.realCommunityID(),"conf=" + conf.realConfID() + ",post=" + postid);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -791,8 +778,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -811,7 +797,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end if } // end if
if (creator_uid!=conf.realUID()) if (creator_uid!=env.getUserID())
{ // you can't attach to this message! { // you can't attach to this message!
logger.error("tried to attach data to a message that's not yours!"); logger.error("tried to attach data to a message that's not yours!");
throw new AccessError("You are not permitted to add an attachment to this message."); throw new AccessError("You are not permitted to add an attachment to this message.");
@ -858,7 +844,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
int real_length = 0; int real_length = 0;
int tmp_stgmethod; int tmp_stgmethod;
if (engine.isNoCompressMimeType(m_type)) if (env.getEngine().isNoCompressMimeType(m_type))
{ // don't compress me, just store me normally { // don't compress me, just store me normally
logger.debug("stored as NORMAL data (no compression)"); logger.debug("stored as NORMAL data (no compression)");
real_data = data; real_data = data;
@ -913,7 +899,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
try try
{ // open up a database connection { // open up a database connection
conn = datapool.getConnection(); conn = env.getConnection();
// make sure we have the right status to upload // make sure we have the right status to upload
refresh(conn); refresh(conn);
@ -948,9 +934,8 @@ class TopicMessageUserContextImpl implements TopicMessageContext
stgmethod = tmp_stgmethod; stgmethod = tmp_stgmethod;
// Generate an audit record indicating what we did. // Generate an audit record indicating what we did.
ar = new AuditRecord(AuditRecord.UPLOAD_ATTACHMENT,conf.realUID(),conf.userRemoteAddress(), ar = env.newAudit(AuditRecord.UPLOAD_ATTACHMENT,"conf=" + env.getConfID() + ",post=" + postid,
conf.realCommunityID(),"conf=" + conf.realConfID() + ",post=" + postid, "len=" + length + ",type=" + m_type + ",name=" + file + ",method=" + tmp_stgmethod);
"len=" + length + ",type=" + m_type + ",name=" + file + ",method=" + tmp_stgmethod);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -973,8 +958,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -982,7 +966,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
public boolean canPublish() public boolean canPublish()
{ {
if (!(Capability.canPublishToFrontPage(conf.realBaseLevel()))) if (!(Capability.canPublishToFrontPage(env.getUser().realBaseLevel())))
return false; // must be a sysadmin to publish return false; // must be a sysadmin to publish
if ((scribble_date!=null) || nuked) if ((scribble_date!=null) || nuked)
return false; // cannot publish a scribbled or nuked message return false; // cannot publish a scribbled or nuked message
@ -991,7 +975,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// see if the post has already been published // see if the post has already been published
@ -1007,8 +991,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1018,7 +1001,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
public void publish() throws DataException, AccessError public void publish() throws DataException, AccessError
{ {
if (!(Capability.canPublishToFrontPage(conf.realBaseLevel()))) if (!(Capability.canPublishToFrontPage(env.getUser().realBaseLevel())))
{ // you aren't allowed to publish - naughty naughty! { // you aren't allowed to publish - naughty naughty!
logger.error("unable to publish because we're not allowed"); logger.error("unable to publish because we're not allowed");
throw new AccessError("You are not permitted to publish postings to the front page."); throw new AccessError("You are not permitted to publish postings to the front page.");
@ -1044,7 +1027,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// see if post has already been published // see if post has already been published
@ -1054,31 +1037,30 @@ class TopicMessageUserContextImpl implements TopicMessageContext
throw new DataException("This posting has already been published."); throw new DataException("This posting has already been published.");
boolean done = false; boolean done = false;
engine.startPublish(); env.getEngine().startPublish();
try try
{ // insert the post reference into the database { // insert the post reference into the database
StringBuffer sql = StringBuffer sql =
new StringBuffer("INSERT INTO postpublish (sigid, postid, by_uid, on_date) VALUES ("); new StringBuffer("INSERT INTO postpublish (sigid, postid, by_uid, on_date) VALUES (");
sql.append(conf.realCommunityID()).append(", ").append(postid).append(", ").append(conf.realUID()); sql.append(env.getCommunityID()).append(", ").append(postid).append(", ").append(env.getUserID());
java.util.Date now = new java.util.Date(); java.util.Date now = new java.util.Date();
sql.append(", '").append(SQLUtil.encodeDate(now)).append("');"); sql.append(", '").append(SQLUtil.encodeDate(now)).append("');");
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
// generate an audit record indicating what we've done // generate an audit record indicating what we've done
ar = new AuditRecord(AuditRecord.PUBLISH_POST,conf.realUID(),conf.userRemoteAddress(), ar = env.newAudit(AuditRecord.PUBLISH_POST,"conf=" + env.getConfID() + ",post=" + postid);
conf.realCommunityID(),"conf=" + conf.realConfID() + ",post=" + postid);
// establish cached data object for front page // establish cached data object for front page
engine.publishNew(new PublishedMessageImpl(datapool,postid,parent,num,linecount,creator_uid, env.getEngine().publishNew(new PublishedMessageImpl(env,postid,parent,num,linecount,creator_uid,
posted,pseud,creator_cache,text_cache)); posted,pseud,creator_cache,text_cache));
done = true; done = true;
} // end try } // end try
finally finally
{ // make sure to release the lock if we goofed in here { // make sure to release the lock if we goofed in here
if (!done) if (!done)
engine.publishNew(null); env.getEngine().publishNew(null);
} // end finally } // end finally
@ -1103,8 +1085,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1115,11 +1096,11 @@ class TopicMessageUserContextImpl implements TopicMessageContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
static List loadMessageRange(EngineBackend engine, ConferenceBackend conf, DataPool datapool, int topicid, static List loadMessageRange(EnvConference env, int topicid, int post_low, int post_high)
int post_low, int post_high) throws DataException throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("loadMessageRange for conf # " + conf.realConfID() + ", topic #" + topicid + ", range [" logger.debug("loadMessageRange for conf # " + env.getConfID() + ", topic #" + topicid + ", range ["
+ post_low + ", " + post_high + "]"); + post_low + ", " + post_high + "]");
ArrayList rc = new ArrayList(); ArrayList rc = new ArrayList();
@ -1127,7 +1108,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// run a query to get all the posts in a particular topic // run a query to get all the posts in a particular topic
@ -1145,11 +1126,10 @@ class TopicMessageUserContextImpl implements TopicMessageContext
while (rs.next()) while (rs.next())
{ // create implementation objects and shove them into the return vector { // create implementation objects and shove them into the return vector
TopicMessageContext val = TopicMessageContext val =
new TopicMessageUserContextImpl(engine,conf,datapool,rs.getLong(1),rs.getLong(2),rs.getInt(3), new TopicMessageUserContextImpl(env,rs.getLong(1),rs.getLong(2),rs.getInt(3),rs.getInt(4),
rs.getInt(4),rs.getInt(5),SQLUtil.getFullDateTime(rs,6), rs.getInt(5),SQLUtil.getFullDateTime(rs,6),rs.getBoolean(7),
rs.getBoolean(7),rs.getInt(8),SQLUtil.getFullDateTime(rs,9), rs.getInt(8),SQLUtil.getFullDateTime(rs,9),rs.getString(10),
rs.getString(10),rs.getInt(11),rs.getString(12),rs.getString(13), rs.getInt(11),rs.getString(12),rs.getString(13),rs.getInt(14));
rs.getInt(14));
rc.add(val); rc.add(val);
} // end while } // end while
@ -1163,8 +1143,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1172,18 +1151,17 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end loadMessageRange } // end loadMessageRange
static TopicMessageContext loadMessage(EngineBackend engine, ConferenceBackend conf, DataPool datapool, static TopicMessageContext loadMessage(EnvConference env, int topicid, int message_num) throws DataException
int topicid, int message_num) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("loadMessage for conf # " + conf.realConfID() + ", topic #" + topicid + ", message " logger.debug("loadMessage for conf # " + env.getConfID() + ", topic #" + topicid + ", message "
+ message_num); + message_num);
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// run a query to get all the posts in a particular topic // run a query to get all the posts in a particular topic
@ -1198,11 +1176,10 @@ class TopicMessageUserContextImpl implements TopicMessageContext
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
if (rs.next()) // create an object reference and return it if (rs.next()) // create an object reference and return it
return new TopicMessageUserContextImpl(engine,conf,datapool,rs.getLong(1),rs.getLong(2),rs.getInt(3), return new TopicMessageUserContextImpl(env,rs.getLong(1),rs.getLong(2),rs.getInt(3),rs.getInt(4),
rs.getInt(4),rs.getInt(5),SQLUtil.getFullDateTime(rs,6), rs.getInt(5),SQLUtil.getFullDateTime(rs,6),rs.getBoolean(7),
rs.getBoolean(7),rs.getInt(8),SQLUtil.getFullDateTime(rs,9), rs.getInt(8),SQLUtil.getFullDateTime(rs,9),rs.getString(10),
rs.getString(10),rs.getInt(11),rs.getString(12), rs.getInt(11),rs.getString(12),rs.getString(13),rs.getInt(14));
rs.getString(13),rs.getInt(14));
// indicates an error... // indicates an error...
throw new DataException("Message not found."); throw new DataException("Message not found.");
@ -1216,24 +1193,22 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
} // end loadMessage } // end loadMessage
static TopicMessageContext getMessage(EngineBackend engine, ConferenceBackend conf, DataPool datapool, static TopicMessageContext getMessage(EnvConference env, long postid) throws DataException
long postid) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("getMessage for conf # " + conf.realConfID() + ", post #" + postid); logger.debug("getMessage for conf # " + env.getConfID() + ", post #" + postid);
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = StringBuffer sql =
@ -1241,17 +1216,16 @@ class TopicMessageUserContextImpl implements TopicMessageContext
+ "p.hidden, p.scribble_uid, p.scribble_date, p.pseud, a.datalen, a.filename, " + "p.hidden, p.scribble_uid, p.scribble_date, p.pseud, a.datalen, a.filename, "
+ "a.mimetype, a.stgmethod FROM topics t, posts p LEFT JOIN postattach a " + "a.mimetype, a.stgmethod FROM topics t, posts p LEFT JOIN postattach a "
+ "ON p.postid = a.postid WHERE t.topicid = p.topicid AND t.confid = "); + "ON p.postid = a.postid WHERE t.topicid = p.topicid AND t.confid = ");
sql.append(conf.realConfID()).append(" AND p.postid = ").append(postid).append(';'); sql.append(env.getConfID()).append(" AND p.postid = ").append(postid).append(';');
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString()); logger.debug("SQL: " + sql.toString());
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
if (rs.next()) // create an object reference and return it if (rs.next()) // create an object reference and return it
return new TopicMessageUserContextImpl(engine,conf,datapool,rs.getLong(1),rs.getLong(2),rs.getInt(3), return new TopicMessageUserContextImpl(env,rs.getLong(1),rs.getLong(2),rs.getInt(3),rs.getInt(4),
rs.getInt(4),rs.getInt(5),SQLUtil.getFullDateTime(rs,6), rs.getInt(5),SQLUtil.getFullDateTime(rs,6),rs.getBoolean(7),
rs.getBoolean(7),rs.getInt(8),SQLUtil.getFullDateTime(rs,9), rs.getInt(8),SQLUtil.getFullDateTime(rs,9),rs.getString(10),
rs.getString(10),rs.getInt(11),rs.getString(12), rs.getInt(11),rs.getString(12),rs.getString(13),rs.getInt(14));
rs.getString(13),rs.getInt(14));
// indicates an error... // indicates an error...
throw new DataException("Message not found."); throw new DataException("Message not found.");
@ -1265,8 +1239,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -20,10 +20,11 @@ package com.silverwrist.venice.core.impl;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.htmlcheck.*; import com.silverwrist.venice.htmlcheck.*;
import com.silverwrist.venice.security.AuditRecord; import com.silverwrist.venice.security.AuditRecord;
import com.silverwrist.venice.core.*;
class TopicUserContextImpl implements TopicContext class TopicUserContextImpl implements TopicContext
{ {
@ -39,9 +40,7 @@ class TopicUserContextImpl implements TopicContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; private EnvConference env; // the enclosing environment
private ConferenceBackend conf;
private DataPool datapool;
private int topicid; private int topicid;
private short topicnum; private short topicnum;
private int creator_uid; private int creator_uid;
@ -61,14 +60,11 @@ class TopicUserContextImpl implements TopicContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
protected TopicUserContextImpl(EngineBackend engine, ConferenceBackend conf, DataPool datapool, int topicid, protected TopicUserContextImpl(EnvConference env, int topicid, short topicnum, int creator_uid,
short topicnum, int creator_uid, int top_message, boolean frozen, int top_message, boolean frozen, boolean archived, java.util.Date created,
boolean archived, java.util.Date created, java.util.Date lastupdate, java.util.Date lastupdate, String name, boolean hidden, int unread)
String name, boolean hidden, int unread)
{ {
this.engine = engine; this.env = env;
this.conf = conf;
this.datapool = datapool;
this.topicid = topicid; this.topicid = topicid;
this.topicnum = topicnum; this.topicnum = topicnum;
this.creator_uid = creator_uid; this.creator_uid = creator_uid;
@ -83,15 +79,12 @@ class TopicUserContextImpl implements TopicContext
} // end constructor } // end constructor
TopicUserContextImpl(EngineBackend engine, ConferenceBackend conf, DataPool datapool, ReturnTopicInfo inf, TopicUserContextImpl(EnvConference env, ReturnTopicInfo inf, String name)
String name)
{ {
this.engine = engine; this.env = env;
this.conf = conf;
this.datapool = datapool;
this.topicid = inf.getTopicID(); this.topicid = inf.getTopicID();
this.topicnum = inf.getTopicNum(); this.topicnum = inf.getTopicNum();
this.creator_uid = conf.realUID(); this.creator_uid = env.getUserID();
this.top_message = 0; this.top_message = 0;
this.frozen = false; this.frozen = false;
this.archived = false; this.archived = false;
@ -144,7 +137,7 @@ class TopicUserContextImpl implements TopicContext
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// perform a requery of the database // perform a requery of the database
ResultSet rs = queryByTopic(stmt,topicid,conf.realUID()); ResultSet rs = queryByTopic(stmt,topicid,env.getUserID());
if (rs.next()) if (rs.next())
{ // update the fields that are capable of changing { // update the fields that are capable of changing
top_message = rs.getInt(4); top_message = rs.getInt(4);
@ -166,7 +159,7 @@ class TopicUserContextImpl implements TopicContext
{ {
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT bozo_uid FROM topicbozo WHERE topicid = "); StringBuffer sql = new StringBuffer("SELECT bozo_uid FROM topicbozo WHERE topicid = ");
sql.append(topicid).append(" AND uid = ").append(conf.realUID()).append(';'); sql.append(topicid).append(" AND uid = ").append(env.getUserID()).append(';');
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
bozo_uids = new HashSet(); bozo_uids = new HashSet();
while (rs.next()) while (rs.next())
@ -187,7 +180,7 @@ class TopicUserContextImpl implements TopicContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
refresh(conn); refresh(conn);
} // end try } // end try
@ -199,8 +192,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -280,13 +272,13 @@ class TopicUserContextImpl implements TopicContext
public boolean canFreeze() public boolean canFreeze()
{ {
return conf.userCanHide(); return env.getConference().userCanHide();
} // end canFreeze } // end canFreeze
public boolean canArchive() public boolean canArchive()
{ {
return conf.userCanHide(); return env.getConference().userCanHide();
} // end canArchive } // end canArchive
@ -294,7 +286,7 @@ class TopicUserContextImpl implements TopicContext
{ {
if ((frozen==flag) || deleted) if ((frozen==flag) || deleted)
return; // no-op return; // no-op
if (!(conf.userCanHide())) if (!(env.getConference().userCanHide()))
{ // you can't freeze the topic! { // you can't freeze the topic!
logger.error("user cannot change frozen status of topic"); logger.error("user cannot change frozen status of topic");
throw new AccessError("You are not permitted to freeze or unfreeze this topic."); throw new AccessError("You are not permitted to freeze or unfreeze this topic.");
@ -306,7 +298,7 @@ class TopicUserContextImpl implements TopicContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the SQL statement to freeze or unfreeze the topic // create the SQL statement to freeze or unfreeze the topic
@ -315,9 +307,8 @@ class TopicUserContextImpl implements TopicContext
if (stmt.executeUpdate(sql.toString())>0) if (stmt.executeUpdate(sql.toString())>0)
{ // success! save the flag and generate an audit record { // success! save the flag and generate an audit record
frozen = flag; frozen = flag;
ar = new AuditRecord(AuditRecord.TOPIC_FREEZE,conf.realUID(),conf.userRemoteAddress(), ar = env.newAudit(AuditRecord.TOPIC_FREEZE,"conf=" + env.getConfID() + ",topic=" + topicid,
conf.realCommunityID(),"conf=" + String.valueOf(conf.realConfID()) + ",topic=" flag ? "freeze" : "unfreeze");
+ String.valueOf(topicid),flag ? "freeze" : "unfreeze");
} // end if } // end if
else // somebody else must have deleted this topic else // somebody else must have deleted this topic
@ -344,8 +335,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -355,7 +345,7 @@ class TopicUserContextImpl implements TopicContext
{ {
if ((archived==flag) || deleted) if ((archived==flag) || deleted)
return; // no-op return; // no-op
if (!(conf.userCanHide())) if (!(env.getConference().userCanHide()))
{ // you can't archive the topic! { // you can't archive the topic!
logger.error("user cannot change archived status of topic"); logger.error("user cannot change archived status of topic");
throw new AccessError("You are not permitted to archive or unarchive this topic."); throw new AccessError("You are not permitted to archive or unarchive this topic.");
@ -367,7 +357,7 @@ class TopicUserContextImpl implements TopicContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the SQL statement to freeze or unfreeze the topic // create the SQL statement to freeze or unfreeze the topic
@ -376,9 +366,8 @@ class TopicUserContextImpl implements TopicContext
if (stmt.executeUpdate(sql.toString())>0) if (stmt.executeUpdate(sql.toString())>0)
{ // success! save the flag and generate an audit record { // success! save the flag and generate an audit record
archived = flag; archived = flag;
ar = new AuditRecord(AuditRecord.TOPIC_ARCHIVE,conf.realUID(),conf.userRemoteAddress(), ar = env.newAudit(AuditRecord.TOPIC_ARCHIVE,"conf=" + env.getConfID() + ",topic=" + topicid,
conf.realCommunityID(),"conf=" + String.valueOf(conf.realConfID()) + ",topic=" flag ? "archive" : "unarchive");
+ String.valueOf(topicid),flag ? "archive" : "unarchive");
} // end if } // end if
else // somebody else must have deleted this topic else // somebody else must have deleted this topic
@ -405,8 +394,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -414,14 +402,14 @@ class TopicUserContextImpl implements TopicContext
public void setHidden(boolean flag) throws DataException public void setHidden(boolean flag) throws DataException
{ {
if ((hidden==flag) || deleted || conf.userIsAnonymous()) if ((hidden==flag) || deleted || env.getUser().userIsAnonymous())
return; // no-op return; // no-op
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
stmt.executeUpdate("LOCK TABLES topicsettings WRITE, topics READ;"); stmt.executeUpdate("LOCK TABLES topicsettings WRITE, topics READ;");
@ -429,7 +417,7 @@ class TopicUserContextImpl implements TopicContext
{ // start by trying to see if we can update topicsettings directly { // start by trying to see if we can update topicsettings directly
StringBuffer sql = new StringBuffer("UPDATE topicsettings SET hidden = "); StringBuffer sql = new StringBuffer("UPDATE topicsettings SET hidden = ");
sql.append(flag ? '1' : '0').append(" WHERE topicid = ").append(topicid).append(" AND uid = "); sql.append(flag ? '1' : '0').append(" WHERE topicid = ").append(topicid).append(" AND uid = ");
sql.append(conf.realUID()).append(';'); sql.append(env.getUserID()).append(';');
if (stmt.executeUpdate(sql.toString())>0) if (stmt.executeUpdate(sql.toString())>0)
{ // that was all we needed - just save the flag and exit { // that was all we needed - just save the flag and exit
hidden = flag; hidden = flag;
@ -451,7 +439,7 @@ class TopicUserContextImpl implements TopicContext
// OK, just insert a new row into topicsettings, why dontcha... // OK, just insert a new row into topicsettings, why dontcha...
sql.setLength(0); sql.setLength(0);
sql.append("INSERT INTO topicsettings (topicid, uid, hidden) VALUES (").append(topicid).append(", "); sql.append("INSERT INTO topicsettings (topicid, uid, hidden) VALUES (").append(topicid).append(", ");
sql.append(conf.realUID()).append(", ").append(flag ? '1' : '0').append(");"); sql.append(env.getUserID()).append(", ").append(flag ? '1' : '0').append(");");
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
hidden = flag; // successful completion hidden = flag; // successful completion
@ -472,8 +460,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -493,7 +480,7 @@ class TopicUserContextImpl implements TopicContext
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("[raw] setUnreadMessages(" + count + ") entry"); logger.debug("[raw] setUnreadMessages(" + count + ") entry");
if (conf.userIsAnonymous()) if (env.getUser().userIsAnonymous())
{ // this is effectively a no-op, but log it { // this is effectively a no-op, but log it
logger.debug("reject 1: anonymous user"); logger.debug("reject 1: anonymous user");
return; return;
@ -519,7 +506,7 @@ class TopicUserContextImpl implements TopicContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
stmt.executeUpdate("LOCK TABLES confsettings WRITE, topicsettings WRITE, topics READ;"); stmt.executeUpdate("LOCK TABLES confsettings WRITE, topicsettings WRITE, topics READ;");
@ -529,13 +516,13 @@ class TopicUserContextImpl implements TopicContext
sql.append(last_msg).append(", last_read = '"); sql.append(last_msg).append(", last_read = '");
java.util.Date now = new java.util.Date(); java.util.Date now = new java.util.Date();
sql.append(SQLUtil.encodeDate(now)).append("' WHERE topicid = ").append(topicid).append(" AND uid = "); sql.append(SQLUtil.encodeDate(now)).append("' WHERE topicid = ").append(topicid).append(" AND uid = ");
sql.append(conf.realUID()).append(';'); sql.append(env.getUserID()).append(';');
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString()); logger.debug("SQL: " + sql.toString());
if (stmt.executeUpdate(sql.toString())>0) if (stmt.executeUpdate(sql.toString())>0)
{ // that was all we needed - just save the flag and exit { // that was all we needed - just save the flag and exit
logger.debug("--> bailed out after update - done with setUnreadMessages{"); logger.debug("--> bailed out after update - done with setUnreadMessages{");
conf.touchRead(conn); env.getConference().touchRead(conn);
unread = count; unread = count;
return; return;
@ -558,12 +545,12 @@ class TopicUserContextImpl implements TopicContext
// OK, just insert a new row into topicsettings, why dontcha... // OK, just insert a new row into topicsettings, why dontcha...
sql.setLength(0); sql.setLength(0);
sql.append("INSERT INTO topicsettings (topicid, uid, last_message, last_read) VALUES ("); sql.append("INSERT INTO topicsettings (topicid, uid, last_message, last_read) VALUES (");
sql.append(topicid).append(", ").append(conf.realUID()).append(", ").append(last_msg).append(", '"); sql.append(topicid).append(", ").append(env.getUserID()).append(", ").append(last_msg).append(", '");
sql.append(SQLUtil.encodeDate(now)).append("');"); sql.append(SQLUtil.encodeDate(now)).append("');");
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString()); logger.debug("SQL: " + sql.toString());
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
conf.touchRead(conn); env.getConference().touchRead(conn);
unread = count; // successful completion unread = count; // successful completion
} // end try } // end try
@ -583,8 +570,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -598,7 +584,7 @@ class TopicUserContextImpl implements TopicContext
public List getMessages(int low, int high) throws DataException, AccessError public List getMessages(int low, int high) throws DataException, AccessError
{ {
if (!(conf.userCanRead())) if (!(env.getConference().userCanRead()))
{ // they can't read messages in this topic! { // they can't read messages in this topic!
logger.error("trying to read postings w/o permission!"); logger.error("trying to read postings w/o permission!");
throw new AccessError("You do not have permission to read messages in this conference."); throw new AccessError("You do not have permission to read messages in this conference.");
@ -607,15 +593,15 @@ class TopicUserContextImpl implements TopicContext
// reorder parameters so they come in the correct order! // reorder parameters so they come in the correct order!
if (low<=high) if (low<=high)
return TopicMessageUserContextImpl.loadMessageRange(engine,conf,datapool,topicid,low,high); return TopicMessageUserContextImpl.loadMessageRange(env,topicid,low,high);
else else
return TopicMessageUserContextImpl.loadMessageRange(engine,conf,datapool,topicid,high,low); return TopicMessageUserContextImpl.loadMessageRange(env,topicid,high,low);
} // end getMessages } // end getMessages
public TopicMessageContext getMessage(int number) throws DataException, AccessError public TopicMessageContext getMessage(int number) throws DataException, AccessError
{ {
if (!(conf.userCanRead())) if (!(env.getConference().userCanRead()))
{ // they can't read messages in this topic! { // they can't read messages in this topic!
logger.error("trying to read postings w/o permission!"); logger.error("trying to read postings w/o permission!");
throw new AccessError("You do not have permission to read messages in this conference."); throw new AccessError("You do not have permission to read messages in this conference.");
@ -623,7 +609,7 @@ class TopicUserContextImpl implements TopicContext
} // end if } // end if
// pass down to one of our static functiions to return this // pass down to one of our static functiions to return this
return TopicMessageUserContextImpl.loadMessage(engine,conf,datapool,topicid,number); return TopicMessageUserContextImpl.loadMessage(env,topicid,number);
} // end getMessage } // end getMessage
@ -633,7 +619,7 @@ class TopicUserContextImpl implements TopicContext
if (logger.isInfoEnabled()) if (logger.isInfoEnabled())
logger.info("postNewMessage(" + parent + ", '" + pseud + "',<text>) entry"); logger.info("postNewMessage(" + parent + ", '" + pseud + "',<text>) entry");
if (!(conf.userCanPost())) if (!(env.getConference().userCanPost()))
{ // they can't post in this topic! { // they can't post in this topic!
logger.error("trying to post w/o permission!"); logger.error("trying to post w/o permission!");
throw new AccessError("You do not have permission to post messages in this conference."); throw new AccessError("You do not have permission to post messages in this conference.");
@ -647,14 +633,14 @@ class TopicUserContextImpl implements TopicContext
} // end if } // end if
if (frozen && !(conf.userCanHide())) if (frozen && !(env.getConference().userCanHide()))
{ // can't post to a frozen topic! { // can't post to a frozen topic!
logger.error("can't post to a frozen topic!"); logger.error("can't post to a frozen topic!");
throw new AccessError("The topic is frozen, and you do not have permission to post to it."); throw new AccessError("The topic is frozen, and you do not have permission to post to it.");
} // end if } // end if
if (archived && !(conf.userCanHide())) if (archived && !(env.getConference().userCanHide()))
{ // can't post to a frozen topic! { // can't post to a frozen topic!
logger.error("can't post to an archived topic!"); logger.error("can't post to an archived topic!");
throw new AccessError("The topic is archived, and you do not have permission to post to it."); throw new AccessError("The topic is archived, and you do not have permission to post to it.");
@ -662,9 +648,9 @@ class TopicUserContextImpl implements TopicContext
} // end if } // end if
// preprocess the two arguments through HTML checkers // preprocess the two arguments through HTML checkers
HTMLChecker pseud_ch = engine.createCheckerObject(engine.HTMLC_POST_PSEUD); HTMLChecker pseud_ch = env.getEngine().createCheckerObject(EngineBackend.HTMLC_POST_PSEUD);
HTMLChecker text_ch = engine.createCheckerObject(engine.HTMLC_POST_BODY); HTMLChecker text_ch = env.getEngine().createCheckerObject(EngineBackend.HTMLC_POST_BODY);
text_ch.setContextValue("PostLinkDecoderContext",conf.createDecoderContext(topicnum)); text_ch.setContextValue("PostLinkDecoderContext",env.getConference().createDecoderContext(topicnum));
try try
{ // run both arguments through the HTML checker { // run both arguments through the HTML checker
pseud_ch.append(pseud); pseud_ch.append(pseud);
@ -704,7 +690,7 @@ class TopicUserContextImpl implements TopicContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// slap a lock on all the tables we need to touch // slap a lock on all the tables we need to touch
@ -721,14 +707,14 @@ class TopicUserContextImpl implements TopicContext
} // end if } // end if
if (frozen && !(conf.userCanHide())) if (frozen && !(env.getConference().userCanHide()))
{ // can't post to a frozen topic! { // can't post to a frozen topic!
logger.error("can't post to a frozen topic!"); logger.error("can't post to a frozen topic!");
throw new AccessError("The topic is frozen, and you do not have permission to post to it."); throw new AccessError("The topic is frozen, and you do not have permission to post to it.");
} // end if } // end if
if (archived && !(conf.userCanHide())) if (archived && !(env.getConference().userCanHide()))
{ // can't post to a frozen topic! { // can't post to a frozen topic!
logger.error("can't post to an archived topic!"); logger.error("can't post to an archived topic!");
throw new AccessError("The topic is archived, and you do not have permission to post to it."); throw new AccessError("The topic is archived, and you do not have permission to post to it.");
@ -744,7 +730,7 @@ class TopicUserContextImpl implements TopicContext
StringBuffer sql = new StringBuffer("INSERT INTO posts (parent, topicid, num, linecount, creator_uid, " StringBuffer sql = new StringBuffer("INSERT INTO posts (parent, topicid, num, linecount, creator_uid, "
+ "posted, pseud) VALUES ("); + "posted, pseud) VALUES (");
sql.append(parent).append(", ").append(topicid).append(", ").append(new_post_num).append(", "); sql.append(parent).append(", ").append(topicid).append(", ").append(new_post_num).append(", ");
sql.append(text_linecount).append(", ").append(conf.realUID()).append(", '"); sql.append(text_linecount).append(", ").append(env.getUserID()).append(", '");
posted_date = new java.util.Date(); posted_date = new java.util.Date();
sql.append(SQLUtil.encodeDate(posted_date)).append("', '").append(real_pseud).append("');"); sql.append(SQLUtil.encodeDate(posted_date)).append("', '").append(real_pseud).append("');");
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
@ -776,7 +762,7 @@ class TopicUserContextImpl implements TopicContext
// mark that we posted to the topic // mark that we posted to the topic
sql.setLength(0); sql.setLength(0);
sql.append("UPDATE topicsettings SET last_post = '").append(SQLUtil.encodeDate(posted_date)); sql.append("UPDATE topicsettings SET last_post = '").append(SQLUtil.encodeDate(posted_date));
sql.append("' WHERE topicid = ").append(topicid).append(" AND uid = ").append(conf.realUID()); sql.append("' WHERE topicid = ").append(topicid).append(" AND uid = ").append(env.getUserID());
sql.append(';'); sql.append(';');
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString()); logger.debug("SQL: " + sql.toString());
@ -784,7 +770,7 @@ class TopicUserContextImpl implements TopicContext
{ // we had no topicsettings record, add one { // we had no topicsettings record, add one
sql.setLength(0); sql.setLength(0);
sql.append("INSERT INTO topicsettings (topicid, uid, last_post) VALUES (").append(topicid); sql.append("INSERT INTO topicsettings (topicid, uid, last_post) VALUES (").append(topicid);
sql.append(", ").append(conf.realUID()).append(", '").append(SQLUtil.encodeDate(posted_date)); sql.append(", ").append(env.getUserID()).append(", '").append(SQLUtil.encodeDate(posted_date));
sql.append("');"); sql.append("');");
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString()); logger.debug("SQL: " + sql.toString());
@ -793,8 +779,8 @@ class TopicUserContextImpl implements TopicContext
} // end if } // end if
// mark that we posted to the conference // mark that we posted to the conference
conf.touchUpdate(conn,posted_date); env.getConference().touchUpdate(conn,posted_date);
conf.touchPost(conn,posted_date); env.getConference().touchPost(conn,posted_date);
// Fill in our own local variables to reflect the update. This includes the recalculation // Fill in our own local variables to reflect the update. This includes the recalculation
// of "unread" based on the new value of "top_message". // of "unread" based on the new value of "top_message".
@ -814,10 +800,8 @@ class TopicUserContextImpl implements TopicContext
} // end finally } // end finally
// record what we did in an audit record // record what we did in an audit record
ar = new AuditRecord(AuditRecord.POST_MESSAGE,conf.realUID(),conf.userRemoteAddress(), ar = env.newAudit(AuditRecord.POST_MESSAGE,"conf=" + env.getConfID() + ",topic=" + topicid + ",post="
conf.realCommunityID(),"conf=" + String.valueOf(conf.realConfID()) + ",topic=" + new_post_id,"pseud=" + real_pseud);
+ String.valueOf(topicid) + ",post=" + String.valueOf(new_post_id),
"pseud=" + real_pseud);
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -840,34 +824,33 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
// return the new message context // return the new message context
return new TopicMessageUserContextImpl(engine,conf,datapool,new_post_id,parent,new_post_num, return new TopicMessageUserContextImpl(env,new_post_id,parent,new_post_num,text_linecount,env.getUserID(),
text_linecount,conf.realUID(),posted_date,real_pseud); posted_date,real_pseud);
} // end postMessage } // end postMessage
public HTMLChecker getPreviewChecker() public HTMLChecker getPreviewChecker()
{ {
HTMLChecker rc = engine.createCheckerObject(engine.HTMLC_PREVIEW_BODY); HTMLChecker rc = env.getEngine().createCheckerObject(EngineBackend.HTMLC_PREVIEW_BODY);
rc.setContextValue("PostLinkDecoderContext",conf.createDecoderContext(topicnum)); rc.setContextValue("PostLinkDecoderContext",env.getConference().createDecoderContext(topicnum));
return rc; return rc;
} // end getPreviewChecker } // end getPreviewChecker
public boolean canDelete() public boolean canDelete()
{ {
return conf.userCanNuke(); return env.getConference().userCanNuke();
} // end canDelete } // end canDelete
public void delete() throws DataException, AccessError public void delete() throws DataException, AccessError
{ {
if (!(conf.userCanNuke())) if (!(env.getConference().userCanNuke()))
{ // we can't delete the topic! { // we can't delete the topic!
logger.error("trying to delete w/o permission!"); logger.error("trying to delete w/o permission!");
throw new AccessError("You do not have permission to delete this topic."); throw new AccessError("You do not have permission to delete this topic.");
@ -884,7 +867,7 @@ class TopicUserContextImpl implements TopicContext
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// lock some tables while we do the critical parts of the delete // lock some tables while we do the critical parts of the delete
@ -907,7 +890,7 @@ class TopicUserContextImpl implements TopicContext
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
// and indicate that we updated the conference // and indicate that we updated the conference
conf.touchUpdate(conn,new java.util.Date()); env.getConference().touchUpdate(conn,new java.util.Date());
// determine the number of posts in this topic, and the maximum post ID // determine the number of posts in this topic, and the maximum post ID
sql.setLength(0); sql.setLength(0);
@ -930,9 +913,7 @@ class TopicUserContextImpl implements TopicContext
} // end finally } // end finally
// record what we did in an audit record // record what we did in an audit record
ar = new AuditRecord(AuditRecord.DELETE_TOPIC,conf.realUID(),conf.userRemoteAddress(), ar = env.newAudit(AuditRecord.DELETE_TOPIC,"conf=" + env.getConfID() + ",topic=" + topicid);
conf.realCommunityID(),"conf=" + String.valueOf(conf.realConfID()) + ",topic="
+ String.valueOf(topicid));
} // end try } // end try
catch (SQLException e) catch (SQLException e)
@ -955,13 +936,12 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
// Delete the rest of the gunk in the background; spin off another thread to handle it. // Delete the rest of the gunk in the background; spin off another thread to handle it.
BackgroundTopicPurge purger = new BackgroundTopicPurge(engine,datapool,topicid,post_count,post_max); BackgroundTopicPurge purger = new BackgroundTopicPurge(env,topicid,post_count,post_max);
Thread thrd = new Thread(purger); Thread thrd = new Thread(purger);
thrd.setPriority(Thread.NORM_PRIORITY-1); thrd.setPriority(Thread.NORM_PRIORITY-1);
thrd.start(); thrd.start();
@ -974,8 +954,8 @@ class TopicUserContextImpl implements TopicContext
ArrayList rc = new ArrayList(); ArrayList rc = new ArrayList();
try try
{ // retrieve a connection from the datapool { // retrieve a connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the SQL statement to retrieve all posters // create the SQL statement to retrieve all posters
@ -1007,8 +987,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1034,8 +1013,8 @@ class TopicUserContextImpl implements TopicContext
ArrayList rc = new ArrayList(); ArrayList rc = new ArrayList();
try try
{ // retrieve a connection from the datapool { // retrieve a connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the SQL statement to retrieve all readers // create the SQL statement to retrieve all readers
@ -1067,8 +1046,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1090,7 +1068,7 @@ class TopicUserContextImpl implements TopicContext
public boolean isBozo(int other_uid) throws DataException public boolean isBozo(int other_uid) throws DataException
{ {
if (deleted || conf.userIsAnonymous() || (other_uid==conf.realUID())) if (deleted || env.getUser().userIsAnonymous() || (other_uid==env.getUserID()))
return false; // no-op return false; // no-op
if (bozo_uids==null) if (bozo_uids==null)
@ -1098,7 +1076,7 @@ class TopicUserContextImpl implements TopicContext
Connection conn = null; Connection conn = null;
try try
{ // load the bozo filter UIDs from the database { // load the bozo filter UIDs from the database
conn = datapool.getConnection(); conn = env.getConnection();
loadBozo(conn); loadBozo(conn);
} // end try } // end try
@ -1110,8 +1088,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1123,13 +1100,13 @@ class TopicUserContextImpl implements TopicContext
public void setBozo(int other_uid, boolean bozo) throws DataException public void setBozo(int other_uid, boolean bozo) throws DataException
{ {
if (deleted || conf.userIsAnonymous() || (other_uid==conf.realUID())) if (deleted || env.getUser().userIsAnonymous() || (other_uid==env.getUserID()))
return; // no-op return; // no-op
Connection conn = null; Connection conn = null;
try try
{ // figure out what to do here { // figure out what to do here
conn = datapool.getConnection(); conn = env.getConnection();
refresh(conn); refresh(conn);
if (deleted) if (deleted)
return; // one more check to make sure we're not deleted return; // one more check to make sure we're not deleted
@ -1144,7 +1121,7 @@ class TopicUserContextImpl implements TopicContext
if (!(bozo_uids.contains(uid_key))) if (!(bozo_uids.contains(uid_key)))
{ // add them to the bozo list { // add them to the bozo list
sql = new StringBuffer("INSERT INTO topicbozo (topicid, uid, bozo_uid) VALUES ("); sql = new StringBuffer("INSERT INTO topicbozo (topicid, uid, bozo_uid) VALUES (");
sql.append(topicid).append(", ").append(conf.realUID()).append(", ").append(other_uid).append(");"); sql.append(topicid).append(", ").append(env.getUserID()).append(", ").append(other_uid).append(");");
stmt = conn.createStatement(); stmt = conn.createStatement();
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
bozo_uids.add(uid_key); bozo_uids.add(uid_key);
@ -1158,7 +1135,7 @@ class TopicUserContextImpl implements TopicContext
if (bozo_uids.contains(uid_key)) if (bozo_uids.contains(uid_key))
{ // remove them from the bozo list { // remove them from the bozo list
sql = new StringBuffer("DELETE FROM topicbozo WHERE topicid = "); sql = new StringBuffer("DELETE FROM topicbozo WHERE topicid = ");
sql.append(topicid).append(" AND uid = ").append(conf.realUID()).append(" AND bozo_uid = "); sql.append(topicid).append(" AND uid = ").append(env.getUserID()).append(" AND bozo_uid = ");
sql.append(other_uid).append(';'); sql.append(other_uid).append(';');
stmt = conn.createStatement(); stmt = conn.createStatement();
stmt.executeUpdate(sql.toString()); stmt.executeUpdate(sql.toString());
@ -1178,8 +1155,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1190,13 +1166,13 @@ class TopicUserContextImpl implements TopicContext
// 1. You can't set bozo filters on a deleted topic. // 1. You can't set bozo filters on a deleted topic.
// 2. You can't set bozo filters if you're the anonymous user. // 2. You can't set bozo filters if you're the anonymous user.
// 3. You can't bozo-filter yourself, silly. // 3. You can't bozo-filter yourself, silly.
return !(deleted || conf.userIsAnonymous() || (other_uid==conf.realUID())); return !(deleted || env.getUser().userIsAnonymous() || (other_uid==env.getUserID()));
} // end canSetBozoFilter } // end canSetBozoFilter
public List getBozos() throws DataException public List getBozos() throws DataException
{ {
if (deleted || conf.userIsAnonymous()) if (deleted || env.getUser().userIsAnonymous())
return Collections.EMPTY_LIST; // no-op return Collections.EMPTY_LIST; // no-op
if (bozo_uids==null) if (bozo_uids==null)
@ -1204,7 +1180,7 @@ class TopicUserContextImpl implements TopicContext
Connection conn = null; Connection conn = null;
try try
{ // load the bozo filter UIDs from the database { // load the bozo filter UIDs from the database
conn = datapool.getConnection(); conn = env.getConnection();
loadBozo(conn); loadBozo(conn);
} // end try } // end try
@ -1216,8 +1192,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1232,18 +1207,16 @@ class TopicUserContextImpl implements TopicContext
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
static List getTopicList(EngineBackend engine, ConferenceBackend conf, DataPool datapool, int get_option, static List getTopicList(EnvConference env, int get_option, int sort_option) throws DataException
int sort_option) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("getTopicList for conf # " + String.valueOf(conf.realConfID()) + ", user #" logger.debug("getTopicList for conf # " + env.getConfID() + ", user #" + env.getUserID());
+ String.valueOf(conf.realUID()));
ArrayList rc = new ArrayList(); // return from this function ArrayList rc = new ArrayList(); // return from this function
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// Figure out what the "where" clause of the SQL statement will be. This is in addition to a // Figure out what the "where" clause of the SQL statement will be. This is in addition to a
@ -1352,7 +1325,7 @@ class TopicUserContextImpl implements TopicContext
if (get_option==ConferenceContext.DISPLAY_ACTIVE) if (get_option==ConferenceContext.DISPLAY_ACTIVE)
sql.append(", SIGN(t.top_message - IFNULL(s.last_message,-1)) AS newflag"); sql.append(", SIGN(t.top_message - IFNULL(s.last_message,-1)) AS newflag");
sql.append(" FROM topics t LEFT JOIN topicsettings s ON t.topicid = s.topicid AND s.uid = "); sql.append(" FROM topics t LEFT JOIN topicsettings s ON t.topicid = s.topicid AND s.uid = ");
sql.append(conf.realUID()).append(" WHERE t.confid = ").append(conf.realConfID()); sql.append(env.getUserID()).append(" WHERE t.confid = ").append(env.getConfID());
if (where_clause!=null) if (where_clause!=null)
sql.append(" AND ").append(where_clause); sql.append(" AND ").append(where_clause);
sql.append(" ORDER BY "); sql.append(" ORDER BY ");
@ -1368,10 +1341,10 @@ class TopicUserContextImpl implements TopicContext
while (rs.next()) while (rs.next())
{ // create the returned objects and add them to the vector { // create the returned objects and add them to the vector
TopicContext top = TopicContext top =
new TopicUserContextImpl(engine,conf,datapool,rs.getInt(1),rs.getShort(2),rs.getInt(3), new TopicUserContextImpl(env,rs.getInt(1),rs.getShort(2),rs.getInt(3),rs.getInt(4),
rs.getInt(4),rs.getBoolean(5),rs.getBoolean(6), rs.getBoolean(5),rs.getBoolean(6),SQLUtil.getFullDateTime(rs,7),
SQLUtil.getFullDateTime(rs,7),SQLUtil.getFullDateTime(rs,8), SQLUtil.getFullDateTime(rs,8),rs.getString(9),rs.getBoolean(10),
rs.getString(9),rs.getBoolean(10),rs.getInt(11)); rs.getInt(11));
rc.add(top); rc.add(top);
} // end while } // end while
@ -1385,8 +1358,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1394,27 +1366,25 @@ class TopicUserContextImpl implements TopicContext
} // end getTopicList } // end getTopicList
static TopicContext getTopicByID(EngineBackend engine, ConferenceBackend conf, DataPool datapool, static TopicContext getTopicByID(EnvConference env, int topicid) throws DataException
int topicid) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("getTopicByID for topic # " + String.valueOf(topicid) + ", user #" logger.debug("getTopicByID for topic # " + topicid + ", user #" + env.getUserID());
+ String.valueOf(conf.realUID()));
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// Query the dtabase by topic ID. // Query the dtabase by topic ID.
ResultSet rs = queryByTopic(stmt,topicid,conf.realUID()); ResultSet rs = queryByTopic(stmt,topicid,env.getUserID());
if (rs.next()) // found it! if (rs.next()) // found it!
return new TopicUserContextImpl(engine,conf,datapool,topicid,rs.getShort(2),rs.getInt(3), return new TopicUserContextImpl(env,topicid,rs.getShort(2),rs.getInt(3),rs.getInt(4),rs.getBoolean(5),
rs.getInt(4),rs.getBoolean(5),rs.getBoolean(6), rs.getBoolean(6),SQLUtil.getFullDateTime(rs,7),
SQLUtil.getFullDateTime(rs,7),SQLUtil.getFullDateTime(rs,8), SQLUtil.getFullDateTime(rs,8),rs.getString(9),rs.getBoolean(10),
rs.getString(9),rs.getBoolean(10),rs.getInt(11)); rs.getInt(11));
// else fall out and return null // else fall out and return null
} // end try } // end try
@ -1426,8 +1396,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1435,18 +1404,17 @@ class TopicUserContextImpl implements TopicContext
} // end getTopicByID } // end getTopicByID
static TopicContext getTopicByNumber(EngineBackend engine, ConferenceBackend conf, DataPool datapool, static TopicContext getTopicByNumber(EnvConference env, short topicnum) throws DataException
short topicnum) throws DataException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("getTopicByNumber for topic # " + String.valueOf(topicnum) + ", conf # " logger.debug("getTopicByNumber for topic # " + topicnum + ", conf # " + env.getConfID() + ", user #"
+ String.valueOf(conf.realConfID()) + ", user #" + String.valueOf(conf.realUID())); + env.getUserID());
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// Build the database query. // Build the database query.
@ -1455,7 +1423,7 @@ class TopicUserContextImpl implements TopicContext
+ "t.createdate, t.lastupdate, t.name, IFNULL(s.hidden,0) AS hidden, " + "t.createdate, t.lastupdate, t.name, IFNULL(s.hidden,0) AS hidden, "
+ "(t.top_message - IFNULL(s.last_message,-1)) AS unread FROM topics t " + "(t.top_message - IFNULL(s.last_message,-1)) AS unread FROM topics t "
+ "LEFT JOIN topicsettings s ON t.topicid = s.topicid AND s.uid = "); + "LEFT JOIN topicsettings s ON t.topicid = s.topicid AND s.uid = ");
sql.append(conf.realUID()).append(" WHERE t.confid = ").append(conf.realConfID()); sql.append(env.getUserID()).append(" WHERE t.confid = ").append(env.getConfID());
sql.append(" AND t.num = ").append(topicnum).append(';'); sql.append(" AND t.num = ").append(topicnum).append(';');
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString()); logger.debug("SQL: " + sql.toString());
@ -1463,10 +1431,10 @@ class TopicUserContextImpl implements TopicContext
// Now pass this query off to the database! // Now pass this query off to the database!
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
if (rs.next()) // found it! if (rs.next()) // found it!
return new TopicUserContextImpl(engine,conf,datapool,rs.getInt(1),topicnum,rs.getInt(3), return new TopicUserContextImpl(env,rs.getInt(1),topicnum,rs.getInt(3),rs.getInt(4),rs.getBoolean(5),
rs.getInt(4),rs.getBoolean(5),rs.getBoolean(6), rs.getBoolean(6),SQLUtil.getFullDateTime(rs,7),
SQLUtil.getFullDateTime(rs,7),SQLUtil.getFullDateTime(rs,8), SQLUtil.getFullDateTime(rs,8),rs.getString(9),rs.getBoolean(10),
rs.getString(9),rs.getBoolean(10),rs.getInt(11)); rs.getInt(11));
// else fall out and return null // else fall out and return null
} // end try } // end try
@ -1478,8 +1446,7 @@ class TopicUserContextImpl implements TopicContext
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -23,6 +23,7 @@ import org.apache.log4j.*;
import com.silverwrist.util.*; import com.silverwrist.util.*;
import com.silverwrist.venice.*; import com.silverwrist.venice.*;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.security.PasswordHash; import com.silverwrist.venice.security.PasswordHash;
import com.silverwrist.venice.security.Capability; import com.silverwrist.venice.security.Capability;
@ -54,8 +55,7 @@ class UserContextImpl implements UserContext, UserBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; // the back end of the engine private EnvUser env; // the environment store
private DataPool datapool; // the data pool used by this object
private String remote_addr; // remote address identifier private String remote_addr; // remote address identifier
private int uid = -1; // the user ID we're using private int uid = -1; // the user ID we're using
private int contactid; // ID of our contact information private int contactid; // ID of our contact information
@ -80,10 +80,9 @@ class UserContextImpl implements UserContext, UserBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
UserContextImpl(EngineBackend engine, DataPool datapool) UserContextImpl(EnvEngine env)
{ {
this.engine = engine; this.env = new EnvUser(env,this);
this.datapool = datapool;
} // end constructor } // end constructor
@ -131,7 +130,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // call through to lower level function { // call through to lower level function
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM userprefs WHERE uid = " + uid + ";"); ResultSet rs = stmt.executeQuery("SELECT * FROM userprefs WHERE uid = " + uid + ";");
@ -170,8 +169,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection { // make sure we release the connection
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -183,7 +181,7 @@ class UserContextImpl implements UserContext, UserBackend
logger.debug("sendEmailConfirmation(): sending to \"" + my_email + "\""); logger.debug("sendEmailConfirmation(): sending to \"" + my_email + "\"");
// Create the message to be sent. // Create the message to be sent.
String message = engine.getStockMessage("email-confirm"); String message = env.getEngine().getStockMessage("email-confirm");
if (message==null) if (message==null)
{ // no message defined? oy! { // no message defined? oy!
logger.error("internal error condition: email-confirm stock message not defined"); logger.error("internal error condition: email-confirm stock message not defined");
@ -197,12 +195,12 @@ class UserContextImpl implements UserContext, UserBackend
vars.put("confnum",String.valueOf(confirm_num)); vars.put("confnum",String.valueOf(confirm_num));
message = StringUtil.replaceAllVariables(message,vars); message = StringUtil.replaceAllVariables(message,vars);
String subject = engine.getStockMessage("email-confirm-subject"); String subject = env.getEngine().getStockMessage("email-confirm-subject");
if (subject==null) if (subject==null)
subject = "Venice Email Confirmation"; subject = "Venice Email Confirmation";
// Create the emailer and send the message. // Create the emailer and send the message.
SimpleEmailer emailer = engine.createEmailer(); Emailer emailer = env.getEngine().createEmailer();
emailer.setTo(my_email); emailer.setTo(my_email);
emailer.setSubject(subject); emailer.setSubject(subject);
emailer.setText(message); emailer.setText(message);
@ -276,7 +274,7 @@ class UserContextImpl implements UserContext, UserBackend
Connection conn = null; Connection conn = null;
try try
{ // get a connection and create a statement { // get a connection and create a statement
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
@ -298,8 +296,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -390,7 +387,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // look for a user name matching this user record { // look for a user name matching this user record
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE username = '" ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE username = '"
+ SQLUtil.encodeString(username) + "';"); + SQLUtil.encodeString(username) + "';");
@ -474,8 +471,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end if } // end if
@ -499,7 +495,7 @@ class UserContextImpl implements UserContext, UserBackend
{ // the confirmation number is wrong { // the confirmation number is wrong
logger.warn("...confirmation number incorrect"); logger.warn("...confirmation number incorrect");
ar = new AuditRecord(AuditRecord.VERIFY_FAIL,uid,remote_addr,"Invalid confirmation number"); ar = new AuditRecord(AuditRecord.VERIFY_FAIL,uid,remote_addr,"Invalid confirmation number");
engine.saveAuditRecord(ar); env.getEngine().saveAuditRecord(ar);
throw new AccessError("Confirmation number is incorrect. Please try again."); throw new AccessError("Confirmation number is incorrect. Please try again.");
} // end if } // end if
@ -508,7 +504,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // get a connection and set the user's status to reflect the verification { // get a connection and set the user's status to reflect the verification
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = 1, base_lvl = "); StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = 1, base_lvl = ");
sql.append(DefaultLevels.afterEmailVerification()).append(" WHERE uid = ").append(uid).append(';'); sql.append(DefaultLevels.afterEmailVerification()).append(" WHERE uid = ").append(uid).append(';');
@ -543,8 +539,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end if } // end if
@ -569,11 +564,11 @@ class UserContextImpl implements UserContext, UserBackend
AuditRecord ar = null; AuditRecord ar = null;
try try
{ // need to change the user's email confirmation number first { // need to change the user's email confirmation number first
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// generate new confirmation number // generate new confirmation number
int new_confirm_num = engine.getNewConfirmationNumber(); int new_confirm_num = env.getEngine().getNewConfirmationNumber();
// create an SQL statement to reset the user account information, and execute it // create an SQL statement to reset the user account information, and execute it
StringBuffer sql = new StringBuffer("UPDATE users SET email_confnum = "); StringBuffer sql = new StringBuffer("UPDATE users SET email_confnum = ");
@ -609,8 +604,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end if } // end if
@ -623,7 +617,7 @@ class UserContextImpl implements UserContext, UserBackend
ContactInfoImpl rc; ContactInfoImpl rc;
if (contactid>=0) if (contactid>=0)
rc = new ContactInfoImpl(datapool,contactid); rc = new ContactInfoImpl(env,contactid);
else else
rc = new ContactInfoImpl(uid); rc = new ContactInfoImpl(uid);
if (my_email==null) if (my_email==null)
@ -662,7 +656,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Stashable obj = (Stashable)ci; Stashable obj = (Stashable)ci;
// save the contact information // save the contact information
@ -694,7 +688,7 @@ class UserContextImpl implements UserContext, UserBackend
logger.debug("email address changed, need to reconfirm"); logger.debug("email address changed, need to reconfirm");
// generate new confirmation number // generate new confirmation number
int new_confirm_num = engine.getNewConfirmationNumber(); int new_confirm_num = env.getEngine().getNewConfirmationNumber();
// create an SQL statement to reset the user account information, and execute it // create an SQL statement to reset the user account information, and execute it
StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = 0, email_confnum = "); StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = 0, email_confnum = ");
@ -744,8 +738,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end if } // end if
@ -761,8 +754,8 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
UserProfileImpl prof = new UserProfileImpl(engine,this,conn,xusername, UserProfileImpl prof = new UserProfileImpl(env,conn,xusername,
Capability.canSeeHiddenContactFields(level)); Capability.canSeeHiddenContactFields(level));
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("...found it!"); logger.debug("...found it!");
@ -777,8 +770,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -792,8 +784,8 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
UserProfileImpl prof = new UserProfileImpl(engine,this,conn,xuid, UserProfileImpl prof = new UserProfileImpl(env,conn,xuid,
Capability.canSeeHiddenContactFields(level)); Capability.canSeeHiddenContactFields(level));
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("...found it!"); logger.debug("...found it!");
@ -808,8 +800,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -829,7 +820,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
PasswordHash phash = new PasswordHash(password); PasswordHash phash = new PasswordHash(password);
StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '"); StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '");
@ -861,8 +852,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -881,7 +871,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE users SET description = '"); StringBuffer sql = new StringBuffer("UPDATE users SET description = '");
sql.append(SQLUtil.encodeString(new_descr)).append("' WHERE uid = ").append(uid).append(';'); sql.append(SQLUtil.encodeString(new_descr)).append("' WHERE uid = ").append(uid).append(';');
@ -898,8 +888,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -907,75 +896,74 @@ class UserContextImpl implements UserContext, UserBackend
public List getMemberCommunities() throws DataException public List getMemberCommunities() throws DataException
{ {
return CommunityUserContextImpl.getMemberCommunityEntries(engine,this,datapool); return CommunityUserContextImpl.getMemberCommunityEntries(env);
} // end getMemberCommunities } // end getMemberCommunities
public CommunityContext getCommunityContext(int cid) throws DataException public CommunityContext getCommunityContext(int cid) throws DataException
{ {
return CommunityUserContextImpl.getCommunityContext(engine,this,datapool,cid); return CommunityUserContextImpl.getCommunityContext(env,cid);
} // end getCommunityContext } // end getCommunityContext
public CommunityContext getCommunityContext(String alias) throws DataException public CommunityContext getCommunityContext(String alias) throws DataException
{ {
return CommunityUserContextImpl.getCommunityContext(engine,this,datapool,alias); return CommunityUserContextImpl.getCommunityContext(env,alias);
} // end getCommunityContext } // end getCommunityContext
public List getRootCategoryList() throws DataException public List getRootCategoryList() throws DataException
{ {
return CategoryDescriptorImpl.getTopLevelCategoryList(datapool,Capability.hideHiddenCategories(level)); return CategoryDescriptorImpl.getTopLevelCategoryList(env,Capability.hideHiddenCategories(level));
} // end getRootCategoryList } // end getRootCategoryList
public CategoryDescriptor getCategoryDescriptor(int catid) throws DataException public CategoryDescriptor getCategoryDescriptor(int catid) throws DataException
{ {
return new CategoryDescriptorImpl(datapool,catid,Capability.hideHiddenCategories(level)); return new CategoryDescriptorImpl(env,catid,Capability.hideHiddenCategories(level));
} // end getCategoryDescriptor } // end getCategoryDescriptor
public List searchForCommunities(int field, int mode, String term, int offset, int count) public List searchForCommunities(int field, int mode, String term, int offset, int count)
throws DataException throws DataException
{ {
return CommunityUserContextImpl.searchForCommunities(engine,this,datapool,field,mode,term,offset,count); return CommunityUserContextImpl.searchForCommunities(env,field,mode,term,offset,count);
} // end searchForCommunities } // end searchForCommunities
public int getSearchCommunityCount(int field, int mode, String term) throws DataException public int getSearchCommunityCount(int field, int mode, String term) throws DataException
{ {
return CommunityUserContextImpl.getSearchCommunityCount(this,datapool,field,mode,term); return CommunityUserContextImpl.getSearchCommunityCount(env,field,mode,term);
} // end getSearchCommunityCount } // end getSearchCommunityCount
public List getCommunitiesInCategory(int catid, int offset, int count) throws DataException public List getCommunitiesInCategory(int catid, int offset, int count) throws DataException
{ {
return CommunityUserContextImpl.getCommunitiesInCategory(engine,this,datapool,catid,offset,count); return CommunityUserContextImpl.getCommunitiesInCategory(env,catid,offset,count);
} // end getCommunitiesInCategory } // end getCommunitiesInCategory
public List getCommunitiesInCategory(CategoryDescriptor cat, int offset, int count) throws DataException public List getCommunitiesInCategory(CategoryDescriptor cat, int offset, int count) throws DataException
{ {
return CommunityUserContextImpl.getCommunitiesInCategory(engine,this,datapool,cat.getLinkedCategoryID(), return CommunityUserContextImpl.getCommunitiesInCategory(env,cat.getLinkedCategoryID(),offset,count);
offset,count);
} // end getCommunitiesInCategory } // end getCommunitiesInCategory
public int getNumCommunitiesInCategory(int catid) throws DataException public int getNumCommunitiesInCategory(int catid) throws DataException
{ {
return CommunityUserContextImpl.getNumCommunitiesInCategory(this,datapool,catid); return CommunityUserContextImpl.getNumCommunitiesInCategory(env,catid);
} // end getNumCommunitiessInCategory } // end getNumCommunitiessInCategory
public int getNumCommunitiesInCategory(CategoryDescriptor cat) throws DataException public int getNumCommunitiesInCategory(CategoryDescriptor cat) throws DataException
{ {
return CommunityUserContextImpl.getNumCommunitiesInCategory(this,datapool,cat.getLinkedCategoryID()); return CommunityUserContextImpl.getNumCommunitiesInCategory(env,cat.getLinkedCategoryID());
} // end getNumCommunitiesInCategory } // end getNumCommunitiesInCategory
public List searchForCategories(int mode, String term, int offset, int count) throws DataException public List searchForCategories(int mode, String term, int offset, int count) throws DataException
{ {
return CategoryDescriptorImpl.searchForCategories(datapool,Capability.hideHiddenCategories(level), return CategoryDescriptorImpl.searchForCategories(env,Capability.hideHiddenCategories(level),
Capability.showHiddenSearchCategories(level),mode, Capability.showHiddenSearchCategories(level),mode,
term,offset,count); term,offset,count);
@ -983,7 +971,7 @@ class UserContextImpl implements UserContext, UserBackend
public int getSearchCategoryCount(int mode, String term) throws DataException public int getSearchCategoryCount(int mode, String term) throws DataException
{ {
return CategoryDescriptorImpl.getSearchCategoryCount(datapool,Capability.hideHiddenCategories(level), return CategoryDescriptorImpl.getSearchCategoryCount(env,Capability.hideHiddenCategories(level),
Capability.showHiddenSearchCategories(level), Capability.showHiddenSearchCategories(level),
mode,term); mode,term);
@ -1001,11 +989,11 @@ class UserContextImpl implements UserContext, UserBackend
boolean hide_search = (hide_mode==CommunityContext.HIDE_BOTH); boolean hide_search = (hide_mode==CommunityContext.HIDE_BOTH);
// Create the new community's database entries and internal data. // Create the new community's database entries and internal data.
CommunityData new_comm = CommunityCoreData.createCommunity(engine,this,datapool,name,alias,uid,language, CommunityData new_comm = CommunityCoreData.createCommunity(env,name,alias,uid,language,synopsis,rules,
synopsis,rules,joinkey,hide_dir,hide_search); joinkey,hide_dir,hide_search);
// Create the community context we return to the user. // Create the community context we return to the user.
CommunityContext rc = new CommunityUserContextImpl(engine,this,datapool,new_comm); CommunityContext rc = new CommunityUserContextImpl(env,new_comm);
// And that's it! You expected lightning bolts maybe? :-) // And that's it! You expected lightning bolts maybe? :-)
@ -1015,7 +1003,7 @@ class UserContextImpl implements UserContext, UserBackend
public boolean canCreateCommunity() public boolean canCreateCommunity()
{ {
return (level>=engine.getParamInt(EngineBackend.IP_CREATECOMMUNITYLVL)); return (level>=env.getEngine().getParamInt(EngineBackend.IP_CREATECOMMUNITYLVL));
} // end canCreateCommunity } // end canCreateCommunity
@ -1026,7 +1014,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// retrieve the necessary rows from the sideboxes table // retrieve the necessary rows from the sideboxes table
@ -1034,8 +1022,9 @@ class UserContextImpl implements UserContext, UserBackend
+ " ORDER BY sequence;"); + " ORDER BY sequence;");
while (rs.next()) while (rs.next())
{ // create the implementation objects and return them all { // create the implementation objects and return them all
SideBoxDescriptor sbd = new SideBoxDescriptorImpl(uid,engine.getMasterSideBoxDescriptor(rs.getInt(1)), SideBoxDescriptor sbd =
datapool,rs.getInt(2)); new SideBoxDescriptorImpl(env,env.getEngine().getMasterSideBoxDescriptor(rs.getInt(1)),
rs.getInt(2));
rc.add(sbd); rc.add(sbd);
} // end while } // end while
@ -1049,8 +1038,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1060,14 +1048,14 @@ class UserContextImpl implements UserContext, UserBackend
public void addSideBox(int id) throws DataException public void addSideBox(int id) throws DataException
{ {
if (engine.getMasterSideBoxDescriptor(id)==null) if (env.getEngine().getMasterSideBoxDescriptor(id)==null)
throw new DataException("invalid sidebox ID: " + id); throw new DataException("invalid sidebox ID: " + id);
Connection conn = null; Connection conn = null;
try try
{ // retrieve a connection from the datapool { // retrieve a connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
stmt.executeUpdate("LOCK TABLES sideboxes WRITE;"); stmt.executeUpdate("LOCK TABLES sideboxes WRITE;");
@ -1110,8 +1098,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1119,7 +1106,7 @@ class UserContextImpl implements UserContext, UserBackend
public List getConferenceHotlist() throws DataException public List getConferenceHotlist() throws DataException
{ {
return ConferenceUserContextImpl.getUserHotlist(engine,this,datapool); return ConferenceUserContextImpl.getUserHotlist(env);
} // end getConferenceHotlist } // end getConferenceHotlist
@ -1139,7 +1126,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end if } // end if
// create the return object // create the return object
return new AdminOperationsImpl(engine,this,datapool); return new AdminOperationsImpl(env);
} // end getAdminInterface } // end getAdminInterface
@ -1158,7 +1145,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the update statement // create the update statement
@ -1180,8 +1167,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1202,7 +1188,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create the update statement // create the update statement
@ -1224,8 +1210,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1241,12 +1226,12 @@ class UserContextImpl implements UserContext, UserBackend
} // end if } // end if
// Generate a random authentication string and poke it into the database for this user. // Generate a random authentication string and poke it into the database for this user.
String tokenauth = engine.generateRandomAuthString(); String tokenauth = env.getEngine().generateRandomAuthString();
Connection conn = null; Connection conn = null;
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE users SET tokenauth = '"); StringBuffer sql = new StringBuffer("UPDATE users SET tokenauth = '");
sql.append(tokenauth).append("' WHERE uid = ").append(uid).append(';'); sql.append(tokenauth).append("' WHERE uid = ").append(uid).append(';');
@ -1261,8 +1246,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1327,7 +1311,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end if } // end if
String pending_auth = token.substring(xstart,xend); String pending_auth = token.substring(xstart,xend);
if (!(engine.isValidRandomAuthString(pending_auth))) if (!(env.getEngine().isValidRandomAuthString(pending_auth)))
{ // the auth string is not valid by the rules under which it was generated { // the auth string is not valid by the rules under which it was generated
logger.error("Token parse error: invalid auth string value"); logger.error("Token parse error: invalid auth string value");
return false; return false;
@ -1373,7 +1357,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // look for a user record matching this user ID { // look for a user record matching this user ID
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE uid = " + pending_uid + ";"); ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE uid = " + pending_uid + ";");
@ -1451,8 +1435,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end if } // end if
@ -1463,7 +1446,7 @@ class UserContextImpl implements UserContext, UserBackend
public Advertisement selectAd() public Advertisement selectAd()
{ {
// just get a random ad for now // just get a random ad for now
return AdvertisementImpl.getRandomAd(datapool); return AdvertisementImpl.getRandomAd(env);
} // end selectAd } // end selectAd
@ -1589,7 +1572,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE is_anon = 1;"); ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE is_anon = 1;");
if (!(rs.next())) if (!(rs.next()))
@ -1612,8 +1595,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1643,7 +1625,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // get a database connection and call the internal function { // get a database connection and call the internal function
conn = datapool.getConnection(); conn = env.getConnection();
autoJoinCommunities(conn); autoJoinCommunities(conn);
} // end try } // end try
@ -1655,8 +1637,7 @@ class UserContextImpl implements UserContext, UserBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally

View File

@ -22,6 +22,7 @@ import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.util.*; import com.silverwrist.util.*;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
class UserProfileImpl implements UserProfile class UserProfileImpl implements UserProfile
@ -31,15 +32,14 @@ class UserProfileImpl implements UserProfile
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private static Category logger = Category.getInstance(UserProfileImpl.class.getName()); private static Category logger = Category.getInstance(UserProfileImpl.class);
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Attributes * Attributes
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private EngineBackend engine; // the engine back end private EnvUser env; // the user environment
private UserBackend user; // the user that generated this profile
private int uid; // user ID private int uid; // user ID
private String username; // user name private String username; // user name
private String given_name; // given name ("first name") private String given_name; // given name ("first name")
@ -72,13 +72,12 @@ class UserProfileImpl implements UserProfile
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
UserProfileImpl(EngineBackend engine, UserBackend user, Connection conn, String username, boolean override) UserProfileImpl(EnvUser env, Connection conn, String username, boolean override)
throws DataException, SQLException throws DataException, SQLException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("load UserProfileImpl by name: " + username + " (" + override + ")"); logger.debug("load UserProfileImpl by name: " + username + " (" + override + ")");
this.engine = engine; this.env = env;
this.user = user;
// first retrieve from the users table // first retrieve from the users table
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -106,13 +105,12 @@ class UserProfileImpl implements UserProfile
} // end constructor } // end constructor
UserProfileImpl(EngineBackend engine, UserBackend user, Connection conn, int uid, boolean override) UserProfileImpl(EnvUser env, Connection conn, int uid, boolean override)
throws DataException, SQLException throws DataException, SQLException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("load UserProfileImpl by UID: " + uid + " (" + override + ")"); logger.debug("load UserProfileImpl by UID: " + uid + " (" + override + ")");
this.engine = engine; this.env = env;
this.user = user;
// first retrieve from the users table // first retrieve from the users table
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -157,7 +155,7 @@ class UserProfileImpl implements UserProfile
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
if (rs.next()) if (rs.next())
{ // load all the record data { // load all the record data
boolean me_anon = user.userIsAnonymous(); boolean me_anon = env.getUser().userIsAnonymous();
given_name = rs.getString("given_name"); given_name = rs.getString("given_name");
family_name = rs.getString("family_name"); family_name = rs.getString("family_name");
String blort = rs.getString("middle_init"); String blort = rs.getString("middle_init");
@ -405,16 +403,16 @@ class UserProfileImpl implements UserProfile
public boolean canSendQuickEmail() public boolean canSendQuickEmail()
{ {
return !is_anon && !(user.userIsAnonymous()); return !is_anon && !(env.getUser().userIsAnonymous());
} // end canSendQuickEmail } // end canSendQuickEmail
public void sendQuickEmail(String subject, String text) throws AccessError, DataException, EmailException public void sendQuickEmail(String subject, String text) throws AccessError, DataException, EmailException
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Send Quick E-Mail (from uid " + user.realUID() + " to uid " + uid + ")"); logger.debug("Send Quick E-Mail (from uid " + env.getUserID() + " to uid " + uid + ")");
if (user.userIsAnonymous()) if (env.getUser().userIsAnonymous())
{ // we can't send quick emails if we're anonymous! { // we can't send quick emails if we're anonymous!
logger.error("sending user is not logged in."); logger.error("sending user is not logged in.");
throw new AccessError("You must be logged in to send a quick E-mail message."); throw new AccessError("You must be logged in to send a quick E-mail message.");
@ -430,11 +428,11 @@ class UserProfileImpl implements UserProfile
// assemble the full text // assemble the full text
StringBuffer text_buf = new StringBuffer(text); StringBuffer text_buf = new StringBuffer(text);
text_buf.append("\n\n--\n").append(engine.getStockMessage("signature")); text_buf.append("\n\n--\n").append(env.getEngine().getStockMessage("signature"));
// create the emailer object, fill it in, and send it // create the emailer object, fill it in, and send it
SimpleEmailer em = engine.createEmailer(); Emailer em = env.getEngine().createEmailer();
em.setFrom(user.realUserName(),user.realEmailAddress()); em.setFrom(env.getUser().realUserName(),env.getUser().realEmailAddress());
em.setTo(real_email); em.setTo(real_email);
em.setSubject(subject); em.setSubject(subject);
em.setText(text_buf.toString()); em.setText(text_buf.toString());

View File

@ -25,6 +25,7 @@ import org.w3c.dom.*;
import com.silverwrist.util.*; import com.silverwrist.util.*;
import com.silverwrist.util.cache.*; import com.silverwrist.util.cache.*;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.core.internals.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.htmlcheck.*; import com.silverwrist.venice.htmlcheck.*;
import com.silverwrist.venice.htmlcheck.dict.*; import com.silverwrist.venice.htmlcheck.dict.*;
@ -264,7 +265,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
Integer xcid = (Integer)key; Integer xcid = (Integer)key;
try try
{ // create the desired object { // create the desired object
return new CommunityCoreData(VeniceEngineImpl.this,datapool,xcid.intValue()); return new CommunityCoreData(env,xcid.intValue());
} // end try } // end try
catch (DataException e) catch (DataException e)
@ -293,7 +294,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
Integer xconf = (Integer)key; Integer xconf = (Integer)key;
try try
{ // create the desired object { // create the desired object
return new ConferenceCoreData(VeniceEngineImpl.this,datapool,xconf.intValue()); return new ConferenceCoreData(env,xconf.intValue());
} // end try } // end try
catch (DataException e) catch (DataException e)
@ -392,7 +393,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
*/ */
private Document config = null; // configuration data private Document config = null; // configuration data
private DataPool datapool = null; // database connection pool private EnvEngine env = null; // my environment
private Random rng; // random number generator private Random rng; // random number generator
private Properties email_props = null; // email properties private Properties email_props = null; // email properties
private javax.mail.Session mailsession = null; // email session object private javax.mail.Session mailsession = null; // email session object
@ -479,7 +480,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
Connection conn = null; Connection conn = null;
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
@ -529,8 +530,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -651,6 +651,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
this.config = config; this.config = config;
DataPool datapool = null;
ArrayList dictionary_tmp; ArrayList dictionary_tmp;
try try
{ // first, verify that this is a valid configuration { // first, verify that this is a valid configuration
@ -847,11 +848,15 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
catch (ConfigException ce) catch (ConfigException ce)
{ // before we leave on a ConfigException, nuke the important data { // before we leave on a ConfigException, nuke the important data
this.config = null; this.config = null;
datapool = null; if (datapool!=null)
datapool.closeAllConnections();
throw ce; throw ce;
} // end catch } // end catch
// Initialize the environment.
env = new EnvEngine(this,datapool);
for (i=0; i<sideboxes.length; i++) // insert sideboxes into hashtable for (i=0; i<sideboxes.length; i++) // insert sideboxes into hashtable
sidebox_ids.put(new Integer(sideboxes[i].getID()),sideboxes[i]); sidebox_ids.put(new Integer(sideboxes[i].getID()),sideboxes[i]);
@ -862,7 +867,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
Connection conn = null; Connection conn = null;
try try
{ // get a connection from the data pool { // get a connection from the data pool
conn = datapool.getConnection(); conn = env.getConnection();
// load the master feature table // load the master feature table
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
@ -896,8 +901,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -911,8 +915,8 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
SQLEncodingFilter sql_filter = new SQLEncodingFilter(); SQLEncodingFilter sql_filter = new SQLEncodingFilter();
SpellingRewriter spell_rewriter = new SpellingRewriter(); SpellingRewriter spell_rewriter = new SpellingRewriter();
URLRewriter url_rewriter = new URLRewriter(); URLRewriter url_rewriter = new URLRewriter();
PostLinkRewriter postlink_rewriter = new PostLinkRewriter(datapool); PostLinkRewriter postlink_rewriter = new PostLinkRewriter(env.getDataPool());
UserNameRewriter username_rewriter = new UserNameRewriter(datapool); UserNameRewriter username_rewriter = new UserNameRewriter(env.getDataPool());
// Create the LazyLexicon that holds our dictionary files, and add it to the SpellingRewriter. // Create the LazyLexicon that holds our dictionary files, and add it to the SpellingRewriter.
LazyTreeLexicon lex = new LazyTreeLexicon((String[])(dictionary_tmp.toArray(new String[0]))); LazyTreeLexicon lex = new LazyTreeLexicon((String[])(dictionary_tmp.toArray(new String[0])));
@ -1005,7 +1009,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
public UserContext createUserContext(String remote_addr) throws DataException public UserContext createUserContext(String remote_addr) throws DataException
{ {
checkInitialized(); checkInitialized();
UserContextImpl uci = new UserContextImpl(this,datapool); UserContextImpl uci = new UserContextImpl(env);
uci.loadAnonymous(remote_addr); uci.loadAnonymous(remote_addr);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("createUserContext(): context loaded :-)"); logger.debug("createUserContext(): context loaded :-)");
@ -1020,7 +1024,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
try try
{ // look for a user name matching this user record { // look for a user name matching this user record
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT c.email FROM users u, contacts c WHERE u.contactid = " ResultSet rs = stmt.executeQuery("SELECT c.email FROM users u, contacts c WHERE u.contactid = "
+ "c.contactid AND u.username = '" + SQLUtil.encodeString(username) + "c.contactid AND u.username = '" + SQLUtil.encodeString(username)
@ -1047,8 +1051,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1061,7 +1064,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
try try
{ // look for a user name matching this user record { // look for a user name matching this user record
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT c.email, u.uid, u.passreminder FROM users u, contacts c " StringBuffer sql = new StringBuffer("SELECT c.email, u.uid, u.passreminder FROM users u, contacts c "
+ "WHERE u.contactid = c.contactid AND u.username = '"); + "WHERE u.contactid = c.contactid AND u.username = '");
@ -1106,7 +1109,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
subject = "Venice Password Reminder Message"; subject = "Venice Password Reminder Message";
// Create the emailer and send the message. // Create the emailer and send the message.
SimpleEmailer emailer = createEmailer(); Emailer emailer = createEmailer();
emailer.setTo(email_addr); emailer.setTo(email_addr);
emailer.setSubject(subject); emailer.setSubject(subject);
emailer.setText(message); emailer.setText(message);
@ -1123,8 +1126,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1159,7 +1161,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
Connection conn = null; Connection conn = null;
try try
{ // perform the database update { // perform the database update
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '"); StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '");
sql.append(phash.toString()).append("' WHERE uid = ").append(uid).append(';'); sql.append(phash.toString()).append("' WHERE uid = ").append(uid).append(';');
@ -1174,8 +1176,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1200,7 +1201,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
subject = "Venice Password Changed"; subject = "Venice Password Changed";
// Create the emailer and send the message. // Create the emailer and send the message.
SimpleEmailer emailer = createEmailer(); Emailer emailer = createEmailer();
emailer.setTo(pcr.getEmail()); emailer.setTo(pcr.getEmail());
emailer.setSubject(subject); emailer.setSubject(subject);
emailer.setText(message); emailer.setText(message);
@ -1227,7 +1228,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
try try
{ // look to see if the user name is already present { // look to see if the user name is already present
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
stmt.executeUpdate("LOCK TABLES users WRITE, userprefs WRITE, propuser WRITE, sigmember WRITE, " stmt.executeUpdate("LOCK TABLES users WRITE, userprefs WRITE, propuser WRITE, sigmember WRITE, "
+ "sideboxes WRITE, confhotlist WRITE;"); + "sideboxes WRITE, confhotlist WRITE;");
@ -1380,13 +1381,12 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
// create a new context for the user (they're now effectively logged in) // create a new context for the user (they're now effectively logged in)
UserContextImpl rc = new UserContextImpl(this,datapool); UserContextImpl rc = new UserContextImpl(env);
rc.loadNewUser(remote_addr,new_uid,DefaultLevels.newUser(),username,confirm_num,created,created); rc.loadNewUser(remote_addr,new_uid,DefaultLevels.newUser(),username,confirm_num,created,created);
rc.autoJoinCommunities(); // EJB 4/14/2001 rc.autoJoinCommunities(); // EJB 4/14/2001
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
@ -1402,7 +1402,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
try try
{ // do a SELECT on the sigs table { // do a SELECT on the sigs table
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT sigid FROM sigs WHERE alias = '"); StringBuffer sql = new StringBuffer("SELECT sigid FROM sigs WHERE alias = '");
sql.append(alias).append("'"); sql.append(alias).append("'");
@ -1420,8 +1420,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1438,7 +1437,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
try try
{ // do a SELECT on the category table { // do a SELECT on the category table
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT catid FROM refcategory WHERE catid = "); StringBuffer sql = new StringBuffer("SELECT catid FROM refcategory WHERE catid = ");
sql.append(catid).append(';'); sql.append(catid).append(';');
@ -1453,8 +1452,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1473,7 +1471,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT u.uid, u.username, u.description, c.given_name, " StringBuffer sql = new StringBuffer("SELECT u.uid, u.username, u.description, c.given_name, "
+ "c.family_name, c.locality, c.region, c.country FROM users u, " + "c.family_name, c.locality, c.region, c.country FROM users u, "
@ -1547,8 +1545,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1565,7 +1562,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM users u, contacts c WHERE u.contactid = " StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM users u, contacts c WHERE u.contactid = "
+ "c.contactid AND "); + "c.contactid AND ");
@ -1635,8 +1632,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1654,7 +1650,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
try try
{ // get a database connection { // get a database connection
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
// create and execute the right SQL statement // create and execute the right SQL statement
@ -1671,8 +1667,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure we release the connection before we go { // make sure we release the connection before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1687,7 +1682,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
try try
{ // do a SELECT on the confalias table { // do a SELECT on the confalias table
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT confid FROM confalias WHERE alias = '"); StringBuffer sql = new StringBuffer("SELECT confid FROM confalias WHERE alias = '");
sql.append(alias).append("';"); sql.append(alias).append("';");
@ -1702,8 +1697,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -1768,14 +1762,13 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
// If the cache list contains too few items, backfill it from the database. // If the cache list contains too few items, backfill it from the database.
if (cache_fp_posts.size()<gp_ints[IP_NUMFRONTPAGEPOSTS]) if (cache_fp_posts.size()<gp_ints[IP_NUMFRONTPAGEPOSTS])
PublishedMessageImpl.backfillCache(cache_fp_posts,gp_ints[IP_NUMFRONTPAGEPOSTS],datapool); PublishedMessageImpl.backfillCache(cache_fp_posts,gp_ints[IP_NUMFRONTPAGEPOSTS],env);
// Copy the contents to the return vector, casting them to TopicMessageContext. // Copy the contents to the return vector.
Iterator it = cache_fp_posts.iterator(); Iterator it = cache_fp_posts.iterator();
while (it.hasNext()) while (it.hasNext())
{ // cast each element and add the casted object to the output { // cast each element and add the casted object to the output
PublishedMessageImpl pmi = (PublishedMessageImpl)(it.next()); TopicMessageContext ctxt = (TopicMessageContext)(it.next());
TopicMessageContext ctxt = (TopicMessageContext)pmi;
rc.add(ctxt); rc.add(ctxt);
} // end while } // end while
@ -1783,7 +1776,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end synchronized block } // end synchronized block
if (all) // add the extra postings to the list if (all) // add the extra postings to the list
PublishedMessageImpl.backfillReturn(rc,datapool); PublishedMessageImpl.backfillReturn(rc,env);
return Collections.unmodifiableList(rc); return Collections.unmodifiableList(rc);
@ -1797,20 +1790,20 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
public Advertisement getAdByID(int id) public Advertisement getAdByID(int id)
{ {
return AdvertisementImpl.getAdByID(datapool,id); return AdvertisementImpl.getAdByID(env,id);
} // end getAdByID } // end getAdByID
public Advertisement selectAd() public Advertisement selectAd()
{ {
// just get a random ad for now // just get a random ad for now
return AdvertisementImpl.getRandomAd(datapool); return AdvertisementImpl.getRandomAd(env);
} // end selectAd } // end selectAd
public BinaryData loadImage(int id) throws DataException public BinaryData loadImage(int id) throws DataException
{ {
return ImageStore.loadImageByID(datapool,id); return ImageStore.loadImageByID(env,id);
} // end loadImage } // end loadImage
@ -1831,7 +1824,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
public SimpleEmailer createEmailer() public Emailer createEmailer()
{ {
checkInitialized(); checkInitialized();
return new SimpleEmailer(email_props,mailsession); return new SimpleEmailer(email_props,mailsession);
@ -2038,7 +2031,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
try try
{ // get a connection and use it to store the audit record { // get a connection and use it to store the audit record
conn = datapool.getConnection(); conn = env.getConnection();
ar.store(conn); ar.store(conn);
} // end try } // end try
@ -2049,8 +2042,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -2092,7 +2084,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
try try
{ // get a connection and use it to reload { // get a connection and use it to reload
conn = datapool.getConnection(); conn = env.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
loadDefaults(stmt); loadDefaults(stmt);
@ -2105,8 +2097,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end catch } // end catch
finally finally
{ // make sure the connection is released before we go { // make sure the connection is released before we go
if (conn!=null) env.releaseConnection(conn);
datapool.releaseConnection(conn);
} // end finally } // end finally
@ -2124,7 +2115,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
} // end startPublish } // end startPublish
public synchronized void publishNew(PublishedMessageImpl pubmsg) public synchronized void publishNew(TopicMessageContext pubmsg)
{ {
if (pubmsg!=null) if (pubmsg!=null)
{ // add the new message { // add the new message
@ -2144,8 +2135,8 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
Iterator it = cache_fp_posts.iterator(); Iterator it = cache_fp_posts.iterator();
while (it.hasNext()) while (it.hasNext())
{ // get each published message in the cache in turn, looking for the specified post ID { // get each published message in the cache in turn, looking for the specified post ID
PublishedMessageImpl pmi = (PublishedMessageImpl)(it.next()); TopicMessageContext tmc = (TopicMessageContext)(it.next());
if (pmi.getPostID()==postid) if (tmc.getPostID()==postid)
{ // drop the specified post ID like a hot rock { // drop the specified post ID like a hot rock
it.remove(); it.remove();
break; break;

View File

@ -15,12 +15,12 @@
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.core.impl; package com.silverwrist.venice.core.internals;
import com.silverwrist.venice.core.DataException; import com.silverwrist.venice.core.DataException;
import com.silverwrist.venice.core.CommunityContext; import com.silverwrist.venice.core.CommunityContext;
public interface CommunityBackend extends UserBackend public interface CommunityBackend
{ {
public abstract CommunityContext selfCommunity(); public abstract CommunityContext selfCommunity();

View File

@ -15,7 +15,7 @@
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.core.impl; package com.silverwrist.venice.core.internals;
import java.util.BitSet; import java.util.BitSet;
import java.util.Date; import java.util.Date;
@ -67,21 +67,21 @@ public interface CommunityData
public abstract boolean canJoinCommunity(int uid, int level); public abstract boolean canJoinCommunity(int uid, int level);
public abstract void putContactInfo(UserBackend user, ContactInfo ci) throws DataException; public abstract void putContactInfo(EnvCommunity outer, ContactInfo ci) throws DataException;
public abstract BitSet getFeatureSet(); public abstract BitSet getFeatureSet();
public abstract void putFeatureSet(UserBackend user, BitSet set) throws DataException; public abstract void putFeatureSet(EnvCommunity outer, BitSet set) throws DataException;
public abstract List getCommunityFeaturesList(int level); public abstract List getCommunityFeaturesList(int level);
public abstract String getDefaultApplet(); public abstract String getDefaultApplet();
public abstract void setName(UserBackend user, String name) throws DataException; public abstract void setName(EnvCommunity outer, String name) throws DataException;
public abstract void setAlias(UserBackend user, String alias) throws DataException; public abstract void setAlias(EnvCommunity outer, String alias) throws DataException;
public abstract void setCategoryID(UserBackend user, int catid) throws DataException; public abstract void setCategoryID(EnvCommunity outer, int catid) throws DataException;
public abstract void setSynopsis(String synopsis) throws DataException; public abstract void setSynopsis(String synopsis) throws DataException;
@ -95,11 +95,12 @@ public interface CommunityData
public abstract boolean getHideSearch(); public abstract boolean getHideSearch();
public abstract void setHideFlags(UserBackend user, boolean directory, boolean search) throws DataException; public abstract void setHideFlags(EnvCommunity outer, boolean directory, boolean search)
throws DataException;
public abstract boolean getMembersOnly(); public abstract boolean getMembersOnly();
public abstract void setMembersOnly(UserBackend user, boolean flag) throws DataException; public abstract void setMembersOnly(EnvCommunity outer, boolean flag) throws DataException;
public abstract short getInitialFeatureIndex(); public abstract short getInitialFeatureIndex();
@ -107,7 +108,7 @@ public interface CommunityData
public abstract String getJoinKey() throws DataException; public abstract String getJoinKey() throws DataException;
public abstract void setJoinKey(UserBackend user, String key) throws DataException; public abstract void setJoinKey(EnvCommunity outer, String key) throws DataException;
public abstract int getReadLevel(); public abstract int getReadLevel();
@ -119,12 +120,12 @@ public interface CommunityData
public abstract int getJoinLevel(); public abstract int getJoinLevel();
public abstract void setSecurityLevels(UserBackend user, int read, int write, int create, int delete, public abstract void setSecurityLevels(EnvCommunity outer, int read, int write, int create, int delete,
int join) throws DataException; int join) throws DataException;
public abstract boolean isAdminCommunity(); public abstract boolean isAdminCommunity();
public abstract void setMembership(UserBackend user, int uid, int grant_level, boolean locked, public abstract void setMembership(EnvCommunity outer, int uid, int grant_level, boolean locked,
boolean hidden) throws DataException; boolean hidden) throws DataException;
public abstract int getMemberCount(boolean include_hidden) throws DataException; public abstract int getMemberCount(boolean include_hidden) throws DataException;
@ -135,7 +136,7 @@ public interface CommunityData
public abstract void detachConferenceDataObject(int confid); public abstract void detachConferenceDataObject(int confid);
public abstract ConferenceCommunityContext createConference(CommunityBackend comm, String name, String alias, public abstract ConferenceCommunityContext createConference(EnvCommunity outer, String name, String alias,
String description, boolean pvt, String description, boolean pvt,
boolean hide_list) boolean hide_list)
throws DataException; throws DataException;
@ -150,7 +151,7 @@ public interface CommunityData
public abstract int getMemberLevel(int uid) throws DataException; public abstract int getMemberLevel(int uid) throws DataException;
public abstract void delete(UserBackend user) throws DataException; public abstract void delete(EnvCommunity outer) throws DataException;
public abstract CommunityProperties getProperties(); public abstract CommunityProperties getProperties();

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * language governing rights and limitations under the License.
* *
* The Original Code is the Venice Web Community System. * The Original Code is the Venice Web Communities System.
* *
* 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
@ -15,7 +15,7 @@
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.core.impl; package com.silverwrist.venice.core.internals;
public interface CommunityDataBackend public interface CommunityDataBackend
{ {

View File

@ -15,7 +15,7 @@
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.core.impl; package com.silverwrist.venice.core.internals;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
@ -23,7 +23,7 @@ import java.util.Date;
import com.silverwrist.venice.db.PostLinkDecoderContext; import com.silverwrist.venice.db.PostLinkDecoderContext;
import com.silverwrist.venice.core.DataException; import com.silverwrist.venice.core.DataException;
public interface ConferenceBackend extends CommunityBackend public interface ConferenceBackend
{ {
public abstract int realConfID(); public abstract int realConfID();

View File

@ -15,7 +15,7 @@
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.core.impl; package com.silverwrist.venice.core.internals;
import java.sql.Connection; import java.sql.Connection;
import java.util.Date; import java.util.Date;
@ -63,20 +63,20 @@ public interface ConferenceCommunityContext
public abstract int getDeleteLevel() throws DataException; public abstract int getDeleteLevel() throws DataException;
public abstract void setSecurityLevels(CommunityBackend comm, int read, int post, int create, int hide, public abstract void setSecurityLevels(EnvCommunity outer, int read, int post, int create, int hide,
int nuke, int change, int delete) throws DataException; int nuke, int change, int delete) throws DataException;
public abstract void setName(CommunityBackend comm, String val) throws DataException; public abstract void setName(EnvCommunity outer, String val) throws DataException;
public abstract void setDescription(String val) throws DataException; public abstract void setDescription(String val) throws DataException;
public abstract void addAlias(CommunityBackend comm, String alias) throws DataException; public abstract void addAlias(EnvCommunity outer, String alias) throws DataException;
public abstract void removeAlias(CommunityBackend comm, String alias) throws DataException; public abstract void removeAlias(EnvCommunity outer, String alias) throws DataException;
public abstract void setMembership(CommunityBackend comm, int uid, int grant_level) throws DataException; public abstract void setMembership(EnvCommunity outer, int uid, int grant_level) throws DataException;
public abstract void setCommunityGrantedLevel(CommunityBackend comm, int new_level) throws DataException; public abstract void setCommunityGrantedLevel(EnvCommunity outer, int new_level) throws DataException;
public abstract short getSequence(); public abstract short getSequence();
@ -84,13 +84,13 @@ public interface ConferenceCommunityContext
public abstract boolean getHideList(); public abstract boolean getHideList();
public abstract void setHideList(CommunityBackend comm, boolean flag) throws DataException; public abstract void setHideList(EnvCommunity outer, boolean flag) throws DataException;
public abstract boolean canHideTopics(int level); public abstract boolean canHideTopics(int level);
public abstract String getAnAlias() throws DataException; public abstract String getAnAlias() throws DataException;
public abstract ReturnTopicInfo createNewTopic(CommunityBackend comm, String title, String pseud, public abstract ReturnTopicInfo createNewTopic(EnvCommunity outer, String title, String pseud,
String body) throws DataException; String body) throws DataException;
public abstract boolean canScribblePosts(int level); public abstract boolean canScribblePosts(int level);
@ -107,7 +107,7 @@ public interface ConferenceCommunityContext
public abstract boolean canDeleteConference(int level); public abstract boolean canDeleteConference(int level);
public abstract void delete(UserBackend user) throws DataException; public abstract void delete(EnvCommunity outer) throws DataException;
public abstract boolean displayPostPictures(); public abstract boolean displayPostPictures();

View File

@ -15,7 +15,7 @@
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.core.impl; package com.silverwrist.venice.core.internals;
import java.sql.Connection; import java.sql.Connection;
import java.util.Date; import java.util.Date;
@ -61,24 +61,24 @@ public interface ConferenceData
public abstract int getDeleteLevel(); public abstract int getDeleteLevel();
public abstract void setSecurityLevels(CommunityBackend comm, int read, int post, int create, int hide, public abstract void setSecurityLevels(EnvCommunity outer, int read, int post, int create, int hide,
int nuke, int change, int delete) throws DataException; int nuke, int change, int delete) throws DataException;
public abstract void setName(CommunityBackend comm, String val) throws DataException; public abstract void setName(EnvCommunity outer, String val) throws DataException;
public abstract void setDescription(String val) throws DataException; public abstract void setDescription(String val) throws DataException;
public abstract void addAlias(CommunityBackend comm, String alias) throws DataException; public abstract void addAlias(EnvCommunity outer, String alias) throws DataException;
public abstract void removeAlias(CommunityBackend comm, String alias) throws DataException; public abstract void removeAlias(EnvCommunity outer, String alias) throws DataException;
public abstract void setMembership(CommunityBackend comm, int uid, int grant_level) throws DataException; public abstract void setMembership(EnvCommunity outer, int uid, int grant_level) throws DataException;
public abstract boolean canHideTopics(int level); public abstract boolean canHideTopics(int level);
public abstract String getAnAlias() throws DataException; public abstract String getAnAlias() throws DataException;
public abstract ReturnTopicInfo createNewTopic(CommunityBackend comm, String title, String pseud, public abstract ReturnTopicInfo createNewTopic(EnvCommunity outer, String title, String pseud,
String body, int body_lines) throws DataException; String body, int body_lines) throws DataException;
public abstract boolean canScribblePosts(int level); public abstract boolean canScribblePosts(int level);
@ -101,7 +101,7 @@ public interface ConferenceData
public abstract boolean canDeleteConference(int level); public abstract boolean canDeleteConference(int level);
public abstract void delete(UserBackend user, int the_cid) throws DataException; public abstract void delete(EnvCommunity outer) throws DataException;
public abstract boolean displayPostPictures(); public abstract boolean displayPostPictures();

View File

@ -0,0 +1,34 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.core.internals;
import com.silverwrist.venice.core.EmailException;
public interface Emailer
{
public abstract void setTo(String to) throws EmailException;
public abstract void setFrom(String from_name, String from_addr) throws EmailException;
public abstract void setSubject(String subject);
public abstract void setText(String text);
public abstract void send() throws EmailException;
} // end interface Emailer

View File

@ -15,7 +15,7 @@
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.core.impl; package com.silverwrist.venice.core.internals;
import java.util.BitSet; import java.util.BitSet;
import java.util.List; import java.util.List;
@ -24,6 +24,7 @@ import com.silverwrist.venice.htmlcheck.HTMLChecker;
import com.silverwrist.venice.core.DataException; import com.silverwrist.venice.core.DataException;
import com.silverwrist.venice.core.GlobalProperties; import com.silverwrist.venice.core.GlobalProperties;
import com.silverwrist.venice.core.SideBoxDescriptor; import com.silverwrist.venice.core.SideBoxDescriptor;
import com.silverwrist.venice.core.TopicMessageContext;
public interface EngineBackend public interface EngineBackend
{ {
@ -47,7 +48,7 @@ public interface EngineBackend
// Boolean parameter indexes // Boolean parameter indexes
public static final int BP_POSTPICTURES = 0; public static final int BP_POSTPICTURES = 0;
public abstract SimpleEmailer createEmailer(); public abstract Emailer createEmailer();
public abstract String getStockMessage(String key); public abstract String getStockMessage(String key);
@ -93,7 +94,7 @@ public interface EngineBackend
public abstract void startPublish(); public abstract void startPublish();
public abstract void publishNew(PublishedMessageImpl pubmsg); public abstract void publishNew(TopicMessageContext pubmsg);
public abstract void unpublish(long postid); public abstract void unpublish(long postid);

View File

@ -0,0 +1,105 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.core.internals;
import com.silverwrist.venice.security.AuditRecord;
public class EnvCommunity extends EnvUser
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityBackend comm; // the community back end
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public EnvCommunity(EnvUser parent, CommunityBackend comm)
{
super(parent);
this.comm = comm;
} // end constructor
protected EnvCommunity(EnvCommunity other)
{
super(other);
this.comm = other.comm;
} // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class EnvUser
*--------------------------------------------------------------------------------
*/
public AuditRecord newAudit(int type, String data1, String data2, String data3, String data4)
{
return new AuditRecord(type,super.getUserID(),super.getUser().userRemoteAddress(),getCommunityID(),data1,
data2,data3,data4);
} // end newAudit
public AuditRecord newAudit(int type, String data1, String data2, String data3)
{
return new AuditRecord(type,super.getUserID(),super.getUser().userRemoteAddress(),getCommunityID(),data1,
data2,data3);
} // end newAudit
public AuditRecord newAudit(int type, String data1, String data2)
{
return new AuditRecord(type,super.getUserID(),super.getUser().userRemoteAddress(),getCommunityID(),data1,
data2);
} // end newAudit
public AuditRecord newAudit(int type, String data1)
{
return new AuditRecord(type,super.getUserID(),super.getUser().userRemoteAddress(),getCommunityID(),data1);
} // end newAudit
public AuditRecord newAudit(int type)
{
return new AuditRecord(type,super.getUserID(),super.getUser().userRemoteAddress(),getCommunityID());
} // end newAudit
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final CommunityBackend getCommunity()
{
return comm;
} // end getCommunity
public final int getCommunityID()
{
return comm.realCommunityID();
} // end getCommunityID()
} // end class EnvCommunity

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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.core.internals;
public class EnvCommunityData extends EnvEngine
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityDataBackend comm;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public EnvCommunityData(EnvEngine parent, CommunityDataBackend comm)
{
super(parent);
this.comm = comm;
} // end constructor
protected EnvCommunityData(EnvCommunityData other)
{
super(other);
this.comm = other.comm;
} // end EnvCommunityData
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final CommunityDataBackend getCommunityData()
{
return comm;
} // end getCommunityData
public final int getCommunityID()
{
return comm.realCommunityID();
} // end getCommunityID
} // end class EnvCommunityData

View File

@ -0,0 +1,66 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.core.internals;
public class EnvConference extends EnvCommunity
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private ConferenceBackend conf;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public EnvConference(EnvCommunity parent, ConferenceBackend conf)
{
super(parent);
this.conf = conf;
} // end constructor
protected EnvConference(EnvConference other)
{
super(other);
this.conf = other.conf;
} // end constructor
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final ConferenceBackend getConference()
{
return conf;
} // end getConference
public final int getConfID()
{
return conf.realConfID();
} // end getConfID
} // end class EnvConference

View File

@ -0,0 +1,39 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.core.internals;
public class EnvConferenceCommunity extends EnvCommunityData
{
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public EnvConferenceCommunity(EnvCommunityData parent)
{
super(parent);
} // end constructor
protected EnvConferenceCommunity(EnvConferenceCommunity other)
{
super(other);
} // end constructor
} // end class EnvConferenceCommunity

View File

@ -0,0 +1,39 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.core.internals;
public class EnvConferenceData extends EnvEngine
{
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public EnvConferenceData(EnvEngine parent)
{
super(parent);
} // end constructor
protected EnvConferenceData(EnvConferenceData other)
{
super(other);
} // end constructor
} // end class EnvConferenceData

View File

@ -0,0 +1,83 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.core.internals;
import java.sql.Connection;
import java.sql.SQLException;
import com.silverwrist.venice.db.*;
public class EnvEngine
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private EngineBackend engine; // the engine
private DataPool datapool; // the database pool
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public EnvEngine(EngineBackend engine, DataPool datapool)
{
this.engine = engine;
this.datapool = datapool;
} // end constructor
protected EnvEngine(EnvEngine other)
{
this.engine = other.engine;
this.datapool = other.datapool;
} // end constructor
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final EngineBackend getEngine()
{
return engine;
} // end getEngine
public final DataPool getDataPool()
{
return datapool;
} // end getDataPool
public final Connection getConnection() throws SQLException
{
return datapool.getConnection();
} // end getConnection
public final void releaseConnection(Connection c)
{
if (c!=null)
datapool.releaseConnection(c);
} // end releaseConnection
} // end class EnvEngine

View File

@ -0,0 +1,97 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.core.internals;
import com.silverwrist.venice.security.AuditRecord;
public class EnvUser extends EnvEngine
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private UserBackend user; // the user backend object
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public EnvUser(EnvEngine parent, UserBackend user)
{
super(parent);
this.user = user;
} // end constructor
protected EnvUser(EnvUser other)
{
super(other);
this.user = other.user;
} // end constructor
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final UserBackend getUser()
{
return user;
} // end getUser
public final int getUserID()
{
return user.realUID();
} // end getUserID
public AuditRecord newAudit(int type, String data1, String data2, String data3, String data4)
{
return new AuditRecord(type,getUserID(),user.userRemoteAddress(),data1,data2,data3,data4);
} // end newAudit
public AuditRecord newAudit(int type, String data1, String data2, String data3)
{
return new AuditRecord(type,getUserID(),user.userRemoteAddress(),data1,data2,data3);
} // end newAudit
public AuditRecord newAudit(int type, String data1, String data2)
{
return new AuditRecord(type,getUserID(),user.userRemoteAddress(),data1,data2);
} // end newAudit
public AuditRecord newAudit(int type, String data1)
{
return new AuditRecord(type,getUserID(),user.userRemoteAddress(),data1);
} // end newAudit
public AuditRecord newAudit(int type)
{
return new AuditRecord(type,getUserID(),user.userRemoteAddress());
} // end newAudit
} // end class EnvUser

View File

@ -15,24 +15,24 @@
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.core.impl; package com.silverwrist.venice.core.internals;
class ReturnConfSeq public final class ReturnConfSeq
{ {
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Attributes * Attributes
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private ConferenceData conf; private ConferenceData conf; // conference being returned
private short sequence; private short sequence; // sequence number of conference
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructor * Constructor
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
ReturnConfSeq(ConferenceData conf, short sequence) public ReturnConfSeq(ConferenceData conf, short sequence)
{ {
this.conf = conf; this.conf = conf;
this.sequence = sequence; this.sequence = sequence;
@ -44,13 +44,13 @@ class ReturnConfSeq
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
ConferenceData getConference() public final ConferenceData getConference()
{ {
return conf; return conf;
} // end getConference } // end getConference
short getSequence() public final short getSequence()
{ {
return sequence; return sequence;

View File

@ -15,20 +15,20 @@
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.core.impl; package com.silverwrist.venice.core.internals;
import java.util.Date; import java.util.Date;
public class ReturnTopicInfo public final class ReturnTopicInfo
{ {
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Attributes * Attributes
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private int topic_id; private int topic_id; // the topic ID
private short topic_num; private short topic_num; // the topic number
private Date create_date; private Date create_date; // the creation date
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructor * Constructor
@ -48,19 +48,19 @@ public class ReturnTopicInfo
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
public int getTopicID() public final int getTopicID()
{ {
return topic_id; return topic_id;
} // end getTopicID } // end getTopicID
public short getTopicNum() public final short getTopicNum()
{ {
return topic_num; return topic_num;
} // end getTopicNum } // end getTopicNum
public Date getCreateDate() public final Date getCreateDate()
{ {
return create_date; return create_date;

View File

@ -15,7 +15,7 @@
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.core.impl; package com.silverwrist.venice.core.internals;
import com.silverwrist.venice.core.DataException; import com.silverwrist.venice.core.DataException;

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * language governing rights and limitations under the License.
* *
* The Original Code is the Venice Web Community System. * The Original Code is the Venice Web Communities System.
* *
* 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
@ -22,6 +22,11 @@ import com.silverwrist.venice.ValidationException;
public class CDEmailAddressFormField extends CDTextFormField public class CDEmailAddressFormField extends CDTextFormField
{ {
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public CDEmailAddressFormField(String name, String caption, String caption2, boolean required, public CDEmailAddressFormField(String name, String caption, String caption2, boolean required,
int size, int maxlength) int size, int maxlength)
{ {
@ -35,13 +40,24 @@ public class CDEmailAddressFormField extends CDTextFormField
} // end constructor } // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class CDTextFormField
*--------------------------------------------------------------------------------
*/
protected void validateContents(String value) throws ValidationException protected void validateContents(String value) throws ValidationException
{ {
super.validateContents(value);
if (!IDUtils.isValidEmailAddress(value)) if (!IDUtils.isValidEmailAddress(value))
throw new ValidationException("The value of '" + getCaption() + "' must be a correct Internet address."); throw new ValidationException("The value of '" + getCaption() + "' must be a correct Internet address.");
} // end validateContents } // end validateContents
/*--------------------------------------------------------------------------------
* Implementations from interface CDFormField
*--------------------------------------------------------------------------------
*/
public Object clone() public Object clone()
{ {
return new CDEmailAddressFormField(this); return new CDEmailAddressFormField(this);

View File

@ -94,6 +94,7 @@ public class CDIntegerFormField extends CDTextFormField
protected void validateContents(String value) throws ValidationException protected void validateContents(String value) throws ValidationException
{ {
super.validateContents(value);
try try
{ // convert to an integer and check against range { // convert to an integer and check against range
int x = Integer.parseInt(value); int x = Integer.parseInt(value);

View File

@ -30,6 +30,7 @@ public class CDTextFormField extends CDBaseFormField
private int size; private int size;
private int maxlength; private int maxlength;
private int real_maxlength;
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructors * Constructors
@ -40,8 +41,9 @@ public class CDTextFormField extends CDBaseFormField
int size, int maxlength) int size, int maxlength)
{ {
super(name,caption,caption2,required); super(name,caption,caption2,required);
this.size = size; this.size = Math.max(size,2);
this.maxlength = maxlength; this.maxlength = Math.max(maxlength,2);
this.real_maxlength = maxlength;
} // end constructor } // end constructor
@ -50,6 +52,7 @@ public class CDTextFormField extends CDBaseFormField
super(other); super(other);
this.size = other.size; this.size = other.size;
this.maxlength = other.maxlength; this.maxlength = other.maxlength;
this.real_maxlength = other.real_maxlength;
} // end constructor } // end constructor
@ -73,7 +76,11 @@ public class CDTextFormField extends CDBaseFormField
} // end renderActualField } // end renderActualField
protected void validateContents(String value) throws ValidationException protected void validateContents(String value) throws ValidationException
{ // this is a do-nothing value {
if (value.length()>real_maxlength)
throw new ValidationException("The value of the '" + getCaption() + "' field must be no longer than "
+ real_maxlength + " characters.");
} // end validateContents } // end validateContents
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------

View File

@ -47,12 +47,18 @@ public class CDVeniceIDFormField extends CDTextFormField
protected void validateContents(String value) throws ValidationException protected void validateContents(String value) throws ValidationException
{ {
super.validateContents(value);
if (!IDUtils.isValidVeniceID(value)) if (!IDUtils.isValidVeniceID(value))
throw new ValidationException("There is an invalid character in the '" + getCaption() + "'field. " throw new ValidationException("There is an invalid character in the '" + getCaption() + "'field. "
+ "Valid characters are letters, digits, -, _, !, ~, *, ', and $."); + "Valid characters are letters, digits, -, _, !, ~, *, ', and $.");
} // end validateContents } // end validateContents
/*--------------------------------------------------------------------------------
* Implementations from interface CDFormField
*--------------------------------------------------------------------------------
*/
public CDFormField duplicate() public CDFormField duplicate()
{ {
return new CDVeniceIDFormField(this); return new CDVeniceIDFormField(this);