fixed a bug with the topic visit order and another one with the anyUnread
function (it needs to ignore archived topics)
This commit is contained in:
@@ -250,14 +250,14 @@ public class ConfDisplay extends VeniceServlet
|
||||
|
||||
} // end getInterval
|
||||
|
||||
private static void restorePosts(ServletRequest request, ConferenceContext conf)
|
||||
private static boolean restorePosts(ServletRequest request, ConferenceContext conf, TopicContext curr_topic)
|
||||
{
|
||||
String xtopic = request.getParameter("rtop");
|
||||
if (StringUtil.isStringEmpty(xtopic))
|
||||
return;
|
||||
return true;
|
||||
String xcount = request.getParameter("rct");
|
||||
if (StringUtil.isStringEmpty(xcount))
|
||||
return;
|
||||
return true;
|
||||
|
||||
TopicContext topic;
|
||||
try
|
||||
@@ -268,19 +268,19 @@ public class ConfDisplay extends VeniceServlet
|
||||
catch (NumberFormatException nfe)
|
||||
{ // the topic number was invalid - forget it
|
||||
logger.warn("restorePosts: error translating topic number");
|
||||
return;
|
||||
return true;
|
||||
|
||||
} // end catch
|
||||
catch (DataException de)
|
||||
{ // could not get the topic...
|
||||
logger.warn("restorePosts: DataException getting topic - " + de.getMessage(),de);
|
||||
return;
|
||||
return true;
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // no access to the topic
|
||||
logger.warn("restorePosts: AccessError getting topic - " + ae.getMessage(),ae);
|
||||
return;
|
||||
return true;
|
||||
|
||||
} // end catch
|
||||
|
||||
@@ -291,7 +291,7 @@ public class ConfDisplay extends VeniceServlet
|
||||
if ((nunread<=0) || (nunread>topic.getTotalMessages()))
|
||||
{ // must be in the range [1, #messages]...
|
||||
logger.warn("restorePosts: unread post count out of range");
|
||||
return;
|
||||
return true;
|
||||
|
||||
} // end if
|
||||
|
||||
@@ -299,7 +299,7 @@ public class ConfDisplay extends VeniceServlet
|
||||
catch (NumberFormatException nfe)
|
||||
{ // the number of unread posts was invalid - forget it
|
||||
logger.warn("restorePosts: error translating unread post count");
|
||||
return;
|
||||
return true;
|
||||
|
||||
} // end catch
|
||||
|
||||
@@ -314,6 +314,8 @@ public class ConfDisplay extends VeniceServlet
|
||||
|
||||
} // end catch
|
||||
|
||||
return (topic.getTopicID()!=curr_topic.getTopicID());
|
||||
|
||||
} // end restorePosts
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
@@ -356,11 +358,11 @@ public class ConfDisplay extends VeniceServlet
|
||||
setMyLocation(request,on_error + "&topic=" + topic.getTopicNumber());
|
||||
|
||||
// if this request is restoring the number of unread posts in another topic, try to do so
|
||||
restorePosts(request,conf);
|
||||
boolean do_readnew = restorePosts(request,conf,topic);
|
||||
|
||||
// determine what the post interval is we want to display
|
||||
PostInterval piv = getInterval(engine,request,topic,on_error);
|
||||
boolean read_new = !(StringUtil.isStringEmpty(request.getParameter("rnm")));
|
||||
boolean read_new = do_readnew && !(StringUtil.isStringEmpty(request.getParameter("rnm")));
|
||||
boolean show_adv = !(StringUtil.isStringEmpty(request.getParameter("shac")));
|
||||
|
||||
// Create the post display.
|
||||
|
||||
@@ -36,7 +36,6 @@ public class TopicVisitOrder
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private int confid;
|
||||
private short[] topics;
|
||||
private boolean[] unread;
|
||||
private int ndx_next;
|
||||
@@ -46,9 +45,8 @@ public class TopicVisitOrder
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected TopicVisitOrder(int confid, List topiclist)
|
||||
protected TopicVisitOrder(List topiclist)
|
||||
{
|
||||
this.confid = confid;
|
||||
this.topics = new short[topiclist.size()];
|
||||
this.unread = new boolean[topiclist.size()];
|
||||
|
||||
@@ -65,6 +63,25 @@ public class TopicVisitOrder
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Map getInternalMap(HttpSession session)
|
||||
{
|
||||
Map rc = (Map)(session.getAttribute(ATTRIBUTE));
|
||||
if (rc==null)
|
||||
{ // create a new HashMap
|
||||
rc = Collections.synchronizedMap(new HashMap());
|
||||
session.setAttribute(ATTRIBUTE,rc);
|
||||
|
||||
} // end if
|
||||
|
||||
return rc;
|
||||
|
||||
} // end getInternalMap
|
||||
|
||||
private int moveNext()
|
||||
{
|
||||
int i = ndx_next;
|
||||
@@ -88,23 +105,17 @@ public class TopicVisitOrder
|
||||
|
||||
public static TopicVisitOrder initialize(HttpSession session, int confid, List topic_list)
|
||||
{
|
||||
TopicVisitOrder tvo = new TopicVisitOrder(confid,topic_list);
|
||||
session.setAttribute(ATTRIBUTE,tvo);
|
||||
TopicVisitOrder tvo = new TopicVisitOrder(topic_list);
|
||||
Map tvo_map = getInternalMap(session);
|
||||
tvo_map.put(new Integer(confid),tvo);
|
||||
return tvo;
|
||||
|
||||
} // end initialize
|
||||
|
||||
public static TopicVisitOrder retrieve(HttpSession session, int confid)
|
||||
{
|
||||
TopicVisitOrder tvo = (TopicVisitOrder)(session.getAttribute(ATTRIBUTE));
|
||||
if (tvo!=null)
|
||||
{ // make sure the conference is OK
|
||||
if (tvo.confid!=confid) // wrong conference - remove this
|
||||
tvo = null;
|
||||
|
||||
} // end if
|
||||
|
||||
return tvo;
|
||||
Map tvo_map = getInternalMap(session);
|
||||
return (TopicVisitOrder)(tvo_map.get(new Integer(confid)));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
|
||||
Reference in New Issue
Block a user