From 3d32fe95c5609290e09ed901b4105a5a432b988a Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Sat, 7 Apr 2001 05:30:33 +0000 Subject: [PATCH] second round of public beta bugfixes: - fixed a bug in navigation between conferences via post links - fixed the "your post is 'new'" bug (this was actually another bug, in postNewMessage()) - some other stuff --- etc/erbo.dict | 1 + .../core/impl/TopicUserContextImpl.java | 43 +++++++++++++++++-- .../venice/servlets/ConfDisplay.java | 2 +- .../venice/servlets/ConfOperations.java | 13 ++++-- .../venice/servlets/format/TopicPosts.java | 27 +++++++++--- .../servlets/format/TopicVisitOrder.java | 6 +-- 6 files changed, 75 insertions(+), 17 deletions(-) diff --git a/etc/erbo.dict b/etc/erbo.dict index eba346a..c358a5c 100644 --- a/etc/erbo.dict +++ b/etc/erbo.dict @@ -12,6 +12,7 @@ can't cartman cdt checkouts +communityware couldn't crewmember crewmembers diff --git a/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java b/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java index 8547321..1e421f8 100644 --- a/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java @@ -475,14 +475,29 @@ class TopicUserContextImpl implements TopicContext public void setUnreadMessages(int count) throws DataException { + if (logger.isDebugEnabled()) + logger.debug("[raw] setUnreadMessages(" + count + ") entry"); + if (conf.userIsAnonymous()) - return; // no-op + { // this is effectively a no-op, but log it + logger.debug("reject 1: anonymous user"); + return; + + } // end if if (count>(top_message+1)) // constrain count to [0, top_message+1] count = top_message + 1; else if (count<0) count = 0; if ((count==unread) || deleted) - return; // no-op + { // this is effectively a no-op, but log it + if (logger.isDebugEnabled()) + logger.debug("reject 2: count=" + count + ", unread=" + unread + ", deleted=" + deleted); + return; + + } // end if + + if (logger.isInfoEnabled()) + logger.info("[cooked] setUnreadMessages(" + count + ") entry"); int last_msg = top_message - count; Connection conn = null; // pooled database connection @@ -498,8 +513,11 @@ class TopicUserContextImpl implements TopicContext StringBuffer sql = new StringBuffer("UPDATE topicsettings SET last_message = "); sql.append(last_msg).append(" WHERE topicid = ").append(topicid).append(" AND uid = "); sql.append(conf.realUID()).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); unread = count; return; @@ -509,9 +527,12 @@ class TopicUserContextImpl implements TopicContext // OK, check: Is the topic still there?!? sql.setLength(0); sql.append("SELECT topicid from topics WHERE topicid = ").append(topicid).append(';'); + if (logger.isDebugEnabled()) + logger.debug("SQL: " + sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString()); if (!(rs.next())) { // the topic's been deleted - bail out + logger.debug("--> bailed out because topic is deleted - done with setUnreadMessages{"); makeDeleted(); return; @@ -521,6 +542,8 @@ class TopicUserContextImpl implements TopicContext sql.setLength(0); sql.append("INSERT INTO topicsettings (topicid, uid, last_message) VALUES (").append(topicid); sql.append(", ").append(conf.realUID()).append(", ").append(last_msg).append(");"); + if (logger.isDebugEnabled()) + logger.debug("SQL: " + sql.toString()); stmt.executeUpdate(sql.toString()); conf.touchRead(conn); unread = count; // successful completion @@ -589,6 +612,9 @@ class TopicUserContextImpl implements TopicContext public TopicMessageContext postNewMessage(long parent, String pseud, String text) throws DataException, AccessError { + if (logger.isInfoEnabled()) + logger.info("postNewMessage(" + parent + ", '" + pseud + "',) entry"); + if (!(conf.userCanPost())) { // they can't post in this topic! logger.error("trying to post w/o permission!"); @@ -642,6 +668,8 @@ class TopicUserContextImpl implements TopicContext real_pseud = pseud_ch.getValue(); real_text = text_ch.getValue(); text_linecount = text_ch.getLines(); + if (logger.isDebugEnabled()) + logger.debug("new post has " + text_linecount + " lines"); } // end try catch (NotYetFinishedException e) @@ -691,6 +719,8 @@ class TopicUserContextImpl implements TopicContext // Determine what the new post number is. new_post_num = top_message + 1; + if (logger.isDebugEnabled()) + logger.debug("New post number: " + new_post_num); // Add the post "header" to the posts table. StringBuffer sql = new StringBuffer("INSERT INTO posts (parent, topicid, num, linecount, creator_uid, " @@ -708,6 +738,8 @@ class TopicUserContextImpl implements TopicContext if (!(rs.next())) throw new InternalStateError("postMessage(): Unable to get new post ID!"); new_post_id = rs.getLong(1); + if (logger.isDebugEnabled()) + logger.debug("New post ID: " + new_post_id); // Touch the topic values to reflect the added post. sql.setLength(0); @@ -727,9 +759,14 @@ class TopicUserContextImpl implements TopicContext conf.touchUpdate(conn,posted_date); conf.touchPost(conn,posted_date); - // fill in our own local variables to reflect the update + // Fill in our own local variables to reflect the update. This includes the recalculation + // of "unread" based on the new value of "top_message". + int tmp_last_msg = top_message - unread; top_message = new_post_num; lastupdate = posted_date; + unread = top_message - tmp_last_msg; + + logger.debug("message post completed successfully"); } // end try finally diff --git a/src/com/silverwrist/venice/servlets/ConfDisplay.java b/src/com/silverwrist/venice/servlets/ConfDisplay.java index 8559b47..2d5dcbf 100644 --- a/src/com/silverwrist/venice/servlets/ConfDisplay.java +++ b/src/com/silverwrist/venice/servlets/ConfDisplay.java @@ -75,7 +75,7 @@ public class ConfDisplay extends VeniceServlet *-------------------------------------------------------------------------------- */ - private static Category logger = Category.getInstance(ConfDisplay.class.getName()); + private static Category logger = Category.getInstance(ConfDisplay.class); /*-------------------------------------------------------------------------------- * Internal functions diff --git a/src/com/silverwrist/venice/servlets/ConfOperations.java b/src/com/silverwrist/venice/servlets/ConfOperations.java index f5aab1c..ceff786 100644 --- a/src/com/silverwrist/venice/servlets/ConfOperations.java +++ b/src/com/silverwrist/venice/servlets/ConfOperations.java @@ -80,12 +80,12 @@ public class ConfOperations extends VeniceServlet private static boolean validateNewTopic(ServletRequest request, String on_error) throws ErrorBox { - boolean is_title_null, is_zp_null; + //boolean is_title_null, is_zp_null; String foo = request.getParameter("title"); if (foo==null) throw new ErrorBox(null,"Title parameter was not specified.",on_error); - is_title_null = (foo.length()==0); + //is_title_null = (foo.length()==0); foo = request.getParameter("pseud"); if (foo==null) @@ -94,9 +94,13 @@ public class ConfOperations extends VeniceServlet foo = request.getParameter("pb"); if (foo==null) throw new ErrorBox(null,"Body text was not specified.",on_error); - is_zp_null = (foo.length()==0); + //is_zp_null = (foo.length()==0); + /* EJB 4/5/2001 - remove this for consistency. FUTURE: bring it back under a global option? return is_title_null || is_zp_null; + -- end removed code */ + + return false; } // end validateNewTopic @@ -709,8 +713,11 @@ public class ConfOperations extends VeniceServlet } // end catch + /* EJB 4/5/2001 - code removed for consistency - FUTURE: bring it back controlled by + a global option? if (ntf.isNullRequest()) return null; // no title or text specified - "204 No Content" + -- end removed code */ setMyLocation(request,"confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=T"); return ntf; diff --git a/src/com/silverwrist/venice/servlets/format/TopicPosts.java b/src/com/silverwrist/venice/servlets/format/TopicPosts.java index 358f5d7..fd3c7df 100644 --- a/src/com/silverwrist/venice/servlets/format/TopicPosts.java +++ b/src/com/silverwrist/venice/servlets/format/TopicPosts.java @@ -20,6 +20,7 @@ package com.silverwrist.venice.servlets.format; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; +import org.apache.log4j.*; import com.silverwrist.util.StringUtil; import com.silverwrist.venice.core.*; @@ -30,6 +31,8 @@ public class TopicPosts implements JSPRender *-------------------------------------------------------------------------------- */ + private static Category logger = Category.getInstance(TopicPosts.class); + // Attribute name for request attribute protected static final String ATTR_NAME = "com.silverwrist.venice.content.TopicPosts"; @@ -60,6 +63,10 @@ public class TopicPosts implements JSPRender TopicContext topic, int first, int last, boolean read_new, boolean show_advanced) throws DataException, AccessError { + if (logger.isDebugEnabled()) + logger.debug("TopicPosts: sig=" + sig.getSIGID() + ", conf=" + conf.getConfID() + ", topic=" + + topic.getTopicNumber() + ", range=[" + first + ", " + last + "], rnm=" + read_new + + ", shac=" + show_advanced); this.engine = engine; this.sig = sig; this.conf = conf; @@ -70,9 +77,12 @@ public class TopicPosts implements JSPRender this.unread = topic.getUnreadMessages(); if (read_new) topic.setUnreadMessages(0); + if (logger.isDebugEnabled()) + logger.debug(this.unread + " unread messages"); this.messages = topic.getMessages(first,last); this.visit_order = TopicVisitOrder.retrieve(request.getSession(true),conf.getConfID()); - visit_order.visit(topic.getTopicNumber()); + if (visit_order!=null) + visit_order.visit(topic.getTopicNumber()); List aliases = conf.getAliases(); topic_stem = (String)(aliases.get(0)) + "." + String.valueOf(topic.getTopicNumber()) + "."; @@ -173,7 +183,10 @@ public class TopicPosts implements JSPRender public int getNextTopicNumber() { - return visit_order.getNext(); + if (visit_order!=null) + return visit_order.getNext(); + else + return -1; } // end getNextTopicNumber @@ -203,8 +216,9 @@ public class TopicPosts implements JSPRender public String getNextLocator() { StringBuffer buf = new StringBuffer("sig="); - buf.append(sig.getSIGID()).append("&conf=").append(conf.getConfID()).append("&top="); - buf.append(visit_order.getNext()); + buf.append(sig.getSIGID()).append("&conf=").append(conf.getConfID()); + if (visit_order!=null) + buf.append("&top=").append(visit_order.getNext()); return buf.toString(); } // end getNextLocator @@ -257,7 +271,10 @@ public class TopicPosts implements JSPRender public boolean canDoNextTopic() { - return visit_order.isNext(); + if (visit_order!=null) + return visit_order.isNext(); + else + return false; } // end canDoNextTopic diff --git a/src/com/silverwrist/venice/servlets/format/TopicVisitOrder.java b/src/com/silverwrist/venice/servlets/format/TopicVisitOrder.java index 9f85e75..d8ceef8 100644 --- a/src/com/silverwrist/venice/servlets/format/TopicVisitOrder.java +++ b/src/com/silverwrist/venice/servlets/format/TopicVisitOrder.java @@ -99,13 +99,9 @@ public class TopicVisitOrder TopicVisitOrder tvo = (TopicVisitOrder)(session.getAttribute(ATTRIBUTE)); if (tvo!=null) { // make sure the conference is OK - if (tvo.confid!=confid) - { // wrong conference - remove this - session.removeAttribute(ATTRIBUTE); + if (tvo.confid!=confid) // wrong conference - remove this tvo = null; - } // end if - } // end if return tvo;