diff --git a/TODO b/TODO
index 005eaaa..6979e36 100644
--- a/TODO
+++ b/TODO
@@ -6,7 +6,8 @@ Lots!
- 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
- 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
before we go live. (It plugs into the Administrative SIG features.)
diff --git a/src/com/silverwrist/venice/core/ConferenceContext.java b/src/com/silverwrist/venice/core/ConferenceContext.java
index 9d3150b..fed6bda 100644
--- a/src/com/silverwrist/venice/core/ConferenceContext.java
+++ b/src/com/silverwrist/venice/core/ConferenceContext.java
@@ -117,4 +117,6 @@ public interface ConferenceContext
public abstract HTMLChecker getNewTopicPreviewChecker();
+ public abstract void fixSeen() throws DataException;
+
} // end interface ConferenceContext
diff --git a/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java b/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java
index a378c2a..edc6ea9 100644
--- a/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java
+++ b/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java
@@ -74,6 +74,48 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
} // 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
*--------------------------------------------------------------------------------
@@ -908,6 +950,68 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
} // 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
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/Account.java b/src/com/silverwrist/venice/servlets/Account.java
index d268a9f..470a277 100644
--- a/src/com/silverwrist/venice/servlets/Account.java
+++ b/src/com/silverwrist/venice/servlets/Account.java
@@ -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());
/*--------------------------------------------------------------------------------
@@ -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
{
final String desired_name = "NewAccountDialog";
@@ -122,186 +130,154 @@ public class Account extends VeniceServlet
} // end getServletInfo
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
- {
- RenderData rdat = createRenderData(request,response);
- UserContext user = getUserContext(request);
- String page_title = null;
- ContentRender content = null;
- boolean display_login = false;
+ /*--------------------------------------------------------------------------------
+ * Overrides from class VeniceServlet
+ *--------------------------------------------------------------------------------
+ */
+ 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
if (tgt==null)
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"))
- { // "L" = Log in/out
+ { // "L" = Log In/Out
if (user.isLoggedIn())
- { // log the user out and send 'em back to the "top" page
+ { // this is a Logout command
clearUserContext(request);
- // TODO: here is where the persistent cookie gets nuked, if it does...
- rdat.redirectTo("top");
- return;
+ throw new RedirectResult("top"); // take 'em back to the "top" page
- } // end if (logging out)
- else
- { // display the Login page
- LoginDialog dlg = makeLoginDialog();
- dlg.setupNew(tgt);
- page_title = dlg.getTitle();
- content = dlg;
+ } // end if
- } // end else
+ // this is a Login command - display the Login page
+ LoginDialog dlg = makeLoginDialog();
+ dlg.setupNew(tgt);
+ return dlg;
} // end if ("L" command)
- else if (cmd.equals("C"))
+
+ 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);
+ 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);
- } // end if
- else
- { // display the "Create Account" page
- NewAccountDialog dlg = makeNewAccountDialog();
- dlg.setEngine(getVeniceEngine());
- page_title = dlg.getTitle();
- dlg.setTarget(tgt);
- dlg.setFieldValue("country","US");
- content = dlg;
-
- } // end else
+ // display the "Create Account" dialog
+ NewAccountDialog dlg = makeNewAccountDialog();
+ dlg.setEngine(engine);
+ dlg.setTarget(tgt);
+ dlg.setFieldValue("country","US");
+ return dlg;
} // end if ("C" command)
- else if (cmd.equals("P"))
+
+ if (cmd.equals("P"))
{ // "P" = user profile
- if (user.isLoggedIn())
- { // display the User Profile page
- EditProfileDialog dlg = makeEditProfileDialog();
- try
- { // load the profile information
- dlg.setupDialog(user,tgt);
+ if (!(user.isLoggedIn())) // you have to be logged in for this one!
+ 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();
+ try
+ { /// set up the profile information for the dialog
+ dlg.setupDialog(user,tgt);
- // prepare for display
- page_title = dlg.getTitle();
- content = dlg;
+ } // end try
+ catch (DataException e)
+ { // unable to load the contact info for the profile
+ return new ErrorBox("Database Error","Database error retrieving profile: " + e.getMessage(),tgt);
- } // end try
- catch (DataException e)
- { // we couldn't load the contact info for the profile
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error retrieving profile: " + e.getMessage(),tgt);
+ } // end catch
- } // end catch
-
- } // 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 modify the profile "
- + "on your account.",tgt);
-
- } // end else
+ return dlg; // display dialog
} // end if ("P" command)
- else if (cmd.equals("V"))
+
+ if (cmd.equals("V"))
{ // "V" = verify email address
- display_login = true;
-
- if (user.isLoggedIn())
- { // 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 "
+ setDisplayLogins(request);
+ if (!(user.isLoggedIn())) // you have to be logged in for this one!
+ return new ErrorBox("Error","You must log in before you can verify your account's "
+ "email address.",tgt);
- } // end else
+ // display the "verify email" dialog
+ VerifyEmailDialog dlg = makeVerifyEmailDialog();
+ dlg.setTarget(tgt);
+ return dlg;
- } // end else if ("V" command)
- else
- { // unknown command
- page_title = "Internal Error";
- logger.error("invalid command to Account.doGet: " + cmd);
- content = new ErrorBox(page_title,"Invalid command to Account.doGet",tgt);
+ } // end if ("V" command)
- } // end else
+ // command not found!
+ logger.error("invalid command to Account.doGet: " + cmd);
+ return new ErrorBox("Internal Error","Invalid command to Account.doGet",tgt);
- BaseJSPData basedat = new BaseJSPData(page_title,"account?cmd=" + cmd,content);
- basedat.displayLoginLinks(display_login);
- basedat.transfer(getServletContext(),rdat);
+ } // end doVeniceGet
- } // end doGet
-
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
+ protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
+ UserContext user, RenderData rdat)
+ throws ServletException, IOException, VeniceServletResult
{
- RenderData rdat = createRenderData(request,response);
- UserContext user = getUserContext(request);
- String page_title = null;
- ContentRender content = null;
- boolean display_login = false;
-
+ changeMenuTop(request); // this is "top" menus
String tgt = request.getParameter("tgt"); // target location
if (tgt==null)
- tgt = "top"; // go back to Top screen if nothing else
- String cmd = request.getParameter("cmd"); // command parameter
+ tgt = "top"; // go back to the Top screen if nothing else
+ String cmd = getStandardCommandParam(request);
if (cmd.equals("L"))
- { // log the user in
+ { // "L" = login the user
LoginDialog dlg = makeLoginDialog();
if (dlg.isButtonClicked(request,"cancel"))
- { // go back where we came from - we decided not to log in anyhoo
- rdat.redirectTo(tgt);
- return;
-
- } // end if (canceled)
+ throw new RedirectResult(tgt); // we decided not to log in - go back where we came from
if (dlg.isButtonClicked(request,"remind"))
{ // this will email a password reminder to the owner's account
dlg.loadValues(request); // load the dialog values
+
try
{ // send the password reminder
- getVeniceEngine().sendPasswordReminder(dlg.getFieldValue("user"));
+ engine.sendPasswordReminder(dlg.getFieldValue("user"));
// recycle and redisplay the dialog box
dlg.resetOnError("Password reminder has been sent to your e-mail address.");
- page_title = dlg.getTitle();
- content = dlg;
} // end try
- catch (DataException e1)
- { // this indicates a database error - display an ErrorBox
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error finding user: " + e1.getMessage(),tgt);
+ catch (DataException de)
+ { // there was a database error finding your email address
+ return new ErrorBox("Database Error","Database error finding user: " + de.getMessage(),tgt);
} // end catch
- catch (AccessError e2)
+ catch (AccessError ae)
{ // this indicates a problem with the user account or password
- page_title = "User E-mail Address Not Found";
- content = new ErrorBox(page_title,e2.getMessage(),tgt);
+ return new ErrorBox("User E-mail Address Not Found",ae.getMessage(),tgt);
} // end catch
catch (EmailException ee)
{ // error sending the confirmation email
- page_title = "E-mail Error";
- content = new ErrorBox(page_title,"E-mail error sending reminder: " + ee.getMessage(),tgt);
+ return new ErrorBox("E-mail Error","E-mail error sending reminder: " + ee.getMessage(),tgt);
} // end catch
- } // end if ("reminder" button clicked)
- else if (dlg.isButtonClicked(request,"login"))
+ return dlg; // redisplay the dialog
+
+ } // end if ("remind" button clicked)
+
+ if (dlg.isButtonClicked(request,"login"))
{ // we actually want to try and log in! imagine that!
dlg.loadValues(request); // load the values
@@ -313,123 +289,96 @@ public class Account extends VeniceServlet
// assuming it worked OK, redirect them back where they came from
// (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);
- rdat.redirectTo(url);
- return;
+ if (user.isEmailVerified())
+ 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
- catch (DataException e1)
+ catch (DataException de)
{ // this indicates a database error - display an ErrorBox
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error logging in: " + e1.getMessage(),tgt);
+ return new ErrorBox("Database Error","Database error logging in: " + de.getMessage(),tgt);
} // end catch
- catch (AccessError e2)
+ catch (AccessError ae)
{ // this indicates a problem with the user account or password
- dlg.resetOnError(e2.getMessage());
- page_title = dlg.getTitle();
- content = dlg;
+ dlg.resetOnError(ae.getMessage());
} // end catch
- } // end else if ("login" button clicked)
- 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);
+ return dlg; // go back and redisplay the dialog
- } // 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)
- else if (cmd.equals("C"))
- { // C = Create New Account
+
+ if (cmd.equals("C"))
+ { // "C" = Create New Account
NewAccountDialog dlg = makeNewAccountDialog();
- dlg.setEngine(getVeniceEngine());
+ dlg.setEngine(engine);
if (dlg.isButtonClicked(request,"cancel"))
- { // go back where we came from - we decided not to create the account anyhoo
- String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
- response.sendRedirect(url);
- return;
-
- } // end if ("cancel" button clicked)
+ throw new RedirectResult(tgt); // we decided not to create account - go back where we came from
if (dlg.isButtonClicked(request,"create"))
{ // OK, actually want to create the account!
dlg.loadValues(request); // load field values
-
+
try
{ // attempt to create the account
UserContext uc = dlg.doDialog(request);
putUserContext(request,uc); // effectively logging in the new user
- user = uc;
// now jump to the Verify page
- String partial = "account?cmd=V&tgt=" + URLEncoder.encode(tgt);
- String url = response.encodeRedirectURL(rdat.getFullServletPath(partial));
- response.sendRedirect(url);
- return;
+ throw new RedirectResult("account?cmd=V&tgt=" + URLEncoder.encode(tgt));
} // end try
catch (ValidationException ve)
{ // unable to validate some of the data in the form
dlg.resetOnError(ve.getMessage() + " Please try again.");
- page_title = dlg.getTitle();
- content = dlg;
} // end catch
catch (DataException de)
{ // data error in setting up account
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error creating account: " + de.getMessage(),tgt);
+ return new ErrorBox("Database Error","Database error creating account: " + de.getMessage(),tgt);
} // end catch
catch (AccessError ae)
{ // access error in setting up the account
dlg.resetOnError(ae.getMessage());
- page_title = dlg.getTitle();
- content = dlg;
} // end catch
catch (EmailException ee)
{ // error sending the confirmation email
- page_title = "E-mail Error";
- content = new ErrorBox(page_title,"E-mail error creating account: " + ee.getMessage(),tgt);
+ return new ErrorBox("E-mail Error","E-mail error creating account: " + ee.getMessage(),tgt);
} // end catch
- } // end if ("create" button clicked)
- else
- { // the button must be wrong!
- page_title = "Internal Error";
- logger.error("no known button click on Account.doPost, cmd=C");
- content = new ErrorBox(page_title,"Unknown command button pressed",tgt);
+ return dlg; // redisplay me
- } // end else
+ } // end if ("create" button pressed)
- } // end else if ("C" command)
- else if (cmd.equals("V"))
- { // V = Verify E-mail Address
- display_login = true;
+ // the button must be wrong!
+ logger.error("no known button click on Account.doPost, cmd=C");
+ return new ErrorBox("Internal Error","Unknown command button pressed",tgt);
+
+ } // end if ("C" command)
+
+ if (cmd.equals("V"))
+ { // "V" = Verify E-mail Address
+ setDisplayLogins(request);
VerifyEmailDialog dlg = makeVerifyEmailDialog();
if (dlg.isButtonClicked(request,"cancel"))
- { // go back to our desired location
- String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
- response.sendRedirect(url);
- return;
-
- } // end if ("cancel" button clicked)
+ throw new RedirectResult(tgt); // we decided not to bother - go back where we came from
if (dlg.isButtonClicked(request,"again"))
- { // do a "send again"
+ { // send the confirmation message again
try
{ // resend the email confirmation
user.resendEmailConfirmation();
@@ -437,25 +386,24 @@ public class Account extends VeniceServlet
// now force the form to be redisplayed
dlg.clearAllFields();
dlg.setTarget(tgt);
- page_title = dlg.getTitle();
- content = dlg;
} // end try
catch (DataException de)
- { // data error in setting up account
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error sending confirmation: " + de.getMessage(),tgt);
+ { // database error resending confirmation
+ return new ErrorBox("Database Error","Database error sending confirmation: " + de.getMessage(),tgt);
} // end catch
catch (EmailException ee)
{ // error sending the confirmation email
- page_title = "E-mail Error";
- content = new ErrorBox(page_title,"E-mail error sending confirmation: " + ee.getMessage(),tgt);
+ return new ErrorBox("E-mail Error","E-mail error sending confirmation: " + ee.getMessage(),tgt);
} // end catch
- } // end if ("again" clicked)
- else if (dlg.isButtonClicked(request,"ok"))
+ return dlg; // redisplay the dialog
+
+ } // end if ("again" button clicked)
+
+ if (dlg.isButtonClicked(request,"ok"))
{ // try to verify the confirmation number
dlg.loadValues(request); // load field values
@@ -465,119 +413,85 @@ public class Account extends VeniceServlet
user.confirmEmail(dlg.getConfirmationNumber());
// go back to our desired location
- String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
- response.sendRedirect(url);
- return;
+ throw new RedirectResult(tgt);
} // end try
catch (ValidationException ve)
{ // there was a validation error...
dlg.resetOnError(ve.getMessage() + " Please try again.");
- page_title = dlg.getTitle();
- content = dlg;
} // end catch
catch (DataException de)
- { // data error in setting up account
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error verifying email: " + de.getMessage(),tgt);
+ { // data error in confirming account
+ return new ErrorBox("Database Error","Database error verifying email: " + de.getMessage(),tgt);
} // end catch
catch (AccessError ae)
- { // access error in setting up the account
+ { // invalid confirmation number, perhaps?
dlg.resetOnError(ae.getMessage());
- page_title = dlg.getTitle();
- content = dlg;
} // end catch
- } // end else if ("OK" clicked)
- else
- { // the button must be wrong!
- page_title = "Internal Error";
- logger.error("no known button click on Account.doPost, cmd=V");
- content = new ErrorBox(page_title,"Unknown command button pressed",tgt);
+ return dlg; // redisplay the dialog
- } // end else
+ } // end if ("ok" button clicked)
- } // end else if ("V" command)
- else if (cmd.equals("P"))
- { // P = Edit User Profile
- display_login = true;
+ // the button must be wrong!
+ logger.error("no known button click on Account.doPost, cmd=V");
+ return new ErrorBox("Internal Error","Unknown command button pressed",tgt);
+
+ } // end if ("V" command)
+
+ if (cmd.equals("P"))
+ { // "P" = Edit User Profile
+ setDisplayLogins(request);
EditProfileDialog dlg = makeEditProfileDialog();
if (dlg.isButtonClicked(request,"cancel"))
- { // go back to our desired location
- String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
- response.sendRedirect(url);
- return;
-
- } // end if ("cancel" button clicked)
+ throw new RedirectResult(tgt); // we decided not to bother - go back where we came from
if (dlg.isButtonClicked(request,"update"))
{ // we're ready to update the user profile
dlg.loadValues(request); // load field values
try
- { // validate the dialog and start setting info
- String url;
- if (dlg.doDialog(user))
- { // the email address was changed - need to jump to the "Verify" page
- String partial = "account?cmd=V&tgt=" + URLEncoder.encode(tgt);
- 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;
+ { // validate the dialog and reset profile info
+ if (dlg.doDialog(user)) // need to reconfirm email address
+ throw new RedirectResult("account?cmd=V&tgt=" + URLEncoder.encode(tgt));
+ else
+ throw new RedirectResult(tgt); // just go straight on back
} // end try
catch (ValidationException ve)
{ // there was a validation error...
dlg.resetOnError(ve.getMessage() + " Please try again.");
- page_title = dlg.getTitle();
- content = dlg;
} // end catch
catch (DataException de)
- { // data error in setting up account
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error updating profile: " + de.getMessage(),tgt);
+ { // data error in changing profile
+ return new ErrorBox("Database Error","Database error updating profile: " + de.getMessage(),tgt);
} // end catch
catch (EmailException ee)
{ // error sending the confirmation email
- page_title = "E-mail Error";
- content = new ErrorBox(page_title,"E-mail error sending confirmation: " + ee.getMessage(),tgt);
+ return new ErrorBox("E-mail Error","E-mail error sending confirmation: " + ee.getMessage(),tgt);
} // end catch
- } // end if ("update" button pressed)
- else
- { // the button must be wrong!
- page_title = "Internal Error";
- logger.error("no known button click on Account.doPost, cmd=P");
- content = new ErrorBox(page_title,"Unknown command button pressed",tgt);
+ return dlg; // redisplay dialog
- } // end else
+ } // end if ("update" button clicked)
- } // end else if ("P" command)
- else
- { // unknown command
- page_title = "Internal Error";
- logger.error("invalid command to Account.doPost: " + cmd);
- content = new ErrorBox(page_title,"Invalid command to Account.doPost",tgt);
+ // the button must be wrong!
+ logger.error("no known button click on Account.doPost, cmd=P");
+ return new ErrorBox("Internal Error","Unknown command button pressed",tgt);
- } // end else
+ } // end if
- changeMenuTop(request);
+ // unknown command
+ logger.error("invalid command to Account.doPost: " + cmd);
+ return new ErrorBox("Internal Error","Invalid command to Account.doPost",tgt);
- BaseJSPData basedat = new BaseJSPData(page_title,"account?cmd=" + cmd,content);
- basedat.displayLoginLinks(display_login);
- basedat.transfer(getServletContext(),rdat);
-
- } // end doPost
+ } // end doVenicePost
} // end class Account
diff --git a/src/com/silverwrist/venice/servlets/Attachment.java b/src/com/silverwrist/venice/servlets/Attachment.java
index 8ef7acd..b9aa73a 100644
--- a/src/com/silverwrist/venice/servlets/Attachment.java
+++ b/src/com/silverwrist/venice/servlets/Attachment.java
@@ -22,10 +22,8 @@ import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
-import com.silverwrist.util.StringUtil;
import com.silverwrist.util.ServletMultipartHandler;
import com.silverwrist.util.ServletMultipartException;
-import com.silverwrist.venice.ValidationException;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.servlets.format.*;
@@ -38,135 +36,6 @@ public class Attachment extends VeniceServlet
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
*--------------------------------------------------------------------------------
@@ -180,248 +49,101 @@ public class Attachment extends VeniceServlet
} // 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 page_title = null;
- Object content = null;
- SIGContext sig = null; // SIG context
- ConferenceContext conf = null; // conference context
- TopicMessageContext msg = null; // message context
+ // get the SIG
+ SIGContext sig = getSIGParameter(request,user,true,"top");
+ changeMenuSIG(request,sig);
+
+ // get the conference
+ ConferenceContext conf = getConferenceParameter(request,sig,true,"top");
+
+ // get the message we want to use
+ TopicMessageContext msg = getMessageParameter(request,conf,true,"top");
+
+ String type, filename;
+ int length;
+ InputStream data;
try
- { // this outer try is to catch ValidationException
- try
- { // all commands require a SIG parameter
- sig = getSIGParameter(request,user);
- changeMenuSIG(request,sig);
- if (logger.isDebugEnabled())
- logger.debug("found SIG #" + String.valueOf(sig.getSIGID()));
-
- } // 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(),"top");
-
- } // 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()));
-
- } // 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
+ { // retrieve the information about the attachment
+ type = msg.getAttachmentType();
+ filename = msg.getAttachmentFilename();
+ length = msg.getAttachmentLength();
+ data = msg.getAttachmentData();
} // 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");
+ { // unable to access the data stream
+ return new ErrorBox("Access Error",ae.getMessage(),"top");
+
+ } // end catch
+ catch (DataException de)
+ { // error getting at the data stream from the attachment
+ return new ErrorBox("Database Error","Database error retrieving attachment: " + de.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!
+ // now we want to send that data back to the user!
+ throw new SendFileResult(type,filename,length,data);
- } // end try
- 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 doVeniceGet
- } // end catch
- catch (DataException de)
- { // error looking up the conference
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error retrieving attachment: " + de.getMessage(),"top");
-
- } // end catch
-
- } // end if
-
- // we only get here if there were an error
- BaseJSPData basedat = new BaseJSPData(page_title,"top",content);
- basedat.transfer(getServletContext(),rdat);
-
- } // end doGet
-
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
+ protected VeniceContent doVenicePost(HttpServletRequest request, ServletMultipartHandler mphandler,
+ VeniceEngine engine, UserContext user, RenderData rdat)
+ throws ServletException, IOException, VeniceServletResult
{
- UserContext user = getUserContext(request);
- 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
+ // Get target URL for the operation
+ if (mphandler.isFileParam("target"))
+ return new ErrorBox(null,"Internal Error: 'target' should be a normal param","top");
+ String target = mphandler.getValue("target");
+ setMyLocation(request,target);
+
+ // also check on file parameter status
+ if (!(mphandler.isFileParam("thefile")))
+ 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);
+
+ // get the conference
+ ConferenceContext conf = getConferenceParameter(request,sig,true,"top");
+
+ // get the message we want to use
+ TopicMessageContext msg = getMessageParameter(request,conf,true,"top");
try
- { // this outer try is to catch ValidationException
- mphandler = new ServletMultipartHandler(request);
-
- if (mphandler.isFileParam("target"))
- throw new ValidationException("Internal Error: 'target' should be a normal param");
- target = mphandler.getValue("target");
-
- try
- { // 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")))
- throw new ValidationException("Internal error: 'thefile' should be a file param");
-
+ { // attach the data to the message!
+ msg.attachData(mphandler.getContentType("thefile"),mphandler.getValue("thefile"),
+ mphandler.getContentSize("thefile"),mphandler.getFileContentStream("thefile"));
} // end try
- catch (ValidationException ve)
- { // these all get handled in pretty much the same way
- page_title = "Error";
- content = new ErrorBox(null,ve.getMessage(),target);
-
- } // 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(),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);
+ { // error processing the file parameter data
+ return new ErrorBox(null,"Internal Error: " + smpe.getMessage(),target);
+
+ } // end catch
+ catch (AccessError ae)
+ { // access error posting the attachment data
+ return new ErrorBox("Access Error",ae.getMessage(),target);
+
+ } // end catch
+ catch (DataException de)
+ { // error storing the attachment in the database
+ return new ErrorBox("Database Error","Database error storing attachment: " + de.getMessage(),target);
} // end catch
- if (content==null)
- { // we're ready to get the data and attach it
- try
- { // attach the data to the message!
- msg.attachData(mphandler.getContentType("thefile"),mphandler.getValue("thefile"),
- mphandler.getContentSize("thefile"),mphandler.getFileContentStream("thefile"));
+ throw new RedirectResult(target); // get back, get back, get back to where you once belonged
- // go back to where we should have gone before we uploaded the message
- rdat.redirectTo(target);
- return;
-
- } // end try
- 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
- catch (AccessError ae)
- { // 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 (DataException de)
- { // error looking up the conference
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error storing attachment: " + de.getMessage(),target);
-
- } // end catch
-
- } // end if (we got all the parameters OK)
-
- // we only get here if there were an error
- BaseJSPData basedat = new BaseJSPData(page_title,target,content);
- basedat.transfer(getServletContext(),rdat);
-
- } // end doPost
+ } // end doVenicePost
} // end class Attachment
diff --git a/src/com/silverwrist/venice/servlets/ConfDisplay.java b/src/com/silverwrist/venice/servlets/ConfDisplay.java
index f79f458..8559b47 100644
--- a/src/com/silverwrist/venice/servlets/ConfDisplay.java
+++ b/src/com/silverwrist/venice/servlets/ConfDisplay.java
@@ -82,82 +82,8 @@ public class ConfDisplay 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 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
+ private static void getViewSortDefaults(ServletRequest request, int confid, TopicSortHolder tsc,
+ String on_error) throws ErrorBox
{
String str = request.getParameter("view");
if (!(StringUtil.isStringEmpty(str)))
@@ -176,7 +102,7 @@ public class ConfDisplay extends VeniceServlet
break;
default:
- throw new ValidationException("Invalid view parameter.");
+ throw new ErrorBox(null,"Invalid view parameter.",on_error);
} // end switch
@@ -184,7 +110,7 @@ public class ConfDisplay extends VeniceServlet
catch (NumberFormatException nfe)
{ // failure in parseInt
logger.error("Cannot convert view parameter '" + str + "'!");
- throw new ValidationException("Invalid view parameter.");
+ throw new ErrorBox(null,"Invalid view parameter.",on_error);
} // end catch
@@ -208,7 +134,7 @@ public class ConfDisplay extends VeniceServlet
break;
default:
- throw new ValidationException("Invalid sort parameter.");
+ throw new ErrorBox(null,"Invalid sort parameter.",on_error);
} // end switch
@@ -216,7 +142,7 @@ public class ConfDisplay extends VeniceServlet
catch (NumberFormatException nfe)
{ // failure in parseInt
logger.error("Cannot convert sort parameter '" + str + "'!");
- throw new ValidationException("Invalid sort parameter.");
+ throw new ErrorBox(null,"Invalid sort parameter.",on_error);
} // end catch
@@ -224,8 +150,8 @@ public class ConfDisplay extends VeniceServlet
} // end getViewSortDefaults
- private static PostInterval getInterval(VeniceEngine engine, ServletRequest request, TopicContext topic)
- throws ValidationException
+ private static PostInterval getInterval(VeniceEngine engine, ServletRequest request, TopicContext topic,
+ String on_error) throws ErrorBox
{
int first, last;
@@ -294,7 +220,7 @@ public class ConfDisplay extends VeniceServlet
} // end try
catch (NumberFormatException nfe)
{ // 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
@@ -312,7 +238,7 @@ public class ConfDisplay extends VeniceServlet
} // end try
catch (NumberFormatException nfe)
{ // 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
@@ -403,178 +329,94 @@ public class ConfDisplay extends VeniceServlet
} // end getServletInfo
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
- {
- 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
- TopicContext topic = null; // topic context
+ /*--------------------------------------------------------------------------------
+ * Overrides from class VeniceServlet
+ *--------------------------------------------------------------------------------
+ */
- try
- { // this outer try is to catch ValidationException
+ protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
+ UserContext user, RenderData rdat)
+ throws ServletException, IOException, VeniceServletResult
+ {
+ // get the SIG
+ SIGContext sig = getSIGParameter(request,user,true,"top");
+ changeMenuSIG(request,sig);
+
+ // get the conference
+ ConferenceContext conf = getConferenceParameter(request,sig,true,"top");
+
+ // get the topic, if we have it
+ TopicContext topic = getTopicParameter(request,conf,false,"top");
+
+ if (topic!=null)
+ { // we're handling messages within a single topic
+ if (logger.isDebugEnabled())
+ 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
+ restorePosts(request,conf);
+
+ // determine what the post interval is we want to display
+ PostInterval piv = getInterval(engine,request,topic,on_error);
+ boolean read_new = !(StringUtil.isStringEmpty(request.getParameter("rnm")));
+ boolean show_adv = !(StringUtil.isStringEmpty(request.getParameter("shac")));
+
+ // Create the post display.
+ TopicPosts tpos = null;
try
- { // all commands require a SIG parameter
- sig = getSIGParameter(request,user);
- changeMenuSIG(request,sig);
- if (logger.isDebugEnabled())
- logger.debug("found SIG #" + String.valueOf(sig.getSIGID()));
+ { // create the display
+ tpos = new TopicPosts(request,engine,sig,conf,topic,piv.getFirst(),piv.getLast(),read_new,show_adv);
} // 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(),"top");
+ { // there was a database error retrieving messages
+ return new ErrorBox("Database Error","Database error listing messages: " + de.getMessage(),on_error);
+
+ } // end catch
+ catch (AccessError ae)
+ { // we were unable to retrieve the message list
+ return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // 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()));
-
- } // 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");
+ return tpos;
- } // end catch
+ } // end if (messages in a topic)
+ else
+ { // we're displaying the conference's topic list
+ if (logger.isDebugEnabled())
+ logger.debug("MODE: display topics in conference");
+ setMyLocation(request,"confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID());
+ String on_error = "confops?sig=" + sig.getSIGID();
- } // end if
+ // get any changes to view or sort options
+ TopicSortHolder opts = TopicSortHolder.retrieve(request.getSession(true));
+ getViewSortDefaults(request,conf.getConfID(),opts,on_error);
- 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");
+ TopicListing tl = null;
+ try
+ { // create the topic lict
+ tl = new TopicListing(request,sig,conf,opts.getViewOption(conf.getConfID()),
+ opts.getSortOption(conf.getConfID()));
- } // end if
+ } // end try
+ catch (DataException de)
+ { // there was a database error retrieving topics
+ return new ErrorBox("Database Error","Database error listing topics: " + de.getMessage(),on_error);
- } // 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
+ catch (AccessError ae)
+ { // we were unable to retrieve the topic list
+ return new ErrorBox("Access Error",ae.getMessage(),on_error);
- } // end catch
+ } // end catch
- } // end if
+ return tl;
- } // 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 else (topics in a conference)
- } // 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)
- { // we're handling messages within a single topic
- if (logger.isDebugEnabled())
- logger.debug("MODE: display messages in topic");
-
- // if this request is restoring the number of unread posts in another topic, try to do so
- restorePosts(request,conf);
-
- try
- { // determine what the post interval is we want to display
- VeniceEngine engine = getVeniceEngine();
- PostInterval piv = getInterval(engine,request,topic);
- boolean read_new = !(StringUtil.isStringEmpty(request.getParameter("rnm")));
- boolean show_adv = !(StringUtil.isStringEmpty(request.getParameter("shac")));
-
- // create the post display
- TopicPosts tpos = new TopicPosts(request,engine,sig,conf,topic,piv.getFirst(),piv.getLast(),
- read_new,show_adv);
- content = tpos;
- page_title = topic.getName() + ": " + String.valueOf(topic.getTotalMessages()) + " Total; "
- + String.valueOf(tpos.getNewMessages()) + " New; Last: "
- + rdat.formatDateForDisplay(topic.getLastUpdateDate());
-
- } // 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)
- { // there was a database error retrieving topics
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error listing messages: " + 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 if
- else
- { // we're displaying the conference's topic list
- if (logger.isDebugEnabled())
- logger.debug("MODE: display topics in conference");
-
- TopicSortHolder opts = TopicSortHolder.retrieve(request.getSession(true));
- try
- { // get any changes to view or sort options
- getViewSortDefaults(request,conf.getConfID(),opts);
-
- // create the topic list
- content = new TopicListing(request,sig,conf,opts.getViewOption(conf.getConfID()),
- opts.getSortOption(conf.getConfID()));
- page_title = "Topics in " + conf.getName();
-
- } // 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 retrieving topics
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error listing topics: " + 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
-
- } // end if
-
- BaseJSPData basedat = new BaseJSPData(page_title,"confdisp?" + request.getQueryString(),content);
- basedat.transfer(getServletContext(),rdat);
-
- } // end doGet
+ } // end doVeniceGet
} // end class ConfDisplay
diff --git a/src/com/silverwrist/venice/servlets/ConfOperations.java b/src/com/silverwrist/venice/servlets/ConfOperations.java
index 999c32d..e82537e 100644
--- a/src/com/silverwrist/venice/servlets/ConfOperations.java
+++ b/src/com/silverwrist/venice/servlets/ConfOperations.java
@@ -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
{
final String desired_name = "CreateConferenceDialog";
@@ -108,22 +56,22 @@ public class ConfOperations extends VeniceServlet
} // 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;
String foo = request.getParameter("title");
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);
foo = request.getParameter("pseud");
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");
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);
return is_title_null || is_zp_null;
@@ -143,375 +91,256 @@ public class ConfOperations extends VeniceServlet
} // end getServletInfo
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
- {
- UserContext user = getUserContext(request);
- RenderData rdat = createRenderData(request,response);
- String page_title = null;
- Object content = null;
- SIGContext sig = null;
+ /*--------------------------------------------------------------------------------
+ * Overrides from class VeniceServlet
+ *--------------------------------------------------------------------------------
+ */
+ protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
+ UserContext user, RenderData rdat)
+ throws ServletException, IOException, VeniceServletResult
+ {
+ // get the SIG
+ SIGContext sig = getSIGParameter(request,user,true,"top");
+ changeMenuSIG(request,sig);
+ String on_error = "confops?sig=" + sig.getSIGID();
+
+ // get the command we want to use
+ String cmd = getStandardCommandParam(request);
+
+ if (cmd.equals("C"))
+ { // "C" = "Create conference"
+ if (!(sig.canCreateConference()))
+ return new ErrorBox("Access Error","You are not permitted to create conferences in this SIG.",
+ on_error);
+
+ // make the "create" dialog
+ CreateConferenceDialog dlg = makeCreateConferenceDialog();
+ dlg.setupDialog(engine,sig);
+ setMyLocation(request,on_error + "&cmd=C");
+ return dlg;
+
+ } // end if ("C" command)
+
+ if (cmd.equals("T"))
+ { // "T" = "Create topic" (requires conference parameter)
+ ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
+ on_error = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
+
+ // Create the new topic form.
+ NewTopicForm ntf = new NewTopicForm(sig,conf);
+ ntf.setupNewRequest();
+ setMyLocation(request,"confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=T");
+ 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
+ catch (DataException de)
+ { // some sort of error in the database
+ return new ErrorBox("Database Error","Database error catching up conference: " + de.getMessage(),
+ on_error);
+
+ } // end catch
+
+ return null; // null response here
+
+ } // end if ("FX" command)
+
+ // Any unrecognized command shows us the conference list.
+ on_error = "sigprofile?sig=" + sig.getSIGID();
try
- { // all conference commands require a SIG parameter as well
- sig = getSIGParameter(request,user);
- changeMenuSIG(request,sig);
+ { // make a conference listing
+ setMyLocation(request,"confops?sig=" + sig.getSIGID());
+ return new ConferenceListing(sig);
} // end try
- catch (ValidationException ve)
- { // 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");
+ { // something wrong in the database
+ return new ErrorBox("Database Error","Database error finding conferences: " + de.getMessage(),on_error);
+
+ } // end catch
+ catch (AccessError ae)
+ { // some lack of access is causing problems
+ return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
- if (content==null)
- { // get the command we want to use
- String cmd = request.getParameter("cmd");
- if (cmd==null)
- cmd = "???";
+ } // end doVeniceGet
- if (cmd.equals("C"))
- { // "C" = "Create conference"
- if (sig.canCreateConference())
- { // make the create conference dialog!
- CreateConferenceDialog dlg = makeCreateConferenceDialog();
- dlg.setupDialog(getVeniceEngine(),sig);
- content = dlg;
- page_title = dlg.getTitle();
+ protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
+ UserContext user, RenderData rdat)
+ throws ServletException, IOException, VeniceServletResult
+ {
+ // get the SIG
+ SIGContext sig = getSIGParameter(request,user,true,"top");
+ changeMenuSIG(request,sig);
+ String on_error = "confops?sig=" + sig.getSIGID();
- } // 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.","top");
+ // get the command we want to use
+ String cmd = getStandardCommandParam(request);
- } // end else
+ if (cmd.equals("C"))
+ { // "C" = "Create Conference"
+ if (!(sig.canCreateConference()))
+ 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();
+ dlg.setupDialog(engine,sig);
+
+ if (dlg.isButtonClicked(request,"cancel"))
+ throw new RedirectResult(on_error); // they chickened out - go back to the conference list
+
+ if (dlg.isButtonClicked(request,"create"))
+ { // OK, they actually want to create the new conference...
+ dlg.loadValues(request); // load the form data
- } // end if
- else if (cmd.equals("T"))
- { // "T" = "Create topic" (requires conference parameter)
try
- { // start by getting the conference parameter
- ConferenceContext conf = getConferenceParameter(request,sig);
+ { // attempt to create the conference!
+ ConferenceContext conf = dlg.doDialog(sig);
- // create the New Topic form
- NewTopicForm ntf = new NewTopicForm(sig,conf);
- ntf.setupNewRequest();
- content = ntf;
- page_title = "Create New Topic";
+ // success! redirect to the conference's topic list
+ throw new RedirectResult("confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID());
} // 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()));
+ { // validation error - throw it back to the user
+ dlg.resetOnError(ve.getMessage() + " Please try again.");
} // 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()));
+ { // some sort of access error - display an error dialog
+ return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // 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(),
- "sigprofile?sig=" + String.valueOf(sig.getSIGID()));
+ { // database error creating the conference
+ return new ErrorBox("Database Error","Database error creating conference: " + de.getMessage(),
+ on_error);
} // end catch
- } // end else
- else
- { // any unrecognized command jumps us to "conference list"
- try
- { // show the conference listing
- content = new ConferenceListing(sig);
- page_title = "Conference Listing: " + sig.getName();
+ setMyLocation(request,on_error + "&cmd=C");
+ return dlg; // redisplay the dialog
- } // end try
- catch (DataException de)
- { // something wrong in the database
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error finding conferences: " + de.getMessage(),
- "sigprofile?sig=" + String.valueOf(sig.getSIGID()));
+ } // end if ("create" button clicked)
- } // end catch
- catch (AccessError ae)
- { // some lack of access is causing problems
- page_title = "Access Error";
- content = new ErrorBox(page_title,ae.getMessage(),
- "sigprofile?sig=" + String.valueOf(sig.getSIGID()));
+ // error - don't know what button was clicked
+ logger.error("no known button click on ConfOperations.doPost, cmd=C");
+ return new ErrorBox("Internal Error","Unknown command button pressed",on_error);
- } // end catch
+ } // end if ("C" command)
- } // end else
+ if (cmd.equals("T"))
+ { // "T" command = Create New Topic (requires conference parameter)
+ ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
+ on_error = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
- } // end if (SIG parameter retrieved OK)
+ // determine what to do based on the button pressed
+ if (isImageButtonClicked(request,"cancel"))
+ throw new RedirectResult(on_error); // the user chickened out - go back to the conference display
- BaseJSPData basedat = new BaseJSPData(page_title,"confops?" + request.getQueryString(),content);
- basedat.transfer(getServletContext(),rdat);
-
- } // 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;
- SIGContext sig = null;
- String location;
-
- try
- { // all conference commands require a SIG parameter as well
- sig = getSIGParameter(request,user);
- changeMenuSIG(request,sig);
- location = "confops?sig=" + String.valueOf(sig.getSIGID());
-
- } // end try
- catch (ValidationException ve)
- { // 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"))
- { // "C" = "Create Conference"
- if (sig.canCreateConference())
- { // load up the create conference dialog!
- CreateConferenceDialog dlg = makeCreateConferenceDialog();
- dlg.setupDialog(getVeniceEngine(),sig);
-
- if (dlg.isButtonClicked(request,"cancel"))
- { // they chickened out - go back to the conference list
- rdat.redirectTo(location);
- return;
-
- } // end if
-
- if (dlg.isButtonClicked(request,"create"))
- { // OK, they actually want to create the new conference...
- dlg.loadValues(request); // load the form data
-
- try
- { // attempt to create the conference!
- ConferenceContext conf = dlg.doDialog(sig);
-
- // success! go to the conference's topic list
- rdat.redirectTo("confdisp?sig=" + String.valueOf(sig.getSIGID()) + "&conf="
- + String.valueOf(conf.getConfID()));
- return;
-
- } // end try
- catch (ValidationException ve)
- { // validation error - throw it back to the user
- dlg.resetOnError(ve.getMessage() + " Please try again.");
- content = dlg;
- page_title = dlg.getTitle();
-
- } // end catch
- catch (AccessError ae)
- { // some sort of access error - display an error dialog
- page_title = "Access Error";
- content = new ErrorBox(page_title,ae.getMessage(),location);
-
- } // end catch
- catch (DataException de)
- { // database error creating the conference
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error creating conference: " + de.getMessage(),
- location);
-
- } // end catch
-
- } // end if
- else
- { // error - don't know what button was clicked
- page_title = "Internal Error";
- logger.error("no known button click on ConfOperations.doPost, cmd=C");
- content = new ErrorBox(page_title,"Unknown command button pressed",location);
-
- } // 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)
- else if (cmd.equals("T"))
- { // "T" command = Create New Topic (requires conference parameter)
- ConferenceContext conf = null;
+ if (isImageButtonClicked(request,"preview"))
+ { // generate a preview and redisplay the form
+ NewTopicForm ntf = new NewTopicForm(sig,conf);
try
- { // start by getting the conference parameter
- conf = getConferenceParameter(request,sig);
+ { // generate a preview display
+ ntf.generatePreview(engine,conf,request);
} // end try
catch (ValidationException ve)
- { // we can't get the conference parameter
- page_title = "Error";
- content = new ErrorBox(null,ve.getMessage(),location);
+ { // something messed up in the preview generation
+ return new ErrorBox(null,ve.getMessage(),on_error);
+
+ } // end catch
+
+ if (ntf.isNullRequest())
+ return null; // no title or text specified - "204 No Content"
+
+ 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
+ if (validateNewTopic(request,on_error))
+ return null; // this is a null request - send a null response
+
+ try
+ { // add the new topic!
+ TopicContext topic = conf.addTopic(request.getParameter("title"),request.getParameter("pseud"),
+ request.getParameter("pb"));
+
+ final String yes = "Y";
+ if (yes.equals(request.getParameter("attach")))
+ { // we need to upload an attachment for this post
+ setMyLocation(request,on_error);
+ return new AttachmentForm(sig,conf,topic.getMessage(0),on_error);
+
+ } // end if
+
+ } // end try
+ catch (DataException de)
+ { // display a database error
+ return new ErrorBox("Database Error","Database error adding topic: " + de.getMessage(),on_error);
} // 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);
+ { // some sort of access problem
+ return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // 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"))
- { // the user chickened out - go back to the conference display
- rdat.redirectTo(on_error);
- return;
+ // jump back to the form under normal circumstances
+ throw new RedirectResult(on_error);
- } // end if
+ } // end if ("post" clicked)
- if (isImageButtonClicked(request,"preview"))
- { // generate a preview and redisplay the form
- NewTopicForm ntf = new NewTopicForm(sig,conf);
+ // we don't know what button was pressed
+ logger.error("no known button click on ConfOperations.doPost, cmd=T");
+ return new ErrorBox("Internal Error","Unknown command button pressed",on_error);
- try
- { // do a preview generation
- ntf.generatePreview(getVeniceEngine(),conf,request);
+ } // end if ("T" command)
+
+ 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();
- if (ntf.isNullRequest())
- { // no title or text specified - this is a "204 No Content" return
- rdat.nullResponse();
- return;
+ // TODO: finish this later
- } // end if
+ return null;
- content = ntf;
- page_title = "Preview New Topic";
+ } // end if ("P" command)
- } // end try
- catch (ValidationException ve)
- { // something messed up in the preview generation
- page_title = "Error";
- content = new ErrorBox(null,ve.getMessage(),on_error);
+ // unrecognized command!
+ logger.error("invalid command to ConfOperations.doPost: " + cmd);
+ return new ErrorBox("Internal Error","Invalid command to ConfOperations.doPost",on_error);
- } // end catch
-
- } // end if ("preview" button clicked)
- else if (isImageButtonClicked(request,"post"))
- { // OK, let's do a post request!
- try
- { // first validate that we've got all the parameters
- if (validateNewTopic(request))
- { // this is a null request - send a null response
- rdat.nullResponse();
- return;
-
- } // end if
-
- // add the new topic!
- TopicContext topic = conf.addTopic(request.getParameter("title"),request.getParameter("pseud"),
- request.getParameter("pb"));
-
- final String yes = "Y";
- if (yes.equals(request.getParameter("attach")))
- { // we need to upload an attachment for this post
- TopicMessageContext msg = topic.getMessage(0); // load the "zero post"
-
- content = new AttachmentForm(sig,conf,msg,on_error);
- page_title = "Upload Attachment";
-
- } // 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
- catch (ValidationException ve)
- { // the validation of parameters failed
- page_title = "Error";
- content = new ErrorBox(null,ve.getMessage(),on_error);
-
- } // end catch
- catch (DataException de)
- { // display a database error
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error adding topic: " + de.getMessage(),on_error);
-
- } // end catch
- catch (AccessError ae)
- { // some sort of access problem
- page_title = "Access Error";
- content = new ErrorBox(page_title,ae.getMessage(),on_error);
-
- } // end catch
-
- } // end else if
- else
- { // we don't know what button was pressed
- page_title = "Internal Error";
- logger.error("no known button click on ConfOperations.doPost, cmd=T");
- content = new ErrorBox(page_title,"Unknown command button pressed",on_error);
-
- } // end else
-
- } // end if (we got the conference parameter OK)
-
- } // end else if ("T" command)
- else
- { // unrecognized command!
- page_title = "Internal Error";
- logger.error("invalid command to ConfOperations.doPost: " + cmd);
- content = new ErrorBox(page_title,"Invalid command to ConfOperations.doPost",location);
-
- } // end else
-
- } // end if (SIG parameter retrieved OK)
-
- BaseJSPData basedat = new BaseJSPData(page_title,location,content);
- basedat.transfer(getServletContext(),rdat);
-
- } // end doPost
+ } // end doVenicePost
} // end class ConfOperations
diff --git a/src/com/silverwrist/venice/servlets/ContentResult.java b/src/com/silverwrist/venice/servlets/ContentResult.java
new file mode 100644
index 0000000..b0f544b
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/ContentResult.java
@@ -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 .
+ *
+ * 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 ,
+ * 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
diff --git a/src/com/silverwrist/venice/servlets/ErrorResult.java b/src/com/silverwrist/venice/servlets/ErrorResult.java
new file mode 100644
index 0000000..57c402f
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/ErrorResult.java
@@ -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 .
+ *
+ * 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 ,
+ * 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
diff --git a/src/com/silverwrist/venice/servlets/ExecuteResult.java b/src/com/silverwrist/venice/servlets/ExecuteResult.java
new file mode 100644
index 0000000..40dccb9
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/ExecuteResult.java
@@ -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 .
+ *
+ * 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 ,
+ * 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
diff --git a/src/com/silverwrist/venice/servlets/Find.java b/src/com/silverwrist/venice/servlets/Find.java
index 8edb580..60f6aff 100644
--- a/src/com/silverwrist/venice/servlets/Find.java
+++ b/src/com/silverwrist/venice/servlets/Find.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@@ -75,7 +75,7 @@ public class Find extends VeniceServlet
} // end getDisplayParam
- private int getCategoryParam(ServletRequest request) throws ServletException
+ private int getCategoryParam(VeniceEngine engine, ServletRequest request)
{
String cat_str = request.getParameter("cat");
if (cat_str==null)
@@ -84,7 +84,7 @@ public class Find extends VeniceServlet
try
{ // get the category ID and check it for validity
int cat = Integer.parseInt(cat_str);
- if (getVeniceEngine().isValidCategoryID(cat))
+ if (engine.isValidCategoryID(cat))
return cat;
} // end try
@@ -109,86 +109,71 @@ public class Find extends VeniceServlet
} // end getServletInfo
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
- {
- UserContext user = getUserContext(request);
- RenderData rdat = createRenderData(request,response);
- String page_title = null;
- Object content = null;
+ /*--------------------------------------------------------------------------------
+ * Overrides from class VeniceServlet
+ *--------------------------------------------------------------------------------
+ */
+ 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
// figure out which page to display
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
int cat = -1;
if (disp==FindData.FD_SIGS)
- cat = getCategoryParam(request);
+ cat = getCategoryParam(engine,request);
try
{ // attempt to configure the display
finddata.loadGet(cat);
- // display the standard output
- page_title = "Find";
- content = finddata;
-
} // end try
catch (DataException de)
{ // database error, man
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error accessing category data: " + de.getMessage(),"top");
+ return new ErrorBox("Database Error","Database error accessing category data: " + de.getMessage(),"top");
} // end catch
- BaseJSPData basedat = new BaseJSPData(page_title,"find?" + request.getQueryString(),content);
- basedat.transfer(getServletContext(),rdat);
+ setMyLocation(request,"find?" + request.getQueryString());
+ return finddata;
- } // end doGet
+ } // end doVeniceGet
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
+ protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
+ 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
// figure out which page to display
int disp = getDisplayParam(request,FindData.getNumChoices());
- FindData finddata = new FindData(getVeniceEngine(),user,disp);
+ FindData finddata = new FindData(engine,user,disp);
try
{ // attempt to configure the display
finddata.loadPost(request);
- // display the standard output
- page_title = "Find";
- content = finddata;
-
} // end try
catch (ValidationException ve)
{ // error in find parameters
- page_title = "Find Error";
- content = new ErrorBox(null,ve.getMessage(),"top");
+ return new ErrorBox("Find Error",ve.getMessage(),"top");
} // end catch
catch (DataException de)
{ // database error, man
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error on find: " + de.getMessage(),"top");
+ return new ErrorBox("Database Error","Database error on find: " + de.getMessage(),"top");
} // end catch
- BaseJSPData basedat = new BaseJSPData(page_title,
- "find?disp=" + String.valueOf(finddata.getDisplayOption()),content);
- basedat.transfer(getServletContext(),rdat);
+ setMyLocation(request,"find?disp=" + finddata.getDisplayOption());
+ return finddata;
- } // end doPost
+ } // end doVenicePost
} // end class Find
diff --git a/src/com/silverwrist/venice/servlets/PostMessage.java b/src/com/silverwrist/venice/servlets/PostMessage.java
index 9d68c1e..1a61c25 100644
--- a/src/com/silverwrist/venice/servlets/PostMessage.java
+++ b/src/com/silverwrist/venice/servlets/PostMessage.java
@@ -41,89 +41,11 @@ public class PostMessage 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 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
+ private static int getPostNumber(ServletRequest request, String on_error) throws ErrorBox
{
String str = request.getParameter("sd");
if (StringUtil.isStringEmpty(str))
- throw new ValidationException("Invalid parameter.");
+ throw new ErrorBox(null,"Invalid parameter.",on_error);
try
{ // get the number of posts we think he topic has
return Integer.parseInt(str);
@@ -131,7 +53,7 @@ public class PostMessage extends VeniceServlet
} // end try
catch (NumberFormatException nfe)
{ // not a good integer...
- throw new ValidationException("Invalid parameter.");
+ throw new ErrorBox(null,"Invalid parameter.",on_error);
} // end catch
@@ -150,265 +72,108 @@ public class PostMessage extends VeniceServlet
} // end getServletInfo
- 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;
- SIGContext sig = null; // SIG context
- ConferenceContext conf = null; // conference context
- TopicContext topic = null; // topic context
+ /*--------------------------------------------------------------------------------
+ * Overrides from class VeniceServlet
+ *--------------------------------------------------------------------------------
+ */
+
+ protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
+ UserContext user, RenderData rdat)
+ throws ServletException, IOException, VeniceServletResult
+ {
+ // get the SIG
+ SIGContext sig = getSIGParameter(request,user,true,"top");
+ changeMenuSIG(request,sig);
+
+ // get the conference
+ ConferenceContext conf = getConferenceParameter(request,sig,true,"top");
+
+ // get the topic
+ TopicContext topic = getTopicParameter(request,conf,true,"top");
+
+ String on_error = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&top="
+ + topic.getTopicNumber();
+
+ // make sure we've got some post data
+ String raw_postdata = request.getParameter("pb");
+ if (StringUtil.isStringEmpty(raw_postdata))
+ return null; // don't allow zero-size posts
+
+ final String yes = "Y";
+
+ if (isImageButtonClicked(request,"cancel"))
+ throw new RedirectResult(on_error); // canceled posting - take us back
+
+ if (isImageButtonClicked(request,"preview")) // generate a preview
+ return new PostPreview(engine,sig,conf,topic,request.getParameter("pseud"),raw_postdata,
+ request.getParameter("next"),getPostNumber(request,on_error),
+ yes.equals(request.getParameter("attach")));
+
+ if (isImageButtonClicked(request,"post") || isImageButtonClicked(request,"postnext"))
+ { // post the message, and then either go back to the same topic or on to the next one
+ boolean go_next = isImageButtonClicked(request,"postnext");
+ int pn = getPostNumber(request,on_error);
- try
- { // this outer try is to catch ValidationException
try
- { // all commands require a SIG parameter
- sig = getSIGParameter(request,user);
- changeMenuSIG(request,sig);
- if (logger.isDebugEnabled())
- logger.debug("found SIG #" + String.valueOf(sig.getSIGID()));
+ { // first check for slippage
+ if (pn!=topic.getTotalMessages()) // slippage detected! display the slippage screen
+ return new PostSlippage(engine,sig,conf,topic,pn,request.getParameter("next"),
+ request.getParameter("pseud"),raw_postdata,
+ yes.equals(request.getParameter("attach")));
+
+ // post the darn thing!
+ TopicMessageContext msg = topic.postNewMessage(0,request.getParameter("pseud"),raw_postdata);
+
+ short next;
+ try
+ { // attempt to get the value of the "next topic" parameter
+ if (go_next)
+ { // get the "next topic" parameter
+ String foo = request.getParameter("next");
+ if (StringUtil.isStringEmpty(foo))
+ next = topic.getTopicNumber();
+ else
+ next = Short.parseShort(foo);
+
+ } // end if
+ else
+ next = topic.getTopicNumber();
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // just default me
+ next = topic.getTopicNumber();
+
+ } // 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")))
+ return new AttachmentForm(sig,conf,msg,target); // go to upload an attachment
+
+ // no attachment - redirect where we need to go
+ throw new RedirectResult(target);
} // 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(),"top");
+ { // there was a database error posting the message
+ return new ErrorBox("Database Error","Database error posting message: " + de.getMessage(),"top");
+
+ } // end catch
+ catch (AccessError ae)
+ { // we were unable to post the message
+ return new ErrorBox("Access Error",ae.getMessage(),"top");
} // 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()));
-
- } // 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 if
- } // end catch
+ // unknown button clicked
+ logger.error("no known button click on PostMessage.doPost");
+ return new ErrorBox("Internal Error","Unknown command button pressed","top");
- } // 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");
- if (StringUtil.isStringEmpty(raw_postdata))
- { // don't allow zero-size posts
- rdat.nullResponse();
- return;
-
- } // end if
-
- final String yes = "Y";
-
- // now decide what to do based on which button got clicked
- if (isImageButtonClicked(request,"cancel"))
- { // canceled posting - take us back to familiar ground
- rdat.redirectTo("confdisp?sig=" + String.valueOf(sig.getSIGID()) + "&conf="
- + String.valueOf(conf.getConfID()) + "&top="
- + String.valueOf(topic.getTopicNumber()));
- return;
-
- } // end if ("Cancel")
- else if (isImageButtonClicked(request,"preview"))
- { // previewing the post!
- 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")));
- page_title = "Previewing Post";
-
- } // end try
- catch (ValidationException ve)
- { // there was some sort of a parameter error in the display (getPostNumber can throw this)
- page_title = "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
- { // 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);
- 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,
- yes.equals(request.getParameter("attach")));
- page_title = "Slippage or Double-Click Detected";
-
- } // end else
-
- } // 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);
-
- short next;
- try
- { // attempt to get the value of the "next topic" parameter
- String foo = request.getParameter("next");
- if (StringUtil.isStringEmpty(foo))
- next = topic.getTopicNumber();
- else
- next = Short.parseShort(foo);
-
- } // end try
- catch (NumberFormatException nfe)
- { // just default me
- next = topic.getTopicNumber();
-
- } // end catch
-
- if (yes.equals(request.getParameter("attach")))
- { // we have an attachment to upload...
- // 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
- else
- { // 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
- 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 & Go Next")
- else
- { // unknown button clicked
- page_title = "Internal Error";
- logger.error("no known button click on PostMessage.doPost");
- content = new ErrorBox(page_title,"Unknown command button pressed","top");
-
- } // end else
-
- } // end if (got all parameters oK)
-
- BaseJSPData basedat = new BaseJSPData(page_title,"post",content);
- basedat.transfer(getServletContext(),rdat);
-
- } // end doPost
+ } // end doVenicePost
} // end class PostMessage
diff --git a/src/com/silverwrist/venice/servlets/PostOperations.java b/src/com/silverwrist/venice/servlets/PostOperations.java
index 204cc74..48187d8 100644
--- a/src/com/silverwrist/venice/servlets/PostOperations.java
+++ b/src/com/silverwrist/venice/servlets/PostOperations.java
@@ -39,115 +39,6 @@ public class PostOperations extends VeniceServlet
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
*--------------------------------------------------------------------------------
@@ -161,233 +52,130 @@ public class PostOperations extends VeniceServlet
} // 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 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
+ // get the SIG
+ SIGContext sig = getSIGParameter(request,user,true,"top");
+ changeMenuSIG(request,sig);
+ String locator = "sig=" + sig.getSIGID();
+ String location = "sigprofile?" + locator;
- try
- { // this outer try is to catch ValidationException
+ // get the conference
+ ConferenceContext conf = getConferenceParameter(request,sig,true,location);
+ locator += "&conf=" + conf.getConfID();
+ location = "confdisp?" + locator;
+
+ // get the topic
+ TopicContext topic = getTopicParameter(request,conf,true,location);
+ locator += "&top=" + topic.getTopicID();
+ location = "confdisp?" + locator;
+
+ // get the message
+ TopicMessageContext msg = getMessageParameter(request,topic,true,location);
+ location = "confdisp?" + locator + "&p1=" + msg.getPostNumber() + "&shac=1";
+ setMyLocation(request,location);
+
+ // figure out what command we want to perform
+ String cmd = getStandardCommandParam(request);
+
+ if (cmd.equals("HY") || cmd.equals("HN"))
+ { // we want to hide or show the message
try
- { // all commands require a SIG parameter
- sig = getSIGParameter(request,user);
- changeMenuSIG(request,sig);
- if (logger.isDebugEnabled())
- logger.debug("found SIG #" + String.valueOf(sig.getSIGID()));
- locator = "sig=" + String.valueOf(sig.getSIGID());
- location = "sigprofile?" + locator;
+ { // attempt to hide or show the message
+ msg.setHidden(cmd.equals("HY"));
- } // end try
+ // go back and display stuff
+ throw new RedirectResult(location);
+
+ } // end if
catch (DataException de)
- { // error looking up the SIG
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),location);
+ { // there was a database error
+ return new ErrorBox("Database Error","Database error setting hidden status: " + de.getMessage(),
+ location);
+
+ } // end catch
+ catch (AccessError ae)
+ { // naughty naughty = you can't do this!
+ return new ErrorBox("Access Error",ae.getMessage(),location);
} // end catch
- if (content==null)
- { // we got the SIG parameter OK
- try
- { // all commands require a conference parameter
- conf = getConferenceParameter(request,sig);
- if (logger.isDebugEnabled())
- logger.debug("found conf #" + String.valueOf(conf.getConfID()));
- locator += "&conf=" + String.valueOf(conf.getConfID());
- location = "confdisp?" + locator;
-
- } // end try
- catch (DataException de)
- { // error looking up the conference
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error finding conference: " + de.getMessage(),location);
+ } // end if ("hide" or "show")
- } // end catch
+ if (cmd.equals("SCR"))
+ { // we want to scribble the message
+ try
+ { // attempt to scribble the message
+ msg.scribble();
- } // end if
+ // go back and display stuff
+ throw new RedirectResult(location);
- if (content==null)
- { // we got the conference parameter OK
- try
- { // now we need a topic parameter
- topic = getTopicParameter(request,conf);
- if (logger.isDebugEnabled())
- logger.debug("found topic #" + String.valueOf(topic.getTopicID()));
- locator += "&top=" + String.valueOf(topic.getTopicID());
- location = "confdisp?" + locator;
+ } // end try
+ catch (DataException de)
+ { // there was a database error
+ return new ErrorBox("Database Error","Database error scribbling message: " + de.getMessage(),
+ location);
- } // end try
- catch (DataException de)
- { // error looking up the conference
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error finding topic: " + de.getMessage(),location);
+ } // end catch
+ catch (AccessError ae)
+ { // naughty naughty = you can't do this!
+ return new ErrorBox("Access Error",ae.getMessage(),location);
- } // end catch
+ } // end catch
- } // end if
+ } // end if ("scribble")
- 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";
+ if (cmd.equals("NUKE"))
+ { // nuking requires confirmation
+ try
+ { // we need confirmation on this operation
+ if (ConfirmBox.isConfirmed(request,NUKE_CONFIRM_ATTR,NUKE_CONFIRM_PARAM))
+ { // OK, go ahead, nuke the message!
+ msg.nuke();
- } // end try
- catch (DataException de)
- { // error looking up the conference
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error finding message: " + de.getMessage(),location);
+ // after which, redirect to topic view
+ throw new RedirectResult("confdisp?" + locator);
- } // end catch
+ } // end if (confirmed)
+ else
+ { // not a proper confirmation - better display one
+ List aliases = conf.getAliases();
+ String message = "You are about to nuke message <" + (String)(aliases.get(0)) + "."
+ + topic.getTopicNumber() + "." + msg.getPostNumber() + ">, originally composed by <"
+ + msg.getCreatorName() + ">! Are you sure you want to do this?";
+ String confirm_url = "postops?" + locator + "&msg=" + msg.getPostNumber() + "&cmd=NUKE";
+ return new ConfirmBox(request,NUKE_CONFIRM_ATTR,NUKE_CONFIRM_PARAM,"Nuke Message",
+ message,confirm_url,location);
- } // end if
+ } // end else (not yet confirmed)
+
+ } // end try
+ catch (DataException de)
+ { // there was a database error
+ return new ErrorBox("Database Error","Database error nuking message: " + de.getMessage(),
+ location);
- } // 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)
+ { // naughty naughty = you can't do this!
+ return new ErrorBox("Access Error",ae.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
- } // end catch
+ } // end if ("nuke")
- if (content==null)
- { // figure out what command we want to perform
- String cmd = request.getParameter("cmd");
- if (cmd==null)
- cmd = "???";
+ // unrecognized command!
+ logger.error("invalid command to PostOperations.doGet: " + cmd);
+ return new ErrorBox("Internal Error","Invalid command to PostOperations.doGet",location);
- if (cmd.equals("HY") || cmd.equals("HN"))
- { // we want to hide or show the message
- try
- { // attempt to hide or show the message
- msg.setHidden(cmd.equals("HY"));
-
- // go back and display stuff
- rdat.redirectTo(location);
- return;
-
- } // end try
- catch (DataException de)
- { // there was a database error
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error setting hidden status: " + de.getMessage(),
- location);
-
- } // end catch
- catch (AccessError ae)
- { // naughty naughty = you can't do this!
- page_title = "Access Error";
- content = new ErrorBox(page_title,ae.getMessage(),location);
-
- } // end catch
-
- } // end if ("hide" or "show")
- else if (cmd.equals("SCR"))
- { // we want to scribble the message
- try
- { // attempt to scribble the message
- msg.scribble();
-
- // go back and display stuff
- rdat.redirectTo(location);
- return;
-
- } // end try
- catch (DataException de)
- { // there was a database error
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error scribbling message: " + de.getMessage(),
- location);
-
- } // end catch
- catch (AccessError ae)
- { // naughty naughty = you can't do this!
- page_title = "Access Error";
- content = new ErrorBox(page_title,ae.getMessage(),location);
-
- } // end catch
-
- } // end else if ("scribble")
- else if (cmd.equals("NUKE"))
- { // nuking requires confirmation
- try
- { // we need confirmation on this operation!
- if (ConfirmBox.isConfirmed(request,NUKE_CONFIRM_ATTR,NUKE_CONFIRM_PARAM))
- { // OK, go ahead, nuke the message!
- msg.nuke();
-
- // after which, redirect to topic view
- rdat.redirectTo("confdisp?" + locator);
- return;
-
- } // end if
- else
- { // not a proper confirmation - better display one
- List aliases = conf.getAliases();
- String message = "You are about to nuke message <" + (String)(aliases.get(0)) + "."
- + String.valueOf(topic.getTopicNumber()) + "." + String.valueOf(msg.getPostNumber())
- + ">, originally composed by <" + msg.getCreatorName()
- + ">! Are you sure you want to do this?";
- String confirm_url = "postops?" + locator + "&msg=" + msg.getPostNumber() + "&cmd=NUKE";
-
- page_title = "Nuke Message";
- content = new ConfirmBox(request,NUKE_CONFIRM_ATTR,NUKE_CONFIRM_PARAM,page_title,
- message,confirm_url,location);
-
- } // end else
-
- } // end try
- catch (DataException de)
- { // there was a database error
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error nuking message: " + de.getMessage(),
- location);
-
- } // end catch
- catch (AccessError ae)
- { // naughty naughty = you can't do this!
- page_title = "Access Error";
- content = new ErrorBox(page_title,ae.getMessage(),location);
-
- } // end catch
-
- } // end else if ("nuke")
- else
- { // unrecognized command!
- page_title = "Internal Error";
- logger.error("invalid command to PostOperations.doGet: " + cmd);
- content = new ErrorBox(page_title,"Invalid command to PostOperations.doGet",location);
-
- } // end else
-
- } // end if (got parameters OK)
-
- BaseJSPData basedat = new BaseJSPData(page_title,location,content);
- basedat.transfer(getServletContext(),rdat);
-
- } // end doGet
+ } // end doVeniceGet
} // end class PostOperations
-
-
-
-
-
-
diff --git a/src/com/silverwrist/venice/servlets/PostShortcut.java b/src/com/silverwrist/venice/servlets/PostShortcut.java
index 69d6886..7529787 100644
--- a/src/com/silverwrist/venice/servlets/PostShortcut.java
+++ b/src/com/silverwrist/venice/servlets/PostShortcut.java
@@ -40,31 +40,34 @@ public class PostShortcut extends VeniceServlet
} // 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);
PostLinkDecoder decoder;
try
{ // attempt to decode the path link information
decoder = new PostLinkDecoder(raw_link);
- if (decoder.getSIG()==null) // it must include the SIG
- throw new ValidationException("ambiguous post link (no SIG)");
} // end try
catch (ValidationException e)
- { // display an error message for validation
- String page_title = "Invalid Post Link";
- ContentRender content = new ErrorBox(page_title,"Invalid post link \"" + raw_link + "\": "
- + e.getMessage(),null);
- new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
- return;
-
+ { // the post link decoder failed
+ return new ErrorBox("Invalid Post Link","Invalid post link \"" + raw_link + "\": " + e.getMessage(),
+ null);
+
} // 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;
try
{ // get the SIG represented by that alias
@@ -73,20 +76,13 @@ public class PostShortcut extends VeniceServlet
} // end try
catch (DataException e)
{ // can't find the SIG - we're screwed
- String page_title = "Invalid Post Link";
- ContentRender content = new ErrorBox(page_title,"Invalid post link \"" + raw_link
- + "\": cannot find SIG: " + e.getMessage(),null);
- new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
- return;
+ return new ErrorBox("Invalid Post Link","Invalid post link \"" + raw_link + "\": cannot find SIG: "
+ + e.getMessage(),null);
} // end catch
- if (decoder.getConference()==null)
- { // it's a SIG link only - redirect to the SIG's default page
- rdat.redirectTo("sig/" + decoder.getSIG());
- return;
-
- } // end if
+ if (decoder.getConference()==null) // it's a SIG link only - redirect to the SIG's default page
+ throw new RedirectResult("sig/" + decoder.getSIG());
ConferenceContext conf;
try
@@ -96,31 +92,21 @@ public class PostShortcut extends VeniceServlet
} // end try
catch (DataException e)
{ // can't find the conference - we're screwed
- String page_title = "Invalid Post Link";
- ContentRender content = new ErrorBox(page_title,"Invalid post link \"" + raw_link
- + "\": cannot find conference: " + e.getMessage(),null);
- new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
- return;
+ return new ErrorBox("Invalid Post Link","Invalid post link \"" + raw_link
+ + "\": cannot find conference: " + e.getMessage(),null);
} // end catch
catch (AccessError ae)
{ // we can't get to the conference...
- String page_title = "Access Error";
- ContentRender content = new ErrorBox(page_title,ae.getMessage(),null);
- new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
- return;
+ return new ErrorBox("Access Error",ae.getMessage(),null);
} // end catch
// 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)
- { // just a conference link - go to the top-level display
- rdat.redirectTo("confdisp?" + locator);
- return;
-
- } // end if
+ if (decoder.getTopic()==-1) // just a conference link - go to the top-level display
+ throw new RedirectResult("confdisp?" + locator);
TopicContext topic;
try
@@ -130,32 +116,26 @@ public class PostShortcut extends VeniceServlet
} // end try
catch (DataException e)
{ // we can't find the topic - we're screwed
- String page_title = "Invalid Post Link";
- ContentRender content = new ErrorBox(page_title,"Invalid post link \"" + raw_link
- + "\": cannot find topic: " + e.getMessage(),null);
- new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
- return;
+ return new ErrorBox("Invalid Post Link","Invalid post link \"" + raw_link + "\": cannot find topic: "
+ + e.getMessage(),null);
} // end catch
catch (AccessError ae)
{ // we can't get to the topic...
- String page_title = "Access Error";
- ContentRender content = new ErrorBox(page_title,ae.getMessage(),null);
- new BaseJSPData(page_title,"top",content).transfer(getServletContext(),rdat);
- return;
+ return new ErrorBox("Access Error",ae.getMessage(),null);
} // end catch
// 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
- rdat.redirectTo("confdisp?" + locator + "&rnm=1");
- else // we're referencing a post range within the topic
- rdat.redirectTo("confdisp?" + locator + "&p1=" + String.valueOf(decoder.getFirstPost()) + "&p2="
- + String.valueOf(decoder.getLastPost()));
+ throw new RedirectResult("confdisp?" + locator + "&rnm=1");
- } // 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
-
diff --git a/src/com/silverwrist/venice/servlets/RedirectResult.java b/src/com/silverwrist/venice/servlets/RedirectResult.java
new file mode 100644
index 0000000..32b3301
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/RedirectResult.java
@@ -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 .
+ *
+ * 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 ,
+ * 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
diff --git a/src/com/silverwrist/venice/servlets/SIGAdmin.java b/src/com/silverwrist/venice/servlets/SIGAdmin.java
index 6dfe199..68d3d0b 100644
--- a/src/com/silverwrist/venice/servlets/SIGAdmin.java
+++ b/src/com/silverwrist/venice/servlets/SIGAdmin.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@@ -87,355 +87,238 @@ public class SIGAdmin extends VeniceServlet
} // 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 page_title = null;
- Object content = null;
+ // get the SIG context
+ SIGContext sig = getSIGParameter(request,user,true,"top");
+ changeMenuSIG(request,sig);
+ setMyLocation(request,"sigadmin?" + request.getQueryString());
+ String on_error = "sigadmin?sig=" + sig.getSIGID();
- 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);
-
- } // end try
- catch (NumberFormatException nfe)
- { // 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");
+ if (logger.isDebugEnabled())
+ logger.debug("SIGAdmin/doGet operating on SIG \"" + sig.getName() + "\" (" + sig.getSIGID() + ")");
- } // 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");
+ // now decide what to do based on the "cmd" parameter
+ String cmd = getStandardCommandParam(request);
+ if (logger.isDebugEnabled())
+ logger.debug("SIGAdmin/doGet command value = " + cmd);
- } // end catch
+ if (cmd.equals("P"))
+ { // "P" = "Edit Profile"
+ if (!(sig.canModifyProfile()))
+ { // 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);
- if (logger.isDebugEnabled() && (sig!=null))
- logger.debug("SIGAdmin/doGet operating on SIG \"" + sig.getName() + "\" ("
- + String.valueOf(sig.getSIGID()) + ")");
+ } // end if
- 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
+ // construct the edit profile dialog and load it up for use
+ EditSIGProfileDialog dlg = makeEditSIGProfileDialog();
- if (logger.isDebugEnabled())
- logger.debug("SIGAdmin/doGet command value = " + cmd);
+ try
+ { // load the values for this dialog
+ dlg.setupDialog(engine,sig);
- if (cmd.equals("P"))
- { // this is the profile editing screen
- if (sig.canModifyProfile())
- { // construct the edit profile dialog and load it up for use
- EditSIGProfileDialog dlg = makeEditSIGProfileDialog();
+ } // end try
+ catch (DataException de)
+ { // we could not load the values because of a data exception
+ logger.error("DB error loading SIG profile: " + de.getMessage(),de);
+ return new ErrorBox("Database Error","Database error retrieving profile: " + de.getMessage(),on_error);
- try
- { // load the values for this dialog
- dlg.setupDialog(getVeniceEngine(),sig);
+ } // end catch
+ catch (AccessError ae)
+ { // we don't have enough privilege
+ logger.error("Access error loading SIG profile: " + ae.getMessage(),ae);
+ return new ErrorBox("Unauthorized","You do not have access to modify this SIG's profile.",on_error);
- // prepare for display
- page_title = dlg.getTitle();
- content = dlg;
+ } // end catch
- } // end try
- catch (DataException de)
- { // 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);
- content = new ErrorBox(page_title,"Database error retrieving profile: " + de.getMessage(),
- "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+ return dlg; // display me!
- } // end catch
- catch (AccessError ae)
- { // we don't have enough privilege
- page_title = "Unauthorized";
- 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.",
- "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+ } // end if ("P" command)
- } // end catch
+ if (cmd.equals("T"))
+ { // "T" = "Set Category"
+ 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 if
- else
- { // no access - sorry, dude
- page_title = "Unauthorized";
- logger.error("tried to call up SIG profile 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
+ // did they actually send a "set" parameter?
+ String p = request.getParameter("set");
+ if (!(StringUtil.isStringEmpty(p)))
+ { // OK, we're setting the category ID...
+ try
+ { // get the new category ID and set it
+ int catid = Integer.parseInt(p);
+ if (!(engine.isValidCategoryID(catid)))
+ throw new NumberFormatException(); // dump the category if it's not valid
- } // end if (profile editing)
- 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");
- if (!(StringUtil.isStringEmpty(p)))
- { // OK, we're setting the category ID...
- try
- { // get the new category ID and set it
- int catid = Integer.parseInt(p);
- if (!(getVeniceEngine().isValidCategoryID(catid)))
- throw new NumberFormatException(); // dump the category if it's not valid
+ // change the category ID
+ sig.setCategoryID(catid);
- sig.setCategoryID(catid);
+ } // end try
+ catch (NumberFormatException nfe)
+ { // we got an invalid category value...
+ return new ErrorBox("Invalid Input","Invalid category ID passed to category browser.",on_error);
- // 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 catch
+ catch (DataException de)
+ { // unable to update the SIG properly
+ logger.error("DB error updating SIG: " + de.getMessage(),de);
+ return new ErrorBox("Database Error","Database error updating SIG: " + de.getMessage(),on_error);
- } // end try
- catch (NumberFormatException nfe)
- { // we got an invalid category value...
- page_title = "Invalid Input";
- content = new ErrorBox(page_title,"Invalid category ID passed to category browser.",
- "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+ } // end catch
+ catch (AccessError ae)
+ { // database access error - display an error box
+ logger.error("Access error updating SIG: " + ae.getMessage(),ae);
+ return new ErrorBox("Access Error",ae.getMessage(),on_error);
- } // end catch
- catch (DataException de)
- { // unable to update the SIG properly
- page_title = "Database Error";
- logger.error("DB error updating SIG: " + de.getMessage(),de);
- content = new ErrorBox(page_title,"Database error updating SIG: " + de.getMessage(),
- "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+ } // end catch
- } // end catch
- catch (AccessError ae)
- { // database access error - display an error box
- page_title = "Access Error";
- logger.error("Access error updating SIG: " + ae.getMessage(),ae);
- content = new ErrorBox(page_title,ae.getMessage(),
- "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+ // now that it's set, go back to the admin menu
+ throw new RedirectResult(on_error);
- } // end catch
-
- } // end if (actually setting the category
+ } // end if (setting category ID)
+ else
+ { // we're browsing - try and figure out what to display
+ try
+ { // get the "go" parameter to see what the current category ID is
+ p = request.getParameter("go");
+ int curr_catid;
+ if (StringUtil.isStringEmpty(p))
+ curr_catid = sig.getCategoryID();
else
- { // we're browsing - try and figure out what to display
- try
- { // get the "go" parameter to see what the current category ID is
- p = request.getParameter("go");
- int curr_catid;
- if (StringUtil.isStringEmpty(p))
- curr_catid = sig.getCategoryID();
- else
- curr_catid = Integer.parseInt(p);
+ curr_catid = Integer.parseInt(p);
- if (!(getVeniceEngine().isValidCategoryID(curr_catid)))
- throw new NumberFormatException(); // dump the category if it's not valid
+ if (!(engine.isValidCategoryID(curr_catid)))
+ throw new NumberFormatException(); // dump the category if it's not valid
- // create the browser panel and let it rip
- content = new SIGCategoryBrowseData(user,sig,curr_catid);
- page_title = "Set SIG Category";
+ // create the browser panel and let it rip
+ return new SIGCategoryBrowseData(user,sig,curr_catid);
- } // end try
- catch (NumberFormatException nfe)
- { // we got an invalid category value...
- page_title = "Invalid Input";
- content = new ErrorBox(page_title,"Invalid category ID passed to category browser.",
- "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+ } // end try
+ catch (NumberFormatException nfe)
+ { // we got an invalid category value...
+ return new ErrorBox("Invalid Input","Invalid category ID passed to category browser.",on_error);
- } // end catch
- catch (DataException de)
- { // unable to get the categories properly
- page_title = "Database Error";
- logger.error("DB error browsing categories: " + de.getMessage(),de);
- content = new ErrorBox(page_title,"Database error browsing categories: " + de.getMessage(),
- "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+ } // end catch
+ catch (DataException de)
+ { // unable to get the categories properly
+ logger.error("DB error browsing categories: " + de.getMessage(),de);
+ return new ErrorBox("Database Error","Database error browsing categories: " + de.getMessage(),
+ on_error);
- } // end catch
+ } // end catch
- } // end else (browsing through categories)
+ } // end else
- } // 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 if ("T" command)
- } // end else
-
- } // end else if (category selector)
- else // other request
- { // all unknown requests get turned into menu display requests
- if (sig.canAdministerSIG())
- { // create a SIG administration menu
- SIGAdminTop menu = makeSIGAdminTop();
- menu.setSIG(sig);
- content = menu;
- page_title = "SIG Administration";
-
- } // end if
- 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
-
- } // end else (other request i.e. menu request)
+ // all unknown requests get turned into menu display requests
+ if (!(sig.canAdministerSIG()))
+ { // 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
- // else getting the SIG already caused problems
- BaseJSPData basedat = new BaseJSPData(page_title,"sigadmin?" + request.getQueryString(),content);
- basedat.transfer(getServletContext(),rdat);
+ // create a SIG administration menu
+ SIGAdminTop menu = makeSIGAdminTop();
+ menu.setSIG(sig);
+ return menu;
- } // end doGet
+ } // end doVeniceGet
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
+ protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
+ UserContext user, RenderData rdat)
+ throws ServletException, IOException, VeniceServletResult
{
- UserContext user = getUserContext(request);
- RenderData rdat = createRenderData(request,response);
- String page_title = null;
- ContentRender content = null;
+ // get the SIG context
+ SIGContext sig = getSIGParameter(request,user,true,"top");
+ changeMenuSIG(request,sig);
+ String on_error = "sigadmin?sig=" + sig.getSIGID();
+ setMyLocation(request,on_error);
- 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);
-
- } // end try
- catch (NumberFormatException nfe)
- { // 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");
+ if (logger.isDebugEnabled())
+ logger.debug("SIGAdmin/doPost operating on SIG \"" + sig.getName() + "\" (" + sig.getSIGID() + ")");
- } // 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");
+ // now decide what to do based on the "cmd" parameter
+ String cmd = getStandardCommandParam(request);
+ if (logger.isDebugEnabled())
+ logger.debug("SIGAdmin/doPost command value = " + cmd);
- } // end catch
+ if (cmd.equals("P"))
+ { // "P" = "Edit Profile"
+ if (!(sig.canModifyProfile()))
+ { // 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);
- if (logger.isDebugEnabled() && (sig!=null))
- logger.debug("SIGAdmin/doPost operating on SIG \"" + sig.getName() + "\" ("
- + String.valueOf(sig.getSIGID()) + ")");
+ } // end if
- 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
+ // construct the edit profile dialog and load it up for use
+ EditSIGProfileDialog dlg = makeEditSIGProfileDialog();
+ dlg.setupDialogBasic(engine,sig);
- if (logger.isDebugEnabled())
- logger.debug("SIGAdmin/doPost command value = " + cmd);
+ if (dlg.isButtonClicked(request,"cancel"))
+ throw new RedirectResult(on_error); // go back - they canceled out
- if (cmd.equals("P"))
- { // we just finished editing the profile...
- if (sig.canModifyProfile())
- { // construct the edit profile dialog and load it up for use
- EditSIGProfileDialog dlg = makeEditSIGProfileDialog();
- dlg.setupDialogBasic(getVeniceEngine(),sig);
+ if (dlg.isButtonClicked(request,"update"))
+ { // begin updating the SIG's contents
+ dlg.loadValues(request); // do value loading now
- if (dlg.isButtonClicked(request,"cancel"))
- { // go back to our desired location
- String target = "sigadmin?sig=" + String.valueOf(sig.getSIGID());
- String url = response.encodeRedirectURL(rdat.getFullServletPath(target));
- response.sendRedirect(url);
- return;
+ try
+ { // attempt to change the SIG profile now...
+ dlg.doDialog(sig);
- } // end if ("cancel" button clicked)
+ // now jump back to the main menu
+ clearMenu(request);
+ throw new RedirectResult(on_error);
- if (dlg.isButtonClicked(request,"update"))
- { // begin updating the SIG's contents
- dlg.loadValues(request); // do value loading now
+ } // end try
+ catch (ValidationException ve)
+ { // simple validation exception
+ if (logger.isDebugEnabled())
+ logger.debug("validation failure: " + ve.getMessage());
+ dlg.resetOnError(sig,ve.getMessage() + " Please try again.");
- try
- { // attempt to change the SIG profile now...
- dlg.doDialog(sig);
+ } // end catch
+ catch (DataException de)
+ { // database error updating the SIG values
+ logger.error("DB error updating SIG: " + de.getMessage(),de);
+ return new ErrorBox("Database Error","Database error updating SIG: " + de.getMessage(),on_error);
- // go back to the Admin menu on success
- clearMenu(request); // menu title may have been invalidated
- String target = "sigadmin?sig=" + String.valueOf(sig.getSIGID());
- String url = response.encodeRedirectURL(rdat.getFullServletPath(target));
- response.sendRedirect(url);
- return;
+ } // end catch
+ catch (AccessError ae)
+ { // access error changing the SIG values
+ logger.error("Access error updating SIG: " + ae.getMessage(),ae);
+ return new ErrorBox("Access Error",ae.getMessage(),on_error);
- } // end try
- catch (ValidationException ve)
- { // simple validation exception
- if (logger.isDebugEnabled())
- logger.debug("validation failure: " + ve.getMessage());
- dlg.resetOnError(sig,ve.getMessage() + " Please try again.");
- page_title = dlg.getTitle();
- content = dlg;
+ } // end catch
- } // end catch
- catch (DataException de)
- { // database error updating the SIG values
- page_title = "Database Error";
- logger.error("DB error updating SIG: " + de.getMessage(),de);
- content = new ErrorBox(page_title,"Database error updating SIG: " + de.getMessage(),
- "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+ return dlg;
- } // end catch
- catch (AccessError ae)
- { // access error changing the SIG values
- page_title = "Access Error";
- logger.error("Access error updating SIG: " + ae.getMessage(),ae);
- content = new ErrorBox(page_title,ae.getMessage(),
- "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+ } // end if ("update" pressed)
- } // end catch
+ // what the hell was that button?
+ logger.error("no known button click on SIGAdmin.doPost, cmd=P");
+ return new ErrorBox("Internal Error","Unknown command button pressed",on_error);
- } // end if ("update" button pressed);
- else
- { // what the hell was that button?
- page_title = "Internal Error";
- logger.error("no known button click on SIGAdmin.doPost, cmd=P");
- content = new ErrorBox(page_title,"Unknown command button pressed",
- "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+ } // end if ("P" command)
- } // end else
+ // on unknown command, redirect to the GET function
+ return doVeniceGet(request,engine,user,rdat);
- } // end if
- else
- { // 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 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 doVenicePost
} // end class SIGAdmin
diff --git a/src/com/silverwrist/venice/servlets/SIGFrontEnd.java b/src/com/silverwrist/venice/servlets/SIGFrontEnd.java
index d729218..6ca6b23 100644
--- a/src/com/silverwrist/venice/servlets/SIGFrontEnd.java
+++ b/src/com/silverwrist/venice/servlets/SIGFrontEnd.java
@@ -38,45 +38,42 @@ public class SIGFrontEnd extends VeniceServlet
} // 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 page_title = null;
- ContentRender content = null;
+ // get the SIG alias name from the request path info
+ String sigalias = request.getPathInfo().substring(1);
try
- { // get the SIG alias name from the request path info
- String sigalias = request.getPathInfo().substring(1);
-
- // get the SIG's context from the alias name
+ { // get the SIG's context from the alias name
SIGContext sig = user.getSIGContext(sigalias);
// get the default servlet from the SIG context
- String def_applet = sig.getDefaultApplet();
- if (def_applet==null)
- throw new DataException("unable to get SIG default servlet");
+ String def_servlet = sig.getDefaultApplet();
+ if (def_servlet==null)
+ { // 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!
- String url = response.encodeRedirectURL(rdat.getFullServletPath(def_applet));
- response.sendRedirect(url);
- return;
+ } // end if
+
+ // and go there
+ throw new RedirectResult(def_servlet);
} // end try
catch (DataException de)
{ // set up to display an ErrorBox
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),"top");
+ changeMenuTop(request);
+ return new ErrorBox("Database Error","Database error finding SIG: " + de.getMessage(),"top");
} // end catch
- changeMenuTop(request);
-
- // 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 doVeniceGet
} // end class SIGFrontEnd
diff --git a/src/com/silverwrist/venice/servlets/SIGOperations.java b/src/com/silverwrist/venice/servlets/SIGOperations.java
index 2b5d995..294caf3 100644
--- a/src/com/silverwrist/venice/servlets/SIGOperations.java
+++ b/src/com/silverwrist/venice/servlets/SIGOperations.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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()
{
final String desired_name = "JoinKeyDialog";
@@ -115,342 +89,239 @@ public class SIGOperations extends VeniceServlet
} // end getServletInfo
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
- {
- UserContext user = getUserContext(request);
- RenderData rdat = createRenderData(request,response);
- String page_title = null;
- Object content = null;
+ /*--------------------------------------------------------------------------------
+ * Overrides from class VeniceServlet
+ *--------------------------------------------------------------------------------
+ */
+ protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
+ UserContext user, RenderData rdat)
+ throws ServletException, IOException, VeniceServletResult
+ {
// get the command we want to use
- String cmd = request.getParameter("cmd");
- if (cmd==null)
- cmd = "???";
+ String cmd = getStandardCommandParam(request);
+ setMyLocation(request,"sigops?" + request.getQueryString());
if (cmd.equals("J"))
{ // "J" = "Join" (requires SIG parameter)
- try
- { // get the SIG parameter first!
- SIGContext sig = getSIGParameter(request,user);
+ SIGContext sig = getSIGParameter(request,user,true,"top");
- if (sig.canJoin())
- { // OK, we can join the SIG, now, is it public or private?
- if (sig.isPublicSIG())
- { // attempt to join right now! (no join key required)
- sig.join(null);
+ if (!(sig.canJoin())) // not permitted to join!
+ return new ErrorBox("SIG Error","You are not permitted to join this SIG.","top");
- // success! display the "welcome" page
- content = new SIGWelcome(sig);
- page_title = "Welcome to " + sig.getName();
- clearMenu(request); // force the clear to regen the menus
- changeMenuSIG(request,sig);
+ if (sig.isPublicSIG())
+ { // attempt to join right now! (no join key required)
+ try
+ { // call down to join the SIG
+ sig.join(null);
- } // end if (public SIG)
- else
- { // we need to prompt them for the join key...
- JoinKeyDialog dlg = makeJoinKeyDialog();
- dlg.setupDialog(sig);
- content = dlg;
- page_title = "Join SIG";
- changeMenuSIG(request,sig);
+ // success! display the "welcome" page
+ clearMenu(request); // force the clear to regen the menus
+ 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 else (private SIG)
+ } // end catch
+ catch (DataException de)
+ { // data exception doing something
+ return new ErrorBox("Database Error","Database error joining SIG: " + de.getMessage(),"top");
- } // 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 catch
- } // end else
+ } // end if (public SIG)
+ else
+ { // we need to prompt them for the join key....
+ JoinKeyDialog dlg = makeJoinKeyDialog();
+ dlg.setupDialog(sig);
+ changeMenuSIG(request,sig);
+ return dlg;
- } // 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 else (private SIG)
} // end if ("J" command)
- else if (cmd.equals("U"))
+
+ if (cmd.equals("U"))
{ // "U" = "Unjoin (requires SIG parameter)
- try
- { // get the SIG parameter first!
- SIGContext sig = getSIGParameter(request,user);
+ SIGContext sig = getSIGParameter(request,user,true,"top");
- if (sig.canUnjoin())
- { // OK, let's test for a confirmation...
- if (ConfirmBox.isConfirmed(request,UNJOIN_CONFIRM_ATTR,UNJOIN_CONFIRM_PARAM))
- { // OK, if you say so, let's unjoin!
- sig.unjoin();
+ 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))
+ { // OK, if you say so, let's unjoin!
+ try
+ { // do the unjoin now...
+ 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 try
+ catch (AccessError ae)
+ { // access error
+ return new ErrorBox("Access Error","Unable to unjoin SIG: " + ae.getMessage(),"top");
- } // 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 catch
+ catch (DataException de)
+ { // data exception doing something
+ return new ErrorBox("Database Error","Database error unjoining SIG: " + de.getMessage(),"top");
- } // end else
+ } // end catch
- } // end if
- else
- { // throw an error
- page_title = "Error";
- content = new ErrorBox("SIG Error","You cannot unjoin this SIG.","top");
-
- } // end else
-
- } // end try
- catch (AccessError ae)
- { // access error
- page_title = "Access Error";
- content = new ErrorBox(page_title,"Unable to unjoin SIG: " + ae.getMessage(),"top");
-
- } // end catch
- catch (DataException de)
- { // data exception doing something
- page_title = "Database Error";
- 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 else if ("U" command)
- else if (cmd.equals("C"))
- { // "C" - Create SIG (no parameters)
- 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);
+ // after which, redirect back to the top
+ clearMenu(request);
+ throw new RedirectResult("top");
} // end if
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");
+ { // not a proper confirmation - display the confirm box
+ String message = "Are you sure you want to unjoin the '" + sig.getName() + "' SIG?";
+ 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 if ("C" command)
- else
- { // this is an error!
- page_title = "Internal Error";
- logger.error("invalid command to SIGOperations.doGet: " + cmd);
- content = new ErrorBox(page_title,"Invalid command to SIGOperations.doGet","top");
+ } // end if ("U" command)
- } // end else
+ if (cmd.equals("C"))
+ { // "C" - Create SIG (no parameters)
+ if (!(user.canCreateSIG()))
+ return new ErrorBox("SIG Error","You are not permitted to create SIGs.","top");
- BaseJSPData basedat = new BaseJSPData(page_title,"sigops?" + request.getQueryString(),content);
- basedat.transfer(getServletContext(),rdat);
+ // present the "Create New SIG" dialog
+ CreateSIGDialog dlg = makeCreateSIGDialog();
+ dlg.setupDialog(engine);
+ changeMenuTop(request);
+ return dlg;
- } // end doGet
+ } // end if ("C" command)
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
+ // this is an error!
+ logger.error("invalid command to SIGOperations.doGet: " + cmd);
+ return new ErrorBox("Internal Error","Invalid command to SIGOperations.doGet","top");
+
+ } // end doVeniceGet
+
+ protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
+ UserContext user, RenderData rdat)
+ throws ServletException, IOException, VeniceServletResult
{
- UserContext user = getUserContext(request);
- RenderData rdat = createRenderData(request,response);
- String page_title = null;
- Object content = null;
-
// get the command we want to use
- String cmd = request.getParameter("cmd");
- if (cmd==null)
- cmd = "???";
+ String cmd = getStandardCommandParam(request);
+ setMyLocation(request,"sigops?cmd=" + cmd);
if (cmd.equals("J"))
{ // "J" = Join SIG (requires SIG parameter)
- try
- { // get the SIG we're talking about
- SIGContext sig = getSIGParameter(request,user);
- JoinKeyDialog dlg = makeJoinKeyDialog();
+ SIGContext sig = getSIGParameter(request,user,true,"top");
+ JoinKeyDialog dlg = makeJoinKeyDialog();
- if (dlg.isButtonClicked(request,"cancel"))
- { // canceled join - return to SIG opening page
- rdat.redirectTo("sig/" + sig.getAlias());
- return;
+ if (dlg.isButtonClicked(request,"cancel")) // cancel - go back to SIG opening page
+ throw new RedirectResult("sig/" + sig.getAlias());
- } // 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"))
- { // they clicked the "join" button
- if (sig.canJoin())
- { // we are permitted to join this SIG...
- dlg.loadValues(request); // load the dialog
+ if (dlg.isButtonClicked(request,"join"))
+ { // OK, go join the SIG
+ dlg.loadValues(request); // load the dialog
+
+ try
+ { // attempt to join the SIG!
+ dlg.doDialog(sig);
+
+ // success! display the "welcome" page
+ clearMenu(request); // force the clear to regen the menus
+ changeMenuSIG(request,sig);
+ return new SIGWelcome(sig);
+
+ } // end try
+ catch (ValidationException ve)
+ { // here, a validation exception causes us to recycle and retry
+ dlg.resetOnError(ve.getMessage() + " Please try again.");
+ changeMenuSIG(request,sig);
- try
- { // attempt to join the SIG!
- dlg.doDialog(sig);
-
- // success! display the "welcome" page
- content = new SIGWelcome(sig);
- page_title = "Welcome to " + sig.getName();
- clearMenu(request); // force the clear to regen the menus
- changeMenuSIG(request,sig);
-
- } // end try
- catch (ValidationException ve2)
- { // here, a validation exception causes us to recycle and retry
- dlg.resetOnError(ve2.getMessage() + " Please try again.");
- content = dlg;
- page_title = "Join SIG";
- changeMenuSIG(request,sig);
+ } // end catch
+ catch (AccessError ae)
+ { // this is probably a bogus key - let them retry
+ dlg.resetOnError(ae.getMessage() + " Please try again.");
+ changeMenuSIG(request,sig);
- } // end catch
- catch (AccessError ae)
- { // this is probably a bogus key - let them retry
- dlg.resetOnError(ae.getMessage() + " Please try again.");
- content = dlg;
- page_title = "Join SIG";
- changeMenuSIG(request,sig);
-
- } // end catch
+ } // end catch
+ catch (DataException de)
+ { // database error joining something
+ return new ErrorBox("Database Error","Database error joining SIG: " + de.getMessage(),"top");
- } // end if
- else
- { // throw an error
- page_title = "Error";
- content = new ErrorBox("SIG Error","You are not permitted to join this SIG.","top");
+ } // end catch
- } // end else
+ return dlg; // recycle and try aagin
- } // 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 if ("join" clicked)
- } // end else
-
- } // end try
- catch (DataException de)
- { // database error joining something
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error joining SIG: " + de.getMessage(),"top");
-
- } // end catch
- catch (ValidationException ve)
- { // validation error - bogus parameter, I think
- page_title = "Error";
- content = new ErrorBox(null,ve.getMessage(),"top");
-
- } // end catch
+ // 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)
- else if (cmd.equals("C"))
+
+ if (cmd.equals("C"))
{ // "C" = Create New SIG
- if (user.canCreateSIG())
- { // load the "Create SIG" dialog
- CreateSIGDialog dlg = makeCreateSIGDialog();
- dlg.setupDialog(getVeniceEngine());
+ if (!(user.canCreateSIG()))
+ return new ErrorBox("SIG Error","You are not permitted to create SIGs.","top");
- if (dlg.isButtonClicked(request,"cancel"))
- { // canceled create - return to top page
- rdat.redirectTo("top");
- return;
+ // load the "Create SIG" dialog
+ CreateSIGDialog dlg = makeCreateSIGDialog();
+ dlg.setupDialog(engine);
- } // end if
+ if (dlg.isButtonClicked(request,"cancel")) // cancel - go back to top
+ throw new RedirectResult("top");
- if (dlg.isButtonClicked(request,"create"))
- { // OK, they actually want to create the new SIG...
- dlg.loadValues(request); // load the form data
+ if (dlg.isButtonClicked(request,"create"))
+ { // OK, they actually want to create the new SIG...
+ dlg.loadValues(request); // load the form data
- try
- { // attempt to create the SIG!
- SIGContext sig = dlg.doDialog(user);
+ try
+ { // attempt to create the SIG!
+ SIGContext sig = dlg.doDialog(user);
- // 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!
+ // created successfully - display a "new SIG welcome" page
+ changeMenuSIG(request,sig); // display menus for the first time!
+ return new NewSIGWelcome(sig);
- } // end try
- catch (ValidationException ve2)
- { // here, a validation exception causes us to recycle and retry
- dlg.resetOnError(ve2.getMessage() + " Please try again.");
- content = dlg;
- page_title = dlg.getTitle();
- changeMenuTop(request);
+ } // end try
+ catch (ValidationException ve)
+ { // here, a validation exception causes us to recycle and retry
+ dlg.resetOnError(ve.getMessage() + " Please try again.");
+ changeMenuTop(request);
- } // end catch
- catch (AccessError ae)
- { // this is probably a bogus key - let them retry
- dlg.resetOnError(ae.getMessage() + " Please try again.");
- content = dlg;
- page_title = dlg.getTitle();
- changeMenuTop(request);
+ } // end catch
+ catch (AccessError ae)
+ { // this is probably a bogus key - let them retry
+ dlg.resetOnError(ae.getMessage() + " Please try again.");
+ changeMenuTop(request);
- } // end catch
- catch (DataException de)
- { // database error doing something
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error creating SIG: " + de.getMessage(),"top");
+ } // end catch
+ catch (DataException de)
+ { // database error doing something
+ return new ErrorBox("Database Error","Database error creating SIG: " + de.getMessage(),"top");
- } // end catch
+ } // end catch
- } // end if
- else
- { // error - don't know what button was clicked
- page_title = "Internal Error";
- logger.error("no known button click on SIGOperations.doPost, cmd=C");
- content = new ErrorBox(page_title,"Unknown command button pressed","top");
+ return dlg; // put the dialog back up
- } // end else
+ } // end if ("create" pressed)
- } // end if
- 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");
+ // error - don't know what button was clicked
+ logger.error("no known button click on SIGOperations.doPost, cmd=C");
+ return new ErrorBox("Internal Error","Unknown command button pressed","top");
- } // end else
+ } // end if ("C" command)
- } // end else if ("C" command)
- else
- { // this is an error!
- page_title = "Internal Error";
- logger.error("invalid command to SIGOperations.doPost: " + cmd);
- content = new ErrorBox(page_title,"Invalid command to SIGOperations.doPost","top");
+ // this is an error!
+ logger.error("invalid command to SIGOperations.doPost: " + cmd);
+ return new ErrorBox("Internal Error","Invalid command to SIGOperations.doPost","top");
- } // end else
-
- BaseJSPData basedat = new BaseJSPData(page_title,"top",content);
- basedat.transfer(getServletContext(),rdat);
-
- } // end doPost
+ } // end doVenicePost
} // end class SIGOperations
diff --git a/src/com/silverwrist/venice/servlets/SIGProfile.java b/src/com/silverwrist/venice/servlets/SIGProfile.java
index 06e7ce0..e25083d 100644
--- a/src/com/silverwrist/venice/servlets/SIGProfile.java
+++ b/src/com/silverwrist/venice/servlets/SIGProfile.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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
{
+ /*--------------------------------------------------------------------------------
+ * Overrides from class HttpServlet
+ *--------------------------------------------------------------------------------
+ */
+
public String getServletInfo()
{
String rc = "SIGProfile servlet - Displays the profile of a SIG\n"
@@ -33,43 +38,31 @@ public class SIGProfile extends VeniceServlet
} // 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 page_title = null;
- Object content = null;
+ // get the SIG
+ SIGContext sig = getSIGParameter(request,user,true,"top");
+ setMyLocation(request,"sigprofile?sig=" + sig.getSIGID());
try
- { // get the ID of the SIG we want to see the profile of
- 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();
+ { // create the profile display
changeMenuSIG(request,sig);
+ return new SIGProfileData(engine,user,sig);
} // 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)
{ // in this case, we had database trouble
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error accessing SIG: " + de.getMessage(),"top");
+ return new ErrorBox("Database Error","Database error accessing SIG: " + de.getMessage(),"top");
} // end catch
- BaseJSPData basedat = new BaseJSPData(page_title,"sigprofile?" + request.getQueryString(),content);
- basedat.transfer(getServletContext(),rdat);
-
- } // end doGet
+ } // end doVeniceGet
} // end class SIGProfile
diff --git a/src/com/silverwrist/venice/servlets/SendFileResult.java b/src/com/silverwrist/venice/servlets/SendFileResult.java
new file mode 100644
index 0000000..5d826e7
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/SendFileResult.java
@@ -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 .
+ *
+ * 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 ,
+ * 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
diff --git a/src/com/silverwrist/venice/servlets/Top.java b/src/com/silverwrist/venice/servlets/Top.java
index 6788ef0..de515fa 100644
--- a/src/com/silverwrist/venice/servlets/Top.java
+++ b/src/com/silverwrist/venice/servlets/Top.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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
{
+ /*--------------------------------------------------------------------------------
+ * Overrides from class HttpServlet
+ *--------------------------------------------------------------------------------
+ */
+
public void init(ServletConfig config) throws ServletException
{
super.init(config); // required before we do anything else
@@ -36,7 +41,7 @@ public class Top extends VeniceServlet
DOMConfigurator.configure(ctxt.getInitParameter("logging.config"));
// Initialize the Venice engine.
- VeniceEngine engine = getVeniceEngine(ctxt);
+ VeniceEngine engine = Variables.getVeniceEngine(ctxt);
// Initialize the Venice rendering system.
RenderConfig.getRenderConfig(ctxt);
@@ -52,36 +57,34 @@ public class Top extends VeniceServlet
public String getServletInfo()
{
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;
} // 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);
- ContentRender content = null;
- String page_title = "My Front Page";
+ changeMenuTop(request);
+ setMyLocation(request,"top");
try
{ // attempt to get the user content
- content = new TopContent(user);
+ return new TopContent(user);
} // end try
- catch (DataException e)
+ catch (DataException de)
{ // there was a database error, whoops!
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Error loading front page: " + e.getMessage(),null);
+ return new ErrorBox("Database Error","Error loading front page: " + de.getMessage(),null);
} // end catch
- changeMenuTop(request);
-
- BaseJSPData basedat = new BaseJSPData(page_title,"top",content);
- basedat.transfer(getServletContext(),rdat);
-
- } // end doGet
+ } // end doVeniceGet
} // end class Top
diff --git a/src/com/silverwrist/venice/servlets/TopicOperations.java b/src/com/silverwrist/venice/servlets/TopicOperations.java
index ee1a5ac..b939b09 100644
--- a/src/com/silverwrist/venice/servlets/TopicOperations.java
+++ b/src/com/silverwrist/venice/servlets/TopicOperations.java
@@ -38,89 +38,6 @@ public class TopicOperations extends VeniceServlet
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
*--------------------------------------------------------------------------------
@@ -134,224 +51,142 @@ public class TopicOperations extends VeniceServlet
} // end getServletInfo
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
- {
- UserContext user = getUserContext(request);
- RenderData rdat = createRenderData(request,response);
- String location = "top";
- String locator = null;
- String page_title = null;
- Object content = null;
- SIGContext sig = null; // SIG context
- ConferenceContext conf = null; // conference context
- TopicContext topic = null; // topic context
+ /*--------------------------------------------------------------------------------
+ * Overrides from class VeniceServlet
+ *--------------------------------------------------------------------------------
+ */
- try
- { // this outer try is to catch ValidationException
+ protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
+ UserContext user, RenderData rdat)
+ throws ServletException, IOException, VeniceServletResult
+ {
+ // get the SIG
+ SIGContext sig = getSIGParameter(request,user,true,"top");
+ changeMenuSIG(request,sig);
+ String locator = "sig=" + sig.getSIGID();
+ String location = "sigprofile?" + locator;
+
+ // get the conference
+ ConferenceContext conf = getConferenceParameter(request,sig,true,location);
+ locator += "&conf=" + conf.getConfID();
+ location = "confdisp?" + locator;
+
+ // get the topic
+ TopicContext topic = getTopicParameter(request,conf,true,location);
+ locator += "&top=" + topic.getTopicNumber();
+ location = "confdisp?" + locator;
+
+ // figure out what command we want to perform...
+ String cmd = getStandardCommandParam(request);
+
+ if (cmd.equals("HY") || cmd.equals("HN"))
+ { // we want to set the hide status of the topic
try
- { // all commands require a SIG parameter
- sig = getSIGParameter(request,user);
- changeMenuSIG(request,sig);
- if (logger.isDebugEnabled())
- logger.debug("found SIG #" + String.valueOf(sig.getSIGID()));
- locator = "sig=" + String.valueOf(sig.getSIGID());
- location = "sigprofile?" + locator;
+ { // call down to set the topic!
+ topic.setHidden(cmd.equals("HY"));
} // end try
catch (DataException de)
- { // error looking up the SIG
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),location);
+ { // there was a database error
+ return new ErrorBox("Database Error","Database error setting hide status: " + de.getMessage(),
+ location);
} // end catch
- if (content==null)
- { // we got the SIG parameter OK
+ // go back to the topic view
+ throw new RedirectResult(location);
+
+ } // end if ("hide" or "show")
+
+ if (cmd.equals("FY") || cmd.equals("FN"))
+ { // we want to set the frozen status of the topic
+ try
+ { // call down to set the topic!
+ topic.setFrozen(cmd.equals("FY"));
+
+ } // end try
+ catch (DataException de)
+ { // there was a database error
+ return new ErrorBox("Database Error","Database error setting freeze status: " + de.getMessage(),
+ location);
+
+ } // end catch
+ catch (AccessError ae)
+ { // naughty naughty = you can't do this!
+ return new ErrorBox("Access Error",ae.getMessage(),location);
+
+ } // end catch
+
+ // go back to the topic view
+ 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
+ try
+ { // call down to set the topic!
+ topic.setArchived(cmd.equals("AY"));
+
+ } // end try
+ catch (DataException de)
+ { // there was a database error
+ return new ErrorBox("Database Error","Database error setting archive status: " + de.getMessage(),
+ location);
+
+ } // end catch
+ catch (AccessError ae)
+ { // naughty naughty = you can't do this!
+ return new ErrorBox("Access Error",ae.getMessage(),location);
+
+ } // end catch
+
+ // go back to the topic view
+ throw new RedirectResult(location);
+
+ } // end if ("archive" or "unarchive")
+
+ if (cmd.equals("DEL"))
+ { // Delete Topic requires a confirmation!
+ if (ConfirmBox.isConfirmed(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM))
+ { // OK, go ahead, delete the topic!
+ location = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
+
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;
+ { // delete the bloody topic!
+ topic.delete();
+
+ } // end try
+ catch (DataException de)
+ { // there was a database error
+ return new ErrorBox("Database Error","Database error deleting topic: " + de.getMessage(),location);
- } // end try
- catch (DataException de)
- { // error looking up the conference
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error finding conference: " + de.getMessage(),location);
-
- } // end catch
-
- } // end if
-
- if (content==null)
- { // we got the conference parameter OK
- try
- { // now we need a topic parameter
- topic = getTopicParameter(request,conf);
- if (logger.isDebugEnabled())
- logger.debug("found topic #" + String.valueOf(topic.getTopicID()));
- locator += "&top=" + String.valueOf(topic.getTopicNumber());
- location = "confdisp?" + locator;
-
- } // end try
- catch (DataException de)
- { // error looking up the conference
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error finding topic: " + de.getMessage(),location);
-
- } // end catch
-
- } // end if
-
- } // end try
- catch (ValidationException ve)
- { // these all get handled in pretty much the same way
- page_title = "Error";
- content = new ErrorBox(null,ve.getMessage(),location);
-
- } // end catch
- catch (AccessError ae)
- { // these all get handled in pretty much the same way
- page_title = "Access Error";
- content = new ErrorBox(page_title,ae.getMessage(),location);
-
- } // end catch
-
- if (content==null)
- { // figure out what command we want to perform...
- String cmd = request.getParameter("cmd");
- if (cmd==null)
- cmd = "???";
-
- if (cmd.equals("HY") || cmd.equals("HN"))
- { // we want to set the hide status of the topic
- try
- { // call down to set the topic!
- topic.setHidden(cmd.equals("HY"));
-
- // go back to the topic view
- rdat.redirectTo(location);
- return;
-
- } // end try
- catch (DataException de)
- { // there was a database error
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error setting hide status: " + de.getMessage(),location);
-
- } // end catch
-
- } // end if ("hide" or "show")
- else if (cmd.equals("FY") || cmd.equals("FN"))
- { // we want to set the frozen status of the topic
- try
- { // call down to set the topic!
- topic.setFrozen(cmd.equals("FY"));
-
- // go back to the topic view
- rdat.redirectTo(location);
- return;
-
- } // end try
- catch (DataException de)
- { // there was a database error
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error setting freeze status: " + de.getMessage(),
- location);
-
} // end catch
catch (AccessError ae)
{ // naughty naughty = you can't do this!
- page_title = "Access Error";
- content = new ErrorBox(page_title,ae.getMessage(),location);
+ return new ErrorBox("Access Error",ae.getMessage(),location);
} // end catch
-
- } // end else if ("freeze" or "unfreeze")
- else if (cmd.equals("AY") || cmd.equals("AN"))
- { // we want to change the archived status of the topic
- try
- { // call down to set the topic!
- topic.setArchived(cmd.equals("AY"));
- // go back to the topic view
- rdat.redirectTo(location);
- return;
+ // go back to the conference view
+ throw new RedirectResult(location);
- } // end try
- catch (DataException de)
- { // there was a database error
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error setting archive status: " + de.getMessage(),
- location);
-
- } // end catch
- catch (AccessError ae)
- { // naughty naughty = you can't do this!
- page_title = "Access Error";
- content = new ErrorBox(page_title,ae.getMessage(),location);
-
- } // end catch
-
- } // end else if ("archive" or "unarchive")
- else if (cmd.equals("DEL"))
- { // we need confirmation on this operation!
- if (ConfirmBox.isConfirmed(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM))
- { // OK, go ahead, delete the topic!
- location = "confdisp?sig=" + String.valueOf(sig.getSIGID()) + "&conf="
- + String.valueOf(conf.getConfID());
-
- try
- { // delete the bloody topic!
- topic.delete();
-
- // after which, redirect to conference view
- rdat.redirectTo(location);
- return;
-
- } // end try
- catch (DataException de)
- { // there was a database error
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error deleting topic: " + de.getMessage(),location);
-
- } // end catch
- catch (AccessError ae)
- { // naughty naughty = you can't do this!
- page_title = "Access Error";
- content = new ErrorBox(page_title,ae.getMessage(),location);
-
- } // end catch
-
- } // end if
- else
- { // not a proper confirmation - better display one
- String message = "You are about to delete topic " + String.valueOf(topic.getTopicNumber())
- + " from the \"" + conf.getName() + "\" conference! Are you sure you want to do this?";
- String confirm_url = "topicops?" + locator + "&cmd=DEL";
- page_title = "Delete Topic";
- content = new ConfirmBox(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM,page_title,
- message,confirm_url,location);
-
- } // end else
-
- } // end else if ("delete")
+ } // end if (confirmed)
else
- { // unrecognized command
- page_title = "Internal Error";
- logger.error("invalid command to TopicOperations.doGet: " + cmd);
- content = new ErrorBox(page_title,"Invalid command to TopicOperations.doGet",location);
+ { // not a proper confirmation - better display one
+ String message = "You are about to delete topic " + String.valueOf(topic.getTopicNumber())
+ + " from the \"" + conf.getName() + "\" conference! Are you sure you want to do this?";
+ return new ConfirmBox(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM,"Delete Topic",message,
+ "topicops?" + locator + "&cmd=DEL",location);
} // end else
- } // end if
+ } // end if (delete)
- BaseJSPData basedat = new BaseJSPData(page_title,location,content);
- basedat.transfer(getServletContext(),rdat);
+ // unrecognized command
+ logger.error("invalid command to TopicOperations.doGet: " + cmd);
+ return new ErrorBox("Internal Error","Invalid command to TopicOperations.doGet",location);
- } // end doGet
+ } // end doVeniceGet
} // end class TopicOperations
diff --git a/src/com/silverwrist/venice/servlets/UserDisplay.java b/src/com/silverwrist/venice/servlets/UserDisplay.java
index 9b65b63..b1d9af1 100644
--- a/src/com/silverwrist/venice/servlets/UserDisplay.java
+++ b/src/com/silverwrist/venice/servlets/UserDisplay.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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
{
+ /*--------------------------------------------------------------------------------
+ * Overrides from class HttpServlet
+ *--------------------------------------------------------------------------------
+ */
+
public String getServletInfo()
{
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;
} // 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 page_title = null;
- Object content = null;
+ String uname = request.getPathInfo().substring(1); // the username we're looking at
try
- { // use the request path info to get the username to load the profile from
- String uname = request.getPathInfo().substring(1);
+ { // load the profile corresponding to that username and display it
UserProfile prof = user.getProfile(uname);
- content = new UserProfileData(prof);
- page_title = "User Profile - " + prof.getUserName();
+ changeMenuTop(request);
+ return new UserProfileData(prof);
} // end try
catch (DataException de)
{ // unable to get the user name
- page_title = "Database Error";
- content = new ErrorBox(page_title,"Database error finding user: " + de.getMessage(),"top");
+ return new ErrorBox("Database Error","Database error finding user: " + de.getMessage(),"top");
} // end catch
- changeMenuTop(request);
-
- // format and display the user
- BaseJSPData basedat = new BaseJSPData(page_title,"user" + request.getPathInfo(),content);
- basedat.transfer(getServletContext(),rdat);
-
- } // end doGet
+ } // end doVeniceGet
} // end class UserDisplay
diff --git a/src/com/silverwrist/venice/servlets/Variables.java b/src/com/silverwrist/venice/servlets/Variables.java
index a2bfb08..4b64693 100644
--- a/src/com/silverwrist/venice/servlets/Variables.java
+++ b/src/com/silverwrist/venice/servlets/Variables.java
@@ -176,9 +176,9 @@ public class Variables
} // 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
diff --git a/src/com/silverwrist/venice/servlets/VeniceServlet.java b/src/com/silverwrist/venice/servlets/VeniceServlet.java
index cdec44e..59e4f6a 100644
--- a/src/com/silverwrist/venice/servlets/VeniceServlet.java
+++ b/src/com/silverwrist/venice/servlets/VeniceServlet.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@@ -17,10 +17,14 @@
*/
package com.silverwrist.venice.servlets;
+import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.util.ServletMultipartHandler;
+import com.silverwrist.util.ServletMultipartException;
import com.silverwrist.venice.core.*;
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());
+ /*--------------------------------------------------------------------------------
+ * 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
*--------------------------------------------------------------------------------
*/
- protected static boolean isImageButtonClicked(ServletRequest request, String name)
+ protected static final boolean isImageButtonClicked(ServletRequest request, String name)
{
String val = request.getParameter(name + ".x");
return (val!=null);
} // end isImageButtonClicked
- protected static VeniceEngine getVeniceEngine(ServletContext ctxt) throws ServletException
+ /*
+ protected static final VeniceEngine getVeniceEngine(ServletContext ctxt) throws ServletException
{
return Variables.getVeniceEngine(ctxt);
} // end getVeniceEngine
- protected VeniceEngine getVeniceEngine() throws ServletException
+ protected final VeniceEngine getVeniceEngine() throws ServletException
{
return Variables.getVeniceEngine(getServletContext());
} // 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));
} // end getUserContext
+ */
- protected void putUserContext(HttpServletRequest request, UserContext ctxt)
+ protected final void putUserContext(HttpServletRequest request, UserContext ctxt)
{
Variables.putUserContext(request.getSession(true),ctxt);
} // end putUserContext
- protected void clearUserContext(HttpServletRequest request)
+ protected final void clearUserContext(HttpServletRequest request)
{
Variables.clearUserContext(request.getSession(true));
} // end clearUserContext
- protected static List getCountryList(ServletContext ctxt) throws ServletException
+ protected static final List getCountryList(ServletContext ctxt) throws ServletException
{
return Variables.getCountryList(ctxt);
} // end getCountryList
- protected List getCountryList() throws ServletException
+ protected final List getCountryList() throws ServletException
{
return Variables.getCountryList(getServletContext());
} // end getCountryList
- protected List getLanguageList(ServletContext ctxt) throws ServletException
+ protected final List getLanguageList(ServletContext ctxt) throws ServletException
{
return Variables.getLanguageList(ctxt);
} // end getLanguageList
- protected List getLanguageList() throws ServletException
+ protected final List getLanguageList() throws ServletException
{
return Variables.getLanguageList(getServletContext());
} // end getLanguageList
- protected void changeMenuTop(HttpServletRequest request)
+ protected final void changeMenuTop(HttpServletRequest request)
{
Variables.setMenuTop(getServletContext(),request.getSession(true));
} // end changeMenuTop
- protected void changeMenuSIG(HttpServletRequest request, SIGContext sig)
+ protected final void changeMenuSIG(HttpServletRequest request, SIGContext sig)
{
Variables.setMenuSIG(request.getSession(true),sig);
} // end changeMenuSIG
- protected void clearMenu(HttpServletRequest request)
+ protected final void clearMenu(HttpServletRequest request)
{
Variables.clearMenu(request.getSession(true));
} // end clearMenu
- protected RenderData createRenderData(HttpServletRequest request, HttpServletResponse response)
+ /*
+ protected final RenderData createRenderData(HttpServletRequest request, HttpServletResponse response)
throws ServletException
{
return RenderConfig.createRenderData(getServletContext(),request,response);
} // 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
diff --git a/src/com/silverwrist/venice/servlets/VeniceServletResult.java b/src/com/silverwrist/venice/servlets/VeniceServletResult.java
new file mode 100644
index 0000000..5736cca
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/VeniceServletResult.java
@@ -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 .
+ *
+ * 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 ,
+ * 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
diff --git a/src/com/silverwrist/venice/servlets/format/AttachmentForm.java b/src/com/silverwrist/venice/servlets/format/AttachmentForm.java
index a837d5a..8d793b9 100644
--- a/src/com/silverwrist/venice/servlets/format/AttachmentForm.java
+++ b/src/com/silverwrist/venice/servlets/format/AttachmentForm.java
@@ -69,6 +69,17 @@ public class AttachmentForm implements JSPRender
} // end retrieve
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return "Upload Attachment";
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/BaseJSPData.java b/src/com/silverwrist/venice/servlets/format/BaseJSPData.java
index 4fa3d72..0dd516c 100644
--- a/src/com/silverwrist/venice/servlets/format/BaseJSPData.java
+++ b/src/com/silverwrist/venice/servlets/format/BaseJSPData.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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 Object content; // the actual content
+ private VeniceContent content; // the actual content
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.content = content;
@@ -78,12 +76,18 @@ public class BaseJSPData
} // end store
- public String getTitle()
+ public String getTitle(RenderData rdat)
{
- return title;
+ return content.getPageTitle(rdat);
} // end getTitle
+ public boolean locationSpecified()
+ {
+ return (location!=null);
+
+ } // end if
+
public String getLocation()
{
return location;
@@ -92,7 +96,7 @@ public class BaseJSPData
public boolean displayLoginLinks()
{
- return login_links;
+ return login_links && (location!=null);
} // end displayLoginLinks
@@ -115,8 +119,7 @@ public class BaseJSPData
{
if (content==null)
{ // there is no content!
- ErrorBox box = new ErrorBox(null,"Internal Error: There is no content available",null);
- box.renderHere(out,rdat);
+ new ErrorBox(null,"Internal Error: There is no content available",null).renderHere(out,rdat);
return;
} // end if
@@ -128,8 +131,7 @@ public class BaseJSPData
return;
} // end if
-
- if (content instanceof JSPRender)
+ else if (content instanceof JSPRender)
{ // we have a JSP-rendered page - include it
JSPRender jr = (JSPRender)content;
rdat.storeJSPRender(jr);
@@ -141,10 +143,8 @@ public class BaseJSPData
return;
} // end if
-
- // this is the fallback if we don't recognize the content
- ErrorBox box2 = new ErrorBox(null,"Internal Error: Content of invalid type",null);
- box2.renderHere(out,rdat);
+ else // this is the fallback if we don't recognize the content
+ new ErrorBox(null,"Internal Error: Content of invalid type",null).renderHere(out,rdat);
} // end renderContent
diff --git a/src/com/silverwrist/venice/servlets/format/CDBaseFormFieldReverse.java b/src/com/silverwrist/venice/servlets/format/CDBaseFormFieldReverse.java
index e699717..d955ef1 100644
--- a/src/com/silverwrist/venice/servlets/format/CDBaseFormFieldReverse.java
+++ b/src/com/silverwrist/venice/servlets/format/CDBaseFormFieldReverse.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
diff --git a/src/com/silverwrist/venice/servlets/format/CDCommandButton.java b/src/com/silverwrist/venice/servlets/format/CDCommandButton.java
index 99bb632..aae5f26 100644
--- a/src/com/silverwrist/venice/servlets/format/CDCommandButton.java
+++ b/src/com/silverwrist/venice/servlets/format/CDCommandButton.java
@@ -19,7 +19,7 @@ package com.silverwrist.venice.servlets.format;
import javax.servlet.ServletRequest;
-public interface CDCommandButton extends ContentRender
+public interface CDCommandButton extends ComponentRender
{
public abstract String getName();
diff --git a/src/com/silverwrist/venice/servlets/format/CDFormField.java b/src/com/silverwrist/venice/servlets/format/CDFormField.java
index 6bfea45..e6f2c56 100644
--- a/src/com/silverwrist/venice/servlets/format/CDFormField.java
+++ b/src/com/silverwrist/venice/servlets/format/CDFormField.java
@@ -19,7 +19,7 @@ package com.silverwrist.venice.servlets.format;
import com.silverwrist.venice.ValidationException;
-public interface CDFormField extends ContentRender
+public interface CDFormField extends ComponentRender
{
public abstract String getName();
diff --git a/src/com/silverwrist/venice/servlets/format/ComponentRender.java b/src/com/silverwrist/venice/servlets/format/ComponentRender.java
new file mode 100644
index 0000000..de61378
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/ComponentRender.java
@@ -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 .
+ *
+ * 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 ,
+ * 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
diff --git a/src/com/silverwrist/venice/servlets/format/ConferenceListing.java b/src/com/silverwrist/venice/servlets/format/ConferenceListing.java
index e3a13bf..a8b5b0c 100644
--- a/src/com/silverwrist/venice/servlets/format/ConferenceListing.java
+++ b/src/com/silverwrist/venice/servlets/format/ConferenceListing.java
@@ -66,6 +66,17 @@ public class ConferenceListing implements JSPRender
} // end retrieve
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return "Conference Listing: " + sig.getName();
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/ConfirmBox.java b/src/com/silverwrist/venice/servlets/format/ConfirmBox.java
index 0d45ac1..209a7fa 100644
--- a/src/com/silverwrist/venice/servlets/format/ConfirmBox.java
+++ b/src/com/silverwrist/venice/servlets/format/ConfirmBox.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@@ -93,7 +93,18 @@ public class ConfirmBox implements ContentRender
} // end doConfirm
/*--------------------------------------------------------------------------------
- * Implementations from class ContentRender
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return title;
+
+ } // end getPageTitle
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface ContentRender
*--------------------------------------------------------------------------------
*/
diff --git a/src/com/silverwrist/venice/servlets/format/ContentDialog.java b/src/com/silverwrist/venice/servlets/format/ContentDialog.java
index a7f3322..6007668 100644
--- a/src/com/silverwrist/venice/servlets/format/ContentDialog.java
+++ b/src/com/silverwrist/venice/servlets/format/ContentDialog.java
@@ -122,6 +122,17 @@ public class ContentDialog implements Cloneable, ContentRender
{ // do nothing at this level
} // end validateWholeForm
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return title;
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* 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)
{
this.error_message = message;
diff --git a/src/com/silverwrist/venice/servlets/format/ContentMenuPanel.java b/src/com/silverwrist/venice/servlets/format/ContentMenuPanel.java
index 0603475..79f1e9d 100644
--- a/src/com/silverwrist/venice/servlets/format/ContentMenuPanel.java
+++ b/src/com/silverwrist/venice/servlets/format/ContentMenuPanel.java
@@ -99,6 +99,17 @@ public class ContentMenuPanel implements Cloneable, ContentRender
} // end constructor
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return title;
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface ContentRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/ContentRender.java b/src/com/silverwrist/venice/servlets/format/ContentRender.java
index 7cfbd6d..267c03c 100644
--- a/src/com/silverwrist/venice/servlets/format/ContentRender.java
+++ b/src/com/silverwrist/venice/servlets/format/ContentRender.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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.IOException;
-public interface ContentRender
+public interface ContentRender extends VeniceContent
{
public abstract void renderHere(Writer out, RenderData rdat) throws IOException;
diff --git a/src/com/silverwrist/venice/servlets/format/ErrorBox.java b/src/com/silverwrist/venice/servlets/format/ErrorBox.java
index 6cb2505..6d32252 100644
--- a/src/com/silverwrist/venice/servlets/format/ErrorBox.java
+++ b/src/com/silverwrist/venice/servlets/format/ErrorBox.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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.IOException;
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 message;
private String back;
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
public ErrorBox(String title, String message, String back)
{
+ super();
this.title = title;
this.message = message;
this.back = back;
@@ -38,6 +50,22 @@ public class ErrorBox implements ContentRender
} // 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
{
out.write("
");
diff --git a/src/com/silverwrist/venice/servlets/format/FindData.java b/src/com/silverwrist/venice/servlets/format/FindData.java
index 91a000e..007a761 100644
--- a/src/com/silverwrist/venice/servlets/format/FindData.java
+++ b/src/com/silverwrist/venice/servlets/format/FindData.java
@@ -138,6 +138,17 @@ public class FindData implements JSPRender, SearchMode
} // end retrieve
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return "Find";
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/JSPRender.java b/src/com/silverwrist/venice/servlets/format/JSPRender.java
index d826db3..2415a17 100644
--- a/src/com/silverwrist/venice/servlets/format/JSPRender.java
+++ b/src/com/silverwrist/venice/servlets/format/JSPRender.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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;
-public interface JSPRender
+public interface JSPRender extends VeniceContent
{
public abstract void store(ServletRequest request);
diff --git a/src/com/silverwrist/venice/servlets/format/ManageConference.java b/src/com/silverwrist/venice/servlets/format/ManageConference.java
new file mode 100644
index 0000000..c667f73
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/ManageConference.java
@@ -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 .
+ *
+ * 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 ,
+ * 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
diff --git a/src/com/silverwrist/venice/servlets/format/MenuSIG.java b/src/com/silverwrist/venice/servlets/format/MenuSIG.java
index b7618d4..566163d 100644
--- a/src/com/silverwrist/venice/servlets/format/MenuSIG.java
+++ b/src/com/silverwrist/venice/servlets/format/MenuSIG.java
@@ -23,7 +23,7 @@ import java.util.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
-public class MenuSIG implements ContentRender
+public class MenuSIG implements ComponentRender
{
private String image_url;
private boolean image_url_needs_fixup = false;
diff --git a/src/com/silverwrist/venice/servlets/format/MenuTop.java b/src/com/silverwrist/venice/servlets/format/MenuTop.java
index 9af54e5..e8c2fe2 100644
--- a/src/com/silverwrist/venice/servlets/format/MenuTop.java
+++ b/src/com/silverwrist/venice/servlets/format/MenuTop.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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.IOException;
-public class MenuTop implements ContentRender
+public class MenuTop implements ComponentRender
{
public MenuTop()
{ // constructor does nothing
diff --git a/src/com/silverwrist/venice/servlets/format/NewSIGWelcome.java b/src/com/silverwrist/venice/servlets/format/NewSIGWelcome.java
index 88ee8e3..57350ac 100644
--- a/src/com/silverwrist/venice/servlets/format/NewSIGWelcome.java
+++ b/src/com/silverwrist/venice/servlets/format/NewSIGWelcome.java
@@ -61,6 +61,17 @@ public class NewSIGWelcome implements JSPRender
} // end retrieve
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return "New SIG Created";
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/NewTopicForm.java b/src/com/silverwrist/venice/servlets/format/NewTopicForm.java
index f1dba8f..e9d1f86 100644
--- a/src/com/silverwrist/venice/servlets/format/NewTopicForm.java
+++ b/src/com/silverwrist/venice/servlets/format/NewTopicForm.java
@@ -70,6 +70,17 @@ public class NewTopicForm implements JSPRender
} // end retrieve
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return "Create New Topic";
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/PostPreview.java b/src/com/silverwrist/venice/servlets/format/PostPreview.java
index f41eda8..3af0eab 100644
--- a/src/com/silverwrist/venice/servlets/format/PostPreview.java
+++ b/src/com/silverwrist/venice/servlets/format/PostPreview.java
@@ -105,6 +105,17 @@ public class PostPreview implements JSPRender
} // end retrieve
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return "Previewing Message";
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/PostSlippage.java b/src/com/silverwrist/venice/servlets/format/PostSlippage.java
index 67ba6a4..22a238d 100644
--- a/src/com/silverwrist/venice/servlets/format/PostSlippage.java
+++ b/src/com/silverwrist/venice/servlets/format/PostSlippage.java
@@ -98,6 +98,17 @@ public class PostSlippage implements JSPRender
} // end retrieve
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return "Slippage or Double-Click Detected";
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/RenderData.java b/src/com/silverwrist/venice/servlets/format/RenderData.java
index 3231096..4d8f40a 100644
--- a/src/com/silverwrist/venice/servlets/format/RenderData.java
+++ b/src/com/silverwrist/venice/servlets/format/RenderData.java
@@ -308,6 +308,18 @@ public class RenderData
} // 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
{
response.setContentType(type);
diff --git a/src/com/silverwrist/venice/servlets/format/SIGCategoryBrowseData.java b/src/com/silverwrist/venice/servlets/format/SIGCategoryBrowseData.java
index cf84363..68f2afb 100644
--- a/src/com/silverwrist/venice/servlets/format/SIGCategoryBrowseData.java
+++ b/src/com/silverwrist/venice/servlets/format/SIGCategoryBrowseData.java
@@ -71,6 +71,17 @@ public class SIGCategoryBrowseData implements JSPRender
} // end retrieve
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return "Set SIG Category";
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/SIGProfileData.java b/src/com/silverwrist/venice/servlets/format/SIGProfileData.java
index b1d8572..d6a3338 100644
--- a/src/com/silverwrist/venice/servlets/format/SIGProfileData.java
+++ b/src/com/silverwrist/venice/servlets/format/SIGProfileData.java
@@ -70,6 +70,17 @@ public class SIGProfileData implements JSPRender
} // end retrieve
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return "SIG Profile: " + sig.getName();
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/SIGWelcome.java b/src/com/silverwrist/venice/servlets/format/SIGWelcome.java
index 0924990..d700bb5 100644
--- a/src/com/silverwrist/venice/servlets/format/SIGWelcome.java
+++ b/src/com/silverwrist/venice/servlets/format/SIGWelcome.java
@@ -61,6 +61,17 @@ public class SIGWelcome implements JSPRender
} // end retrieve
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return "Welcome to " + name;
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/TCStandardPanel.java b/src/com/silverwrist/venice/servlets/format/TCStandardPanel.java
index 728ea97..d042852 100644
--- a/src/com/silverwrist/venice/servlets/format/TCStandardPanel.java
+++ b/src/com/silverwrist/venice/servlets/format/TCStandardPanel.java
@@ -26,7 +26,7 @@ import com.silverwrist.venice.core.DataException;
public abstract class TCStandardPanel extends TopContentPanel
{
- class TCButton implements ContentRender
+ class TCButton implements ComponentRender
{
private String image;
private String alt_text;
diff --git a/src/com/silverwrist/venice/servlets/format/TopContent.java b/src/com/silverwrist/venice/servlets/format/TopContent.java
index 295c078..16c8aaa 100644
--- a/src/com/silverwrist/venice/servlets/format/TopContent.java
+++ b/src/com/silverwrist/venice/servlets/format/TopContent.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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
{
- // Static constants
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
public static final int MAX_COLS = 2;
- // Attributes
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
private int actual_cols = MAX_COLS;
private int[] col_sizes;
private Vector panels = new Vector();
private boolean display_configure;
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
public TopContent(UserContext uc) throws DataException
{
int i; // loop counter
@@ -74,6 +87,22 @@ public class TopContent implements ContentRender
} // 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
{
out.write("
\n");
@@ -108,6 +137,6 @@ public class TopContent implements ContentRender
rdat.writeFooter(out);
- } /* end renderHere */
+ } // end renderHere
} // end class TopContent
diff --git a/src/com/silverwrist/venice/servlets/format/TopContentPanel.java b/src/com/silverwrist/venice/servlets/format/TopContentPanel.java
index 887adf9..a12949c 100644
--- a/src/com/silverwrist/venice/servlets/format/TopContentPanel.java
+++ b/src/com/silverwrist/venice/servlets/format/TopContentPanel.java
@@ -22,7 +22,7 @@ import java.io.IOException;
import com.silverwrist.venice.core.UserContext;
import com.silverwrist.venice.core.DataException;
-public abstract class TopContentPanel implements ContentRender, Cloneable
+public abstract class TopContentPanel implements ComponentRender, Cloneable
{
protected TopContentPanel()
{ // do nothing
diff --git a/src/com/silverwrist/venice/servlets/format/TopicListing.java b/src/com/silverwrist/venice/servlets/format/TopicListing.java
index ab456ca..5ca0b7b 100644
--- a/src/com/silverwrist/venice/servlets/format/TopicListing.java
+++ b/src/com/silverwrist/venice/servlets/format/TopicListing.java
@@ -72,6 +72,17 @@ public class TopicListing implements JSPRender
} // end retrieve
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return "Topics in " + conf.getName();
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/TopicPosts.java b/src/com/silverwrist/venice/servlets/format/TopicPosts.java
index 9493ba5..358f5d7 100644
--- a/src/com/silverwrist/venice/servlets/format/TopicPosts.java
+++ b/src/com/silverwrist/venice/servlets/format/TopicPosts.java
@@ -89,6 +89,18 @@ public class TopicPosts implements JSPRender
} // 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
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/UserProfileData.java b/src/com/silverwrist/venice/servlets/format/UserProfileData.java
index e5f16a1..6338b10 100644
--- a/src/com/silverwrist/venice/servlets/format/UserProfileData.java
+++ b/src/com/silverwrist/venice/servlets/format/UserProfileData.java
@@ -60,6 +60,17 @@ public class UserProfileData implements JSPRender
} // end retrieve
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceContent
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getPageTitle(RenderData rdat)
+ {
+ return "User Profile - " + prof.getUserName();
+
+ } // end getPageTitle
+
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/servlets/format/VeniceContent.java b/src/com/silverwrist/venice/servlets/format/VeniceContent.java
new file mode 100644
index 0000000..4928de9
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/VeniceContent.java
@@ -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 .
+ *
+ * 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 ,
+ * 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
diff --git a/web/format/base.jsp b/web/format/base.jsp
index 9a93ef4..cc2671f 100644
--- a/web/format/base.jsp
+++ b/web/format/base.jsp
@@ -7,7 +7,7 @@
WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License.
- The Original Code is the Venice Web Community System.
+ The Original Code is the Venice Web Communities System.
The Initial Developer of the Original Code is Eric J. Bowersox ,
for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@@ -22,9 +22,10 @@
<%@ 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)
menu = new MenuTop();
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);
RenderData rdat = RenderConfig.createRenderData(application,request,response);
- BaseJSPData basedat = BaseJSPData.retrieve(request);
%>
- <%= rdat.getTitleTag(basedat.getTitle()) %>
+ <%= rdat.getTitleTag(basedat.getTitle(rdat)) %>
diff --git a/web/format/conferences.jsp b/web/format/conferences.jsp
index 806d2f9..b92e118 100644
--- a/web/format/conferences.jsp
+++ b/web/format/conferences.jsp
@@ -35,8 +35,7 @@
" ALT="*" WIDTH=14 HEIGHT=14 BORDER=0>
<% } // end if %>
diff --git a/web/format/find.jsp b/web/format/find.jsp
index 1fb9315..e08f384 100644
--- a/web/format/find.jsp
+++ b/web/format/find.jsp
@@ -7,7 +7,7 @@
WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License.
- The Original Code is the Venice Web Community System.
+ The Original Code is the Venice Web Communities System.
The Initial Developer of the Original Code is Eric J. Bowersox ,
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) %>
Display all categories whose name
- <% } else throw new InternalStateError("display parameter " + String.valueOf(data.getDisplayOption())
- + " invalid"); %>
+ <% } else throw new InternalStateError("display parameter " + data.getDisplayOption() + " invalid"); %>