implemented the rest of the functions on the "posts" page; fixed post links
so they work now; added the HTML Reference (originally from CW); added the post output filtering to turn the "pseudo-URIs" in the database into real URIs
This commit is contained in:
@@ -224,7 +224,7 @@ public class ConfDisplay extends VeniceServlet
|
||||
|
||||
} // end getViewSortDefaults
|
||||
|
||||
private static PostInterval getInterval(ServletRequest request, TopicContext topic)
|
||||
private static PostInterval getInterval(VeniceEngine engine, ServletRequest request, TopicContext topic)
|
||||
throws ValidationException
|
||||
{
|
||||
int first, last;
|
||||
@@ -274,10 +274,10 @@ public class ConfDisplay extends VeniceServlet
|
||||
{ // no range specified - cook up a default one
|
||||
last = topic.getTotalMessages();
|
||||
int ur = topic.getUnreadMessages();
|
||||
if ((ur==0) || (ur>=20)) // TODO: configurable
|
||||
first = last - 20;
|
||||
if ((ur==0) || (ur>=engine.getNumPostsPerPage()))
|
||||
first = last - engine.getNumPostsPerPage();
|
||||
else
|
||||
first = last - (ur+2);
|
||||
first = last - (ur + engine.getNumOldPostsBeforeNew());
|
||||
last--;
|
||||
|
||||
} // end if
|
||||
@@ -324,6 +324,72 @@ public class ConfDisplay extends VeniceServlet
|
||||
|
||||
} // end getInterval
|
||||
|
||||
private static void restorePosts(ServletRequest request, ConferenceContext conf)
|
||||
{
|
||||
String xtopic = request.getParameter("rtop");
|
||||
if (StringUtil.isStringEmpty(xtopic))
|
||||
return;
|
||||
String xcount = request.getParameter("rct");
|
||||
if (StringUtil.isStringEmpty(xcount))
|
||||
return;
|
||||
|
||||
TopicContext topic;
|
||||
try
|
||||
{ // get the topic corresponding to the first parameter
|
||||
topic = conf.getTopic(Short.parseShort(xtopic));
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // the topic number was invalid - forget it
|
||||
logger.warn("restorePosts: error translating topic number");
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
catch (DataException de)
|
||||
{ // could not get the topic...
|
||||
logger.warn("restorePosts: DataException getting topic - " + de.getMessage(),de);
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // no access to the topic
|
||||
logger.warn("restorePosts: AccessError getting topic - " + ae.getMessage(),ae);
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
|
||||
int nunread;
|
||||
try
|
||||
{ // translate the number of unread posts to set
|
||||
nunread = Integer.parseInt(xcount);
|
||||
if ((nunread<=0) || (nunread>topic.getTotalMessages()))
|
||||
{ // must be in the range [1, #messages]...
|
||||
logger.warn("restorePosts: unread post count out of range");
|
||||
return;
|
||||
|
||||
} // end if
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // the number of unread posts was invalid - forget it
|
||||
logger.warn("restorePosts: error translating unread post count");
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
|
||||
try
|
||||
{ // now try to set the unread messages
|
||||
topic.setUnreadMessages(nunread);
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // could not get the topic...
|
||||
logger.warn("restorePosts: DataException setting unread messages - " + de.getMessage(),de);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end restorePosts
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
@@ -428,14 +494,18 @@ public class ConfDisplay extends VeniceServlet
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("MODE: display messages in topic");
|
||||
|
||||
// if this request is restoring the number of unread posts in another topic, try to do so
|
||||
restorePosts(request,conf);
|
||||
|
||||
try
|
||||
{ // determine what the post interval is we want to display
|
||||
PostInterval piv = getInterval(request,topic);
|
||||
VeniceEngine engine = getVeniceEngine();
|
||||
PostInterval piv = getInterval(engine,request,topic);
|
||||
boolean read_new = !(StringUtil.isStringEmpty(request.getParameter("rnm")));
|
||||
boolean show_adv = !(StringUtil.isStringEmpty(request.getParameter("shac")));
|
||||
|
||||
// create the post display
|
||||
TopicPosts tpos = new TopicPosts(request,sig,conf,topic,piv.getFirst(),piv.getLast(),
|
||||
TopicPosts tpos = new TopicPosts(request,engine,sig,conf,topic,piv.getFirst(),piv.getLast(),
|
||||
read_new,show_adv);
|
||||
content = tpos;
|
||||
page_title = topic.getName() + ": " + String.valueOf(topic.getTotalMessages()) + " Total; "
|
||||
|
||||
@@ -414,7 +414,7 @@ public class ConfOperations extends VeniceServlet
|
||||
|
||||
try
|
||||
{ // do a preview generation
|
||||
ntf.generatePreview(getVeniceEngine(),request);
|
||||
ntf.generatePreview(getVeniceEngine(),conf,request);
|
||||
|
||||
if (ntf.isNullRequest())
|
||||
{ // no title or text specified - this is a "204 No Content" return
|
||||
|
||||
393
src/com/silverwrist/venice/servlets/PostOperations.java
Normal file
393
src/com/silverwrist/venice/servlets/PostOperations.java
Normal file
@@ -0,0 +1,393 @@
|
||||
/*
|
||||
* 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.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class PostOperations extends VeniceServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final String NUKE_CONFIRM_ATTR = "servlets.PostOperations.nuke.confirm";
|
||||
private static final String NUKE_CONFIRM_PARAM = "confirm";
|
||||
|
||||
private static Category logger = Category.getInstance(TopicOperations.class.getName());
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static SIGContext getSIGParameter(ServletRequest request, UserContext user)
|
||||
throws ValidationException, DataException
|
||||
{
|
||||
String str = request.getParameter("sig");
|
||||
if (str==null)
|
||||
{ // no SIG parameter - bail out now!
|
||||
logger.error("SIG parameter not specified!");
|
||||
throw new ValidationException("No SIG specified.");
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // turn the string into a SIGID, and thence to a SIGContext
|
||||
int sigid = Integer.parseInt(str);
|
||||
return user.getSIGContext(sigid);
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // error in Integer.parseInt
|
||||
logger.error("Cannot convert SIG parameter '" + str + "'!");
|
||||
throw new ValidationException("Invalid SIG parameter.");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getSIGParameter
|
||||
|
||||
private static ConferenceContext getConferenceParameter(ServletRequest request, SIGContext sig)
|
||||
throws ValidationException, DataException, AccessError
|
||||
{
|
||||
String str = request.getParameter("conf");
|
||||
if (str==null)
|
||||
{ // no conference parameter - bail out now!
|
||||
logger.error("Conference parameter not specified!");
|
||||
throw new ValidationException("No conference specified.");
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // turn the string into a ConfID, and thence to a ConferenceContext
|
||||
int confid = Integer.parseInt(str);
|
||||
return sig.getConferenceContext(confid);
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // error in Integer.parseInt
|
||||
logger.error("Cannot convert conference parameter '" + str + "'!");
|
||||
throw new ValidationException("Invalid conference parameter.");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getConferenceParameter
|
||||
|
||||
private static TopicContext getTopicParameter(ServletRequest request, ConferenceContext conf)
|
||||
throws ValidationException, DataException, AccessError
|
||||
{
|
||||
String str = request.getParameter("top");
|
||||
if (StringUtil.isStringEmpty(str))
|
||||
{ // no topic parameter - bail out now!
|
||||
logger.error("Topic parameter not specified!");
|
||||
throw new ValidationException("No topic specified.");
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // turn the string into a TopicID, and thence to a TopicContext
|
||||
short topicid = Short.parseShort(str);
|
||||
return conf.getTopic(topicid);
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // error in Integer.parseInt
|
||||
logger.error("Cannot convert topic parameter '" + str + "'!");
|
||||
throw new ValidationException("Invalid topic parameter.");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getTopicParameter
|
||||
|
||||
private static TopicMessageContext getMessageParameter(ServletRequest request, TopicContext topic)
|
||||
throws ValidationException, DataException, AccessError
|
||||
{
|
||||
String str = request.getParameter("msg");
|
||||
if (StringUtil.isStringEmpty(str))
|
||||
{ // no topic parameter - bail out now!
|
||||
logger.error("Message parameter not specified!");
|
||||
throw new ValidationException("No message specified.");
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // turn the string into a TopicID, and thence to a TopicContext
|
||||
int message_num = Integer.parseInt(str);
|
||||
return topic.getMessage(message_num);
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // error in Integer.parseInt
|
||||
logger.error("Cannot convert message parameter '" + str + "'!");
|
||||
throw new ValidationException("Invalid message parameter.");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getMessageParameter
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "PostOperations servlet - General post operations (hide, scribble, etc.)\n"
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
String location = "top";
|
||||
String locator = null;
|
||||
String page_title = null;
|
||||
Object content = null;
|
||||
SIGContext sig = null; // SIG context
|
||||
ConferenceContext conf = null; // conference context
|
||||
TopicContext topic = null; // topic context
|
||||
TopicMessageContext msg = null; // message context
|
||||
|
||||
try
|
||||
{ // this outer try is to catch ValidationException
|
||||
try
|
||||
{ // all commands require a SIG parameter
|
||||
sig = getSIGParameter(request,user);
|
||||
changeMenuSIG(request,sig);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("found SIG #" + String.valueOf(sig.getSIGID()));
|
||||
locator = "sig=" + String.valueOf(sig.getSIGID());
|
||||
location = "sigprofile?" + locator;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // error looking up the SIG
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
if (content==null)
|
||||
{ // we got the SIG parameter OK
|
||||
try
|
||||
{ // all commands require a conference parameter
|
||||
conf = getConferenceParameter(request,sig);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("found conf #" + String.valueOf(conf.getConfID()));
|
||||
locator += "&conf=" + String.valueOf(conf.getConfID());
|
||||
location = "confdisp?" + locator;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // error looking up the conference
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error finding conference: " + de.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
if (content==null)
|
||||
{ // we got the conference parameter OK
|
||||
try
|
||||
{ // now we need a topic parameter
|
||||
topic = getTopicParameter(request,conf);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("found topic #" + String.valueOf(topic.getTopicID()));
|
||||
locator += "&top=" + String.valueOf(topic.getTopicID());
|
||||
location = "confdisp?" + locator;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // error looking up the conference
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error finding topic: " + de.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
if (content==null)
|
||||
{ // we got the topic parameter OK
|
||||
try
|
||||
{ // now we need a message parameter
|
||||
msg = getMessageParameter(request,topic);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("found message #" + String.valueOf(msg.getPostID()));
|
||||
location = "confdisp?" + locator + "&p1=" + msg.getPostNumber() + "&shac=1";
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // error looking up the conference
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error finding message: " + de.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
} // end try
|
||||
catch (ValidationException ve)
|
||||
{ // these all get handled in pretty much the same way
|
||||
page_title = "Error";
|
||||
content = new ErrorBox(null,ve.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // these all get handled in pretty much the same way
|
||||
page_title = "Access Error";
|
||||
content = new ErrorBox(page_title,ae.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
if (content==null)
|
||||
{ // figure out what command we want to perform
|
||||
String cmd = request.getParameter("cmd");
|
||||
if (cmd==null)
|
||||
cmd = "???";
|
||||
|
||||
if (cmd.equals("HY") || cmd.equals("HN"))
|
||||
{ // we want to hide or show the message
|
||||
try
|
||||
{ // attempt to hide or show the message
|
||||
msg.setHidden(cmd.equals("HY"));
|
||||
|
||||
// go back and display stuff
|
||||
rdat.redirectTo(location);
|
||||
return;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // there was a database error
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error setting hidden status: " + de.getMessage(),
|
||||
location);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // naughty naughty = you can't do this!
|
||||
page_title = "Access Error";
|
||||
content = new ErrorBox(page_title,ae.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if ("hide" or "show")
|
||||
else if (cmd.equals("SCR"))
|
||||
{ // we want to scribble the message
|
||||
try
|
||||
{ // attempt to scribble the message
|
||||
msg.scribble();
|
||||
|
||||
// go back and display stuff
|
||||
rdat.redirectTo(location);
|
||||
return;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // there was a database error
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error scribbling message: " + de.getMessage(),
|
||||
location);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // naughty naughty = you can't do this!
|
||||
page_title = "Access Error";
|
||||
content = new ErrorBox(page_title,ae.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end else if ("scribble")
|
||||
else if (cmd.equals("NUKE"))
|
||||
{ // nuking requires confirmation
|
||||
try
|
||||
{ // we need confirmation on this operation!
|
||||
if (ConfirmBox.isConfirmed(request,NUKE_CONFIRM_ATTR,NUKE_CONFIRM_PARAM))
|
||||
{ // OK, go ahead, nuke the message!
|
||||
msg.nuke();
|
||||
|
||||
// after which, redirect to topic view
|
||||
rdat.redirectTo("confdisp?" + locator);
|
||||
return;
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // not a proper confirmation - better display one
|
||||
List aliases = conf.getAliases();
|
||||
String message = "You are about to nuke message <" + (String)(aliases.get(0)) + "."
|
||||
+ String.valueOf(topic.getTopicNumber()) + "." + String.valueOf(msg.getPostNumber())
|
||||
+ ">, originally composed by <" + msg.getCreatorName()
|
||||
+ ">! Are you sure you want to do this?";
|
||||
String confirm_url = "postops?" + locator + "&msg=" + msg.getPostNumber() + "&cmd=NUKE";
|
||||
|
||||
page_title = "Nuke Message";
|
||||
content = new ConfirmBox(request,NUKE_CONFIRM_ATTR,NUKE_CONFIRM_PARAM,page_title,
|
||||
message,confirm_url,location);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // there was a database error
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error nuking message: " + de.getMessage(),
|
||||
location);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // naughty naughty = you can't do this!
|
||||
page_title = "Access Error";
|
||||
content = new ErrorBox(page_title,ae.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end else if ("nuke")
|
||||
else
|
||||
{ // unrecognized command!
|
||||
page_title = "Internal Error";
|
||||
logger.error("invalid command to PostOperations.doGet: " + cmd);
|
||||
content = new ErrorBox(page_title,"Invalid command to PostOperations.doGet",location);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if (got parameters OK)
|
||||
|
||||
BaseJSPData basedat = new BaseJSPData(page_title,location,content);
|
||||
basedat.transfer(getServletContext(),rdat);
|
||||
|
||||
} // end doGet
|
||||
|
||||
} // end class PostOperations
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
161
src/com/silverwrist/venice/servlets/PostShortcut.java
Normal file
161
src/com/silverwrist/venice/servlets/PostShortcut.java
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* 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.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.db.PostLinkDecoder;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class PostShortcut extends VeniceServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "PostShortcut servlet - Decodes a post link and redirects to it\n"
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
String raw_link = request.getPathInfo().substring(1);
|
||||
PostLinkDecoder decoder;
|
||||
|
||||
try
|
||||
{ // attempt to decode the path link information
|
||||
decoder = new PostLinkDecoder(raw_link);
|
||||
if (decoder.getSIG()==null) // it must include the SIG
|
||||
throw new ValidationException("ambiguous post link (no SIG)");
|
||||
|
||||
} // end try
|
||||
catch (ValidationException e)
|
||||
{ // display an error message for validation
|
||||
String page_title = "Invalid Post Link";
|
||||
ContentRender content = new ErrorBox(page_title,"Invalid post link \"" + raw_link + "\": "
|
||||
+ e.getMessage(),null);
|
||||
new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
|
||||
SIGContext sig;
|
||||
try
|
||||
{ // get the SIG represented by that alias
|
||||
sig = user.getSIGContext(decoder.getSIG());
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
{ // can't find the SIG - we're screwed
|
||||
String page_title = "Invalid Post Link";
|
||||
ContentRender content = new ErrorBox(page_title,"Invalid post link \"" + raw_link
|
||||
+ "\": cannot find SIG: " + e.getMessage(),null);
|
||||
new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
|
||||
if (decoder.getConference()==null)
|
||||
{ // it's a SIG link only - redirect to the SIG's default page
|
||||
rdat.redirectTo("sig/" + decoder.getSIG());
|
||||
return;
|
||||
|
||||
} // end if
|
||||
|
||||
ConferenceContext conf;
|
||||
try
|
||||
{ // get the conference represented by that alias
|
||||
conf = sig.getConferenceContext(decoder.getConference());
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
{ // can't find the conference - we're screwed
|
||||
String page_title = "Invalid Post Link";
|
||||
ContentRender content = new ErrorBox(page_title,"Invalid post link \"" + raw_link
|
||||
+ "\": cannot find conference: " + e.getMessage(),null);
|
||||
new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // we can't get to the conference...
|
||||
String page_title = "Access Error";
|
||||
ContentRender content = new ErrorBox(page_title,ae.getMessage(),null);
|
||||
new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
|
||||
// compute an elementary "locator"
|
||||
String locator = "sig=" + String.valueOf(sig.getSIGID()) + "&conf=" + String.valueOf(conf.getConfID());
|
||||
|
||||
if (decoder.getTopic()==-1)
|
||||
{ // just a conference link - go to the top-level display
|
||||
rdat.redirectTo("confdisp?" + locator);
|
||||
return;
|
||||
|
||||
} // end if
|
||||
|
||||
TopicContext topic;
|
||||
try
|
||||
{ // get the topic number specified within that topic
|
||||
topic = conf.getTopic(decoder.getTopic());
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
{ // we can't find the topic - we're screwed
|
||||
String page_title = "Invalid Post Link";
|
||||
ContentRender content = new ErrorBox(page_title,"Invalid post link \"" + raw_link
|
||||
+ "\": cannot find topic: " + e.getMessage(),null);
|
||||
new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // we can't get to the topic...
|
||||
String page_title = "Access Error";
|
||||
ContentRender content = new ErrorBox(page_title,ae.getMessage(),null);
|
||||
new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
|
||||
// add the topic to our locator
|
||||
locator += "&top=" + String.valueOf(decoder.getTopic());
|
||||
|
||||
if (decoder.getFirstPost()==-1) // we're just referencing the topic
|
||||
rdat.redirectTo("confdisp?" + locator + "&rnm=1");
|
||||
else // we're referencing a post range within the topic
|
||||
rdat.redirectTo("confdisp?" + locator + "&p1=" + String.valueOf(decoder.getFirstPost()) + "&p2="
|
||||
+ String.valueOf(decoder.getLastPost()));
|
||||
|
||||
} // end doGet
|
||||
|
||||
} // end class PostShortcut
|
||||
|
||||
@@ -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
|
||||
@@ -25,10 +25,15 @@ import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class SIGFrontEnd extends VeniceServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "SIGFrontEnd servlet - Redirects to the \"default feature\" of a SIG\n"
|
||||
+ "Part of the Venice Web conferencing system\n";
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
357
src/com/silverwrist/venice/servlets/TopicOperations.java
Normal file
357
src/com/silverwrist/venice/servlets/TopicOperations.java
Normal file
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
* 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.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class TopicOperations extends VeniceServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final String DELETE_CONFIRM_ATTR = "servlets.TopicOperations.delete.confirm";
|
||||
private static final String DELETE_CONFIRM_PARAM = "confirm";
|
||||
|
||||
private static Category logger = Category.getInstance(TopicOperations.class.getName());
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static SIGContext getSIGParameter(ServletRequest request, UserContext user)
|
||||
throws ValidationException, DataException
|
||||
{
|
||||
String str = request.getParameter("sig");
|
||||
if (str==null)
|
||||
{ // no SIG parameter - bail out now!
|
||||
logger.error("SIG parameter not specified!");
|
||||
throw new ValidationException("No SIG specified.");
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // turn the string into a SIGID, and thence to a SIGContext
|
||||
int sigid = Integer.parseInt(str);
|
||||
return user.getSIGContext(sigid);
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // error in Integer.parseInt
|
||||
logger.error("Cannot convert SIG parameter '" + str + "'!");
|
||||
throw new ValidationException("Invalid SIG parameter.");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getSIGParameter
|
||||
|
||||
private static ConferenceContext getConferenceParameter(ServletRequest request, SIGContext sig)
|
||||
throws ValidationException, DataException, AccessError
|
||||
{
|
||||
String str = request.getParameter("conf");
|
||||
if (str==null)
|
||||
{ // no conference parameter - bail out now!
|
||||
logger.error("Conference parameter not specified!");
|
||||
throw new ValidationException("No conference specified.");
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // turn the string into a ConfID, and thence to a ConferenceContext
|
||||
int confid = Integer.parseInt(str);
|
||||
return sig.getConferenceContext(confid);
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // error in Integer.parseInt
|
||||
logger.error("Cannot convert conference parameter '" + str + "'!");
|
||||
throw new ValidationException("Invalid conference parameter.");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getConferenceParameter
|
||||
|
||||
private static TopicContext getTopicParameter(ServletRequest request, ConferenceContext conf)
|
||||
throws ValidationException, DataException, AccessError
|
||||
{
|
||||
String str = request.getParameter("top");
|
||||
if (StringUtil.isStringEmpty(str))
|
||||
{ // no topic parameter - bail out now!
|
||||
logger.error("Topic parameter not specified!");
|
||||
throw new ValidationException("No topic specified.");
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // turn the string into a TopicID, and thence to a TopicContext
|
||||
short topicid = Short.parseShort(str);
|
||||
return conf.getTopic(topicid);
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // error in Integer.parseInt
|
||||
logger.error("Cannot convert topic parameter '" + str + "'!");
|
||||
throw new ValidationException("Invalid topic parameter.");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getTopicParameter
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "TopicOperations servlet - General topic operations (freeze, archive, etc.)\n"
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
String location = "top";
|
||||
String locator = null;
|
||||
String page_title = null;
|
||||
Object content = null;
|
||||
SIGContext sig = null; // SIG context
|
||||
ConferenceContext conf = null; // conference context
|
||||
TopicContext topic = null; // topic context
|
||||
|
||||
try
|
||||
{ // this outer try is to catch ValidationException
|
||||
try
|
||||
{ // all commands require a SIG parameter
|
||||
sig = getSIGParameter(request,user);
|
||||
changeMenuSIG(request,sig);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("found SIG #" + String.valueOf(sig.getSIGID()));
|
||||
locator = "sig=" + String.valueOf(sig.getSIGID());
|
||||
location = "sigprofile?" + locator;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // error looking up the SIG
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
if (content==null)
|
||||
{ // we got the SIG parameter OK
|
||||
try
|
||||
{ // all commands require a conference parameter
|
||||
conf = getConferenceParameter(request,sig);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("found conf #" + String.valueOf(conf.getConfID()));
|
||||
locator += "&conf=" + String.valueOf(conf.getConfID());
|
||||
location = "confdisp?" + locator;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // error looking up the conference
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error finding conference: " + de.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
if (content==null)
|
||||
{ // we got the conference parameter OK
|
||||
try
|
||||
{ // now we need a topic parameter
|
||||
topic = getTopicParameter(request,conf);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("found topic #" + String.valueOf(topic.getTopicID()));
|
||||
locator += "&top=" + String.valueOf(topic.getTopicNumber());
|
||||
location = "confdisp?" + locator;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // error looking up the conference
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error finding topic: " + de.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
} // end try
|
||||
catch (ValidationException ve)
|
||||
{ // these all get handled in pretty much the same way
|
||||
page_title = "Error";
|
||||
content = new ErrorBox(null,ve.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // these all get handled in pretty much the same way
|
||||
page_title = "Access Error";
|
||||
content = new ErrorBox(page_title,ae.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
if (content==null)
|
||||
{ // figure out what command we want to perform...
|
||||
String cmd = request.getParameter("cmd");
|
||||
if (cmd==null)
|
||||
cmd = "???";
|
||||
|
||||
if (cmd.equals("HY") || cmd.equals("HN"))
|
||||
{ // we want to set the hide status of the topic
|
||||
try
|
||||
{ // call down to set the topic!
|
||||
topic.setHidden(cmd.equals("HY"));
|
||||
|
||||
// go back to the topic view
|
||||
rdat.redirectTo(location);
|
||||
return;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // there was a database error
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error setting hide status: " + de.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if ("hide" or "show")
|
||||
else if (cmd.equals("FY") || cmd.equals("FN"))
|
||||
{ // we want to set the frozen status of the topic
|
||||
try
|
||||
{ // call down to set the topic!
|
||||
topic.setFrozen(cmd.equals("FY"));
|
||||
|
||||
// go back to the topic view
|
||||
rdat.redirectTo(location);
|
||||
return;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // there was a database error
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error setting freeze status: " + de.getMessage(),
|
||||
location);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // naughty naughty = you can't do this!
|
||||
page_title = "Access Error";
|
||||
content = new ErrorBox(page_title,ae.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end else if ("freeze" or "unfreeze")
|
||||
else if (cmd.equals("AY") || cmd.equals("AN"))
|
||||
{ // we want to change the archived status of the topic
|
||||
try
|
||||
{ // call down to set the topic!
|
||||
topic.setArchived(cmd.equals("AY"));
|
||||
|
||||
// go back to the topic view
|
||||
rdat.redirectTo(location);
|
||||
return;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // there was a database error
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error setting archive status: " + de.getMessage(),
|
||||
location);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // naughty naughty = you can't do this!
|
||||
page_title = "Access Error";
|
||||
content = new ErrorBox(page_title,ae.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end else if ("archive" or "unarchive")
|
||||
else if (cmd.equals("DEL"))
|
||||
{ // we need confirmation on this operation!
|
||||
if (ConfirmBox.isConfirmed(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM))
|
||||
{ // OK, go ahead, delete the topic!
|
||||
location = "confdisp?sig=" + String.valueOf(sig.getSIGID()) + "&conf="
|
||||
+ String.valueOf(conf.getConfID());
|
||||
|
||||
try
|
||||
{ // delete the bloody topic!
|
||||
topic.delete();
|
||||
|
||||
// after which, redirect to conference view
|
||||
rdat.redirectTo(location);
|
||||
return;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // there was a database error
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error deleting topic: " + de.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // naughty naughty = you can't do this!
|
||||
page_title = "Access Error";
|
||||
content = new ErrorBox(page_title,ae.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // not a proper confirmation - better display one
|
||||
String message = "You are about to delete topic " + String.valueOf(topic.getTopicNumber())
|
||||
+ " from the \"" + conf.getName() + "\" conference! Are you sure you want to do this?";
|
||||
String confirm_url = "topicops?" + locator + "&cmd=DEL";
|
||||
page_title = "Delete Topic";
|
||||
content = new ConfirmBox(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM,page_title,
|
||||
message,confirm_url,location);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end else if ("delete")
|
||||
else
|
||||
{ // unrecognized command
|
||||
page_title = "Internal Error";
|
||||
logger.error("invalid command to TopicOperations.doGet: " + cmd);
|
||||
content = new ErrorBox(page_title,"Invalid command to TopicOperations.doGet",location);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if
|
||||
|
||||
BaseJSPData basedat = new BaseJSPData(page_title,location,content);
|
||||
basedat.transfer(getServletContext(),rdat);
|
||||
|
||||
} // end doGet
|
||||
|
||||
} // end class TopicOperations
|
||||
@@ -101,7 +101,8 @@ public class NewTopicForm implements JSPRender
|
||||
|
||||
} // end setupNewRequest
|
||||
|
||||
public void generatePreview(VeniceEngine engine, ServletRequest request) throws ValidationException
|
||||
public void generatePreview(VeniceEngine engine, ConferenceContext conf, ServletRequest request)
|
||||
throws ValidationException
|
||||
{
|
||||
HTMLChecker check;
|
||||
|
||||
@@ -136,7 +137,7 @@ public class NewTopicForm implements JSPRender
|
||||
post_box = check.getValue();
|
||||
|
||||
// generate the body text preview
|
||||
check = engine.getPreviewChecker();
|
||||
check = conf.getNewTopicPreviewChecker();
|
||||
check.append(foo);
|
||||
check.finish();
|
||||
preview = check.getValue();
|
||||
|
||||
@@ -79,7 +79,7 @@ public class PostPreview implements JSPRender
|
||||
this.data = check.getValue();
|
||||
|
||||
// now generate the preview
|
||||
check = engine.getPreviewChecker();
|
||||
check = topic.getPreviewChecker();
|
||||
check.append(data);
|
||||
check.finish();
|
||||
this.preview = check.getValue();
|
||||
|
||||
@@ -47,6 +47,7 @@ public class PostSlippage implements JSPRender
|
||||
private String pseud;
|
||||
private String text;
|
||||
private boolean attach;
|
||||
private String topic_stem;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
@@ -63,6 +64,8 @@ public class PostSlippage implements JSPRender
|
||||
this.messages = topic.getMessages(lastval,topic.getTotalMessages()-1);
|
||||
this.next = next;
|
||||
this.attach = attach;
|
||||
List aliases = conf.getAliases();
|
||||
topic_stem = (String)(aliases.get(0)) + "." + String.valueOf(topic.getTopicNumber()) + ".";
|
||||
|
||||
try
|
||||
{ // run the text and pseud through an HTML checker to escape them
|
||||
@@ -213,4 +216,10 @@ public class PostSlippage implements JSPRender
|
||||
|
||||
} // end getBodyText
|
||||
|
||||
public String getMessageReference(TopicMessageContext msg)
|
||||
{
|
||||
return topic_stem + String.valueOf(msg.getPostNumber());
|
||||
|
||||
} // end getMessageReference
|
||||
|
||||
} // end class PostSlippage
|
||||
|
||||
@@ -54,6 +54,7 @@ public class RenderConfig
|
||||
private String font_face;
|
||||
private String base_url;
|
||||
private String image_url;
|
||||
private String static_url;
|
||||
private String site_logo;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
@@ -148,6 +149,17 @@ public class RenderConfig
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Image path: " + image_url);
|
||||
|
||||
static_url = paths_sect_h.getSubElementText("static");
|
||||
if (static_url==null)
|
||||
{ // no <static/> tag - bail out now!
|
||||
logger.fatal("<paths/> section has no <static/> element");
|
||||
throw new ConfigException("no <static/> found in <paths/> section",paths_sect);
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Static files path: " + static_url);
|
||||
|
||||
site_logo = paths_sect_h.getSubElementText("site-logo");
|
||||
if (site_logo==null)
|
||||
{ // no <image/> tag - bail out now!
|
||||
@@ -256,6 +268,14 @@ public class RenderConfig
|
||||
|
||||
} // end getFullImagePath
|
||||
|
||||
String getStaticFilePath(String name)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(static_url).append(name);
|
||||
return buf.toString();
|
||||
|
||||
} // end getStaticFilePath
|
||||
|
||||
String getTitleTag(String specific)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
@@ -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
|
||||
@@ -24,6 +24,9 @@ import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.IDUtils;
|
||||
import com.silverwrist.venice.db.PostLinkRewriter;
|
||||
import com.silverwrist.venice.db.UserNameRewriter;
|
||||
|
||||
public class RenderData
|
||||
{
|
||||
@@ -128,6 +131,12 @@ public class RenderData
|
||||
|
||||
} // end getFullImagePath
|
||||
|
||||
public String getStaticFilePath(String name)
|
||||
{
|
||||
return rconf.getStaticFilePath(name);
|
||||
|
||||
} // end getStaticFilePath
|
||||
|
||||
public String getFormatJSPPath(String name)
|
||||
{
|
||||
return "/format/" + name;
|
||||
@@ -320,4 +329,87 @@ public class RenderData
|
||||
|
||||
} // end sendBinaryData
|
||||
|
||||
public String rewritePostData(String data)
|
||||
{
|
||||
if ((data.indexOf(PostLinkRewriter.URI_PREFIX)<0) && (data.indexOf(UserNameRewriter.URI_PREFIX)<0))
|
||||
return data;
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
String interm;
|
||||
|
||||
if (data.indexOf(PostLinkRewriter.URI_PREFIX)>=0)
|
||||
{ // begin replacing everything with post links
|
||||
String t = data;
|
||||
int p = t.indexOf(PostLinkRewriter.URI_PREFIX);
|
||||
while (p>=0)
|
||||
{ // break off the start of the string
|
||||
if (p>0)
|
||||
buf.append(t.substring(0,p));
|
||||
t = t.substring(p + PostLinkRewriter.URI_PREFIX.length());
|
||||
|
||||
// find the end of the post link...
|
||||
p = 0;
|
||||
while (IDUtils.isValidPostLinkChar(t.charAt(p)))
|
||||
p++;
|
||||
|
||||
if (p>0)
|
||||
{ // append the post link to the "go" servlet path, and encode the lot
|
||||
buf.append(getEncodedServletPath("go/" + t.substring(0,p)));
|
||||
t = t.substring(p);
|
||||
|
||||
} // end if
|
||||
else // false alarm
|
||||
buf.append(PostLinkRewriter.URI_PREFIX);
|
||||
|
||||
// and now look again...
|
||||
p = t.indexOf(PostLinkRewriter.URI_PREFIX);
|
||||
|
||||
} // end while
|
||||
|
||||
buf.append(t);
|
||||
interm = buf.toString();
|
||||
buf.setLength(0);
|
||||
|
||||
} // end if
|
||||
else // no post link strings, this is the intermediate form
|
||||
interm = data;
|
||||
|
||||
if (interm.indexOf(UserNameRewriter.URI_PREFIX)>=0)
|
||||
{ // begin replacing everything with user links
|
||||
String t = interm;
|
||||
int p = t.indexOf(UserNameRewriter.URI_PREFIX);
|
||||
while (p>=0)
|
||||
{ // break off the start of the string
|
||||
if (p>0)
|
||||
buf.append(t.substring(0,p));
|
||||
t = t.substring(p + UserNameRewriter.URI_PREFIX.length());
|
||||
|
||||
// find the end of the user link...
|
||||
p = 0;
|
||||
while (IDUtils.isValidVeniceIDChar(t.charAt(p)))
|
||||
p++;
|
||||
|
||||
if (p>0)
|
||||
{ // append the post link to the "user" servlet path, and encode the lot
|
||||
buf.append(getEncodedServletPath("user/" + t.substring(0,p)));
|
||||
t = t.substring(p);
|
||||
|
||||
} // end if
|
||||
else // false alarm
|
||||
buf.append(UserNameRewriter.URI_PREFIX);
|
||||
|
||||
// and now look again...
|
||||
p = t.indexOf(UserNameRewriter.URI_PREFIX);
|
||||
|
||||
} // end while
|
||||
|
||||
buf.append(t);
|
||||
return buf.toString();
|
||||
|
||||
} // end if
|
||||
else // no more to find - just return this
|
||||
return interm;
|
||||
|
||||
} // end rewritePostData
|
||||
|
||||
} // end class RenderData
|
||||
|
||||
@@ -38,6 +38,7 @@ public class TopicPosts implements JSPRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private VeniceEngine engine;
|
||||
private SIGContext sig;
|
||||
private ConferenceContext conf;
|
||||
private TopicContext topic;
|
||||
@@ -47,6 +48,7 @@ public class TopicPosts implements JSPRender
|
||||
private int unread;
|
||||
private List messages;
|
||||
private TopicVisitOrder visit_order;
|
||||
private String topic_stem;
|
||||
private String cache_locator = null;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
@@ -54,10 +56,11 @@ public class TopicPosts implements JSPRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public TopicPosts(HttpServletRequest request, SIGContext sig, ConferenceContext conf, TopicContext topic,
|
||||
int first, int last, boolean read_new, boolean show_advanced)
|
||||
public TopicPosts(HttpServletRequest request, VeniceEngine engine, SIGContext sig, ConferenceContext conf,
|
||||
TopicContext topic, int first, int last, boolean read_new, boolean show_advanced)
|
||||
throws DataException, AccessError
|
||||
{
|
||||
this.engine = engine;
|
||||
this.sig = sig;
|
||||
this.conf = conf;
|
||||
this.topic = topic;
|
||||
@@ -70,6 +73,8 @@ public class TopicPosts implements JSPRender
|
||||
this.messages = topic.getMessages(first,last);
|
||||
this.visit_order = TopicVisitOrder.retrieve(request.getSession(true),conf.getConfID());
|
||||
visit_order.visit(topic.getTopicNumber());
|
||||
List aliases = conf.getAliases();
|
||||
topic_stem = (String)(aliases.get(0)) + "." + String.valueOf(topic.getTopicNumber()) + ".";
|
||||
|
||||
} // end constructor
|
||||
|
||||
@@ -192,6 +197,14 @@ public class TopicPosts implements JSPRender
|
||||
|
||||
} // end getNextLocator
|
||||
|
||||
public String getRestoreLocator()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer("rtop=");
|
||||
buf.append(topic.getTopicNumber()).append("&rct=").append(unread);
|
||||
return buf.toString();
|
||||
|
||||
} // end getRestoreLocator
|
||||
|
||||
public String getIdentifyingData()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer("Posts ");
|
||||
@@ -262,7 +275,7 @@ public class TopicPosts implements JSPRender
|
||||
|
||||
public boolean canDeleteTopic()
|
||||
{
|
||||
return false; // TODO: fix me
|
||||
return topic.canDelete();
|
||||
|
||||
} // end canDeleteTopic
|
||||
|
||||
@@ -274,7 +287,7 @@ public class TopicPosts implements JSPRender
|
||||
|
||||
public String getScrollUpLocator()
|
||||
{
|
||||
int new_first = first - 20; // TODO: configurable
|
||||
int new_first = first - engine.getNumPostsPerPage();
|
||||
int new_last = last - 1;
|
||||
if (new_first<0)
|
||||
{ // normalize so we start at 0
|
||||
@@ -291,14 +304,14 @@ public class TopicPosts implements JSPRender
|
||||
|
||||
public boolean canScrollDown()
|
||||
{
|
||||
return ((topic.getTotalMessages() - (1 + last))>=20); // TODO: configurable
|
||||
return ((topic.getTotalMessages() - (1 + last))>=engine.getNumPostsPerPage());
|
||||
|
||||
} // end canScrollDown
|
||||
|
||||
public String getScrollDownLocator()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer("p1=");
|
||||
buf.append(last+1).append("&p2=").append(last+20); // TODO: configurable
|
||||
buf.append(last+1).append("&p2=").append(last+engine.getNumPostsPerPage());
|
||||
return buf.toString();
|
||||
|
||||
} // end getScrollDownLocator
|
||||
@@ -313,7 +326,7 @@ public class TopicPosts implements JSPRender
|
||||
{
|
||||
int my_last = topic.getTotalMessages();
|
||||
StringBuffer buf = new StringBuffer("p1=");
|
||||
buf.append(my_last-20).append("&p2=").append(my_last-1); // TODO: configurable
|
||||
buf.append(my_last-engine.getNumPostsPerPage()).append("&p2=").append(my_last-1);
|
||||
return buf.toString();
|
||||
|
||||
} // end getScrollToEndLocator
|
||||
@@ -351,4 +364,16 @@ public class TopicPosts implements JSPRender
|
||||
|
||||
} // end getDefaultPseud
|
||||
|
||||
public String getMessageReference(TopicMessageContext msg)
|
||||
{
|
||||
return topic_stem + String.valueOf(msg.getPostNumber());
|
||||
|
||||
} // end getMessageReference
|
||||
|
||||
public int getNumPostsPerPage()
|
||||
{
|
||||
return engine.getNumPostsPerPage();
|
||||
|
||||
} // end getNumPostsPerPage
|
||||
|
||||
} // end class TopicPosts
|
||||
|
||||
Reference in New Issue
Block a user