partial implementation of conference management; rewrote the whole servlets

layer to eliminate duplicate code and make error checking more efficient
(we now use a system that relies on Throwables to do interesting things)
This commit is contained in:
Eric J. Bowersox 2001-02-10 07:20:27 +00:00
parent a51fa644b7
commit f706cdaf5f
65 changed files with 2914 additions and 3040 deletions

3
TODO
View File

@ -6,7 +6,8 @@ Lots!
- Should we provide the sysadmin the ability to disable SIG creation for - Should we provide the sysadmin the ability to disable SIG creation for
non-admin users? Maybe there needs to be a "global" set of levels that non-admin users? Maybe there needs to be a "global" set of levels that
aren't hardcoded. Where do they get stored? The database? aren't hardcoded. Where do they get stored? The database? (Maybe the
nice shiny new "globals" table?)
- There's no system admin functionality AT ALL. We need to have this stuff - There's no system admin functionality AT ALL. We need to have this stuff
before we go live. (It plugs into the Administrative SIG features.) before we go live. (It plugs into the Administrative SIG features.)

View File

@ -117,4 +117,6 @@ public interface ConferenceContext
public abstract HTMLChecker getNewTopicPreviewChecker(); public abstract HTMLChecker getNewTopicPreviewChecker();
public abstract void fixSeen() throws DataException;
} // end interface ConferenceContext } // end interface ConferenceContext

View File

@ -74,6 +74,48 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
} // end class ConfCache } // end class ConfCache
/*--------------------------------------------------------------------------------
* Internal class used in the implementation of fixSeen()
*--------------------------------------------------------------------------------
*/
static class FixSeenHelper
{
private int topicid;
private int top_message;
private boolean do_insert;
public FixSeenHelper(int topicid, int top_message, boolean do_insert)
{
this.topicid = topicid;
this.top_message = top_message;
this.do_insert = do_insert;
} // end constructor
public void doFix(Statement stmt, int uid) throws SQLException
{
StringBuffer sql = new StringBuffer();
if (do_insert)
{ // construct an SQL INSERT statement
sql.append("INSERT INTO topicsettings (topicid, uid, last_message) VALUES (").append(topicid);
sql.append(", ").append(uid).append(", ").append(top_message).append(");");
} // end if
else
{ // construct an SQL UPDATE statement
sql.append("UPDATE topicsettings SET last_message = ").append(top_message).append(" WHERE topicid = ");
sql.append(topicid).append(" AND uid = ").append(uid).append(';');
} // end else
// now execute the update
stmt.executeUpdate(sql.toString());
} // end doFix
} // end class FixSeenHelper
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Static data members * Static data members
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -908,6 +950,68 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
} // end getNewTopicPreviewChecker } // end getNewTopicPreviewChecker
public void fixSeen() throws DataException
{
Connection conn = null;
try
{ // retrieve a connection from the datapool
conn = datapool.getConnection();
Statement stmt = conn.createStatement();
// lock the tables that we need
stmt.executeUpdate("LOCK TABLES confsettings WRITE, topicsettings WRITE, topics READ;");
try
{ // get the existing topic list and its top messages list
StringBuffer sql =
new StringBuffer("SELECT topics.topicid, topics.top_message, ISNULL(topicsettings.last_message) "
+ "FROM topics LEFT JOIN topicsettings ON topics.topicid = topicsettings.topicid "
+ "AND topicsettings.uid = ");
sql.append(sig.realUID()).append(" WHERE topics.confid = ").append(confid).append(';');
ResultSet rs = stmt.executeQuery(sql.toString());
// use the results to build up a list of FixSeenHelpers
Vector tmp = new Vector();
while (rs.next())
tmp.add(new FixSeenHelper(rs.getInt(1),rs.getInt(2),rs.getBoolean(3)));
// now iterate over the list and call doFix on each one
Iterator it = tmp.iterator();
while (it.hasNext())
{ // just hit each one in turn
FixSeenHelper fsh = (FixSeenHelper)(it.next());
fsh.doFix(stmt,sig.realUID());
} // end while
// update our last-read indicator, too
touchRead(conn);
} // end try
finally
{ // make sure we unlock everything before we go
Statement ulk_stmt = conn.createStatement();
ulk_stmt.executeUpdate("UNLOCK TABLES;");
} // end finally
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error updating user information: " + e.getMessage(),e);
throw new DataException("unable to update user information: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
if (conn!=null)
datapool.releaseConnection(conn);
} // end finally
} // end fixSeen
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface UserBackend * Implementations from interface UserBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -34,6 +34,8 @@ public class Account extends VeniceServlet
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private static final String DISPLAY_LOGIN_ATTR = "com.silverwrist.venice.servlets.internal.DisplayLogin";
private static Category logger = Category.getInstance(Account.class.getName()); private static Category logger = Category.getInstance(Account.class.getName());
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
@ -41,6 +43,12 @@ public class Account extends VeniceServlet
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private void setDisplayLogins(ServletRequest request)
{
request.setAttribute(DISPLAY_LOGIN_ATTR,new Integer(0));
} // end setDisplayLogins
private NewAccountDialog makeNewAccountDialog() throws ServletException private NewAccountDialog makeNewAccountDialog() throws ServletException
{ {
final String desired_name = "NewAccountDialog"; final String desired_name = "NewAccountDialog";
@ -122,186 +130,154 @@ public class Account extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
{ *--------------------------------------------------------------------------------
RenderData rdat = createRenderData(request,response); */
UserContext user = getUserContext(request);
String page_title = null;
ContentRender content = null;
boolean display_login = false;
protected String getMyLocation(HttpServletRequest request, VeniceEngine engine, UserContext user,
RenderData rdat)
{
if (request.getAttribute(DISPLAY_LOGIN_ATTR)!=null)
return "account?cmd=" + getStandardCommandParam(request);
else
return null;
} // end getMyLocation
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
String tgt = request.getParameter("tgt"); // target location String tgt = request.getParameter("tgt"); // target location
if (tgt==null) if (tgt==null)
tgt = "top"; // go back to the Top screen if nothing else tgt = "top"; // go back to the Top screen if nothing else
String cmd = request.getParameter("cmd"); // command parameter String cmd = getStandardCommandParam(request);
if (cmd.equals("L")) if (cmd.equals("L"))
{ // "L" = Log in/out { // "L" = Log In/Out
if (user.isLoggedIn()) if (user.isLoggedIn())
{ // log the user out and send 'em back to the "top" page { // this is a Logout command
clearUserContext(request); clearUserContext(request);
// TODO: here is where the persistent cookie gets nuked, if it does... throw new RedirectResult("top"); // take 'em back to the "top" page
rdat.redirectTo("top");
return;
} // end if (logging out)
else
{ // display the Login page
LoginDialog dlg = makeLoginDialog();
dlg.setupNew(tgt);
page_title = dlg.getTitle();
content = dlg;
} // end else
} // end if ("L" command)
else if (cmd.equals("C"))
{ // "C" = create new account
if (user.isLoggedIn())
{ // you can't create a new account while logged in on an existing one!
page_title = "Error";
content = new ErrorBox(page_title,"You cannot create a new account while logged in on "
+ "an existing one. You must log out first.",tgt);
} // end if } // end if
else
{ // display the "Create Account" page // this is a Login command - display the Login page
LoginDialog dlg = makeLoginDialog();
dlg.setupNew(tgt);
return dlg;
} // end if ("L" command)
if (cmd.equals("C"))
{ // "C" = create new account
if (user.isLoggedIn()) // you can't create a new account while logged in on an existing one!
return new ErrorBox("Error","You cannot create a new account while logged in on an existing "
+ "one. You must log out first.",tgt);
// display the "Create Account" dialog
NewAccountDialog dlg = makeNewAccountDialog(); NewAccountDialog dlg = makeNewAccountDialog();
dlg.setEngine(getVeniceEngine()); dlg.setEngine(engine);
page_title = dlg.getTitle();
dlg.setTarget(tgt); dlg.setTarget(tgt);
dlg.setFieldValue("country","US"); dlg.setFieldValue("country","US");
content = dlg; return dlg;
} // end else
} // end if ("C" command) } // end if ("C" command)
else if (cmd.equals("P"))
if (cmd.equals("P"))
{ // "P" = user profile { // "P" = user profile
if (user.isLoggedIn()) if (!(user.isLoggedIn())) // you have to be logged in for this one!
{ // display the User Profile page return new ErrorBox("Error","You must log in before you can modify the profile "
+ "on your account.",tgt);
// set up the Edit Profile dialog
EditProfileDialog dlg = makeEditProfileDialog(); EditProfileDialog dlg = makeEditProfileDialog();
try try
{ // load the profile information { /// set up the profile information for the dialog
dlg.setupDialog(user,tgt); dlg.setupDialog(user,tgt);
// prepare for display
page_title = dlg.getTitle();
content = dlg;
} // end try } // end try
catch (DataException e) catch (DataException e)
{ // we couldn't load the contact info for the profile { // unable to load the contact info for the profile
page_title = "Database Error"; return new ErrorBox("Database Error","Database error retrieving profile: " + e.getMessage(),tgt);
content = new ErrorBox(page_title,"Database error retrieving profile: " + e.getMessage(),tgt);
} // end catch } // end catch
} // end if return dlg; // display dialog
else
{ // you have to be logged in for this one!
page_title = "Error";
content = new ErrorBox(page_title,"You must log in before you can modify the profile "
+ "on your account.",tgt);
} // end else
} // end if ("P" command) } // end if ("P" command)
else if (cmd.equals("V"))
if (cmd.equals("V"))
{ // "V" = verify email address { // "V" = verify email address
display_login = true; setDisplayLogins(request);
if (!(user.isLoggedIn())) // you have to be logged in for this one!
if (user.isLoggedIn()) return new ErrorBox("Error","You must log in before you can verify your account's "
{ // display the Verify E-mail Address page
VerifyEmailDialog dlg = makeVerifyEmailDialog();
page_title = dlg.getTitle();
dlg.setTarget(tgt);
content = dlg;
} // end if
else
{ // you have to be logged in for this one!
page_title = "Error";
content = new ErrorBox(page_title,"You must log in before you can verify your account's "
+ "email address.",tgt); + "email address.",tgt);
} // end else // display the "verify email" dialog
VerifyEmailDialog dlg = makeVerifyEmailDialog();
dlg.setTarget(tgt);
return dlg;
} // end else if ("V" command) } // end if ("V" command)
else
{ // unknown command // command not found!
page_title = "Internal Error";
logger.error("invalid command to Account.doGet: " + cmd); logger.error("invalid command to Account.doGet: " + cmd);
content = new ErrorBox(page_title,"Invalid command to Account.doGet",tgt); return new ErrorBox("Internal Error","Invalid command to Account.doGet",tgt);
} // end else } // end doVeniceGet
BaseJSPData basedat = new BaseJSPData(page_title,"account?cmd=" + cmd,content); protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
basedat.displayLoginLinks(display_login); UserContext user, RenderData rdat)
basedat.transfer(getServletContext(),rdat); throws ServletException, IOException, VeniceServletResult
} // end doGet
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{ {
RenderData rdat = createRenderData(request,response); changeMenuTop(request); // this is "top" menus
UserContext user = getUserContext(request);
String page_title = null;
ContentRender content = null;
boolean display_login = false;
String tgt = request.getParameter("tgt"); // target location String tgt = request.getParameter("tgt"); // target location
if (tgt==null) if (tgt==null)
tgt = "top"; // go back to Top screen if nothing else tgt = "top"; // go back to the Top screen if nothing else
String cmd = request.getParameter("cmd"); // command parameter String cmd = getStandardCommandParam(request);
if (cmd.equals("L")) if (cmd.equals("L"))
{ // log the user in { // "L" = login the user
LoginDialog dlg = makeLoginDialog(); LoginDialog dlg = makeLoginDialog();
if (dlg.isButtonClicked(request,"cancel")) if (dlg.isButtonClicked(request,"cancel"))
{ // go back where we came from - we decided not to log in anyhoo throw new RedirectResult(tgt); // we decided not to log in - go back where we came from
rdat.redirectTo(tgt);
return;
} // end if (canceled)
if (dlg.isButtonClicked(request,"remind")) if (dlg.isButtonClicked(request,"remind"))
{ // this will email a password reminder to the owner's account { // this will email a password reminder to the owner's account
dlg.loadValues(request); // load the dialog values dlg.loadValues(request); // load the dialog values
try try
{ // send the password reminder { // send the password reminder
getVeniceEngine().sendPasswordReminder(dlg.getFieldValue("user")); engine.sendPasswordReminder(dlg.getFieldValue("user"));
// recycle and redisplay the dialog box // recycle and redisplay the dialog box
dlg.resetOnError("Password reminder has been sent to your e-mail address."); dlg.resetOnError("Password reminder has been sent to your e-mail address.");
page_title = dlg.getTitle();
content = dlg;
} // end try } // end try
catch (DataException e1) catch (DataException de)
{ // this indicates a database error - display an ErrorBox { // there was a database error finding your email address
page_title = "Database Error"; return new ErrorBox("Database Error","Database error finding user: " + de.getMessage(),tgt);
content = new ErrorBox(page_title,"Database error finding user: " + e1.getMessage(),tgt);
} // end catch } // end catch
catch (AccessError e2) catch (AccessError ae)
{ // this indicates a problem with the user account or password { // this indicates a problem with the user account or password
page_title = "User E-mail Address Not Found"; return new ErrorBox("User E-mail Address Not Found",ae.getMessage(),tgt);
content = new ErrorBox(page_title,e2.getMessage(),tgt);
} // end catch } // end catch
catch (EmailException ee) catch (EmailException ee)
{ // error sending the confirmation email { // error sending the confirmation email
page_title = "E-mail Error"; return new ErrorBox("E-mail Error","E-mail error sending reminder: " + ee.getMessage(),tgt);
content = new ErrorBox(page_title,"E-mail error sending reminder: " + ee.getMessage(),tgt);
} // end catch } // end catch
} // end if ("reminder" button clicked) return dlg; // redisplay the dialog
else if (dlg.isButtonClicked(request,"login"))
} // end if ("remind" button clicked)
if (dlg.isButtonClicked(request,"login"))
{ // we actually want to try and log in! imagine that! { // we actually want to try and log in! imagine that!
dlg.loadValues(request); // load the values dlg.loadValues(request); // load the values
@ -313,53 +289,41 @@ public class Account extends VeniceServlet
// assuming it worked OK, redirect them back where they came from // assuming it worked OK, redirect them back where they came from
// (or to the verification page if they need to go there) // (or to the verification page if they need to go there)
String url;
if (user.isEmailVerified())
url = tgt;
else // they haven't verified yet - remind them to do so
url = "account?cmd=V&tgt=" + URLEncoder.encode(tgt);
clearMenu(request); clearMenu(request);
rdat.redirectTo(url); if (user.isEmailVerified())
return; throw new RedirectResult(tgt);
else // they haven't verified yet - remind them to do so
throw new RedirectResult("account?cmd=V&tgt=" + URLEncoder.encode(tgt));
} // end try } // end try
catch (DataException e1) catch (DataException de)
{ // this indicates a database error - display an ErrorBox { // this indicates a database error - display an ErrorBox
page_title = "Database Error"; return new ErrorBox("Database Error","Database error logging in: " + de.getMessage(),tgt);
content = new ErrorBox(page_title,"Database error logging in: " + e1.getMessage(),tgt);
} // end catch } // end catch
catch (AccessError e2) catch (AccessError ae)
{ // this indicates a problem with the user account or password { // this indicates a problem with the user account or password
dlg.resetOnError(e2.getMessage()); dlg.resetOnError(ae.getMessage());
page_title = dlg.getTitle();
content = dlg;
} // end catch } // end catch
} // end else if ("login" button clicked) return dlg; // go back and redisplay the dialog
else
{ // the button must be wrong!
page_title = "Internal Error";
logger.error("no known button click on Account.doPost, cmd=L");
content = new ErrorBox(page_title,"Unknown command button pressed",tgt);
} // end else } // end if ("login" button clicked)
// the button must be wrong!
logger.error("no known button click on Account.doPost, cmd=L");
return new ErrorBox("Internal Error","Unknown command button pressed",tgt);
} // end if ("L" command) } // end if ("L" command)
else if (cmd.equals("C"))
{ // C = Create New Account if (cmd.equals("C"))
{ // "C" = Create New Account
NewAccountDialog dlg = makeNewAccountDialog(); NewAccountDialog dlg = makeNewAccountDialog();
dlg.setEngine(getVeniceEngine()); dlg.setEngine(engine);
if (dlg.isButtonClicked(request,"cancel")) if (dlg.isButtonClicked(request,"cancel"))
{ // go back where we came from - we decided not to create the account anyhoo throw new RedirectResult(tgt); // we decided not to create account - go back where we came from
String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
response.sendRedirect(url);
return;
} // end if ("cancel" button clicked)
if (dlg.isButtonClicked(request,"create")) if (dlg.isButtonClicked(request,"create"))
{ // OK, actually want to create the account! { // OK, actually want to create the account!
@ -369,67 +333,52 @@ public class Account extends VeniceServlet
{ // attempt to create the account { // attempt to create the account
UserContext uc = dlg.doDialog(request); UserContext uc = dlg.doDialog(request);
putUserContext(request,uc); // effectively logging in the new user putUserContext(request,uc); // effectively logging in the new user
user = uc;
// now jump to the Verify page // now jump to the Verify page
String partial = "account?cmd=V&tgt=" + URLEncoder.encode(tgt); throw new RedirectResult("account?cmd=V&tgt=" + URLEncoder.encode(tgt));
String url = response.encodeRedirectURL(rdat.getFullServletPath(partial));
response.sendRedirect(url);
return;
} // end try } // end try
catch (ValidationException ve) catch (ValidationException ve)
{ // unable to validate some of the data in the form { // unable to validate some of the data in the form
dlg.resetOnError(ve.getMessage() + " Please try again."); dlg.resetOnError(ve.getMessage() + " Please try again.");
page_title = dlg.getTitle();
content = dlg;
} // end catch } // end catch
catch (DataException de) catch (DataException de)
{ // data error in setting up account { // data error in setting up account
page_title = "Database Error"; return new ErrorBox("Database Error","Database error creating account: " + de.getMessage(),tgt);
content = new ErrorBox(page_title,"Database error creating account: " + de.getMessage(),tgt);
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // access error in setting up the account { // access error in setting up the account
dlg.resetOnError(ae.getMessage()); dlg.resetOnError(ae.getMessage());
page_title = dlg.getTitle();
content = dlg;
} // end catch } // end catch
catch (EmailException ee) catch (EmailException ee)
{ // error sending the confirmation email { // error sending the confirmation email
page_title = "E-mail Error"; return new ErrorBox("E-mail Error","E-mail error creating account: " + ee.getMessage(),tgt);
content = new ErrorBox(page_title,"E-mail error creating account: " + ee.getMessage(),tgt);
} // end catch } // end catch
} // end if ("create" button clicked) return dlg; // redisplay me
else
{ // the button must be wrong! } // end if ("create" button pressed)
page_title = "Internal Error";
// the button must be wrong!
logger.error("no known button click on Account.doPost, cmd=C"); logger.error("no known button click on Account.doPost, cmd=C");
content = new ErrorBox(page_title,"Unknown command button pressed",tgt); return new ErrorBox("Internal Error","Unknown command button pressed",tgt);
} // end else } // end if ("C" command)
} // end else if ("C" command) if (cmd.equals("V"))
else if (cmd.equals("V")) { // "V" = Verify E-mail Address
{ // V = Verify E-mail Address setDisplayLogins(request);
display_login = true;
VerifyEmailDialog dlg = makeVerifyEmailDialog(); VerifyEmailDialog dlg = makeVerifyEmailDialog();
if (dlg.isButtonClicked(request,"cancel")) if (dlg.isButtonClicked(request,"cancel"))
{ // go back to our desired location throw new RedirectResult(tgt); // we decided not to bother - go back where we came from
String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
response.sendRedirect(url);
return;
} // end if ("cancel" button clicked)
if (dlg.isButtonClicked(request,"again")) if (dlg.isButtonClicked(request,"again"))
{ // do a "send again" { // send the confirmation message again
try try
{ // resend the email confirmation { // resend the email confirmation
user.resendEmailConfirmation(); user.resendEmailConfirmation();
@ -437,25 +386,24 @@ public class Account extends VeniceServlet
// now force the form to be redisplayed // now force the form to be redisplayed
dlg.clearAllFields(); dlg.clearAllFields();
dlg.setTarget(tgt); dlg.setTarget(tgt);
page_title = dlg.getTitle();
content = dlg;
} // end try } // end try
catch (DataException de) catch (DataException de)
{ // data error in setting up account { // database error resending confirmation
page_title = "Database Error"; return new ErrorBox("Database Error","Database error sending confirmation: " + de.getMessage(),tgt);
content = new ErrorBox(page_title,"Database error sending confirmation: " + de.getMessage(),tgt);
} // end catch } // end catch
catch (EmailException ee) catch (EmailException ee)
{ // error sending the confirmation email { // error sending the confirmation email
page_title = "E-mail Error"; return new ErrorBox("E-mail Error","E-mail error sending confirmation: " + ee.getMessage(),tgt);
content = new ErrorBox(page_title,"E-mail error sending confirmation: " + ee.getMessage(),tgt);
} // end catch } // end catch
} // end if ("again" clicked) return dlg; // redisplay the dialog
else if (dlg.isButtonClicked(request,"ok"))
} // end if ("again" button clicked)
if (dlg.isButtonClicked(request,"ok"))
{ // try to verify the confirmation number { // try to verify the confirmation number
dlg.loadValues(request); // load field values dlg.loadValues(request); // load field values
@ -465,119 +413,85 @@ public class Account extends VeniceServlet
user.confirmEmail(dlg.getConfirmationNumber()); user.confirmEmail(dlg.getConfirmationNumber());
// go back to our desired location // go back to our desired location
String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt)); throw new RedirectResult(tgt);
response.sendRedirect(url);
return;
} // end try } // end try
catch (ValidationException ve) catch (ValidationException ve)
{ // there was a validation error... { // there was a validation error...
dlg.resetOnError(ve.getMessage() + " Please try again."); dlg.resetOnError(ve.getMessage() + " Please try again.");
page_title = dlg.getTitle();
content = dlg;
} // end catch } // end catch
catch (DataException de) catch (DataException de)
{ // data error in setting up account { // data error in confirming account
page_title = "Database Error"; return new ErrorBox("Database Error","Database error verifying email: " + de.getMessage(),tgt);
content = new ErrorBox(page_title,"Database error verifying email: " + de.getMessage(),tgt);
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // access error in setting up the account { // invalid confirmation number, perhaps?
dlg.resetOnError(ae.getMessage()); dlg.resetOnError(ae.getMessage());
page_title = dlg.getTitle();
content = dlg;
} // end catch } // end catch
} // end else if ("OK" clicked) return dlg; // redisplay the dialog
else
{ // the button must be wrong! } // end if ("ok" button clicked)
page_title = "Internal Error";
// the button must be wrong!
logger.error("no known button click on Account.doPost, cmd=V"); logger.error("no known button click on Account.doPost, cmd=V");
content = new ErrorBox(page_title,"Unknown command button pressed",tgt); return new ErrorBox("Internal Error","Unknown command button pressed",tgt);
} // end else } // end if ("V" command)
} // end else if ("V" command) if (cmd.equals("P"))
else if (cmd.equals("P")) { // "P" = Edit User Profile
{ // P = Edit User Profile setDisplayLogins(request);
display_login = true;
EditProfileDialog dlg = makeEditProfileDialog(); EditProfileDialog dlg = makeEditProfileDialog();
if (dlg.isButtonClicked(request,"cancel")) if (dlg.isButtonClicked(request,"cancel"))
{ // go back to our desired location throw new RedirectResult(tgt); // we decided not to bother - go back where we came from
String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
response.sendRedirect(url);
return;
} // end if ("cancel" button clicked)
if (dlg.isButtonClicked(request,"update")) if (dlg.isButtonClicked(request,"update"))
{ // we're ready to update the user profile { // we're ready to update the user profile
dlg.loadValues(request); // load field values dlg.loadValues(request); // load field values
try try
{ // validate the dialog and start setting info { // validate the dialog and reset profile info
String url; if (dlg.doDialog(user)) // need to reconfirm email address
if (dlg.doDialog(user)) throw new RedirectResult("account?cmd=V&tgt=" + URLEncoder.encode(tgt));
{ // the email address was changed - need to jump to the "Verify" page else
String partial = "account?cmd=V&tgt=" + URLEncoder.encode(tgt); throw new RedirectResult(tgt); // just go straight on back
url = response.encodeRedirectURL(rdat.getFullServletPath(partial));
} // end if
else // just go back where we came from
url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
response.sendRedirect(url);
return;
} // end try } // end try
catch (ValidationException ve) catch (ValidationException ve)
{ // there was a validation error... { // there was a validation error...
dlg.resetOnError(ve.getMessage() + " Please try again."); dlg.resetOnError(ve.getMessage() + " Please try again.");
page_title = dlg.getTitle();
content = dlg;
} // end catch } // end catch
catch (DataException de) catch (DataException de)
{ // data error in setting up account { // data error in changing profile
page_title = "Database Error"; return new ErrorBox("Database Error","Database error updating profile: " + de.getMessage(),tgt);
content = new ErrorBox(page_title,"Database error updating profile: " + de.getMessage(),tgt);
} // end catch } // end catch
catch (EmailException ee) catch (EmailException ee)
{ // error sending the confirmation email { // error sending the confirmation email
page_title = "E-mail Error"; return new ErrorBox("E-mail Error","E-mail error sending confirmation: " + ee.getMessage(),tgt);
content = new ErrorBox(page_title,"E-mail error sending confirmation: " + ee.getMessage(),tgt);
} // end catch } // end catch
} // end if ("update" button pressed) return dlg; // redisplay dialog
else
{ // the button must be wrong! } // end if ("update" button clicked)
page_title = "Internal Error";
// the button must be wrong!
logger.error("no known button click on Account.doPost, cmd=P"); logger.error("no known button click on Account.doPost, cmd=P");
content = new ErrorBox(page_title,"Unknown command button pressed",tgt); return new ErrorBox("Internal Error","Unknown command button pressed",tgt);
} // end else } // end if
} // end else if ("P" command) // unknown command
else
{ // unknown command
page_title = "Internal Error";
logger.error("invalid command to Account.doPost: " + cmd); logger.error("invalid command to Account.doPost: " + cmd);
content = new ErrorBox(page_title,"Invalid command to Account.doPost",tgt); return new ErrorBox("Internal Error","Invalid command to Account.doPost",tgt);
} // end else } // end doVenicePost
changeMenuTop(request);
BaseJSPData basedat = new BaseJSPData(page_title,"account?cmd=" + cmd,content);
basedat.displayLoginLinks(display_login);
basedat.transfer(getServletContext(),rdat);
} // end doPost
} // end class Account } // end class Account

View File

@ -22,10 +22,8 @@ import java.util.*;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.http.*; import javax.servlet.http.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.util.ServletMultipartHandler; import com.silverwrist.util.ServletMultipartHandler;
import com.silverwrist.util.ServletMultipartException; import com.silverwrist.util.ServletMultipartException;
import com.silverwrist.venice.ValidationException;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.servlets.format.*; import com.silverwrist.venice.servlets.format.*;
@ -38,135 +36,6 @@ public class Attachment extends VeniceServlet
private static Category logger = Category.getInstance(Attachment.class.getName()); private static Category logger = Category.getInstance(Attachment.class.getName());
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private static SIGContext getSIGParameter(String str, UserContext user)
throws ValidationException, DataException
{
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 SIGContext getSIGParameter(ServletRequest request, UserContext user)
throws ValidationException, DataException
{
return getSIGParameter(request.getParameter("sig"),user);
} // end getSIGParameter
private static SIGContext getSIGParameter(ServletMultipartHandler mphandler, UserContext user)
throws ValidationException, DataException
{
if (mphandler.isFileParam("sig"))
throw new ValidationException("Internal Error: SIG should be a normal param");
return getSIGParameter(mphandler.getValue("sig"),user);
} // end getSIGParameter
private static ConferenceContext getConferenceParameter(String str, SIGContext sig)
throws ValidationException, DataException, AccessError
{
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 ConferenceContext getConferenceParameter(ServletRequest request, SIGContext sig)
throws ValidationException, DataException, AccessError
{
return getConferenceParameter(request.getParameter("conf"),sig);
} // end getConferenceParameter
private static ConferenceContext getConferenceParameter(ServletMultipartHandler mphandler, SIGContext sig)
throws ValidationException, DataException, AccessError
{
if (mphandler.isFileParam("conf"))
throw new ValidationException("Internal Error: conference should be a normal param");
return getConferenceParameter(mphandler.getValue("conf"),sig);
} // end getConferenceParameter
private static TopicMessageContext getMessageParameter(String str, ConferenceContext conf)
throws ValidationException, DataException, AccessError
{
if (str==null)
{ // no conference parameter - bail out now!
logger.error("Message parameter not specified!");
throw new ValidationException("No message specified.");
} // end if
try
{ // turn the string into a postid, and thence to a TopicMessageContext
long postid = Long.parseLong(str);
return conf.getMessageByPostID(postid);
} // 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
private static TopicMessageContext getMessageParameter(ServletRequest request, ConferenceContext conf)
throws ValidationException, DataException, AccessError
{
return getMessageParameter(request.getParameter("msg"),conf);
} // end getMessageParameter
private static TopicMessageContext getMessageParameter(ServletMultipartHandler mphandler,
ConferenceContext conf)
throws ValidationException, DataException, AccessError
{
if (mphandler.isFileParam("msg"))
throw new ValidationException("Internal Error: message should be a normal param");
return getMessageParameter(mphandler.getValue("msg"),conf);
} // end getMessageParameter
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Overrides from class HttpServlet * Overrides from class HttpServlet
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -180,248 +49,101 @@ public class Attachment extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
{ *--------------------------------------------------------------------------------
UserContext user = getUserContext(request); */
RenderData rdat = createRenderData(request,response);
String page_title = null;
Object content = null;
SIGContext sig = null; // SIG context
ConferenceContext conf = null; // conference context
TopicMessageContext msg = null; // message context
try protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
{ // this outer try is to catch ValidationException UserContext user, RenderData rdat)
try throws ServletException, IOException, VeniceServletResult
{ // all commands require a SIG parameter {
sig = getSIGParameter(request,user); // get the SIG
SIGContext sig = getSIGParameter(request,user,true,"top");
changeMenuSIG(request,sig); changeMenuSIG(request,sig);
if (logger.isDebugEnabled())
logger.debug("found SIG #" + String.valueOf(sig.getSIGID()));
} // end try // get the conference
catch (DataException de) ConferenceContext conf = getConferenceParameter(request,sig,true,"top");
{ // error looking up the SIG
page_title = "Database Error";
content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),"top");
} // end catch // get the message we want to use
TopicMessageContext msg = getMessageParameter(request,conf,true,"top");
String type, filename;
int length;
InputStream data;
if (content==null)
{ // we got the SIG parameter OK
try try
{ // all commands require a conference parameter { // retrieve the information about the attachment
conf = getConferenceParameter(request,sig); type = msg.getAttachmentType();
if (logger.isDebugEnabled()) filename = msg.getAttachmentFilename();
logger.debug("found conf #" + String.valueOf(conf.getConfID())); length = msg.getAttachmentLength();
data = msg.getAttachmentData();
} // 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(),"top");
} // end catch
} // end if
if (content==null)
{ // we got the conference parameter OK
try
{ // now we need a message parameter
msg = getMessageParameter(request,conf);
if (logger.isDebugEnabled())
logger.debug("found post #" + String.valueOf(msg.getPostID()));
} // 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(),"top");
} // 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(),"top");
} // 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(),"top");
} // end catch
if (content==null)
{ // extract the attachment data from the message and send it out
try
{ // extract the attachment data and send it out!
rdat.sendBinaryData(msg.getAttachmentType(),msg.getAttachmentFilename(),
msg.getAttachmentLength(),msg.getAttachmentData());
return; // now we're all done!
} // end try } // end try
catch (AccessError ae) catch (AccessError ae)
{ // these all get handled in pretty much the same way { // unable to access the data stream
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),"top");
content = new ErrorBox(page_title,ae.getMessage(),"top");
} // end catch } // end catch
catch (DataException de) catch (DataException de)
{ // error looking up the conference { // error getting at the data stream from the attachment
page_title = "Database Error"; return new ErrorBox("Database Error","Database error retrieving attachment: " + de.getMessage(),"top");
content = new ErrorBox(page_title,"Database error retrieving attachment: " + de.getMessage(),"top");
} // end catch } // end catch
} // end if // now we want to send that data back to the user!
throw new SendFileResult(type,filename,length,data);
// we only get here if there were an error } // end doVeniceGet
BaseJSPData basedat = new BaseJSPData(page_title,"top",content);
basedat.transfer(getServletContext(),rdat);
} // end doGet protected VeniceContent doVenicePost(HttpServletRequest request, ServletMultipartHandler mphandler,
VeniceEngine engine, UserContext user, RenderData rdat)
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, VeniceServletResult
throws ServletException, IOException
{ {
UserContext user = getUserContext(request); // Get target URL for the operation
RenderData rdat = createRenderData(request,response);
ServletMultipartHandler mphandler = null;
String target = "top";
String page_title = null;
Object content = null;
SIGContext sig = null; // SIG context
ConferenceContext conf = null; // conference context
TopicMessageContext msg = null; // message context
try
{ // this outer try is to catch ValidationException
mphandler = new ServletMultipartHandler(request);
if (mphandler.isFileParam("target")) if (mphandler.isFileParam("target"))
throw new ValidationException("Internal Error: 'target' should be a normal param"); return new ErrorBox(null,"Internal Error: 'target' should be a normal param","top");
target = mphandler.getValue("target"); String target = mphandler.getValue("target");
setMyLocation(request,target);
try // also check on file parameter status
{ // all commands require a SIG parameter
sig = getSIGParameter(mphandler,user);
changeMenuSIG(request,sig);
if (logger.isDebugEnabled())
logger.debug("found SIG #" + String.valueOf(sig.getSIGID()));
} // 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(),target);
} // end catch
if (content==null)
{ // we got the SIG parameter OK
try
{ // all commands require a conference parameter
conf = getConferenceParameter(mphandler,sig);
if (logger.isDebugEnabled())
logger.debug("found conf #" + String.valueOf(conf.getConfID()));
} // 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(),target);
} // end catch
} // end if
if (content==null)
{ // we got the conference parameter OK
try
{ // now we need a message parameter
msg = getMessageParameter(mphandler,conf);
if (logger.isDebugEnabled())
logger.debug("found post #" + String.valueOf(msg.getPostID()));
} // 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(),target);
} // end catch
} // end if
// also check on file and target parameter status
if (!(mphandler.isFileParam("thefile"))) if (!(mphandler.isFileParam("thefile")))
throw new ValidationException("Internal error: 'thefile' should be a file param"); return new ErrorBox(null,"Internal Error: 'thefile' should be a file param",target);
// get the SIG
SIGContext sig = getSIGParameter(request,user,true,"top");
changeMenuSIG(request,sig);
} // end try // get the conference
catch (ValidationException ve) ConferenceContext conf = getConferenceParameter(request,sig,true,"top");
{ // these all get handled in pretty much the same way
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),target);
} // end catch // get the message we want to use
catch (AccessError ae) TopicMessageContext msg = getMessageParameter(request,conf,true,"top");
{ // these all get handled in pretty much the same way
page_title = "Access Error";
content = new ErrorBox(page_title,ae.getMessage(),target);
} // end catch
catch (ServletMultipartException smpe)
{ // this is kind of a special case
page_title = "Error";
content = new ErrorBox(page_title,"Internal Error: " + smpe.getMessage(),target);
} // end catch
if (content==null)
{ // we're ready to get the data and attach it
try try
{ // attach the data to the message! { // attach the data to the message!
msg.attachData(mphandler.getContentType("thefile"),mphandler.getValue("thefile"), msg.attachData(mphandler.getContentType("thefile"),mphandler.getValue("thefile"),
mphandler.getContentSize("thefile"),mphandler.getFileContentStream("thefile")); mphandler.getContentSize("thefile"),mphandler.getFileContentStream("thefile"));
// go back to where we should have gone before we uploaded the message
rdat.redirectTo(target);
return;
} // end try } // end try
catch (ServletMultipartException smpe) catch (ServletMultipartException smpe)
{ // this is kind of a special case { // error processing the file parameter data
page_title = "Error"; return new ErrorBox(null,"Internal Error: " + smpe.getMessage(),target);
content = new ErrorBox(page_title,"Internal Error: " + smpe.getMessage(),target);
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // these all get handled in pretty much the same way { // access error posting the attachment data
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),target);
content = new ErrorBox(page_title,ae.getMessage(),target);
} // end catch } // end catch
catch (DataException de) catch (DataException de)
{ // error looking up the conference { // error storing the attachment in the database
page_title = "Database Error"; return new ErrorBox("Database Error","Database error storing attachment: " + de.getMessage(),target);
content = new ErrorBox(page_title,"Database error storing attachment: " + de.getMessage(),target);
} // end catch } // end catch
} // end if (we got all the parameters OK) throw new RedirectResult(target); // get back, get back, get back to where you once belonged
// we only get here if there were an error } // end doVenicePost
BaseJSPData basedat = new BaseJSPData(page_title,target,content);
basedat.transfer(getServletContext(),rdat);
} // end doPost
} // end class Attachment } // end class Attachment

View File

@ -82,82 +82,8 @@ public class ConfDisplay extends VeniceServlet
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private static SIGContext getSIGParameter(ServletRequest request, UserContext user) private static void getViewSortDefaults(ServletRequest request, int confid, TopicSortHolder tsc,
throws ValidationException, DataException String on_error) throws ErrorBox
{
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))
return null; // no topic specified
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 void getViewSortDefaults(ServletRequest request, int confid, TopicSortHolder tsc)
throws ValidationException
{ {
String str = request.getParameter("view"); String str = request.getParameter("view");
if (!(StringUtil.isStringEmpty(str))) if (!(StringUtil.isStringEmpty(str)))
@ -176,7 +102,7 @@ public class ConfDisplay extends VeniceServlet
break; break;
default: default:
throw new ValidationException("Invalid view parameter."); throw new ErrorBox(null,"Invalid view parameter.",on_error);
} // end switch } // end switch
@ -184,7 +110,7 @@ public class ConfDisplay extends VeniceServlet
catch (NumberFormatException nfe) catch (NumberFormatException nfe)
{ // failure in parseInt { // failure in parseInt
logger.error("Cannot convert view parameter '" + str + "'!"); logger.error("Cannot convert view parameter '" + str + "'!");
throw new ValidationException("Invalid view parameter."); throw new ErrorBox(null,"Invalid view parameter.",on_error);
} // end catch } // end catch
@ -208,7 +134,7 @@ public class ConfDisplay extends VeniceServlet
break; break;
default: default:
throw new ValidationException("Invalid sort parameter."); throw new ErrorBox(null,"Invalid sort parameter.",on_error);
} // end switch } // end switch
@ -216,7 +142,7 @@ public class ConfDisplay extends VeniceServlet
catch (NumberFormatException nfe) catch (NumberFormatException nfe)
{ // failure in parseInt { // failure in parseInt
logger.error("Cannot convert sort parameter '" + str + "'!"); logger.error("Cannot convert sort parameter '" + str + "'!");
throw new ValidationException("Invalid sort parameter."); throw new ErrorBox(null,"Invalid sort parameter.",on_error);
} // end catch } // end catch
@ -224,8 +150,8 @@ public class ConfDisplay extends VeniceServlet
} // end getViewSortDefaults } // end getViewSortDefaults
private static PostInterval getInterval(VeniceEngine engine, ServletRequest request, TopicContext topic) private static PostInterval getInterval(VeniceEngine engine, ServletRequest request, TopicContext topic,
throws ValidationException String on_error) throws ErrorBox
{ {
int first, last; int first, last;
@ -294,7 +220,7 @@ public class ConfDisplay extends VeniceServlet
} // end try } // end try
catch (NumberFormatException nfe) catch (NumberFormatException nfe)
{ // we could not translate the parameter to a number { // we could not translate the parameter to a number
throw new ValidationException("Message parameter is invalid."); throw new ErrorBox(null,"Message parameter is invalid.",on_error);
} // end catch } // end catch
@ -312,7 +238,7 @@ public class ConfDisplay extends VeniceServlet
} // end try } // end try
catch (NumberFormatException nfe) catch (NumberFormatException nfe)
{ // we could not translate the parameter to a number { // we could not translate the parameter to a number
throw new ValidationException("Message parameter is invalid."); throw new ErrorBox(null,"Message parameter is invalid.",on_error);
} // end catch } // end catch
@ -403,178 +329,94 @@ public class ConfDisplay extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{ {
UserContext user = getUserContext(request); // get the SIG
RenderData rdat = createRenderData(request,response); SIGContext sig = getSIGParameter(request,user,true,"top");
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); changeMenuSIG(request,sig);
if (logger.isDebugEnabled())
logger.debug("found SIG #" + String.valueOf(sig.getSIGID()));
} // end try // get the conference
catch (DataException de) ConferenceContext conf = getConferenceParameter(request,sig,true,"top");
{ // error looking up the SIG
page_title = "Database Error";
content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),"top");
} // end catch // get the topic, if we have it
TopicContext topic = getTopicParameter(request,conf,false,"top");
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()));
} // 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(),"top");
} // end catch
} // end if
if (content==null)
{ // we got the conference parameter OK
try
{ // there's an optional topic parameter
topic = getTopicParameter(request,conf);
if (logger.isDebugEnabled())
{ // do a little debugging output
if (topic!=null)
logger.debug("found topic #" + String.valueOf(topic.getTopicID()));
else
logger.debug("no topic specified");
} // end if
} // 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(),"top");
} // 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(),"top");
} // 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(),"top");
} // end catch
if (content==null)
{ // OK, let's handle the display now
if (topic!=null) if (topic!=null)
{ // we're handling messages within a single topic { // we're handling messages within a single topic
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("MODE: display messages in topic"); logger.debug("MODE: display messages in topic");
String on_error = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
setMyLocation(request,on_error + "&topic=" + topic.getTopicNumber());
// if this request is restoring the number of unread posts in another topic, try to do so // if this request is restoring the number of unread posts in another topic, try to do so
restorePosts(request,conf); restorePosts(request,conf);
try // determine what the post interval is we want to display
{ // determine what the post interval is we want to display PostInterval piv = getInterval(engine,request,topic,on_error);
VeniceEngine engine = getVeniceEngine();
PostInterval piv = getInterval(engine,request,topic);
boolean read_new = !(StringUtil.isStringEmpty(request.getParameter("rnm"))); boolean read_new = !(StringUtil.isStringEmpty(request.getParameter("rnm")));
boolean show_adv = !(StringUtil.isStringEmpty(request.getParameter("shac"))); boolean show_adv = !(StringUtil.isStringEmpty(request.getParameter("shac")));
// create the post display // Create the post display.
TopicPosts tpos = new TopicPosts(request,engine,sig,conf,topic,piv.getFirst(),piv.getLast(), TopicPosts tpos = null;
read_new,show_adv); try
content = tpos; { // create the display
page_title = topic.getName() + ": " + String.valueOf(topic.getTotalMessages()) + " Total; " tpos = new TopicPosts(request,engine,sig,conf,topic,piv.getFirst(),piv.getLast(),read_new,show_adv);
+ String.valueOf(tpos.getNewMessages()) + " New; Last: "
+ rdat.formatDateForDisplay(topic.getLastUpdateDate());
} // end try } // end try
catch (ValidationException ve)
{ // there's an error in the parameters somewhere
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),"top");
} // end catch
catch (DataException de) catch (DataException de)
{ // there was a database error retrieving topics { // there was a database error retrieving messages
page_title = "Database Error"; return new ErrorBox("Database Error","Database error listing messages: " + de.getMessage(),on_error);
content = new ErrorBox(page_title,"Database error listing messages: " + de.getMessage(),"top");
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // we were unable to retrieve the topic list { // we were unable to retrieve the message list
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),on_error);
content = new ErrorBox(page_title,ae.getMessage(),"top");
} // end catch } // end catch
} // end if return tpos;
} // end if (messages in a topic)
else else
{ // we're displaying the conference's topic list { // we're displaying the conference's topic list
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("MODE: display topics in conference"); logger.debug("MODE: display topics in conference");
setMyLocation(request,"confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID());
String on_error = "confops?sig=" + sig.getSIGID();
// get any changes to view or sort options
TopicSortHolder opts = TopicSortHolder.retrieve(request.getSession(true)); TopicSortHolder opts = TopicSortHolder.retrieve(request.getSession(true));
try getViewSortDefaults(request,conf.getConfID(),opts,on_error);
{ // get any changes to view or sort options
getViewSortDefaults(request,conf.getConfID(),opts);
// create the topic list TopicListing tl = null;
content = new TopicListing(request,sig,conf,opts.getViewOption(conf.getConfID()), try
{ // create the topic lict
tl = new TopicListing(request,sig,conf,opts.getViewOption(conf.getConfID()),
opts.getSortOption(conf.getConfID())); opts.getSortOption(conf.getConfID()));
page_title = "Topics in " + conf.getName();
} // end try } // end try
catch (ValidationException ve)
{ // there was some sort of a parameter error in the display
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),"top");
} // end catch
catch (DataException de) catch (DataException de)
{ // there was a database error retrieving topics { // there was a database error retrieving topics
page_title = "Database Error"; return new ErrorBox("Database Error","Database error listing topics: " + de.getMessage(),on_error);
content = new ErrorBox(page_title,"Database error listing topics: " + de.getMessage(),"top");
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // we were unable to retrieve the topic list { // we were unable to retrieve the topic list
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),on_error);
content = new ErrorBox(page_title,ae.getMessage(),"top");
} // end catch } // end catch
} // end else return tl;
} // end if } // end else (topics in a conference)
BaseJSPData basedat = new BaseJSPData(page_title,"confdisp?" + request.getQueryString(),content); } // end doVeniceGet
basedat.transfer(getServletContext(),rdat);
} // end doGet
} // end class ConfDisplay } // end class ConfDisplay

View File

@ -39,58 +39,6 @@ public class ConfOperations extends VeniceServlet
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
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 CreateConferenceDialog makeCreateConferenceDialog() throws ServletException private CreateConferenceDialog makeCreateConferenceDialog() throws ServletException
{ {
final String desired_name = "CreateConferenceDialog"; final String desired_name = "CreateConferenceDialog";
@ -108,22 +56,22 @@ public class ConfOperations extends VeniceServlet
} // end makeCreateConferenceDialog } // end makeCreateConferenceDialog
private static boolean validateNewTopic(ServletRequest request) throws ValidationException 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"); String foo = request.getParameter("title");
if (foo==null) if (foo==null)
throw new ValidationException("Title parameter was not specified."); 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"); foo = request.getParameter("pseud");
if (foo==null) if (foo==null)
throw new ValidationException("Pseud parameter was not specified."); throw new ErrorBox(null,"Pseud parameter was not specified.",on_error);
foo = request.getParameter("pb"); foo = request.getParameter("pb");
if (foo==null) if (foo==null)
throw new ValidationException("Body text was not specified."); throw new ErrorBox(null,"Body text was not specified.",on_error);
is_zp_null = (foo.length()==0); is_zp_null = (foo.length()==0);
return is_title_null || is_zp_null; return is_title_null || is_zp_null;
@ -143,177 +91,127 @@ public class ConfOperations extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{ {
UserContext user = getUserContext(request); // get the SIG
RenderData rdat = createRenderData(request,response); SIGContext sig = getSIGParameter(request,user,true,"top");
String page_title = null;
Object content = null;
SIGContext sig = null;
try
{ // all conference commands require a SIG parameter as well
sig = getSIGParameter(request,user);
changeMenuSIG(request,sig); changeMenuSIG(request,sig);
String on_error = "confops?sig=" + sig.getSIGID();
} // end try // get the command we want to use
catch (ValidationException ve) String cmd = getStandardCommandParam(request);
{ // no SIG specified
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),"top");
} // end catch
catch (DataException de)
{ // error looking up the SIG
page_title = "Database Error";
content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),"top");
} // end catch
if (content==null)
{ // get the command we want to use
String cmd = request.getParameter("cmd");
if (cmd==null)
cmd = "???";
if (cmd.equals("C")) if (cmd.equals("C"))
{ // "C" = "Create conference" { // "C" = "Create conference"
if (sig.canCreateConference()) if (!(sig.canCreateConference()))
{ // make the create conference dialog! return new ErrorBox("Access Error","You are not permitted to create conferences in this SIG.",
on_error);
// make the "create" dialog
CreateConferenceDialog dlg = makeCreateConferenceDialog(); CreateConferenceDialog dlg = makeCreateConferenceDialog();
dlg.setupDialog(getVeniceEngine(),sig); dlg.setupDialog(engine,sig);
content = dlg; setMyLocation(request,on_error + "&cmd=C");
page_title = dlg.getTitle(); return dlg;
} // end if } // end if ("C" command)
else
{ // we can't create conferences
page_title = "Error";
content = new ErrorBox("SIG Error","You are not permitted to create conferences in this SIG.","top");
} // end else if (cmd.equals("T"))
} // end if
else if (cmd.equals("T"))
{ // "T" = "Create topic" (requires conference parameter) { // "T" = "Create topic" (requires conference parameter)
try ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
{ // start by getting the conference parameter on_error = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
ConferenceContext conf = getConferenceParameter(request,sig);
// create the New Topic form // Create the new topic form.
NewTopicForm ntf = new NewTopicForm(sig,conf); NewTopicForm ntf = new NewTopicForm(sig,conf);
ntf.setupNewRequest(); ntf.setupNewRequest();
content = ntf; setMyLocation(request,"confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=T");
page_title = "Create New Topic"; return ntf;
} // end if ("T" command)
if (cmd.equals("Q"))
{ // "Q" = display Manage menu (requires conference parameter)
ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
on_error = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
// display the "Manage Conference" display
setMyLocation(request,"confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=Q");
return new ManageConference(sig,conf);
} // end if ("Q" command)
if (cmd.equals("FX"))
{ // "FX" = the dreaded fixseen :-) - catches up the entire conference
ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
on_error = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
try
{ // do the fixseen operation
conf.fixSeen();
} // end try } // end try
catch (ValidationException ve)
{ // we can't get the conference parameter
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),
"sigprofile?sig=" + String.valueOf(sig.getSIGID()));
} // end catch
catch (AccessError ae)
{ // we have some sort of access problem
page_title = "Access Error";
content = new ErrorBox(page_title,ae.getMessage(),
"sigprofile?sig=" + String.valueOf(sig.getSIGID()));
} // end catch
catch (DataException de) catch (DataException de)
{ // some sort of error in the database { // some sort of error in the database
page_title = "Database Error"; return new ErrorBox("Database Error","Database error catching up conference: " + de.getMessage(),
content = new ErrorBox(page_title,"Database error finding conference: " + de.getMessage(), on_error);
"sigprofile?sig=" + String.valueOf(sig.getSIGID()));
} // end catch } // end catch
} // end else return null; // null response here
else
{ // any unrecognized command jumps us to "conference list" } // end if ("FX" command)
// Any unrecognized command shows us the conference list.
on_error = "sigprofile?sig=" + sig.getSIGID();
try try
{ // show the conference listing { // make a conference listing
content = new ConferenceListing(sig); setMyLocation(request,"confops?sig=" + sig.getSIGID());
page_title = "Conference Listing: " + sig.getName(); return new ConferenceListing(sig);
} // end try } // end try
catch (DataException de) catch (DataException de)
{ // something wrong in the database { // something wrong in the database
page_title = "Database Error"; return new ErrorBox("Database Error","Database error finding conferences: " + de.getMessage(),on_error);
content = new ErrorBox(page_title,"Database error finding conferences: " + de.getMessage(),
"sigprofile?sig=" + String.valueOf(sig.getSIGID()));
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // some lack of access is causing problems { // some lack of access is causing problems
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),on_error);
content = new ErrorBox(page_title,ae.getMessage(),
"sigprofile?sig=" + String.valueOf(sig.getSIGID()));
} // end catch } // end catch
} // end else } // end doVeniceGet
} // end if (SIG parameter retrieved OK) protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
BaseJSPData basedat = new BaseJSPData(page_title,"confops?" + request.getQueryString(),content); throws ServletException, IOException, VeniceServletResult
basedat.transfer(getServletContext(),rdat);
} // end doGet
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{ {
UserContext user = getUserContext(request); // get the SIG
RenderData rdat = createRenderData(request,response); SIGContext sig = getSIGParameter(request,user,true,"top");
String page_title = null;
Object content = null;
SIGContext sig = null;
String location;
try
{ // all conference commands require a SIG parameter as well
sig = getSIGParameter(request,user);
changeMenuSIG(request,sig); changeMenuSIG(request,sig);
location = "confops?sig=" + String.valueOf(sig.getSIGID()); String on_error = "confops?sig=" + sig.getSIGID();
} // end try // get the command we want to use
catch (ValidationException ve) String cmd = getStandardCommandParam(request);
{ // no SIG specified
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),"top");
location = "top";
} // end catch
catch (DataException de)
{ // error looking up the SIG
page_title = "Database Error";
content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),"top");
location = "top";
} // end catch
if (content==null)
{ // get the command we want to use
String cmd = request.getParameter("cmd");
if (cmd==null)
cmd = "???";
if (cmd.equals("C")) if (cmd.equals("C"))
{ // "C" = "Create Conference" { // "C" = "Create Conference"
if (sig.canCreateConference()) if (!(sig.canCreateConference()))
{ // load up the create conference dialog! return new ErrorBox("Access Error","You are not permitted to create conferences in this SIG.",
on_error);
// load up the create conference dialog!
CreateConferenceDialog dlg = makeCreateConferenceDialog(); CreateConferenceDialog dlg = makeCreateConferenceDialog();
dlg.setupDialog(getVeniceEngine(),sig); dlg.setupDialog(engine,sig);
if (dlg.isButtonClicked(request,"cancel")) if (dlg.isButtonClicked(request,"cancel"))
{ // they chickened out - go back to the conference list throw new RedirectResult(on_error); // they chickened out - go back to the conference list
rdat.redirectTo(location);
return;
} // end if
if (dlg.isButtonClicked(request,"create")) if (dlg.isButtonClicked(request,"create"))
{ // OK, they actually want to create the new conference... { // OK, they actually want to create the new conference...
@ -323,195 +221,126 @@ public class ConfOperations extends VeniceServlet
{ // attempt to create the conference! { // attempt to create the conference!
ConferenceContext conf = dlg.doDialog(sig); ConferenceContext conf = dlg.doDialog(sig);
// success! go to the conference's topic list // success! redirect to the conference's topic list
rdat.redirectTo("confdisp?sig=" + String.valueOf(sig.getSIGID()) + "&conf=" throw new RedirectResult("confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID());
+ String.valueOf(conf.getConfID()));
return;
} // end try } // end try
catch (ValidationException ve) catch (ValidationException ve)
{ // validation error - throw it back to the user { // validation error - throw it back to the user
dlg.resetOnError(ve.getMessage() + " Please try again."); dlg.resetOnError(ve.getMessage() + " Please try again.");
content = dlg;
page_title = dlg.getTitle();
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // some sort of access error - display an error dialog { // some sort of access error - display an error dialog
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),on_error);
content = new ErrorBox(page_title,ae.getMessage(),location);
} // end catch } // end catch
catch (DataException de) catch (DataException de)
{ // database error creating the conference { // database error creating the conference
page_title = "Database Error"; return new ErrorBox("Database Error","Database error creating conference: " + de.getMessage(),
content = new ErrorBox(page_title,"Database error creating conference: " + de.getMessage(), on_error);
location);
} // end catch } // end catch
} // end if setMyLocation(request,on_error + "&cmd=C");
else return dlg; // redisplay the dialog
{ // error - don't know what button was clicked
page_title = "Internal Error"; } // end if ("create" button clicked)
// error - don't know what button was clicked
logger.error("no known button click on ConfOperations.doPost, cmd=C"); logger.error("no known button click on ConfOperations.doPost, cmd=C");
content = new ErrorBox(page_title,"Unknown command button pressed",location); return new ErrorBox("Internal Error","Unknown command button pressed",on_error);
} // end else
} // end if
else
{ // we can't create conferences
page_title = "Error";
content = new ErrorBox("SIG Error","You are not permitted to create conferences in this SIG.",
location);
} // end else
} // end if ("C" command) } // end if ("C" command)
else if (cmd.equals("T"))
if (cmd.equals("T"))
{ // "T" command = Create New Topic (requires conference parameter) { // "T" command = Create New Topic (requires conference parameter)
ConferenceContext conf = null; ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
on_error = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
try // determine what to do based on the button pressed
{ // start by getting the conference parameter
conf = getConferenceParameter(request,sig);
} // end try
catch (ValidationException ve)
{ // we can't get the conference parameter
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),location);
} // end catch
catch (AccessError ae)
{ // we have some sort of access problem
page_title = "Access Error";
content = new ErrorBox(page_title,ae.getMessage(),location);
} // end catch
catch (DataException de)
{ // some sort of error in the database
page_title = "Database Error";
content = new ErrorBox(page_title,"Database error finding conference: " + de.getMessage(),location);
} // end catch
if (content==null)
{ // determine what to do based on the button pressed
String on_error = "confdisp?sig=" + String.valueOf(sig.getSIGID()) + "&conf="
+ String.valueOf(conf.getConfID());
if (isImageButtonClicked(request,"cancel")) if (isImageButtonClicked(request,"cancel"))
{ // the user chickened out - go back to the conference display throw new RedirectResult(on_error); // the user chickened out - go back to the conference display
rdat.redirectTo(on_error);
return;
} // end if
if (isImageButtonClicked(request,"preview")) if (isImageButtonClicked(request,"preview"))
{ // generate a preview and redisplay the form { // generate a preview and redisplay the form
NewTopicForm ntf = new NewTopicForm(sig,conf); NewTopicForm ntf = new NewTopicForm(sig,conf);
try try
{ // do a preview generation { // generate a preview display
ntf.generatePreview(getVeniceEngine(),conf,request); ntf.generatePreview(engine,conf,request);
if (ntf.isNullRequest())
{ // no title or text specified - this is a "204 No Content" return
rdat.nullResponse();
return;
} // end if
content = ntf;
page_title = "Preview New Topic";
} // end try } // end try
catch (ValidationException ve) catch (ValidationException ve)
{ // something messed up in the preview generation { // something messed up in the preview generation
page_title = "Error"; return new ErrorBox(null,ve.getMessage(),on_error);
content = new ErrorBox(null,ve.getMessage(),on_error);
} // end catch } // end catch
} // end if ("preview" button clicked) if (ntf.isNullRequest())
else if (isImageButtonClicked(request,"post")) return null; // no title or text specified - "204 No Content"
{ // OK, let's do a post request!
try setMyLocation(request,"confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=T");
return ntf;
} // end if ("preview" clicked)
if (isImageButtonClicked(request,"post"))
{ // first validate that we've got all the parameters { // first validate that we've got all the parameters
if (validateNewTopic(request)) if (validateNewTopic(request,on_error))
{ // this is a null request - send a null response return null; // this is a null request - send a null response
rdat.nullResponse();
return;
} // end if try
{ // add the new topic!
// add the new topic!
TopicContext topic = conf.addTopic(request.getParameter("title"),request.getParameter("pseud"), TopicContext topic = conf.addTopic(request.getParameter("title"),request.getParameter("pseud"),
request.getParameter("pb")); request.getParameter("pb"));
final String yes = "Y"; final String yes = "Y";
if (yes.equals(request.getParameter("attach"))) if (yes.equals(request.getParameter("attach")))
{ // we need to upload an attachment for this post { // we need to upload an attachment for this post
TopicMessageContext msg = topic.getMessage(0); // load the "zero post" setMyLocation(request,on_error);
return new AttachmentForm(sig,conf,topic.getMessage(0),on_error);
content = new AttachmentForm(sig,conf,msg,on_error);
page_title = "Upload Attachment";
} // end if } // end if
else
{ // the post is complete, we need only jump to the topic
// TODO: jump straight to the new topic
rdat.redirectTo(on_error);
return;
} // end else
} // end try } // end try
catch (ValidationException ve)
{ // the validation of parameters failed
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),on_error);
} // end catch
catch (DataException de) catch (DataException de)
{ // display a database error { // display a database error
page_title = "Database Error"; return new ErrorBox("Database Error","Database error adding topic: " + de.getMessage(),on_error);
content = new ErrorBox(page_title,"Database error adding topic: " + de.getMessage(),on_error);
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // some sort of access problem { // some sort of access problem
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),on_error);
content = new ErrorBox(page_title,ae.getMessage(),on_error);
} // end catch } // end catch
} // end else if // jump back to the form under normal circumstances
else throw new RedirectResult(on_error);
{ // we don't know what button was pressed
page_title = "Internal Error"; } // end if ("post" clicked)
// we don't know what button was pressed
logger.error("no known button click on ConfOperations.doPost, cmd=T"); logger.error("no known button click on ConfOperations.doPost, cmd=T");
content = new ErrorBox(page_title,"Unknown command button pressed",on_error); return new ErrorBox("Internal Error","Unknown command button pressed",on_error);
} // end else } // end if ("T" command)
} // end if (we got the conference parameter OK) if (cmd.equals("P"))
{ // "P" = Set default pseud (requires conference parameter)
ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
on_error = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
} // end else if ("T" command) // TODO: finish this later
else
{ // unrecognized command! return null;
page_title = "Internal Error";
} // end if ("P" command)
// unrecognized command!
logger.error("invalid command to ConfOperations.doPost: " + cmd); logger.error("invalid command to ConfOperations.doPost: " + cmd);
content = new ErrorBox(page_title,"Invalid command to ConfOperations.doPost",location); return new ErrorBox("Internal Error","Invalid command to ConfOperations.doPost",on_error);
} // end else } // end doVenicePost
} // end if (SIG parameter retrieved OK)
BaseJSPData basedat = new BaseJSPData(page_title,location,content);
basedat.transfer(getServletContext(),rdat);
} // end doPost
} // end class ConfOperations } // end class ConfOperations

View File

@ -0,0 +1,54 @@
/*
* 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 com.silverwrist.venice.servlets.format.VeniceContent;
public class ContentResult extends VeniceServletResult
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private VeniceContent content;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ContentResult(VeniceContent content)
{
super();
this.content = content;
} // end constructor
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public VeniceContent getContent()
{
return content;
} // end getContent
} // end class ContentResult

View File

@ -0,0 +1,66 @@
/*
* 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.IOException;
import com.silverwrist.venice.servlets.format.RenderData;
public class ErrorResult extends ExecuteResult
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private int code;
private String msg;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public ErrorResult(int code)
{
this.code = code;
this.msg = null;
} // end constructor
public ErrorResult(int code, String msg)
{
this.code = code;
this.msg = msg;
} // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class ExecuteResult
*--------------------------------------------------------------------------------
*/
public void execute(RenderData rdat) throws IOException
{
if (msg!=null)
rdat.errorResponse(code,msg);
else
rdat.errorResponse(code);
} // end execute
} // end class ErrorResult

View File

@ -0,0 +1,44 @@
/*
* 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.IOException;
import javax.servlet.ServletException;
import com.silverwrist.venice.servlets.format.RenderData;
public abstract class ExecuteResult extends VeniceServletResult
{
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
protected ExecuteResult()
{
super();
} // end constructor
/*--------------------------------------------------------------------------------
* Abstract operations which must be overridden
*--------------------------------------------------------------------------------
*/
public abstract void execute(RenderData rdat) throws IOException, ServletException;
} // end class ExecuteResult

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -75,7 +75,7 @@ public class Find extends VeniceServlet
} // end getDisplayParam } // end getDisplayParam
private int getCategoryParam(ServletRequest request) throws ServletException private int getCategoryParam(VeniceEngine engine, ServletRequest request)
{ {
String cat_str = request.getParameter("cat"); String cat_str = request.getParameter("cat");
if (cat_str==null) if (cat_str==null)
@ -84,7 +84,7 @@ public class Find extends VeniceServlet
try try
{ // get the category ID and check it for validity { // get the category ID and check it for validity
int cat = Integer.parseInt(cat_str); int cat = Integer.parseInt(cat_str);
if (getVeniceEngine().isValidCategoryID(cat)) if (engine.isValidCategoryID(cat))
return cat; return cat;
} // end try } // end try
@ -109,86 +109,71 @@ public class Find extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
{ *--------------------------------------------------------------------------------
UserContext user = getUserContext(request); */
RenderData rdat = createRenderData(request,response);
String page_title = null;
Object content = null;
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
changeMenuTop(request); // we go to the "top" menus for this changeMenuTop(request); // we go to the "top" menus for this
// figure out which page to display // figure out which page to display
int disp = getDisplayParam(request,FindData.getNumChoices()); int disp = getDisplayParam(request,FindData.getNumChoices());
FindData finddata = new FindData(getVeniceEngine(),user,disp); FindData finddata = new FindData(engine,user,disp);
// figure out the category ID parameter // figure out the category ID parameter
int cat = -1; int cat = -1;
if (disp==FindData.FD_SIGS) if (disp==FindData.FD_SIGS)
cat = getCategoryParam(request); cat = getCategoryParam(engine,request);
try try
{ // attempt to configure the display { // attempt to configure the display
finddata.loadGet(cat); finddata.loadGet(cat);
// display the standard output
page_title = "Find";
content = finddata;
} // end try } // end try
catch (DataException de) catch (DataException de)
{ // database error, man { // database error, man
page_title = "Database Error"; return new ErrorBox("Database Error","Database error accessing category data: " + de.getMessage(),"top");
content = new ErrorBox(page_title,"Database error accessing category data: " + de.getMessage(),"top");
} // end catch } // end catch
BaseJSPData basedat = new BaseJSPData(page_title,"find?" + request.getQueryString(),content); setMyLocation(request,"find?" + request.getQueryString());
basedat.transfer(getServletContext(),rdat); return finddata;
} // end doGet } // end doVeniceGet
public void doPost(HttpServletRequest request, HttpServletResponse response) protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
throws ServletException, IOException UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{ {
UserContext user = getUserContext(request);
RenderData rdat = createRenderData(request,response);
String page_title = null;
Object content = null;
changeMenuTop(request); // we go to the "top" menus for this changeMenuTop(request); // we go to the "top" menus for this
// figure out which page to display // figure out which page to display
int disp = getDisplayParam(request,FindData.getNumChoices()); int disp = getDisplayParam(request,FindData.getNumChoices());
FindData finddata = new FindData(getVeniceEngine(),user,disp); FindData finddata = new FindData(engine,user,disp);
try try
{ // attempt to configure the display { // attempt to configure the display
finddata.loadPost(request); finddata.loadPost(request);
// display the standard output
page_title = "Find";
content = finddata;
} // end try } // end try
catch (ValidationException ve) catch (ValidationException ve)
{ // error in find parameters { // error in find parameters
page_title = "Find Error"; return new ErrorBox("Find Error",ve.getMessage(),"top");
content = new ErrorBox(null,ve.getMessage(),"top");
} // end catch } // end catch
catch (DataException de) catch (DataException de)
{ // database error, man { // database error, man
page_title = "Database Error"; return new ErrorBox("Database Error","Database error on find: " + de.getMessage(),"top");
content = new ErrorBox(page_title,"Database error on find: " + de.getMessage(),"top");
} // end catch } // end catch
BaseJSPData basedat = new BaseJSPData(page_title, setMyLocation(request,"find?disp=" + finddata.getDisplayOption());
"find?disp=" + String.valueOf(finddata.getDisplayOption()),content); return finddata;
basedat.transfer(getServletContext(),rdat);
} // end doPost } // end doVenicePost
} // end class Find } // end class Find

View File

@ -41,89 +41,11 @@ public class PostMessage extends VeniceServlet
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private static SIGContext getSIGParameter(ServletRequest request, UserContext user) private static int getPostNumber(ServletRequest request, String on_error) throws ErrorBox
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 int getPostNumber(ServletRequest request) throws ValidationException
{ {
String str = request.getParameter("sd"); String str = request.getParameter("sd");
if (StringUtil.isStringEmpty(str)) if (StringUtil.isStringEmpty(str))
throw new ValidationException("Invalid parameter."); throw new ErrorBox(null,"Invalid parameter.",on_error);
try try
{ // get the number of posts we think he topic has { // get the number of posts we think he topic has
return Integer.parseInt(str); return Integer.parseInt(str);
@ -131,7 +53,7 @@ public class PostMessage extends VeniceServlet
} // end try } // end try
catch (NumberFormatException nfe) catch (NumberFormatException nfe)
{ // not a good integer... { // not a good integer...
throw new ValidationException("Invalid parameter."); throw new ErrorBox(null,"Invalid parameter.",on_error);
} // end catch } // end catch
@ -150,198 +72,73 @@ public class PostMessage extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doPost(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{ {
UserContext user = getUserContext(request); // get the SIG
RenderData rdat = createRenderData(request,response); SIGContext sig = getSIGParameter(request,user,true,"top");
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); changeMenuSIG(request,sig);
if (logger.isDebugEnabled())
logger.debug("found SIG #" + String.valueOf(sig.getSIGID()));
} // end try // get the conference
catch (DataException de) ConferenceContext conf = getConferenceParameter(request,sig,true,"top");
{ // error looking up the SIG
page_title = "Database Error";
content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),"top");
} // end catch // get the topic
TopicContext topic = getTopicParameter(request,conf,true,"top");
if (content==null) String on_error = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&top="
{ // we got the SIG parameter OK + topic.getTopicNumber();
try
{ // all commands require a conference parameter
conf = getConferenceParameter(request,sig);
if (logger.isDebugEnabled())
logger.debug("found conf #" + String.valueOf(conf.getConfID()));
} // end try // make sure we've got some post data
catch (DataException de)
{ // error looking up the conference
page_title = "Database Error";
content = new ErrorBox(page_title,"Database error finding conference: " + de.getMessage(),"top");
} // 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()));
} // 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(),"top");
} // 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(),"top");
} // 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(),"top");
} // end catch
if (content==null)
{ // make sure we've got some post data
String raw_postdata = request.getParameter("pb"); String raw_postdata = request.getParameter("pb");
if (StringUtil.isStringEmpty(raw_postdata)) if (StringUtil.isStringEmpty(raw_postdata))
{ // don't allow zero-size posts return null; // don't allow zero-size posts
rdat.nullResponse();
return;
} // end if
final String yes = "Y"; final String yes = "Y";
// now decide what to do based on which button got clicked
if (isImageButtonClicked(request,"cancel")) if (isImageButtonClicked(request,"cancel"))
{ // canceled posting - take us back to familiar ground throw new RedirectResult(on_error); // canceled posting - take us back
rdat.redirectTo("confdisp?sig=" + String.valueOf(sig.getSIGID()) + "&conf="
+ String.valueOf(conf.getConfID()) + "&top="
+ String.valueOf(topic.getTopicNumber()));
return;
} // end if ("Cancel") if (isImageButtonClicked(request,"preview")) // generate a preview
else if (isImageButtonClicked(request,"preview")) return new PostPreview(engine,sig,conf,topic,request.getParameter("pseud"),raw_postdata,
{ // previewing the post! request.getParameter("next"),getPostNumber(request,on_error),
try
{ // generate a preview view
content = new PostPreview(getVeniceEngine(),sig,conf,topic,request.getParameter("pseud"),
raw_postdata,request.getParameter("next"),getPostNumber(request),
yes.equals(request.getParameter("attach"))); yes.equals(request.getParameter("attach")));
page_title = "Previewing Post";
} // end try if (isImageButtonClicked(request,"post") || isImageButtonClicked(request,"postnext"))
catch (ValidationException ve) { // post the message, and then either go back to the same topic or on to the next one
{ // there was some sort of a parameter error in the display (getPostNumber can throw this) boolean go_next = isImageButtonClicked(request,"postnext");
page_title = "Error"; int pn = getPostNumber(request,on_error);
content = new ErrorBox(null,ve.getMessage(),"top");
} // end catch
} // end else if ("Preview & Spellcheck")
else if (isImageButtonClicked(request,"post"))
{ // post the message, and then reload the same topic
try try
{ // first, check against slippage { // first check for slippage
int pn = getPostNumber(request); if (pn!=topic.getTotalMessages()) // slippage detected! display the slippage screen
if (pn==topic.getTotalMessages()) return new PostSlippage(engine,sig,conf,topic,pn,request.getParameter("next"),
{ // no slippage - post the message!!!
TopicMessageContext msg = topic.postNewMessage(0,request.getParameter("pseud"),raw_postdata);
if (yes.equals(request.getParameter("attach")))
{ // we have an attachment to upload...display the "Upload Attachment" form
String target = "confdisp?sig=" + String.valueOf(sig.getSIGID()) + "&conf="
+ String.valueOf(conf.getConfID()) + "&top="
+ String.valueOf(topic.getTopicNumber()) + "&rnm=1";
content = new AttachmentForm(sig,conf,msg,target);
page_title = "Upload Attachment";
} // end if
else
{ // no attachment - jump back to the topic
rdat.redirectTo("confdisp?sig=" + String.valueOf(sig.getSIGID()) + "&conf="
+ String.valueOf(conf.getConfID()) + "&top="
+ String.valueOf(topic.getTopicNumber()) + "&rnm=1");
return;
} // end else
} // end if
else
{ // slippage detected - show the slippage display
content = new PostSlippage(getVeniceEngine(),sig,conf,topic,pn,request.getParameter("next"),
request.getParameter("pseud"),raw_postdata, request.getParameter("pseud"),raw_postdata,
yes.equals(request.getParameter("attach"))); yes.equals(request.getParameter("attach")));
page_title = "Slippage or Double-Click Detected";
} // end else // post the darn thing!
} // end try
catch (ValidationException ve)
{ // there was some sort of a parameter error in the display
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),"top");
} // end catch
catch (DataException de)
{ // there was a database error posting the message
page_title = "Database Error";
content = new ErrorBox(page_title,"Database error posting message: " + de.getMessage(),"top");
} // end catch
catch (AccessError ae)
{ // we were unable to retrieve the topic list
page_title = "Access Error";
content = new ErrorBox(page_title,ae.getMessage(),"top");
} // end catch
} // end else if ("Post & Reload")
else if (isImageButtonClicked(request,"postnext"))
{ // post the message, and then go to the "next" topic
try
{ // first, check against slippage
int pn = getPostNumber(request);
if (pn==topic.getTotalMessages())
{ // no slippage - post the message!
TopicMessageContext msg = topic.postNewMessage(0,request.getParameter("pseud"),raw_postdata); TopicMessageContext msg = topic.postNewMessage(0,request.getParameter("pseud"),raw_postdata);
short next; short next;
try try
{ // attempt to get the value of the "next topic" parameter { // attempt to get the value of the "next topic" parameter
if (go_next)
{ // get the "next topic" parameter
String foo = request.getParameter("next"); String foo = request.getParameter("next");
if (StringUtil.isStringEmpty(foo)) if (StringUtil.isStringEmpty(foo))
next = topic.getTopicNumber(); next = topic.getTopicNumber();
else else
next = Short.parseShort(foo); next = Short.parseShort(foo);
} // end if
else
next = topic.getTopicNumber();
} // end try } // end try
catch (NumberFormatException nfe) catch (NumberFormatException nfe)
{ // just default me { // just default me
@ -349,66 +146,34 @@ public class PostMessage extends VeniceServlet
} // end catch } // end catch
// where do we want to go now?
String target = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&top="
+ next + "&rnm=1";
if (yes.equals(request.getParameter("attach"))) if (yes.equals(request.getParameter("attach")))
{ // we have an attachment to upload... return new AttachmentForm(sig,conf,msg,target); // go to upload an attachment
// TODO: jump somewhere we can upload the attachment!
rdat.redirectTo("confdisp?sig=" + String.valueOf(sig.getSIGID()) + "&conf="
+ String.valueOf(conf.getConfID()) + "&top=" + String.valueOf(next) + "&rnm=1");
return;
} // end if // no attachment - redirect where we need to go
else throw new RedirectResult(target);
{ // no attachment - jump to the next topic
rdat.redirectTo("confdisp?sig=" + String.valueOf(sig.getSIGID()) + "&conf="
+ String.valueOf(conf.getConfID()) + "&top=" + String.valueOf(next) + "&rnm=1");
return;
} // end else
} // end if
else
{ // slippage detected - show the slippage display
content = new PostSlippage(getVeniceEngine(),sig,conf,topic,pn,request.getParameter("next"),
request.getParameter("pseud"),raw_postdata,
yes.equals(request.getParameter("attach")));
page_title = "Slippage or Double-Click Detected";
} // end else
} // end try } // end try
catch (ValidationException ve)
{ // there was some sort of a parameter error in the display
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),"top");
} // end catch
catch (DataException de) catch (DataException de)
{ // there was a database error posting the message { // there was a database error posting the message
page_title = "Database Error"; return new ErrorBox("Database Error","Database error posting message: " + de.getMessage(),"top");
content = new ErrorBox(page_title,"Database error posting message: " + de.getMessage(),"top");
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // we were unable to retrieve the topic list { // we were unable to post the message
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),"top");
content = new ErrorBox(page_title,ae.getMessage(),"top");
} // end catch } // end catch
} // end else if ("Post & Go Next") } // end if
else
{ // unknown button clicked // unknown button clicked
page_title = "Internal Error";
logger.error("no known button click on PostMessage.doPost"); logger.error("no known button click on PostMessage.doPost");
content = new ErrorBox(page_title,"Unknown command button pressed","top"); return new ErrorBox("Internal Error","Unknown command button pressed","top");
} // end else } // end doVenicePost
} // end if (got all parameters oK)
BaseJSPData basedat = new BaseJSPData(page_title,"post",content);
basedat.transfer(getServletContext(),rdat);
} // end doPost
} // end class PostMessage } // end class PostMessage

View File

@ -39,115 +39,6 @@ public class PostOperations extends VeniceServlet
private static Category logger = Category.getInstance(TopicOperations.class.getName()); 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 * Overrides from class HttpServlet
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -161,117 +52,38 @@ public class PostOperations extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{ {
UserContext user = getUserContext(request); // get the SIG
RenderData rdat = createRenderData(request,response); SIGContext sig = getSIGParameter(request,user,true,"top");
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); changeMenuSIG(request,sig);
if (logger.isDebugEnabled()) String locator = "sig=" + sig.getSIGID();
logger.debug("found SIG #" + String.valueOf(sig.getSIGID())); String location = "sigprofile?" + locator;
locator = "sig=" + String.valueOf(sig.getSIGID());
location = "sigprofile?" + locator;
} // end try // get the conference
catch (DataException de) ConferenceContext conf = getConferenceParameter(request,sig,true,location);
{ // error looking up the SIG locator += "&conf=" + conf.getConfID();
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; location = "confdisp?" + locator;
} // end try // get the topic
catch (DataException de) TopicContext topic = getTopicParameter(request,conf,true,location);
{ // error looking up the conference locator += "&top=" + topic.getTopicID();
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; location = "confdisp?" + locator;
} // end try // get the message
catch (DataException de) TopicMessageContext msg = getMessageParameter(request,topic,true,location);
{ // 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"; location = "confdisp?" + locator + "&p1=" + msg.getPostNumber() + "&shac=1";
setMyLocation(request,location);
} // end try // figure out what command we want to perform
catch (DataException de) String cmd = getStandardCommandParam(request);
{ // 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")) if (cmd.equals("HY") || cmd.equals("HN"))
{ // we want to hide or show the message { // we want to hide or show the message
@ -280,114 +92,90 @@ public class PostOperations extends VeniceServlet
msg.setHidden(cmd.equals("HY")); msg.setHidden(cmd.equals("HY"));
// go back and display stuff // go back and display stuff
rdat.redirectTo(location); throw new RedirectResult(location);
return;
} // end try } // end if
catch (DataException de) catch (DataException de)
{ // there was a database error { // there was a database error
page_title = "Database Error"; return new ErrorBox("Database Error","Database error setting hidden status: " + de.getMessage(),
content = new ErrorBox(page_title,"Database error setting hidden status: " + de.getMessage(),
location); location);
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // naughty naughty = you can't do this! { // naughty naughty = you can't do this!
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),location);
content = new ErrorBox(page_title,ae.getMessage(),location);
} // end catch } // end catch
} // end if ("hide" or "show") } // end if ("hide" or "show")
else if (cmd.equals("SCR"))
if (cmd.equals("SCR"))
{ // we want to scribble the message { // we want to scribble the message
try try
{ // attempt to scribble the message { // attempt to scribble the message
msg.scribble(); msg.scribble();
// go back and display stuff // go back and display stuff
rdat.redirectTo(location); throw new RedirectResult(location);
return;
} // end try } // end try
catch (DataException de) catch (DataException de)
{ // there was a database error { // there was a database error
page_title = "Database Error"; return new ErrorBox("Database Error","Database error scribbling message: " + de.getMessage(),
content = new ErrorBox(page_title,"Database error scribbling message: " + de.getMessage(),
location); location);
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // naughty naughty = you can't do this! { // naughty naughty = you can't do this!
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),location);
content = new ErrorBox(page_title,ae.getMessage(),location);
} // end catch } // end catch
} // end else if ("scribble") } // end if ("scribble")
else if (cmd.equals("NUKE"))
if (cmd.equals("NUKE"))
{ // nuking requires confirmation { // nuking requires confirmation
try try
{ // we need confirmation on this operation! { // we need confirmation on this operation
if (ConfirmBox.isConfirmed(request,NUKE_CONFIRM_ATTR,NUKE_CONFIRM_PARAM)) if (ConfirmBox.isConfirmed(request,NUKE_CONFIRM_ATTR,NUKE_CONFIRM_PARAM))
{ // OK, go ahead, nuke the message! { // OK, go ahead, nuke the message!
msg.nuke(); msg.nuke();
// after which, redirect to topic view // after which, redirect to topic view
rdat.redirectTo("confdisp?" + locator); throw new RedirectResult("confdisp?" + locator);
return;
} // end if } // end if (confirmed)
else else
{ // not a proper confirmation - better display one { // not a proper confirmation - better display one
List aliases = conf.getAliases(); List aliases = conf.getAliases();
String message = "You are about to nuke message <" + (String)(aliases.get(0)) + "." String message = "You are about to nuke message <" + (String)(aliases.get(0)) + "."
+ String.valueOf(topic.getTopicNumber()) + "." + String.valueOf(msg.getPostNumber()) + topic.getTopicNumber() + "." + msg.getPostNumber() + ">, originally composed by <"
+ ">, originally composed by <" + msg.getCreatorName() + msg.getCreatorName() + ">! Are you sure you want to do this?";
+ ">! Are you sure you want to do this?";
String confirm_url = "postops?" + locator + "&msg=" + msg.getPostNumber() + "&cmd=NUKE"; String confirm_url = "postops?" + locator + "&msg=" + msg.getPostNumber() + "&cmd=NUKE";
return new ConfirmBox(request,NUKE_CONFIRM_ATTR,NUKE_CONFIRM_PARAM,"Nuke Message",
page_title = "Nuke Message";
content = new ConfirmBox(request,NUKE_CONFIRM_ATTR,NUKE_CONFIRM_PARAM,page_title,
message,confirm_url,location); message,confirm_url,location);
} // end else } // end else (not yet confirmed)
} // end try } // end try
catch (DataException de) catch (DataException de)
{ // there was a database error { // there was a database error
page_title = "Database Error"; return new ErrorBox("Database Error","Database error nuking message: " + de.getMessage(),
content = new ErrorBox(page_title,"Database error nuking message: " + de.getMessage(),
location); location);
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // naughty naughty = you can't do this! { // naughty naughty = you can't do this!
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),location);
content = new ErrorBox(page_title,ae.getMessage(),location);
} // end catch } // end catch
} // end else if ("nuke") } // end if ("nuke")
else
{ // unrecognized command! // unrecognized command!
page_title = "Internal Error";
logger.error("invalid command to PostOperations.doGet: " + cmd); logger.error("invalid command to PostOperations.doGet: " + cmd);
content = new ErrorBox(page_title,"Invalid command to PostOperations.doGet",location); return new ErrorBox("Internal Error","Invalid command to PostOperations.doGet",location);
} // end else } // end doVeniceGet
} // end if (got parameters OK)
BaseJSPData basedat = new BaseJSPData(page_title,location,content);
basedat.transfer(getServletContext(),rdat);
} // end doGet
} // end class PostOperations } // end class PostOperations

View File

@ -40,31 +40,34 @@ public class PostShortcut extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{ {
UserContext user = getUserContext(request);
RenderData rdat = createRenderData(request,response);
String raw_link = request.getPathInfo().substring(1); String raw_link = request.getPathInfo().substring(1);
PostLinkDecoder decoder; PostLinkDecoder decoder;
try try
{ // attempt to decode the path link information { // attempt to decode the path link information
decoder = new PostLinkDecoder(raw_link); decoder = new PostLinkDecoder(raw_link);
if (decoder.getSIG()==null) // it must include the SIG
throw new ValidationException("ambiguous post link (no SIG)");
} // end try } // end try
catch (ValidationException e) catch (ValidationException e)
{ // display an error message for validation { // the post link decoder failed
String page_title = "Invalid Post Link"; return new ErrorBox("Invalid Post Link","Invalid post link \"" + raw_link + "\": " + e.getMessage(),
ContentRender content = new ErrorBox(page_title,"Invalid post link \"" + raw_link + "\": " null);
+ e.getMessage(),null);
new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
return;
} // end catch } // end catch
if (decoder.getSIG()==null) // it must include the SIG
return new ErrorBox("Invalid Post Link","Invalid post link \"" + raw_link
+ "\": ambiguous post link (no SIG)",null);
SIGContext sig; SIGContext sig;
try try
{ // get the SIG represented by that alias { // get the SIG represented by that alias
@ -73,20 +76,13 @@ public class PostShortcut extends VeniceServlet
} // end try } // end try
catch (DataException e) catch (DataException e)
{ // can't find the SIG - we're screwed { // can't find the SIG - we're screwed
String page_title = "Invalid Post Link"; return new ErrorBox("Invalid Post Link","Invalid post link \"" + raw_link + "\": cannot find SIG: "
ContentRender content = new ErrorBox(page_title,"Invalid post link \"" + raw_link + e.getMessage(),null);
+ "\": cannot find SIG: " + e.getMessage(),null);
new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
return;
} // end catch } // end catch
if (decoder.getConference()==null) if (decoder.getConference()==null) // it's a SIG link only - redirect to the SIG's default page
{ // it's a SIG link only - redirect to the SIG's default page throw new RedirectResult("sig/" + decoder.getSIG());
rdat.redirectTo("sig/" + decoder.getSIG());
return;
} // end if
ConferenceContext conf; ConferenceContext conf;
try try
@ -96,31 +92,21 @@ public class PostShortcut extends VeniceServlet
} // end try } // end try
catch (DataException e) catch (DataException e)
{ // can't find the conference - we're screwed { // can't find the conference - we're screwed
String page_title = "Invalid Post Link"; return new ErrorBox("Invalid Post Link","Invalid post link \"" + raw_link
ContentRender content = new ErrorBox(page_title,"Invalid post link \"" + raw_link
+ "\": cannot find conference: " + e.getMessage(),null); + "\": cannot find conference: " + e.getMessage(),null);
new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
return;
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // we can't get to the conference... { // we can't get to the conference...
String page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),null);
ContentRender content = new ErrorBox(page_title,ae.getMessage(),null);
new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
return;
} // end catch } // end catch
// compute an elementary "locator" // compute an elementary "locator"
String locator = "sig=" + String.valueOf(sig.getSIGID()) + "&conf=" + String.valueOf(conf.getConfID()); String locator = "sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
if (decoder.getTopic()==-1) if (decoder.getTopic()==-1) // just a conference link - go to the top-level display
{ // just a conference link - go to the top-level display throw new RedirectResult("confdisp?" + locator);
rdat.redirectTo("confdisp?" + locator);
return;
} // end if
TopicContext topic; TopicContext topic;
try try
@ -130,32 +116,26 @@ public class PostShortcut extends VeniceServlet
} // end try } // end try
catch (DataException e) catch (DataException e)
{ // we can't find the topic - we're screwed { // we can't find the topic - we're screwed
String page_title = "Invalid Post Link"; return new ErrorBox("Invalid Post Link","Invalid post link \"" + raw_link + "\": cannot find topic: "
ContentRender content = new ErrorBox(page_title,"Invalid post link \"" + raw_link + e.getMessage(),null);
+ "\": cannot find topic: " + e.getMessage(),null);
new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
return;
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // we can't get to the topic... { // we can't get to the topic...
String page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),null);
ContentRender content = new ErrorBox(page_title,ae.getMessage(),null);
new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
return;
} // end catch } // end catch
// add the topic to our locator // add the topic to our locator
locator += "&top=" + String.valueOf(decoder.getTopic()); locator += "&top=" + decoder.getTopic();
if (decoder.getFirstPost()==-1) // we're just referencing the topic if (decoder.getFirstPost()==-1) // we're just referencing the topic
rdat.redirectTo("confdisp?" + locator + "&rnm=1"); throw new RedirectResult("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 // we're referencing a post range within the topic
throw new RedirectResult("confdisp?" + locator + "&p1=" + decoder.getFirstPost() + "&p2="
+ decoder.getLastPost());
} // end doVeniceGet
} // end class PostShortcut } // end class PostShortcut

View File

@ -0,0 +1,55 @@
/*
* 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.IOException;
import com.silverwrist.venice.servlets.format.RenderData;
public class RedirectResult extends ExecuteResult
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String target;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public RedirectResult(String target)
{
super();
this.target = target;
} // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class ExecuteResult
*--------------------------------------------------------------------------------
*/
public void execute(RenderData rdat) throws IOException
{
rdat.redirectTo(target);
} // end doRedirect
} // end class RedirectResult

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -87,140 +87,108 @@ public class SIGAdmin extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{ {
UserContext user = getUserContext(request); // get the SIG context
RenderData rdat = createRenderData(request,response); SIGContext sig = getSIGParameter(request,user,true,"top");
String page_title = null;
Object content = null;
SIGContext sig = null;
try
{ // first get the SIG context we're working with
int sigid = Integer.parseInt(request.getParameter("sig"));
sig = user.getSIGContext(sigid);
changeMenuSIG(request,sig); changeMenuSIG(request,sig);
setMyLocation(request,"sigadmin?" + request.getQueryString());
String on_error = "sigadmin?sig=" + sig.getSIGID();
} // end try if (logger.isDebugEnabled())
catch (NumberFormatException nfe) logger.debug("SIGAdmin/doGet operating on SIG \"" + sig.getName() + "\" (" + sig.getSIGID() + ")");
{ // an improperly formatted SIGID brought us down!
page_title = "Input Error";
logger.error("Somebody fed 'sig=" + request.getParameter("sig") + "' to this page, that's bogus");
content = new ErrorBox(page_title,"SIG ID not valid: " + request.getParameter("sig"),"top");
} // end catch
catch (DataException de)
{ // unable to pull SIG data out of the database
page_title = "Database Error";
logger.error("database error looking up SIGID " + request.getParameter("sig"));
content = new ErrorBox(page_title,"Database error accessing SIG: " + de.getMessage(),"top");
} // end catch
if (logger.isDebugEnabled() && (sig!=null))
logger.debug("SIGAdmin/doGet operating on SIG \"" + sig.getName() + "\" ("
+ String.valueOf(sig.getSIGID()) + ")");
if (content==null)
{ // now decide what to do based on the "cmd" parameter
String cmd = request.getParameter("cmd");
if (cmd==null)
cmd = "???"; // something pretty much guaranteed not to be used
// now decide what to do based on the "cmd" parameter
String cmd = getStandardCommandParam(request);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SIGAdmin/doGet command value = " + cmd); logger.debug("SIGAdmin/doGet command value = " + cmd);
if (cmd.equals("P")) if (cmd.equals("P"))
{ // this is the profile editing screen { // "P" = "Edit Profile"
if (sig.canModifyProfile()) if (!(sig.canModifyProfile()))
{ // construct the edit profile dialog and load it up for use { // no access - sorry, dude
logger.error("tried to call up SIG profile screen without access...naughty naughty!");
return new ErrorBox("Unauthorized","You do not have access to modify this SIG's profile.",on_error);
} // end if
// construct the edit profile dialog and load it up for use
EditSIGProfileDialog dlg = makeEditSIGProfileDialog(); EditSIGProfileDialog dlg = makeEditSIGProfileDialog();
try try
{ // load the values for this dialog { // load the values for this dialog
dlg.setupDialog(getVeniceEngine(),sig); dlg.setupDialog(engine,sig);
// prepare for display
page_title = dlg.getTitle();
content = dlg;
} // end try } // end try
catch (DataException de) catch (DataException de)
{ // we could not load the values because of a data exception { // we could not load the values because of a data exception
page_title = "Database Error";
logger.error("DB error loading SIG profile: " + de.getMessage(),de); logger.error("DB error loading SIG profile: " + de.getMessage(),de);
content = new ErrorBox(page_title,"Database error retrieving profile: " + de.getMessage(), return new ErrorBox("Database Error","Database error retrieving profile: " + de.getMessage(),on_error);
"sigadmin?sig=" + String.valueOf(sig.getSIGID()));
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // we don't have enough privilege { // we don't have enough privilege
page_title = "Unauthorized";
logger.error("Access error loading SIG profile: " + ae.getMessage(),ae); logger.error("Access error loading SIG profile: " + ae.getMessage(),ae);
content = new ErrorBox(page_title,"You do not have access to modify this SIG's profile.", return new ErrorBox("Unauthorized","You do not have access to modify this SIG's profile.",on_error);
"sigadmin?sig=" + String.valueOf(sig.getSIGID()));
} // end catch } // end catch
} // end if return dlg; // display me!
else
{ // no access - sorry, dude } // end if ("P" command)
page_title = "Unauthorized";
logger.error("tried to call up SIG profile screen without access...naughty naughty!"); if (cmd.equals("T"))
content = new ErrorBox(page_title,"You do not have access to modify this SIG's profile.", { // "T" = "Set Category"
"sigadmin?sig=" + String.valueOf(sig.getSIGID())); if (!(sig.canModifyProfile()))
{ // no access - sorry man
logger.error("tried to call up SIG category set screen without access...naughty naughty!");
return new ErrorBox("Unauthorized","You do not have access to modify this SIG's profile.",on_error);
} // end else } // end else
} // end if (profile editing) // did they actually send a "set" parameter?
else if (cmd.equals("T"))
{ // this is the category set code!
if (sig.canModifyProfile())
{ // did they actually send a "set" parameter?
String p = request.getParameter("set"); String p = request.getParameter("set");
if (!(StringUtil.isStringEmpty(p))) if (!(StringUtil.isStringEmpty(p)))
{ // OK, we're setting the category ID... { // OK, we're setting the category ID...
try try
{ // get the new category ID and set it { // get the new category ID and set it
int catid = Integer.parseInt(p); int catid = Integer.parseInt(p);
if (!(getVeniceEngine().isValidCategoryID(catid))) if (!(engine.isValidCategoryID(catid)))
throw new NumberFormatException(); // dump the category if it's not valid throw new NumberFormatException(); // dump the category if it's not valid
// change the category ID
sig.setCategoryID(catid); sig.setCategoryID(catid);
// now that the category ID is set, go back to the admin menu
String target = "sigadmin?sig=" + String.valueOf(sig.getSIGID());
String url = response.encodeRedirectURL(rdat.getFullServletPath(target));
response.sendRedirect(url);
return;
} // end try } // end try
catch (NumberFormatException nfe) catch (NumberFormatException nfe)
{ // we got an invalid category value... { // we got an invalid category value...
page_title = "Invalid Input"; return new ErrorBox("Invalid Input","Invalid category ID passed to category browser.",on_error);
content = new ErrorBox(page_title,"Invalid category ID passed to category browser.",
"sigadmin?sig=" + String.valueOf(sig.getSIGID()));
} // end catch } // end catch
catch (DataException de) catch (DataException de)
{ // unable to update the SIG properly { // unable to update the SIG properly
page_title = "Database Error";
logger.error("DB error updating SIG: " + de.getMessage(),de); logger.error("DB error updating SIG: " + de.getMessage(),de);
content = new ErrorBox(page_title,"Database error updating SIG: " + de.getMessage(), return new ErrorBox("Database Error","Database error updating SIG: " + de.getMessage(),on_error);
"sigadmin?sig=" + String.valueOf(sig.getSIGID()));
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // database access error - display an error box { // database access error - display an error box
page_title = "Access Error";
logger.error("Access error updating SIG: " + ae.getMessage(),ae); logger.error("Access error updating SIG: " + ae.getMessage(),ae);
content = new ErrorBox(page_title,ae.getMessage(), return new ErrorBox("Access Error",ae.getMessage(),on_error);
"sigadmin?sig=" + String.valueOf(sig.getSIGID()));
} // end catch } // end catch
} // end if (actually setting the category // now that it's set, go back to the admin menu
throw new RedirectResult(on_error);
} // end if (setting category ID)
else else
{ // we're browsing - try and figure out what to display { // we're browsing - try and figure out what to display
try try
@ -232,131 +200,78 @@ public class SIGAdmin extends VeniceServlet
else else
curr_catid = Integer.parseInt(p); curr_catid = Integer.parseInt(p);
if (!(getVeniceEngine().isValidCategoryID(curr_catid))) if (!(engine.isValidCategoryID(curr_catid)))
throw new NumberFormatException(); // dump the category if it's not valid throw new NumberFormatException(); // dump the category if it's not valid
// create the browser panel and let it rip // create the browser panel and let it rip
content = new SIGCategoryBrowseData(user,sig,curr_catid); return new SIGCategoryBrowseData(user,sig,curr_catid);
page_title = "Set SIG Category";
} // end try } // end try
catch (NumberFormatException nfe) catch (NumberFormatException nfe)
{ // we got an invalid category value... { // we got an invalid category value...
page_title = "Invalid Input"; return new ErrorBox("Invalid Input","Invalid category ID passed to category browser.",on_error);
content = new ErrorBox(page_title,"Invalid category ID passed to category browser.",
"sigadmin?sig=" + String.valueOf(sig.getSIGID()));
} // end catch } // end catch
catch (DataException de) catch (DataException de)
{ // unable to get the categories properly { // unable to get the categories properly
page_title = "Database Error";
logger.error("DB error browsing categories: " + de.getMessage(),de); logger.error("DB error browsing categories: " + de.getMessage(),de);
content = new ErrorBox(page_title,"Database error browsing categories: " + de.getMessage(), return new ErrorBox("Database Error","Database error browsing categories: " + de.getMessage(),
"sigadmin?sig=" + String.valueOf(sig.getSIGID())); on_error);
} // end catch } // end catch
} // end else (browsing through categories)
} // end if
else
{ // no access - sorry man
page_title = "Unauthorized";
logger.error("tried to call up SIG category set screen without access...naughty naughty!");
content = new ErrorBox(page_title,"You do not have access to modify this SIG's profile.",
"sigadmin?sig=" + String.valueOf(sig.getSIGID()));
} // end else } // end else
} // end else if (category selector) } // end if ("T" command)
else // other request
{ // all unknown requests get turned into menu display requests // all unknown requests get turned into menu display requests
if (sig.canAdministerSIG()) if (!(sig.canAdministerSIG()))
{ // create a SIG administration menu { // no access - sorry buddy
logger.error("tried to call up SIG admin menu without access...naughty naughty!");
return new ErrorBox("Access Error","You do not have access to administer this SIG.",on_error);
} // end if
// create a SIG administration menu
SIGAdminTop menu = makeSIGAdminTop(); SIGAdminTop menu = makeSIGAdminTop();
menu.setSIG(sig); menu.setSIG(sig);
content = menu; return menu;
page_title = "SIG Administration";
} // end if } // end doVeniceGet
else
{ // no access - sorry buddy
page_title = "Access Error";
logger.error("tried to call up SIG admin menu without access...naughty naughty!");
content = new ErrorBox(page_title,"You do not have access to administer this SIG.",
"sigprofile?sig=" + String.valueOf(sig.getSIGID()));
} // end else protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
} // end else (other request i.e. menu request) throws ServletException, IOException, VeniceServletResult
} // end if
// else getting the SIG already caused problems
BaseJSPData basedat = new BaseJSPData(page_title,"sigadmin?" + request.getQueryString(),content);
basedat.transfer(getServletContext(),rdat);
} // end doGet
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{ {
UserContext user = getUserContext(request); // get the SIG context
RenderData rdat = createRenderData(request,response); SIGContext sig = getSIGParameter(request,user,true,"top");
String page_title = null;
ContentRender content = null;
SIGContext sig = null;
try
{ // first get the SIG context we're working with
int sigid = Integer.parseInt(request.getParameter("sig"));
sig = user.getSIGContext(sigid);
changeMenuSIG(request,sig); changeMenuSIG(request,sig);
String on_error = "sigadmin?sig=" + sig.getSIGID();
setMyLocation(request,on_error);
} // end try if (logger.isDebugEnabled())
catch (NumberFormatException nfe) logger.debug("SIGAdmin/doPost operating on SIG \"" + sig.getName() + "\" (" + sig.getSIGID() + ")");
{ // an improperly formatted SIGID brought us down!
page_title = "Input Error";
logger.error("Somebody fed 'sig=" + request.getParameter("sig") + "' to this page, that's bogus");
content = new ErrorBox(page_title,"SIG ID not valid: " + request.getParameter("sig"),"top");
} // end catch
catch (DataException de)
{ // unable to pull SIG data out of the database
page_title = "Database Error";
logger.error("database error looking up SIGID " + request.getParameter("sig"));
content = new ErrorBox(page_title,"Database error accessing SIG: " + de.getMessage(),"top");
} // end catch
if (logger.isDebugEnabled() && (sig!=null))
logger.debug("SIGAdmin/doPost operating on SIG \"" + sig.getName() + "\" ("
+ String.valueOf(sig.getSIGID()) + ")");
if (content==null)
{ // now decide what to do based on the "cmd" parameter
String cmd = request.getParameter("cmd");
if (cmd==null)
cmd = "???"; // something pretty much guaranteed not to be used
// now decide what to do based on the "cmd" parameter
String cmd = getStandardCommandParam(request);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("SIGAdmin/doPost command value = " + cmd); logger.debug("SIGAdmin/doPost command value = " + cmd);
if (cmd.equals("P")) if (cmd.equals("P"))
{ // we just finished editing the profile... { // "P" = "Edit Profile"
if (sig.canModifyProfile()) if (!(sig.canModifyProfile()))
{ // construct the edit profile dialog and load it up for use { // no access - sorry, dude
logger.error("tried to call up SIG profile screen without access...naughty naughty!");
return new ErrorBox("Unauthorized","You do not have access to modify this SIG's profile.",on_error);
} // end if
// construct the edit profile dialog and load it up for use
EditSIGProfileDialog dlg = makeEditSIGProfileDialog(); EditSIGProfileDialog dlg = makeEditSIGProfileDialog();
dlg.setupDialogBasic(getVeniceEngine(),sig); dlg.setupDialogBasic(engine,sig);
if (dlg.isButtonClicked(request,"cancel")) if (dlg.isButtonClicked(request,"cancel"))
{ // go back to our desired location throw new RedirectResult(on_error); // go back - they canceled out
String target = "sigadmin?sig=" + String.valueOf(sig.getSIGID());
String url = response.encodeRedirectURL(rdat.getFullServletPath(target));
response.sendRedirect(url);
return;
} // end if ("cancel" button clicked)
if (dlg.isButtonClicked(request,"update")) if (dlg.isButtonClicked(request,"update"))
{ // begin updating the SIG's contents { // begin updating the SIG's contents
@ -366,12 +281,9 @@ public class SIGAdmin extends VeniceServlet
{ // attempt to change the SIG profile now... { // attempt to change the SIG profile now...
dlg.doDialog(sig); dlg.doDialog(sig);
// go back to the Admin menu on success // now jump back to the main menu
clearMenu(request); // menu title may have been invalidated clearMenu(request);
String target = "sigadmin?sig=" + String.valueOf(sig.getSIGID()); throw new RedirectResult(on_error);
String url = response.encodeRedirectURL(rdat.getFullServletPath(target));
response.sendRedirect(url);
return;
} // end try } // end try
catch (ValidationException ve) catch (ValidationException ve)
@ -379,63 +291,34 @@ public class SIGAdmin extends VeniceServlet
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("validation failure: " + ve.getMessage()); logger.debug("validation failure: " + ve.getMessage());
dlg.resetOnError(sig,ve.getMessage() + " Please try again."); dlg.resetOnError(sig,ve.getMessage() + " Please try again.");
page_title = dlg.getTitle();
content = dlg;
} // end catch } // end catch
catch (DataException de) catch (DataException de)
{ // database error updating the SIG values { // database error updating the SIG values
page_title = "Database Error";
logger.error("DB error updating SIG: " + de.getMessage(),de); logger.error("DB error updating SIG: " + de.getMessage(),de);
content = new ErrorBox(page_title,"Database error updating SIG: " + de.getMessage(), return new ErrorBox("Database Error","Database error updating SIG: " + de.getMessage(),on_error);
"sigadmin?sig=" + String.valueOf(sig.getSIGID()));
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // access error changing the SIG values { // access error changing the SIG values
page_title = "Access Error";
logger.error("Access error updating SIG: " + ae.getMessage(),ae); logger.error("Access error updating SIG: " + ae.getMessage(),ae);
content = new ErrorBox(page_title,ae.getMessage(), return new ErrorBox("Access Error",ae.getMessage(),on_error);
"sigadmin?sig=" + String.valueOf(sig.getSIGID()));
} // end catch } // end catch
} // end if ("update" button pressed); return dlg;
else
{ // what the hell was that button? } // end if ("update" pressed)
page_title = "Internal Error";
// what the hell was that button?
logger.error("no known button click on SIGAdmin.doPost, cmd=P"); logger.error("no known button click on SIGAdmin.doPost, cmd=P");
content = new ErrorBox(page_title,"Unknown command button pressed", return new ErrorBox("Internal Error","Unknown command button pressed",on_error);
"sigadmin?sig=" + String.valueOf(sig.getSIGID()));
} // end else } // end if ("P" command)
} // end if // on unknown command, redirect to the GET function
else return doVeniceGet(request,engine,user,rdat);
{ // no access - sorry, dude
page_title = "Unauthorized";
logger.error("tried to edit SIG profile without access...naughty naughty!");
content = new ErrorBox(page_title,"You do not have access to modify this SIG's profile.",
"sigadmin?sig=" + String.valueOf(sig.getSIGID()));
} // end else } // end doVenicePost
} // end if (editing profile)
else // unknown command
{ // just use that to redirect to the GET url
String target = "sigadmin?sig=" + String.valueOf(sig.getSIGID()) + "&cmd=" + cmd;
String url = response.encodeRedirectURL(rdat.getFullServletPath(target));
response.sendRedirect(url);
return;
} // end else (unknown command)
} // end if
// else getting the SIG already caused problems
BaseJSPData basedat = new BaseJSPData(page_title,"sigadmin?sig=" + String.valueOf(sig.getSIGID()),content);
basedat.transfer(getServletContext(),rdat);
} // end doPost
} // end class SIGAdmin } // end class SIGAdmin

View File

@ -38,45 +38,42 @@ public class SIGFrontEnd extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
{ *--------------------------------------------------------------------------------
UserContext user = getUserContext(request); */
RenderData rdat = createRenderData(request,response);
String page_title = null;
ContentRender content = null;
try protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
{ // get the SIG alias name from the request path info UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// get the SIG alias name from the request path info
String sigalias = request.getPathInfo().substring(1); String sigalias = request.getPathInfo().substring(1);
// get the SIG's context from the alias name try
{ // get the SIG's context from the alias name
SIGContext sig = user.getSIGContext(sigalias); SIGContext sig = user.getSIGContext(sigalias);
// get the default servlet from the SIG context // get the default servlet from the SIG context
String def_applet = sig.getDefaultApplet(); String def_servlet = sig.getDefaultApplet();
if (def_applet==null) if (def_servlet==null)
throw new DataException("unable to get SIG default servlet"); { // return the default servlet
changeMenuTop(request);
return new ErrorBox("Internal Error","unable to get SIG default servlet","top");
// redirect to the appropriate top-level page! } // end if
String url = response.encodeRedirectURL(rdat.getFullServletPath(def_applet));
response.sendRedirect(url); // and go there
return; throw new RedirectResult(def_servlet);
} // end try } // end try
catch (DataException de) catch (DataException de)
{ // set up to display an ErrorBox { // set up to display an ErrorBox
page_title = "Database Error"; changeMenuTop(request);
content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),"top"); return new ErrorBox("Database Error","Database error finding SIG: " + de.getMessage(),"top");
} // end catch } // end catch
changeMenuTop(request); } // end doVeniceGet
// this code is only used if we have to display an ErrorBox
BaseJSPData basedat = new BaseJSPData(page_title,"sig" + request.getPathInfo(),content);
basedat.transfer(getServletContext(),rdat);
} // end doGet
} // end class SIGFrontEnd } // end class SIGFrontEnd

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -42,32 +42,6 @@ public class SIGOperations extends VeniceServlet
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
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 JoinKeyDialog makeJoinKeyDialog() private JoinKeyDialog makeJoinKeyDialog()
{ {
final String desired_name = "JoinKeyDialog"; final String desired_name = "JoinKeyDialog";
@ -115,200 +89,142 @@ public class SIGOperations extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
{ *--------------------------------------------------------------------------------
UserContext user = getUserContext(request); */
RenderData rdat = createRenderData(request,response);
String page_title = null;
Object content = null;
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// get the command we want to use // get the command we want to use
String cmd = request.getParameter("cmd"); String cmd = getStandardCommandParam(request);
if (cmd==null) setMyLocation(request,"sigops?" + request.getQueryString());
cmd = "???";
if (cmd.equals("J")) if (cmd.equals("J"))
{ // "J" = "Join" (requires SIG parameter) { // "J" = "Join" (requires SIG parameter)
try SIGContext sig = getSIGParameter(request,user,true,"top");
{ // get the SIG parameter first!
SIGContext sig = getSIGParameter(request,user); if (!(sig.canJoin())) // not permitted to join!
return new ErrorBox("SIG Error","You are not permitted to join this SIG.","top");
if (sig.canJoin())
{ // OK, we can join the SIG, now, is it public or private?
if (sig.isPublicSIG()) if (sig.isPublicSIG())
{ // attempt to join right now! (no join key required) { // attempt to join right now! (no join key required)
try
{ // call down to join the SIG
sig.join(null); sig.join(null);
// success! display the "welcome" page // success! display the "welcome" page
content = new SIGWelcome(sig);
page_title = "Welcome to " + sig.getName();
clearMenu(request); // force the clear to regen the menus clearMenu(request); // force the clear to regen the menus
changeMenuSIG(request,sig); changeMenuSIG(request,sig);
return new SIGWelcome(sig);
} // end try
catch (AccessError ae)
{ // access error
return new ErrorBox("Access Error","Unable to join SIG: " + ae.getMessage(),"top");
} // end catch
catch (DataException de)
{ // data exception doing something
return new ErrorBox("Database Error","Database error joining SIG: " + de.getMessage(),"top");
} // end catch
} // end if (public SIG) } // end if (public SIG)
else else
{ // we need to prompt them for the join key... { // we need to prompt them for the join key....
JoinKeyDialog dlg = makeJoinKeyDialog(); JoinKeyDialog dlg = makeJoinKeyDialog();
dlg.setupDialog(sig); dlg.setupDialog(sig);
content = dlg;
page_title = "Join SIG";
changeMenuSIG(request,sig); changeMenuSIG(request,sig);
return dlg;
} // end else (private SIG) } // end else (private SIG)
} // end if (allowed to join the SIG)
else
{ // throw an error
page_title = "Error";
content = new ErrorBox("SIG Error","You are not permitted to join this SIG.","top");
} // end else
} // end try
catch (AccessError ae)
{ // access error
page_title = "Access Error";
content = new ErrorBox(page_title,"Unable to join SIG: " + ae.getMessage(),"top");
} // end catch
catch (DataException de)
{ // data exception doing something
page_title = "Database Error";
content = new ErrorBox(page_title,"Database error joining SIG: " + de.getMessage(),"top");
} // end catch
catch (ValidationException ve)
{ // validation error - wrong parameters, likely
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),"top");
} // end catch
} // end if ("J" command) } // end if ("J" command)
else if (cmd.equals("U"))
{ // "U" = "Unjoin (requires SIG parameter)
try
{ // get the SIG parameter first!
SIGContext sig = getSIGParameter(request,user);
if (sig.canUnjoin()) if (cmd.equals("U"))
{ // OK, let's test for a confirmation... { // "U" = "Unjoin (requires SIG parameter)
SIGContext sig = getSIGParameter(request,user,true,"top");
if (!(sig.canUnjoin()))
return new ErrorBox("SIG Error","You cannot unjoin this SIG.","top");
// OK, let's test for a confirmation...
if (ConfirmBox.isConfirmed(request,UNJOIN_CONFIRM_ATTR,UNJOIN_CONFIRM_PARAM)) if (ConfirmBox.isConfirmed(request,UNJOIN_CONFIRM_ATTR,UNJOIN_CONFIRM_PARAM))
{ // OK, if you say so, let's unjoin! { // OK, if you say so, let's unjoin!
try
{ // do the unjoin now...
sig.unjoin(); sig.unjoin();
// after which, let's just go back to top
clearMenu(request); // force the clear to regen the menus
rdat.redirectTo("top");
return;
} // end if
else
{ // not a proper confirmation - better display one
String message = "Are you sure you want to unjoin the '" + sig.getName() + "' SIG?";
String confirm_url = "sigops?cmd=U&sig=" + String.valueOf(sig.getSIGID());
String deny_url = "sig/" + sig.getAlias();
page_title = "Unjoining SIG";
content = new ConfirmBox(request,UNJOIN_CONFIRM_ATTR,UNJOIN_CONFIRM_PARAM,page_title,
message,confirm_url,deny_url);
} // end else
} // end if
else
{ // throw an error
page_title = "Error";
content = new ErrorBox("SIG Error","You cannot unjoin this SIG.","top");
} // end else
} // end try } // end try
catch (AccessError ae) catch (AccessError ae)
{ // access error { // access error
page_title = "Access Error"; return new ErrorBox("Access Error","Unable to unjoin SIG: " + ae.getMessage(),"top");
content = new ErrorBox(page_title,"Unable to unjoin SIG: " + ae.getMessage(),"top");
} // end catch } // end catch
catch (DataException de) catch (DataException de)
{ // data exception doing something { // data exception doing something
page_title = "Database Error"; return new ErrorBox("Database Error","Database error unjoining SIG: " + de.getMessage(),"top");
content = new ErrorBox(page_title,"Database error unjoining SIG: " + de.getMessage(),"top");
} // end catch
catch (ValidationException ve)
{ // validation error - wrong parameters, likely
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),"top");
} // end catch } // end catch
} // end else if ("U" command) // after which, redirect back to the top
else if (cmd.equals("C")) clearMenu(request);
{ // "C" - Create SIG (no parameters) throw new RedirectResult("top");
if (user.canCreateSIG())
{ // present the "Create New SIG" dialog
CreateSIGDialog dlg = makeCreateSIGDialog();
dlg.setupDialog(getVeniceEngine());
// prepare for display
page_title = dlg.getTitle();
content = dlg;
changeMenuTop(request);
} // end if } // end if
else else
{ // the user isn't permitted to make new SIGs... { // not a proper confirmation - display the confirm box
page_title = "Error"; String message = "Are you sure you want to unjoin the '" + sig.getName() + "' SIG?";
content = new ErrorBox("SIG Error","You are not permitted to create SIGs.","top"); return new ConfirmBox(request,UNJOIN_CONFIRM_ATTR,UNJOIN_CONFIRM_PARAM,"Unjoining SIG",
message,"sigops?cmd=U&sig=" + sig.getSIGID(),"sig/" + sig.getAlias());
} // end else } // end else
} // end else if ("C" command) } // end if ("U" command)
else
{ // this is an error! if (cmd.equals("C"))
page_title = "Internal Error"; { // "C" - Create SIG (no parameters)
if (!(user.canCreateSIG()))
return new ErrorBox("SIG Error","You are not permitted to create SIGs.","top");
// present the "Create New SIG" dialog
CreateSIGDialog dlg = makeCreateSIGDialog();
dlg.setupDialog(engine);
changeMenuTop(request);
return dlg;
} // end if ("C" command)
// this is an error!
logger.error("invalid command to SIGOperations.doGet: " + cmd); logger.error("invalid command to SIGOperations.doGet: " + cmd);
content = new ErrorBox(page_title,"Invalid command to SIGOperations.doGet","top"); return new ErrorBox("Internal Error","Invalid command to SIGOperations.doGet","top");
} // end else } // end doVeniceGet
BaseJSPData basedat = new BaseJSPData(page_title,"sigops?" + request.getQueryString(),content); protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
basedat.transfer(getServletContext(),rdat); UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
} // end doGet
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{ {
UserContext user = getUserContext(request);
RenderData rdat = createRenderData(request,response);
String page_title = null;
Object content = null;
// get the command we want to use // get the command we want to use
String cmd = request.getParameter("cmd"); String cmd = getStandardCommandParam(request);
if (cmd==null) setMyLocation(request,"sigops?cmd=" + cmd);
cmd = "???";
if (cmd.equals("J")) if (cmd.equals("J"))
{ // "J" = Join SIG (requires SIG parameter) { // "J" = Join SIG (requires SIG parameter)
try SIGContext sig = getSIGParameter(request,user,true,"top");
{ // get the SIG we're talking about
SIGContext sig = getSIGParameter(request,user);
JoinKeyDialog dlg = makeJoinKeyDialog(); JoinKeyDialog dlg = makeJoinKeyDialog();
if (dlg.isButtonClicked(request,"cancel")) if (dlg.isButtonClicked(request,"cancel")) // cancel - go back to SIG opening page
{ // canceled join - return to SIG opening page throw new RedirectResult("sig/" + sig.getAlias());
rdat.redirectTo("sig/" + sig.getAlias());
return;
} // end if if (!(sig.canJoin())) // not permitted to join!
return new ErrorBox("SIG Error","You are not permitted to join this SIG.","top");
if (dlg.isButtonClicked(request,"join")) if (dlg.isButtonClicked(request,"join"))
{ // they clicked the "join" button { // OK, go join the SIG
if (sig.canJoin())
{ // we are permitted to join this SIG...
dlg.loadValues(request); // load the dialog dlg.loadValues(request); // load the dialog
try try
@ -316,74 +232,50 @@ public class SIGOperations extends VeniceServlet
dlg.doDialog(sig); dlg.doDialog(sig);
// success! display the "welcome" page // success! display the "welcome" page
content = new SIGWelcome(sig);
page_title = "Welcome to " + sig.getName();
clearMenu(request); // force the clear to regen the menus clearMenu(request); // force the clear to regen the menus
changeMenuSIG(request,sig); changeMenuSIG(request,sig);
return new SIGWelcome(sig);
} // end try } // end try
catch (ValidationException ve2) catch (ValidationException ve)
{ // here, a validation exception causes us to recycle and retry { // here, a validation exception causes us to recycle and retry
dlg.resetOnError(ve2.getMessage() + " Please try again."); dlg.resetOnError(ve.getMessage() + " Please try again.");
content = dlg;
page_title = "Join SIG";
changeMenuSIG(request,sig); changeMenuSIG(request,sig);
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // this is probably a bogus key - let them retry { // this is probably a bogus key - let them retry
dlg.resetOnError(ae.getMessage() + " Please try again."); dlg.resetOnError(ae.getMessage() + " Please try again.");
content = dlg;
page_title = "Join SIG";
changeMenuSIG(request,sig); changeMenuSIG(request,sig);
} // end catch } // end catch
} // end if
else
{ // throw an error
page_title = "Error";
content = new ErrorBox("SIG Error","You are not permitted to join this SIG.","top");
} // end else
} // end if ("join" button clicked)
else
{ // error - don't know what button was clicked
page_title = "Internal Error";
logger.error("no known button click on SIGOperations.doPost, cmd=J");
content = new ErrorBox(page_title,"Unknown command button pressed","top");
} // end else
} // end try
catch (DataException de) catch (DataException de)
{ // database error joining something { // database error joining something
page_title = "Database Error"; return new ErrorBox("Database Error","Database error joining SIG: " + de.getMessage(),"top");
content = new ErrorBox(page_title,"Database error joining SIG: " + de.getMessage(),"top");
} // end catch } // end catch
catch (ValidationException ve)
{ // validation error - bogus parameter, I think
page_title = "Error";
content = new ErrorBox(null,ve.getMessage(),"top");
} // end catch return dlg; // recycle and try aagin
} // end if ("join" clicked)
// error - don't know what button was clicked
logger.error("no known button click on SIGOperations.doPost, cmd=J");
return new ErrorBox("Internal Error","Unknown command button pressed","top");
} // end if ("J" command) } // end if ("J" command)
else if (cmd.equals("C"))
if (cmd.equals("C"))
{ // "C" = Create New SIG { // "C" = Create New SIG
if (user.canCreateSIG()) if (!(user.canCreateSIG()))
{ // load the "Create SIG" dialog return new ErrorBox("SIG Error","You are not permitted to create SIGs.","top");
// load the "Create SIG" dialog
CreateSIGDialog dlg = makeCreateSIGDialog(); CreateSIGDialog dlg = makeCreateSIGDialog();
dlg.setupDialog(getVeniceEngine()); dlg.setupDialog(engine);
if (dlg.isButtonClicked(request,"cancel")) if (dlg.isButtonClicked(request,"cancel")) // cancel - go back to top
{ // canceled create - return to top page throw new RedirectResult("top");
rdat.redirectTo("top");
return;
} // end if
if (dlg.isButtonClicked(request,"create")) if (dlg.isButtonClicked(request,"create"))
{ // OK, they actually want to create the new SIG... { // OK, they actually want to create the new SIG...
@ -394,63 +286,42 @@ public class SIGOperations extends VeniceServlet
SIGContext sig = dlg.doDialog(user); SIGContext sig = dlg.doDialog(user);
// created successfully - display a "new SIG welcome" page // created successfully - display a "new SIG welcome" page
content = new NewSIGWelcome(sig);
page_title = "SIG Created";
changeMenuSIG(request,sig); // display menus for the first time! changeMenuSIG(request,sig); // display menus for the first time!
return new NewSIGWelcome(sig);
} // end try } // end try
catch (ValidationException ve2) catch (ValidationException ve)
{ // here, a validation exception causes us to recycle and retry { // here, a validation exception causes us to recycle and retry
dlg.resetOnError(ve2.getMessage() + " Please try again."); dlg.resetOnError(ve.getMessage() + " Please try again.");
content = dlg;
page_title = dlg.getTitle();
changeMenuTop(request); changeMenuTop(request);
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // this is probably a bogus key - let them retry { // this is probably a bogus key - let them retry
dlg.resetOnError(ae.getMessage() + " Please try again."); dlg.resetOnError(ae.getMessage() + " Please try again.");
content = dlg;
page_title = dlg.getTitle();
changeMenuTop(request); changeMenuTop(request);
} // end catch } // end catch
catch (DataException de) catch (DataException de)
{ // database error doing something { // database error doing something
page_title = "Database Error"; return new ErrorBox("Database Error","Database error creating SIG: " + de.getMessage(),"top");
content = new ErrorBox(page_title,"Database error creating SIG: " + de.getMessage(),"top");
} // end catch } // end catch
} // end if return dlg; // put the dialog back up
else
{ // error - don't know what button was clicked } // end if ("create" pressed)
page_title = "Internal Error";
// error - don't know what button was clicked
logger.error("no known button click on SIGOperations.doPost, cmd=C"); logger.error("no known button click on SIGOperations.doPost, cmd=C");
content = new ErrorBox(page_title,"Unknown command button pressed","top"); return new ErrorBox("Internal Error","Unknown command button pressed","top");
} // end else } // end if ("C" command)
} // end if // this is an error!
else
{ // the user isn't permitted to make new SIGs...
page_title = "Error";
content = new ErrorBox("SIG Error","You are not permitted to create SIGs.","top");
} // end else
} // end else if ("C" command)
else
{ // this is an error!
page_title = "Internal Error";
logger.error("invalid command to SIGOperations.doPost: " + cmd); logger.error("invalid command to SIGOperations.doPost: " + cmd);
content = new ErrorBox(page_title,"Invalid command to SIGOperations.doPost","top"); return new ErrorBox("Internal Error","Invalid command to SIGOperations.doPost","top");
} // end else } // end doVenicePost
BaseJSPData basedat = new BaseJSPData(page_title,"top",content);
basedat.transfer(getServletContext(),rdat);
} // end doPost
} // end class SIGOperations } // end class SIGOperations

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -25,6 +25,11 @@ import com.silverwrist.venice.servlets.format.*;
public class SIGProfile extends VeniceServlet public class SIGProfile extends VeniceServlet
{ {
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo() public String getServletInfo()
{ {
String rc = "SIGProfile servlet - Displays the profile of a SIG\n" String rc = "SIGProfile servlet - Displays the profile of a SIG\n"
@ -33,43 +38,31 @@ public class SIGProfile extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{ {
UserContext user = getUserContext(request); // get the SIG
RenderData rdat = createRenderData(request,response); SIGContext sig = getSIGParameter(request,user,true,"top");
String page_title = null; setMyLocation(request,"sigprofile?sig=" + sig.getSIGID());
Object content = null;
try try
{ // get the ID of the SIG we want to see the profile of { // create the profile display
int sigid = Integer.parseInt(request.getParameter("sig"));
// get the SIG context for the user
SIGContext sig = user.getSIGContext(sigid);
// create the profile display
content = new SIGProfileData(getVeniceEngine(),user,sig);
page_title = "SIG Profile: " + sig.getName();
changeMenuSIG(request,sig); changeMenuSIG(request,sig);
return new SIGProfileData(engine,user,sig);
} // end try } // end try
catch (NumberFormatException nfe)
{ // something as simple as an improper SIGID brought us down?!?!?
page_title = "Input Error";
content = new ErrorBox(page_title,"SIG ID not valid: " + request.getParameter("sig"),"top");
} // end catch
catch (DataException de) catch (DataException de)
{ // in this case, we had database trouble { // in this case, we had database trouble
page_title = "Database Error"; return new ErrorBox("Database Error","Database error accessing SIG: " + de.getMessage(),"top");
content = new ErrorBox(page_title,"Database error accessing SIG: " + de.getMessage(),"top");
} // end catch } // end catch
BaseJSPData basedat = new BaseJSPData(page_title,"sigprofile?" + request.getQueryString(),content); } // end doVeniceGet
basedat.transfer(getServletContext(),rdat);
} // end doGet
} // end class SIGProfile } // end class SIGProfile

View File

@ -0,0 +1,61 @@
/*
* 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.IOException;
import java.io.InputStream;
import com.silverwrist.venice.servlets.format.RenderData;
public class SendFileResult extends ExecuteResult
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String type;
private String filename;
private int length;
private InputStream data;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public SendFileResult(String type, String filename, int length, InputStream data)
{
this.type = type;
this.filename = filename;
this.length = length;
this.data = data;
} // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class ExecuteResult
*--------------------------------------------------------------------------------
*/
public void execute(RenderData rdat) throws IOException
{
rdat.sendBinaryData(type,filename,length,data);
} // end execute
} // end class SendFileResult

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -27,6 +27,11 @@ import com.silverwrist.venice.servlets.format.*;
public class Top extends VeniceServlet public class Top extends VeniceServlet
{ {
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public void init(ServletConfig config) throws ServletException public void init(ServletConfig config) throws ServletException
{ {
super.init(config); // required before we do anything else super.init(config); // required before we do anything else
@ -36,7 +41,7 @@ public class Top extends VeniceServlet
DOMConfigurator.configure(ctxt.getInitParameter("logging.config")); DOMConfigurator.configure(ctxt.getInitParameter("logging.config"));
// Initialize the Venice engine. // Initialize the Venice engine.
VeniceEngine engine = getVeniceEngine(ctxt); VeniceEngine engine = Variables.getVeniceEngine(ctxt);
// Initialize the Venice rendering system. // Initialize the Venice rendering system.
RenderConfig.getRenderConfig(ctxt); RenderConfig.getRenderConfig(ctxt);
@ -52,36 +57,34 @@ public class Top extends VeniceServlet
public String getServletInfo() public String getServletInfo()
{ {
String rc = "Top applet - Displays the Venice front page\n" String rc = "Top applet - Displays the Venice front page\n"
+ "Part of the Venice Web conferencing system\n"; + "Part of the Venice Web Communities System\n";
return rc; return rc;
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{ {
UserContext user = getUserContext(request); changeMenuTop(request);
RenderData rdat = createRenderData(request,response); setMyLocation(request,"top");
ContentRender content = null;
String page_title = "My Front Page";
try try
{ // attempt to get the user content { // attempt to get the user content
content = new TopContent(user); return new TopContent(user);
} // end try } // end try
catch (DataException e) catch (DataException de)
{ // there was a database error, whoops! { // there was a database error, whoops!
page_title = "Database Error"; return new ErrorBox("Database Error","Error loading front page: " + de.getMessage(),null);
content = new ErrorBox(page_title,"Error loading front page: " + e.getMessage(),null);
} // end catch } // end catch
changeMenuTop(request); } // end doVeniceGet
BaseJSPData basedat = new BaseJSPData(page_title,"top",content);
basedat.transfer(getServletContext(),rdat);
} // end doGet
} // end class Top } // end class Top

View File

@ -38,89 +38,6 @@ public class TopicOperations extends VeniceServlet
private static Category logger = Category.getInstance(TopicOperations.class.getName()); 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 * Overrides from class HttpServlet
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -134,97 +51,33 @@ public class TopicOperations extends VeniceServlet
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{ {
UserContext user = getUserContext(request); // get the SIG
RenderData rdat = createRenderData(request,response); SIGContext sig = getSIGParameter(request,user,true,"top");
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); changeMenuSIG(request,sig);
if (logger.isDebugEnabled()) String locator = "sig=" + sig.getSIGID();
logger.debug("found SIG #" + String.valueOf(sig.getSIGID())); String location = "sigprofile?" + locator;
locator = "sig=" + String.valueOf(sig.getSIGID());
location = "sigprofile?" + locator;
} // end try // get the conference
catch (DataException de) ConferenceContext conf = getConferenceParameter(request,sig,true,location);
{ // error looking up the SIG locator += "&conf=" + conf.getConfID();
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; location = "confdisp?" + locator;
} // end try // get the topic
catch (DataException de) TopicContext topic = getTopicParameter(request,conf,true,location);
{ // error looking up the conference locator += "&top=" + topic.getTopicNumber();
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; location = "confdisp?" + locator;
} // end try // figure out what command we want to perform...
catch (DataException de) String cmd = getStandardCommandParam(request);
{ // 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")) if (cmd.equals("HY") || cmd.equals("HN"))
{ // we want to set the hide status of the topic { // we want to set the hide status of the topic
@ -232,126 +85,108 @@ public class TopicOperations extends VeniceServlet
{ // call down to set the topic! { // call down to set the topic!
topic.setHidden(cmd.equals("HY")); topic.setHidden(cmd.equals("HY"));
// go back to the topic view
rdat.redirectTo(location);
return;
} // end try } // end try
catch (DataException de) catch (DataException de)
{ // there was a database error { // there was a database error
page_title = "Database Error"; return new ErrorBox("Database Error","Database error setting hide status: " + de.getMessage(),
content = new ErrorBox(page_title,"Database error setting hide status: " + de.getMessage(),location); location);
} // end catch } // end catch
// go back to the topic view
throw new RedirectResult(location);
} // end if ("hide" or "show") } // end if ("hide" or "show")
else if (cmd.equals("FY") || cmd.equals("FN"))
if (cmd.equals("FY") || cmd.equals("FN"))
{ // we want to set the frozen status of the topic { // we want to set the frozen status of the topic
try try
{ // call down to set the topic! { // call down to set the topic!
topic.setFrozen(cmd.equals("FY")); topic.setFrozen(cmd.equals("FY"));
// go back to the topic view
rdat.redirectTo(location);
return;
} // end try } // end try
catch (DataException de) catch (DataException de)
{ // there was a database error { // there was a database error
page_title = "Database Error"; return new ErrorBox("Database Error","Database error setting freeze status: " + de.getMessage(),
content = new ErrorBox(page_title,"Database error setting freeze status: " + de.getMessage(),
location); location);
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // naughty naughty = you can't do this! { // naughty naughty = you can't do this!
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),location);
content = new ErrorBox(page_title,ae.getMessage(),location);
} // end catch } // end catch
} // end else if ("freeze" or "unfreeze") // go back to the topic view
else if (cmd.equals("AY") || cmd.equals("AN")) throw new RedirectResult(location);
} // end if ("freeze" or "unfreeze")
if (cmd.equals("AY") || cmd.equals("AN"))
{ // we want to change the archived status of the topic { // we want to change the archived status of the topic
try try
{ // call down to set the topic! { // call down to set the topic!
topic.setArchived(cmd.equals("AY")); topic.setArchived(cmd.equals("AY"));
// go back to the topic view
rdat.redirectTo(location);
return;
} // end try } // end try
catch (DataException de) catch (DataException de)
{ // there was a database error { // there was a database error
page_title = "Database Error"; return new ErrorBox("Database Error","Database error setting archive status: " + de.getMessage(),
content = new ErrorBox(page_title,"Database error setting archive status: " + de.getMessage(),
location); location);
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // naughty naughty = you can't do this! { // naughty naughty = you can't do this!
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),location);
content = new ErrorBox(page_title,ae.getMessage(),location);
} // end catch } // end catch
} // end else if ("archive" or "unarchive") // go back to the topic view
else if (cmd.equals("DEL")) throw new RedirectResult(location);
{ // we need confirmation on this operation!
} // end if ("archive" or "unarchive")
if (cmd.equals("DEL"))
{ // Delete Topic requires a confirmation!
if (ConfirmBox.isConfirmed(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM)) if (ConfirmBox.isConfirmed(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM))
{ // OK, go ahead, delete the topic! { // OK, go ahead, delete the topic!
location = "confdisp?sig=" + String.valueOf(sig.getSIGID()) + "&conf=" location = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
+ String.valueOf(conf.getConfID());
try try
{ // delete the bloody topic! { // delete the bloody topic!
topic.delete(); topic.delete();
// after which, redirect to conference view
rdat.redirectTo(location);
return;
} // end try } // end try
catch (DataException de) catch (DataException de)
{ // there was a database error { // there was a database error
page_title = "Database Error"; return new ErrorBox("Database Error","Database error deleting topic: " + de.getMessage(),location);
content = new ErrorBox(page_title,"Database error deleting topic: " + de.getMessage(),location);
} // end catch } // end catch
catch (AccessError ae) catch (AccessError ae)
{ // naughty naughty = you can't do this! { // naughty naughty = you can't do this!
page_title = "Access Error"; return new ErrorBox("Access Error",ae.getMessage(),location);
content = new ErrorBox(page_title,ae.getMessage(),location);
} // end catch } // end catch
} // end if // go back to the conference view
throw new RedirectResult(location);
} // end if (confirmed)
else else
{ // not a proper confirmation - better display one { // not a proper confirmation - better display one
String message = "You are about to delete topic " + String.valueOf(topic.getTopicNumber()) 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?"; + " from the \"" + conf.getName() + "\" conference! Are you sure you want to do this?";
String confirm_url = "topicops?" + locator + "&cmd=DEL"; return new ConfirmBox(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM,"Delete Topic",message,
page_title = "Delete Topic"; "topicops?" + locator + "&cmd=DEL",location);
content = new ConfirmBox(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM,page_title,
message,confirm_url,location);
} // end else } // end else
} // end else if ("delete") } // end if (delete)
else
{ // unrecognized command // unrecognized command
page_title = "Internal Error";
logger.error("invalid command to TopicOperations.doGet: " + cmd); logger.error("invalid command to TopicOperations.doGet: " + cmd);
content = new ErrorBox(page_title,"Invalid command to TopicOperations.doGet",location); return new ErrorBox("Internal Error","Invalid command to TopicOperations.doGet",location);
} // end else } // end doVeniceGet
} // end if
BaseJSPData basedat = new BaseJSPData(page_title,location,content);
basedat.transfer(getServletContext(),rdat);
} // end doGet
} // end class TopicOperations } // end class TopicOperations

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -25,43 +25,43 @@ import com.silverwrist.venice.servlets.format.*;
public class UserDisplay extends VeniceServlet public class UserDisplay extends VeniceServlet
{ {
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo() public String getServletInfo()
{ {
String rc = "UserDisplay servlet - Displays Venice user profiles\n" String rc = "UserDisplay servlet - Displays Venice user profiles\n"
+ "Part of the Venice Web conferencing system\n"; + "Part of the Venice Web Communities System\n";
return rc; return rc;
} // end getServletInfo } // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response) /*--------------------------------------------------------------------------------
throws ServletException, IOException * Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{ {
UserContext user = getUserContext(request); String uname = request.getPathInfo().substring(1); // the username we're looking at
RenderData rdat = createRenderData(request,response);
String page_title = null;
Object content = null;
try try
{ // use the request path info to get the username to load the profile from { // load the profile corresponding to that username and display it
String uname = request.getPathInfo().substring(1);
UserProfile prof = user.getProfile(uname); UserProfile prof = user.getProfile(uname);
content = new UserProfileData(prof); changeMenuTop(request);
page_title = "User Profile - " + prof.getUserName(); return new UserProfileData(prof);
} // end try } // end try
catch (DataException de) catch (DataException de)
{ // unable to get the user name { // unable to get the user name
page_title = "Database Error"; return new ErrorBox("Database Error","Database error finding user: " + de.getMessage(),"top");
content = new ErrorBox(page_title,"Database error finding user: " + de.getMessage(),"top");
} // end catch } // end catch
changeMenuTop(request); } // end doVeniceGet
// format and display the user
BaseJSPData basedat = new BaseJSPData(page_title,"user" + request.getPathInfo(),content);
basedat.transfer(getServletContext(),rdat);
} // end doGet
} // end class UserDisplay } // end class UserDisplay

View File

@ -176,9 +176,9 @@ public class Variables
} // end getLanguageList } // end getLanguageList
public static ContentRender getMenu(HttpSession session) public static ComponentRender getMenu(HttpSession session)
{ {
return (ContentRender)(session.getAttribute(MENU_ATTRIBUTE)); return (ComponentRender)(session.getAttribute(MENU_ATTRIBUTE));
} // end getMenu } // end getMenu

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -17,10 +17,14 @@
*/ */
package com.silverwrist.venice.servlets; package com.silverwrist.venice.servlets;
import java.io.*;
import java.util.*; import java.util.*;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.http.*; import javax.servlet.http.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.util.ServletMultipartHandler;
import com.silverwrist.util.ServletMultipartException;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.servlets.format.*; import com.silverwrist.venice.servlets.format.*;
@ -31,97 +35,628 @@ public abstract class VeniceServlet extends HttpServlet
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private static final String LOCATION_ATTR = "com.silverwrist.venice.servlets.internal.Location";
private static Category logger = Category.getInstance(VeniceServlet.class.getName()); private static Category logger = Category.getInstance(VeniceServlet.class.getName());
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private static final void notSupported(HttpServletRequest request, String message) throws ErrorResult
{
String protocol = request.getProtocol();
if (protocol.endsWith("1.1"))
throw new ErrorResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED,message);
else
throw new ErrorResult(HttpServletResponse.SC_BAD_REQUEST,message);
} // end notSupported
private static final SIGContext getSIGParameter(String str, UserContext user, boolean required,
String on_error) throws ErrorBox
{
if (StringUtil.isStringEmpty(str))
{ // there's no SIG parameter
if (required)
{ // no SIG parameter - bail out now!
logger.error("SIG parameter not specified!");
throw new ErrorBox(null,"No SIG specified.",on_error);
} // end if
else
{ // a null SIGContext is permitted
if (logger.isDebugEnabled())
logger.debug("no SIG specified");
return null;
} // end else
} // end if
SIGContext rc = null;
try
{ // turn the string into a SIGID, and thence to a SIGContext
rc = user.getSIGContext(Integer.parseInt(str));
if (logger.isDebugEnabled())
logger.debug("found SIG #" + rc.getSIGID());
} // end try
catch (NumberFormatException nfe)
{ // error in Integer.parseInt
logger.error("Cannot convert SIG parameter '" + str + "'!");
throw new ErrorBox(null,"Invalid SIG parameter.",on_error);
} // end catch
catch (DataException de)
{ // error looking up the SIG
throw new ErrorBox("Database Error","Database error finding SIG: " + de.getMessage(),on_error);
} // end catch
return rc;
} // end getSIGParameter
private static ConferenceContext getConferenceParameter(String str, SIGContext sig, boolean required,
String on_error) throws ErrorBox
{
if (StringUtil.isStringEmpty(str))
{ // there's no conference parameter
if (required)
{ // no conference parameter - bail out now!
logger.error("Conference parameter not specified!");
throw new ErrorBox(null,"No conference specified.",on_error);
} // end if
else
{ // a null ConferenceContext is permitted
if (logger.isDebugEnabled())
logger.debug("no conference specified");
return null;
} // end else
} // end if
ConferenceContext rc = null;
try
{ // turn the string into a ConfID, and thence to a ConferenceContext
rc = sig.getConferenceContext(Integer.parseInt(str));
if (logger.isDebugEnabled())
logger.debug("found conf #" + rc.getConfID());
} // end try
catch (NumberFormatException nfe)
{ // error in Integer.parseInt
logger.error("Cannot convert conference parameter '" + str + "'!");
throw new ErrorBox(null,"Invalid conference parameter.",on_error);
} // end catch
catch (AccessError ae)
{ // these all get handled in pretty much the same way
throw new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // error looking up the conference
throw new ErrorBox("Database Error","Database error finding conference: " + de.getMessage(),on_error);
} // end catch
return rc;
} // end getConferenceParameter
private static TopicContext getTopicParameter(String str, ConferenceContext conf, boolean required,
String on_error) throws ErrorBox
{
if (StringUtil.isStringEmpty(str))
{ // there's no topic parameter
if (required)
{ // no topic parameter - bail out now!
logger.error("Topic parameter not specified!");
throw new ErrorBox(null,"No topic specified.",on_error);
} // end if
else
{ // a null TopicContext is permitted
if (logger.isDebugEnabled())
logger.debug("no topic specified");
return null;
} // end else
} // end if
TopicContext rc = null;
try
{ // turn the string into a TopicID, and thence to a TopicContext
rc = conf.getTopic(Short.parseShort(str));
if (logger.isDebugEnabled())
logger.debug("found topic #" + rc.getTopicID());
} // end try
catch (NumberFormatException nfe)
{ // error in Integer.parseInt
logger.error("Cannot convert topic parameter '" + str + "'!");
throw new ErrorBox(null,"Invalid topic parameter.",on_error);
} // end catch
catch (AccessError ae)
{ // these all get handled in pretty much the same way
throw new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // error looking up the topic
throw new ErrorBox("Database Error","Database error finding topic: " + de.getMessage(),"top");
} // end catch
return rc;
} // end getTopicParameter
private static TopicMessageContext getMessageParameter(String str, ConferenceContext conf, boolean required,
String on_error) throws ErrorBox
{
if (StringUtil.isStringEmpty(str))
{ // there's no message parameter
if (required)
{ // no message parameter - bail out now!
logger.error("Message parameter not specified!");
throw new ErrorBox(null,"No message specified.",on_error);
} // end if
else
{ // a null TopicMessageContext is permitted
if (logger.isDebugEnabled())
logger.debug("no message specified");
return null;
} // end else
} // end if
TopicMessageContext rc = null;
try
{ // turn the string into a postid, and thence to a TopicMessageContext
rc = conf.getMessageByPostID(Long.parseLong(str));
if (logger.isDebugEnabled())
logger.debug("found post #" + rc.getPostID());
} // end try
catch (NumberFormatException nfe)
{ // error in Integer.parseInt
logger.error("Cannot convert message parameter '" + str + "'!");
throw new ErrorBox(null,"Invalid message parameter.",on_error);
} // end catch
catch (AccessError ae)
{ // these all get handled in pretty much the same way
throw new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // error looking up the conference
throw new ErrorBox("Database Error","Database error finding message: " + de.getMessage(),on_error);
} // end catch
return rc;
} // end getMessageParameter
private static TopicMessageContext getMessageParameter(String str, TopicContext topic, boolean required,
String on_error) throws ErrorBox
{
if (StringUtil.isStringEmpty(str))
{ // there's no message parameter
if (required)
{ // no message parameter - bail out now!
logger.error("Message parameter not specified!");
throw new ErrorBox(null,"No message specified.",on_error);
} // end if
else
{ // a null TopicMessageContext is permitted
if (logger.isDebugEnabled())
logger.debug("no message specified");
return null;
} // end else
} // end if
TopicMessageContext rc = null;
try
{ // turn the string into a post number, and thence to a TopicMessageContext
rc = topic.getMessage(Integer.parseInt(str));
if (logger.isDebugEnabled())
logger.debug("found post #" + rc.getPostID());
} // end try
catch (NumberFormatException nfe)
{ // error in Integer.parseInt
logger.error("Cannot convert message parameter '" + str + "'!");
throw new ErrorBox(null,"Invalid message parameter.",on_error);
} // end catch
catch (AccessError ae)
{ // these all get handled in pretty much the same way
throw new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // error looking up the conference
throw new ErrorBox("Database Error","Database error finding message: " + de.getMessage(),on_error);
} // end catch
return rc;
} // end getMessageParameter
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Internal operations intended for use by derived classes * Internal operations intended for use by derived classes
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
protected static boolean isImageButtonClicked(ServletRequest request, String name) protected static final boolean isImageButtonClicked(ServletRequest request, String name)
{ {
String val = request.getParameter(name + ".x"); String val = request.getParameter(name + ".x");
return (val!=null); return (val!=null);
} // end isImageButtonClicked } // end isImageButtonClicked
protected static VeniceEngine getVeniceEngine(ServletContext ctxt) throws ServletException /*
protected static final VeniceEngine getVeniceEngine(ServletContext ctxt) throws ServletException
{ {
return Variables.getVeniceEngine(ctxt); return Variables.getVeniceEngine(ctxt);
} // end getVeniceEngine } // end getVeniceEngine
protected VeniceEngine getVeniceEngine() throws ServletException protected final VeniceEngine getVeniceEngine() throws ServletException
{ {
return Variables.getVeniceEngine(getServletContext()); return Variables.getVeniceEngine(getServletContext());
} // end getVeniceEngine } // end getVeniceEngine
*/
protected UserContext getUserContext(HttpServletRequest request) throws ServletException /*
protected final UserContext getUserContext(HttpServletRequest request) throws ServletException
{ {
return Variables.getUserContext(getServletContext(),request,request.getSession(true)); return Variables.getUserContext(getServletContext(),request,request.getSession(true));
} // end getUserContext } // end getUserContext
*/
protected void putUserContext(HttpServletRequest request, UserContext ctxt) protected final void putUserContext(HttpServletRequest request, UserContext ctxt)
{ {
Variables.putUserContext(request.getSession(true),ctxt); Variables.putUserContext(request.getSession(true),ctxt);
} // end putUserContext } // end putUserContext
protected void clearUserContext(HttpServletRequest request) protected final void clearUserContext(HttpServletRequest request)
{ {
Variables.clearUserContext(request.getSession(true)); Variables.clearUserContext(request.getSession(true));
} // end clearUserContext } // end clearUserContext
protected static List getCountryList(ServletContext ctxt) throws ServletException protected static final List getCountryList(ServletContext ctxt) throws ServletException
{ {
return Variables.getCountryList(ctxt); return Variables.getCountryList(ctxt);
} // end getCountryList } // end getCountryList
protected List getCountryList() throws ServletException protected final List getCountryList() throws ServletException
{ {
return Variables.getCountryList(getServletContext()); return Variables.getCountryList(getServletContext());
} // end getCountryList } // end getCountryList
protected List getLanguageList(ServletContext ctxt) throws ServletException protected final List getLanguageList(ServletContext ctxt) throws ServletException
{ {
return Variables.getLanguageList(ctxt); return Variables.getLanguageList(ctxt);
} // end getLanguageList } // end getLanguageList
protected List getLanguageList() throws ServletException protected final List getLanguageList() throws ServletException
{ {
return Variables.getLanguageList(getServletContext()); return Variables.getLanguageList(getServletContext());
} // end getLanguageList } // end getLanguageList
protected void changeMenuTop(HttpServletRequest request) protected final void changeMenuTop(HttpServletRequest request)
{ {
Variables.setMenuTop(getServletContext(),request.getSession(true)); Variables.setMenuTop(getServletContext(),request.getSession(true));
} // end changeMenuTop } // end changeMenuTop
protected void changeMenuSIG(HttpServletRequest request, SIGContext sig) protected final void changeMenuSIG(HttpServletRequest request, SIGContext sig)
{ {
Variables.setMenuSIG(request.getSession(true),sig); Variables.setMenuSIG(request.getSession(true),sig);
} // end changeMenuSIG } // end changeMenuSIG
protected void clearMenu(HttpServletRequest request) protected final void clearMenu(HttpServletRequest request)
{ {
Variables.clearMenu(request.getSession(true)); Variables.clearMenu(request.getSession(true));
} // end clearMenu } // end clearMenu
protected RenderData createRenderData(HttpServletRequest request, HttpServletResponse response) /*
protected final RenderData createRenderData(HttpServletRequest request, HttpServletResponse response)
throws ServletException throws ServletException
{ {
return RenderConfig.createRenderData(getServletContext(),request,response); return RenderConfig.createRenderData(getServletContext(),request,response);
} // end createRenderData } // end createRenderData
*/
protected final String getStandardCommandParam(ServletRequest request)
{
String foo = request.getParameter("cmd");
if (foo==null)
return "???";
else
return foo;
} // end getStandardCommandParam
protected final void setMyLocation(ServletRequest request, String loc)
{
request.setAttribute(LOCATION_ATTR,loc);
} // end setMyLocation
protected final static SIGContext getSIGParameter(ServletRequest request, UserContext user, boolean required,
String on_error) throws ErrorBox
{
return getSIGParameter(request.getParameter("sig"),user,required,on_error);
} // end getSIGParameter
protected final static SIGContext getSIGParameter(ServletMultipartHandler mphandler, UserContext user,
boolean required, String on_error) throws ErrorBox
{
if (mphandler.isFileParam("sig"))
throw new ErrorBox(null,"Internal Error: SIG should be a normal param",on_error);
return getSIGParameter(mphandler.getValue("sig"),user,required,on_error);
} // end getSIGParameter
protected final static ConferenceContext getConferenceParameter(ServletRequest request, SIGContext sig,
boolean required, String on_error)
throws ErrorBox
{
return getConferenceParameter(request.getParameter("conf"),sig,required,on_error);
} // end getConferenceParameter
protected final static ConferenceContext getConferenceParameter(ServletMultipartHandler mphandler,
SIGContext sig, boolean required,
String on_error) throws ErrorBox
{
if (mphandler.isFileParam("conf"))
throw new ErrorBox(null,"Internal Error: conference should be a normal param",on_error);
return getConferenceParameter(mphandler.getValue("conf"),sig,required,on_error);
} // end getConferenceParameter
protected final static TopicContext getTopicParameter(ServletRequest request, ConferenceContext conf,
boolean required, String on_error) throws ErrorBox
{
return getTopicParameter(request.getParameter("top"),conf,required,on_error);
} // end getTopicParameter
protected final static TopicContext getTopicParameter(ServletMultipartHandler mphandler,
ConferenceContext conf, boolean required,
String on_error) throws ErrorBox
{
if (mphandler.isFileParam("top"))
throw new ErrorBox(null,"Internal Error: topic should be a normal param",on_error);
return getTopicParameter(mphandler.getValue("top"),conf,required,on_error);
} // end getTopicParameter
protected final static TopicMessageContext getMessageParameter(ServletRequest request,
ConferenceContext conf, boolean required,
String on_error) throws ErrorBox
{
return getMessageParameter(request.getParameter("msg"),conf,required,on_error);
} // end getMessageParameter
protected final static TopicMessageContext getMessageParameter(ServletMultipartHandler mphandler,
ConferenceContext conf, boolean required,
String on_error) throws ErrorBox
{
if (mphandler.isFileParam("msg"))
throw new ErrorBox(null,"Internal Error: message should be a normal param",on_error);
return getMessageParameter(mphandler.getValue("msg"),conf,required,on_error);
} // end getMessageParameter
protected final static TopicMessageContext getMessageParameter(ServletRequest request, TopicContext topic,
boolean required, String on_error)
throws ErrorBox
{
return getMessageParameter(request.getParameter("msg"),topic,required,on_error);
} // end getMessageParameter
protected final static TopicMessageContext getMessageParameter(ServletMultipartHandler mphandler,
TopicContext topic, boolean required,
String on_error) throws ErrorBox
{
if (mphandler.isFileParam("msg"))
throw new ErrorBox(null,"Internal Error: message should be a normal param",on_error);
return getMessageParameter(mphandler.getValue("msg"),topic,required,on_error);
} // end getMessageParameter
/*--------------------------------------------------------------------------------
* Overrideable operations
*--------------------------------------------------------------------------------
*/
protected String getMyLocation(HttpServletRequest request, VeniceEngine engine, UserContext user,
RenderData rdat)
{
return (String)(request.getAttribute(LOCATION_ATTR));
} // end getMyLocation
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
notSupported(request,"GET method not supported");
return null;
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
notSupported(request,"POST method not supported for normal form posts");
return null;
} // end doVenicePost
protected VeniceContent doVenicePost(HttpServletRequest request, ServletMultipartHandler mphandler,
VeniceEngine engine, UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
notSupported(request,"POST method not supported for multipart/form-data posts");
return null;
} // end doVenicePost
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public final void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
ServletContext ctxt = getServletContext();
VeniceEngine engine = Variables.getVeniceEngine(ctxt);
UserContext user = Variables.getUserContext(ctxt,request,request.getSession(true));
RenderData rdat = RenderConfig.createRenderData(ctxt,request,response);
VeniceContent content = null;
try
{ // run the actual "get" in the servlet
content = doVeniceGet(request,engine,user,rdat);
} // end try
catch (VeniceServletResult res)
{ // special VeniceServletResult catch here - figure out what result it is
if (res instanceof VeniceContent)
content = (VeniceContent)res; // this is content
else if (res instanceof ContentResult)
{ // this contains content
ContentResult cres = (ContentResult)res;
content = cres.getContent();
} // end else if
else if (res instanceof ExecuteResult)
{ // direct-execution result
ExecuteResult xres = (ExecuteResult)res;
xres.execute(rdat);
return;
} // end else if
else // unrecognized VeniceServletResult
content = null;
} // end catch
if (content!=null)
{ // display the content!
BaseJSPData base = new BaseJSPData(getMyLocation(request,engine,user,rdat),content);
base.transfer(ctxt,rdat);
} // end if
else // there is no content - display the null response
rdat.nullResponse();
} // end doGet
public final void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
ServletContext ctxt = getServletContext();
VeniceEngine engine = Variables.getVeniceEngine(ctxt);
UserContext user = Variables.getUserContext(ctxt,request,request.getSession(true));
RenderData rdat = RenderConfig.createRenderData(ctxt,request,response);
ServletMultipartHandler mphandler = null;
VeniceContent content = null;
if (ServletMultipartHandler.canHandle(request))
{ // if this is a multipart/form-data request, invoke our special handler code
try
{ // create the multipart handler
mphandler = new ServletMultipartHandler(request);
} // end try
catch (ServletMultipartException e)
{ // this is an error message we need to generate and just bail out on
BaseJSPData base = new BaseJSPData(getMyLocation(request,engine,user,rdat),
new ErrorBox(null,"Internal Error: " + e.getMessage(),null));
base.transfer(ctxt,rdat);
return;
} // end if
} // end if
try
{ // call the appropriate doVenicePost method
if (mphandler!=null)
content = doVenicePost(request,mphandler,engine,user,rdat);
else
content = doVenicePost(request,engine,user,rdat);
} // end try
catch (VeniceServletResult res)
{ // special VeniceServletResult catch here - figure out what result it is
if (res instanceof VeniceContent)
content = (VeniceContent)res; // this is content
else if (res instanceof ContentResult)
{ // this contains content
ContentResult cres = (ContentResult)res;
content = cres.getContent();
} // end else if
else if (res instanceof ExecuteResult)
{ // direct-execution result
ExecuteResult xres = (ExecuteResult)res;
xres.execute(rdat);
return;
} // end else if
else // unrecognized VeniceServletResult
content = null;
} // end catch
if (content!=null)
{ // display the content!
BaseJSPData base = new BaseJSPData(getMyLocation(request,engine,user,rdat),content);
base.transfer(ctxt,rdat);
} // end if
else // there is no content - display the null response
rdat.nullResponse();
} // end doPost
} // end class VeniceServlet } // end class VeniceServlet

View File

@ -0,0 +1,59 @@
/*
* 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.PrintWriter;
import java.io.PrintStream;
public class VeniceServletResult extends Throwable
{
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public VeniceServletResult()
{
super();
} // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class Throwable
*--------------------------------------------------------------------------------
*/
public final void printStackTrace()
{ // do nothing - this isn't really an error
} // end printStackTrace
public final void printStackTrace(PrintStream s)
{ // do nothing - this isn't really an error
} // end printStackTrace
public final void printStackTrace(PrintWriter s)
{ // do nothing - this isn't really an error
} // end printStackTrace
public final Throwable fillInStackTrace()
{ // do nothing - this isn't really an error
return this;
} // end fillInStackTrace
} // end class VeniceServletResult

View File

@ -69,6 +69,17 @@ public class AttachmentForm implements JSPRender
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Upload Attachment";
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -38,9 +38,8 @@ public class BaseJSPData
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private String title; // title string to use for this page
private String location; // location string to use for this page private String location; // location string to use for this page
private Object content; // the actual content private VeniceContent content; // the actual content
private boolean login_links = true; // show login links up top? private boolean login_links = true; // show login links up top?
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
@ -48,9 +47,8 @@ public class BaseJSPData
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
public BaseJSPData(String title, String location, Object content) public BaseJSPData(String location, VeniceContent content)
{ {
this.title = title;
this.location = location; this.location = location;
this.content = content; this.content = content;
@ -78,12 +76,18 @@ public class BaseJSPData
} // end store } // end store
public String getTitle() public String getTitle(RenderData rdat)
{ {
return title; return content.getPageTitle(rdat);
} // end getTitle } // end getTitle
public boolean locationSpecified()
{
return (location!=null);
} // end if
public String getLocation() public String getLocation()
{ {
return location; return location;
@ -92,7 +96,7 @@ public class BaseJSPData
public boolean displayLoginLinks() public boolean displayLoginLinks()
{ {
return login_links; return login_links && (location!=null);
} // end displayLoginLinks } // end displayLoginLinks
@ -115,8 +119,7 @@ public class BaseJSPData
{ {
if (content==null) if (content==null)
{ // there is no content! { // there is no content!
ErrorBox box = new ErrorBox(null,"Internal Error: There is no content available",null); new ErrorBox(null,"Internal Error: There is no content available",null).renderHere(out,rdat);
box.renderHere(out,rdat);
return; return;
} // end if } // end if
@ -128,8 +131,7 @@ public class BaseJSPData
return; return;
} // end if } // end if
else if (content instanceof JSPRender)
if (content instanceof JSPRender)
{ // we have a JSP-rendered page - include it { // we have a JSP-rendered page - include it
JSPRender jr = (JSPRender)content; JSPRender jr = (JSPRender)content;
rdat.storeJSPRender(jr); rdat.storeJSPRender(jr);
@ -141,10 +143,8 @@ public class BaseJSPData
return; return;
} // end if } // end if
else // this is the fallback if we don't recognize the content
// this is the fallback if we don't recognize the content new ErrorBox(null,"Internal Error: Content of invalid type",null).renderHere(out,rdat);
ErrorBox box2 = new ErrorBox(null,"Internal Error: Content of invalid type",null);
box2.renderHere(out,rdat);
} // end renderContent } // end renderContent

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are

View File

@ -19,7 +19,7 @@ package com.silverwrist.venice.servlets.format;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
public interface CDCommandButton extends ContentRender public interface CDCommandButton extends ComponentRender
{ {
public abstract String getName(); public abstract String getName();

View File

@ -19,7 +19,7 @@ package com.silverwrist.venice.servlets.format;
import com.silverwrist.venice.ValidationException; import com.silverwrist.venice.ValidationException;
public interface CDFormField extends ContentRender public interface CDFormField extends ComponentRender
{ {
public abstract String getName(); public abstract String getName();

View File

@ -0,0 +1,27 @@
/*
* 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.format;
import java.io.Writer;
import java.io.IOException;
public interface ComponentRender
{
public abstract void renderHere(Writer out, RenderData rdat) throws IOException;
} // end interface ComponentRender

View File

@ -66,6 +66,17 @@ public class ConferenceListing implements JSPRender
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Conference Listing: " + sig.getName();
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -93,7 +93,18 @@ public class ConfirmBox implements ContentRender
} // end doConfirm } // end doConfirm
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from class ContentRender * Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return title;
} // end getPageTitle
/*--------------------------------------------------------------------------------
* Implementations from interface ContentRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */

View File

@ -122,6 +122,17 @@ public class ContentDialog implements Cloneable, ContentRender
{ // do nothing at this level { // do nothing at this level
} // end validateWholeForm } // end validateWholeForm
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return title;
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface ContentRender * Implementations from interface ContentRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -214,12 +225,6 @@ public class ContentDialog implements Cloneable, ContentRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
public String getTitle()
{
return title;
} // end getTitle
public void setErrorMessage(String message) public void setErrorMessage(String message)
{ {
this.error_message = message; this.error_message = message;

View File

@ -99,6 +99,17 @@ public class ContentMenuPanel implements Cloneable, ContentRender
} // end constructor } // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return title;
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface ContentRender * Implementations from interface ContentRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -20,7 +20,7 @@ package com.silverwrist.venice.servlets.format;
import java.io.Writer; import java.io.Writer;
import java.io.IOException; import java.io.IOException;
public interface ContentRender public interface ContentRender extends VeniceContent
{ {
public abstract void renderHere(Writer out, RenderData rdat) throws IOException; public abstract void renderHere(Writer out, RenderData rdat) throws IOException;

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -20,15 +20,27 @@ package com.silverwrist.venice.servlets.format;
import java.io.Writer; import java.io.Writer;
import java.io.IOException; import java.io.IOException;
import com.silverwrist.util.StringUtil; import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.servlets.VeniceServletResult;
public class ErrorBox implements ContentRender public class ErrorBox extends VeniceServletResult implements ContentRender
{ {
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String title; private String title;
private String message; private String message;
private String back; private String back;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ErrorBox(String title, String message, String back) public ErrorBox(String title, String message, String back)
{ {
super();
this.title = title; this.title = title;
this.message = message; this.message = message;
this.back = back; this.back = back;
@ -38,6 +50,22 @@ public class ErrorBox implements ContentRender
} // end constructor } // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return title;
} // end getPageTitle
/*--------------------------------------------------------------------------------
* Implementations from interface ContentRender
*--------------------------------------------------------------------------------
*/
public void renderHere(Writer out, RenderData rdat) throws IOException public void renderHere(Writer out, RenderData rdat) throws IOException
{ {
out.write("<P><TABLE ALIGN=CENTER WIDTH=\"70%\" BORDER=1 CELLPADDING=2 CELLSPACING=1>"); out.write("<P><TABLE ALIGN=CENTER WIDTH=\"70%\" BORDER=1 CELLPADDING=2 CELLSPACING=1>");

View File

@ -138,6 +138,17 @@ public class FindData implements JSPRender, SearchMode
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Find";
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -19,7 +19,7 @@ package com.silverwrist.venice.servlets.format;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
public interface JSPRender public interface JSPRender extends VeniceContent
{ {
public abstract void store(ServletRequest request); public abstract void store(ServletRequest request);

View File

@ -0,0 +1,130 @@
/*
* 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.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
public class ManageConference implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ManageConference";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private SIGContext sig; // the SIG we're in
private ConferenceContext conf; // the conference being listed
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ManageConference(SIGContext sig, ConferenceContext conf)
{
this.sig = sig;
this.conf = conf;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static ManageConference retrieve(ServletRequest request)
{
return (ManageConference)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Manage Conference: " + conf.getName();
} // end getPageTitle
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "manage_conf.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getSIGID()
{
return sig.getSIGID();
} // end getSIGID
public int getConfID()
{
return conf.getConfID();
} // end getConfID
public String getConfName()
{
return conf.getName();
} // end getConfName
public String getLocator()
{
return "sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
} // end getLocator
public boolean displayAdminSection()
{
return conf.canChangeConference();
// TODO: needs to have "delete" permission OR'ed in
} // end displayAdminSection
} // end class ManageConference

View File

@ -23,7 +23,7 @@ import java.util.*;
import com.silverwrist.util.StringUtil; import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
public class MenuSIG implements ContentRender public class MenuSIG implements ComponentRender
{ {
private String image_url; private String image_url;
private boolean image_url_needs_fixup = false; private boolean image_url_needs_fixup = false;

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -20,7 +20,7 @@ package com.silverwrist.venice.servlets.format;
import java.io.Writer; import java.io.Writer;
import java.io.IOException; import java.io.IOException;
public class MenuTop implements ContentRender public class MenuTop implements ComponentRender
{ {
public MenuTop() public MenuTop()
{ // constructor does nothing { // constructor does nothing

View File

@ -61,6 +61,17 @@ public class NewSIGWelcome implements JSPRender
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "New SIG Created";
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -70,6 +70,17 @@ public class NewTopicForm implements JSPRender
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Create New Topic";
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -105,6 +105,17 @@ public class PostPreview implements JSPRender
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Previewing Message";
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -98,6 +98,17 @@ public class PostSlippage implements JSPRender
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Slippage or Double-Click Detected";
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -308,6 +308,18 @@ public class RenderData
} // end nullResponse } // end nullResponse
public void errorResponse(int code) throws IOException
{
response.sendError(code);
} // end errorResponse
public void errorResponse(int code, String msg) throws IOException
{
response.sendError(code,msg);
} // end errorResponse
public void sendBinaryData(String type, String filename, int length, InputStream data) throws IOException public void sendBinaryData(String type, String filename, int length, InputStream data) throws IOException
{ {
response.setContentType(type); response.setContentType(type);

View File

@ -71,6 +71,17 @@ public class SIGCategoryBrowseData implements JSPRender
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Set SIG Category";
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -70,6 +70,17 @@ public class SIGProfileData implements JSPRender
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "SIG Profile: " + sig.getName();
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -61,6 +61,17 @@ public class SIGWelcome implements JSPRender
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Welcome to " + name;
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -26,7 +26,7 @@ import com.silverwrist.venice.core.DataException;
public abstract class TCStandardPanel extends TopContentPanel public abstract class TCStandardPanel extends TopContentPanel
{ {
class TCButton implements ContentRender class TCButton implements ComponentRender
{ {
private String image; private String image;
private String alt_text; private String alt_text;

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * 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>, * 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 * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -24,15 +24,28 @@ import com.silverwrist.venice.core.*;
public class TopContent implements ContentRender public class TopContent implements ContentRender
{ {
// Static constants /*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
public static final int MAX_COLS = 2; public static final int MAX_COLS = 2;
// Attributes /*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private int actual_cols = MAX_COLS; private int actual_cols = MAX_COLS;
private int[] col_sizes; private int[] col_sizes;
private Vector panels = new Vector(); private Vector panels = new Vector();
private boolean display_configure; private boolean display_configure;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public TopContent(UserContext uc) throws DataException public TopContent(UserContext uc) throws DataException
{ {
int i; // loop counter int i; // loop counter
@ -74,6 +87,22 @@ public class TopContent implements ContentRender
} // end constructor } // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "My Front Page";
} // end getPageTitle
/*--------------------------------------------------------------------------------
* Implementations from interface ContentRender
*--------------------------------------------------------------------------------
*/
public void renderHere(Writer out, RenderData rdat) throws IOException public void renderHere(Writer out, RenderData rdat) throws IOException
{ {
out.write("<TABLE BORDER=0 ALIGN=CENTER WIDTH=\"100%\" CELLPADDING=4 CELLSPACING=0>\n"); out.write("<TABLE BORDER=0 ALIGN=CENTER WIDTH=\"100%\" CELLPADDING=4 CELLSPACING=0>\n");
@ -108,6 +137,6 @@ public class TopContent implements ContentRender
rdat.writeFooter(out); rdat.writeFooter(out);
} /* end renderHere */ } // end renderHere
} // end class TopContent } // end class TopContent

View File

@ -22,7 +22,7 @@ import java.io.IOException;
import com.silverwrist.venice.core.UserContext; import com.silverwrist.venice.core.UserContext;
import com.silverwrist.venice.core.DataException; import com.silverwrist.venice.core.DataException;
public abstract class TopContentPanel implements ContentRender, Cloneable public abstract class TopContentPanel implements ComponentRender, Cloneable
{ {
protected TopContentPanel() protected TopContentPanel()
{ // do nothing { // do nothing

View File

@ -72,6 +72,17 @@ public class TopicListing implements JSPRender
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Topics in " + conf.getName();
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -89,6 +89,18 @@ public class TopicPosts implements JSPRender
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return topic.getName() + ": " + topic.getTotalMessages() + " Total; " + unread + " New; Last: "
+ rdat.formatDateForDisplay(topic.getLastUpdateDate());
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -60,6 +60,17 @@ public class UserProfileData implements JSPRender
} // end retrieve } // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "User Profile - " + prof.getUserName();
} // end getPageTitle
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface JSPRender * Implementations from interface JSPRender
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -0,0 +1,24 @@
/*
* 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.format;
public interface VeniceContent
{
public abstract String getPageTitle(RenderData rdat);
} // end interface VeniceContent

View File

@ -7,7 +7,7 @@
WARRANTY OF ANY KIND, either express or implied. See the License for the specific WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License. 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>, 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 for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -22,9 +22,10 @@
<%@ page import = "com.silverwrist.venice.servlets.format.*" %> <%@ page import = "com.silverwrist.venice.servlets.format.*" %>
<%! <%!
private static void renderMenu(HttpSession session, java.io.Writer out, RenderData rdat) throws java.io.IOException private static void renderMenu(HttpSession session, java.io.Writer out, RenderData rdat)
throws java.io.IOException
{ {
ContentRender menu = Variables.getMenu(session); ComponentRender menu = Variables.getMenu(session);
if (menu==null) if (menu==null)
menu = new MenuTop(); menu = new MenuTop();
menu.renderHere(out,rdat); menu.renderHere(out,rdat);
@ -33,14 +34,15 @@ private static void renderMenu(HttpSession session, java.io.Writer out, RenderDa
%> %>
<% <%
BaseJSPData basedat = BaseJSPData.retrieve(request);
Variables.failIfNull(basedat);
UserContext user = Variables.getUserContext(application,request,session); UserContext user = Variables.getUserContext(application,request,session);
RenderData rdat = RenderConfig.createRenderData(application,request,response); RenderData rdat = RenderConfig.createRenderData(application,request,response);
BaseJSPData basedat = BaseJSPData.retrieve(request);
%> %>
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"> <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<HTML> <HTML>
<HEAD> <HEAD>
<%= rdat.getTitleTag(basedat.getTitle()) %> <%= rdat.getTitleTag(basedat.getTitle(rdat)) %>
</HEAD> </HEAD>
<BODY BGCOLOR="#9999FF"> <BODY BGCOLOR="#9999FF">

View File

@ -35,8 +35,7 @@
<IMG SRC="<%= rdat.getFullImagePath("purple-ball.gif") %>" ALT="*" WIDTH=14 HEIGHT=14 BORDER=0> <IMG SRC="<%= rdat.getFullImagePath("purple-ball.gif") %>" ALT="*" WIDTH=14 HEIGHT=14 BORDER=0>
</TD> </TD>
<TD ALIGN=LEFT><%= rdat.getStdFontTag(null,2) %> <TD ALIGN=LEFT><%= rdat.getStdFontTag(null,2) %>
<% String path = "confdisp?sig=" + String.valueOf(data.getSIGID()) + "&conf=" <% String path = "confdisp?sig=" + data.getSIGID() + "&conf=" + data.getConferenceID(i); %>
+ String.valueOf(data.getConferenceID(i)); %>
<A HREF="<%= rdat.getEncodedServletPath(path) %>"><%= StringUtil.encodeHTML(data.getConferenceName(i)) %></A> - <A HREF="<%= rdat.getEncodedServletPath(path) %>"><%= StringUtil.encodeHTML(data.getConferenceName(i)) %></A> -
Latest activity: <%= rdat.getActivityString(data.getLastUpdateDate(i)) %><BR> Latest activity: <%= rdat.getActivityString(data.getLastUpdateDate(i)) %><BR>
<% int count = data.getNumHosts(i); %> <% int count = data.getNumHosts(i); %>
@ -59,7 +58,7 @@
<% if (data.canCreateConference()) { %> <% if (data.canCreateConference()) { %>
<P> <P>
<DIV ALIGN="LEFT"> <DIV ALIGN="LEFT">
<A HREF="<%= rdat.getEncodedServletPath("confops?cmd=C&sig=" + String.valueOf(data.getSIGID())) %>"><IMG <A HREF="<%= rdat.getEncodedServletPath("confops?cmd=C&sig=" + data.getSIGID()) %>"><IMG
SRC="<%= rdat.getFullImagePath("bn_create_new.gif") %>" ALT="Create New" WIDTH=80 HEIGHT=24 BORDER=0></A> SRC="<%= rdat.getFullImagePath("bn_create_new.gif") %>" ALT="Create New" WIDTH=80 HEIGHT=24 BORDER=0></A>
</DIV> </DIV>
<% } // end if %> <% } // end if %>

View File

@ -7,7 +7,7 @@
WARRANTY OF ANY KIND, either express or implied. See the License for the specific WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License. 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>, 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 for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -105,8 +105,7 @@ private static String getActivityString(SIGContext sig, RenderData rdat)
<%= rdat.getStdFontTag(null,2) %> <%= rdat.getStdFontTag(null,2) %>
Display all categories whose name&nbsp;&nbsp; Display all categories whose name&nbsp;&nbsp;
<% } else throw new InternalStateError("display parameter " + String.valueOf(data.getDisplayOption()) <% } else throw new InternalStateError("display parameter " + data.getDisplayOption() + " invalid"); %>
+ " invalid"); %>
<SELECT NAME="mode" SIZE=1> <SELECT NAME="mode" SIZE=1>
<OPTION VALUE="<%= SearchMode.SEARCH_PREFIX %>" <OPTION VALUE="<%= SearchMode.SEARCH_PREFIX %>"

View File

@ -0,0 +1,59 @@
<%--
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):
--%>
<%@ page import = "java.util.*" %>
<%@ page import = "com.silverwrist.util.StringUtil" %>
<%@ page import = "com.silverwrist.venice.core.*" %>
<%@ page import = "com.silverwrist.venice.servlets.Variables" %>
<%@ page import = "com.silverwrist.venice.servlets.format.*" %>
<%
ManageConference data = ManageConference.retrieve(request);
Variables.failIfNull(data);
RenderData rdat = RenderConfig.createRenderData(application,request,response);
%>
<% if (rdat.useHTMLComments()) { %><!-- Managing conference #<%= data.getConfID() %> --><% } %>
<% rdat.writeContentHeader(out,"Manage Conference:",data.getConfName()); %>
<%= rdat.getStdFontTag(null,2) %>
<A HREF="<%= rdat.getEncodedServletPath("confdisp?" + data.getLocator()) %>">Return to Topic List</A>
</FONT><P>
<% if (rdat.useHTMLComments()) { %><!-- Set Default Pseud Form --><% } %>
<FORM METHOD="POST" ACTION="<%= rdat.getEncodedServletPath("confops") %>">
<INPUT TYPE="HIDDEN" NAME="sig" VALUE="<%= data.getSIGID() %>">
<INPUT TYPE="HIDDEN" NAME="conf" VALUE="<%= data.getConfID() %>">
<INPUT TYPE="HIDDEN" NAME="cmd" VALUE="P">
<%= rdat.getStdFontTag(null,2) %>
Set default pseud for conference:
<INPUT TYPE="TEXT" NAME="pseud" VALUE="" SIZE=37 MAXLENGTH=255>&nbsp;
<INPUT TYPE="IMAGE" SRC="<%= rdat.getFullImagePath("bn_set.gif") %>" NAME="set" ALT="Set"
WIDTH=80 HEIGHT=24 BORDER=0>
</FONT>
</FORM><P>
<% if (rdat.useHTMLComments()) { %><!-- Fixseen Link --><% } %>
<%= rdat.getStdFontTag(null,2) %><B>
<A HREF="<%= rdat.getEncodedServletPath("confops?" + data.getLocator() + "&cmd=FX") %>">Mark
entire conference as read (fixseen)</A>
</B></FONT><P>
<% if (data.displayAdminSection()) { %>
<% if (rdat.useHTMLComments()) { %><!-- Host Tools Section --><% } %>
<%-- TODO: fill this in --%>
<% } // end if (displaying admin section) %>
<% rdat.writeFooter(out); %>

View File

@ -34,8 +34,8 @@
tmp = "(Frozen) "; tmp = "(Frozen) ";
else else
tmp = ""; tmp = "";
rdat.writeContentHeader(out,data.getTopicName(),tmp + String.valueOf(data.getTotalMessages()) rdat.writeContentHeader(out,data.getTopicName(),tmp + data.getTotalMessages() + " Total; "
+ " Total; " + String.valueOf(data.getNewMessages()) + " New; Last: " + data.getNewMessages() + " New; Last: "
+ rdat.formatDateForDisplay(data.getLastUpdate())); + rdat.formatDateForDisplay(data.getLastUpdate()));
%> %>
<TABLE BORDER=0 WIDTH="100%" CELLPADDING=0 CELLSPACING=0> <TABLE BORDER=0 WIDTH="100%" CELLPADDING=0 CELLSPACING=0>
@ -162,7 +162,7 @@
<% } // end if %> <% } // end if %>
<%= rdat.getStdFontTag(null,2) %> <%= rdat.getStdFontTag(null,2) %>
<A HREF="<%= rdat.getEncodedServletPath("confdisp?" + data.getLocator() + "&shac=1&p1=" <A HREF="<%= rdat.getEncodedServletPath("confdisp?" + data.getLocator() + "&shac=1&p1="
+ String.valueOf(msg.getPostNumber())) %>"><%= msg.getPostNumber() %></A> of + msg.getPostNumber()) %>"><%= msg.getPostNumber() %></A> of
<A HREF="<%= last_post %>"><%= data.getTotalMessages() - 1 %></A> <A HREF="<%= last_post %>"><%= data.getTotalMessages() - 1 %></A>
<%= rdat.getStdFontTag(null,1) %>&lt;<%= data.getMessageReference(msg) %>&gt;</FONT> <%= rdat.getStdFontTag(null,1) %>&lt;<%= data.getMessageReference(msg) %>&gt;</FONT>
<% if (data.showAdvanced() && msg.isHidden()) { %> <% if (data.showAdvanced() && msg.isHidden()) { %>
@ -176,7 +176,7 @@
</EM>) </EM>)
<% if (msg.hasAttachment()) { %> <% if (msg.hasAttachment()) { %>
<A HREF="<%= rdat.getEncodedServletPath("attachment?" + data.getConfLocator() + "&msg=" <A HREF="<%= rdat.getEncodedServletPath("attachment?" + data.getConfLocator() + "&msg="
+ String.valueOf(msg.getPostID())) %>"><IMG + msg.getPostID()) %>"><IMG
SRC="<%= rdat.getFullImagePath("attachment.gif") %>" SRC="<%= rdat.getFullImagePath("attachment.gif") %>"
ALT="(Attachment <%= msg.getAttachmentFilename() %> - <%= msg.getAttachmentLength() %> bytes)" ALT="(Attachment <%= msg.getAttachmentFilename() %> - <%= msg.getAttachmentLength() %> bytes)"
WIDTH=16 HEIGHT=16 BORDER=0></A> WIDTH=16 HEIGHT=16 BORDER=0></A>
@ -190,14 +190,14 @@
<% } else if (msg.isHidden() && !(data.showAdvanced())) { %> <% } else if (msg.isHidden() && !(data.showAdvanced())) { %>
<TT><EM><B> <TT><EM><B>
<A HREF="<%= rdat.getEncodedServletPath("confdisp?" + data.getLocator() + "&shac=1&p1=" <A HREF="<%= rdat.getEncodedServletPath("confdisp?" + data.getLocator() + "&shac=1&p1="
+ String.valueOf(msg.getPostNumber())) %>">(Hidden + msg.getPostNumber()) %>">(Hidden
Message: <%= msg.getNumLines() %> <% if (msg.getNumLines()==1) { %>Line<% } else { %>Lines<% } %>)</A> Message: <%= msg.getNumLines() %> <% if (msg.getNumLines()==1) { %>Line<% } else { %>Lines<% } %>)</A>
</B></EM></TT><P> </B></EM></TT><P>
<% } else { %> <% } else { %>
<PRE><%= rdat.rewritePostData(data.getMessageBodyText(msg)) %></PRE> <PRE><%= rdat.rewritePostData(data.getMessageBodyText(msg)) %></PRE>
<% } // end if %> <% } // end if %>
<% if (data.showAdvanced()) { %> <% if (data.showAdvanced()) { %>
<% String po_loc = data.getLocator() + "&msg=" + String.valueOf(msg.getPostNumber()); %> <% String po_loc = data.getLocator() + "&msg=" + msg.getPostNumber(); %>
</TD><TD NOWRAP ALIGN=RIGHT> </TD><TD NOWRAP ALIGN=RIGHT>
<% if (!(msg.isScribbled())) { %> <% if (!(msg.isScribbled())) { %>
<% if (msg.canHide()) { %> <% if (msg.canHide()) { %>

View File

@ -7,7 +7,7 @@
WARRANTY OF ANY KIND, either express or implied. See the License for the specific WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License. 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>, 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 for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -51,9 +51,12 @@
<% if (data.isUserLoggedIn()) { %> <% if (data.isUserLoggedIn()) { %>
<DIV ALIGN="CENTER"> <DIV ALIGN="CENTER">
<% if (sig.isMember()) { %> <% if (sig.isMember()) { %>
<A HREF="/TODO"><IMG SRC="<%= rdat.getFullImagePath("bn_invite.gif") %>" ALT="Invite" WIDTH=80 HEIGHT=24 BORDER=0></A> <A HREF="/TODO"><IMG SRC="<%= rdat.getFullImagePath("bn_invite.gif") %>" ALT="Invite"
WIDTH=80 HEIGHT=24 BORDER=0></A>
<% } else if (sig.canJoin()) { %> <% } else if (sig.canJoin()) { %>
<A HREF="<%= rdat.getEncodedServletPath("sigops?cmd=J&sig=" + String.valueOf(sig.getSIGID())) %>"><IMG SRC="<%= rdat.getFullImagePath("bn_join_now.gif") %>" ALT="Join Now" WIDTH=80 HEIGHT=24 BORDER=0></A> <A HREF="<%= rdat.getEncodedServletPath("sigops?cmd=J&sig=" + sig.getSIGID()) %>"><IMG
SRC="<%= rdat.getFullImagePath("bn_join_now.gif") %>" ALT="Join Now"
WIDTH=80 HEIGHT=24 BORDER=0></A>
<% } // end if %> <% } // end if %>
</DIV> </DIV>
<% } // end if (user is logged in) %> <% } // end if (user is logged in) %>

View File

@ -31,7 +31,7 @@
<% rdat.writeContentHeader(out,"Topics in " + data.getConfName(),null); %> <% rdat.writeContentHeader(out,"Topics in " + data.getConfName(),null); %>
<%= rdat.getStdFontTag(null,2) %> <%= rdat.getStdFontTag(null,2) %>
<DIV ALIGN="LEFT"> <DIV ALIGN="LEFT">
<A HREF="<%= rdat.getEncodedServletPath("confops?sig=" + String.valueOf(data.getSIGID())) %>"><IMG <A HREF="<%= rdat.getEncodedServletPath("confops?sig=" + data.getSIGID()) %>"><IMG
SRC="<%= rdat.getFullImagePath("bn_conference_list.gif") %>" ALT="Conference List" WIDTH=80 HEIGHT=24 SRC="<%= rdat.getFullImagePath("bn_conference_list.gif") %>" ALT="Conference List" WIDTH=80 HEIGHT=24
BORDER=0></A>&nbsp;&nbsp; BORDER=0></A>&nbsp;&nbsp;
<% if (data.canCreateTopic()) { %> <% if (data.canCreateTopic()) { %>
@ -56,31 +56,31 @@
<TR VALIGN=TOP> <TR VALIGN=TOP>
<TD ALIGN=LEFT WIDTH="1%"><%= rdat.getStdFontTag(null,2) %> <TD ALIGN=LEFT WIDTH="1%"><%= rdat.getStdFontTag(null,2) %>
<% tmp = self + "&sort=" <% tmp = self + "&sort="
+ String.valueOf(data.isSort(ConferenceContext.SORT_NUMBER) ? -ConferenceContext.SORT_NUMBER + (data.isSort(ConferenceContext.SORT_NUMBER) ? -ConferenceContext.SORT_NUMBER
: ConferenceContext.SORT_NUMBER); %> : ConferenceContext.SORT_NUMBER); %>
<B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">#</A></B> <B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">#</A></B>
</FONT></TD> </FONT></TD>
<TD ALIGN=LEFT><%= rdat.getStdFontTag(null,2) %> <TD ALIGN=LEFT><%= rdat.getStdFontTag(null,2) %>
<% tmp = self + "&sort=" <% tmp = self + "&sort="
+ String.valueOf(data.isSort(ConferenceContext.SORT_NAME) ? -ConferenceContext.SORT_NAME + (data.isSort(ConferenceContext.SORT_NAME) ? -ConferenceContext.SORT_NAME
: ConferenceContext.SORT_NAME); %> : ConferenceContext.SORT_NAME); %>
<B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">Topic Name</A></B> <B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">Topic Name</A></B>
</FONT></TD> </FONT></TD>
<TD ALIGN=RIGHT><%= rdat.getStdFontTag(null,2) %> <TD ALIGN=RIGHT><%= rdat.getStdFontTag(null,2) %>
<% tmp = self + "&sort=" <% tmp = self + "&sort="
+ String.valueOf(data.isSort(ConferenceContext.SORT_UNREAD) ? -ConferenceContext.SORT_UNREAD + (data.isSort(ConferenceContext.SORT_UNREAD) ? -ConferenceContext.SORT_UNREAD
: ConferenceContext.SORT_UNREAD); %> : ConferenceContext.SORT_UNREAD); %>
<B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">New</A></B> <B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">New</A></B>
</FONT></TD> </FONT></TD>
<TD ALIGN=RIGHT><%= rdat.getStdFontTag(null,2) %> <TD ALIGN=RIGHT><%= rdat.getStdFontTag(null,2) %>
<% tmp = self + "&sort=" <% tmp = self + "&sort="
+ String.valueOf(data.isSort(ConferenceContext.SORT_TOTAL) ? -ConferenceContext.SORT_TOTAL + (data.isSort(ConferenceContext.SORT_TOTAL) ? -ConferenceContext.SORT_TOTAL
: ConferenceContext.SORT_TOTAL); %> : ConferenceContext.SORT_TOTAL); %>
<B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">Total</A></B> <B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">Total</A></B>
</FONT></TD> </FONT></TD>
<TD ALIGN=LEFT><%= rdat.getStdFontTag(null,2) %> <TD ALIGN=LEFT><%= rdat.getStdFontTag(null,2) %>
<% tmp = self + "&sort=" <% tmp = self + "&sort="
+ String.valueOf(data.isSort(ConferenceContext.SORT_DATE) ? -ConferenceContext.SORT_DATE + (data.isSort(ConferenceContext.SORT_DATE) ? -ConferenceContext.SORT_DATE
: ConferenceContext.SORT_DATE); %> : ConferenceContext.SORT_DATE); %>
<B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">Last Response</A></B> <B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">Last Response</A></B>
</FONT></TD> </FONT></TD>
@ -90,7 +90,7 @@
<% while (it.hasNext()) { %> <% while (it.hasNext()) { %>
<% <%
TopicContext topic = (TopicContext)(it.next()); TopicContext topic = (TopicContext)(it.next());
tmp = self + "&top=" + String.valueOf(topic.getTopicNumber()) + "&rnm=1"; tmp = self + "&top=" + topic.getTopicNumber() + "&rnm=1";
%> %>
<TR VALIGN=TOP> <TR VALIGN=TOP>
<TD ALIGN=LEFT WIDTH="1%"><%= rdat.getStdFontTag(null,2) %> <TD ALIGN=LEFT WIDTH="1%"><%= rdat.getStdFontTag(null,2) %>
@ -108,7 +108,7 @@
<A HREF="<%= rdat.getEncodedServletPath(tmp) %>"><%= topic.getUnreadMessages() %></A> <A HREF="<%= rdat.getEncodedServletPath(tmp) %>"><%= topic.getUnreadMessages() %></A>
</FONT></TD> </FONT></TD>
<TD ALIGN=RIGHT><%= rdat.getStdFontTag(null,2) %> <TD ALIGN=RIGHT><%= rdat.getStdFontTag(null,2) %>
<A HREF="<%= rdat.getEncodedServletPath(self + "&top=" + String.valueOf(topic.getTopicNumber()) <A HREF="<%= rdat.getEncodedServletPath(self + "&top=" + topic.getTopicNumber()
+ "&p1=0&p2=-1") %>"><%= topic.getTotalMessages() %></A> + "&p1=0&p2=-1") %>"><%= topic.getTotalMessages() %></A>
</FONT></TD> </FONT></TD>
<TD ALIGN=LEFT><%= rdat.getStdFontTag(null,2) %> <TD ALIGN=LEFT><%= rdat.getStdFontTag(null,2) %>
@ -156,31 +156,34 @@
<% if (data.isView(ConferenceContext.DISPLAY_NEW)) { %> <% if (data.isView(ConferenceContext.DISPLAY_NEW)) { %>
<B>New</B> <B>New</B>
<% } else { %> <% } else { %>
<A HREF="<%= rdat.getEncodedServletPath(self + "&view=" + String.valueOf(ConferenceContext.DISPLAY_NEW)) %>">New</A> <A HREF="<%= rdat.getEncodedServletPath(self + "&view=" + ConferenceContext.DISPLAY_NEW) %>">New</A>
<% } // end if %> <% } // end if %>
<B>|</B> <B>|</B>
<% if (data.isView(ConferenceContext.DISPLAY_ACTIVE)) { %> <% if (data.isView(ConferenceContext.DISPLAY_ACTIVE)) { %>
<B>Active</B> <B>Active</B>
<% } else { %> <% } else { %>
<A HREF="<%= rdat.getEncodedServletPath(self + "&view=" + String.valueOf(ConferenceContext.DISPLAY_ACTIVE)) %>">Active</A> <A HREF="<%= rdat.getEncodedServletPath(self + "&view="
+ ConferenceContext.DISPLAY_ACTIVE) %>">Active</A>
<% } // end if %> <% } // end if %>
<B>|</B> <B>|</B>
<% if (data.isView(ConferenceContext.DISPLAY_ALL)) { %> <% if (data.isView(ConferenceContext.DISPLAY_ALL)) { %>
<B>All</B> <B>All</B>
<% } else { %> <% } else { %>
<A HREF="<%= rdat.getEncodedServletPath(self + "&view=" + String.valueOf(ConferenceContext.DISPLAY_ALL)) %>">All</A> <A HREF="<%= rdat.getEncodedServletPath(self + "&view=" + ConferenceContext.DISPLAY_ALL) %>">All</A>
<% } // end if %> <% } // end if %>
<B>|</B> <B>|</B>
<% if (data.isView(ConferenceContext.DISPLAY_HIDDEN)) { %> <% if (data.isView(ConferenceContext.DISPLAY_HIDDEN)) { %>
<B>Hidden</B> <B>Hidden</B>
<% } else { %> <% } else { %>
<A HREF="<%= rdat.getEncodedServletPath(self + "&view=" + String.valueOf(ConferenceContext.DISPLAY_HIDDEN)) %>">Hidden</A> <A HREF="<%= rdat.getEncodedServletPath(self + "&view="
+ ConferenceContext.DISPLAY_HIDDEN) %>">Hidden</A>
<% } // end if %> <% } // end if %>
<B>|</B> <B>|</B>
<% if (data.isView(ConferenceContext.DISPLAY_ARCHIVED)) { %> <% if (data.isView(ConferenceContext.DISPLAY_ARCHIVED)) { %>
<B>Archived</B> <B>Archived</B>
<% } else { %> <% } else { %>
<A HREF="<%= rdat.getEncodedServletPath(self + "&view=" + String.valueOf(ConferenceContext.DISPLAY_ARCHIVED)) %>">Archived</A> <A HREF="<%= rdat.getEncodedServletPath(self + "&view="
+ ConferenceContext.DISPLAY_ARCHIVED) %>">Archived</A>
<% } // end if %> <% } // end if %>
<B>]</B> <B>]</B>
</DIV> </DIV>