added topic links at the bottom of "published" posts, fixed the log in or

create problem when going through PostShortcut
This commit is contained in:
Eric J. Bowersox 2001-12-14 23:50:29 +00:00
parent a0a78059bc
commit b86ef1c3b0
12 changed files with 590 additions and 37 deletions

View File

@ -190,4 +190,6 @@ public interface ConferenceContext
public abstract int getSearchPostCount(String search_terms) throws AccessError, DataException;
public abstract String getPostLink() throws DataException;
} // end interface ConferenceContext

View File

@ -120,4 +120,8 @@ public interface TopicContext
public abstract int getSearchPostCount(String search_terms) throws AccessError, DataException;
public abstract ConferenceContext getEnclosingConference();
public abstract String getPostLink() throws DataException;
} // end interface TopicContext

View File

@ -79,4 +79,8 @@ public interface TopicMessageContext
public abstract void publish() throws DataException, AccessError;
public abstract TopicContext getEnclosingTopic() throws DataException;
public abstract String getPostLink() throws DataException;
} // end interface TopicMessageContext

View File

@ -1736,11 +1736,27 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
} // end getSearchPostCount
public String getPostLink() throws DataException
{
if (deleted)
return null;
String v = getConferenceData().getAnAlias();
return env.getCommunityAlias() + "!" + v;
} // end getPostLink
/*--------------------------------------------------------------------------------
* Implementations from interface ConferenceBackend
*--------------------------------------------------------------------------------
*/
public ConferenceContext selfConference()
{
return this;
} // end selfConference
public int realConfID()
{
return confid;

View File

@ -42,8 +42,10 @@ class PublishedMessageImpl implements TopicMessageContext
*/
private EnvEngine env; // the execution environment
private int cid;
private long postid;
private long parent;
private int topicid;
private int num;
private int linecount;
private int creator_uid;
@ -51,18 +53,22 @@ class PublishedMessageImpl implements TopicMessageContext
private String pseud;
private String creator_cache = null;
private String text_cache = null;
private PublishedMessageTopicImpl topic = null;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
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)
PublishedMessageImpl(EnvEngine env, int cid, long postid, long parent, int topicid, int num, int linecount,
int creator_uid, java.util.Date posted, String pseud, String creator_cache,
String text_cache)
{
this.env = env;
this.cid = cid;
this.postid = postid;
this.parent = parent;
this.topicid = topicid;
this.num = num;
this.linecount = linecount;
this.creator_uid = creator_uid;
@ -73,12 +79,14 @@ class PublishedMessageImpl implements TopicMessageContext
} // end constructor
protected PublishedMessageImpl(EnvEngine env, long postid, long parent, int num, int linecount,
int creator_uid, java.util.Date posted, String pseud)
protected PublishedMessageImpl(EnvEngine env, int cid, long postid, long parent, int topicid, int num,
int linecount, int creator_uid, java.util.Date posted, String pseud)
{
this.env = env;
this.cid = cid;
this.postid = postid;
this.parent = parent;
this.topicid = topicid;
this.num = num;
this.linecount = linecount;
this.creator_uid = creator_uid;
@ -327,6 +335,20 @@ class PublishedMessageImpl implements TopicMessageContext
} // end publish
public TopicContext getEnclosingTopic() throws DataException
{
if (topic==null)
topic = new PublishedMessageTopicImpl(env,cid,topicid);
return topic;
} // end getEnclosingTopic
public String getPostLink() throws DataException
{
return getEnclosingTopic().getPostLink() + "." + num;
} // end getPostLink
/*--------------------------------------------------------------------------------
* Static operations usable only within package
*--------------------------------------------------------------------------------
@ -343,8 +365,8 @@ class PublishedMessageImpl implements TopicMessageContext
// create the statement to retrieve the post information
StringBuffer sql =
new StringBuffer("SELECT p.postid, q.parent, q.num, q.linecount, q.creator_uid, q.posted, "
+ "q.pseud FROM postpublish p, posts q WHERE p.postid = q.postid "
new StringBuffer("SELECT p.sigid, p.postid, q.parent, q.topicid, q.num, q.linecount, q.creator_uid, "
+ "q.posted, q.pseud FROM postpublish p, posts q WHERE p.postid = q.postid "
+ "ORDER BY p.on_date DESC, p.postid ASC LIMIT ");
sql.append(cache_list.size()).append(", ").append(desired_size-cache_list.size()).append(';');
@ -352,9 +374,9 @@ class PublishedMessageImpl implements TopicMessageContext
ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next())
{ // 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));
TopicMessageContext tmc = new PublishedMessageImpl(env,rs.getInt(1),rs.getLong(2),rs.getLong(3),
rs.getInt(4),rs.getInt(5),rs.getInt(6),rs.getInt(7),
SQLUtil.getFullDateTime(rs,8),rs.getString(9));
cache_list.add(tmc);
} // end while
@ -391,9 +413,9 @@ class PublishedMessageImpl implements TopicMessageContext
return; // nothing to do here!
// execute the statement to retrieve the post information
final String sql = "SELECT p.postid, q.parent, q.num, q.linecount, q.creator_uid, q.posted, q.pseud "
+ "FROM postpublish p, posts q WHERE p.postid = q.postid ORDER BY p.on_date DESC, "
+ "p.postid ASC;";
final String sql = "SELECT p.sigid, p.postid, q.parent, q.topicid, q.num, q.linecount, q.creator_uid, "
+ "q.posted, q.pseud FROM postpublish p, posts q WHERE p.postid = q.postid "
+ "ORDER BY p.on_date DESC, p.postid ASC;";
rs = stmt.executeQuery(sql);
// append to the output list
@ -403,8 +425,9 @@ class PublishedMessageImpl implements TopicMessageContext
if ((ctr--)<=0)
{ // append context, please
TopicMessageContext ctxt =
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));
new PublishedMessageImpl(env,rs.getInt(1),rs.getLong(2),rs.getLong(3),rs.getInt(4),rs.getInt(5),
rs.getInt(6),rs.getInt(7),SQLUtil.getFullDateTime(rs,8),
rs.getString(9));
return_list.add(ctxt);
} // end if

View File

@ -0,0 +1,396 @@
/*
* 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.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.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.htmlcheck.HTMLChecker;
class PublishedMessageTopicImpl implements TopicContext
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(PublishedMessageTopicImpl.class);
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private EnvEngine env;
private int cid;
private int topicid;
private short topicnum;
private int creator_uid;
private int total_msgs;
private boolean frozen;
private boolean archived;
private java.util.Date createdate;
private java.util.Date lastupdate;
private String name;
private String postlink;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
PublishedMessageTopicImpl(EnvEngine env, int cid, int topicid) throws DataException
{
Connection conn = null;
try
{ // get a database connection
conn = env.getConnection();
Statement stmt = conn.createStatement();
// query the topics table for information
StringBuffer sql =
new StringBuffer("SELECT confid, num, creator_uid, top_message, frozen, archived, createdate, "
+ "lastupdate, name FROM topics WHERE topicid = ");
sql.append(topicid).append(";");
ResultSet rs = stmt.executeQuery(sql.toString());
if (!(rs.next()))
throw new DataException("Topic with ID " + topicid + " not found");
// fill internal attributes with data
this.env = env;
this.cid = cid;
this.topicid = topicid;
int confid = rs.getInt(1);
this.topicnum = rs.getShort(2);
this.creator_uid = rs.getInt(3);
this.total_msgs = rs.getInt(4) + 1;
this.frozen = rs.getBoolean(5);
this.archived = rs.getBoolean(6);
this.createdate = SQLUtil.getFullDateTime(rs,7);
this.lastupdate = SQLUtil.getFullDateTime(rs,8);
this.name = rs.getString(9);
// retrieve the community alias
rs = stmt.executeQuery("SELECT alias FROM sigs WHERE sigid = " + cid + ";");
if (!(rs.next()))
throw new DataException("Community with ID " + cid + " not found");
postlink = rs.getString(1) + "!";
// retrieve a conference alias
rs = stmt.executeQuery("SELECT alias FROM confalias WHERE confid = " + confid + " LIMIT 1;");
if (!(rs.next()))
throw new DataException("Conference with ID " + confid + " not found");
postlink += (rs.getString(1) + "." + topicnum);
} // end try
catch (SQLException e)
{ // turn this into a data exception
logger.error("unable to get topic data",e);
throw new DataException("Error getting topic data: " + e.getMessage(),e);
} // end catch
finally
{ // release the connection
env.releaseConnection(conn);
} // end finally
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface TopicContext
*--------------------------------------------------------------------------------
*/
public void refresh()
{ // do nothing
} // end refresh
public int getTopicID()
{
return topicid;
} // end getTopicID
public short getTopicNumber()
{
return topicnum;
} // end getTopicNumber
public String getName()
{
return name;
} // end getName
public int getUnreadMessages()
{
return 0;
} // end getUnreadMessages
public int getTotalMessages()
{
return total_msgs;
} // end getTotalMessages
public java.util.Date getLastUpdateDate()
{
return lastupdate;
} // end getLastUpdateDate
public int getCreatorUID()
{
return creator_uid;
} // end getCreatorUID
public boolean isFrozen()
{
return frozen;
} // end isFrozen
public boolean isArchived()
{
return archived;
} // end isArchived
public java.util.Date getCreatedDate()
{
return createdate;
} // end egtCreatedDate
public boolean isHidden()
{
return false;
} // end isHidden
public boolean isDeleted()
{
return false;
} // end isDeleted
public boolean canFreeze()
{
return false;
} // end canFreeze
public boolean canArchive()
{
return false;
} // end canArchive
public void setFrozen(boolean flag) throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end setFrozen
public void setArchived(boolean flag) throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end setArchived
public void setHidden(boolean flag)
{ // do nothing
} // end setHidden
public int getFirstUnreadMessage()
{
return -1;
} // end getFirstUnreadMessage
public void setUnreadMessages(int count)
{ // do nothing
} // end setUnreadMessages
public void fixSeen()
{ // do nothing
} // end fixSeen
public List getMessages(int low, int high) throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end getMessages
public TopicMessageContext getMessage(int number) throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end getMessage
public TopicMessageContext postNewMessage(long parent, String pseud, String text) throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end postNewMessage
public HTMLChecker getPreviewChecker()
{
return null;
} // end getPreviewChecker
public boolean canDelete()
{
return false;
} // end canDelete
public void delete() throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end delete
public void deleteTopic() throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end deleteTopic
public List getActivePosters(int skip, int limit) throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end getActivePosters
public List getActivePosters(int limit) throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end getActivePosters
public List getActivePosters() throws DataException, AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end getActivePosters
public List getActiveReaders(int skip, int limit) throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end getActiveReaders
public List getActiveReaders(int limit) throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end getActiveReaders
public List getActiveReaders() throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end getActiveReaders
public boolean isBozo(int other_uid)
{
return false;
} // end isBozo
public void setBozo(int other_uid, boolean bozo)
{ // do nothing
} // end setBozo
public boolean canSetBozo(int other_uid)
{
return false;
} // end canSetBozo
public List getBozos()
{
return Collections.EMPTY_LIST;
} // end getBozos
public boolean isSubscribed()
{
return false;
} // end isSubscribed
public void setSubscribed(boolean flag)
{ // do nothing
} // end setSubscribed
public void sendInvitation(String address, String personal_message) throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end sendInvitation
public boolean canSendInvitation()
{
return false;
} // end canSendInvitation
public void sendMailToParticipants(boolean posters, int day_limit, String subject, String text)
throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end sendMailToParticipants
public List searchPosts(String search_terms, int offset, int count)
throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end searchPosts
public int getSearchPostCount(String search_terms) throws AccessError
{
throw new AccessError("cannot perform this function from a read-only topic view");
} // end getSearchPostCount
public ConferenceContext getEnclosingConference()
{
throw new InternalStateError("function not implemented");
} // end getEnclosingConference
public String getPostLink()
{
return postlink;
} // end getPostLink
} // end PublishedMessageTopicImpl

View File

@ -49,6 +49,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
private EnvConference env; // the conference environment
private long postid; // the ID of this post
private long parent; // the parent post ID (not really used)
private int topicid; // the topic ID we live within
private int num; // the post number within the topic
private int linecount; // number of lines in message
private int creator_uid; // the UID of the poster
@ -70,14 +71,15 @@ class TopicMessageUserContextImpl implements TopicMessageContext
*--------------------------------------------------------------------------------
*/
protected TopicMessageUserContextImpl(EnvConference env, long postid, long parent, int num, int linecount,
int creator_uid, java.util.Date posted, boolean hidden,
protected TopicMessageUserContextImpl(EnvConference env, long postid, long parent, int topicid, 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.env = env;
this.postid = postid;
this.parent = parent;
this.topicid = topicid;
this.num = num;
this.linecount = linecount;
this.creator_uid = creator_uid;
@ -93,12 +95,13 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end constructor
TopicMessageUserContextImpl(EnvConference env, long postid, long parent, int num, int linecount,
TopicMessageUserContextImpl(EnvConference env, long postid, long parent, int topicid, int num, int linecount,
int creator_uid, java.util.Date posted, String pseud)
{
this.env = env;
this.postid = postid;
this.parent = parent;
this.topicid = topicid;
this.num = num;
this.linecount = linecount;
this.creator_uid = creator_uid;
@ -1007,8 +1010,9 @@ class TopicMessageUserContextImpl implements TopicMessageContext
ar = env.newAudit(AuditRecord.PUBLISH_POST,"conf=" + env.getConfID() + ",post=" + postid);
// establish cached data object for front page
env.getEngine().publishNew(new PublishedMessageImpl(env,postid,parent,num,linecount,creator_uid,
posted,pseud,creator_cache,text_cache));
env.getEngine().publishNew(new PublishedMessageImpl(env,env.getCommunityID(),postid,parent,topicid,
num,linecount,creator_uid,posted,pseud,
creator_cache,text_cache));
done = true;
} // end try
@ -1035,6 +1039,48 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end publish
public TopicContext getEnclosingTopic() throws DataException
{
return TopicUserContextImpl.getTopicByID(env,topicid);
} // end getEnclosingTopic
public String getPostLink() throws DataException
{
if (nuked)
return null;
String prefix = env.getConference().selfConference().getPostLink();
short topicnum = -1;
Connection conn = null;
try
{ // get a database connection
conn = env.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT num FROM topics WHERE topicid = " + topicid + ";");
if (!(rs.next()))
throw new DataException("unable to locate topic number for topic ID " + topicid);
topicnum = rs.getShort(1);
} // end try
catch (SQLException e)
{ // just trap SQL exceptions and log them
logger.error("unable to get topic number: " + e.getMessage(),e);
throw new DataException("unable to get topic number: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
env.releaseConnection(conn);
} // end finally
// composite together the post link value
return prefix + "." + topicnum + "." + num;
} // end getPostLink
/*--------------------------------------------------------------------------------
* External static operations
*--------------------------------------------------------------------------------
@ -1070,7 +1116,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
while (rs.next())
{ // create implementation objects and shove them into the return vector
TopicMessageContext val =
new TopicMessageUserContextImpl(env,rs.getLong(1),rs.getLong(2),rs.getInt(3),rs.getInt(4),
new TopicMessageUserContextImpl(env,rs.getLong(1),rs.getLong(2),topicid,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));
@ -1120,10 +1166,11 @@ class TopicMessageUserContextImpl implements TopicMessageContext
ResultSet rs = stmt.executeQuery(sql.toString());
if (rs.next()) // create an object reference and return it
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));
return new TopicMessageUserContextImpl(env,rs.getLong(1),rs.getLong(2),topicid,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.");
@ -1156,10 +1203,11 @@ class TopicMessageUserContextImpl implements TopicMessageContext
Statement stmt = conn.createStatement();
StringBuffer sql =
new StringBuffer("SELECT p.postid, p.parent, p.num, p.linecount, p.creator_uid, p.posted, "
+ "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 = ");
new StringBuffer("SELECT p.postid, p.parent, p.topicid, p.num, p.linecount, p.creator_uid, "
+ "p.posted, 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(env.getConfID()).append(" AND p.postid = ").append(postid).append(';');
if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString());
@ -1167,9 +1215,10 @@ class TopicMessageUserContextImpl implements TopicMessageContext
if (rs.next()) // create an object reference and return it
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));
rs.getInt(5),rs.getInt(6),SQLUtil.getFullDateTime(rs,7),
rs.getBoolean(8),rs.getInt(9),SQLUtil.getFullDateTime(rs,10),
rs.getString(11),rs.getInt(12),rs.getString(13),
rs.getString(14),rs.getInt(15));
// indicates an error...
throw new DataException("Message not found.");

View File

@ -850,8 +850,8 @@ class TopicUserContextImpl implements TopicContext
// else don't bother - it would be a waste of time
// return the new message context
return new TopicMessageUserContextImpl(env,new_post_id,parent,new_post_num,text_linecount,env.getUserID(),
posted_date,real_pseud);
return new TopicMessageUserContextImpl(env,new_post_id,parent,topicid,new_post_num,text_linecount,
env.getUserID(),posted_date,real_pseud);
} // end postMessage
@ -1516,6 +1516,20 @@ class TopicUserContextImpl implements TopicContext
} // end getSearchPostCount
public ConferenceContext getEnclosingConference()
{
return env.getConference().selfConference();
} // end getEnclosingConference
public String getPostLink() throws DataException
{
if (deleted)
return null;
return env.getConference().selfConference().getPostLink() + "." + topicnum;
} // end getPostLink
/*--------------------------------------------------------------------------------
* External operations usable only from within the package
*--------------------------------------------------------------------------------

View File

@ -20,11 +20,14 @@ package com.silverwrist.venice.core.internals;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;
import com.silverwrist.venice.core.ConferenceContext;
import com.silverwrist.venice.db.PostLinkDecoderContext;
import com.silverwrist.venice.except.DataException;
public interface ConferenceBackend
{
public abstract ConferenceContext selfConference();
public abstract int realConfID();
public abstract boolean userCanHide();

View File

@ -98,7 +98,10 @@ public class PostShortcut extends VeniceServlet
} // end catch
catch (AccessError ae)
{ // we can't get to the conference...
return new ErrorBox("Access Error",ae.getMessage(),null);
if (user.isLoggedIn())
return new ErrorBox("Access Error",ae.getMessage(),null);
else
return new LogInOrCreate("go/" + raw_link);
} // end catch
@ -122,7 +125,10 @@ public class PostShortcut extends VeniceServlet
} // end catch
catch (AccessError ae)
{ // we can't get to the topic...
return new ErrorBox("Access Error",ae.getMessage(),null);
if (user.isLoggedIn())
return new ErrorBox("Access Error",ae.getMessage(),null);
else
return new LogInOrCreate("go/" + raw_link);
} // end catch

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
@ -33,6 +34,8 @@ public class TopDisplay implements ContentRender, ColorSelectors
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(TopDisplay.class);
private static final String ATTR_NAME = "com.silverwrist.venice.TopDisplay";
/*--------------------------------------------------------------------------------
@ -125,6 +128,7 @@ public class TopDisplay implements ContentRender, ColorSelectors
} // end try
catch (ServletException se)
{ // since we can't throw ServletException, we throw IOException
logger.error("top_content.jsp failure",se);
throw new IOException("Failure including top_content.jsp");
} // end catch
@ -162,7 +166,8 @@ public class TopDisplay implements ContentRender, ColorSelectors
} // end try
catch (ServletException se)
{ // since we can't throw ServletException, we throw IOException
{ // since we can't throw ServletException, we write an error message
logger.error("sidebox #" + i + " failure",se);
out.write(rdat.getStdFontTag(SIDEBOX_CONTENT_FOREGROUND,2) + "<EM>failure rendering class "
+ sideboxes[i].getClass().getName() + ": " + StringUtil.encodeHTML(se.getMessage())
+ "</EM></FONT>\n");
@ -173,10 +178,14 @@ public class TopDisplay implements ContentRender, ColorSelectors
rdat.flushOutput(); // now make sure the included page is properly flushed
} // end else if
else // this is bogus - just display a little error here
else
{ // this is bogus - just display a little error here
logger.error("sidebox #" + i + " class " + sideboxes[i].getClass().getName() + " cannot be rendered");
out.write(rdat.getStdFontTag(SIDEBOX_CONTENT_FOREGROUND,2) + "<EM>cannot display sidebox of class: "
+ sideboxes[i].getClass().getName() + "</EM></FONT>\n");
} // end else
// close up the framework of this sidebox
out.write("</TD></TR></TABLE><P>\n");
@ -215,6 +224,29 @@ public class TopDisplay implements ContentRender, ColorSelectors
} // end getPosterName
public static String getTopicPostLink(RenderData rdat, TopicMessageContext msg)
{
try
{ // retrieve the topic post link and name, and combine them
TopicContext topic = msg.getEnclosingTopic();
String plink = topic.getPostLink();
return "<A HREF=\"" + rdat.getEncodedServletPath("go/" + plink) + "\">" + topic.getName() + "</A>";
} // end try
catch (DataException de)
{ // just return null on failure
return null;
} // end catch
catch (Exception e)
{ // temporary guard point here
logger.error("Caught in getTopicPostLink:",e);
return null;
} // end catch
} // end getTopicPostLink
public static String getMessageBodyText(TopicMessageContext msg)
{
try

View File

@ -37,6 +37,7 @@
for (int i=0; i<ntp; i++) {
TopicMessageContext msg = data.getTopPost(i);
String poster = data.getPosterName(msg);
String topic_link = data.getTopicPostLink(rdat,msg);
%>
<% if (i>0) { %><HR WIDTH="70%"><% } %>
<%= rdat.getStdFontTag(ColorSelectors.CONTENT_FOREGROUND,2) %>
@ -47,6 +48,9 @@
</EM>)
<P>
<PRE><%= rdat.rewritePostData(data.getMessageBodyText(msg)) %></PRE>
<% if (topic_link!=null) { %>
<P><FONT SIZE=-1><EM>(From the topic: <%= topic_link %>)</EM></FONT><BR>
<% } // end if %>
</FONT>
<%
} // end for