implemented most of the Manage Conference functions - set pseud, fixseen,

conference edit, alias management, poster and lurker reports
This commit is contained in:
Eric J. Bowersox
2001-02-12 01:50:10 +00:00
parent f706cdaf5f
commit 0070e4fb44
31 changed files with 1260 additions and 47 deletions
@@ -0,0 +1,32 @@
/*
* 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;
import java.util.Date;
public interface ActiveUser
{
public abstract int getUID();
public abstract String getName();
public abstract Date getLastRead();
public abstract Date getLastWrite();
} // end interface ActiveUser
@@ -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
@@ -119,4 +119,16 @@ public interface ConferenceContext
public abstract void fixSeen() throws DataException;
public abstract List getActivePosters(int skip, int limit) throws DataException;
public abstract List getActivePosters(int limit) throws DataException;
public abstract List getActivePosters() throws DataException;
public abstract List getActiveReaders(int skip, int limit) throws DataException;
public abstract List getActiveReaders(int limit) throws DataException;
public abstract List getActiveReaders() throws DataException;
} // end interface ConferenceContext
@@ -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
@@ -0,0 +1,78 @@
/*
* 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.impl;
import java.util.Date;
import com.silverwrist.venice.core.ActiveUser;
class ActiveUserImpl implements ActiveUser
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private int uid;
private String name;
private Date last_read;
private Date last_write;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
ActiveUserImpl(int uid, String name, Date last_read, Date last_write)
{
this.uid = uid;
this.name = name;
this.last_read = last_read;
this.last_write = last_write;
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface ActiveUser
*--------------------------------------------------------------------------------
*/
public int getUID()
{
return uid;
} // end getUID
public String getName()
{
return name;
} // end getName
public Date getLastRead()
{
return last_read;
} // end getLastRead
public Date getLastWrite()
{
return last_write;
} // end getLastWrite
} // end class ActiveUserImpl
@@ -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
@@ -633,7 +633,7 @@ class ConferenceCoreData implements ConferenceData
// OK, go delete the row (or not, if this alias is not in the table)
sql.setLength(0);
sql.append("DELETE FROM confalias WHERE confid = ").append(confid).append("AND alias = '");
sql.append("DELETE FROM confalias WHERE confid = ").append(confid).append(" AND alias = '");
sql.append(SQLUtil.encodeString(alias)).append("';");
did_it = (stmt.executeUpdate(sql.toString())>0);
@@ -648,7 +648,7 @@ class ConferenceCoreData implements ConferenceData
if (did_it)
{ // set the database's update date and generate a new audit record
touchUpdate(conn);
if (cached_alias.equals(alias))
if ((cached_alias!=null) && cached_alias.equals(alias))
cached_alias = null; // also release the cached alias and force a re-get
ar = new AuditRecord(AuditRecord.CONF_ALIAS,sig.realUID(),sig.userRemoteAddress(),sig.realSIGID(),
"conf=" + String.valueOf(confid),"remove=" + alias);
@@ -738,6 +738,9 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
public void setDefaultPseud(String val) throws DataException
{
if (sig.userIsAnonymous())
return; // anonymous user can't change pseud
Connection conn = null; // pooled database connection
try
@@ -952,6 +955,9 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
public void fixSeen() throws DataException
{
if (sig.userIsAnonymous())
return; // anonymous user can't fixseen
Connection conn = null;
try
@@ -1012,6 +1018,126 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
} // end fixSeen
public List getActivePosters(int skip, int limit) throws DataException
{
Connection conn = null;
Vector rc = new Vector();
try
{ // retrieve a connection from the datapool
conn = datapool.getConnection();
Statement stmt = conn.createStatement();
// create the SQL statement to retrieve all posters
StringBuffer sql =
new StringBuffer("SELECT s.uid, u.username, s.last_read, s.last_post FROM confsettings s, "
+ "users u WHERE u.uid = s.uid AND s.confid = ");
sql.append(confid).append(" AND u.is_anon = 0 AND ISNULL(s.last_post) = 0 ORDER BY s.last_post DESC");
if ((skip>=0) && (limit>0))
sql.append(" LIMIT ").append(skip).append(", ").append(limit);
sql.append(';');
// execute the statement
ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next())
{ // return all the records as ActiveUser data elements
ActiveUser usr = new ActiveUserImpl(rs.getInt(1),rs.getString(2),SQLUtil.getFullDateTime(rs,3),
SQLUtil.getFullDateTime(rs,4));
rc.add(usr);
} // end while
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error getting active poster list: " + e.getMessage(),e);
throw new DataException("unable to get active poster listing: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
if (conn!=null)
datapool.releaseConnection(conn);
} // end finally
return new ReadOnlyVector(rc);
} // end getActivePosters
public List getActivePosters(int limit) throws DataException
{
return getActivePosters(0,limit);
} // end getActivePosters
public List getActivePosters() throws DataException
{
return getActivePosters(-1,-1);
} // end getActivePosters
public List getActiveReaders(int skip, int limit) throws DataException
{
Connection conn = null;
Vector rc = new Vector();
try
{ // retrieve a connection from the datapool
conn = datapool.getConnection();
Statement stmt = conn.createStatement();
// create the SQL statement to retrieve all readers
StringBuffer sql =
new StringBuffer("SELECT s.uid, u.username, s.last_read, s.last_post FROM confsettings s, "
+ "users u WHERE u.uid = s.uid AND s.confid = ");
sql.append(confid).append(" AND u.is_anon = 0 AND ISNULL(s.last_read) = 0 ORDER BY s.last_read DESC");
if ((skip>=0) && (limit>0))
sql.append(" LIMIT ").append(skip).append(", ").append(limit);
sql.append(';');
// execute the statement
ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next())
{ // return all the records as ActiveUser data elements
ActiveUser usr = new ActiveUserImpl(rs.getInt(1),rs.getString(2),SQLUtil.getFullDateTime(rs,3),
SQLUtil.getFullDateTime(rs,4));
rc.add(usr);
} // end while
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error getting active reader list: " + e.getMessage(),e);
throw new DataException("unable to get active reader listing: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
if (conn!=null)
datapool.releaseConnection(conn);
} // end finally
return new ReadOnlyVector(rc);
} // end getActiveReaders
public List getActiveReaders(int limit) throws DataException
{
return getActiveReaders(0,limit);
} // end getActiveReaders
public List getActiveReaders() throws DataException
{
return getActiveReaders(-1,-1);
} // end getActiveReaders
/*--------------------------------------------------------------------------------
* Implementations from interface UserBackend
*--------------------------------------------------------------------------------
@@ -1041,6 +1167,12 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
} // end userDefaultPseud
public boolean userIsAnonymous()
{
return sig.userIsAnonymous();
} // end userIsAnonymous
/*--------------------------------------------------------------------------------
* Implementations from interface SIGBackend
*--------------------------------------------------------------------------------
@@ -1104,6 +1236,9 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
public void touchRead(Connection conn) throws SQLException
{
if (sig.userIsAnonymous())
return; // anonymous user can't update squat
Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer();
@@ -1133,6 +1268,9 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
public void touchPost(Connection conn, java.util.Date post_date) throws SQLException
{
if (sig.userIsAnonymous())
return; // anonymous user can't update squat
Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer();
@@ -1102,6 +1102,12 @@ class SIGUserContextImpl implements SIGContext, SIGBackend
} // end userDefaultPseud
public boolean userIsAnonymous()
{
return user.userIsAnonymous();
} // end userIsAnonymous
/*--------------------------------------------------------------------------------
* Implementations from interface SIGBackend
*--------------------------------------------------------------------------------
@@ -443,13 +443,13 @@ class TopicMessageUserContextImpl implements TopicMessageContext
public boolean canHide()
{
return ((creator_uid==conf.realUID()) || conf.userCanHide());
return (((creator_uid==conf.realUID()) && (!conf.userIsAnonymous())) || conf.userCanHide());
} // end canHide
public boolean canScribble()
{
return ((creator_uid==conf.realUID()) || conf.userCanScribble());
return (((creator_uid==conf.realUID()) && (!conf.userIsAnonymous())) || conf.userCanScribble());
} // end canScribble
@@ -461,6 +461,8 @@ class TopicMessageUserContextImpl implements TopicMessageContext
public void setHidden(boolean flag) throws DataException, AccessError
{
if (conf.userIsAnonymous())
return; // no-op
if ((creator_uid!=conf.realUID()) && !(conf.userCanHide()))
{ // we can't change the hidden status!
logger.error("trying to set hidden status of post w/o permission!");
@@ -468,7 +470,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end if
if (nuked || (scribble_date!=null))
if (nuked || (scribble_date!=null) || (hidden==flag))
return; // changing the status of a nuked or scribbled post is futile
Connection conn = null;
@@ -539,6 +541,8 @@ class TopicMessageUserContextImpl implements TopicMessageContext
public void scribble() throws DataException, AccessError
{
if (conf.userIsAnonymous())
return; // no-op
if ((creator_uid!=conf.realUID()) && !(conf.userCanScribble()))
{ // we can't scribble this post
logger.error("trying to scribble post w/o permission!");
@@ -398,7 +398,7 @@ class TopicUserContextImpl implements TopicContext
public void setHidden(boolean flag) throws DataException
{
if ((hidden==flag) || deleted)
if ((hidden==flag) || deleted || conf.userIsAnonymous())
return; // no-op
Connection conn = null; // pooled database connection
@@ -474,6 +474,8 @@ class TopicUserContextImpl implements TopicContext
public void setUnreadMessages(int count) throws DataException
{
if (conf.userIsAnonymous())
return; // no-op
if (count>(top_message+1)) // constrain count to [0, top_message+1]
count = top_message + 1;
else if (count<0)
@@ -29,4 +29,6 @@ public interface UserBackend
public abstract String userDefaultPseud() throws DataException;
public abstract boolean userIsAnonymous();
} // end interface UserBackend
@@ -924,6 +924,12 @@ class UserContextImpl implements UserContext, UserBackend
} // end userDefaultPseud
public boolean userIsAnonymous()
{
return is_anon;
} // end userIsAnonymous
/*--------------------------------------------------------------------------------
* Operations private to implementation package
*--------------------------------------------------------------------------------