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:
parent
313a46818f
commit
47b88efd75
|
@ -21,6 +21,7 @@ import java.sql.*;
|
|||
import java.util.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.security.AuditRecord;
|
||||
import com.silverwrist.venice.security.SecLevels;
|
||||
|
@ -39,20 +40,16 @@ class AdminOperationsImpl implements AdminOperations
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private EngineBackend engine; // the back end of the engine
|
||||
private UserBackend user; // the UserContext that created this object
|
||||
private DataPool datapool; // the data pool used by this object
|
||||
private EnvUser env; // the execution environment
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
AdminOperationsImpl(EngineBackend engine, UserBackend user, DataPool datapool)
|
||||
AdminOperationsImpl(EnvUser env)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.user = user;
|
||||
this.datapool = datapool;
|
||||
this.env = env;
|
||||
|
||||
} // end constructor
|
||||
|
||||
|
@ -63,7 +60,7 @@ class AdminOperationsImpl implements AdminOperations
|
|||
|
||||
public boolean isGlobalAdmin()
|
||||
{
|
||||
return (user.realBaseLevel()==SecLevels.GLOBAL_BOFH);
|
||||
return (env.getUser().realBaseLevel()==SecLevels.GLOBAL_BOFH);
|
||||
|
||||
} // end isGlobalAdmin
|
||||
|
||||
|
@ -74,7 +71,7 @@ class AdminOperationsImpl implements AdminOperations
|
|||
|
||||
try
|
||||
{ // 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);
|
||||
|
||||
} // end try
|
||||
|
@ -86,8 +83,7 @@ class AdminOperationsImpl implements AdminOperations
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -102,7 +98,7 @@ class AdminOperationsImpl implements AdminOperations
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool and get the audit records
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
rc = AuditRecord.getAuditRecordCount(conn,-1);
|
||||
|
||||
} // end try
|
||||
|
@ -114,8 +110,7 @@ class AdminOperationsImpl implements AdminOperations
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -125,25 +120,25 @@ class AdminOperationsImpl implements AdminOperations
|
|||
|
||||
public AdminUserContext getUserContext(int uid) throws DataException
|
||||
{
|
||||
return AdminUserContextImpl.getAdminUserContext(engine,user,datapool,uid);
|
||||
return AdminUserContextImpl.getAdminUserContext(env,uid);
|
||||
|
||||
} // end getUserContext
|
||||
|
||||
public AdminUserContext getUserContext(String username) throws DataException
|
||||
{
|
||||
return AdminUserContextImpl.getAdminUserContext(engine,user,datapool,username);
|
||||
return AdminUserContextImpl.getAdminUserContext(env,username);
|
||||
|
||||
} // end getUserContext
|
||||
|
||||
public GlobalProperties getProperties()
|
||||
{
|
||||
return engine.getProperties();
|
||||
return env.getEngine().getProperties();
|
||||
|
||||
} // end getProperties
|
||||
|
||||
public void setProperties(GlobalProperties props) throws DataException
|
||||
{
|
||||
engine.setProperties(props);
|
||||
env.getEngine().setProperties(props);
|
||||
|
||||
} // end setProperties
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.*;
|
|||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.International;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.security.PasswordHash;
|
||||
import com.silverwrist.venice.security.AuditRecord;
|
||||
|
@ -40,9 +41,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private EngineBackend engine; // the back end of the engine
|
||||
private UserBackend user; // the controlling administrative user
|
||||
private DataPool datapool; // the data pool used by this object
|
||||
private EnvUser env; // the local environment
|
||||
private int uid; // the user ID of this user
|
||||
private int contactid; // ID of associated contact information
|
||||
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)
|
||||
throws SQLException
|
||||
protected AdminUserContextImpl(EnvUser env, ResultSet rs) throws SQLException
|
||||
{
|
||||
this.engine = engine;
|
||||
this.user = user;
|
||||
this.datapool = datapool;
|
||||
this.env = env;
|
||||
this.uid = rs.getInt("uid");
|
||||
this.contactid = rs.getInt("contactid");
|
||||
this.level = rs.getInt("base_lvl");
|
||||
|
@ -119,15 +115,14 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET description = '");
|
||||
sql.append(SQLUtil.encodeString(new_descr)).append("' WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
description = new_descr; // change stored information
|
||||
ar = new AuditRecord(AuditRecord.ADMIN_ACCOUNT_CHANGE,user.realUID(),user.userRemoteAddress(),0,
|
||||
"uid=" + uid,"field=description");
|
||||
ar = env.newAudit(AuditRecord.ADMIN_ACCOUNT_CHANGE,"uid=" + uid,"field=description");
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -150,8 +145,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -173,15 +167,14 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET base_lvl = ");
|
||||
sql.append(new_level).append(" WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
level = new_level;
|
||||
ar = new AuditRecord(AuditRecord.ADMIN_SET_SECURITY,user.realUID(),user.userRemoteAddress(),0,
|
||||
"uid=" + uid,"level=" + new_level);
|
||||
ar = env.newAudit(AuditRecord.ADMIN_SET_SECURITY,"uid=" + uid,"level=" + new_level);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -204,8 +197,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -227,15 +219,14 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = ");
|
||||
sql.append(flag ? '1' : '0').append(" WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
email_verified = flag;
|
||||
ar = new AuditRecord(AuditRecord.ADMIN_ACCOUNT_CHANGE,user.realUID(),user.userRemoteAddress(),0,
|
||||
"uid=" + uid,"field=verify_email");
|
||||
ar = env.newAudit(AuditRecord.ADMIN_ACCOUNT_CHANGE,"uid=" + uid,"field=verify_email");
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -258,8 +249,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -281,15 +271,14 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET lockout = ");
|
||||
sql.append(flag ? '1' : '0').append(" WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
lockout = flag;
|
||||
ar = new AuditRecord(AuditRecord.ADMIN_LOCK_OUT,user.realUID(),user.userRemoteAddress(),0,
|
||||
"uid=" + uid,flag ? "locked" : "unlocked");
|
||||
ar = env.newAudit(AuditRecord.ADMIN_LOCK_OUT,"uid=" + uid,flag ? "locked" : "unlocked");
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -312,8 +301,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -326,7 +314,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
ContactInfoImpl rc;
|
||||
if (contactid>=0)
|
||||
rc = new ContactInfoImpl(datapool,contactid);
|
||||
rc = new ContactInfoImpl(env,contactid);
|
||||
else
|
||||
rc = new ContactInfoImpl(uid);
|
||||
return rc;
|
||||
|
@ -351,7 +339,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Stashable obj = (Stashable)ci;
|
||||
|
||||
// save the contact information
|
||||
|
@ -365,8 +353,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
} // end if
|
||||
|
||||
ar = new AuditRecord(AuditRecord.ADMIN_USER_CONTACT_INFO,user.realUID(),user.userRemoteAddress(),
|
||||
"uid=" + uid,"contactid=" + contactid);
|
||||
ar = env.newAudit(AuditRecord.ADMIN_USER_CONTACT_INFO,"uid=" + uid,"contactid=" + contactid);
|
||||
|
||||
} // end try
|
||||
catch (ClassCastException cce)
|
||||
|
@ -395,8 +382,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end if
|
||||
|
||||
|
@ -409,7 +395,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
PasswordHash phash = new PasswordHash(password);
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '");
|
||||
|
@ -418,8 +404,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
// record an audit record for this user
|
||||
ar = new AuditRecord(AuditRecord.ADMIN_PASSWORD_CHANGE,user.realUID(),user.userRemoteAddress(),
|
||||
"uid=" + uid);
|
||||
ar = env.newAudit(AuditRecord.ADMIN_PASSWORD_CHANGE,"uid=" + uid);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -442,8 +427,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -462,7 +446,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the update statement
|
||||
|
@ -474,8 +458,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
// replace the locale here
|
||||
my_locale = locale;
|
||||
ar = new AuditRecord(AuditRecord.ADMIN_ACCOUNT_CHANGE,user.realUID(),user.userRemoteAddress(),0,
|
||||
"uid=" + uid,"field=localeid");
|
||||
ar = env.newAudit(AuditRecord.ADMIN_ACCOUNT_CHANGE,"uid=" + uid,"field=localeid");
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -498,8 +481,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -518,7 +500,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the update statement
|
||||
|
@ -530,8 +512,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
// replace the locale here
|
||||
my_tz = timezone;
|
||||
ar = new AuditRecord(AuditRecord.ADMIN_ACCOUNT_CHANGE,user.realUID(),user.userRemoteAddress(),0,
|
||||
"uid=" + uid,"field=tzid");
|
||||
ar = env.newAudit(AuditRecord.ADMIN_ACCOUNT_CHANGE,"uid=" + uid,"field=tzid");
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -554,8 +535,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -578,14 +558,13 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static AdminUserContext getAdminUserContext(EngineBackend engine, UserBackend user, DataPool datapool,
|
||||
int uid) throws DataException
|
||||
static AdminUserContext getAdminUserContext(EnvUser env, int uid) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM users INNER JOIN userprefs "
|
||||
+ "ON users.uid = userprefs.uid WHERE users.uid = " + uid + ";");
|
||||
|
@ -594,7 +573,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
if (rs.getBoolean("is_anon"))
|
||||
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
|
||||
catch (SQLException e)
|
||||
|
@ -605,21 +584,19 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // release the connection where necessary
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end getAdminUserContext
|
||||
|
||||
static AdminUserContext getAdminUserContext(EngineBackend engine, UserBackend user, DataPool datapool,
|
||||
String username) throws DataException
|
||||
static AdminUserContext getAdminUserContext(EnvUser env, String username) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM users INNER JOIN userprefs "
|
||||
+ "ON users.uid = userprefs.uid WHERE users.username = '"
|
||||
|
@ -629,7 +606,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
if (rs.getBoolean("is_anon"))
|
||||
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
|
||||
catch (SQLException e)
|
||||
|
@ -640,8 +617,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // release the connection where necessary
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.sql.*;
|
|||
import java.util.Random;
|
||||
import com.silverwrist.util.cache.CacheMap;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.EnvEngine;
|
||||
import com.silverwrist.venice.db.*;
|
||||
|
||||
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 String imagepath; // image path
|
||||
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.imagepath = rs.getString("imagepath");
|
||||
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);
|
||||
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 + ";");
|
||||
if (!(rs.next()))
|
||||
return null;
|
||||
rc = new AdvertisementImpl(datapool,rs);
|
||||
rc = new AdvertisementImpl(env,rs);
|
||||
ad_cache.put(my_ad_id,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;
|
||||
|
||||
try
|
||||
{ // get a database connection and call the internal function
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
return getTheAd(datapool,stmt,id);
|
||||
return getTheAd(env,stmt,id);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -144,20 +145,19 @@ class AdvertisementImpl implements Advertisement
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end getAdByID
|
||||
|
||||
static Advertisement getRandomAd(DataPool datapool)
|
||||
static Advertisement getRandomAd(EnvEngine env)
|
||||
{
|
||||
Connection conn = null;
|
||||
|
||||
try
|
||||
{ // get a database connection and call the internal function
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT MAX(adid) FROM adverts;");
|
||||
if (!(rs.next()))
|
||||
|
@ -167,7 +167,7 @@ class AdvertisementImpl implements Advertisement
|
|||
for (int i=0; i<100; i++)
|
||||
{ // select an ad ID
|
||||
int ad_id = rng.nextInt(maximum) + 1;
|
||||
Advertisement rc = getTheAd(datapool,stmt,ad_id);
|
||||
Advertisement rc = getTheAd(env,stmt,ad_id);
|
||||
if (rc!=null)
|
||||
return rc;
|
||||
|
||||
|
@ -183,8 +183,7 @@ class AdvertisementImpl implements Advertisement
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -22,9 +22,10 @@ import java.util.*;
|
|||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.ParallelRunQueue;
|
||||
import com.silverwrist.util.cache.ObjectCache;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.core.DataException;
|
||||
import com.silverwrist.venice.core.InternalStateError;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
|
||||
class BackgroundCommunityPurge implements Runnable
|
||||
{
|
||||
|
@ -40,9 +41,7 @@ class BackgroundCommunityPurge implements Runnable
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private EngineBackend engine;
|
||||
private DataPool datapool;
|
||||
private UserBackend user;
|
||||
private EnvCommunity env;
|
||||
private int cid;
|
||||
private int num_confs;
|
||||
private int max_confid;
|
||||
|
@ -53,12 +52,9 @@ class BackgroundCommunityPurge implements Runnable
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
BackgroundCommunityPurge(EngineBackend engine, DataPool datapool, UserBackend user, int cid, int num_confs,
|
||||
int max_confid, ObjectCache conf_objcache)
|
||||
BackgroundCommunityPurge(EnvCommunity env, int cid, int num_confs, int max_confid, ObjectCache conf_objcache)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.datapool = datapool;
|
||||
this.user = user;
|
||||
this.env = env;
|
||||
this.cid = cid;
|
||||
this.num_confs = num_confs;
|
||||
this.max_confid = max_confid;
|
||||
|
@ -81,7 +77,7 @@ class BackgroundCommunityPurge implements Runnable
|
|||
|
||||
try
|
||||
{ // get a database connection from the pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// run some "lower priority" deletes
|
||||
|
@ -106,7 +102,7 @@ class BackgroundCommunityPurge implements Runnable
|
|||
if (confobj!=null)
|
||||
{ // OK, there's an object - do the delete internally and release the object
|
||||
conf_objcache.detach(key);
|
||||
confobj.delete(user);
|
||||
confobj.delete(env);
|
||||
|
||||
} // end if
|
||||
else
|
||||
|
@ -141,7 +137,7 @@ class BackgroundCommunityPurge implements Runnable
|
|||
rs = stmt.executeQuery(sql.toString());
|
||||
if (!(rs.next()))
|
||||
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)
|
||||
|
||||
|
@ -167,8 +163,7 @@ class BackgroundCommunityPurge implements Runnable
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.log4j.*;
|
|||
import com.silverwrist.util.ParallelRunQueue;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.core.InternalStateError;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
|
||||
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
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private EngineBackend engine;
|
||||
private DataPool datapool;
|
||||
private EnvEngine env; // the environment
|
||||
private int confid;
|
||||
private int num_topics;
|
||||
private int max_topicid;
|
||||
|
@ -48,11 +48,9 @@ class BackgroundConferencePurge implements Runnable
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
BackgroundConferencePurge(EngineBackend engine, DataPool datapool, int confid, int num_topics,
|
||||
int max_topicid)
|
||||
BackgroundConferencePurge(EnvEngine env, int confid, int num_topics, int max_topicid)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.datapool = datapool;
|
||||
this.env = env;
|
||||
this.confid = confid;
|
||||
this.num_topics = num_topics;
|
||||
this.max_topicid = max_topicid;
|
||||
|
@ -74,7 +72,7 @@ class BackgroundConferencePurge implements Runnable
|
|||
|
||||
try
|
||||
{ // get a database connection from the pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// purge out some auxiliary tables first
|
||||
|
@ -104,7 +102,7 @@ class BackgroundConferencePurge implements Runnable
|
|||
rs = stmt.executeQuery(sql.toString());
|
||||
if (!(rs.next()))
|
||||
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
|
||||
|
||||
|
@ -120,8 +118,7 @@ class BackgroundConferencePurge implements Runnable
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package com.silverwrist.venice.core.impl;
|
|||
import java.sql.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
|
||||
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
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private EngineBackend engine;
|
||||
private DataPool datapool;
|
||||
private EnvEngine env; // the environment block
|
||||
private int topicid;
|
||||
private int num_posts;
|
||||
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.datapool = datapool;
|
||||
this.env = env;
|
||||
this.topicid = topicid;
|
||||
this.num_posts = num_posts;
|
||||
this.max_postid = max_postid;
|
||||
|
@ -71,7 +70,7 @@ class BackgroundTopicPurge implements Runnable
|
|||
|
||||
try
|
||||
{ // get a database connection from the pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// 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 postdogear WHERE postid = " + postids[i] + ";");
|
||||
if (stmt.executeUpdate("DELETE FROM postpublish WHERE postid = " + postids[i] + ";")>0)
|
||||
engine.unpublish(postids[i]);
|
||||
env.getEngine().unpublish(postids[i]);
|
||||
|
||||
} // end for
|
||||
|
||||
|
@ -105,8 +104,7 @@ class BackgroundTopicPurge implements Runnable
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.*;
|
|||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.EnvEngine;
|
||||
|
||||
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
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private DataPool datapool; // used for doing database lookups
|
||||
private EnvEngine env; // the execution environment
|
||||
private LinkedList cats; // the actual category segments
|
||||
private int symlink = -1; // if our category is actually a symlink
|
||||
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();
|
||||
this.do_hide = do_hide;
|
||||
|
||||
|
@ -91,7 +92,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
|
||||
try
|
||||
{ // get a connection and a prepared statement
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
doFillFromTop(conn,catid);
|
||||
|
||||
} // end try
|
||||
|
@ -102,17 +103,16 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure and release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // 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
|
||||
{
|
||||
this.datapool = datapool;
|
||||
this.env = env;
|
||||
cats = new LinkedList();
|
||||
this.do_hide = do_hide;
|
||||
|
||||
|
@ -123,9 +123,9 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
|
||||
} // 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.symlink = symlink;
|
||||
this.do_hide = do_hide;
|
||||
|
@ -136,7 +136,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
|
||||
protected CategoryDescriptorImpl(CategoryDescriptorImpl other, int copy_levels)
|
||||
{
|
||||
this.datapool = other.datapool;
|
||||
this.env = other.env;
|
||||
this.cats = new LinkedList();
|
||||
this.symlink = ((copy_levels==other.cats.size()) ? other.symlink : -1);
|
||||
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)
|
||||
{
|
||||
this.datapool = other.datapool;
|
||||
this.env = other.env;
|
||||
this.cats = new LinkedList();
|
||||
this.symlink = symlink;
|
||||
this.do_hide = other.do_hide;
|
||||
|
@ -164,18 +164,6 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* finalize() function
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void finalize()
|
||||
{
|
||||
datapool = null;
|
||||
cats = null;
|
||||
|
||||
} // end finalize
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
|
@ -248,7 +236,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
{
|
||||
if (symlink!=-1)
|
||||
{ // "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();
|
||||
|
||||
} // end if
|
||||
|
@ -257,7 +245,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
ArrayList rc = new ArrayList();
|
||||
try
|
||||
{ // get a connection and create a statement
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT catid, symlink, name FROM refcategory WHERE parent = ");
|
||||
sql.append(getCategoryID());
|
||||
|
@ -283,8 +271,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure and release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -324,7 +311,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
public CategoryDescriptor getLinkedCategory() throws DataException
|
||||
{
|
||||
if (symlink!=-1)
|
||||
return new CategoryDescriptorImpl(datapool,symlink,do_hide);
|
||||
return new CategoryDescriptorImpl(env,symlink,do_hide);
|
||||
else
|
||||
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;
|
||||
ArrayList rc = new ArrayList();
|
||||
try
|
||||
{ // get a connection and create a statement
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT catid, symlink, name FROM refcategory WHERE parent = -1");
|
||||
if (do_hide)
|
||||
|
@ -400,8 +387,8 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
ResultSet rs = stmt.executeQuery(sql.toString());
|
||||
while (rs.next())
|
||||
{ // turn data values into CategoryDescriptor objects
|
||||
CategoryDescriptor ncd = new CategoryDescriptorImpl(datapool,rs.getInt("catid"),rs.getInt("symlink"),
|
||||
rs.getString("name"),do_hide);
|
||||
CategoryDescriptor ncd = new CategoryDescriptorImpl(env,rs.getInt(1),rs.getInt(2),rs.getString(3),
|
||||
do_hide);
|
||||
rc.add(ncd);
|
||||
|
||||
} // end while
|
||||
|
@ -414,8 +401,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure and release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -423,7 +409,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
|
||||
} // 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
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
|
@ -435,7 +421,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
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++)
|
||||
{ // 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);
|
||||
|
||||
} // end for
|
||||
|
@ -492,8 +478,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -501,7 +486,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
|
||||
} // 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
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
|
@ -511,7 +496,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM refcategory WHERE name ");
|
||||
|
||||
|
@ -560,8 +545,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.silverwrist.util.StringUtil;
|
|||
import com.silverwrist.util.cache.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
import com.silverwrist.venice.security.AuditRecord;
|
||||
import com.silverwrist.venice.security.Capability;
|
||||
import com.silverwrist.venice.security.DefaultLevels;
|
||||
|
@ -47,7 +48,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
Integer xconf = (Integer)key;
|
||||
try
|
||||
{ // create the desired object
|
||||
return new ConferenceCommunityContextImpl(engine,CommunityCoreData.this,datapool,xconf.intValue());
|
||||
return new ConferenceCommunityContextImpl(env,xconf.intValue());
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
|
@ -77,8 +78,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private EngineBackend engine; // pointer to engine back end
|
||||
private DataPool datapool; // pointer to data pool
|
||||
private EnvCommunityData env; // the environment
|
||||
private int cid; // ID of this community
|
||||
private java.util.Date created; // date/time of database creation
|
||||
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())
|
||||
logger.debug("new CommunityCoreData for community " + cid);
|
||||
this.engine = engine;
|
||||
this.datapool = datapool;
|
||||
this.env = new EnvCommunityData(env,this);
|
||||
this.cid = cid;
|
||||
|
||||
Connection conn = null;
|
||||
|
||||
try
|
||||
{ // get a database connection from this object
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// get the community basic data from the database
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -171,22 +170,20 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // 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 rules, String joinkey, boolean hide_dir, boolean hide_search,
|
||||
BitSet features)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("new CommunityCoreData for BRAND NEW COMMUNITY " + cid);
|
||||
this.engine = engine;
|
||||
this.datapool = datapool;
|
||||
this.env = new EnvCommunityData(env,this);
|
||||
this.cid = cid;
|
||||
this.created = creation;
|
||||
this.last_access = creation;
|
||||
|
@ -212,31 +209,11 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
this.public_comm = StringUtil.isStringEmpty(joinkey);
|
||||
this.features = (BitSet)(features.clone());
|
||||
this.flags = new OptionSet();
|
||||
if (engine.getParamBoolean(EngineBackend.BP_POSTPICTURES))
|
||||
if (env.getEngine().getParamBoolean(EngineBackend.BP_POSTPICTURES))
|
||||
flags.set(BP_POSTPICTURES);
|
||||
|
||||
} // 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
|
||||
*--------------------------------------------------------------------------------
|
||||
|
@ -313,7 +290,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
Connection conn = null;
|
||||
try
|
||||
{ // get a connection and create a statement
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer();
|
||||
|
||||
|
@ -335,8 +312,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -516,7 +492,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// check to see if the UID is listed in "sigban" table...
|
||||
|
@ -534,8 +510,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -543,7 +518,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end canJoinCommunity
|
||||
|
||||
public synchronized void putContactInfo(UserBackend user, ContactInfo ci) throws DataException
|
||||
public synchronized void putContactInfo(EnvCommunity outer, ContactInfo ci) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This community has been deleted.");
|
||||
|
@ -553,7 +528,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Stashable obj = (Stashable)ci;
|
||||
|
||||
// save the contact information
|
||||
|
@ -568,8 +543,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end if
|
||||
|
||||
touchUpdate(conn);
|
||||
ar = new AuditRecord(AuditRecord.COMMUNITY_CONTACT_INFO,user.realUID(),user.userRemoteAddress(),cid,
|
||||
"contactid=" + contactid);
|
||||
ar = outer.newAudit(AuditRecord.COMMUNITY_CONTACT_INFO,"contactid=" + contactid);
|
||||
|
||||
} // end try
|
||||
catch (ClassCastException cce)
|
||||
|
@ -598,8 +572,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -611,7 +584,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end getFeatureSet
|
||||
|
||||
public synchronized void putFeatureSet(UserBackend user, BitSet set) throws DataException
|
||||
public synchronized void putFeatureSet(EnvCommunity outer, BitSet set) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This community has been deleted.");
|
||||
|
@ -621,7 +594,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.executeUpdate("LOCK TABLES sigftrs WRITE;");
|
||||
|
||||
|
@ -665,7 +638,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end finally
|
||||
|
||||
touchUpdate(conn);
|
||||
ar = new AuditRecord(AuditRecord.COMMUNITY_FEATURE_SET,user.realUID(),user.userRemoteAddress(),cid);
|
||||
ar = outer.newAudit(AuditRecord.COMMUNITY_FEATURE_SET);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -688,8 +661,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -697,19 +669,19 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
public List getCommunityFeaturesList(int level)
|
||||
{
|
||||
return engine.getCommunityFeatureSet(features,level,canReadCommunitySubObjects(level));
|
||||
return env.getEngine().getCommunityFeatureSet(features,level,canReadCommunitySubObjects(level));
|
||||
|
||||
} // end getCommunityFeaturesList
|
||||
|
||||
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);
|
||||
return buf.toString();
|
||||
|
||||
} // end getDefaultApplet
|
||||
|
||||
public synchronized void setName(UserBackend user, String name) throws DataException
|
||||
public synchronized void setName(EnvCommunity outer, String name) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This community has been deleted.");
|
||||
|
@ -719,7 +691,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE sigs SET signame = '");
|
||||
sql.append(SQLUtil.encodeString(name)).append("', lastupdate = '");
|
||||
|
@ -728,8 +700,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
stmt.executeUpdate(sql.toString());
|
||||
this.name = name;
|
||||
last_update = now;
|
||||
ar = new AuditRecord(AuditRecord.COMMUNITY_NAME,user.realUID(),user.userRemoteAddress(),cid,
|
||||
"name=" + name);
|
||||
ar = outer.newAudit(AuditRecord.COMMUNITY_NAME,"name=" + name);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -752,14 +723,13 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end setName
|
||||
|
||||
public synchronized void setAlias(UserBackend user, String alias) throws DataException
|
||||
public synchronized void setAlias(EnvCommunity outer, String alias) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This community has been deleted.");
|
||||
|
@ -769,7 +739,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE sigs SET alias = '");
|
||||
sql.append(alias).append("', lastupdate = '");
|
||||
|
@ -778,8 +748,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
stmt.executeUpdate(sql.toString());
|
||||
this.alias = alias;
|
||||
last_update = now;
|
||||
ar = new AuditRecord(AuditRecord.COMMUNITY_ALIAS,user.realUID(),user.userRemoteAddress(),cid,
|
||||
"alias=" + alias);
|
||||
ar = outer.newAudit(AuditRecord.COMMUNITY_ALIAS,"alias=" + alias);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -802,14 +771,13 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end setAlias
|
||||
|
||||
public synchronized void setCategoryID(UserBackend user, int catid) throws DataException
|
||||
public synchronized void setCategoryID(EnvCommunity outer, int catid) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This community has been deleted.");
|
||||
|
@ -819,7 +787,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE sigs SET catid = ");
|
||||
sql.append(catid).append(", lastupdate = '");
|
||||
|
@ -828,8 +796,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
stmt.executeUpdate(sql.toString());
|
||||
this.category_id = catid;
|
||||
last_update = now;
|
||||
ar = new AuditRecord(AuditRecord.COMMUNITY_CATEGORY,user.realUID(),user.userRemoteAddress(),cid,
|
||||
"catid=" + catid);
|
||||
ar = outer.newAudit(AuditRecord.COMMUNITY_CATEGORY,"catid=" + catid);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -852,8 +819,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -868,7 +834,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE sigs SET synopsis = ");
|
||||
sql.append(SQLUtil.encodeStringArg(synopsis)).append(", lastupdate = '");
|
||||
|
@ -887,8 +853,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -903,7 +868,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE sigs SET language = '");
|
||||
sql.append(SQLUtil.encodeString(language)).append("', lastupdate = '");
|
||||
|
@ -922,8 +887,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -938,7 +902,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE sigs SET rules = ");
|
||||
sql.append(SQLUtil.encodeStringArg(rules)).append(", lastupdate = '");
|
||||
|
@ -957,8 +921,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -973,7 +936,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE sigs SET lastaccess = '");
|
||||
java.util.Date now = new java.util.Date();
|
||||
|
@ -990,8 +953,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1009,7 +971,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end getHideSearch
|
||||
|
||||
public synchronized void setHideFlags(UserBackend user, boolean directory, boolean search)
|
||||
public synchronized void setHideFlags(EnvCommunity outer, boolean directory, boolean search)
|
||||
throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
|
@ -1020,7 +982,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE sigs SET hide_dir = ");
|
||||
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_search = search;
|
||||
last_update = now;
|
||||
ar = new AuditRecord(AuditRecord.COMMUNITY_HIDE_INFO,user.realUID(),user.userRemoteAddress(),cid,
|
||||
"dir=" + directory + ",search=" + search);
|
||||
ar = outer.newAudit(AuditRecord.COMMUNITY_HIDE_INFO,"dir=" + directory + ",search=" + search);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -1055,8 +1016,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1068,7 +1028,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end getMembersOnly
|
||||
|
||||
public synchronized void setMembersOnly(UserBackend user, boolean flag) throws DataException
|
||||
public synchronized void setMembersOnly(EnvCommunity outer, boolean flag) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This community has been deleted.");
|
||||
|
@ -1078,7 +1038,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE sigs SET membersonly = ");
|
||||
sql.append(flag ? '1' : '0').append(", lastupdate = '");
|
||||
|
@ -1087,8 +1047,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
stmt.executeUpdate(sql.toString());
|
||||
members_only = flag;
|
||||
last_update = now;
|
||||
ar = new AuditRecord(AuditRecord.COMMUNITY_MEMBERS_ONLY,user.realUID(),user.userRemoteAddress(),cid,
|
||||
"flag=" + flag);
|
||||
ar = outer.newAudit(AuditRecord.COMMUNITY_MEMBERS_ONLY,"flag=" + flag);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -1111,8 +1070,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1133,7 +1091,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE sigs SET init_ftr = ");
|
||||
sql.append(ndx).append(", lastupdate = '");
|
||||
|
@ -1152,8 +1110,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1168,7 +1125,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT joinkey FROM sigs WHERE sigid = ");
|
||||
sql.append(cid).append(';');
|
||||
|
@ -1191,14 +1148,13 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end getJoinKey
|
||||
|
||||
public synchronized void setJoinKey(UserBackend user, String key) throws DataException
|
||||
public synchronized void setJoinKey(EnvCommunity outer, String key) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This community has been deleted.");
|
||||
|
@ -1208,7 +1164,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE sigs SET joinkey = ");
|
||||
sql.append(SQLUtil.encodeStringArg(key)).append(", lastupdate = '");
|
||||
|
@ -1217,7 +1173,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
stmt.executeUpdate(sql.toString());
|
||||
public_comm = StringUtil.isStringEmpty(key);
|
||||
last_update = now;
|
||||
ar = new AuditRecord(AuditRecord.COMMUNITY_JOIN_KEY,user.realUID(),user.userRemoteAddress(),cid);
|
||||
ar = outer.newAudit(AuditRecord.COMMUNITY_JOIN_KEY);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -1240,8 +1196,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1277,7 +1232,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // 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
|
||||
{
|
||||
if (deleted)
|
||||
|
@ -1288,7 +1243,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// create the SQL statement
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -1311,7 +1266,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
last_update = now;
|
||||
|
||||
// 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
|
||||
catch (SQLException e)
|
||||
|
@ -1334,8 +1289,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1347,7 +1301,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // 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
|
||||
{
|
||||
if (deleted)
|
||||
|
@ -1358,7 +1312,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
boolean did_it = false;
|
||||
stmt.executeUpdate("LOCK TABLES sigmember WRITE;");
|
||||
|
@ -1411,8 +1365,8 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
if (did_it)
|
||||
{ // update the community data and generate an audit record
|
||||
touchUpdate(conn);
|
||||
ar = new AuditRecord(AuditRecord.SET_MEMBERSHIP,user.realUID(),user.userRemoteAddress(),cid,
|
||||
"uid=" + uid,"level=" + grant_level);
|
||||
ar = outer.newAudit(AuditRecord.SET_MEMBERSHIP,"uid=" + uid,"level=" + grant_level);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end try
|
||||
|
@ -1436,8 +1390,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1452,7 +1405,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection and create the appropriate SELECT statement
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM sigmember WHERE sigid = ");
|
||||
sql.append(cid);
|
||||
|
@ -1476,8 +1429,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1487,7 +1439,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
{
|
||||
if (deleted)
|
||||
return false;
|
||||
int ndx = engine.getFeatureIndexBySymbol(symbol);
|
||||
int ndx = env.getEngine().getFeatureIndexBySymbol(symbol);
|
||||
if (ndx>=0)
|
||||
return features.get(ndx);
|
||||
else
|
||||
|
@ -1530,23 +1482,22 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // 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)
|
||||
throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This community has been deleted.");
|
||||
|
||||
ReturnConfSeq rcs = ConferenceCoreData.createConference(engine,comm,datapool,name,alias,description,
|
||||
pvt,hide_list,host_uid);
|
||||
ReturnConfSeq rcs = ConferenceCoreData.createConference(outer,env,name,alias,description,pvt,hide_list,
|
||||
host_uid);
|
||||
ConferenceData cdata = rcs.getConference();
|
||||
if (comm.realUID()!=host_uid) // make the creating user a conference host too
|
||||
cdata.setMembership(comm,comm.realUID(),DefaultLevels.hostConference());
|
||||
if (outer.getUserID()!=host_uid) // make the creating user a conference host too
|
||||
cdata.setMembership(outer,outer.getUserID(),DefaultLevels.hostConference());
|
||||
|
||||
// Wrap the returned ConferenceData object in a ConferenceCommunityContextImpl object and release the
|
||||
// extra reference on it.
|
||||
// Wrap the returned ConferenceData object in a ConferenceCommunityContextImpl object.
|
||||
ConferenceCommunityContextImpl conf =
|
||||
new ConferenceCommunityContextImpl(engine,this,datapool,rcs.getSequence(),hide_list,cdata);
|
||||
new ConferenceCommunityContextImpl(env,rcs.getSequence(),hide_list,cdata);
|
||||
rcs = null;
|
||||
|
||||
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
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create a new SQL statement
|
||||
|
@ -1651,8 +1602,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1674,7 +1624,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
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 = ");
|
||||
|
@ -1746,8 +1696,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1766,7 +1715,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create a new SQL statement
|
||||
|
@ -1804,8 +1753,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1825,7 +1773,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// a relatively simple search
|
||||
|
@ -1848,14 +1796,13 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end getMemberLevel
|
||||
|
||||
public void delete(UserBackend user) throws DataException
|
||||
public void delete(EnvCommunity outer) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This community has been deleted.");
|
||||
|
@ -1869,7 +1816,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// lock the tables we need to reference immediately
|
||||
|
@ -1914,7 +1861,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
} // end finally
|
||||
|
||||
// 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
|
||||
catch (SQLException e)
|
||||
|
@ -1937,14 +1884,13 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
// 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,
|
||||
conf_max,conf_objcache);
|
||||
BackgroundCommunityPurge purger = new BackgroundCommunityPurge(outer,cid,conf_count,conf_max,
|
||||
conf_objcache);
|
||||
Thread thrd = new Thread(purger);
|
||||
thrd.setPriority(Thread.NORM_PRIORITY-1);
|
||||
thrd.start();
|
||||
|
@ -2002,13 +1948,12 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static CommunityData createCommunity(EngineBackend engine, UserBackend user, DataPool datapool, String name,
|
||||
String alias, int host_uid, String language, String synopsis,
|
||||
String rules, String joinkey, boolean hide_dir, boolean hide_search)
|
||||
throws DataException, AccessError
|
||||
static CommunityData createCommunity(EnvUser env, String name, String alias, int host_uid, String language,
|
||||
String synopsis, String rules, String joinkey, boolean hide_dir,
|
||||
boolean hide_search) throws DataException, AccessError
|
||||
{
|
||||
Connection conn = null; // database connection
|
||||
BitSet def_features = engine.getDefaultFeaturesMask();
|
||||
BitSet def_features = env.getEngine().getDefaultFeaturesMask();
|
||||
int new_cid; // ID of the new community
|
||||
java.util.Date creation; // creation date!
|
||||
AuditRecord ar = null; // the audit record
|
||||
|
@ -2016,7 +1961,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
try
|
||||
{ // get a database connection and create the appropriate SELECT statement
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
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
|
||||
// community data object cache.
|
||||
comm = new CommunityCoreData(engine,datapool,new_cid,creation,name,alias,host_uid,language,synopsis,
|
||||
rules,joinkey,hide_dir,hide_search,def_features);
|
||||
comm = new CommunityCoreData(env,new_cid,creation,name,alias,host_uid,language,synopsis,rules,joinkey,
|
||||
hide_dir,hide_search,def_features);
|
||||
comm.newProperties(conn);
|
||||
|
||||
} // end try
|
||||
|
@ -2112,10 +2057,10 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end finally
|
||||
|
||||
engine.registerNewCommunity(comm);
|
||||
env.getEngine().registerNewCommunity(comm);
|
||||
|
||||
// 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);
|
||||
|
||||
} // end try
|
||||
|
@ -2139,8 +2084,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -21,11 +21,12 @@ import java.sql.*;
|
|||
import java.util.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.security.AuditRecord;
|
||||
import com.silverwrist.venice.security.Capability;
|
||||
import com.silverwrist.venice.security.DefaultLevels;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
||||
{
|
||||
|
@ -72,9 +73,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private EngineBackend engine; // pointer to the engine back end
|
||||
private UserBackend user; // pointer to the user back end
|
||||
private DataPool datapool; // pointer to the main data pool
|
||||
private EnvCommunity env; // the environment
|
||||
private int cid; // ID of the underlying community
|
||||
private int level; // access level we have to 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,
|
||||
int granted_level, boolean locked, String name, String alias)
|
||||
protected CommunityUserContextImpl(EnvUser env, int cid, int granted_level, boolean locked, String name,
|
||||
String alias)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("CommunityUserContextImpl constructor:member");
|
||||
this.engine = engine;
|
||||
this.user = user;
|
||||
this.datapool = datapool;
|
||||
this.env = new EnvCommunity(env,this);
|
||||
this.cid = cid;
|
||||
setMemberValues(granted_level,true,locked);
|
||||
this.cache = new CommunitySimpleDataCache(name,alias);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CommunityUserContextImpl(EngineBackend engine, UserBackend user, DataPool datapool, int cid,
|
||||
String name, String alias)
|
||||
protected CommunityUserContextImpl(EnvUser env, int cid, String name, String alias)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("CommunityUserContextImpl constructor:ordinary");
|
||||
this.engine = engine;
|
||||
this.user = user;
|
||||
this.datapool = datapool;
|
||||
this.env = new EnvCommunity(env,this);
|
||||
this.cid = cid;
|
||||
this.level = user.realBaseLevel();
|
||||
this.level = env.getUser().realBaseLevel();
|
||||
this.is_member = false;
|
||||
this.show_admin = false;
|
||||
this.locked = false;
|
||||
|
@ -120,13 +114,11 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end constructor
|
||||
|
||||
CommunityUserContextImpl(EngineBackend engine, UserBackend user, DataPool datapool, CommunityData data)
|
||||
CommunityUserContextImpl(EnvUser env, CommunityData data)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("CommunityUserContextImpl constructor:newCommunity");
|
||||
this.engine = engine;
|
||||
this.user = user;
|
||||
this.datapool = datapool;
|
||||
this.env = new EnvCommunity(env,this);
|
||||
this.cid = data.getID();
|
||||
this.cache = null; // no cache required - we have the CommunityData
|
||||
this.data = data;
|
||||
|
@ -145,10 +137,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
logger.debug("setMemberValues(" + String.valueOf(granted_level) + ", " + String.valueOf(member)
|
||||
+ ", " + String.valueOf(locked) + ")");
|
||||
|
||||
if (user.realBaseLevel()>granted_level)
|
||||
this.level = user.realBaseLevel();
|
||||
else
|
||||
this.level = granted_level;
|
||||
this.level = Math.max(env.getUser().realBaseLevel(),granted_level);
|
||||
this.is_member = member;
|
||||
this.show_admin = Capability.isCommunityAdmin(granted_level);
|
||||
this.locked = locked;
|
||||
|
@ -161,9 +150,9 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
{ // attempt to load the CommunityData object
|
||||
if (deleted)
|
||||
throw new DataException("This community has been deleted.");
|
||||
data = engine.getCommunityDataObject(cid);
|
||||
data = env.getEngine().getCommunityDataObject(cid);
|
||||
if (data!=null)
|
||||
user.saveMRU("community",data);
|
||||
env.getUser().saveMRU("community",data);
|
||||
|
||||
// clear cache when we get the real data
|
||||
cache = null;
|
||||
|
@ -182,9 +171,9 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
return null; // we're deleted
|
||||
try
|
||||
{ // attempt to load the CommunityDataObject
|
||||
data = engine.getCommunityDataObject(cid);
|
||||
data = env.getEngine().getCommunityDataObject(cid);
|
||||
if (data!=null)
|
||||
user.saveMRU("community",data);
|
||||
env.getUser().saveMRU("community",data);
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
|
@ -216,7 +205,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end if
|
||||
|
||||
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!
|
||||
logger.error("user not permitted to read confs from this community");
|
||||
throw new AccessError("You are not permitted to access this community's conferences.");
|
||||
|
@ -225,8 +214,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end testConferenceAccess
|
||||
|
||||
private static CommunityUserContextImpl getCommunityPrivate(EngineBackend engine, UserBackend user,
|
||||
DataPool datapool, Connection conn, int cid)
|
||||
private static CommunityUserContextImpl getCommunityPrivate(EnvUser env, Connection conn, int cid)
|
||||
throws DataException
|
||||
{
|
||||
try
|
||||
|
@ -243,8 +231,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end if
|
||||
|
||||
// initialize the object and check membership info
|
||||
CommunityUserContextImpl sc = new CommunityUserContextImpl(engine,user,datapool,cid,
|
||||
rs.getString(1),rs.getString(2));
|
||||
CommunityUserContextImpl sc = new CommunityUserContextImpl(env,cid,rs.getString(1),rs.getString(2));
|
||||
sc.checkMembership(conn);
|
||||
return sc;
|
||||
|
||||
|
@ -339,8 +326,8 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
{
|
||||
if (deleted)
|
||||
throw new DataException("This community has been deleted.");
|
||||
return new CategoryDescriptorImpl(datapool,getData().getCategoryID(),
|
||||
Capability.hideHiddenCategories(user.realBaseLevel()));
|
||||
return new CategoryDescriptorImpl(env,getData().getCategoryID(),
|
||||
Capability.hideHiddenCategories(env.getUser().realBaseLevel()));
|
||||
|
||||
} // end getCategory
|
||||
|
||||
|
@ -373,11 +360,11 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// load the profile for the user
|
||||
return new UserProfileImpl(engine,user,conn,getData().getHostUID(),
|
||||
Capability.canSeeHiddenContactFields(user.realBaseLevel()));
|
||||
return new UserProfileImpl(env,conn,getData().getHostUID(),
|
||||
Capability.canSeeHiddenContactFields(env.getUser().realBaseLevel()));
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -387,8 +374,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -463,7 +449,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
int id = getData().getContactID();
|
||||
ContactInfo rc;
|
||||
if (id>=0)
|
||||
rc = new ContactInfoImpl(datapool,id);
|
||||
rc = new ContactInfoImpl(env,id);
|
||||
else
|
||||
rc = new ContactInfoImpl(getData().getHostUID(),cid);
|
||||
getData().touch();
|
||||
|
@ -489,7 +475,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end if
|
||||
|
||||
getData().putContactInfo(user,ci);
|
||||
getData().putContactInfo(env,ci);
|
||||
|
||||
} // end putContactInfo
|
||||
|
||||
|
@ -515,7 +501,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
// Adjust the "mask"...this function cannot affect the set of "locked" features.
|
||||
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.
|
||||
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
|
||||
// the "back end" class.
|
||||
new_features.or(update_bits);
|
||||
getData().putFeatureSet(user,new_features);
|
||||
getData().putFeatureSet(env,new_features);
|
||||
|
||||
} // end setFeatures
|
||||
|
||||
|
@ -562,7 +548,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end if
|
||||
|
||||
getData().setName(user,name);
|
||||
getData().setName(env,name);
|
||||
|
||||
} // end setName
|
||||
|
||||
|
@ -576,7 +562,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end if
|
||||
|
||||
getData().setAlias(user,alias);
|
||||
getData().setAlias(env,alias);
|
||||
|
||||
} // end setAlias
|
||||
|
||||
|
@ -597,7 +583,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end if
|
||||
|
||||
getData().setCategoryID(user,catid);
|
||||
getData().setCategoryID(env,catid);
|
||||
|
||||
} // end setCategoryID
|
||||
|
||||
|
@ -689,7 +675,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
boolean hide_dir = (mode!=HIDE_NONE);
|
||||
boolean hide_search = (mode==HIDE_BOTH);
|
||||
getData().setHideFlags(user,hide_dir,hide_search);
|
||||
getData().setHideFlags(env,hide_dir,hide_search);
|
||||
|
||||
} // end setHideMode
|
||||
|
||||
|
@ -720,7 +706,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end if
|
||||
|
||||
getData().setMembersOnly(user,flag);
|
||||
getData().setMembersOnly(env,flag);
|
||||
|
||||
} // end setMembersOnly
|
||||
|
||||
|
@ -736,7 +722,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
public void setInitialFeatureIndex(short ndx) throws DataException, AccessError
|
||||
{
|
||||
if (!(engine.isValidInitialFeatureIndex(ndx)))
|
||||
if (!(env.getEngine().isValidInitialFeatureIndex(ndx)))
|
||||
{ // the mode is not valid
|
||||
logger.error("feature index value " + String.valueOf(ndx) + " is not valid");
|
||||
throw new IllegalArgumentException("invalid initial feature index");
|
||||
|
@ -786,7 +772,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end if
|
||||
|
||||
getData().setJoinKey(user,key);
|
||||
getData().setJoinKey(env,key);
|
||||
|
||||
} // end setJoinKey
|
||||
|
||||
|
@ -905,7 +891,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end if
|
||||
|
||||
getData().setSecurityLevels(user,read,write,create,delete,join);
|
||||
getData().setSecurityLevels(env,read,write,create,delete,join);
|
||||
|
||||
} // end setSecurityLevels
|
||||
|
||||
|
@ -958,7 +944,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end if
|
||||
|
||||
if (!(getData().canJoinCommunity(user.realUID(),level)))
|
||||
if (!(getData().canJoinCommunity(env.getUserID(),level)))
|
||||
{ // this user can't join up!
|
||||
logger.error("user not permitted to join 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
|
||||
|
||||
// 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
|
||||
setMemberValues(DefaultLevels.memberCommunity(),true,false);
|
||||
|
@ -1013,7 +999,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end if
|
||||
|
||||
// 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
|
||||
setMemberValues(-1,false,false);
|
||||
|
@ -1038,7 +1024,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
return false;
|
||||
CommunityData d = getDataNE();
|
||||
if (d!=null)
|
||||
return d.canJoinCommunity(user.realUID(),level);
|
||||
return d.canJoinCommunity(env.getUserID(),level);
|
||||
else
|
||||
return false;
|
||||
|
||||
|
@ -1047,21 +1033,21 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
public List getConferences() throws DataException, AccessError
|
||||
{
|
||||
testConferenceAccess();
|
||||
return ConferenceUserContextImpl.getCommunityConferences(engine,this,datapool);
|
||||
return ConferenceUserContextImpl.getCommunityConferences(env);
|
||||
|
||||
} // end getConferences
|
||||
|
||||
public ConferenceContext getConferenceContext(int confid) throws DataException, AccessError
|
||||
{
|
||||
testConferenceAccess();
|
||||
return ConferenceUserContextImpl.getConference(engine,this,datapool,confid);
|
||||
return ConferenceUserContextImpl.getConference(env,confid);
|
||||
|
||||
} // end getConferenceContext
|
||||
|
||||
public ConferenceContext getConferenceContext(String alias) throws DataException, AccessError
|
||||
{
|
||||
testConferenceAccess();
|
||||
return ConferenceUserContextImpl.getConference(engine,this,datapool,alias);
|
||||
return ConferenceUserContextImpl.getConference(env,alias);
|
||||
|
||||
} // end getConferenceContext
|
||||
|
||||
|
@ -1084,10 +1070,10 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end if
|
||||
|
||||
// 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
|
||||
return new ConferenceUserContextImpl(engine,this,datapool,cdata);
|
||||
return new ConferenceUserContextImpl(env,cdata);
|
||||
|
||||
} // end createConference
|
||||
|
||||
|
@ -1160,9 +1146,9 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end if
|
||||
|
||||
// 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);
|
||||
|
||||
} // end setMembership
|
||||
|
@ -1190,8 +1176,8 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end if
|
||||
|
||||
// call the methods required to delete the community
|
||||
my_comm.delete(user);
|
||||
engine.detachCommunityDataObject(cid);
|
||||
my_comm.delete(env);
|
||||
env.getEngine().detachCommunityDataObject(cid);
|
||||
|
||||
// flag that we've been deleted
|
||||
cache = null;
|
||||
|
@ -1205,14 +1191,14 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
public void sendInvitation(String address, String personal_message)
|
||||
throws AccessError, DataException, EmailException
|
||||
{
|
||||
if (user.userIsAnonymous())
|
||||
if (env.getUser().userIsAnonymous())
|
||||
throw new AccessError("You must be logged in to send an invitation.");
|
||||
|
||||
CommunityData my_comm = getData();
|
||||
my_comm.testMembership(level,is_member);
|
||||
|
||||
// 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);
|
||||
vars.put("community.name",my_comm.getName());
|
||||
subject = StringUtil.replaceAllVariables(subject,vars);
|
||||
|
@ -1220,10 +1206,10 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
// Prepare the message text to be sent to the user.
|
||||
String msg;
|
||||
if (my_comm.isPublicCommunity())
|
||||
msg = engine.getStockMessage("invite-public");
|
||||
msg = env.getEngine().getStockMessage("invite-public");
|
||||
else
|
||||
{ // 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());
|
||||
|
||||
} // end else
|
||||
|
@ -1231,16 +1217,16 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
// Set the remaining variables and replace them.
|
||||
vars.put("community.alias",my_comm.getAlias());
|
||||
vars.put("personal",personal_message);
|
||||
vars.put("fullname",user.realFullName());
|
||||
String uname = user.realUserName();
|
||||
vars.put("fullname",env.getUser().realFullName());
|
||||
String uname = env.getUser().realUserName();
|
||||
vars.put("username",uname);
|
||||
msg = StringUtil.replaceAllVariables(msg,vars);
|
||||
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.
|
||||
SimpleEmailer em = engine.createEmailer();
|
||||
em.setFrom(uname,user.realEmailAddress());
|
||||
// Get a Emailer object, set it up, and send it.
|
||||
Emailer em = env.getEngine().createEmailer();
|
||||
em.setFrom(uname,env.getUser().realEmailAddress());
|
||||
em.setTo(address);
|
||||
em.setSubject(subject);
|
||||
em.setText(msg_buf.toString());
|
||||
|
@ -1250,7 +1236,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
public boolean canSendInvitation()
|
||||
{
|
||||
if (user.userIsAnonymous())
|
||||
if (env.getUser().userIsAnonymous())
|
||||
return false;
|
||||
CommunityData d = getDataNE();
|
||||
if (d==null)
|
||||
|
@ -1275,7 +1261,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
try
|
||||
{ // 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);
|
||||
|
||||
} // end try
|
||||
|
@ -1288,7 +1274,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1312,7 +1298,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool and get the audit records
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
rc = AuditRecord.getAuditRecordCount(conn,cid);
|
||||
|
||||
} // end try
|
||||
|
@ -1325,7 +1311,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1363,65 +1349,6 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // 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
|
||||
*--------------------------------------------------------------------------------
|
||||
|
@ -1498,30 +1425,29 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static List getMemberCommunityEntries(EngineBackend engine, UserBackend user, DataPool datapool)
|
||||
throws DataException
|
||||
static List getMemberCommunityEntries(EnvUser env) throws DataException
|
||||
{
|
||||
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
|
||||
Connection conn = null; // pooled database connection
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
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 "
|
||||
+ "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());
|
||||
while (rs.next())
|
||||
{ // create the user contexts and add them to the return vector
|
||||
int the_cid = rs.getInt(1);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("...found community #" + the_cid);
|
||||
CommunityContext tmp = new CommunityUserContextImpl(engine,user,datapool,the_cid,rs.getInt(2),
|
||||
rs.getBoolean(3),rs.getString(4),rs.getString(5));
|
||||
CommunityContext tmp = new CommunityUserContextImpl(env,the_cid,rs.getInt(2),rs.getBoolean(3),
|
||||
rs.getString(4),rs.getString(5));
|
||||
rc.add(tmp);
|
||||
|
||||
} // end while
|
||||
|
@ -1535,8 +1461,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1544,17 +1469,16 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end getMemberCommunityEntries
|
||||
|
||||
static CommunityContext getCommunityContext(EngineBackend engine, UserBackend user, DataPool datapool,
|
||||
int cid) throws DataException
|
||||
static CommunityContext getCommunityContext(EnvUser env, int cid) throws DataException
|
||||
{
|
||||
Connection conn = null; // pooled database connection
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// return the community we want
|
||||
return getCommunityPrivate(engine,user,datapool,conn,cid);
|
||||
return getCommunityPrivate(env,conn,cid);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -1565,21 +1489,19 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end getCommunityContext
|
||||
|
||||
static CommunityContext getCommunityContext(EngineBackend engine, UserBackend user, DataPool datapool,
|
||||
String alias) throws DataException
|
||||
static CommunityContext getCommunityContext(EnvUser env, String alias) throws DataException
|
||||
{
|
||||
Connection conn = null; // pooled database connection
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// create the query to find the community in the table
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -1594,8 +1516,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end if
|
||||
|
||||
// initialize the object and check membership info
|
||||
CommunityUserContextImpl c = new CommunityUserContextImpl(engine,user,datapool,rs.getInt(1),
|
||||
rs.getString(2),alias);
|
||||
CommunityUserContextImpl c = new CommunityUserContextImpl(env,rs.getInt(1),rs.getString(2),alias);
|
||||
c.checkMembership(conn);
|
||||
return c;
|
||||
|
||||
|
@ -1608,22 +1529,20 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end getCommunityContext
|
||||
|
||||
static CommunityBackend getCommunityBackend(EngineBackend engine, UserBackend user, DataPool datapool,
|
||||
Connection conn, int cid) throws DataException
|
||||
static CommunityBackend getCommunityBackend(EnvUser env, Connection conn, int cid) throws DataException
|
||||
{
|
||||
return getCommunityPrivate(engine,user,datapool,conn,cid);
|
||||
return getCommunityPrivate(env,conn,cid);
|
||||
|
||||
} // end getCommunityBackend
|
||||
|
||||
static List searchForCommunities(EngineBackend engine, UserBackend user, DataPool datapool, int field,
|
||||
int mode, String term, int offset, int count) throws DataException
|
||||
static List searchForCommunities(EnvUser env, int field, int mode, String term, int offset, int count)
|
||||
throws DataException
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Community search: field = " + field + ", mode = " + mode + ", term '" + term
|
||||
|
@ -1634,7 +1553,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT sigid, signame, alias FROM sigs WHERE ");
|
||||
|
||||
|
@ -1672,7 +1591,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end switch
|
||||
|
||||
if (Capability.hideHiddenSearchCommunities(user.realBaseLevel()))
|
||||
if (Capability.hideHiddenSearchCommunities(env.getUser().realBaseLevel()))
|
||||
sql.append(" AND hide_search = 0");
|
||||
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())
|
||||
{ // load all matching communities into the recordset
|
||||
CommunityUserContextImpl c = new CommunityUserContextImpl(engine,user,datapool,rs.getInt(1),
|
||||
rs.getString(2),rs.getString(3));
|
||||
CommunityUserContextImpl c = new CommunityUserContextImpl(env,rs.getInt(1),rs.getString(2),
|
||||
rs.getString(3));
|
||||
c.checkMembership(conn);
|
||||
CommunityContext tmp = c;
|
||||
rc.add(tmp);
|
||||
|
@ -1701,8 +1620,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1710,7 +1628,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // 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
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
|
@ -1720,7 +1638,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM sigs WHERE ");
|
||||
|
||||
|
@ -1758,7 +1676,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // end switch
|
||||
|
||||
if (Capability.hideHiddenSearchCommunities(user.realBaseLevel()))
|
||||
if (Capability.hideHiddenSearchCommunities(env.getUser().realBaseLevel()))
|
||||
sql.append(" AND hide_search = 0");
|
||||
sql.append(';');
|
||||
|
||||
|
@ -1782,15 +1700,13 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end getSearchCommunityCount
|
||||
|
||||
static List getCommunitiesInCategory(EngineBackend engine, UserBackend user, DataPool datapool, int catid,
|
||||
int offset, int count) throws DataException
|
||||
static List getCommunitiesInCategory(EnvUser env, int catid, int offset, int count) throws DataException
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("reading communities in category " + catid + ", offset = " + offset + ", count = " + count);
|
||||
|
@ -1800,11 +1716,11 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT sigid, signame, alias FROM sigs WHERE catid = ");
|
||||
sql.append(catid);
|
||||
if (Capability.hideHiddenDirectoryCommunities(user.realBaseLevel()))
|
||||
if (Capability.hideHiddenDirectoryCommunities(env.getUser().realBaseLevel()))
|
||||
sql.append(" AND hide_dir = 0");
|
||||
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())
|
||||
{ // load all matching communities into the recordset
|
||||
CommunityUserContextImpl c = new CommunityUserContextImpl(engine,user,datapool,rs.getInt(1),
|
||||
rs.getString(2),rs.getString(3));
|
||||
CommunityUserContextImpl c = new CommunityUserContextImpl(env,rs.getInt(1),rs.getString(2),
|
||||
rs.getString(3));
|
||||
c.checkMembership(conn);
|
||||
CommunityContext tmp = c;
|
||||
rc.add(tmp);
|
||||
|
@ -1833,8 +1749,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1842,7 +1757,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
} // 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())
|
||||
logger.debug("reading communities in category " + catid);
|
||||
|
@ -1851,11 +1766,11 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM sigs WHERE catid = ");
|
||||
sql.append(catid);
|
||||
if (Capability.hideHiddenDirectoryCommunities(user.realBaseLevel()))
|
||||
if (Capability.hideHiddenDirectoryCommunities(env.getUser().realBaseLevel()))
|
||||
sql.append(" AND hide_dir = 0");
|
||||
sql.append(';');
|
||||
|
||||
|
@ -1879,8 +1794,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1895,7 +1809,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
|
|||
{
|
||||
Statement stmt = conn.createStatement();
|
||||
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());
|
||||
if (rs.next())
|
||||
{ // we are a member...
|
||||
|
|
|
@ -20,10 +20,11 @@ package com.silverwrist.venice.core.impl;
|
|||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.htmlcheck.*;
|
||||
import com.silverwrist.venice.security.AuditRecord;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
||||
{
|
||||
|
@ -78,9 +79,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private EngineBackend engine; // engine object reference
|
||||
private CommunityDataBackend comm; // community object reference
|
||||
private DataPool datapool; // data pool object
|
||||
private EnvConferenceCommunity env; // the environment
|
||||
private int confid; // ID of this conference
|
||||
private int level; // level granted in conference to members of the community
|
||||
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,
|
||||
int confid) throws DataException
|
||||
ConferenceCommunityContextImpl(EnvCommunityData env, int confid) throws DataException
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("new ConferenceCommunityContextImpl(#" + String.valueOf(confid) + ") for community # "
|
||||
+ comm.realCommunityID());
|
||||
logger.debug("new ConferenceCommunityContextImpl(#" + confid + ") for community # "
|
||||
+ env.getCommunityID());
|
||||
|
||||
this.engine = engine;
|
||||
this.comm = comm;
|
||||
this.datapool = datapool;
|
||||
this.env = new EnvConferenceCommunity(env);
|
||||
this.confid = confid;
|
||||
|
||||
Connection conn = null; // pooled database connection
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// Build a monster query! This is like the query for retrieving the ConferenceUserContextImpl
|
||||
|
@ -118,7 +114,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
StringBuffer sql =
|
||||
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 = ");
|
||||
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())
|
||||
logger.debug("SQL: " + sql.toString());
|
||||
|
||||
|
@ -126,7 +122,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
ResultSet rs = stmt.executeQuery(sql.toString());
|
||||
if (!(rs.next()))
|
||||
throw new DataException("conference ID#" + confid + " not found in community#"
|
||||
+ comm.realCommunityID());
|
||||
+ env.getCommunityID());
|
||||
|
||||
// fill in the "cache" and "level" indicators
|
||||
this.cache = new ConfCache(rs.getString(2),rs.getString(3),SQLUtil.getFullDateTime(rs,1));
|
||||
|
@ -143,23 +139,19 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end constructor
|
||||
|
||||
ConferenceCommunityContextImpl(EngineBackend engine, CommunityDataBackend comm, DataPool datapool,
|
||||
short sequence, boolean hide_list, ConferenceData cdata)
|
||||
ConferenceCommunityContextImpl(EnvCommunityData env, short sequence, boolean hide_list, ConferenceData cdata)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("new ConferenceCommunityContextImpl(NEW#" + confid + ") for community # "
|
||||
+ comm.realCommunityID());
|
||||
+ env.getCommunityID());
|
||||
|
||||
this.engine = engine;
|
||||
this.comm = comm;
|
||||
this.datapool = datapool;
|
||||
this.env = new EnvConferenceCommunity(env);
|
||||
this.confid = cdata.getID();
|
||||
this.level = 0;
|
||||
this.sequence = sequence;
|
||||
|
@ -180,7 +172,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
{ // attempt to load the ConferenceCommunityContext
|
||||
if (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
|
||||
cache = null;
|
||||
|
@ -200,7 +192,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
try
|
||||
{ // attempt to load the ConferenceCommunityContext
|
||||
confdata = engine.getConferenceDataObject(confid);
|
||||
confdata = env.getEngine().getConferenceDataObject(confid);
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
|
@ -384,16 +376,16 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
} // 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
|
||||
{
|
||||
getConferenceData().setSecurityLevels(comm,read,post,create,hide,nuke,change,delete);
|
||||
getConferenceData().setSecurityLevels(outer,read,post,create,hide,nuke,change,delete);
|
||||
|
||||
} // 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
|
||||
|
||||
|
@ -403,25 +395,25 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
} // 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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
public synchronized void setCommunityGrantedLevel(CommunityBackend comm, int new_level) throws DataException
|
||||
public synchronized void setCommunityGrantedLevel(EnvCommunity outer, int new_level) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This conference has been deleted.");
|
||||
|
@ -431,12 +423,12 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// create the SQL statement
|
||||
Statement stmt = conn.createStatement();
|
||||
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(';');
|
||||
|
||||
// execute the update
|
||||
|
@ -446,8 +438,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
level = new_level;
|
||||
|
||||
// create an audit record reflecting the change
|
||||
ar = new AuditRecord(AuditRecord.CONF_SECURITY,comm.realUID(),comm.userRemoteAddress(),
|
||||
comm.realCommunityID(),"conf=" + confid);
|
||||
ar = outer.newAudit(AuditRecord.CONF_SECURITY,"conf=" + confid);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -470,8 +461,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -492,12 +482,12 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// create the SQL statement
|
||||
Statement stmt = conn.createStatement();
|
||||
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(';');
|
||||
|
||||
// execute the update
|
||||
|
@ -515,8 +505,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -528,7 +517,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
} // end getHideList
|
||||
|
||||
public void setHideList(CommunityBackend comm, boolean flag) throws DataException
|
||||
public void setHideList(EnvCommunity outer, boolean flag) throws DataException
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("setHideList(conf #" + confid + ", " + flag + ")");
|
||||
|
@ -552,12 +541,12 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// create the SQL statement
|
||||
Statement stmt = conn.createStatement();
|
||||
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(';');
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("SQL: " + sql.toString());
|
||||
|
@ -569,8 +558,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
hide_list = flag;
|
||||
|
||||
// create an audit record reflecting the change
|
||||
ar = new AuditRecord(AuditRecord.CONF_SECURITY,comm.realUID(),comm.userRemoteAddress(),
|
||||
comm.realCommunityID(),"conf=" + confid);
|
||||
ar = outer.newAudit(AuditRecord.CONF_SECURITY,"conf=" + confid);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -593,8 +581,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -618,7 +605,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
} // 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
|
||||
{
|
||||
ConferenceData d = getConferenceData();
|
||||
|
@ -627,9 +614,10 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
try
|
||||
{ // 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",
|
||||
new PostLinkDecoderContext(comm.realCommunityAlias(),conf_alias,new_topic));
|
||||
new PostLinkDecoderContext(outer.getCommunity().realCommunityAlias(),conf_alias,
|
||||
new_topic));
|
||||
|
||||
try
|
||||
{ // run through the HTML checker
|
||||
|
@ -645,7 +633,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
try
|
||||
{ // 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
|
||||
catch (NotYetFinishedException e)
|
||||
|
@ -727,7 +715,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
} // end canDeleteConference
|
||||
|
||||
public void delete(UserBackend user) throws DataException
|
||||
public void delete(EnvCommunity outer) throws DataException
|
||||
{
|
||||
ConferenceData c = getConferenceData();
|
||||
Connection conn = null;
|
||||
|
@ -735,12 +723,12 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// see if we have to delete the core object as well
|
||||
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());
|
||||
if (rs.next())
|
||||
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
|
||||
sql.setLength(0);
|
||||
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());
|
||||
|
||||
// record that we've been deleted
|
||||
|
@ -767,15 +755,14 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
if (delete_core)
|
||||
{ // the conference is not linked to any other communities - we need to delete the core as well
|
||||
c.delete(user,comm.realCommunityID());
|
||||
engine.detachConferenceDataObject(confid);
|
||||
c.delete(outer);
|
||||
env.getEngine().detachConferenceDataObject(confid);
|
||||
|
||||
} // end if
|
||||
|
||||
|
|
|
@ -21,10 +21,11 @@ import java.sql.*;
|
|||
import java.util.*;
|
||||
import org.apache.log4j.*;
|
||||
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.security.AuditRecord;
|
||||
import com.silverwrist.venice.security.DefaultLevels;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
class ConferenceCoreData implements ConferenceData
|
||||
{
|
||||
|
@ -48,8 +49,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private EngineBackend engine; // pointer to engine back end
|
||||
private DataPool datapool; // pointer to data pool
|
||||
private EnvConferenceData env; // the environment
|
||||
private int confid; // ID 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
|
||||
|
@ -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())
|
||||
logger.debug("new ConferenceCoreData for conference " + confid);
|
||||
this.engine = engine;
|
||||
this.datapool = datapool;
|
||||
this.env = new EnvConferenceData(env);
|
||||
this.confid = confid;
|
||||
|
||||
Connection conn = null;
|
||||
|
||||
try
|
||||
{ // get a database connection from this object
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// get the conference basic data from the database
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -108,20 +107,18 @@ class ConferenceCoreData implements ConferenceData
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected ConferenceCoreData(EngineBackend engine, CommunityDataBackend comm, DataPool datapool, int confid,
|
||||
java.util.Date created, boolean pvt, String name, String descr)
|
||||
protected ConferenceCoreData(EnvCommunityData env, int confid, java.util.Date created, boolean pvt,
|
||||
String name, String descr)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("new ConferenceCoreData for NEW conference " + confid);
|
||||
this.engine = engine;
|
||||
this.datapool = datapool;
|
||||
this.env = new EnvConferenceData(env);
|
||||
this.confid = confid;
|
||||
this.create_date = created;
|
||||
this.last_update = null;
|
||||
|
@ -136,7 +133,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
this.name = name;
|
||||
this.description = descr;
|
||||
this.flags = new OptionSet();
|
||||
if (comm.getParamBoolean(CommunityDataBackend.BP_POSTPICTURES))
|
||||
if (env.getCommunityData().getParamBoolean(CommunityDataBackend.BP_POSTPICTURES))
|
||||
flags.set(BP_POSTPICTURES);
|
||||
|
||||
} // end constructor
|
||||
|
@ -219,7 +216,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
Connection conn = null;
|
||||
try
|
||||
{ // get a connection and create a statement
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer();
|
||||
|
||||
|
@ -241,8 +238,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -318,7 +314,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection from this object
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// get a list of all aliases
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -339,8 +335,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -358,7 +353,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection from this object
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// get a list of all hosts (with user info)
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -388,8 +383,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -471,7 +465,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
} // 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
|
||||
{
|
||||
if (deleted)
|
||||
|
@ -482,7 +476,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// create the SQL statement
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -507,8 +501,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
last_update = now;
|
||||
|
||||
// create an audit record reflecting the change
|
||||
ar = new AuditRecord(AuditRecord.CONF_SECURITY,comm.realUID(),comm.userRemoteAddress(),
|
||||
comm.realCommunityID(),"conf=" + confid);
|
||||
ar = outer.newAudit(AuditRecord.CONF_SECURITY,"conf=" + confid);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -531,14 +524,13 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end setSecurityLevels
|
||||
|
||||
public synchronized void setName(CommunityBackend comm, String val) throws DataException
|
||||
public synchronized void setName(EnvCommunity outer, String val) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This conference has been deleted.");
|
||||
|
@ -548,7 +540,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// create the SQL statement
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -565,8 +557,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
last_update = now;
|
||||
|
||||
// create an audit record reflecting the change
|
||||
ar = new AuditRecord(AuditRecord.CONF_SECURITY,comm.realUID(),comm.userRemoteAddress(),
|
||||
comm.realCommunityID(),"conf=" + confid);
|
||||
ar = outer.newAudit(AuditRecord.CONF_SECURITY,"conf=" + confid);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -589,8 +580,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -605,7 +595,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// create the SQL statement
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -629,14 +619,13 @@ class ConferenceCoreData implements ConferenceData
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end setDescription
|
||||
|
||||
public synchronized void addAlias(CommunityBackend comm, String alias) throws DataException
|
||||
public synchronized void addAlias(EnvCommunity outer, String alias) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This conference has been deleted.");
|
||||
|
@ -646,7 +635,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
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
|
||||
touchUpdate(conn);
|
||||
ar = new AuditRecord(AuditRecord.CONF_ALIAS,comm.realUID(),comm.userRemoteAddress(),
|
||||
comm.realCommunityID(),"conf=" + confid,"add=" + alias);
|
||||
ar = outer.newAudit(AuditRecord.CONF_ALIAS,"conf=" + confid,"add=" + alias);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -704,14 +692,13 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end addAlias
|
||||
|
||||
public synchronized void removeAlias(CommunityBackend comm, String alias) throws DataException
|
||||
public synchronized void removeAlias(EnvCommunity outer, String alias) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This conference has been deleted.");
|
||||
|
@ -721,7 +708,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
boolean did_it = false;
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -768,8 +755,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
touchUpdate(conn);
|
||||
if ((cached_alias!=null) && cached_alias.equals(alias))
|
||||
cached_alias = null; // also release the cached alias and force a re-get
|
||||
ar = new AuditRecord(AuditRecord.CONF_ALIAS,comm.realUID(),comm.userRemoteAddress(),
|
||||
comm.realCommunityID(),"conf=" + confid,"remove=" + alias);
|
||||
ar = outer.newAudit(AuditRecord.CONF_ALIAS,"conf=" + confid,"remove=" + alias);
|
||||
|
||||
} // end if
|
||||
|
||||
|
@ -794,14 +780,13 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // 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)
|
||||
throw new DataException("This conference has been deleted.");
|
||||
|
@ -811,7 +796,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
boolean did_it = false;
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -862,8 +847,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
if (did_it)
|
||||
{ // set the database's update date and generate a new audit record
|
||||
touchUpdate(conn);
|
||||
ar = new AuditRecord(AuditRecord.CONF_MEMBERSHIP,comm.realUID(),comm.userRemoteAddress(),
|
||||
comm.realCommunityID(),"conf=" + confid,"uid=" + uid,"level=" + grant_level);
|
||||
ar = outer.newAudit(AuditRecord.CONF_MEMBERSHIP,"conf=" + confid,"uid=" + uid,"level=" + grant_level);
|
||||
|
||||
} // end if
|
||||
|
||||
|
@ -888,8 +872,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -915,7 +898,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the SQL statement and execute it
|
||||
|
@ -936,14 +919,13 @@ class ConferenceCoreData implements ConferenceData
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // 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
|
||||
{
|
||||
if (deleted)
|
||||
|
@ -957,7 +939,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// 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
|
||||
StringBuffer sql = new StringBuffer("INSERT INTO topics (confid, num, creator_uid, createdate, "
|
||||
+ "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();
|
||||
String now_str = SQLUtil.encodeDate(creation);
|
||||
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
|
||||
sql.setLength(0);
|
||||
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("');");
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("SQL: " + sql.toString());
|
||||
|
@ -1019,9 +1001,8 @@ class ConferenceCoreData implements ConferenceData
|
|||
last_update = creation;
|
||||
|
||||
// create an audit record indicating we were successful
|
||||
ar = new AuditRecord(AuditRecord.CREATE_TOPIC,comm.realUID(),comm.userRemoteAddress(),
|
||||
comm.realCommunityID(),"confid=" + confid,"num=" + new_topic_num,
|
||||
"title=" + title);
|
||||
ar = outer.newAudit(AuditRecord.CREATE_TOPIC,"confid=" + confid,"num=" + new_topic_num,
|
||||
"title=" + title);
|
||||
|
||||
} // end try
|
||||
finally
|
||||
|
@ -1052,8 +1033,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1147,7 +1127,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create a new SQL statement
|
||||
|
@ -1182,8 +1162,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1200,7 +1179,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the statement
|
||||
|
@ -1221,8 +1200,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1244,7 +1222,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
} // end canDeleteConference
|
||||
|
||||
public synchronized void delete(UserBackend user, int the_cid) throws DataException
|
||||
public synchronized void delete(EnvCommunity outer) throws DataException
|
||||
{
|
||||
if (deleted)
|
||||
throw new DataException("This conference has been deleted.");
|
||||
|
@ -1255,7 +1233,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// lock tables on the critical stuff that MUST be deleted now
|
||||
|
@ -1298,8 +1276,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
} // end finally
|
||||
|
||||
// create an audit record indicating we were successful
|
||||
ar = new AuditRecord(AuditRecord.DELETE_CONF,user.realUID(),user.userRemoteAddress(),the_cid,
|
||||
"confid=" + confid);
|
||||
ar = outer.newAudit(AuditRecord.DELETE_CONF,"confid=" + confid);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -1322,14 +1299,12 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
// 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,
|
||||
topic_max);
|
||||
BackgroundConferencePurge purger = new BackgroundConferencePurge(env,confid,topic_count,topic_max);
|
||||
Thread thrd = new Thread(purger);
|
||||
thrd.setPriority(Thread.NORM_PRIORITY-1);
|
||||
thrd.start();
|
||||
|
@ -1376,11 +1351,10 @@ class ConferenceCoreData implements ConferenceData
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static ReturnConfSeq createConference(EngineBackend engine, CommunityBackend comm, DataPool datapool,
|
||||
String name, String alias, String description, boolean pvt,
|
||||
boolean hide_list, int host_uid) throws DataException
|
||||
static ReturnConfSeq createConference(EnvCommunity outer, EnvCommunityData env, String name, String alias,
|
||||
String description, boolean pvt, boolean hide_list, int host_uid)
|
||||
throws DataException
|
||||
{
|
||||
CommunityDataBackend data_backend = comm.getDataBackend();
|
||||
Connection conn = null; // database connection
|
||||
AuditRecord ar = null; // audit record
|
||||
int new_confid; // new conference ID
|
||||
|
@ -1393,7 +1367,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
try
|
||||
{ // start by locking all the tables we need
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.executeUpdate("LOCK TABLES confs WRITE, sigtoconf WRITE, confalias WRITE, confmember WRITE, "
|
||||
+ "propconf WRITE;");
|
||||
|
@ -1411,7 +1385,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
// compute our new sequence number
|
||||
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(';');
|
||||
if (logger.isDebugEnabled())
|
||||
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.
|
||||
sql.setLength(0);
|
||||
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(");");
|
||||
if (logger.isDebugEnabled())
|
||||
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
|
||||
// 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);
|
||||
|
||||
} // end try
|
||||
|
@ -1480,11 +1454,10 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
} // end finally
|
||||
|
||||
engine.registerNewConference(conf);
|
||||
env.getEngine().registerNewConference(conf);
|
||||
|
||||
// create an audit record indicating we were successful
|
||||
ar = new AuditRecord(AuditRecord.CREATE_CONF,comm.realUID(),comm.userRemoteAddress(),
|
||||
comm.realCommunityID(),"confid=" + new_confid,"name=" + name,"alias=" + alias);
|
||||
ar = outer.newAudit(AuditRecord.CREATE_CONF,"confid=" + new_confid,"name=" + name,"alias=" + alias);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -1507,8 +1480,7 @@ class ConferenceCoreData implements ConferenceData
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -22,6 +22,7 @@ import java.sql.*;
|
|||
import java.util.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.EnvEngine;
|
||||
import com.silverwrist.venice.db.*;
|
||||
|
||||
class ContactInfoImpl implements ContactInfo, Stashable
|
||||
|
@ -170,11 +171,11 @@ class ContactInfoImpl implements ContactInfo, Stashable
|
|||
/**
|
||||
* 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.
|
||||
* @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())
|
||||
logger.debug("new ContactInfoImpl (loading CID " + contactid + ")");
|
||||
|
@ -182,7 +183,7 @@ class ContactInfoImpl implements ContactInfo, Stashable
|
|||
|
||||
try
|
||||
{ // get a connection and call loadData
|
||||
conn = dp.getConnection();
|
||||
conn = env.getConnection();
|
||||
loadData(conn,contactid);
|
||||
|
||||
} // end try
|
||||
|
@ -194,8 +195,7 @@ class ContactInfoImpl implements ContactInfo, Stashable
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
dp.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.log4j.*;
|
|||
import com.silverwrist.util.IOUtil;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.EnvEngine;
|
||||
|
||||
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 String type;
|
||||
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.type = type;
|
||||
this.length = length;
|
||||
|
@ -91,7 +92,7 @@ class ImageStore implements BinaryData
|
|||
|
||||
try
|
||||
{ // open up a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// Create the SQL we need to retrieve the image.
|
||||
|
@ -126,8 +127,7 @@ class ImageStore implements BinaryData
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // 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())
|
||||
logger.debug("loadImageByID # " + id);
|
||||
|
@ -149,7 +149,7 @@ class ImageStore implements BinaryData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
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());
|
||||
|
||||
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
|
||||
|
||||
|
@ -172,8 +172,7 @@ class ImageStore implements BinaryData
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -204,7 +203,7 @@ class ImageStore implements BinaryData
|
|||
|
||||
} // 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
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
|
@ -214,7 +213,7 @@ class ImageStore implements BinaryData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
return storeNewImage(conn,type,owner,mime,length,data);
|
||||
|
||||
} // end try
|
||||
|
@ -226,8 +225,7 @@ class ImageStore implements BinaryData
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -250,7 +248,7 @@ class ImageStore implements BinaryData
|
|||
|
||||
} // 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
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
|
@ -260,7 +258,7 @@ class ImageStore implements BinaryData
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
replaceImage(conn,imgid,mime,length,data);
|
||||
|
||||
} // end try
|
||||
|
@ -272,8 +270,7 @@ class ImageStore implements BinaryData
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.log4j.*;
|
|||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.EnvEngine;
|
||||
|
||||
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
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private DataPool datapool;
|
||||
private EnvEngine env; // the execution environment
|
||||
private long postid;
|
||||
private long parent;
|
||||
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)
|
||||
{
|
||||
this.datapool = datapool;
|
||||
this.env = env;
|
||||
this.postid = postid;
|
||||
this.parent = parent;
|
||||
this.num = num;
|
||||
|
@ -71,10 +72,10 @@ class PublishedMessageImpl implements TopicMessageContext
|
|||
|
||||
} // 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)
|
||||
{
|
||||
this.datapool = datapool;
|
||||
this.env = env;
|
||||
this.postid = postid;
|
||||
this.parent = parent;
|
||||
this.num = num;
|
||||
|
@ -144,7 +145,7 @@ class PublishedMessageImpl implements TopicMessageContext
|
|||
|
||||
try
|
||||
{ // use a database connection to get the user name
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
creator_cache = quickGetUserName(conn,creator_uid);
|
||||
|
||||
} // end try
|
||||
|
@ -156,8 +157,7 @@ class PublishedMessageImpl implements TopicMessageContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -211,7 +211,7 @@ class PublishedMessageImpl implements TopicMessageContext
|
|||
|
||||
try
|
||||
{ // use a database connection to get the body text
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT data FROM postdata WHERE postid = "
|
||||
|
@ -230,8 +230,7 @@ class PublishedMessageImpl implements TopicMessageContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // 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;
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the statement to retrieve the post information
|
||||
|
@ -351,8 +350,13 @@ class PublishedMessageImpl implements TopicMessageContext
|
|||
// execute the statement!
|
||||
ResultSet rs = stmt.executeQuery(sql.toString());
|
||||
while (rs.next())
|
||||
cache_list.add(new PublishedMessageImpl(datapool,rs.getLong(1),rs.getLong(2),rs.getInt(3),rs.getInt(4),
|
||||
rs.getInt(5),SQLUtil.getFullDateTime(rs,6),rs.getString(7)));
|
||||
{ // create PublishedMessageImpl objects to backfill the cache
|
||||
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
|
||||
catch (SQLException e)
|
||||
|
@ -363,20 +367,19 @@ class PublishedMessageImpl implements TopicMessageContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // 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;
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// How many posts have been published anyway?
|
||||
|
@ -399,7 +402,7 @@ class PublishedMessageImpl implements TopicMessageContext
|
|||
if ((ctr--)<=0)
|
||||
{ // append context, please
|
||||
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));
|
||||
return_list.add(ctxt);
|
||||
|
||||
|
@ -416,8 +419,7 @@ class PublishedMessageImpl implements TopicMessageContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.sql.*;
|
|||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
|
||||
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 DataPool datapool; // the data pool used by this object
|
||||
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.datapool = datapool;
|
||||
this.sequence = sequence;
|
||||
|
||||
} // end constructor
|
||||
|
@ -94,15 +93,15 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor
|
|||
Connection conn = null;
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the datapool
|
||||
conn = datapool.getConnection();
|
||||
{ // retrieve a connection
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the UPDATE statement and just execute it blind (if this sidebox is not in the list,
|
||||
// the UPDATE is a no-op).
|
||||
StringBuffer sql = new StringBuffer("UPDATE sideboxes SET sequence = ");
|
||||
sql.append(seq).append(" WHERE uid = ").append(uid).append(" AND boxid = ").append(parent.getID());
|
||||
sql.append(';');
|
||||
sql.append(seq).append(" WHERE uid = ").append(env.getUserID()).append(" AND boxid = ");
|
||||
sql.append(parent.getID()).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
this.sequence = seq;
|
||||
|
||||
|
@ -115,8 +114,7 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -127,14 +125,14 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor
|
|||
Connection conn = null;
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the datapool
|
||||
conn = datapool.getConnection();
|
||||
{ // retrieve a connection
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the DELETE statement and just execute it blind (if this conference is not in the hotlist,
|
||||
// the DELETE is a no-op).
|
||||
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());
|
||||
|
||||
} // end try
|
||||
|
@ -146,8 +144,7 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -22,8 +22,9 @@ import javax.mail.*;
|
|||
import javax.mail.internet.*;
|
||||
import com.silverwrist.venice.core.EmailException;
|
||||
import com.silverwrist.venice.core.InternalStateError;
|
||||
import com.silverwrist.venice.core.internals.Emailer;
|
||||
|
||||
class SimpleEmailer
|
||||
class SimpleEmailer implements Emailer
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
|
@ -65,7 +66,7 @@ class SimpleEmailer
|
|||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
* Implementations from interface Emailer
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
|
|
@ -24,10 +24,11 @@ import java.util.zip.*;
|
|||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.IOUtil;
|
||||
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.security.AuditRecord;
|
||||
import com.silverwrist.venice.security.Capability;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
class TopicMessageUserContextImpl implements TopicMessageContext
|
||||
{
|
||||
|
@ -45,9 +46,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private EngineBackend engine;
|
||||
private ConferenceBackend conf;
|
||||
private DataPool datapool;
|
||||
private EnvConference env; // the conference environment
|
||||
private long postid;
|
||||
private long parent;
|
||||
private int num;
|
||||
|
@ -71,15 +70,12 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected TopicMessageUserContextImpl(EngineBackend engine, ConferenceBackend conf, DataPool datapool,
|
||||
long postid, long parent, int num, int linecount, int creator_uid,
|
||||
java.util.Date posted, boolean hidden, int scribble_uid,
|
||||
java.util.Date scribble_date, String pseud, int datalen,
|
||||
String filename, String mimetype, int stgmethod)
|
||||
protected TopicMessageUserContextImpl(EnvConference env, long postid, long parent, int num, int linecount,
|
||||
int creator_uid, java.util.Date posted, boolean hidden,
|
||||
int scribble_uid, java.util.Date scribble_date, String pseud,
|
||||
int datalen, String filename, String mimetype, int stgmethod)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.conf = conf;
|
||||
this.datapool = datapool;
|
||||
this.env = env;
|
||||
this.postid = postid;
|
||||
this.parent = parent;
|
||||
this.num = num;
|
||||
|
@ -97,13 +93,10 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
} // end constructor
|
||||
|
||||
TopicMessageUserContextImpl(EngineBackend engine, ConferenceBackend conf, DataPool datapool,
|
||||
long postid, long parent, int num, int linecount, int creator_uid,
|
||||
java.util.Date posted, String pseud)
|
||||
TopicMessageUserContextImpl(EnvConference env, long postid, long parent, int num, int linecount,
|
||||
int creator_uid, java.util.Date posted, String pseud)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.conf = conf;
|
||||
this.datapool = datapool;
|
||||
this.env = env;
|
||||
this.postid = postid;
|
||||
this.parent = parent;
|
||||
this.num = num;
|
||||
|
@ -227,7 +220,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
try
|
||||
{ // use a database connection to get the user name
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
refresh(conn);
|
||||
if (nuked)
|
||||
return null; // post nuked!
|
||||
|
@ -242,8 +235,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -299,7 +291,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
try
|
||||
{ // use a database connection to get the body text
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
refresh(conn);
|
||||
|
||||
if (nuked)
|
||||
|
@ -327,8 +319,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -375,7 +366,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
InputStream rc = null;
|
||||
try
|
||||
{ // open up a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// make sure we have current data
|
||||
refresh(conn);
|
||||
|
@ -451,8 +442,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -462,27 +452,29 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
public boolean canNuke()
|
||||
{
|
||||
return conf.userCanNuke();
|
||||
return env.getConference().userCanNuke();
|
||||
|
||||
} // end canNuke
|
||||
|
||||
public void setHidden(boolean flag) throws DataException, AccessError
|
||||
{
|
||||
if (conf.userIsAnonymous())
|
||||
if (env.getUser().userIsAnonymous())
|
||||
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!
|
||||
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.");
|
||||
|
@ -497,7 +489,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
try
|
||||
{ // open up a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// lock the tables we reference
|
||||
|
@ -526,9 +518,8 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
} // end finally
|
||||
|
||||
// record what we did in an audit record
|
||||
ar = new AuditRecord(AuditRecord.HIDE_MESSAGE,conf.realUID(),conf.userRemoteAddress(),
|
||||
conf.realCommunityID(),"conf=" + conf.realConfID() + ",post=" + postid,
|
||||
flag ? "hide" : "unhide");
|
||||
ar = env.newAudit(AuditRecord.HIDE_MESSAGE,"conf=" + env.getConfID() + ",post=" + postid,
|
||||
flag ? "hide" : "unhide");
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -551,8 +542,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -560,9 +550,9 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
public void scribble() throws DataException, AccessError
|
||||
{
|
||||
if (conf.userIsAnonymous())
|
||||
if (env.getUser().userIsAnonymous())
|
||||
return; // no-op
|
||||
if ((creator_uid!=conf.realUID()) && !(conf.userCanScribble()))
|
||||
if ((creator_uid!=env.getUserID()) && !(env.getConference().userCanScribble()))
|
||||
{ // we can't scribble this post
|
||||
logger.error("trying to scribble post w/o permission!");
|
||||
throw new AccessError("You are not permitted to scribble this message.");
|
||||
|
@ -577,7 +567,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
try
|
||||
{ // open up a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// lock the tables we reference
|
||||
|
@ -590,7 +580,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
// First, set the appropriate "scribbled" information in the "header".
|
||||
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();
|
||||
final String scribble_pseud = "<EM><B>(Scribbled)</B></EM>"; // TODO: configurable option
|
||||
sql.append(SQLUtil.encodeDate(now)).append("', pseud = '").append(scribble_pseud);
|
||||
|
@ -639,12 +629,12 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
sql.setLength(0);
|
||||
sql.append("DELETE FROM postpublish WHERE postid = ").append(postid).append(';');
|
||||
if (stmt.executeUpdate(sql.toString())>0)
|
||||
engine.unpublish(postid);
|
||||
env.getEngine().unpublish(postid);
|
||||
|
||||
// Update our internal data fields.
|
||||
linecount = 0;
|
||||
hidden = false;
|
||||
scribble_uid = conf.realUID();
|
||||
scribble_uid = env.getUserID();
|
||||
scribble_date = now;
|
||||
pseud = scribble_pseud;
|
||||
text_cache = null;
|
||||
|
@ -658,8 +648,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
} // end finally
|
||||
|
||||
// record what we did in an audit record
|
||||
ar = new AuditRecord(AuditRecord.SCRIBBLE_MESSAGE,conf.realUID(),conf.userRemoteAddress(),
|
||||
conf.realCommunityID(),"conf=" + conf.realConfID() + ",post=" + postid);
|
||||
ar = env.newAudit(AuditRecord.SCRIBBLE_MESSAGE,"conf=" + env.getConfID() + ",post=" + postid);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -682,8 +671,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -691,7 +679,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
public void nuke() throws DataException, AccessError
|
||||
{
|
||||
if (!(conf.userCanNuke()))
|
||||
if (!(env.getConference().userCanNuke()))
|
||||
{ // we can't scribble this post
|
||||
logger.error("trying to nuke post w/o permission!");
|
||||
throw new AccessError("You are not permitted to nuke this message.");
|
||||
|
@ -706,7 +694,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
try
|
||||
{ // open up a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// 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 postdogear WHERE postid = " + postid + ";");
|
||||
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
|
||||
// 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
|
||||
|
||||
// record what we did in an audit record
|
||||
ar = new AuditRecord(AuditRecord.NUKE_MESSAGE,conf.realUID(),conf.userRemoteAddress(),
|
||||
conf.realCommunityID(),"conf=" + conf.realConfID() + ",post=" + postid);
|
||||
ar = env.newAudit(AuditRecord.NUKE_MESSAGE,"conf=" + env.getConfID() + ",post=" + postid);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -791,8 +778,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -811,7 +797,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
} // end if
|
||||
|
||||
if (creator_uid!=conf.realUID())
|
||||
if (creator_uid!=env.getUserID())
|
||||
{ // you can't attach to this message!
|
||||
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.");
|
||||
|
@ -858,7 +844,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
int real_length = 0;
|
||||
int tmp_stgmethod;
|
||||
|
||||
if (engine.isNoCompressMimeType(m_type))
|
||||
if (env.getEngine().isNoCompressMimeType(m_type))
|
||||
{ // don't compress me, just store me normally
|
||||
logger.debug("stored as NORMAL data (no compression)");
|
||||
real_data = data;
|
||||
|
@ -913,7 +899,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
try
|
||||
{ // open up a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// make sure we have the right status to upload
|
||||
refresh(conn);
|
||||
|
@ -948,9 +934,8 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
stgmethod = tmp_stgmethod;
|
||||
|
||||
// Generate an audit record indicating what we did.
|
||||
ar = new AuditRecord(AuditRecord.UPLOAD_ATTACHMENT,conf.realUID(),conf.userRemoteAddress(),
|
||||
conf.realCommunityID(),"conf=" + conf.realConfID() + ",post=" + postid,
|
||||
"len=" + length + ",type=" + m_type + ",name=" + file + ",method=" + tmp_stgmethod);
|
||||
ar = env.newAudit(AuditRecord.UPLOAD_ATTACHMENT,"conf=" + env.getConfID() + ",post=" + postid,
|
||||
"len=" + length + ",type=" + m_type + ",name=" + file + ",method=" + tmp_stgmethod);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -973,8 +958,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -982,7 +966,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
public boolean canPublish()
|
||||
{
|
||||
if (!(Capability.canPublishToFrontPage(conf.realBaseLevel())))
|
||||
if (!(Capability.canPublishToFrontPage(env.getUser().realBaseLevel())))
|
||||
return false; // must be a sysadmin to publish
|
||||
if ((scribble_date!=null) || nuked)
|
||||
return false; // cannot publish a scribbled or nuked message
|
||||
|
@ -991,7 +975,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// see if the post has already been published
|
||||
|
@ -1007,8 +991,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1018,7 +1001,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
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!
|
||||
logger.error("unable to publish because we're not allowed");
|
||||
throw new AccessError("You are not permitted to publish postings to the front page.");
|
||||
|
@ -1044,7 +1027,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// see if post has already been published
|
||||
|
@ -1054,31 +1037,30 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
throw new DataException("This posting has already been published.");
|
||||
|
||||
boolean done = false;
|
||||
engine.startPublish();
|
||||
env.getEngine().startPublish();
|
||||
|
||||
try
|
||||
{ // insert the post reference into the database
|
||||
StringBuffer sql =
|
||||
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();
|
||||
sql.append(", '").append(SQLUtil.encodeDate(now)).append("');");
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
// generate an audit record indicating what we've done
|
||||
ar = new AuditRecord(AuditRecord.PUBLISH_POST,conf.realUID(),conf.userRemoteAddress(),
|
||||
conf.realCommunityID(),"conf=" + conf.realConfID() + ",post=" + postid);
|
||||
ar = env.newAudit(AuditRecord.PUBLISH_POST,"conf=" + env.getConfID() + ",post=" + postid);
|
||||
|
||||
// establish cached data object for front page
|
||||
engine.publishNew(new PublishedMessageImpl(datapool,postid,parent,num,linecount,creator_uid,
|
||||
posted,pseud,creator_cache,text_cache));
|
||||
env.getEngine().publishNew(new PublishedMessageImpl(env,postid,parent,num,linecount,creator_uid,
|
||||
posted,pseud,creator_cache,text_cache));
|
||||
done = true;
|
||||
|
||||
} // end try
|
||||
finally
|
||||
{ // make sure to release the lock if we goofed in here
|
||||
if (!done)
|
||||
engine.publishNew(null);
|
||||
env.getEngine().publishNew(null);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1103,8 +1085,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1115,11 +1096,11 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static List loadMessageRange(EngineBackend engine, ConferenceBackend conf, DataPool datapool, int topicid,
|
||||
int post_low, int post_high) throws DataException
|
||||
static List loadMessageRange(EnvConference env, int topicid, int post_low, int post_high)
|
||||
throws DataException
|
||||
{
|
||||
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 + "]");
|
||||
|
||||
ArrayList rc = new ArrayList();
|
||||
|
@ -1127,7 +1108,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// run a query to get all the posts in a particular topic
|
||||
|
@ -1145,11 +1126,10 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
while (rs.next())
|
||||
{ // create implementation objects and shove them into the return vector
|
||||
TopicMessageContext val =
|
||||
new TopicMessageUserContextImpl(engine,conf,datapool,rs.getLong(1),rs.getLong(2),rs.getInt(3),
|
||||
rs.getInt(4),rs.getInt(5),SQLUtil.getFullDateTime(rs,6),
|
||||
rs.getBoolean(7),rs.getInt(8),SQLUtil.getFullDateTime(rs,9),
|
||||
rs.getString(10),rs.getInt(11),rs.getString(12),rs.getString(13),
|
||||
rs.getInt(14));
|
||||
new TopicMessageUserContextImpl(env,rs.getLong(1),rs.getLong(2),rs.getInt(3),rs.getInt(4),
|
||||
rs.getInt(5),SQLUtil.getFullDateTime(rs,6),rs.getBoolean(7),
|
||||
rs.getInt(8),SQLUtil.getFullDateTime(rs,9),rs.getString(10),
|
||||
rs.getInt(11),rs.getString(12),rs.getString(13),rs.getInt(14));
|
||||
rc.add(val);
|
||||
|
||||
} // end while
|
||||
|
@ -1163,8 +1143,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1172,18 +1151,17 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
|
||||
} // end loadMessageRange
|
||||
|
||||
static TopicMessageContext loadMessage(EngineBackend engine, ConferenceBackend conf, DataPool datapool,
|
||||
int topicid, int message_num) throws DataException
|
||||
static TopicMessageContext loadMessage(EnvConference env, int topicid, int message_num) throws DataException
|
||||
{
|
||||
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);
|
||||
|
||||
Connection conn = null; // pooled database connection
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// 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());
|
||||
|
||||
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),
|
||||
rs.getInt(4),rs.getInt(5),SQLUtil.getFullDateTime(rs,6),
|
||||
rs.getBoolean(7),rs.getInt(8),SQLUtil.getFullDateTime(rs,9),
|
||||
rs.getString(10),rs.getInt(11),rs.getString(12),
|
||||
rs.getString(13),rs.getInt(14));
|
||||
return new TopicMessageUserContextImpl(env,rs.getLong(1),rs.getLong(2),rs.getInt(3),rs.getInt(4),
|
||||
rs.getInt(5),SQLUtil.getFullDateTime(rs,6),rs.getBoolean(7),
|
||||
rs.getInt(8),SQLUtil.getFullDateTime(rs,9),rs.getString(10),
|
||||
rs.getInt(11),rs.getString(12),rs.getString(13),rs.getInt(14));
|
||||
|
||||
// indicates an error...
|
||||
throw new DataException("Message not found.");
|
||||
|
@ -1216,24 +1193,22 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end loadMessage
|
||||
|
||||
static TopicMessageContext getMessage(EngineBackend engine, ConferenceBackend conf, DataPool datapool,
|
||||
long postid) throws DataException
|
||||
static TopicMessageContext getMessage(EnvConference env, long postid) throws DataException
|
||||
{
|
||||
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
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
StringBuffer sql =
|
||||
|
@ -1241,17 +1216,16 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
+ "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 "
|
||||
+ "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())
|
||||
logger.debug("SQL: " + sql.toString());
|
||||
ResultSet rs = stmt.executeQuery(sql.toString());
|
||||
|
||||
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),
|
||||
rs.getInt(4),rs.getInt(5),SQLUtil.getFullDateTime(rs,6),
|
||||
rs.getBoolean(7),rs.getInt(8),SQLUtil.getFullDateTime(rs,9),
|
||||
rs.getString(10),rs.getInt(11),rs.getString(12),
|
||||
rs.getString(13),rs.getInt(14));
|
||||
return new TopicMessageUserContextImpl(env,rs.getLong(1),rs.getLong(2),rs.getInt(3),rs.getInt(4),
|
||||
rs.getInt(5),SQLUtil.getFullDateTime(rs,6),rs.getBoolean(7),
|
||||
rs.getInt(8),SQLUtil.getFullDateTime(rs,9),rs.getString(10),
|
||||
rs.getInt(11),rs.getString(12),rs.getString(13),rs.getInt(14));
|
||||
|
||||
// indicates an error...
|
||||
throw new DataException("Message not found.");
|
||||
|
@ -1265,8 +1239,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -20,10 +20,11 @@ package com.silverwrist.venice.core.impl;
|
|||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.htmlcheck.*;
|
||||
import com.silverwrist.venice.security.AuditRecord;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
class TopicUserContextImpl implements TopicContext
|
||||
{
|
||||
|
@ -39,9 +40,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private EngineBackend engine;
|
||||
private ConferenceBackend conf;
|
||||
private DataPool datapool;
|
||||
private EnvConference env; // the enclosing environment
|
||||
private int topicid;
|
||||
private short topicnum;
|
||||
private int creator_uid;
|
||||
|
@ -61,14 +60,11 @@ class TopicUserContextImpl implements TopicContext
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected TopicUserContextImpl(EngineBackend engine, ConferenceBackend conf, DataPool datapool, int topicid,
|
||||
short topicnum, int creator_uid, int top_message, boolean frozen,
|
||||
boolean archived, java.util.Date created, java.util.Date lastupdate,
|
||||
String name, boolean hidden, int unread)
|
||||
protected TopicUserContextImpl(EnvConference env, int topicid, short topicnum, int creator_uid,
|
||||
int top_message, boolean frozen, boolean archived, java.util.Date created,
|
||||
java.util.Date lastupdate, String name, boolean hidden, int unread)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.conf = conf;
|
||||
this.datapool = datapool;
|
||||
this.env = env;
|
||||
this.topicid = topicid;
|
||||
this.topicnum = topicnum;
|
||||
this.creator_uid = creator_uid;
|
||||
|
@ -83,15 +79,12 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
} // end constructor
|
||||
|
||||
TopicUserContextImpl(EngineBackend engine, ConferenceBackend conf, DataPool datapool, ReturnTopicInfo inf,
|
||||
String name)
|
||||
TopicUserContextImpl(EnvConference env, ReturnTopicInfo inf, String name)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.conf = conf;
|
||||
this.datapool = datapool;
|
||||
this.env = env;
|
||||
this.topicid = inf.getTopicID();
|
||||
this.topicnum = inf.getTopicNum();
|
||||
this.creator_uid = conf.realUID();
|
||||
this.creator_uid = env.getUserID();
|
||||
this.top_message = 0;
|
||||
this.frozen = false;
|
||||
this.archived = false;
|
||||
|
@ -144,7 +137,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
Statement stmt = conn.createStatement();
|
||||
|
||||
// perform a requery of the database
|
||||
ResultSet rs = queryByTopic(stmt,topicid,conf.realUID());
|
||||
ResultSet rs = queryByTopic(stmt,topicid,env.getUserID());
|
||||
if (rs.next())
|
||||
{ // update the fields that are capable of changing
|
||||
top_message = rs.getInt(4);
|
||||
|
@ -166,7 +159,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
{
|
||||
Statement stmt = conn.createStatement();
|
||||
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());
|
||||
bozo_uids = new HashSet();
|
||||
while (rs.next())
|
||||
|
@ -187,7 +180,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
refresh(conn);
|
||||
|
||||
} // end try
|
||||
|
@ -199,8 +192,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -280,13 +272,13 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
public boolean canFreeze()
|
||||
{
|
||||
return conf.userCanHide();
|
||||
return env.getConference().userCanHide();
|
||||
|
||||
} // end canFreeze
|
||||
|
||||
public boolean canArchive()
|
||||
{
|
||||
return conf.userCanHide();
|
||||
return env.getConference().userCanHide();
|
||||
|
||||
} // end canArchive
|
||||
|
||||
|
@ -294,7 +286,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
{
|
||||
if ((frozen==flag) || deleted)
|
||||
return; // no-op
|
||||
if (!(conf.userCanHide()))
|
||||
if (!(env.getConference().userCanHide()))
|
||||
{ // you can't freeze the topic!
|
||||
logger.error("user cannot change frozen status of topic");
|
||||
throw new AccessError("You are not permitted to freeze or unfreeze this topic.");
|
||||
|
@ -306,7 +298,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the SQL statement to freeze or unfreeze the topic
|
||||
|
@ -315,9 +307,8 @@ class TopicUserContextImpl implements TopicContext
|
|||
if (stmt.executeUpdate(sql.toString())>0)
|
||||
{ // success! save the flag and generate an audit record
|
||||
frozen = flag;
|
||||
ar = new AuditRecord(AuditRecord.TOPIC_FREEZE,conf.realUID(),conf.userRemoteAddress(),
|
||||
conf.realCommunityID(),"conf=" + String.valueOf(conf.realConfID()) + ",topic="
|
||||
+ String.valueOf(topicid),flag ? "freeze" : "unfreeze");
|
||||
ar = env.newAudit(AuditRecord.TOPIC_FREEZE,"conf=" + env.getConfID() + ",topic=" + topicid,
|
||||
flag ? "freeze" : "unfreeze");
|
||||
|
||||
} // end if
|
||||
else // somebody else must have deleted this topic
|
||||
|
@ -344,8 +335,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -355,7 +345,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
{
|
||||
if ((archived==flag) || deleted)
|
||||
return; // no-op
|
||||
if (!(conf.userCanHide()))
|
||||
if (!(env.getConference().userCanHide()))
|
||||
{ // you can't archive the topic!
|
||||
logger.error("user cannot change archived status of topic");
|
||||
throw new AccessError("You are not permitted to archive or unarchive this topic.");
|
||||
|
@ -367,7 +357,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the SQL statement to freeze or unfreeze the topic
|
||||
|
@ -376,9 +366,8 @@ class TopicUserContextImpl implements TopicContext
|
|||
if (stmt.executeUpdate(sql.toString())>0)
|
||||
{ // success! save the flag and generate an audit record
|
||||
archived = flag;
|
||||
ar = new AuditRecord(AuditRecord.TOPIC_ARCHIVE,conf.realUID(),conf.userRemoteAddress(),
|
||||
conf.realCommunityID(),"conf=" + String.valueOf(conf.realConfID()) + ",topic="
|
||||
+ String.valueOf(topicid),flag ? "archive" : "unarchive");
|
||||
ar = env.newAudit(AuditRecord.TOPIC_ARCHIVE,"conf=" + env.getConfID() + ",topic=" + topicid,
|
||||
flag ? "archive" : "unarchive");
|
||||
|
||||
} // end if
|
||||
else // somebody else must have deleted this topic
|
||||
|
@ -405,8 +394,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -414,14 +402,14 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
public void setHidden(boolean flag) throws DataException
|
||||
{
|
||||
if ((hidden==flag) || deleted || conf.userIsAnonymous())
|
||||
if ((hidden==flag) || deleted || env.getUser().userIsAnonymous())
|
||||
return; // no-op
|
||||
|
||||
Connection conn = null; // pooled database connection
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
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
|
||||
StringBuffer sql = new StringBuffer("UPDATE topicsettings SET hidden = ");
|
||||
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)
|
||||
{ // that was all we needed - just save the flag and exit
|
||||
hidden = flag;
|
||||
|
@ -451,7 +439,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
// OK, just insert a new row into topicsettings, why dontcha...
|
||||
sql.setLength(0);
|
||||
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());
|
||||
hidden = flag; // successful completion
|
||||
|
||||
|
@ -472,8 +460,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -493,7 +480,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
if (logger.isDebugEnabled())
|
||||
logger.debug("[raw] setUnreadMessages(" + count + ") entry");
|
||||
|
||||
if (conf.userIsAnonymous())
|
||||
if (env.getUser().userIsAnonymous())
|
||||
{ // this is effectively a no-op, but log it
|
||||
logger.debug("reject 1: anonymous user");
|
||||
return;
|
||||
|
@ -519,7 +506,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
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 = '");
|
||||
java.util.Date now = new java.util.Date();
|
||||
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())
|
||||
logger.debug("SQL: " + sql.toString());
|
||||
if (stmt.executeUpdate(sql.toString())>0)
|
||||
{ // that was all we needed - just save the flag and exit
|
||||
logger.debug("--> bailed out after update - done with setUnreadMessages{");
|
||||
conf.touchRead(conn);
|
||||
env.getConference().touchRead(conn);
|
||||
unread = count;
|
||||
return;
|
||||
|
||||
|
@ -558,12 +545,12 @@ class TopicUserContextImpl implements TopicContext
|
|||
// OK, just insert a new row into topicsettings, why dontcha...
|
||||
sql.setLength(0);
|
||||
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("');");
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("SQL: " + sql.toString());
|
||||
stmt.executeUpdate(sql.toString());
|
||||
conf.touchRead(conn);
|
||||
env.getConference().touchRead(conn);
|
||||
unread = count; // successful completion
|
||||
|
||||
} // end try
|
||||
|
@ -583,8 +570,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -598,7 +584,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
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!
|
||||
logger.error("trying to read postings w/o permission!");
|
||||
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!
|
||||
if (low<=high)
|
||||
return TopicMessageUserContextImpl.loadMessageRange(engine,conf,datapool,topicid,low,high);
|
||||
return TopicMessageUserContextImpl.loadMessageRange(env,topicid,low,high);
|
||||
else
|
||||
return TopicMessageUserContextImpl.loadMessageRange(engine,conf,datapool,topicid,high,low);
|
||||
return TopicMessageUserContextImpl.loadMessageRange(env,topicid,high,low);
|
||||
|
||||
} // end getMessages
|
||||
|
||||
public TopicMessageContext getMessage(int number) throws DataException, AccessError
|
||||
{
|
||||
if (!(conf.userCanRead()))
|
||||
if (!(env.getConference().userCanRead()))
|
||||
{ // they can't read messages in this topic!
|
||||
logger.error("trying to read postings w/o permission!");
|
||||
throw new AccessError("You do not have permission to read messages in this conference.");
|
||||
|
@ -623,7 +609,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end if
|
||||
|
||||
// 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
|
||||
|
||||
|
@ -633,7 +619,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
if (logger.isInfoEnabled())
|
||||
logger.info("postNewMessage(" + parent + ", '" + pseud + "',<text>) entry");
|
||||
|
||||
if (!(conf.userCanPost()))
|
||||
if (!(env.getConference().userCanPost()))
|
||||
{ // they can't post in this topic!
|
||||
logger.error("trying to post w/o permission!");
|
||||
throw new AccessError("You do not have permission to post messages in this conference.");
|
||||
|
@ -647,14 +633,14 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
} // end if
|
||||
|
||||
if (frozen && !(conf.userCanHide()))
|
||||
if (frozen && !(env.getConference().userCanHide()))
|
||||
{ // 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.");
|
||||
|
||||
} // end if
|
||||
|
||||
if (archived && !(conf.userCanHide()))
|
||||
if (archived && !(env.getConference().userCanHide()))
|
||||
{ // can't post to a frozen 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.");
|
||||
|
@ -662,9 +648,9 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end if
|
||||
|
||||
// preprocess the two arguments through HTML checkers
|
||||
HTMLChecker pseud_ch = engine.createCheckerObject(engine.HTMLC_POST_PSEUD);
|
||||
HTMLChecker text_ch = engine.createCheckerObject(engine.HTMLC_POST_BODY);
|
||||
text_ch.setContextValue("PostLinkDecoderContext",conf.createDecoderContext(topicnum));
|
||||
HTMLChecker pseud_ch = env.getEngine().createCheckerObject(EngineBackend.HTMLC_POST_PSEUD);
|
||||
HTMLChecker text_ch = env.getEngine().createCheckerObject(EngineBackend.HTMLC_POST_BODY);
|
||||
text_ch.setContextValue("PostLinkDecoderContext",env.getConference().createDecoderContext(topicnum));
|
||||
try
|
||||
{ // run both arguments through the HTML checker
|
||||
pseud_ch.append(pseud);
|
||||
|
@ -704,7 +690,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// slap a lock on all the tables we need to touch
|
||||
|
@ -721,14 +707,14 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
} // end if
|
||||
|
||||
if (frozen && !(conf.userCanHide()))
|
||||
if (frozen && !(env.getConference().userCanHide()))
|
||||
{ // 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.");
|
||||
|
||||
} // end if
|
||||
|
||||
if (archived && !(conf.userCanHide()))
|
||||
if (archived && !(env.getConference().userCanHide()))
|
||||
{ // can't post to a frozen 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.");
|
||||
|
@ -744,7 +730,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
StringBuffer sql = new StringBuffer("INSERT INTO posts (parent, topicid, num, linecount, creator_uid, "
|
||||
+ "posted, pseud) VALUES (");
|
||||
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();
|
||||
sql.append(SQLUtil.encodeDate(posted_date)).append("', '").append(real_pseud).append("');");
|
||||
if (logger.isDebugEnabled())
|
||||
|
@ -776,7 +762,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
// mark that we posted to the topic
|
||||
sql.setLength(0);
|
||||
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(';');
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("SQL: " + sql.toString());
|
||||
|
@ -784,7 +770,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
{ // we had no topicsettings record, add one
|
||||
sql.setLength(0);
|
||||
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("');");
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("SQL: " + sql.toString());
|
||||
|
@ -793,8 +779,8 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end if
|
||||
|
||||
// mark that we posted to the conference
|
||||
conf.touchUpdate(conn,posted_date);
|
||||
conf.touchPost(conn,posted_date);
|
||||
env.getConference().touchUpdate(conn,posted_date);
|
||||
env.getConference().touchPost(conn,posted_date);
|
||||
|
||||
// Fill in our own local variables to reflect the update. This includes the recalculation
|
||||
// of "unread" based on the new value of "top_message".
|
||||
|
@ -814,10 +800,8 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end finally
|
||||
|
||||
// record what we did in an audit record
|
||||
ar = new AuditRecord(AuditRecord.POST_MESSAGE,conf.realUID(),conf.userRemoteAddress(),
|
||||
conf.realCommunityID(),"conf=" + String.valueOf(conf.realConfID()) + ",topic="
|
||||
+ String.valueOf(topicid) + ",post=" + String.valueOf(new_post_id),
|
||||
"pseud=" + real_pseud);
|
||||
ar = env.newAudit(AuditRecord.POST_MESSAGE,"conf=" + env.getConfID() + ",topic=" + topicid + ",post="
|
||||
+ new_post_id,"pseud=" + real_pseud);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -840,34 +824,33 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
// return the new message context
|
||||
return new TopicMessageUserContextImpl(engine,conf,datapool,new_post_id,parent,new_post_num,
|
||||
text_linecount,conf.realUID(),posted_date,real_pseud);
|
||||
return new TopicMessageUserContextImpl(env,new_post_id,parent,new_post_num,text_linecount,env.getUserID(),
|
||||
posted_date,real_pseud);
|
||||
|
||||
} // end postMessage
|
||||
|
||||
public HTMLChecker getPreviewChecker()
|
||||
{
|
||||
HTMLChecker rc = engine.createCheckerObject(engine.HTMLC_PREVIEW_BODY);
|
||||
rc.setContextValue("PostLinkDecoderContext",conf.createDecoderContext(topicnum));
|
||||
HTMLChecker rc = env.getEngine().createCheckerObject(EngineBackend.HTMLC_PREVIEW_BODY);
|
||||
rc.setContextValue("PostLinkDecoderContext",env.getConference().createDecoderContext(topicnum));
|
||||
return rc;
|
||||
|
||||
} // end getPreviewChecker
|
||||
|
||||
public boolean canDelete()
|
||||
{
|
||||
return conf.userCanNuke();
|
||||
return env.getConference().userCanNuke();
|
||||
|
||||
} // end canDelete
|
||||
|
||||
public void delete() throws DataException, AccessError
|
||||
{
|
||||
if (!(conf.userCanNuke()))
|
||||
if (!(env.getConference().userCanNuke()))
|
||||
{ // we can't delete the topic!
|
||||
logger.error("trying to delete w/o permission!");
|
||||
throw new AccessError("You do not have permission to delete this topic.");
|
||||
|
@ -884,7 +867,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// lock some tables while we do the critical parts of the delete
|
||||
|
@ -907,7 +890,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
// 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
|
||||
sql.setLength(0);
|
||||
|
@ -930,9 +913,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end finally
|
||||
|
||||
// record what we did in an audit record
|
||||
ar = new AuditRecord(AuditRecord.DELETE_TOPIC,conf.realUID(),conf.userRemoteAddress(),
|
||||
conf.realCommunityID(),"conf=" + String.valueOf(conf.realConfID()) + ",topic="
|
||||
+ String.valueOf(topicid));
|
||||
ar = env.newAudit(AuditRecord.DELETE_TOPIC,"conf=" + env.getConfID() + ",topic=" + topicid);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -955,13 +936,12 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
// 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);
|
||||
thrd.setPriority(Thread.NORM_PRIORITY-1);
|
||||
thrd.start();
|
||||
|
@ -974,8 +954,8 @@ class TopicUserContextImpl implements TopicContext
|
|||
ArrayList rc = new ArrayList();
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the datapool
|
||||
conn = datapool.getConnection();
|
||||
{ // retrieve a connection
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the SQL statement to retrieve all posters
|
||||
|
@ -1007,8 +987,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1034,8 +1013,8 @@ class TopicUserContextImpl implements TopicContext
|
|||
ArrayList rc = new ArrayList();
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the datapool
|
||||
conn = datapool.getConnection();
|
||||
{ // retrieve a connection
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the SQL statement to retrieve all readers
|
||||
|
@ -1067,8 +1046,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1090,7 +1068,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
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
|
||||
|
||||
if (bozo_uids==null)
|
||||
|
@ -1098,7 +1076,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
Connection conn = null;
|
||||
try
|
||||
{ // load the bozo filter UIDs from the database
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
loadBozo(conn);
|
||||
|
||||
} // end try
|
||||
|
@ -1110,8 +1088,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1123,13 +1100,13 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
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
|
||||
|
||||
Connection conn = null;
|
||||
try
|
||||
{ // figure out what to do here
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
refresh(conn);
|
||||
if (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)))
|
||||
{ // add them to the bozo list
|
||||
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.executeUpdate(sql.toString());
|
||||
bozo_uids.add(uid_key);
|
||||
|
@ -1158,7 +1135,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
if (bozo_uids.contains(uid_key))
|
||||
{ // remove them from the bozo list
|
||||
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(';');
|
||||
stmt = conn.createStatement();
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
@ -1178,8 +1155,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1190,13 +1166,13 @@ class TopicUserContextImpl implements TopicContext
|
|||
// 1. You can't set bozo filters on a deleted topic.
|
||||
// 2. You can't set bozo filters if you're the anonymous user.
|
||||
// 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
|
||||
|
||||
public List getBozos() throws DataException
|
||||
{
|
||||
if (deleted || conf.userIsAnonymous())
|
||||
if (deleted || env.getUser().userIsAnonymous())
|
||||
return Collections.EMPTY_LIST; // no-op
|
||||
|
||||
if (bozo_uids==null)
|
||||
|
@ -1204,7 +1180,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
Connection conn = null;
|
||||
try
|
||||
{ // load the bozo filter UIDs from the database
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
loadBozo(conn);
|
||||
|
||||
} // end try
|
||||
|
@ -1216,8 +1192,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1232,18 +1207,16 @@ class TopicUserContextImpl implements TopicContext
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static List getTopicList(EngineBackend engine, ConferenceBackend conf, DataPool datapool, int get_option,
|
||||
int sort_option) throws DataException
|
||||
static List getTopicList(EnvConference env, int get_option, int sort_option) throws DataException
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("getTopicList for conf # " + String.valueOf(conf.realConfID()) + ", user #"
|
||||
+ String.valueOf(conf.realUID()));
|
||||
logger.debug("getTopicList for conf # " + env.getConfID() + ", user #" + env.getUserID());
|
||||
ArrayList rc = new ArrayList(); // return from this function
|
||||
Connection conn = null; // pooled database connection
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// 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)
|
||||
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(conf.realUID()).append(" WHERE t.confid = ").append(conf.realConfID());
|
||||
sql.append(env.getUserID()).append(" WHERE t.confid = ").append(env.getConfID());
|
||||
if (where_clause!=null)
|
||||
sql.append(" AND ").append(where_clause);
|
||||
sql.append(" ORDER BY ");
|
||||
|
@ -1368,10 +1341,10 @@ class TopicUserContextImpl implements TopicContext
|
|||
while (rs.next())
|
||||
{ // create the returned objects and add them to the vector
|
||||
TopicContext top =
|
||||
new TopicUserContextImpl(engine,conf,datapool,rs.getInt(1),rs.getShort(2),rs.getInt(3),
|
||||
rs.getInt(4),rs.getBoolean(5),rs.getBoolean(6),
|
||||
SQLUtil.getFullDateTime(rs,7),SQLUtil.getFullDateTime(rs,8),
|
||||
rs.getString(9),rs.getBoolean(10),rs.getInt(11));
|
||||
new TopicUserContextImpl(env,rs.getInt(1),rs.getShort(2),rs.getInt(3),rs.getInt(4),
|
||||
rs.getBoolean(5),rs.getBoolean(6),SQLUtil.getFullDateTime(rs,7),
|
||||
SQLUtil.getFullDateTime(rs,8),rs.getString(9),rs.getBoolean(10),
|
||||
rs.getInt(11));
|
||||
rc.add(top);
|
||||
|
||||
} // end while
|
||||
|
@ -1385,8 +1358,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1394,27 +1366,25 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
} // end getTopicList
|
||||
|
||||
static TopicContext getTopicByID(EngineBackend engine, ConferenceBackend conf, DataPool datapool,
|
||||
int topicid) throws DataException
|
||||
static TopicContext getTopicByID(EnvConference env, int topicid) throws DataException
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("getTopicByID for topic # " + String.valueOf(topicid) + ", user #"
|
||||
+ String.valueOf(conf.realUID()));
|
||||
logger.debug("getTopicByID for topic # " + topicid + ", user #" + env.getUserID());
|
||||
|
||||
Connection conn = null; // pooled database connection
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// 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!
|
||||
return new TopicUserContextImpl(engine,conf,datapool,topicid,rs.getShort(2),rs.getInt(3),
|
||||
rs.getInt(4),rs.getBoolean(5),rs.getBoolean(6),
|
||||
SQLUtil.getFullDateTime(rs,7),SQLUtil.getFullDateTime(rs,8),
|
||||
rs.getString(9),rs.getBoolean(10),rs.getInt(11));
|
||||
return new TopicUserContextImpl(env,topicid,rs.getShort(2),rs.getInt(3),rs.getInt(4),rs.getBoolean(5),
|
||||
rs.getBoolean(6),SQLUtil.getFullDateTime(rs,7),
|
||||
SQLUtil.getFullDateTime(rs,8),rs.getString(9),rs.getBoolean(10),
|
||||
rs.getInt(11));
|
||||
// else fall out and return null
|
||||
|
||||
} // end try
|
||||
|
@ -1426,8 +1396,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1435,18 +1404,17 @@ class TopicUserContextImpl implements TopicContext
|
|||
|
||||
} // end getTopicByID
|
||||
|
||||
static TopicContext getTopicByNumber(EngineBackend engine, ConferenceBackend conf, DataPool datapool,
|
||||
short topicnum) throws DataException
|
||||
static TopicContext getTopicByNumber(EnvConference env, short topicnum) throws DataException
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("getTopicByNumber for topic # " + String.valueOf(topicnum) + ", conf # "
|
||||
+ String.valueOf(conf.realConfID()) + ", user #" + String.valueOf(conf.realUID()));
|
||||
logger.debug("getTopicByNumber for topic # " + topicnum + ", conf # " + env.getConfID() + ", user #"
|
||||
+ env.getUserID());
|
||||
|
||||
Connection conn = null; // pooled database connection
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// 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.top_message - IFNULL(s.last_message,-1)) AS unread 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());
|
||||
sql.append(" AND t.num = ").append(topicnum).append(';');
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("SQL: " + sql.toString());
|
||||
|
@ -1463,10 +1431,10 @@ class TopicUserContextImpl implements TopicContext
|
|||
// Now pass this query off to the database!
|
||||
ResultSet rs = stmt.executeQuery(sql.toString());
|
||||
if (rs.next()) // found it!
|
||||
return new TopicUserContextImpl(engine,conf,datapool,rs.getInt(1),topicnum,rs.getInt(3),
|
||||
rs.getInt(4),rs.getBoolean(5),rs.getBoolean(6),
|
||||
SQLUtil.getFullDateTime(rs,7),SQLUtil.getFullDateTime(rs,8),
|
||||
rs.getString(9),rs.getBoolean(10),rs.getInt(11));
|
||||
return new TopicUserContextImpl(env,rs.getInt(1),topicnum,rs.getInt(3),rs.getInt(4),rs.getBoolean(5),
|
||||
rs.getBoolean(6),SQLUtil.getFullDateTime(rs,7),
|
||||
SQLUtil.getFullDateTime(rs,8),rs.getString(9),rs.getBoolean(10),
|
||||
rs.getInt(11));
|
||||
// else fall out and return null
|
||||
|
||||
} // end try
|
||||
|
@ -1478,8 +1446,7 @@ class TopicUserContextImpl implements TopicContext
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.log4j.*;
|
|||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.security.PasswordHash;
|
||||
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 DataPool datapool; // the data pool used by this object
|
||||
private EnvUser env; // the environment store
|
||||
private String remote_addr; // remote address identifier
|
||||
private int uid = -1; // the user ID we're using
|
||||
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.datapool = datapool;
|
||||
this.env = new EnvUser(env,this);
|
||||
|
||||
} // end constructor
|
||||
|
||||
|
@ -131,7 +130,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // call through to lower level function
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM userprefs WHERE uid = " + uid + ";");
|
||||
|
||||
|
@ -170,8 +169,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -183,7 +181,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
logger.debug("sendEmailConfirmation(): sending to \"" + my_email + "\"");
|
||||
|
||||
// Create the message to be sent.
|
||||
String message = engine.getStockMessage("email-confirm");
|
||||
String message = env.getEngine().getStockMessage("email-confirm");
|
||||
if (message==null)
|
||||
{ // no message defined? oy!
|
||||
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));
|
||||
message = StringUtil.replaceAllVariables(message,vars);
|
||||
|
||||
String subject = engine.getStockMessage("email-confirm-subject");
|
||||
String subject = env.getEngine().getStockMessage("email-confirm-subject");
|
||||
if (subject==null)
|
||||
subject = "Venice Email Confirmation";
|
||||
|
||||
// Create the emailer and send the message.
|
||||
SimpleEmailer emailer = engine.createEmailer();
|
||||
Emailer emailer = env.getEngine().createEmailer();
|
||||
emailer.setTo(my_email);
|
||||
emailer.setSubject(subject);
|
||||
emailer.setText(message);
|
||||
|
@ -276,7 +274,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
Connection conn = null;
|
||||
try
|
||||
{ // get a connection and create a statement
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer();
|
||||
|
||||
|
@ -298,8 +296,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -390,7 +387,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // look for a user name matching this user record
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE username = '"
|
||||
+ SQLUtil.encodeString(username) + "';");
|
||||
|
@ -474,8 +471,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end if
|
||||
|
||||
|
@ -499,7 +495,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
{ // the confirmation number is wrong
|
||||
logger.warn("...confirmation number incorrect");
|
||||
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.");
|
||||
|
||||
} // end if
|
||||
|
@ -508,7 +504,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // get a connection and set the user's status to reflect the verification
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = 1, base_lvl = ");
|
||||
sql.append(DefaultLevels.afterEmailVerification()).append(" WHERE uid = ").append(uid).append(';');
|
||||
|
@ -543,8 +539,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end if
|
||||
|
||||
|
@ -569,11 +564,11 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
AuditRecord ar = null;
|
||||
try
|
||||
{ // need to change the user's email confirmation number first
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// 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
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET email_confnum = ");
|
||||
|
@ -609,8 +604,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end if
|
||||
|
||||
|
@ -623,7 +617,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
ContactInfoImpl rc;
|
||||
if (contactid>=0)
|
||||
rc = new ContactInfoImpl(datapool,contactid);
|
||||
rc = new ContactInfoImpl(env,contactid);
|
||||
else
|
||||
rc = new ContactInfoImpl(uid);
|
||||
if (my_email==null)
|
||||
|
@ -662,7 +656,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Stashable obj = (Stashable)ci;
|
||||
|
||||
// save the contact information
|
||||
|
@ -694,7 +688,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
logger.debug("email address changed, need to reconfirm");
|
||||
|
||||
// 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
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = 0, email_confnum = ");
|
||||
|
@ -744,8 +738,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end if
|
||||
|
||||
|
@ -761,8 +754,8 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
UserProfileImpl prof = new UserProfileImpl(engine,this,conn,xusername,
|
||||
conn = env.getConnection();
|
||||
UserProfileImpl prof = new UserProfileImpl(env,conn,xusername,
|
||||
Capability.canSeeHiddenContactFields(level));
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("...found it!");
|
||||
|
@ -777,8 +770,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -792,8 +784,8 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
UserProfileImpl prof = new UserProfileImpl(engine,this,conn,xuid,
|
||||
conn = env.getConnection();
|
||||
UserProfileImpl prof = new UserProfileImpl(env,conn,xuid,
|
||||
Capability.canSeeHiddenContactFields(level));
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("...found it!");
|
||||
|
@ -808,8 +800,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -829,7 +820,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
PasswordHash phash = new PasswordHash(password);
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '");
|
||||
|
@ -861,8 +852,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -881,7 +871,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET description = '");
|
||||
sql.append(SQLUtil.encodeString(new_descr)).append("' WHERE uid = ").append(uid).append(';');
|
||||
|
@ -898,8 +888,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -907,75 +896,74 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
public List getMemberCommunities() throws DataException
|
||||
{
|
||||
return CommunityUserContextImpl.getMemberCommunityEntries(engine,this,datapool);
|
||||
return CommunityUserContextImpl.getMemberCommunityEntries(env);
|
||||
|
||||
} // end getMemberCommunities
|
||||
|
||||
public CommunityContext getCommunityContext(int cid) throws DataException
|
||||
{
|
||||
return CommunityUserContextImpl.getCommunityContext(engine,this,datapool,cid);
|
||||
return CommunityUserContextImpl.getCommunityContext(env,cid);
|
||||
|
||||
} // end getCommunityContext
|
||||
|
||||
public CommunityContext getCommunityContext(String alias) throws DataException
|
||||
{
|
||||
return CommunityUserContextImpl.getCommunityContext(engine,this,datapool,alias);
|
||||
return CommunityUserContextImpl.getCommunityContext(env,alias);
|
||||
|
||||
} // end getCommunityContext
|
||||
|
||||
public List getRootCategoryList() throws DataException
|
||||
{
|
||||
return CategoryDescriptorImpl.getTopLevelCategoryList(datapool,Capability.hideHiddenCategories(level));
|
||||
return CategoryDescriptorImpl.getTopLevelCategoryList(env,Capability.hideHiddenCategories(level));
|
||||
|
||||
} // end getRootCategoryList
|
||||
|
||||
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
|
||||
|
||||
public List searchForCommunities(int field, int mode, String term, int offset, int count)
|
||||
throws DataException
|
||||
{
|
||||
return CommunityUserContextImpl.searchForCommunities(engine,this,datapool,field,mode,term,offset,count);
|
||||
return CommunityUserContextImpl.searchForCommunities(env,field,mode,term,offset,count);
|
||||
|
||||
} // end searchForCommunities
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
public List getCommunitiesInCategory(CategoryDescriptor cat, int offset, int count) throws DataException
|
||||
{
|
||||
return CommunityUserContextImpl.getCommunitiesInCategory(engine,this,datapool,cat.getLinkedCategoryID(),
|
||||
offset,count);
|
||||
return CommunityUserContextImpl.getCommunitiesInCategory(env,cat.getLinkedCategoryID(),offset,count);
|
||||
|
||||
} // end getCommunitiesInCategory
|
||||
|
||||
public int getNumCommunitiesInCategory(int catid) throws DataException
|
||||
{
|
||||
return CommunityUserContextImpl.getNumCommunitiesInCategory(this,datapool,catid);
|
||||
return CommunityUserContextImpl.getNumCommunitiesInCategory(env,catid);
|
||||
|
||||
} // end getNumCommunitiessInCategory
|
||||
|
||||
public int getNumCommunitiesInCategory(CategoryDescriptor cat) throws DataException
|
||||
{
|
||||
return CommunityUserContextImpl.getNumCommunitiesInCategory(this,datapool,cat.getLinkedCategoryID());
|
||||
return CommunityUserContextImpl.getNumCommunitiesInCategory(env,cat.getLinkedCategoryID());
|
||||
|
||||
} // end getNumCommunitiesInCategory
|
||||
|
||||
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,
|
||||
term,offset,count);
|
||||
|
||||
|
@ -983,7 +971,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
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),
|
||||
mode,term);
|
||||
|
||||
|
@ -1001,11 +989,11 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
boolean hide_search = (hide_mode==CommunityContext.HIDE_BOTH);
|
||||
|
||||
// Create the new community's database entries and internal data.
|
||||
CommunityData new_comm = CommunityCoreData.createCommunity(engine,this,datapool,name,alias,uid,language,
|
||||
synopsis,rules,joinkey,hide_dir,hide_search);
|
||||
CommunityData new_comm = CommunityCoreData.createCommunity(env,name,alias,uid,language,synopsis,rules,
|
||||
joinkey,hide_dir,hide_search);
|
||||
|
||||
// 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? :-)
|
||||
|
||||
|
@ -1015,7 +1003,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
public boolean canCreateCommunity()
|
||||
{
|
||||
return (level>=engine.getParamInt(EngineBackend.IP_CREATECOMMUNITYLVL));
|
||||
return (level>=env.getEngine().getParamInt(EngineBackend.IP_CREATECOMMUNITYLVL));
|
||||
|
||||
} // end canCreateCommunity
|
||||
|
||||
|
@ -1026,7 +1014,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// retrieve the necessary rows from the sideboxes table
|
||||
|
@ -1034,8 +1022,9 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
+ " ORDER BY sequence;");
|
||||
while (rs.next())
|
||||
{ // create the implementation objects and return them all
|
||||
SideBoxDescriptor sbd = new SideBoxDescriptorImpl(uid,engine.getMasterSideBoxDescriptor(rs.getInt(1)),
|
||||
datapool,rs.getInt(2));
|
||||
SideBoxDescriptor sbd =
|
||||
new SideBoxDescriptorImpl(env,env.getEngine().getMasterSideBoxDescriptor(rs.getInt(1)),
|
||||
rs.getInt(2));
|
||||
rc.add(sbd);
|
||||
|
||||
} // end while
|
||||
|
@ -1049,8 +1038,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1060,14 +1048,14 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
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);
|
||||
|
||||
Connection conn = null;
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the datapool
|
||||
conn = datapool.getConnection();
|
||||
{ // retrieve a connection
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
stmt.executeUpdate("LOCK TABLES sideboxes WRITE;");
|
||||
|
@ -1110,8 +1098,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1119,7 +1106,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
public List getConferenceHotlist() throws DataException
|
||||
{
|
||||
return ConferenceUserContextImpl.getUserHotlist(engine,this,datapool);
|
||||
return ConferenceUserContextImpl.getUserHotlist(env);
|
||||
|
||||
} // end getConferenceHotlist
|
||||
|
||||
|
@ -1139,7 +1126,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end if
|
||||
|
||||
// create the return object
|
||||
return new AdminOperationsImpl(engine,this,datapool);
|
||||
return new AdminOperationsImpl(env);
|
||||
|
||||
} // end getAdminInterface
|
||||
|
||||
|
@ -1158,7 +1145,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the update statement
|
||||
|
@ -1180,8 +1167,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1202,7 +1188,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create the update statement
|
||||
|
@ -1224,8 +1210,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1241,12 +1226,12 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end if
|
||||
|
||||
// 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;
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET tokenauth = '");
|
||||
sql.append(tokenauth).append("' WHERE uid = ").append(uid).append(';');
|
||||
|
@ -1261,8 +1246,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1327,7 +1311,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end if
|
||||
|
||||
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
|
||||
logger.error("Token parse error: invalid auth string value");
|
||||
return false;
|
||||
|
@ -1373,7 +1357,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // look for a user record matching this user ID
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE uid = " + pending_uid + ";");
|
||||
|
||||
|
@ -1451,8 +1435,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end if
|
||||
|
||||
|
@ -1463,7 +1446,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
public Advertisement selectAd()
|
||||
{
|
||||
// just get a random ad for now
|
||||
return AdvertisementImpl.getRandomAd(datapool);
|
||||
return AdvertisementImpl.getRandomAd(env);
|
||||
|
||||
} // end selectAd
|
||||
|
||||
|
@ -1589,7 +1572,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE is_anon = 1;");
|
||||
if (!(rs.next()))
|
||||
|
@ -1612,8 +1595,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1643,7 +1625,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
|
||||
try
|
||||
{ // get a database connection and call the internal function
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
autoJoinCommunities(conn);
|
||||
|
||||
} // end try
|
||||
|
@ -1655,8 +1637,7 @@ class UserContextImpl implements UserContext, UserBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.*;
|
|||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
|
||||
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
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private EngineBackend engine; // the engine back end
|
||||
private UserBackend user; // the user that generated this profile
|
||||
private EnvUser env; // the user environment
|
||||
private int uid; // user ID
|
||||
private String username; // user 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
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("load UserProfileImpl by name: " + username + " (" + override + ")");
|
||||
this.engine = engine;
|
||||
this.user = user;
|
||||
this.env = env;
|
||||
|
||||
// first retrieve from the users table
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -106,13 +105,12 @@ class UserProfileImpl implements UserProfile
|
|||
|
||||
} // 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
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("load UserProfileImpl by UID: " + uid + " (" + override + ")");
|
||||
this.engine = engine;
|
||||
this.user = user;
|
||||
this.env = env;
|
||||
|
||||
// first retrieve from the users table
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -157,7 +155,7 @@ class UserProfileImpl implements UserProfile
|
|||
ResultSet rs = stmt.executeQuery(sql.toString());
|
||||
if (rs.next())
|
||||
{ // load all the record data
|
||||
boolean me_anon = user.userIsAnonymous();
|
||||
boolean me_anon = env.getUser().userIsAnonymous();
|
||||
given_name = rs.getString("given_name");
|
||||
family_name = rs.getString("family_name");
|
||||
String blort = rs.getString("middle_init");
|
||||
|
@ -405,16 +403,16 @@ class UserProfileImpl implements UserProfile
|
|||
|
||||
public boolean canSendQuickEmail()
|
||||
{
|
||||
return !is_anon && !(user.userIsAnonymous());
|
||||
return !is_anon && !(env.getUser().userIsAnonymous());
|
||||
|
||||
} // end canSendQuickEmail
|
||||
|
||||
public void sendQuickEmail(String subject, String text) throws AccessError, DataException, EmailException
|
||||
{
|
||||
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!
|
||||
logger.error("sending user is not logged in.");
|
||||
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
|
||||
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
|
||||
SimpleEmailer em = engine.createEmailer();
|
||||
em.setFrom(user.realUserName(),user.realEmailAddress());
|
||||
Emailer em = env.getEngine().createEmailer();
|
||||
em.setFrom(env.getUser().realUserName(),env.getUser().realEmailAddress());
|
||||
em.setTo(real_email);
|
||||
em.setSubject(subject);
|
||||
em.setText(text_buf.toString());
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.w3c.dom.*;
|
|||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.util.cache.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.core.internals.*;
|
||||
import com.silverwrist.venice.db.*;
|
||||
import com.silverwrist.venice.htmlcheck.*;
|
||||
import com.silverwrist.venice.htmlcheck.dict.*;
|
||||
|
@ -264,7 +265,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
Integer xcid = (Integer)key;
|
||||
try
|
||||
{ // create the desired object
|
||||
return new CommunityCoreData(VeniceEngineImpl.this,datapool,xcid.intValue());
|
||||
return new CommunityCoreData(env,xcid.intValue());
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
|
@ -293,7 +294,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
Integer xconf = (Integer)key;
|
||||
try
|
||||
{ // create the desired object
|
||||
return new ConferenceCoreData(VeniceEngineImpl.this,datapool,xconf.intValue());
|
||||
return new ConferenceCoreData(env,xconf.intValue());
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
|
@ -392,7 +393,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
*/
|
||||
|
||||
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 Properties email_props = null; // email properties
|
||||
private javax.mail.Session mailsession = null; // email session object
|
||||
|
@ -479,7 +480,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
Connection conn = null;
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer();
|
||||
|
||||
|
@ -529,8 +530,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -651,6 +651,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
this.config = config;
|
||||
|
||||
DataPool datapool = null;
|
||||
ArrayList dictionary_tmp;
|
||||
try
|
||||
{ // first, verify that this is a valid configuration
|
||||
|
@ -847,11 +848,15 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
catch (ConfigException ce)
|
||||
{ // before we leave on a ConfigException, nuke the important data
|
||||
this.config = null;
|
||||
datapool = null;
|
||||
if (datapool!=null)
|
||||
datapool.closeAllConnections();
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
|
||||
// Initialize the environment.
|
||||
env = new EnvEngine(this,datapool);
|
||||
|
||||
for (i=0; i<sideboxes.length; i++) // insert sideboxes into hashtable
|
||||
sidebox_ids.put(new Integer(sideboxes[i].getID()),sideboxes[i]);
|
||||
|
||||
|
@ -862,7 +867,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
Connection conn = null;
|
||||
try
|
||||
{ // get a connection from the data pool
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
|
||||
// load the master feature table
|
||||
Statement stmt = conn.createStatement();
|
||||
|
@ -896,8 +901,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -911,8 +915,8 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
SQLEncodingFilter sql_filter = new SQLEncodingFilter();
|
||||
SpellingRewriter spell_rewriter = new SpellingRewriter();
|
||||
URLRewriter url_rewriter = new URLRewriter();
|
||||
PostLinkRewriter postlink_rewriter = new PostLinkRewriter(datapool);
|
||||
UserNameRewriter username_rewriter = new UserNameRewriter(datapool);
|
||||
PostLinkRewriter postlink_rewriter = new PostLinkRewriter(env.getDataPool());
|
||||
UserNameRewriter username_rewriter = new UserNameRewriter(env.getDataPool());
|
||||
|
||||
// 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])));
|
||||
|
@ -1005,7 +1009,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
public UserContext createUserContext(String remote_addr) throws DataException
|
||||
{
|
||||
checkInitialized();
|
||||
UserContextImpl uci = new UserContextImpl(this,datapool);
|
||||
UserContextImpl uci = new UserContextImpl(env);
|
||||
uci.loadAnonymous(remote_addr);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("createUserContext(): context loaded :-)");
|
||||
|
@ -1020,7 +1024,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
try
|
||||
{ // look for a user name matching this user record
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT c.email FROM users u, contacts c WHERE u.contactid = "
|
||||
+ "c.contactid AND u.username = '" + SQLUtil.encodeString(username)
|
||||
|
@ -1047,8 +1051,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1061,7 +1064,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
try
|
||||
{ // look for a user name matching this user record
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT c.email, u.uid, u.passreminder FROM users u, contacts c "
|
||||
+ "WHERE u.contactid = c.contactid AND u.username = '");
|
||||
|
@ -1106,7 +1109,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
subject = "Venice Password Reminder Message";
|
||||
|
||||
// Create the emailer and send the message.
|
||||
SimpleEmailer emailer = createEmailer();
|
||||
Emailer emailer = createEmailer();
|
||||
emailer.setTo(email_addr);
|
||||
emailer.setSubject(subject);
|
||||
emailer.setText(message);
|
||||
|
@ -1123,8 +1126,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1159,7 +1161,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
Connection conn = null;
|
||||
try
|
||||
{ // perform the database update
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '");
|
||||
sql.append(phash.toString()).append("' WHERE uid = ").append(uid).append(';');
|
||||
|
@ -1174,8 +1176,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1200,7 +1201,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
subject = "Venice Password Changed";
|
||||
|
||||
// Create the emailer and send the message.
|
||||
SimpleEmailer emailer = createEmailer();
|
||||
Emailer emailer = createEmailer();
|
||||
emailer.setTo(pcr.getEmail());
|
||||
emailer.setSubject(subject);
|
||||
emailer.setText(message);
|
||||
|
@ -1227,7 +1228,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
try
|
||||
{ // look to see if the user name is already present
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.executeUpdate("LOCK TABLES users WRITE, userprefs WRITE, propuser WRITE, sigmember WRITE, "
|
||||
+ "sideboxes WRITE, confhotlist WRITE;");
|
||||
|
@ -1380,13 +1381,12 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
} // end catch
|
||||
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
// 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.autoJoinCommunities(); // EJB 4/14/2001
|
||||
if (logger.isDebugEnabled())
|
||||
|
@ -1402,7 +1402,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
try
|
||||
{ // do a SELECT on the sigs table
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT sigid FROM sigs WHERE alias = '");
|
||||
sql.append(alias).append("'");
|
||||
|
@ -1420,8 +1420,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1438,7 +1437,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
try
|
||||
{ // do a SELECT on the category table
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT catid FROM refcategory WHERE catid = ");
|
||||
sql.append(catid).append(';');
|
||||
|
@ -1453,8 +1452,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1473,7 +1471,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
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, "
|
||||
|
@ -1547,8 +1545,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1565,7 +1562,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM users u, contacts c WHERE u.contactid = "
|
||||
+ "c.contactid AND ");
|
||||
|
@ -1635,8 +1632,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1654,7 +1650,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// create and execute the right SQL statement
|
||||
|
@ -1671,8 +1667,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -1687,7 +1682,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
try
|
||||
{ // do a SELECT on the confalias table
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT confid FROM confalias WHERE alias = '");
|
||||
sql.append(alias).append("';");
|
||||
|
@ -1702,8 +1697,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // 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 (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();
|
||||
while (it.hasNext())
|
||||
{ // cast each element and add the casted object to the output
|
||||
PublishedMessageImpl pmi = (PublishedMessageImpl)(it.next());
|
||||
TopicMessageContext ctxt = (TopicMessageContext)pmi;
|
||||
TopicMessageContext ctxt = (TopicMessageContext)(it.next());
|
||||
rc.add(ctxt);
|
||||
|
||||
} // end while
|
||||
|
@ -1783,7 +1776,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end synchronized block
|
||||
|
||||
if (all) // add the extra postings to the list
|
||||
PublishedMessageImpl.backfillReturn(rc,datapool);
|
||||
PublishedMessageImpl.backfillReturn(rc,env);
|
||||
|
||||
return Collections.unmodifiableList(rc);
|
||||
|
||||
|
@ -1797,20 +1790,20 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
public Advertisement getAdByID(int id)
|
||||
{
|
||||
return AdvertisementImpl.getAdByID(datapool,id);
|
||||
return AdvertisementImpl.getAdByID(env,id);
|
||||
|
||||
} // end getAdByID
|
||||
|
||||
public Advertisement selectAd()
|
||||
{
|
||||
// just get a random ad for now
|
||||
return AdvertisementImpl.getRandomAd(datapool);
|
||||
return AdvertisementImpl.getRandomAd(env);
|
||||
|
||||
} // end selectAd
|
||||
|
||||
public BinaryData loadImage(int id) throws DataException
|
||||
{
|
||||
return ImageStore.loadImageByID(datapool,id);
|
||||
return ImageStore.loadImageByID(env,id);
|
||||
|
||||
} // end loadImage
|
||||
|
||||
|
@ -1831,7 +1824,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public SimpleEmailer createEmailer()
|
||||
public Emailer createEmailer()
|
||||
{
|
||||
checkInitialized();
|
||||
return new SimpleEmailer(email_props,mailsession);
|
||||
|
@ -2038,7 +2031,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
try
|
||||
{ // get a connection and use it to store the audit record
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
ar.store(conn);
|
||||
|
||||
} // end try
|
||||
|
@ -2049,8 +2042,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -2092,7 +2084,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
try
|
||||
{ // get a connection and use it to reload
|
||||
conn = datapool.getConnection();
|
||||
conn = env.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
loadDefaults(stmt);
|
||||
|
||||
|
@ -2105,8 +2097,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
if (conn!=null)
|
||||
datapool.releaseConnection(conn);
|
||||
env.releaseConnection(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -2124,7 +2115,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
|
||||
} // end startPublish
|
||||
|
||||
public synchronized void publishNew(PublishedMessageImpl pubmsg)
|
||||
public synchronized void publishNew(TopicMessageContext pubmsg)
|
||||
{
|
||||
if (pubmsg!=null)
|
||||
{ // add the new message
|
||||
|
@ -2144,8 +2135,8 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
Iterator it = cache_fp_posts.iterator();
|
||||
while (it.hasNext())
|
||||
{ // get each published message in the cache in turn, looking for the specified post ID
|
||||
PublishedMessageImpl pmi = (PublishedMessageImpl)(it.next());
|
||||
if (pmi.getPostID()==postid)
|
||||
TopicMessageContext tmc = (TopicMessageContext)(it.next());
|
||||
if (tmc.getPostID()==postid)
|
||||
{ // drop the specified post ID like a hot rock
|
||||
it.remove();
|
||||
break;
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
*
|
||||
* 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.CommunityContext;
|
||||
|
||||
public interface CommunityBackend extends UserBackend
|
||||
public interface CommunityBackend
|
||||
{
|
||||
public abstract CommunityContext selfCommunity();
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.core.impl;
|
||||
package com.silverwrist.venice.core.internals;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.Date;
|
||||
|
@ -67,21 +67,21 @@ public interface CommunityData
|
|||
|
||||
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 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 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;
|
||||
|
||||
|
@ -95,11 +95,12 @@ public interface CommunityData
|
|||
|
||||
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 void setMembersOnly(UserBackend user, boolean flag) throws DataException;
|
||||
public abstract void setMembersOnly(EnvCommunity outer, boolean flag) throws DataException;
|
||||
|
||||
public abstract short getInitialFeatureIndex();
|
||||
|
||||
|
@ -107,7 +108,7 @@ public interface CommunityData
|
|||
|
||||
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();
|
||||
|
||||
|
@ -119,12 +120,12 @@ public interface CommunityData
|
|||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
public abstract int getMemberCount(boolean include_hidden) throws DataException;
|
||||
|
@ -135,7 +136,7 @@ public interface CommunityData
|
|||
|
||||
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,
|
||||
boolean hide_list)
|
||||
throws DataException;
|
||||
|
@ -150,7 +151,7 @@ public interface CommunityData
|
|||
|
||||
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();
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* 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 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>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.core.impl;
|
||||
package com.silverwrist.venice.core.internals;
|
||||
|
||||
public interface CommunityDataBackend
|
||||
{
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.core.impl;
|
||||
package com.silverwrist.venice.core.internals;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
@ -23,7 +23,7 @@ import java.util.Date;
|
|||
import com.silverwrist.venice.db.PostLinkDecoderContext;
|
||||
import com.silverwrist.venice.core.DataException;
|
||||
|
||||
public interface ConferenceBackend extends CommunityBackend
|
||||
public interface ConferenceBackend
|
||||
{
|
||||
public abstract int realConfID();
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.core.impl;
|
||||
package com.silverwrist.venice.core.internals;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.Date;
|
||||
|
@ -63,20 +63,20 @@ public interface ConferenceCommunityContext
|
|||
|
||||
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;
|
||||
|
||||
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 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();
|
||||
|
||||
|
@ -84,13 +84,13 @@ public interface ConferenceCommunityContext
|
|||
|
||||
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 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;
|
||||
|
||||
public abstract boolean canScribblePosts(int level);
|
||||
|
@ -107,7 +107,7 @@ public interface ConferenceCommunityContext
|
|||
|
||||
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();
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.core.impl;
|
||||
package com.silverwrist.venice.core.internals;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.Date;
|
||||
|
@ -61,24 +61,24 @@ public interface ConferenceData
|
|||
|
||||
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;
|
||||
|
||||
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 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 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;
|
||||
|
||||
public abstract boolean canScribblePosts(int level);
|
||||
|
@ -101,7 +101,7 @@ public interface ConferenceData
|
|||
|
||||
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();
|
||||
|
34
src/com/silverwrist/venice/core/internals/Emailer.java
Normal file
34
src/com/silverwrist/venice/core/internals/Emailer.java
Normal 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
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.core.impl;
|
||||
package com.silverwrist.venice.core.internals;
|
||||
|
||||
import java.util.BitSet;
|
||||
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.GlobalProperties;
|
||||
import com.silverwrist.venice.core.SideBoxDescriptor;
|
||||
import com.silverwrist.venice.core.TopicMessageContext;
|
||||
|
||||
public interface EngineBackend
|
||||
{
|
||||
|
@ -47,7 +48,7 @@ public interface EngineBackend
|
|||
// Boolean parameter indexes
|
||||
public static final int BP_POSTPICTURES = 0;
|
||||
|
||||
public abstract SimpleEmailer createEmailer();
|
||||
public abstract Emailer createEmailer();
|
||||
|
||||
public abstract String getStockMessage(String key);
|
||||
|
||||
|
@ -93,7 +94,7 @@ public interface EngineBackend
|
|||
|
||||
public abstract void startPublish();
|
||||
|
||||
public abstract void publishNew(PublishedMessageImpl pubmsg);
|
||||
public abstract void publishNew(TopicMessageContext pubmsg);
|
||||
|
||||
public abstract void unpublish(long postid);
|
||||
|
105
src/com/silverwrist/venice/core/internals/EnvCommunity.java
Normal file
105
src/com/silverwrist/venice/core/internals/EnvCommunity.java
Normal 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
|
|
@ -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
|
66
src/com/silverwrist/venice/core/internals/EnvConference.java
Normal file
66
src/com/silverwrist/venice/core/internals/EnvConference.java
Normal 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
|
||||
|
|
@ -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
|
|
@ -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
|
83
src/com/silverwrist/venice/core/internals/EnvEngine.java
Normal file
83
src/com/silverwrist/venice/core/internals/EnvEngine.java
Normal 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
|
97
src/com/silverwrist/venice/core/internals/EnvUser.java
Normal file
97
src/com/silverwrist/venice/core/internals/EnvUser.java
Normal 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
|
|
@ -15,24 +15,24 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.core.impl;
|
||||
package com.silverwrist.venice.core.internals;
|
||||
|
||||
class ReturnConfSeq
|
||||
public final class ReturnConfSeq
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private ConferenceData conf;
|
||||
private short sequence;
|
||||
private ConferenceData conf; // conference being returned
|
||||
private short sequence; // sequence number of conference
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ReturnConfSeq(ConferenceData conf, short sequence)
|
||||
public ReturnConfSeq(ConferenceData conf, short sequence)
|
||||
{
|
||||
this.conf = conf;
|
||||
this.sequence = sequence;
|
||||
|
@ -44,13 +44,13 @@ class ReturnConfSeq
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ConferenceData getConference()
|
||||
public final ConferenceData getConference()
|
||||
{
|
||||
return conf;
|
||||
|
||||
} // end getConference
|
||||
|
||||
short getSequence()
|
||||
public final short getSequence()
|
||||
{
|
||||
return sequence;
|
||||
|
|
@ -15,20 +15,20 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.core.impl;
|
||||
package com.silverwrist.venice.core.internals;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class ReturnTopicInfo
|
||||
public final class ReturnTopicInfo
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private int topic_id;
|
||||
private short topic_num;
|
||||
private Date create_date;
|
||||
private int topic_id; // the topic ID
|
||||
private short topic_num; // the topic number
|
||||
private Date create_date; // the creation date
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
|
@ -48,19 +48,19 @@ public class ReturnTopicInfo
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public int getTopicID()
|
||||
public final int getTopicID()
|
||||
{
|
||||
return topic_id;
|
||||
|
||||
} // end getTopicID
|
||||
|
||||
public short getTopicNum()
|
||||
public final short getTopicNum()
|
||||
{
|
||||
return topic_num;
|
||||
|
||||
} // end getTopicNum
|
||||
|
||||
public Date getCreateDate()
|
||||
public final Date getCreateDate()
|
||||
{
|
||||
return create_date;
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.core.impl;
|
||||
package com.silverwrist.venice.core.internals;
|
||||
|
||||
import com.silverwrist.venice.core.DataException;
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* 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 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>,
|
||||
* 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
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CDEmailAddressFormField(String name, String caption, String caption2, boolean required,
|
||||
int size, int maxlength)
|
||||
{
|
||||
|
@ -35,13 +40,24 @@ public class CDEmailAddressFormField extends CDTextFormField
|
|||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class CDTextFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void validateContents(String value) throws ValidationException
|
||||
{
|
||||
super.validateContents(value);
|
||||
if (!IDUtils.isValidEmailAddress(value))
|
||||
throw new ValidationException("The value of '" + getCaption() + "' must be a correct Internet address.");
|
||||
|
||||
} // end validateContents
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface CDFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new CDEmailAddressFormField(this);
|
||||
|
|
|
@ -94,6 +94,7 @@ public class CDIntegerFormField extends CDTextFormField
|
|||
|
||||
protected void validateContents(String value) throws ValidationException
|
||||
{
|
||||
super.validateContents(value);
|
||||
try
|
||||
{ // convert to an integer and check against range
|
||||
int x = Integer.parseInt(value);
|
||||
|
|
|
@ -30,6 +30,7 @@ public class CDTextFormField extends CDBaseFormField
|
|||
|
||||
private int size;
|
||||
private int maxlength;
|
||||
private int real_maxlength;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
|
@ -40,8 +41,9 @@ public class CDTextFormField extends CDBaseFormField
|
|||
int size, int maxlength)
|
||||
{
|
||||
super(name,caption,caption2,required);
|
||||
this.size = size;
|
||||
this.maxlength = maxlength;
|
||||
this.size = Math.max(size,2);
|
||||
this.maxlength = Math.max(maxlength,2);
|
||||
this.real_maxlength = maxlength;
|
||||
|
||||
} // end constructor
|
||||
|
||||
|
@ -50,6 +52,7 @@ public class CDTextFormField extends CDBaseFormField
|
|||
super(other);
|
||||
this.size = other.size;
|
||||
this.maxlength = other.maxlength;
|
||||
this.real_maxlength = other.real_maxlength;
|
||||
|
||||
} // end constructor
|
||||
|
||||
|
@ -73,7 +76,11 @@ public class CDTextFormField extends CDBaseFormField
|
|||
} // end renderActualField
|
||||
|
||||
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
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
|
|
|
@ -47,12 +47,18 @@ public class CDVeniceIDFormField extends CDTextFormField
|
|||
|
||||
protected void validateContents(String value) throws ValidationException
|
||||
{
|
||||
super.validateContents(value);
|
||||
if (!IDUtils.isValidVeniceID(value))
|
||||
throw new ValidationException("There is an invalid character in the '" + getCaption() + "'field. "
|
||||
+ "Valid characters are letters, digits, -, _, !, ~, *, ', and $.");
|
||||
|
||||
} // end validateContents
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface CDFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDVeniceIDFormField(this);
|
||||
|
|
Loading…
Reference in New Issue
Block a user