*** empty log message ***
This commit is contained in:
583
src/com/silverwrist/venice/servlets/Account.java
Normal file
583
src/com/silverwrist/venice/servlets/Account.java
Normal file
@@ -0,0 +1,583 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class Account extends VeniceServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Category logger = Category.getInstance(Account.class.getName());
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private NewAccountDialog makeNewAccountDialog() throws ServletException
|
||||
{
|
||||
final String desired_name = "NewAccountDialog";
|
||||
DialogCache cache = DialogCache.getDialogCache(getServletContext());
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
NewAccountDialog template = new NewAccountDialog(getCountryList());
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
// return a new copy
|
||||
return (NewAccountDialog)(cache.getNewDialog(desired_name));
|
||||
|
||||
} // end makeNewAccountDialog
|
||||
|
||||
private LoginDialog makeLoginDialog()
|
||||
{
|
||||
final String desired_name = "LoginDialog";
|
||||
DialogCache cache = DialogCache.getDialogCache(getServletContext());
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
LoginDialog template = new LoginDialog();
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
// return a new copy
|
||||
return (LoginDialog)(cache.getNewDialog(desired_name));
|
||||
|
||||
} // end makeLoginDialog
|
||||
|
||||
private VerifyEmailDialog makeVerifyEmailDialog()
|
||||
{
|
||||
final String desired_name = "VerifyEmailDialog";
|
||||
DialogCache cache = DialogCache.getDialogCache(getServletContext());
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
VerifyEmailDialog template = new VerifyEmailDialog();
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
// return a new copy
|
||||
return (VerifyEmailDialog)(cache.getNewDialog(desired_name));
|
||||
|
||||
} // end makeVerifyEmailDialog
|
||||
|
||||
private EditProfileDialog makeEditProfileDialog() throws ServletException
|
||||
{
|
||||
final String desired_name = "EditProfileDialog";
|
||||
DialogCache cache = DialogCache.getDialogCache(getServletContext());
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
EditProfileDialog template = new EditProfileDialog(getCountryList());
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
// return a new copy
|
||||
return (EditProfileDialog)(cache.getNewDialog(desired_name));
|
||||
|
||||
} // end makeEditProfileDialog
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "Account servlet - Handles login, logout, account creation, and profiles\n"
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // 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;
|
||||
|
||||
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
|
||||
|
||||
if (cmd.equals("L"))
|
||||
{ // "L" = Log in/out
|
||||
if (user.isLoggedIn())
|
||||
{ // log the user out and send 'em back to the "top" page
|
||||
clearUserContext(request);
|
||||
// TODO: here is where the persistent cookie gets nuked, if it does...
|
||||
rdat.redirectTo("top");
|
||||
return;
|
||||
|
||||
} // end if (logging out)
|
||||
else
|
||||
{ // display the Login page
|
||||
LoginDialog dlg = makeLoginDialog();
|
||||
dlg.setupNew(tgt);
|
||||
page_title = dlg.getTitle();
|
||||
content = dlg;
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if ("L" command)
|
||||
else if (cmd.equals("C"))
|
||||
{ // "C" = create new account
|
||||
if (user.isLoggedIn())
|
||||
{ // you can't create a new account while logged in on an existing one!
|
||||
page_title = "Error";
|
||||
content = new ErrorBox(page_title,"You cannot create a new account while logged in on "
|
||||
+ "an existing one. You must log out first.",tgt);
|
||||
|
||||
} // end if
|
||||
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
|
||||
|
||||
} // end if ("C" command)
|
||||
else 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);
|
||||
|
||||
// prepare for display
|
||||
page_title = dlg.getTitle();
|
||||
content = dlg;
|
||||
|
||||
} // 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 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
|
||||
|
||||
} // end if ("P" command)
|
||||
else 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 "
|
||||
+ "email address.",tgt);
|
||||
|
||||
} // end else
|
||||
|
||||
} // 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 else
|
||||
|
||||
BaseJSPData basedat = new BaseJSPData(page_title,"account?cmd=" + cmd,content);
|
||||
basedat.displayLoginLinks(display_login);
|
||||
basedat.transfer(getServletContext(),rdat);
|
||||
|
||||
} // end doGet
|
||||
|
||||
public void doPost(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;
|
||||
|
||||
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
|
||||
|
||||
if (cmd.equals("L"))
|
||||
{ // log the user in
|
||||
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)
|
||||
|
||||
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"));
|
||||
|
||||
// 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);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError e2)
|
||||
{ // 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);
|
||||
|
||||
} // 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);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if ("reminder" button clicked)
|
||||
else if (dlg.isButtonClicked(request,"login"))
|
||||
{ // we actually want to try and log in! imagine that!
|
||||
dlg.loadValues(request); // load the values
|
||||
|
||||
try
|
||||
{ // use the user context to authenticate
|
||||
user.authenticate(dlg.getFieldValue("user"),dlg.getFieldValue("pass"));
|
||||
|
||||
// TODO: here is where the persistent cookie gets sent, if it does...
|
||||
|
||||
// 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;
|
||||
|
||||
} // end try
|
||||
catch (DataException e1)
|
||||
{ // this indicates a database error - display an ErrorBox
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error logging in: " + e1.getMessage(),tgt);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError e2)
|
||||
{ // this indicates a problem with the user account or password
|
||||
dlg.resetOnError(e2.getMessage());
|
||||
page_title = dlg.getTitle();
|
||||
content = dlg;
|
||||
|
||||
} // 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);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if ("L" command)
|
||||
else if (cmd.equals("C"))
|
||||
{ // C = Create New Account
|
||||
NewAccountDialog dlg = makeNewAccountDialog();
|
||||
dlg.setEngine(getVeniceEngine());
|
||||
|
||||
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)
|
||||
|
||||
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;
|
||||
|
||||
} // 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);
|
||||
|
||||
} // 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);
|
||||
|
||||
} // 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);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end else if ("C" command)
|
||||
else if (cmd.equals("V"))
|
||||
{ // V = Verify E-mail Address
|
||||
display_login = true;
|
||||
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)
|
||||
|
||||
if (dlg.isButtonClicked(request,"again"))
|
||||
{ // do a "send again"
|
||||
try
|
||||
{ // resend the email confirmation
|
||||
user.resendEmailConfirmation();
|
||||
|
||||
// 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);
|
||||
|
||||
} // 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);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if ("again" clicked)
|
||||
else if (dlg.isButtonClicked(request,"ok"))
|
||||
{ // try to verify the confirmation number
|
||||
dlg.loadValues(request); // load field values
|
||||
|
||||
try
|
||||
{ // validate that we have a good number
|
||||
dlg.validate();
|
||||
user.confirmEmail(dlg.getConfirmationNumber());
|
||||
|
||||
// go back to our desired location
|
||||
String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
|
||||
response.sendRedirect(url);
|
||||
return;
|
||||
|
||||
} // 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);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // access error in setting up the account
|
||||
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);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end else if ("V" command)
|
||||
else if (cmd.equals("P"))
|
||||
{ // P = Edit User Profile
|
||||
display_login = true;
|
||||
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)
|
||||
|
||||
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;
|
||||
|
||||
} // 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);
|
||||
|
||||
} // 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);
|
||||
|
||||
} // 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);
|
||||
|
||||
} // end else
|
||||
|
||||
} // 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);
|
||||
|
||||
} // end else
|
||||
|
||||
changeMenuTop(request);
|
||||
|
||||
BaseJSPData basedat = new BaseJSPData(page_title,"account?cmd=" + cmd,content);
|
||||
basedat.displayLoginLinks(display_login);
|
||||
basedat.transfer(getServletContext(),rdat);
|
||||
|
||||
} // end doPost
|
||||
|
||||
} // end class Account
|
||||
321
src/com/silverwrist/venice/servlets/ConfDisplay.java
Normal file
321
src/com/silverwrist/venice/servlets/ConfDisplay.java
Normal file
@@ -0,0 +1,321 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class ConfDisplay extends VeniceServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Category logger = Category.getInstance(ConfDisplay.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))
|
||||
return null; // no topic specified
|
||||
|
||||
try
|
||||
{ // turn the string into a TopicID, and thence to a TopicContext
|
||||
short topicid = Short.parseShort(str);
|
||||
return conf.getTopic(topicid);
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // error in Integer.parseInt
|
||||
logger.error("Cannot convert topic parameter '" + str + "'!");
|
||||
throw new ValidationException("Invalid topic parameter.");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getTopicParameter
|
||||
|
||||
private static void getViewSortDefaults(ServletRequest request, int confid, TopicSortHolder tsc)
|
||||
throws ValidationException
|
||||
{
|
||||
String str = request.getParameter("view");
|
||||
if (!(StringUtil.isStringEmpty(str)))
|
||||
{ // we need to change the view parameter
|
||||
try
|
||||
{ // convert the parameter to an integer and then check it against defined values
|
||||
int p = Integer.parseInt(str);
|
||||
switch (p)
|
||||
{
|
||||
case ConferenceContext.DISPLAY_NEW:
|
||||
case ConferenceContext.DISPLAY_ACTIVE:
|
||||
case ConferenceContext.DISPLAY_ALL:
|
||||
case ConferenceContext.DISPLAY_HIDDEN:
|
||||
case ConferenceContext.DISPLAY_ARCHIVED:
|
||||
tsc.setViewOption(confid,p);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ValidationException("Invalid view parameter.");
|
||||
|
||||
} // end switch
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // failure in parseInt
|
||||
logger.error("Cannot convert view parameter '" + str + "'!");
|
||||
throw new ValidationException("Invalid view parameter.");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
str = request.getParameter("sort");
|
||||
if (!(StringUtil.isStringEmpty(str)))
|
||||
{ // we need to change the sort parameter
|
||||
try
|
||||
{ // convert the parameter to an integer and then check it against defined values
|
||||
int p = Integer.parseInt(str);
|
||||
int real_p = ((p<0) ? -p : p);
|
||||
switch (real_p)
|
||||
{
|
||||
case ConferenceContext.SORT_NUMBER:
|
||||
case ConferenceContext.SORT_NAME:
|
||||
case ConferenceContext.SORT_UNREAD:
|
||||
case ConferenceContext.SORT_TOTAL:
|
||||
case ConferenceContext.SORT_DATE:
|
||||
tsc.setSortOption(confid,p);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ValidationException("Invalid sort parameter.");
|
||||
|
||||
} // end switch
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // failure in parseInt
|
||||
logger.error("Cannot convert sort parameter '" + str + "'!");
|
||||
throw new ValidationException("Invalid sort parameter.");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
} // end getViewSortDefaults
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "ConfDisplay servlet - Display of conference topic and message lists\n"
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
String page_title = null;
|
||||
Object content = null;
|
||||
SIGContext sig = null; // SIG context
|
||||
ConferenceContext conf = null; // conference context
|
||||
TopicContext topic = null; // topic context
|
||||
|
||||
try
|
||||
{ // this outer try is to catch ValidationException
|
||||
try
|
||||
{ // all commands require a SIG parameter
|
||||
sig = getSIGParameter(request,user);
|
||||
changeMenuSIG(request,sig);
|
||||
|
||||
} // 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);
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // error looking up the conference
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error finding conference: " + de.getMessage(),"top");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
if (content!=null)
|
||||
{ // we got the conference parameter OK
|
||||
try
|
||||
{ // there's an optional topic parameter
|
||||
topic = getTopicParameter(request,conf);
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // error looking up the conference
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error finding topic: " + de.getMessage(),"top");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
} // end try
|
||||
catch (ValidationException ve)
|
||||
{ // these all get handled in pretty much the same way
|
||||
page_title = "Error";
|
||||
content = new ErrorBox(null,ve.getMessage(),"top");
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // these all get handled in pretty much the same way
|
||||
page_title = "Access Error";
|
||||
content = new ErrorBox(page_title,ae.getMessage(),"top");
|
||||
|
||||
} // end catch
|
||||
|
||||
if (content!=null)
|
||||
{ // OK, let's handle the display now
|
||||
if (topic!=null)
|
||||
{ // we're handling messages within a single topic
|
||||
// TODO: handle this somehow
|
||||
} // end if
|
||||
else
|
||||
{ // we're displaying the conference's topic list
|
||||
TopicSortHolder opts = TopicSortHolder.retrieve(request.getSession(true));
|
||||
try
|
||||
{ // get any changes to view or sort options
|
||||
getViewSortDefaults(request,conf.getConfID(),opts);
|
||||
|
||||
// get the topic list in the desired order!
|
||||
List topic_list = conf.getTopicList(opts.getViewOption(conf.getConfID()),
|
||||
opts.getSortOption(conf.getConfID()));
|
||||
|
||||
// TODO: create the "next topic" list to use for "read next"
|
||||
|
||||
// TODO: create the page view
|
||||
|
||||
} // 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 class ConfDisplay
|
||||
303
src/com/silverwrist/venice/servlets/ConfOperations.java
Normal file
303
src/com/silverwrist/venice/servlets/ConfOperations.java
Normal file
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class ConfOperations extends VeniceServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Category logger = Category.getInstance(ConfOperations.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 CreateConferenceDialog makeCreateConferenceDialog() throws ServletException
|
||||
{
|
||||
final String desired_name = "CreateConferenceDialog";
|
||||
DialogCache cache = DialogCache.getDialogCache(getServletContext());
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
CreateConferenceDialog template = new CreateConferenceDialog();
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
// return a new copy
|
||||
return (CreateConferenceDialog)(cache.getNewDialog(desired_name));
|
||||
|
||||
} // end makeCreateConferenceDialog
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "ConfOperations servlet - General conference operations (list, create, etc.)\n"
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
String page_title = null;
|
||||
Object content = null;
|
||||
SIGContext sig = null;
|
||||
|
||||
try
|
||||
{ // all conference commands require a SIG parameter as well
|
||||
sig = getSIGParameter(request,user);
|
||||
changeMenuSIG(request,sig);
|
||||
|
||||
} // 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");
|
||||
|
||||
} // 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())
|
||||
{ // make the create conference dialog!
|
||||
CreateConferenceDialog dlg = makeCreateConferenceDialog();
|
||||
dlg.setupDialog(getVeniceEngine(),sig);
|
||||
content = dlg;
|
||||
page_title = dlg.getTitle();
|
||||
|
||||
} // 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");
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // any unrecognized command jumps us to "conference list"
|
||||
try
|
||||
{ // show the conference listing
|
||||
content = new ConferenceListing(sig);
|
||||
page_title = "Conference Listing: " + sig.getName();
|
||||
|
||||
} // 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 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()));
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if (SIG parameter retrieved OK)
|
||||
|
||||
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 back to the conference list
|
||||
// TODO: want to jump to the conference's "topic list" page if possible
|
||||
rdat.redirectTo(location);
|
||||
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
|
||||
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 class ConfOperations
|
||||
194
src/com/silverwrist/venice/servlets/Find.java
Normal file
194
src/com/silverwrist/venice/servlets/Find.java
Normal file
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class Find extends VeniceServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected static final String DISPLAY_PARAM_ATTRIBUTE = "servlet.Find.display";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static int getDisplayParam(HttpServletRequest request, int nchoices)
|
||||
{
|
||||
HttpSession session = request.getSession(true);
|
||||
|
||||
try
|
||||
{ // attempt to get the display parameter
|
||||
String dp_str = request.getParameter("disp");
|
||||
if (dp_str!=null)
|
||||
{ // attempt to convert to an integer and range-check it
|
||||
int dp = Integer.parseInt(dp_str);
|
||||
if ((dp>=0) && (dp<nchoices))
|
||||
{ // this is our new current display parameter
|
||||
session.setAttribute(DISPLAY_PARAM_ATTRIBUTE,new Integer(dp));
|
||||
return dp;
|
||||
|
||||
} // end if
|
||||
|
||||
} // end if (parameter found)
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // do nothing - fall through and get the stored default
|
||||
} // end catch
|
||||
|
||||
// retrieve the stored default from the HTTP session
|
||||
Integer dp_default = (Integer)(session.getAttribute(DISPLAY_PARAM_ATTRIBUTE));
|
||||
if (dp_default==null)
|
||||
{ // create an initial default and save it
|
||||
dp_default = new Integer(0);
|
||||
session.setAttribute(DISPLAY_PARAM_ATTRIBUTE,dp_default);
|
||||
|
||||
} // end if
|
||||
|
||||
return dp_default.intValue();
|
||||
|
||||
} // end getDisplayParam
|
||||
|
||||
private int getCategoryParam(ServletRequest request) throws ServletException
|
||||
{
|
||||
String cat_str = request.getParameter("cat");
|
||||
if (cat_str==null)
|
||||
return -1;
|
||||
|
||||
try
|
||||
{ // get the category ID and check it for validity
|
||||
int cat = Integer.parseInt(cat_str);
|
||||
if (getVeniceEngine().isValidCategoryID(cat))
|
||||
return cat;
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // do nothing - fall through and return -1
|
||||
} // end catch
|
||||
|
||||
return -1;
|
||||
|
||||
} // end getCategoryParam
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "Find servlet - The master search page\n"
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
String 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);
|
||||
|
||||
// figure out the category ID parameter
|
||||
int cat = -1;
|
||||
if (disp==FindData.FD_SIGS)
|
||||
cat = getCategoryParam(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");
|
||||
|
||||
} // end catch
|
||||
|
||||
BaseJSPData basedat = new BaseJSPData(page_title,"find?" + 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;
|
||||
|
||||
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);
|
||||
|
||||
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");
|
||||
|
||||
} // end catch
|
||||
catch (DataException de)
|
||||
{ // database error, man
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"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);
|
||||
|
||||
} // end doPost
|
||||
|
||||
} // end class Find
|
||||
441
src/com/silverwrist/venice/servlets/SIGAdmin.java
Normal file
441
src/com/silverwrist/venice/servlets/SIGAdmin.java
Normal file
@@ -0,0 +1,441 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class SIGAdmin extends VeniceServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Category logger = Category.getInstance(SIGAdmin.class.getName());
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private SIGAdminTop makeSIGAdminTop() throws ServletException
|
||||
{
|
||||
final String desired_name = "SIGAdminTop";
|
||||
MenuPanelCache cache = MenuPanelCache.getMenuPanelCache(getServletContext());
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
SIGAdminTop template = new SIGAdminTop();
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
// return a new copy
|
||||
return (SIGAdminTop)(cache.getNewMenuPanel(desired_name));
|
||||
|
||||
} // end makeSIGAdminTop
|
||||
|
||||
private EditSIGProfileDialog makeEditSIGProfileDialog() throws ServletException
|
||||
{
|
||||
final String desired_name = "EditSIGProfileDialog";
|
||||
DialogCache cache = DialogCache.getDialogCache(getServletContext());
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
EditSIGProfileDialog template = new EditSIGProfileDialog(getCountryList(),getLanguageList());
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
// return a new copy
|
||||
return (EditSIGProfileDialog)(cache.getNewDialog(desired_name));
|
||||
|
||||
} // end makeEditSIGProfileDialog
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "SIGAdmin servlet - Administrative functions for SIGs\n"
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
String page_title = null;
|
||||
Object content = null;
|
||||
|
||||
SIGContext sig = null;
|
||||
try
|
||||
{ // first get the SIG context we're working with
|
||||
int sigid = Integer.parseInt(request.getParameter("sig"));
|
||||
sig = user.getSIGContext(sigid);
|
||||
changeMenuSIG(request,sig);
|
||||
|
||||
} // 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");
|
||||
|
||||
} // end catch
|
||||
catch (DataException de)
|
||||
{ // unable to pull SIG data out of the database
|
||||
page_title = "Database Error";
|
||||
logger.error("database error looking up SIGID " + request.getParameter("sig"));
|
||||
content = new ErrorBox(page_title,"Database error accessing SIG: " + de.getMessage(),"top");
|
||||
|
||||
} // end catch
|
||||
|
||||
if (logger.isDebugEnabled() && (sig!=null))
|
||||
logger.debug("SIGAdmin/doGet operating on SIG \"" + sig.getName() + "\" ("
|
||||
+ String.valueOf(sig.getSIGID()) + ")");
|
||||
|
||||
if (content==null)
|
||||
{ // now decide what to do based on the "cmd" parameter
|
||||
String cmd = request.getParameter("cmd");
|
||||
if (cmd==null)
|
||||
cmd = "???"; // something pretty much guaranteed not to be used
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("SIGAdmin/doGet command value = " + cmd);
|
||||
|
||||
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();
|
||||
|
||||
try
|
||||
{ // load the values for this dialog
|
||||
dlg.setupDialog(getVeniceEngine(),sig);
|
||||
|
||||
// prepare for display
|
||||
page_title = dlg.getTitle();
|
||||
content = dlg;
|
||||
|
||||
} // 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()));
|
||||
|
||||
} // 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 catch
|
||||
|
||||
} // 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 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
|
||||
|
||||
sig.setCategoryID(catid);
|
||||
|
||||
// now that the category ID is set, go back to the admin menu
|
||||
String target = "sigadmin?sig=" + String.valueOf(sig.getSIGID());
|
||||
String url = response.encodeRedirectURL(rdat.getFullServletPath(target));
|
||||
response.sendRedirect(url);
|
||||
return;
|
||||
|
||||
} // end try
|
||||
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 (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
|
||||
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()));
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if (actually setting the category
|
||||
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);
|
||||
|
||||
if (!(getVeniceEngine().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";
|
||||
|
||||
} // 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 (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
|
||||
|
||||
} // end else (browsing through categories)
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // no access - sorry man
|
||||
page_title = "Unauthorized";
|
||||
logger.error("tried to call up SIG category set screen without access...naughty naughty!");
|
||||
content = new ErrorBox(page_title,"You do not have access to modify this SIG's profile.",
|
||||
"sigadmin?sig=" + String.valueOf(sig.getSIGID()));
|
||||
|
||||
} // end else
|
||||
|
||||
} // end else 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)
|
||||
|
||||
} // end if
|
||||
// else getting the SIG already caused problems
|
||||
|
||||
BaseJSPData basedat = new BaseJSPData(page_title,"sigadmin?" + request.getQueryString(),content);
|
||||
basedat.transfer(getServletContext(),rdat);
|
||||
|
||||
} // end doGet
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
String page_title = null;
|
||||
ContentRender content = null;
|
||||
|
||||
SIGContext sig = null;
|
||||
try
|
||||
{ // first get the SIG context we're working with
|
||||
int sigid = Integer.parseInt(request.getParameter("sig"));
|
||||
sig = user.getSIGContext(sigid);
|
||||
changeMenuSIG(request,sig);
|
||||
|
||||
} // 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");
|
||||
|
||||
} // end catch
|
||||
catch (DataException de)
|
||||
{ // unable to pull SIG data out of the database
|
||||
page_title = "Database Error";
|
||||
logger.error("database error looking up SIGID " + request.getParameter("sig"));
|
||||
content = new ErrorBox(page_title,"Database error accessing SIG: " + de.getMessage(),"top");
|
||||
|
||||
} // end catch
|
||||
|
||||
if (logger.isDebugEnabled() && (sig!=null))
|
||||
logger.debug("SIGAdmin/doPost operating on SIG \"" + sig.getName() + "\" ("
|
||||
+ String.valueOf(sig.getSIGID()) + ")");
|
||||
|
||||
if (content==null)
|
||||
{ // now decide what to do based on the "cmd" parameter
|
||||
String cmd = request.getParameter("cmd");
|
||||
if (cmd==null)
|
||||
cmd = "???"; // something pretty much guaranteed not to be used
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("SIGAdmin/doPost command value = " + cmd);
|
||||
|
||||
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,"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;
|
||||
|
||||
} // end if ("cancel" button clicked)
|
||||
|
||||
if (dlg.isButtonClicked(request,"update"))
|
||||
{ // begin updating the SIG's contents
|
||||
dlg.loadValues(request); // do value loading now
|
||||
|
||||
try
|
||||
{ // attempt to change the SIG profile now...
|
||||
dlg.doDialog(sig);
|
||||
|
||||
// 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 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
|
||||
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()));
|
||||
|
||||
} // 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 catch
|
||||
|
||||
} // 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 else
|
||||
|
||||
} // 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 class SIGAdmin
|
||||
77
src/com/silverwrist/venice/servlets/SIGFrontEnd.java
Normal file
77
src/com/silverwrist/venice/servlets/SIGFrontEnd.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class SIGFrontEnd extends VeniceServlet
|
||||
{
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "SIGFrontEnd servlet - Redirects to the \"default feature\" of a SIG\n"
|
||||
+ "Part of the Venice Web conferencing system\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
String page_title = null;
|
||||
ContentRender content = null;
|
||||
|
||||
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
|
||||
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");
|
||||
|
||||
// redirect to the appropriate top-level page!
|
||||
String url = response.encodeRedirectURL(rdat.getFullServletPath(def_applet));
|
||||
response.sendRedirect(url);
|
||||
return;
|
||||
|
||||
} // 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");
|
||||
|
||||
} // 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 class SIGFrontEnd
|
||||
456
src/com/silverwrist/venice/servlets/SIGOperations.java
Normal file
456
src/com/silverwrist/venice/servlets/SIGOperations.java
Normal file
@@ -0,0 +1,456 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class SIGOperations extends VeniceServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final String UNJOIN_CONFIRM_ATTR = "servlets.SIGOperations.unjoin.confirm";
|
||||
private static final String UNJOIN_CONFIRM_PARAM = "confirm";
|
||||
|
||||
private static Category logger = Category.getInstance(SIGOperations.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 JoinKeyDialog makeJoinKeyDialog()
|
||||
{
|
||||
final String desired_name = "JoinKeyDialog";
|
||||
DialogCache cache = DialogCache.getDialogCache(getServletContext());
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
JoinKeyDialog template = new JoinKeyDialog();
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
// return a new copy
|
||||
return (JoinKeyDialog)(cache.getNewDialog(desired_name));
|
||||
|
||||
} // end makeJoinKeyDialog
|
||||
|
||||
private CreateSIGDialog makeCreateSIGDialog() throws ServletException
|
||||
{
|
||||
final String desired_name = "CreateSIGDialog";
|
||||
DialogCache cache = DialogCache.getDialogCache(getServletContext());
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
CreateSIGDialog template = new CreateSIGDialog(getCountryList(),getLanguageList());
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
// return a new copy
|
||||
return (CreateSIGDialog)(cache.getNewDialog(desired_name));
|
||||
|
||||
} // end makeCreateSIGDialog
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "SIGOperations servlet - General SIG operations (join, unjoin, etc.)\n"
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
String page_title = null;
|
||||
Object content = null;
|
||||
|
||||
// get the command we want to use
|
||||
String cmd = request.getParameter("cmd");
|
||||
if (cmd==null)
|
||||
cmd = "???";
|
||||
|
||||
if (cmd.equals("J"))
|
||||
{ // "J" = "Join" (requires SIG parameter)
|
||||
try
|
||||
{ // get the SIG parameter first!
|
||||
SIGContext sig = getSIGParameter(request,user);
|
||||
|
||||
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);
|
||||
|
||||
// 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 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);
|
||||
|
||||
} // end else (private SIG)
|
||||
|
||||
} // end if (allowed to join the SIG)
|
||||
else
|
||||
{ // throw an error
|
||||
page_title = "Error";
|
||||
content = new ErrorBox("SIG Error","You are not permitted to join this SIG.","top");
|
||||
|
||||
} // end else
|
||||
|
||||
} // end try
|
||||
catch (AccessError ae)
|
||||
{ // access error
|
||||
page_title = "Access Error";
|
||||
content = new ErrorBox(page_title,"Unable to join SIG: " + ae.getMessage(),"top");
|
||||
|
||||
} // end catch
|
||||
catch (DataException de)
|
||||
{ // data exception doing something
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error joining SIG: " + de.getMessage(),"top");
|
||||
|
||||
} // end catch
|
||||
catch (ValidationException ve)
|
||||
{ // validation error - wrong parameters, likely
|
||||
page_title = "Error";
|
||||
content = new ErrorBox(null,ve.getMessage(),"top");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if ("J" command)
|
||||
else if (cmd.equals("U"))
|
||||
{ // "U" = "Unjoin (requires SIG parameter)
|
||||
try
|
||||
{ // get the SIG parameter first!
|
||||
SIGContext sig = getSIGParameter(request,user);
|
||||
|
||||
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();
|
||||
|
||||
// after which, let's just go back to top
|
||||
clearMenu(request); // force the clear to regen the menus
|
||||
rdat.redirectTo("top");
|
||||
return;
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // not a proper confirmation - better display one
|
||||
String message = "Are you sure you want to unjoin the '" + sig.getName() + "' SIG?";
|
||||
String confirm_url = "sigops?cmd=U&sig=" + String.valueOf(sig.getSIGID());
|
||||
String deny_url = "sig/" + sig.getAlias();
|
||||
page_title = "Unjoining SIG";
|
||||
content = new ConfirmBox(request,UNJOIN_CONFIRM_ATTR,UNJOIN_CONFIRM_PARAM,page_title,
|
||||
message,confirm_url,deny_url);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // throw an error
|
||||
page_title = "Error";
|
||||
content = new ErrorBox("SIG Error","You cannot unjoin this SIG.","top");
|
||||
|
||||
} // end else
|
||||
|
||||
} // end try
|
||||
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);
|
||||
|
||||
} // 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");
|
||||
|
||||
} // 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 else
|
||||
|
||||
BaseJSPData basedat = new BaseJSPData(page_title,"sigops?" + 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;
|
||||
|
||||
// get the command we want to use
|
||||
String cmd = request.getParameter("cmd");
|
||||
if (cmd==null)
|
||||
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();
|
||||
|
||||
if (dlg.isButtonClicked(request,"cancel"))
|
||||
{ // canceled join - return to SIG opening page
|
||||
rdat.redirectTo("sig/" + sig.getAlias());
|
||||
return;
|
||||
|
||||
} // end if
|
||||
|
||||
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
|
||||
|
||||
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.");
|
||||
content = dlg;
|
||||
page_title = "Join SIG";
|
||||
changeMenuSIG(request,sig);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // throw an error
|
||||
page_title = "Error";
|
||||
content = new ErrorBox("SIG Error","You are not permitted to join this SIG.","top");
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if ("join" button clicked)
|
||||
else
|
||||
{ // error - don't know what button was clicked
|
||||
page_title = "Internal Error";
|
||||
logger.error("no known button click on SIGOperations.doPost, cmd=J");
|
||||
content = new ErrorBox(page_title,"Unknown command button pressed","top");
|
||||
|
||||
} // end else
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // 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
|
||||
|
||||
} // end if ("J" command)
|
||||
else if (cmd.equals("C"))
|
||||
{ // "C" = Create New SIG
|
||||
if (user.canCreateSIG())
|
||||
{ // load the "Create SIG" dialog
|
||||
CreateSIGDialog dlg = makeCreateSIGDialog();
|
||||
dlg.setupDialog(getVeniceEngine());
|
||||
|
||||
if (dlg.isButtonClicked(request,"cancel"))
|
||||
{ // canceled create - return to top page
|
||||
rdat.redirectTo("top");
|
||||
return;
|
||||
|
||||
} // end if
|
||||
|
||||
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);
|
||||
|
||||
// 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!
|
||||
|
||||
} // 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 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 (DataException de)
|
||||
{ // database error doing something
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Database error creating SIG: " + de.getMessage(),"top");
|
||||
|
||||
} // 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");
|
||||
|
||||
} // end else
|
||||
|
||||
} // 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");
|
||||
|
||||
} // end else
|
||||
|
||||
} // 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");
|
||||
|
||||
} // end else
|
||||
|
||||
BaseJSPData basedat = new BaseJSPData(page_title,"top",content);
|
||||
basedat.transfer(getServletContext(),rdat);
|
||||
|
||||
} // end doPost
|
||||
|
||||
} // end class SIGOperations
|
||||
75
src/com/silverwrist/venice/servlets/SIGProfile.java
Normal file
75
src/com/silverwrist/venice/servlets/SIGProfile.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class SIGProfile extends VeniceServlet
|
||||
{
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "SIGProfile servlet - Displays the profile of a SIG\n"
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
String page_title = null;
|
||||
Object content = null;
|
||||
|
||||
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();
|
||||
changeMenuSIG(request,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");
|
||||
|
||||
} // end catch
|
||||
|
||||
BaseJSPData basedat = new BaseJSPData(page_title,"sigprofile?" + request.getQueryString(),content);
|
||||
basedat.transfer(getServletContext(),rdat);
|
||||
|
||||
} // end doGet
|
||||
|
||||
} // end class SIGProfile
|
||||
87
src/com/silverwrist/venice/servlets/Top.java
Normal file
87
src/com/silverwrist/venice/servlets/Top.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import org.apache.log4j.xml.DOMConfigurator;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class Top extends VeniceServlet
|
||||
{
|
||||
public void init(ServletConfig config) throws ServletException
|
||||
{
|
||||
super.init(config); // required before we do anything else
|
||||
ServletContext ctxt = config.getServletContext();
|
||||
|
||||
// Initialize LOG4J logging.
|
||||
DOMConfigurator.configure(ctxt.getInitParameter("logging.config"));
|
||||
|
||||
// Initialize the Venice engine.
|
||||
VeniceEngine engine = getVeniceEngine(ctxt);
|
||||
|
||||
// Initialize the Venice rendering system.
|
||||
RenderConfig.getRenderConfig(ctxt);
|
||||
|
||||
} // end init
|
||||
|
||||
public void destroy()
|
||||
{
|
||||
super.destroy();
|
||||
|
||||
} // end destroy
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "Top applet - Displays the Venice front page\n"
|
||||
+ "Part of the Venice Web conferencing system\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
ContentRender content = null;
|
||||
String page_title = "My Front Page";
|
||||
|
||||
try
|
||||
{ // attempt to get the user content
|
||||
content = new TopContent(user);
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
{ // there was a database error, whoops!
|
||||
page_title = "Database Error";
|
||||
content = new ErrorBox(page_title,"Error loading front page: " + e.getMessage(),null);
|
||||
|
||||
} // end catch
|
||||
|
||||
changeMenuTop(request);
|
||||
|
||||
BaseJSPData basedat = new BaseJSPData(page_title,"top",content);
|
||||
basedat.transfer(getServletContext(),rdat);
|
||||
|
||||
} // end doGet
|
||||
|
||||
} // end class Top
|
||||
161
src/com/silverwrist/venice/servlets/TopicSortHolder.java
Normal file
161
src/com/silverwrist/venice/servlets/TopicSortHolder.java
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.util.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import com.silverwrist.venice.core.ConferenceContext;
|
||||
|
||||
public class TopicSortHolder
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal class for holding view and sort options
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static class SortHolderItem
|
||||
{
|
||||
int view_opt;
|
||||
int sort_opt;
|
||||
|
||||
SortHolderItem(int view_opt, int sort_opt)
|
||||
{
|
||||
this.view_opt = view_opt;
|
||||
this.sort_opt = sort_opt;
|
||||
|
||||
} // end constructor
|
||||
|
||||
int getViewOption()
|
||||
{
|
||||
return view_opt;
|
||||
|
||||
} // end getViewOption
|
||||
|
||||
void setViewOption(int val)
|
||||
{
|
||||
view_opt = val;
|
||||
|
||||
} // end setViewOption
|
||||
|
||||
int getSortOption()
|
||||
{
|
||||
return sort_opt;
|
||||
|
||||
} // end getSortOption
|
||||
|
||||
void setSortOption(int val)
|
||||
{
|
||||
sort_opt = val;
|
||||
|
||||
} // end setSortOption
|
||||
|
||||
} // end class SortHolderItem
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected static final String ATTRIBUTE = "conf.display.topic.sort";
|
||||
protected static final int DEFAULT_VIEW = ConferenceContext.DISPLAY_ACTIVE;
|
||||
protected static final int DEFAULT_SORT = ConferenceContext.SORT_NUMBER;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private Hashtable hash = new Hashtable();
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected TopicSortHolder()
|
||||
{ // this does nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private SortHolderItem getItem(int confid)
|
||||
{
|
||||
Integer the_confid = new Integer(confid);
|
||||
SortHolderItem item = (SortHolderItem)(hash.get(the_confid));
|
||||
if (item==null)
|
||||
{ // create a new item...
|
||||
item = new SortHolderItem(DEFAULT_VIEW,DEFAULT_SORT);
|
||||
hash.put(the_confid,item);
|
||||
|
||||
} // end if
|
||||
|
||||
return item;
|
||||
|
||||
} // end getItem
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static TopicSortHolder retrieve(HttpSession session)
|
||||
{
|
||||
Object tmp = session.getAttribute(ATTRIBUTE);
|
||||
if (tmp!=null)
|
||||
return (TopicSortHolder)tmp;
|
||||
|
||||
TopicSortHolder rc = new TopicSortHolder();
|
||||
session.setAttribute(ATTRIBUTE,rc);
|
||||
return rc;
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public int getViewOption(int confid)
|
||||
{
|
||||
return getItem(confid).getViewOption();
|
||||
|
||||
} // end getViewOption
|
||||
|
||||
public void setViewOption(int confid, int opt)
|
||||
{
|
||||
getItem(confid).setViewOption(opt);
|
||||
|
||||
} // end setViewOption
|
||||
|
||||
public int getSortOption(int confid)
|
||||
{
|
||||
return getItem(confid).getSortOption();
|
||||
|
||||
} // end getSortOption
|
||||
|
||||
public void setSortOption(int confid, int opt)
|
||||
{
|
||||
getItem(confid).setSortOption(opt);
|
||||
|
||||
} // end setSortOption
|
||||
|
||||
} // end class TopicSortHolder
|
||||
67
src/com/silverwrist/venice/servlets/UserDisplay.java
Normal file
67
src/com/silverwrist/venice/servlets/UserDisplay.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class UserDisplay extends VeniceServlet
|
||||
{
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "UserDisplay servlet - Displays Venice user profiles\n"
|
||||
+ "Part of the Venice Web conferencing system\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
UserContext user = getUserContext(request);
|
||||
RenderData rdat = createRenderData(request,response);
|
||||
String page_title = null;
|
||||
Object content = null;
|
||||
|
||||
try
|
||||
{ // use the request path info to get the username to load the profile from
|
||||
String uname = request.getPathInfo().substring(1);
|
||||
UserProfile prof = user.getProfile(uname);
|
||||
content = new UserProfileData(prof);
|
||||
page_title = "User Profile - " + prof.getUserName();
|
||||
|
||||
} // 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");
|
||||
|
||||
} // 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 class UserDisplay
|
||||
235
src/com/silverwrist/venice/servlets/Variables.java
Normal file
235
src/com/silverwrist/venice/servlets/Variables.java
Normal file
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.util.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class Variables
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data values
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// ServletContext ("application") attributes
|
||||
protected static final String ENGINE_ATTRIBUTE = "com.silverwrist.venice.core.Engine";
|
||||
protected static final String COUNTRYLIST_ATTRIBUTE = "com.silverwrist.venice.db.CountryList";
|
||||
protected static final String LANGUAGELIST_ATTRIBUTE = "com.silverwrist.venice.db.LanguageList";
|
||||
protected static final String TOPMENU_ATTRIBUTE = "com.silverwrist.venice.servlets.MenuTop";
|
||||
|
||||
// HttpSession ("session") attributes
|
||||
protected static final String USERCTXT_ATTRIBUTE = "user.context";
|
||||
protected static final String MENU_ATTRIBUTE = "current.menu";
|
||||
|
||||
// Servlet initialization parameters
|
||||
protected static final String ENGINE_INIT_PARAM = "venice.config";
|
||||
|
||||
// Cookie name
|
||||
public static final String LOGIN_COOKIE = "VeniceLogin";
|
||||
|
||||
private static Category logger = Category.getInstance(Variables.class.getName());
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static VeniceEngine getVeniceEngine(ServletContext ctxt) throws ServletException
|
||||
{
|
||||
Object foo = ctxt.getAttribute(ENGINE_ATTRIBUTE);
|
||||
if (foo!=null)
|
||||
return (VeniceEngine)foo;
|
||||
|
||||
String cfgfile = ctxt.getInitParameter(ENGINE_INIT_PARAM); // get the config file name
|
||||
logger.info("Initializing Venice engine using config file: " + cfgfile);
|
||||
|
||||
try
|
||||
{ // extract the configuration file name and create the engine
|
||||
VeniceEngine engine = Startup.createEngine(cfgfile);
|
||||
ctxt.setAttribute(ENGINE_ATTRIBUTE,engine);
|
||||
return engine;
|
||||
|
||||
} // end try
|
||||
catch (ConfigException e)
|
||||
{ // configuration failed! post an error message
|
||||
logger.fatal("Engine configuration failed: " + e.getMessage(),e);
|
||||
throw new ServletException("Venice engine configuration failed: " + e.getMessage(),e);
|
||||
|
||||
} // end catch
|
||||
catch (DataException e2)
|
||||
{ // configuration failed! post an error message
|
||||
logger.fatal("Engine data load failed: " + e2.getMessage(),e2);
|
||||
throw new ServletException("Venice engine data load failed: " + e2.getMessage(),e2);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getVeniceEngine
|
||||
|
||||
public static UserContext getUserContext(ServletContext ctxt, ServletRequest request, HttpSession session)
|
||||
throws ServletException
|
||||
{
|
||||
Object uctmp = session.getAttribute(USERCTXT_ATTRIBUTE);
|
||||
if (uctmp!=null)
|
||||
return (UserContext)uctmp;
|
||||
|
||||
try
|
||||
{ // use the Venice engine to create a new user context and save it off
|
||||
VeniceEngine engine = getVeniceEngine(ctxt);
|
||||
UserContext user = engine.createUserContext(request.getRemoteAddr());
|
||||
session.setAttribute(USERCTXT_ATTRIBUTE,user);
|
||||
return user;
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
{ // context creation failed - remap the exception
|
||||
logger.error("Session creation failed: " + e.getMessage(),e);
|
||||
throw new ServletException("Session creation failed: " + e.getMessage(),e);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getUserContext
|
||||
|
||||
public static void putUserContext(HttpSession session, UserContext user)
|
||||
{
|
||||
session.setAttribute(USERCTXT_ATTRIBUTE,user);
|
||||
session.removeAttribute(MENU_ATTRIBUTE);
|
||||
|
||||
} // end putUserContext
|
||||
|
||||
public static void clearUserContext(HttpSession session)
|
||||
{
|
||||
session.removeAttribute(USERCTXT_ATTRIBUTE);
|
||||
session.removeAttribute(MENU_ATTRIBUTE);
|
||||
|
||||
} // end clearUserContext
|
||||
|
||||
public static List getCountryList(ServletContext ctxt) throws ServletException
|
||||
{
|
||||
Object foo = ctxt.getAttribute(COUNTRYLIST_ATTRIBUTE);
|
||||
if (foo!=null)
|
||||
return (List)foo;
|
||||
|
||||
VeniceEngine engine = getVeniceEngine(ctxt);
|
||||
|
||||
try
|
||||
{ // get the country list via the engine and save it
|
||||
List rc = engine.getCountryList();
|
||||
ctxt.setAttribute(COUNTRYLIST_ATTRIBUTE,rc);
|
||||
return rc;
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
{ // the country list could not be retrieved
|
||||
logger.error("Failed to retrieve country list from engine: " + e.getMessage(),e);
|
||||
throw new ServletException("Country list retrieval failed: " + e.getMessage(),e);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getCountryList
|
||||
|
||||
public static List getLanguageList(ServletContext ctxt) throws ServletException
|
||||
{
|
||||
Object foo = ctxt.getAttribute(LANGUAGELIST_ATTRIBUTE);
|
||||
if (foo!=null)
|
||||
return (List)foo;
|
||||
|
||||
VeniceEngine engine = getVeniceEngine(ctxt);
|
||||
|
||||
try
|
||||
{ // get the country list via the engine and save it
|
||||
List rc = engine.getLanguageList();
|
||||
ctxt.setAttribute(LANGUAGELIST_ATTRIBUTE,rc);
|
||||
return rc;
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
{ // the country list could not be retrieved
|
||||
logger.error("Failed to retrieve language list from engine: " + e.getMessage(),e);
|
||||
throw new ServletException("Language list retrieval failed: " + e.getMessage(),e);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getLanguageList
|
||||
|
||||
public static ContentRender getMenu(HttpSession session)
|
||||
{
|
||||
return (ContentRender)(session.getAttribute(MENU_ATTRIBUTE));
|
||||
|
||||
} // end getMenu
|
||||
|
||||
public static void setMenuTop(ServletContext ctxt, HttpSession session)
|
||||
{
|
||||
Object obj = session.getAttribute(MENU_ATTRIBUTE);
|
||||
if ((obj==null) || !(obj instanceof MenuTop))
|
||||
{ // look for the common MenuTop object and set it to the session context
|
||||
obj = ctxt.getAttribute(TOPMENU_ATTRIBUTE);
|
||||
if (obj==null)
|
||||
{ // we don't have a common MenuTop yet...make one
|
||||
MenuTop mt = new MenuTop();
|
||||
ctxt.setAttribute(TOPMENU_ATTRIBUTE,mt);
|
||||
obj = mt;
|
||||
|
||||
} // end if
|
||||
|
||||
session.setAttribute(MENU_ATTRIBUTE,obj);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end setMenuTop
|
||||
|
||||
public static void setMenuSIG(HttpSession session, SIGContext sig)
|
||||
{
|
||||
Object obj = session.getAttribute(MENU_ATTRIBUTE);
|
||||
boolean do_change;
|
||||
if ((obj==null) || !(obj instanceof MenuSIG))
|
||||
do_change = true;
|
||||
else
|
||||
{ // look at the actual SIGIDs underlying the MenuSIG
|
||||
MenuSIG tmp = (MenuSIG)obj;
|
||||
do_change = (tmp.getID()!=sig.getSIGID());
|
||||
|
||||
} // end else
|
||||
|
||||
if (do_change)
|
||||
{ // switch to the appropriate MenuSIG
|
||||
MenuSIG ms = new MenuSIG(sig);
|
||||
session.setAttribute(MENU_ATTRIBUTE,ms);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end setMenuSIG
|
||||
|
||||
public static void clearMenu(HttpSession session)
|
||||
{
|
||||
session.removeAttribute(MENU_ATTRIBUTE);
|
||||
|
||||
} // end clearMenu
|
||||
|
||||
public static void failIfNull(Object obj) throws ServletException
|
||||
{
|
||||
if (obj==null)
|
||||
throw new ServletException("improper context - data not set");
|
||||
|
||||
} // end failIfNull
|
||||
|
||||
} // end class Variables
|
||||
127
src/com/silverwrist/venice/servlets/VeniceServlet.java
Normal file
127
src/com/silverwrist/venice/servlets/VeniceServlet.java
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.util.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public abstract class VeniceServlet extends HttpServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data values
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Category logger = Category.getInstance(VeniceServlet.class.getName());
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations intended for use by derived classes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected static 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
|
||||
{
|
||||
return Variables.getVeniceEngine(ctxt);
|
||||
|
||||
} // end getVeniceEngine
|
||||
|
||||
protected VeniceEngine getVeniceEngine() throws ServletException
|
||||
{
|
||||
return Variables.getVeniceEngine(getServletContext());
|
||||
|
||||
} // end getVeniceEngine
|
||||
|
||||
protected UserContext getUserContext(HttpServletRequest request) throws ServletException
|
||||
{
|
||||
return Variables.getUserContext(getServletContext(),request,request.getSession(true));
|
||||
|
||||
} // end getUserContext
|
||||
|
||||
protected void putUserContext(HttpServletRequest request, UserContext ctxt)
|
||||
{
|
||||
Variables.putUserContext(request.getSession(true),ctxt);
|
||||
|
||||
} // end putUserContext
|
||||
|
||||
protected void clearUserContext(HttpServletRequest request)
|
||||
{
|
||||
Variables.clearUserContext(request.getSession(true));
|
||||
|
||||
} // end clearUserContext
|
||||
|
||||
protected static List getCountryList(ServletContext ctxt) throws ServletException
|
||||
{
|
||||
return Variables.getCountryList(ctxt);
|
||||
|
||||
} // end getCountryList
|
||||
|
||||
protected List getCountryList() throws ServletException
|
||||
{
|
||||
return Variables.getCountryList(getServletContext());
|
||||
|
||||
} // end getCountryList
|
||||
|
||||
protected List getLanguageList(ServletContext ctxt) throws ServletException
|
||||
{
|
||||
return Variables.getLanguageList(ctxt);
|
||||
|
||||
} // end getLanguageList
|
||||
|
||||
protected List getLanguageList() throws ServletException
|
||||
{
|
||||
return Variables.getLanguageList(getServletContext());
|
||||
|
||||
} // end getLanguageList
|
||||
|
||||
protected void changeMenuTop(HttpServletRequest request)
|
||||
{
|
||||
Variables.setMenuTop(getServletContext(),request.getSession(true));
|
||||
|
||||
} // end changeMenuTop
|
||||
|
||||
protected void changeMenuSIG(HttpServletRequest request, SIGContext sig)
|
||||
{
|
||||
Variables.setMenuSIG(request.getSession(true),sig);
|
||||
|
||||
} // end changeMenuSIG
|
||||
|
||||
protected void clearMenu(HttpServletRequest request)
|
||||
{
|
||||
Variables.clearMenu(request.getSession(true));
|
||||
|
||||
} // end clearMenu
|
||||
|
||||
protected RenderData createRenderData(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException
|
||||
{
|
||||
return RenderConfig.createRenderData(getServletContext(),request,response);
|
||||
|
||||
} // end createRenderData
|
||||
|
||||
} // end class VeniceServlet
|
||||
151
src/com/silverwrist/venice/servlets/format/BaseJSPData.java
Normal file
151
src/com/silverwrist/venice/servlets/format/BaseJSPData.java
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
|
||||
public class BaseJSPData
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.BaseJSPData";
|
||||
|
||||
private static Category logger = Category.getInstance(BaseJSPData.class.getName());
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
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 boolean login_links = true; // show login links up top?
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public BaseJSPData(String title, String location, Object content)
|
||||
{
|
||||
this.title = title;
|
||||
this.location = location;
|
||||
this.content = content;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static BaseJSPData retrieve(ServletRequest request)
|
||||
{
|
||||
return (BaseJSPData)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void store(ServletRequest request)
|
||||
{
|
||||
request.setAttribute(ATTR_NAME,this);
|
||||
|
||||
} // end store
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
|
||||
} // end getTitle
|
||||
|
||||
public String getLocation()
|
||||
{
|
||||
return location;
|
||||
|
||||
} // end getLocation
|
||||
|
||||
public boolean displayLoginLinks()
|
||||
{
|
||||
return login_links;
|
||||
|
||||
} // end displayLoginLinks
|
||||
|
||||
public void displayLoginLinks(boolean value)
|
||||
{
|
||||
login_links = value;
|
||||
|
||||
} // end displayLoginLinks
|
||||
|
||||
public void transfer(ServletContext ctxt, RenderData rdat) throws IOException, ServletException
|
||||
{
|
||||
rdat.storeBaseJSPData(this);
|
||||
RequestDispatcher dispatcher = ctxt.getRequestDispatcher(rdat.getFormatJSPPath("base.jsp"));
|
||||
rdat.forwardDispatch(dispatcher);
|
||||
|
||||
} // end transfer
|
||||
|
||||
public void renderContent(ServletContext ctxt, Writer out, RenderData rdat)
|
||||
throws IOException, ServletException
|
||||
{
|
||||
if (content==null)
|
||||
{ // there is no content!
|
||||
ErrorBox box = new ErrorBox(null,"Internal Error: There is no content available",null);
|
||||
box.renderHere(out,rdat);
|
||||
return;
|
||||
|
||||
} // end if
|
||||
|
||||
if (content instanceof ContentRender)
|
||||
{ // we have an old-style ContentRender
|
||||
ContentRender cr = (ContentRender)content;
|
||||
cr.renderHere(out,rdat);
|
||||
return;
|
||||
|
||||
} // end if
|
||||
|
||||
if (content instanceof JSPRender)
|
||||
{ // we have a JSP-rendered page - include it
|
||||
JSPRender jr = (JSPRender)content;
|
||||
rdat.storeJSPRender(jr);
|
||||
RequestDispatcher dispatcher = ctxt.getRequestDispatcher(rdat.getFormatJSPPath(jr.getTargetJSPName()));
|
||||
out.flush();
|
||||
rdat.flushOutput(); // make sure the stuff to be output first is output
|
||||
rdat.includeDispatch(dispatcher);
|
||||
rdat.flushOutput(); // now make sure the included page is properly flushed
|
||||
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);
|
||||
|
||||
} // end renderContent
|
||||
|
||||
} // end class BaseJSPData
|
||||
136
src/com/silverwrist/venice/servlets/format/CDBaseFormField.java
Normal file
136
src/com/silverwrist/venice/servlets/format/CDBaseFormField.java
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
|
||||
public abstract class CDBaseFormField implements CDFormField
|
||||
{
|
||||
private String name;
|
||||
private String caption;
|
||||
private String caption2;
|
||||
private boolean required;
|
||||
private String value = null;
|
||||
private boolean enabled;
|
||||
|
||||
protected CDBaseFormField(String name, String caption, String caption2, boolean required)
|
||||
{
|
||||
this.name = name;
|
||||
this.caption = caption;
|
||||
this.caption2 = caption2;
|
||||
this.required = required;
|
||||
this.enabled = true;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDBaseFormField(CDBaseFormField other)
|
||||
{
|
||||
this.name = other.name;
|
||||
this.caption = other.caption;
|
||||
this.caption2 = other.caption2;
|
||||
this.required = other.required;
|
||||
this.enabled = true;
|
||||
// N.B.: do NOT copy value!
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected abstract void renderActualField(Writer out, RenderData rdat)
|
||||
throws IOException;
|
||||
|
||||
protected void validateContents(String value) throws ValidationException
|
||||
{ // this is a do-nothing value
|
||||
} // end validateContents
|
||||
|
||||
protected final String getCaption()
|
||||
{
|
||||
return caption;
|
||||
|
||||
} // end getCaption
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<TR VALIGN=MIDDLE>\n<TD ALIGN=RIGHT>");
|
||||
if (!enabled)
|
||||
out.write("<FONT COLOR=\"silver\">");
|
||||
out.write(StringUtil.encodeHTML(caption));
|
||||
if (caption2!=null)
|
||||
out.write(" " + StringUtil.encodeHTML(caption2));
|
||||
if (!enabled)
|
||||
out.write("</FONT>");
|
||||
if (required)
|
||||
out.write(rdat.getRequiredBullet());
|
||||
out.write(":</TD>\n<TD ALIGN=LEFT>");
|
||||
renderActualField(out,rdat);
|
||||
out.write("</TD>\n</TR>\n");
|
||||
|
||||
} // end renderHere
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
|
||||
} // end getName
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return value;
|
||||
|
||||
} // end getValue
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
this.value = value;
|
||||
|
||||
} // end setValue
|
||||
|
||||
public boolean isRequired()
|
||||
{
|
||||
return required;
|
||||
|
||||
} // end isRequired
|
||||
|
||||
public CDCommandButton findButton(String name)
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end findButton
|
||||
|
||||
public void validate() throws ValidationException
|
||||
{
|
||||
if (required && enabled && StringUtil.isStringEmpty(value))
|
||||
throw new ValidationException("The '" + caption + "' field is required.");
|
||||
validateContents(value);
|
||||
|
||||
} // end validate
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
|
||||
} // end isEnabled
|
||||
|
||||
public void setEnabled(boolean flag)
|
||||
{
|
||||
enabled = flag;
|
||||
|
||||
} // end setEnabled
|
||||
|
||||
} // end CDBaseFormField
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
|
||||
public abstract class CDBaseFormFieldReverse implements CDFormField
|
||||
{
|
||||
private String name;
|
||||
private String caption;
|
||||
private String caption2;
|
||||
private boolean required;
|
||||
private String value = null;
|
||||
private boolean enabled;
|
||||
|
||||
protected CDBaseFormFieldReverse(String name, String caption, String caption2, boolean required)
|
||||
{
|
||||
this.name = name;
|
||||
this.caption = caption;
|
||||
this.caption2 = caption2;
|
||||
this.required = required;
|
||||
this.enabled = true;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDBaseFormFieldReverse(CDBaseFormFieldReverse other)
|
||||
{
|
||||
this.name = other.name;
|
||||
this.caption = other.caption;
|
||||
this.caption2 = other.caption2;
|
||||
this.required = other.required;
|
||||
this.enabled = true;
|
||||
// N.B.: do NOT copy value!
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected abstract void renderActualField(Writer out, RenderData rdat)
|
||||
throws IOException;
|
||||
|
||||
protected void validateContents(String value) throws ValidationException
|
||||
{ // this is a do-nothing value
|
||||
} // end validateContents
|
||||
|
||||
protected final String getCaption()
|
||||
{
|
||||
return caption;
|
||||
|
||||
} // end getCaption
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<TR VALIGN=MIDDLE>\n<TD ALIGN=RIGHT>");
|
||||
renderActualField(out,rdat);
|
||||
out.write("</TD>\n<TD ALIGN=LEFT>");
|
||||
if (!enabled)
|
||||
out.write("<FONT COLOR=\"silver\">");
|
||||
out.write(StringUtil.encodeHTML(caption));
|
||||
if (caption2!=null)
|
||||
out.write(" " + StringUtil.encodeHTML(caption2));
|
||||
if (!enabled)
|
||||
out.write("</FONT>");
|
||||
if (required)
|
||||
out.write(rdat.getRequiredBullet());
|
||||
out.write("</TD>\n</TR>\n");
|
||||
|
||||
} // end renderHere
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
|
||||
} // end getName
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return value;
|
||||
|
||||
} // end getValue
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
this.value = value;
|
||||
|
||||
} // end setValue
|
||||
|
||||
public boolean isRequired()
|
||||
{
|
||||
return required;
|
||||
|
||||
} // end isRequired
|
||||
|
||||
public CDCommandButton findButton(String name)
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end findButton
|
||||
|
||||
public void validate() throws ValidationException
|
||||
{
|
||||
if (required && enabled && StringUtil.isStringEmpty(value))
|
||||
throw new ValidationException("The '" + caption + "' field is required.");
|
||||
validateContents(value);
|
||||
|
||||
} // end validate
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
|
||||
} // end isEnabled
|
||||
|
||||
public void setEnabled(boolean flag)
|
||||
{
|
||||
enabled = flag;
|
||||
|
||||
} // end setEnabled
|
||||
|
||||
} // end CDBaseFormFieldReverse
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
|
||||
public class CDCheckBoxFormField extends CDBaseFormFieldReverse
|
||||
{
|
||||
private String on_value;
|
||||
|
||||
public CDCheckBoxFormField(String name, String caption, String caption2, String on_value)
|
||||
{
|
||||
super(name,caption,caption2,false);
|
||||
this.on_value = on_value;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDCheckBoxFormField(CDCheckBoxFormField other)
|
||||
{
|
||||
super(other);
|
||||
this.on_value = other.on_value;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void renderActualField(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<INPUT TYPE=CHECKBOX NAME=\"" + getName() + "\" VALUE=\"" + on_value + "\"");
|
||||
if (!isEnabled())
|
||||
out.write(" DISABLED");
|
||||
if (on_value.equals(getValue()))
|
||||
out.write(" CHECKED");
|
||||
out.write(">");
|
||||
|
||||
} // end renderActualField
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDCheckBoxFormField(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class CDCheckBoxFormField
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
public interface CDCommandButton extends ContentRender
|
||||
{
|
||||
public abstract String getName();
|
||||
|
||||
public abstract boolean isClicked(ServletRequest request);
|
||||
|
||||
} // end interface CDCommandButton
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.List;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.Country;
|
||||
|
||||
public class CDCountryListFormField extends CDPickListFormField
|
||||
{
|
||||
public CDCountryListFormField(String name, String caption, String caption2, boolean required,
|
||||
List country_list)
|
||||
{
|
||||
super(name,caption,caption2,required,country_list);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDCountryListFormField(CDCountryListFormField other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void renderChoice(Writer out, RenderData rdat, Object obj, String my_value) throws IOException
|
||||
{
|
||||
Country c = (Country)obj;
|
||||
out.write("<OPTION VALUE=\"" + c.getCode() + "\"");
|
||||
if (c.getCode().equals(my_value))
|
||||
out.write(" SELECTED");
|
||||
out.write(">" + StringUtil.encodeHTML(c.getName()) + "</OPTION>\n");
|
||||
|
||||
} // end renderChoice
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDCountryListFormField(this);
|
||||
|
||||
} // end duplicate
|
||||
|
||||
} // end class CDCountryListFormField
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import com.silverwrist.venice.core.IDUtils;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
|
||||
public class CDEmailAddressFormField extends CDTextFormField
|
||||
{
|
||||
public CDEmailAddressFormField(String name, String caption, String caption2, boolean required,
|
||||
int size, int maxlength)
|
||||
{
|
||||
super(name,caption,caption2,required,size,maxlength);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDEmailAddressFormField(CDEmailAddressFormField other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void validateContents(String value) throws ValidationException
|
||||
{
|
||||
if (!IDUtils.isValidEmailAddress(value))
|
||||
throw new ValidationException("The value of '" + getCaption() + "' must be a correct Internet address.");
|
||||
|
||||
} // end validateContents
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new CDEmailAddressFormField(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class CDEmailAddressFormField
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
|
||||
public class CDFormCategoryHeader implements CDFormField
|
||||
{
|
||||
private String caption;
|
||||
private String rtext;
|
||||
private boolean enabled;
|
||||
|
||||
public CDFormCategoryHeader(String caption)
|
||||
{
|
||||
this.caption = caption;
|
||||
this.rtext = null;
|
||||
this.enabled = true;
|
||||
|
||||
} // end constructor
|
||||
|
||||
public CDFormCategoryHeader(String caption, String rtext)
|
||||
{
|
||||
this.caption = caption;
|
||||
this.rtext = rtext;
|
||||
this.enabled = true;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDFormCategoryHeader(CDFormCategoryHeader other)
|
||||
{
|
||||
this.caption = other.caption;
|
||||
this.rtext = other.rtext;
|
||||
this.enabled = true;
|
||||
|
||||
} // end constructor
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<TR VALIGN=MIDDLE><TD ALIGN=RIGHT>");
|
||||
if (!enabled)
|
||||
out.write("<FONT COLOR=\"silver\">");
|
||||
out.write("<B>" + StringUtil.encodeHTML(caption) + ":</B>");
|
||||
if (!enabled)
|
||||
out.write("</FONT>");
|
||||
out.write("</TD><TD ALIGN=LEFT>");
|
||||
if (rtext==null)
|
||||
out.write(" ");
|
||||
else
|
||||
{ // display in the correct state
|
||||
if (!enabled)
|
||||
out.write("<FONT COLOR=\"silver\">");
|
||||
out.write(StringUtil.encodeHTML(rtext));
|
||||
if (!enabled)
|
||||
out.write("</FONT>");
|
||||
|
||||
} // end else
|
||||
|
||||
out.write("</TD></TR>\n");
|
||||
|
||||
} // end renderHere
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end getName
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end getValue
|
||||
|
||||
public void setValue(String value)
|
||||
{ // do nothing
|
||||
} // end setValue
|
||||
|
||||
public boolean isRequired()
|
||||
{
|
||||
return false;
|
||||
|
||||
} // end isRequired
|
||||
|
||||
public void validate()
|
||||
{ // do nothing
|
||||
} // end validate
|
||||
|
||||
public CDCommandButton findButton(String name)
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end findButton
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
|
||||
} // end isEnabled
|
||||
|
||||
public void setEnabled(boolean flag)
|
||||
{
|
||||
enabled = flag;
|
||||
|
||||
} // end setEnabled
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDFormCategoryHeader(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class CDFormCategoryHeader
|
||||
|
||||
42
src/com/silverwrist/venice/servlets/format/CDFormField.java
Normal file
42
src/com/silverwrist/venice/servlets/format/CDFormField.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
|
||||
public interface CDFormField extends ContentRender
|
||||
{
|
||||
public abstract String getName();
|
||||
|
||||
public abstract String getValue();
|
||||
|
||||
public abstract void setValue(String value);
|
||||
|
||||
public abstract boolean isRequired();
|
||||
|
||||
public abstract void validate() throws ValidationException;
|
||||
|
||||
public abstract CDCommandButton findButton(String name);
|
||||
|
||||
public abstract boolean isEnabled();
|
||||
|
||||
public abstract void setEnabled(boolean flag);
|
||||
|
||||
public abstract CDFormField duplicate();
|
||||
|
||||
} // end interface CDFormField
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
public class CDImageButton implements CDCommandButton
|
||||
{
|
||||
private String name; // name of the button field
|
||||
private String image; // image file to output
|
||||
private String alt_text; // alt text to output
|
||||
private int width; // width of button image
|
||||
private int height; // height of button image
|
||||
|
||||
public CDImageButton(String name, String image, String alt_text, int width, int height)
|
||||
{
|
||||
this.name = name;
|
||||
this.image = image;
|
||||
this.alt_text = alt_text;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
} // end constructor
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<INPUT TYPE=IMAGE NAME=\"" + name + "\" SRC=\"" + rdat.getFullImagePath(image) + "\"");
|
||||
if (alt_text!=null)
|
||||
out.write(" ALT=\"" + alt_text + "\"");
|
||||
out.write(" WIDTH=" + String.valueOf(width) + " HEIGHT=" + String.valueOf(height) + " BORDER=0>");
|
||||
|
||||
} // end renderHere
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
|
||||
} // end getName
|
||||
|
||||
public boolean isClicked(ServletRequest request)
|
||||
{
|
||||
String val = request.getParameter(name + ".x");
|
||||
return (val!=null);
|
||||
|
||||
} // end isClicked
|
||||
|
||||
} // end class CDImageButton
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.List;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.Language;
|
||||
|
||||
public class CDLanguageListFormField extends CDPickListFormField
|
||||
{
|
||||
public CDLanguageListFormField(String name, String caption, String caption2, boolean required,
|
||||
List language_list)
|
||||
{
|
||||
super(name,caption,caption2,required,language_list);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDLanguageListFormField(CDLanguageListFormField other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void renderChoice(Writer out, RenderData rdat, Object obj, String my_value) throws IOException
|
||||
{
|
||||
Language l = (Language)obj;
|
||||
out.write("<OPTION VALUE=\"" + l.getCode() + "\"");
|
||||
if (l.getCode().equals(my_value))
|
||||
out.write(" SELECTED");
|
||||
out.write(">" + StringUtil.encodeHTML(l.getName()) + "</OPTION>\n");
|
||||
|
||||
} // end renderChoice
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDLanguageListFormField(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class CDLanguageListFormField
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
|
||||
public class CDPasswordFormField extends CDBaseFormField
|
||||
{
|
||||
private int size;
|
||||
private int maxlength;
|
||||
|
||||
public CDPasswordFormField(String name, String caption, String caption2, boolean required,
|
||||
int size, int maxlength)
|
||||
{
|
||||
super(name,caption,caption2,required);
|
||||
this.size = size;
|
||||
this.maxlength = maxlength;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDPasswordFormField(CDPasswordFormField other)
|
||||
{
|
||||
super(other);
|
||||
this.size = other.size;
|
||||
this.maxlength = other.maxlength;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void renderActualField(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<INPUT TYPE=PASSWORD NAME=\"" + getName() + "\" SIZE=" + String.valueOf(size));
|
||||
out.write(" MAXLENGTH=" + String.valueOf(maxlength));
|
||||
if (!isEnabled())
|
||||
out.write(" DISABLED");
|
||||
out.write(" VALUE=\"");
|
||||
if (getValue()!=null)
|
||||
out.write(getValue());
|
||||
out.write("\">");
|
||||
|
||||
} // end renderActualField
|
||||
|
||||
protected void validateContents(String value) throws ValidationException
|
||||
{ // this is a do-nothing value
|
||||
} // end validateContents
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDPasswordFormField(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class CDPasswordFormField
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
public class CDPasswordFormFieldCommand extends CDPasswordFormField
|
||||
{
|
||||
private CDCommandButton button;
|
||||
|
||||
public CDPasswordFormFieldCommand(String name, String caption, String caption2, boolean required,
|
||||
int size, int maxlength, CDCommandButton button)
|
||||
{
|
||||
super(name,caption,caption2,required,size,maxlength);
|
||||
this.button = button;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDPasswordFormFieldCommand(CDPasswordFormFieldCommand other)
|
||||
{
|
||||
super(other);
|
||||
this.button = other.button;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void renderActualField(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
super.renderActualField(out,rdat);
|
||||
if (button!=null)
|
||||
{ // add the button
|
||||
out.write(" ");
|
||||
button.renderHere(out,rdat);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end renderActualField
|
||||
|
||||
public CDCommandButton findButton(String name)
|
||||
{
|
||||
if ((button!=null) && (button.getName().equals(name)))
|
||||
return button;
|
||||
else
|
||||
return super.findButton(name);
|
||||
|
||||
} // end findButton
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDPasswordFormFieldCommand(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class CDPasswordFormFieldCommand
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
|
||||
public abstract class CDPickListFormField extends CDBaseFormField
|
||||
{
|
||||
private List choices;
|
||||
|
||||
protected CDPickListFormField(String name, String caption, String caption2, boolean required,
|
||||
List choices)
|
||||
{
|
||||
super(name,caption,caption2,required);
|
||||
this.choices = choices;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDPickListFormField(CDPickListFormField other)
|
||||
{
|
||||
super(other);
|
||||
this.choices = other.choices;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected abstract void renderChoice(Writer out, RenderData rdat, Object obj, String my_value)
|
||||
throws IOException;
|
||||
|
||||
protected void renderActualField(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<SELECT NAME=\"" + getName() + "\" SIZE=1");
|
||||
if (!isEnabled())
|
||||
out.write(" DISABLED");
|
||||
out.write(">\n");
|
||||
Iterator it = choices.iterator();
|
||||
while (it.hasNext())
|
||||
{ // render each of the choices in turn
|
||||
Object c = it.next();
|
||||
renderChoice(out,rdat,c,getValue());
|
||||
|
||||
} // end while
|
||||
|
||||
out.write("</SELECT>\n"); // all done
|
||||
|
||||
} // end renderActualField
|
||||
|
||||
} // end class CDPickListFormField
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.List;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.security.Role;
|
||||
|
||||
public class CDRoleListFormField extends CDPickListFormField
|
||||
{
|
||||
public CDRoleListFormField(String name, String caption, String caption2, boolean required,
|
||||
List role_list)
|
||||
{
|
||||
super(name,caption,caption2,required,role_list);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDRoleListFormField(CDRoleListFormField other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void renderChoice(Writer out, RenderData rdat, Object obj, String my_value) throws IOException
|
||||
{
|
||||
Role r = (Role)obj;
|
||||
out.write("<OPTION VALUE=\"" + String.valueOf(r.getLevel()) + "\"");
|
||||
if ((my_value!=null) && my_value.equals(String.valueOf(r.getLevel())))
|
||||
out.write(" SELECTED");
|
||||
out.write(">" + StringUtil.encodeHTML(r.getName()) + "</OPTION>\n");
|
||||
|
||||
} // end renderChoice
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDRoleListFormField(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class CDRoleListFormField
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.List;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
|
||||
public class CDSimplePickListFormField extends CDPickListFormField
|
||||
{
|
||||
private char separator;
|
||||
|
||||
public CDSimplePickListFormField(String name, String caption, String caption2, boolean required,
|
||||
List string_list, char separator)
|
||||
{
|
||||
super(name,caption,caption2,required,string_list);
|
||||
this.separator = separator;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDSimplePickListFormField(CDSimplePickListFormField other)
|
||||
{
|
||||
super(other);
|
||||
this.separator = other.separator;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void renderChoice(Writer out, RenderData rdat, Object obj, String my_value) throws IOException
|
||||
{
|
||||
String full = (String)obj;
|
||||
int breakpt = full.indexOf(separator);
|
||||
String val = full.substring(0,breakpt);
|
||||
out.write("<OPTION VALUE=\"" + val + "\"");
|
||||
if (val.equals(my_value))
|
||||
out.write(" SELECTED");
|
||||
out.write(">" + StringUtil.encodeHTML(full.substring(breakpt+1)) + "</OPTION>\n");
|
||||
|
||||
} // end renderChoice
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDSimplePickListFormField(this);
|
||||
|
||||
} // end duplicate
|
||||
|
||||
} // end class CDSimplePickListFormField
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
|
||||
public class CDTextFormField extends CDBaseFormField
|
||||
{
|
||||
private int size;
|
||||
private int maxlength;
|
||||
|
||||
public CDTextFormField(String name, String caption, String caption2, boolean required,
|
||||
int size, int maxlength)
|
||||
{
|
||||
super(name,caption,caption2,required);
|
||||
this.size = size;
|
||||
this.maxlength = maxlength;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDTextFormField(CDTextFormField other)
|
||||
{
|
||||
super(other);
|
||||
this.size = other.size;
|
||||
this.maxlength = other.maxlength;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void renderActualField(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<INPUT TYPE=TEXT NAME=\"" + getName() + "\" SIZE=" + String.valueOf(size));
|
||||
out.write(" MAXLENGTH=" + String.valueOf(maxlength));
|
||||
if (!isEnabled())
|
||||
out.write(" DISABLED");
|
||||
out.write(" VALUE=\"");
|
||||
if (getValue()!=null)
|
||||
out.write(getValue());
|
||||
out.write("\">");
|
||||
|
||||
} // end renderActualField
|
||||
|
||||
protected void validateContents(String value) throws ValidationException
|
||||
{ // this is a do-nothing value
|
||||
} // end validateContents
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDTextFormField(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class CDTextFormField
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import com.silverwrist.venice.core.IDUtils;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
|
||||
public class CDVeniceIDFormField extends CDTextFormField
|
||||
{
|
||||
public CDVeniceIDFormField(String name, String caption, String caption2, boolean required,
|
||||
int size, int maxlength)
|
||||
{
|
||||
super(name,caption,caption2,required,size,maxlength);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDVeniceIDFormField(CDVeniceIDFormField other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void validateContents(String value) throws ValidationException
|
||||
{
|
||||
if (!IDUtils.isValidVeniceID(value))
|
||||
throw new ValidationException("There is an invalid character in the '" + getCaption() + "'field. "
|
||||
+ "Valid characters are letters, digits, -, _, !, ~, *, ', and $.");
|
||||
|
||||
} // end validateContents
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDVeniceIDFormField(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class CDVeniceIDFormField
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import javax.servlet.ServletRequest;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class ConferenceListing implements JSPRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Attribute name for request attribute
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ConferenceListing";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private SIGContext sig;
|
||||
private List conferences;
|
||||
private List[] hosts;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public ConferenceListing(SIGContext sig) throws DataException, AccessError
|
||||
{
|
||||
this.sig = sig;
|
||||
this.conferences = sig.getConferences();
|
||||
this.hosts = new List[this.conferences.size()];
|
||||
for (int i=0; i<this.conferences.size(); i++)
|
||||
this.hosts[i] = ((ConferenceContext)(this.conferences.get(i))).getHosts();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static ConferenceListing retrieve(ServletRequest request)
|
||||
{
|
||||
return (ConferenceListing)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface JSPRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void store(ServletRequest request)
|
||||
{
|
||||
request.setAttribute(ATTR_NAME,this);
|
||||
|
||||
} // end store
|
||||
|
||||
public String getTargetJSPName()
|
||||
{
|
||||
return "conferences.jsp";
|
||||
|
||||
} // end getTargetJSPName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public int getSIGID()
|
||||
{
|
||||
return sig.getSIGID();
|
||||
|
||||
} // end getSIGID
|
||||
|
||||
public String getSIGName()
|
||||
{
|
||||
return sig.getName();
|
||||
|
||||
} // end getSIGName
|
||||
|
||||
public int getNumConferences()
|
||||
{
|
||||
return conferences.size();
|
||||
|
||||
} // end getNumConferences
|
||||
|
||||
public int getConferenceID(int ndx)
|
||||
{
|
||||
return ((ConferenceContext)(conferences.get(ndx))).getConfID();
|
||||
|
||||
} // end getConferenceID
|
||||
|
||||
public String getConferenceName(int ndx)
|
||||
{
|
||||
return ((ConferenceContext)(conferences.get(ndx))).getName();
|
||||
|
||||
} // end getConferenceID
|
||||
|
||||
public String getDescription(int ndx)
|
||||
{
|
||||
return ((ConferenceContext)(conferences.get(ndx))).getDescription();
|
||||
|
||||
} // end getDescription
|
||||
|
||||
public Date getLastUpdateDate(int ndx)
|
||||
{
|
||||
return ((ConferenceContext)(conferences.get(ndx))).getLastUpdateDate();
|
||||
|
||||
} // end getLastUpdateDate
|
||||
|
||||
public int getNumHosts(int ndx)
|
||||
{
|
||||
return hosts[ndx].size();
|
||||
|
||||
} // end getNumHosts
|
||||
|
||||
public String getHostName(int ndx, int h)
|
||||
{
|
||||
return ((UserFound)(hosts[ndx].get(h))).getName();
|
||||
|
||||
} // end getHostName
|
||||
|
||||
public boolean canCreateConference()
|
||||
{
|
||||
return sig.canCreateConference();
|
||||
|
||||
} // end canCreateConference
|
||||
|
||||
} // end class ConferenceListing
|
||||
154
src/com/silverwrist/venice/servlets/format/ConfirmBox.java
Normal file
154
src/com/silverwrist/venice/servlets/format/ConfirmBox.java
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
|
||||
public class ConfirmBox implements ContentRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final long TIMEOUT = 60000; // 1 minute
|
||||
|
||||
private static Random rng = null;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private int conf_num;
|
||||
private String title;
|
||||
private String message;
|
||||
private String confirm_url;
|
||||
private String deny_url;
|
||||
private Date created;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public ConfirmBox(HttpServletRequest request, String attr_name, String param_name, String title,
|
||||
String message, String confirm_url, String deny_url)
|
||||
{
|
||||
if (rng==null)
|
||||
{ // initialize the random number gnerator
|
||||
Date now = new Date();
|
||||
rng = new Random(now.getTime());
|
||||
|
||||
} // end if
|
||||
|
||||
// Fill in all the parameters except created.
|
||||
this.conf_num = rng.nextInt(0x1000000);
|
||||
this.title = title;
|
||||
this.message = message;
|
||||
this.confirm_url = confirm_url + "&" + param_name + "=" + String.valueOf(this.conf_num);
|
||||
this.deny_url = deny_url;
|
||||
|
||||
// Stash this object in the HTTP session.
|
||||
HttpSession session = request.getSession(true);
|
||||
session.setAttribute(attr_name,this);
|
||||
|
||||
// Now start the timer ticking...
|
||||
this.created = new Date();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected boolean doConfirm(int test_num)
|
||||
{
|
||||
Date now = new Date();
|
||||
if ((now.getTime()-created.getTime())>TIMEOUT)
|
||||
return false;
|
||||
return (test_num==conf_num);
|
||||
|
||||
} // end doConfirm
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from class ContentRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<P><TABLE ALIGN=CENTER WIDTH=\"70%\" BORDER=1 CELLPADDING=2 CELLSPACING=1>");
|
||||
out.write("<TR VALIGN=MIDDLE><TD ALIGN=CENTER BGCOLOR=\"#006600\">\n");
|
||||
out.write(rdat.getStdFontTag("white",3) + StringUtil.encodeHTML(title) + "</FONT>\n");
|
||||
out.write("</TD></TR><TR VALIGN=MIDDLE><TD ALIGN=CENTER>\n");
|
||||
out.write(rdat.getStdFontTag(null,3) + "<P>" + StringUtil.encodeHTML(message) + "<P>\n");
|
||||
out.write("<A HREF=\"" + rdat.getEncodedServletPath(confirm_url) + "\">");
|
||||
out.write("<IMG SRC=\"" + rdat.getFullImagePath("bn_yes.gif")
|
||||
+ "\" ALT=\"Yes\" WIDTH=80 HEIGHT=24 BORDER=0></A> \n");
|
||||
out.write("<A HREF=\"" + rdat.getEncodedServletPath(deny_url) + "\">");
|
||||
out.write("<IMG SRC=\"" + rdat.getFullImagePath("bn_no.gif")
|
||||
+ "\" ALT=\"No\" WIDTH=80 HEIGHT=24 BORDER=0></A>\n");
|
||||
out.write("</FONT></TD></TR></TABLE><P>\n");
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static boolean isConfirmed(HttpServletRequest request, String attr_name, String param_name)
|
||||
{
|
||||
// First, get the ConfirmBox out of the session data
|
||||
HttpSession session = request.getSession(true);
|
||||
Object obj = session.getAttribute(attr_name);
|
||||
session.removeAttribute(attr_name); // we can only get it out once!
|
||||
if ((obj==null) || !(obj instanceof ConfirmBox)) // this is not a valid ConfirmBox!
|
||||
return false;
|
||||
ConfirmBox cb = (ConfirmBox)obj;
|
||||
|
||||
// Now get the confirmation number out of the URL parameters.
|
||||
String test_num_str = request.getParameter(param_name);
|
||||
if (test_num_str==null)
|
||||
return false; // no confirmation!
|
||||
|
||||
int test_num;
|
||||
try
|
||||
{ // convert to an integer
|
||||
test_num = Integer.parseInt(test_num_str);
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // if the confirmation number is bogus, we're h0sed
|
||||
return false;
|
||||
|
||||
} // end catch
|
||||
|
||||
return cb.doConfirm(test_num);
|
||||
|
||||
} // end isConfirmed
|
||||
|
||||
} // end class ConfirmBox
|
||||
408
src/com/silverwrist/venice/servlets/format/ContentDialog.java
Normal file
408
src/com/silverwrist/venice/servlets/format/ContentDialog.java
Normal file
@@ -0,0 +1,408 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
|
||||
public class ContentDialog implements Cloneable, ContentRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String title; // dialog title
|
||||
private String subtitle; // dialog subtitle
|
||||
private String formname; // name of the built-in form
|
||||
private String action; // action applet
|
||||
private String error_message = null; // error message
|
||||
private String instructions = null; // instructions
|
||||
private Hashtable hidden_fields; // list of all hidden fields & values
|
||||
private Hashtable command_buttons; // command buttons by name
|
||||
private Vector command_order; // command buttons in order (left to right)
|
||||
private Hashtable form_fields; // form fields by name
|
||||
private Vector form_order; // form fields in order (top to bottom)
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public ContentDialog(String title, String subtitle, String formname, String action)
|
||||
{
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.formname = formname;
|
||||
this.action = action;
|
||||
hidden_fields = new Hashtable();
|
||||
command_buttons = new Hashtable();
|
||||
command_order = new Vector();
|
||||
form_fields = new Hashtable();
|
||||
form_order = new Vector();
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected ContentDialog(ContentDialog other)
|
||||
{
|
||||
this.title = other.title;
|
||||
this.subtitle = other.subtitle;
|
||||
this.formname = other.formname;
|
||||
this.action = other.action;
|
||||
this.instructions = other.instructions;
|
||||
this.hidden_fields = (Hashtable)(other.hidden_fields.clone());
|
||||
command_buttons = new Hashtable();
|
||||
command_order = new Vector();
|
||||
form_fields = new Hashtable();
|
||||
form_order = new Vector();
|
||||
|
||||
Enumeration enum = other.command_order.elements();
|
||||
while (enum.hasMoreElements())
|
||||
{ // share the command buttons with the new dialog
|
||||
CDCommandButton button = (CDCommandButton)(enum.nextElement());
|
||||
addCommandButton(button);
|
||||
|
||||
} // end while
|
||||
|
||||
enum = other.form_order.elements();
|
||||
while (enum.hasMoreElements())
|
||||
{ // clone the form fields and put them in the new dialog
|
||||
CDFormField field = (CDFormField)(enum.nextElement());
|
||||
addFormField(field.duplicate());
|
||||
|
||||
} // end while
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private boolean anyRequired()
|
||||
{
|
||||
boolean rc = false;
|
||||
Enumeration enum = form_order.elements();
|
||||
while (!rc && enum.hasMoreElements())
|
||||
{ // look for the first field that's marked "required"
|
||||
CDFormField fld = (CDFormField)(enum.nextElement());
|
||||
rc = fld.isRequired();
|
||||
|
||||
} // end while
|
||||
|
||||
return rc;
|
||||
|
||||
} // end anyRequired
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrideable operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void validateWholeForm() throws ValidationException
|
||||
{ // do nothing at this level
|
||||
} // end validateWholeForm
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ContentRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
Enumeration enum;
|
||||
|
||||
// Output the content header
|
||||
rdat.writeContentHeader(out,title,subtitle);
|
||||
|
||||
if (error_message!=null)
|
||||
{ // print the error message
|
||||
out.write("<TABLE BORDER=0 ALIGN=CENTER CELLPADDING=6 CELLSPACING=0><TR VALIGN=TOP>"
|
||||
+ "<TD ALIGN=CENTER>\n" + rdat.getStdFontTag("#660000",3) + "<B>");
|
||||
out.write(StringUtil.encodeHTML(error_message));
|
||||
out.write("</B></FONT>\n</TD></TR></TABLE>\n");
|
||||
|
||||
} // end if
|
||||
|
||||
// Output the start of the form
|
||||
out.write("<FORM NAME=\"" + formname + "\" METHOD=POST ACTION=\"");
|
||||
out.write(rdat.getEncodedServletPath(action) + "\">" + rdat.getStdFontTag(null,2) + "\n");
|
||||
|
||||
enum = hidden_fields.keys();
|
||||
while (enum.hasMoreElements())
|
||||
{ // output all the hidden fields
|
||||
String name = (String)(enum.nextElement());
|
||||
String value = (String)(hidden_fields.get(name));
|
||||
out.write("<INPUT TYPE=HIDDEN NAME=\"" + name + "\" VALUE=\"" + value + "\">\n");
|
||||
|
||||
} // end while
|
||||
|
||||
if (instructions!=null)
|
||||
out.write(StringUtil.encodeHTML(instructions));
|
||||
if (anyRequired())
|
||||
{ // print the "required fields" instruction
|
||||
if (instructions!=null)
|
||||
out.write("<P>");
|
||||
out.write("Required fields are marked with a " + rdat.getRequiredBullet() + ".<BR>\n");
|
||||
|
||||
} // end if
|
||||
else if (instructions!=null)
|
||||
out.write("<BR>\n");
|
||||
|
||||
out.write("<TABLE BORDER=0 ALIGN=CENTER CELLPADDING=6 CELLSPACING=0>\n");
|
||||
|
||||
if (form_order.size()>0)
|
||||
{ // render the form elements now
|
||||
enum = form_order.elements();
|
||||
while (enum.hasMoreElements())
|
||||
{ // render all the fields in order
|
||||
CDFormField fld = (CDFormField)(enum.nextElement());
|
||||
fld.renderHere(out,rdat);
|
||||
|
||||
} // end while
|
||||
|
||||
} // end if
|
||||
|
||||
out.write("</TABLE>\n");
|
||||
|
||||
if (command_order.size()>0)
|
||||
{ // render the command buttons at the bottom
|
||||
boolean is_first = true;
|
||||
out.write("<DIV ALIGN=CENTER>");
|
||||
enum = command_order.elements();
|
||||
while (enum.hasMoreElements())
|
||||
{ // render each of the command buttons in the list
|
||||
CDCommandButton button = (CDCommandButton)(enum.nextElement());
|
||||
if (is_first)
|
||||
is_first = false;
|
||||
else
|
||||
out.write(" ");
|
||||
button.renderHere(out,rdat);
|
||||
|
||||
} // end while
|
||||
|
||||
out.write("</DIV>\n");
|
||||
|
||||
} // end if
|
||||
|
||||
out.write("</FONT></FORM>\n");
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
|
||||
} // end getTitle
|
||||
|
||||
public void setErrorMessage(String message)
|
||||
{
|
||||
this.error_message = message;
|
||||
|
||||
} // end setErrorMessage
|
||||
|
||||
public void setInstructions(String instructions)
|
||||
{
|
||||
this.instructions = StringUtil.encodeHTML(instructions);
|
||||
|
||||
} // end setInstructions
|
||||
|
||||
public void setHiddenField(String name, String value)
|
||||
{
|
||||
if (value!=null)
|
||||
hidden_fields.put(name,value);
|
||||
|
||||
} // end setHiddenField
|
||||
|
||||
public void removeHiddenField(String name)
|
||||
{
|
||||
hidden_fields.remove(name);
|
||||
|
||||
} // end removeHiddenField
|
||||
|
||||
public void addCommandButton(CDCommandButton button, int position)
|
||||
{
|
||||
command_buttons.put(button.getName(),button);
|
||||
if (position<0)
|
||||
command_order.addElement(button);
|
||||
else
|
||||
command_order.insertElementAt(button,position);
|
||||
|
||||
} // end addCommandButton
|
||||
|
||||
public void addCommandButton(CDCommandButton button)
|
||||
{
|
||||
addCommandButton(button,-1);
|
||||
|
||||
} // end addCommandButton
|
||||
|
||||
public void addFormField(CDFormField field, int position)
|
||||
{
|
||||
String name = field.getName();
|
||||
if (name!=null)
|
||||
form_fields.put(name,field);
|
||||
if (position<0)
|
||||
form_order.addElement(field);
|
||||
else
|
||||
form_order.insertElementAt(field,position);
|
||||
|
||||
} // end addFormField
|
||||
|
||||
public void addFormField(CDFormField field)
|
||||
{
|
||||
addFormField(field,-1);
|
||||
|
||||
} // end addFormField
|
||||
|
||||
public boolean isButtonClicked(ServletRequest request, String name)
|
||||
{
|
||||
CDCommandButton button = (CDCommandButton)(command_buttons.get(name));
|
||||
if (button!=null)
|
||||
return button.isClicked(request);
|
||||
|
||||
// now look in all form fields for the embedded button
|
||||
Enumeration enum = form_order.elements();
|
||||
while (enum.hasMoreElements())
|
||||
{ // zap the state of the fields
|
||||
CDFormField fld = (CDFormField)(enum.nextElement());
|
||||
button = fld.findButton(name);
|
||||
if (button!=null)
|
||||
return button.isClicked(request);
|
||||
|
||||
} // end while
|
||||
|
||||
return false;
|
||||
|
||||
} // end isButtonClicked
|
||||
|
||||
public void loadValues(ServletRequest request)
|
||||
{
|
||||
// Look for the values of the hidden fields first.
|
||||
Enumeration enum = hidden_fields.keys();
|
||||
Hashtable updates = new Hashtable();
|
||||
while (enum.hasMoreElements())
|
||||
{ // get updates to the hidden field values
|
||||
String name = (String)(enum.nextElement());
|
||||
String value = request.getParameter(name);
|
||||
if (value!=null)
|
||||
updates.put(name,value);
|
||||
|
||||
} // end while
|
||||
|
||||
hidden_fields.putAll(updates); // make all the updates be recognized
|
||||
|
||||
// Now look for the values of the form fields.
|
||||
enum = form_order.elements();
|
||||
while (enum.hasMoreElements())
|
||||
{ // look for the first field that's marked "required"
|
||||
CDFormField fld = (CDFormField)(enum.nextElement());
|
||||
String name = fld.getName();
|
||||
if (name!=null) // load the parameter value
|
||||
fld.setValue(request.getParameter(name));
|
||||
|
||||
} // end while
|
||||
|
||||
} // end loadValues
|
||||
|
||||
public void clearAllFields()
|
||||
{
|
||||
Enumeration enum = form_order.elements();
|
||||
while (enum.hasMoreElements())
|
||||
{ // zap the state of the fields
|
||||
CDFormField fld = (CDFormField)(enum.nextElement());
|
||||
fld.setValue(null);
|
||||
|
||||
} // end while
|
||||
|
||||
} // end clearAllFields
|
||||
|
||||
public String getFieldValue(String fieldname)
|
||||
{
|
||||
String value = (String)(hidden_fields.get(fieldname));
|
||||
if (value!=null)
|
||||
return value;
|
||||
|
||||
CDFormField fld = (CDFormField)(form_fields.get(fieldname));
|
||||
if (fld!=null)
|
||||
return fld.getValue();
|
||||
else
|
||||
return null;
|
||||
|
||||
} // end getFieldValue
|
||||
|
||||
public void setFieldValue(String fieldname, String value)
|
||||
{
|
||||
CDFormField fld = (CDFormField)(form_fields.get(fieldname));
|
||||
if (fld!=null)
|
||||
fld.setValue(value);
|
||||
else if (value!=null)
|
||||
setHiddenField(fieldname,value);
|
||||
|
||||
} // end setFieldValue
|
||||
|
||||
public boolean isFieldEnabled(String fieldname)
|
||||
{
|
||||
CDFormField fld = (CDFormField)(form_fields.get(fieldname));
|
||||
if (fld!=null)
|
||||
return fld.isEnabled();
|
||||
else
|
||||
return false;
|
||||
|
||||
} // end isFieldEnabled
|
||||
|
||||
public void setFieldEnabled(String fieldname, boolean flag)
|
||||
{
|
||||
CDFormField fld = (CDFormField)(form_fields.get(fieldname));
|
||||
if (fld!=null)
|
||||
fld.setEnabled(flag);
|
||||
|
||||
} // end setFieldEnabled
|
||||
|
||||
public void validate() throws ValidationException
|
||||
{
|
||||
// validate each field in isolation
|
||||
Enumeration enum = form_order.elements();
|
||||
while (enum.hasMoreElements())
|
||||
{ // look for the first field that's marked "required"
|
||||
CDFormField fld = (CDFormField)(enum.nextElement());
|
||||
fld.validate();
|
||||
|
||||
} // end while
|
||||
|
||||
// now validate the form as a whole
|
||||
validateWholeForm();
|
||||
|
||||
} // end validate
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new ContentDialog(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class Dialog
|
||||
166
src/com/silverwrist/venice/servlets/format/ContentMenuPanel.java
Normal file
166
src/com/silverwrist/venice/servlets/format/ContentMenuPanel.java
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
|
||||
public class ContentMenuPanel implements Cloneable, ContentRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal class for storing content items
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
class ContentMenuPanelItem
|
||||
{
|
||||
private String title;
|
||||
private String url;
|
||||
|
||||
public ContentMenuPanelItem(String title, String url)
|
||||
{
|
||||
this.title = title;
|
||||
this.url = url;
|
||||
|
||||
} // end constructor
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat, Hashtable params) throws IOException
|
||||
{
|
||||
StringBuffer buf = new StringBuffer(url);
|
||||
Enumeration enum = params.keys();
|
||||
while (enum.hasMoreElements())
|
||||
{ // do the parameter replacement
|
||||
String curkey = (String)(enum.nextElement());
|
||||
String rparam = "$" + curkey;
|
||||
int p = buf.toString().indexOf(rparam);
|
||||
while (p>=0)
|
||||
{ // replace the parameter and look for another instance
|
||||
buf.replace(p,p+rparam.length(),(String)(params.get(curkey)));
|
||||
p = buf.toString().indexOf(rparam);
|
||||
|
||||
} // end while
|
||||
|
||||
} // end while
|
||||
|
||||
out.write("<A HREF=\"" + rdat.getEncodedServletPath(buf.toString()) + "\">");
|
||||
out.write(StringUtil.encodeHTML(title) + "</A>");
|
||||
|
||||
} // end renderHere
|
||||
|
||||
} // end class ContentMenuPanelItem
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String title; // menu title
|
||||
private String subtitle; // menu subtitle
|
||||
private Vector items; // list of menu items
|
||||
private Hashtable params; // set of parameters
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public ContentMenuPanel(String title, String subtitle)
|
||||
{
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.items = new Vector();
|
||||
this.params = new Hashtable();
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected ContentMenuPanel(ContentMenuPanel other)
|
||||
{
|
||||
this.title = other.title;
|
||||
this.subtitle = other.subtitle;
|
||||
this.items = other.items;
|
||||
this.params = (Hashtable)(other.params.clone());
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ContentRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
rdat.writeContentHeader(out,title,subtitle);
|
||||
|
||||
out.write("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=2\n");
|
||||
|
||||
Iterator it = items.iterator();
|
||||
while (it.hasNext())
|
||||
{ // render all the menu items
|
||||
out.write("<TR VALIGN=MIDDLE>\n<TD ALIGN=CENTER WIDTH=14><IMG SRC=\""
|
||||
+ rdat.getFullImagePath("purple-ball.gif")
|
||||
+ "\" ALT=\"*\" WIDTH=14 HEIGHT=14 BORDER=0></TD>\n<TD ALIGN=LEFT>");
|
||||
out.write(rdat.getStdFontTag(null,2));
|
||||
ContentMenuPanelItem item = (ContentMenuPanelItem)(it.next());
|
||||
item.renderHere(out,rdat,params);
|
||||
out.write("</FONT></TD>\n</TR>\n");
|
||||
|
||||
} // end while
|
||||
|
||||
out.write("</TABLE>\n");
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void addChoice(String title, String url)
|
||||
{
|
||||
items.add(new ContentMenuPanelItem(title,url));
|
||||
|
||||
} // end addChoice
|
||||
|
||||
public void setParameter(String name, String value)
|
||||
{
|
||||
params.put(name,value);
|
||||
|
||||
} // end setParameter
|
||||
|
||||
public void setTitle(String s)
|
||||
{
|
||||
title = s;
|
||||
|
||||
} // end setTitle
|
||||
|
||||
public void setSubtitle(String s)
|
||||
{
|
||||
subtitle = s;
|
||||
|
||||
} // end setSubtitle
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new ContentMenuPanel(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class ContentMenuPanel
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface ContentRender
|
||||
{
|
||||
public abstract void renderHere(Writer out, RenderData rdat) throws IOException;
|
||||
|
||||
} // end interface ContentRender
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class CreateConferenceDialog extends ContentDialog
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private VeniceEngine engine;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CreateConferenceDialog()
|
||||
{
|
||||
super("Create New Conference",null,"newconfform","confops");
|
||||
setHiddenField("cmd","C");
|
||||
setHiddenField("sig","");
|
||||
|
||||
Vector vec_pubpriv = new Vector(2);
|
||||
vec_pubpriv.add("0|Public");
|
||||
vec_pubpriv.add("1|Private");
|
||||
vec_pubpriv.trimToSize();
|
||||
|
||||
addFormField(new CDTextFormField("name","Conference Name",null,true,32,128));
|
||||
addFormField(new CDVeniceIDFormField("alias","Conference Alias",null,true,32,64));
|
||||
addFormField(new CDTextFormField("descr","Description",null,false,32,255));
|
||||
addFormField(new CDSimplePickListFormField("ctype","Conference type",null,true,vec_pubpriv,'|'));
|
||||
addFormField(new CDCheckBoxFormField("hide","Hide conference in the SIG's conference list",null,"Y"));
|
||||
addCommandButton(new CDImageButton("create","bn_create.gif","Create",80,24));
|
||||
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CreateConferenceDialog(CreateConferenceDialog other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class ContentDialog
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void validateWholeForm() throws ValidationException
|
||||
{
|
||||
if (engine.confAliasExists(getFieldValue("alias")))
|
||||
throw new ValidationException("That alias is already used by another conference on the system.");
|
||||
|
||||
} // end validateWholeForm
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setupDialog(VeniceEngine engine, SIGContext sig)
|
||||
{
|
||||
this.engine = engine;
|
||||
setHiddenField("sig",String.valueOf(sig.getSIGID()));
|
||||
|
||||
} // end setupDialog
|
||||
|
||||
public ConferenceContext doDialog(SIGContext sig) throws ValidationException, DataException, AccessError
|
||||
{
|
||||
validate(); // validate the form
|
||||
|
||||
// Convert a couple of fields to Booleans, which we need.
|
||||
final String yes = "Y";
|
||||
boolean pvt = getFieldValue("ctype").equals("1");
|
||||
boolean hide_list = yes.equals(getFieldValue("hide"));
|
||||
|
||||
// create the conference!
|
||||
return sig.createConference(getFieldValue("name"),getFieldValue("alias"),getFieldValue("descr"),pvt,
|
||||
hide_list);
|
||||
|
||||
} // end if
|
||||
|
||||
public void resetOnError(String message)
|
||||
{
|
||||
setErrorMessage(message);
|
||||
|
||||
} // end resetOnError
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new CreateConferenceDialog(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class CreateConferenceDialog
|
||||
163
src/com/silverwrist/venice/servlets/format/CreateSIGDialog.java
Normal file
163
src/com/silverwrist/venice/servlets/format/CreateSIGDialog.java
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class CreateSIGDialog extends ContentDialog
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private VeniceEngine engine;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CreateSIGDialog(List country_list, List language_list)
|
||||
{
|
||||
super("Create New SIG",null,"createsigform","sigops");
|
||||
setHiddenField("cmd","C");
|
||||
|
||||
Vector vec_pubpriv = new Vector(2);
|
||||
vec_pubpriv.add("0|Public");
|
||||
vec_pubpriv.add("1|Private");
|
||||
vec_pubpriv.trimToSize();
|
||||
|
||||
Vector vec_hidemode = new Vector(3);
|
||||
vec_hidemode.add(String.valueOf(SIGContext.HIDE_NONE) + "|Show in both directory and search");
|
||||
vec_hidemode.add(String.valueOf(SIGContext.HIDE_DIRECTORY) + "|Hide in directory, but not in search");
|
||||
vec_hidemode.add(String.valueOf(SIGContext.HIDE_BOTH) + "|Hide in both directory and search");
|
||||
vec_hidemode.trimToSize();
|
||||
|
||||
addFormField(new CDFormCategoryHeader("Basic Information"));
|
||||
addFormField(new CDTextFormField("name","SIG Name",null,true,32,128));
|
||||
addFormField(new CDVeniceIDFormField("alias","SIG Alias",null,true,32,32));
|
||||
addFormField(new CDTextFormField("synopsis","Synopsis",null,false,32,255));
|
||||
addFormField(new CDTextFormField("rules","Rules",null,false,32,255));
|
||||
addFormField(new CDLanguageListFormField("language","Primary language",null,true,language_list));
|
||||
addFormField(new CDFormCategoryHeader("Location"));
|
||||
addFormField(new CDTextFormField("loc","City",null,false,32,64));
|
||||
addFormField(new CDTextFormField("reg","State/Province",null,false,32,64));
|
||||
addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
|
||||
addFormField(new CDFormCategoryHeader("Security"));
|
||||
addFormField(new CDSimplePickListFormField("comtype","SIG type:",null,true,vec_pubpriv,'|'));
|
||||
addFormField(new CDTextFormField("joinkey","Join key","(for private SIGs)",false,32,64));
|
||||
addFormField(new CDSimplePickListFormField("hidemode","SIG visibility:",null,true,vec_hidemode,'|'));
|
||||
addCommandButton(new CDImageButton("create","bn_create.gif","Create",80,24));
|
||||
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CreateSIGDialog(CreateSIGDialog other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end CreateSIGDialog
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class ContentDialog
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void validateWholeForm() throws ValidationException
|
||||
{
|
||||
if (engine.aliasExists(getFieldValue("alias"),-1))
|
||||
throw new ValidationException("That alias is already used by another SIG on the system.");
|
||||
|
||||
if (getFieldValue("comtype").equals("1"))
|
||||
{ // make sure if they flagged it as Private that they specified a join key
|
||||
if (StringUtil.isStringEmpty(getFieldValue("joinkey")))
|
||||
throw new ValidationException("Private SIGs must specify a join key value.");
|
||||
|
||||
} // end if
|
||||
|
||||
} // end validateWholeForm
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setupDialog(VeniceEngine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
|
||||
} // end setupDialog
|
||||
|
||||
public SIGContext doDialog(UserContext user) throws ValidationException, DataException, AccessError
|
||||
{
|
||||
validate(); // validate the dialog entries
|
||||
|
||||
int hidemode;
|
||||
|
||||
try
|
||||
{ // attempt to get the hide mode first...
|
||||
hidemode = Integer.parseInt(getFieldValue("hidemode"));
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // how rude!
|
||||
throw new InternalStateError("somehow we got a non-numeric result from a numeric dropdown list!");
|
||||
|
||||
} // end catch
|
||||
|
||||
// Determine what the "join key" should be.
|
||||
String jkey;
|
||||
if (getFieldValue("comtype").equals("1"))
|
||||
jkey = getFieldValue("joinkey");
|
||||
else
|
||||
jkey = null;
|
||||
|
||||
// Create the new SIG context.
|
||||
SIGContext rc = user.createSIG(getFieldValue("name"),getFieldValue("alias"),getFieldValue("language"),
|
||||
getFieldValue("synopsis"),getFieldValue("rules"),jkey,hidemode);
|
||||
|
||||
// Get the new SIG's contact record and fill in the pieces of info we know.
|
||||
ContactInfo ci = rc.getContactInfo();
|
||||
ci.setLocality(getFieldValue("loc"));
|
||||
ci.setRegion(getFieldValue("reg"));
|
||||
ci.setPostalCode(getFieldValue("pcode"));
|
||||
ci.setCountry(getFieldValue("country"));
|
||||
rc.putContactInfo(ci);
|
||||
|
||||
return rc; // all done!
|
||||
|
||||
} // end doDialog
|
||||
|
||||
public void resetOnError(String message)
|
||||
{
|
||||
setErrorMessage(message);
|
||||
|
||||
} // end resetOnError
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new CreateSIGDialog(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class CreateSIGDialog
|
||||
103
src/com/silverwrist/venice/servlets/format/DialogCache.java
Normal file
103
src/com/silverwrist/venice/servlets/format/DialogCache.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import javax.servlet.ServletContext;
|
||||
import org.apache.log4j.*;
|
||||
|
||||
public class DialogCache
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data values
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.servlets.DialogCache";
|
||||
|
||||
private static Category logger = Category.getInstance(DialogCache.class.getName());
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Hashtable cache;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected DialogCache()
|
||||
{
|
||||
cache = new Hashtable();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public boolean isCached(String name)
|
||||
{
|
||||
return (cache.get(name)!=null);
|
||||
|
||||
} // end isCached
|
||||
|
||||
public void saveTemplate(ContentDialog template)
|
||||
{
|
||||
String fullname = template.getClass().getName();
|
||||
int clip_pos = fullname.lastIndexOf('.');
|
||||
if (clip_pos>=0)
|
||||
fullname = fullname.substring(clip_pos+1);
|
||||
cache.put(fullname,template);
|
||||
|
||||
} // end saveTemplate
|
||||
|
||||
public ContentDialog getNewDialog(String name)
|
||||
{
|
||||
ContentDialog template = (ContentDialog)(cache.get(name));
|
||||
if (template!=null)
|
||||
return (ContentDialog)(template.clone());
|
||||
else
|
||||
return null;
|
||||
|
||||
} // end getNewDialog
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static operations for use by servlets
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static DialogCache getDialogCache(ServletContext ctxt)
|
||||
{
|
||||
// Look in the servlet attributes first.
|
||||
Object foo = ctxt.getAttribute(ATTR_NAME);
|
||||
if (foo!=null)
|
||||
return (DialogCache)foo;
|
||||
|
||||
// create a new one and return it
|
||||
DialogCache cache = new DialogCache();
|
||||
ctxt.setAttribute(ATTR_NAME,cache);
|
||||
return cache;
|
||||
|
||||
} // end getDialogCache
|
||||
|
||||
} // end class DialogCache
|
||||
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.List;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class EditProfileDialog extends ContentDialog
|
||||
{
|
||||
public EditProfileDialog(List country_list)
|
||||
{
|
||||
super("Edit Your Profile",null,"profform","account");
|
||||
setHiddenField("cmd","P");
|
||||
setHiddenField("tgt","");
|
||||
addFormField(new CDFormCategoryHeader("Password","To change your password, enter a new password "
|
||||
+ "into the fields below."));
|
||||
addFormField(new CDPasswordFormField("pass1","Password",null,false,32,128));
|
||||
addFormField(new CDPasswordFormField("pass2","Password","(retype)",false,32,128));
|
||||
addFormField(new CDTextFormField("remind","Password reminder phrase",null,false,32,255));
|
||||
addFormField(new CDFormCategoryHeader("Name"));
|
||||
addFormField(new CDTextFormField("prefix","Prefix","(Mr., Ms., etc.)",false,8,8));
|
||||
addFormField(new CDTextFormField("first","First name",null,true,32,64));
|
||||
addFormField(new CDTextFormField("mid","Middle initial",null,false,1,1));
|
||||
addFormField(new CDTextFormField("last","Last name",null,true,32,64));
|
||||
addFormField(new CDTextFormField("suffix","Suffix","(Jr., III, etc.)",false,16,16));
|
||||
addFormField(new CDFormCategoryHeader("Location"));
|
||||
addFormField(new CDTextFormField("company","Company",null,false,32,255));
|
||||
addFormField(new CDTextFormField("addr1","Address",null,false,32,255));
|
||||
addFormField(new CDTextFormField("addr2","Address","(line 2)",false,32,255));
|
||||
addFormField(new CDCheckBoxFormField("pvt_addr","Hide address in profile",null,"Y"));
|
||||
addFormField(new CDTextFormField("loc","City",null,true,32,64));
|
||||
addFormField(new CDTextFormField("reg","State/Province",null,true,32,64));
|
||||
addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
|
||||
addFormField(new CDFormCategoryHeader("Phone Numbers"));
|
||||
addFormField(new CDTextFormField("phone","Telephone",null,false,32,32));
|
||||
addFormField(new CDTextFormField("mobile","Mobile/cellphone",null,false,32,32));
|
||||
addFormField(new CDCheckBoxFormField("pvt_phone","Hide phone/mobile numbers in profile",null,"Y"));
|
||||
addFormField(new CDTextFormField("fax","Fax",null,false,32,32));
|
||||
addFormField(new CDCheckBoxFormField("pvt_fax","Hide fax number in profile",null,"Y"));
|
||||
addFormField(new CDFormCategoryHeader("Internet"));
|
||||
addFormField(new CDEmailAddressFormField("email","E-mail address",null,true,32,255));
|
||||
addFormField(new CDCheckBoxFormField("pvt_email","Hide e-mail address in profile",null,"Y"));
|
||||
addFormField(new CDTextFormField("url","Home page","(URL)",false,32,255));
|
||||
addFormField(new CDFormCategoryHeader("Personal"));
|
||||
addFormField(new CDTextFormField("descr","Personal description",null,false,32,255));
|
||||
// TODO: add photo selection/uploading method here
|
||||
addCommandButton(new CDImageButton("update","bn_update.gif","Update",80,24));
|
||||
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected EditProfileDialog(EditProfileDialog other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void validateWholeForm() throws ValidationException
|
||||
{
|
||||
String pass1 = getFieldValue("pass1");
|
||||
String pass2 = getFieldValue("pass2");
|
||||
|
||||
if (StringUtil.isStringEmpty(pass1))
|
||||
{ // empty must match empty
|
||||
if (!StringUtil.isStringEmpty(pass2))
|
||||
throw new ValidationException("The typed passwords do not match.");
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // the two passwords must match
|
||||
if (!(pass1.equals(pass2)))
|
||||
throw new ValidationException("The typed passwords do not match.");
|
||||
|
||||
} // end if
|
||||
|
||||
} // end validateWholeForm
|
||||
|
||||
public void setTarget(String target)
|
||||
{
|
||||
setHiddenField("tgt",target);
|
||||
|
||||
} // end setTarget
|
||||
|
||||
public void setupDialog(UserContext uc, String target) throws DataException
|
||||
{
|
||||
setTarget(target);
|
||||
ContactInfo ci = uc.getContactInfo(); // get the main contact info
|
||||
|
||||
setFieldValue("prefix",ci.getNamePrefix());
|
||||
setFieldValue("first",ci.getGivenName());
|
||||
char init = ci.getMiddleInitial();
|
||||
if (init!=' ')
|
||||
setFieldValue("mid",String.valueOf(init));
|
||||
setFieldValue("last",ci.getFamilyName());
|
||||
setFieldValue("suffix",ci.getNameSuffix());
|
||||
setFieldValue("company",ci.getCompany());
|
||||
setFieldValue("addr1",ci.getAddressLine1());
|
||||
setFieldValue("addr2",ci.getAddressLine2());
|
||||
if (ci.getPrivateAddress())
|
||||
setFieldValue("pvt_addr","Y");
|
||||
setFieldValue("loc",ci.getLocality());
|
||||
setFieldValue("reg",ci.getRegion());
|
||||
setFieldValue("pcode",ci.getPostalCode());
|
||||
setFieldValue("country",ci.getCountry());
|
||||
setFieldValue("phone",ci.getPhone());
|
||||
setFieldValue("mobile",ci.getMobile());
|
||||
if (ci.getPrivatePhone())
|
||||
setFieldValue("pvt_phone","Y");
|
||||
setFieldValue("fax",ci.getFax());
|
||||
if (ci.getPrivateFax())
|
||||
setFieldValue("pvt_fax","Y");
|
||||
setFieldValue("email",ci.getEmail());
|
||||
if (ci.getPrivateEmail())
|
||||
setFieldValue("pvt_email","Y");
|
||||
setFieldValue("url",ci.getURL());
|
||||
setFieldValue("descr",uc.getDescription());
|
||||
|
||||
} // end setupDialog
|
||||
|
||||
public boolean doDialog(UserContext uc) throws ValidationException, DataException, EmailException
|
||||
{
|
||||
validate(); // validate the dialog
|
||||
|
||||
final String yes = "Y"; // the "yes" string
|
||||
ContactInfo ci = uc.getContactInfo(); // get the main contact info
|
||||
|
||||
// Reset all the contact info fields.
|
||||
ci.setNamePrefix(getFieldValue("prefix"));
|
||||
ci.setGivenName(getFieldValue("first"));
|
||||
String foo = getFieldValue("mid");
|
||||
if ((foo==null) || (foo.length()<1))
|
||||
ci.setMiddleInitial(' ');
|
||||
else
|
||||
ci.setMiddleInitial(foo.charAt(0));
|
||||
ci.setFamilyName(getFieldValue("last"));
|
||||
ci.setNameSuffix(getFieldValue("suffix"));
|
||||
ci.setCompany(getFieldValue("company"));
|
||||
ci.setAddressLine1(getFieldValue("addr1"));
|
||||
ci.setAddressLine2(getFieldValue("addr2"));
|
||||
ci.setPrivateAddress(yes.equals(getFieldValue("pvt_addr")));
|
||||
ci.setLocality(getFieldValue("loc"));
|
||||
ci.setRegion(getFieldValue("reg"));
|
||||
ci.setPostalCode(getFieldValue("pcode"));
|
||||
ci.setCountry(getFieldValue("country"));
|
||||
ci.setPhone(getFieldValue("phone"));
|
||||
ci.setMobile(getFieldValue("mobile"));
|
||||
ci.setPrivatePhone(yes.equals(getFieldValue("pvt_phone")));
|
||||
ci.setFax(getFieldValue("fax"));
|
||||
ci.setPrivateFax(yes.equals(getFieldValue("pvt_fax")));
|
||||
ci.setEmail(getFieldValue("email"));
|
||||
ci.setPrivateEmail(yes.equals(getFieldValue("pvt_email")));
|
||||
ci.setURL(getFieldValue("url"));
|
||||
|
||||
// Store the completed contact info.
|
||||
boolean retval = uc.putContactInfo(ci);
|
||||
|
||||
// Save off the user's description.
|
||||
uc.setDescription(getFieldValue("descr"));
|
||||
|
||||
// Finally, change the password if applicable.
|
||||
foo = getFieldValue("pass1");
|
||||
if (!StringUtil.isStringEmpty(foo))
|
||||
uc.setPassword(foo,getFieldValue("remind"));
|
||||
|
||||
return retval; // pass back up so we can decide where to jump
|
||||
|
||||
} // end doDialog
|
||||
|
||||
public void resetOnError(String message)
|
||||
{
|
||||
setErrorMessage(message);
|
||||
setFieldValue("pass1",null);
|
||||
setFieldValue("pass2",null);
|
||||
|
||||
} // end resetOnError
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new EditProfileDialog(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class EditProfileDialog
|
||||
@@ -0,0 +1,270 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.security.Role;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class EditSIGProfileDialog extends ContentDialog
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private VeniceEngine engine;
|
||||
private int sigid;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public EditSIGProfileDialog(List country_list, List language_list)
|
||||
{
|
||||
super("Edit SIG Profile:",null,"sigprofform","sigadmin");
|
||||
setHiddenField("cmd","P");
|
||||
setHiddenField("sig","");
|
||||
|
||||
Vector vec_pubpriv = new Vector(2);
|
||||
vec_pubpriv.add("0|Public");
|
||||
vec_pubpriv.add("1|Private");
|
||||
vec_pubpriv.trimToSize();
|
||||
|
||||
Vector vec_hidemode = new Vector(3);
|
||||
vec_hidemode.add(String.valueOf(SIGContext.HIDE_NONE) + "|Show in both directory and search");
|
||||
vec_hidemode.add(String.valueOf(SIGContext.HIDE_DIRECTORY) + "|Hide in directory, but not in search");
|
||||
vec_hidemode.add(String.valueOf(SIGContext.HIDE_BOTH) + "|Hide in both directory and search");
|
||||
vec_hidemode.trimToSize();
|
||||
|
||||
addFormField(new CDFormCategoryHeader("Basic Information"));
|
||||
addFormField(new CDTextFormField("name","SIG Name",null,true,32,128));
|
||||
addFormField(new CDVeniceIDFormField("alias","SIG Alias",null,true,32,32));
|
||||
addFormField(new CDTextFormField("synopsis","Synopsis",null,false,32,255));
|
||||
addFormField(new CDTextFormField("rules","Rules",null,false,32,255));
|
||||
addFormField(new CDLanguageListFormField("language","Primary language",null,true,language_list));
|
||||
addFormField(new CDTextFormField("url","Home page",null,false,32,255));
|
||||
addFormField(new CDFormCategoryHeader("Location"));
|
||||
addFormField(new CDTextFormField("company","Company",null,false,32,255));
|
||||
addFormField(new CDTextFormField("addr1","Address",null,false,32,255));
|
||||
addFormField(new CDTextFormField("addr2","Address","(line 2)",false,32,255));
|
||||
addFormField(new CDTextFormField("loc","City",null,false,32,64));
|
||||
addFormField(new CDTextFormField("reg","State/Province",null,false,32,64));
|
||||
addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
|
||||
addFormField(new CDFormCategoryHeader("Security"));
|
||||
addFormField(new CDSimplePickListFormField("comtype","SIG type",null,true,vec_pubpriv,'|'));
|
||||
addFormField(new CDTextFormField("joinkey","Join key","(for private SIGs)",false,32,64));
|
||||
addFormField(new CDCheckBoxFormField("membersonly","Allow only members to access this SIG",null,"Y"));
|
||||
addFormField(new CDSimplePickListFormField("hidemode","SIG visibility",null,true,vec_hidemode,'|'));
|
||||
addFormField(new CDRoleListFormField("read_lvl","Security level required to read contents",null,true,
|
||||
Role.getSIGReadList()));
|
||||
addFormField(new CDRoleListFormField("write_lvl","Security level required to update profile",null,true,
|
||||
Role.getSIGWriteList()));
|
||||
addFormField(new CDRoleListFormField("create_lvl","Security level required to create new subobjects",
|
||||
null,true,Role.getSIGCreateList()));
|
||||
addFormField(new CDRoleListFormField("delete_lvl","Security level required to delete SIG",null,true,
|
||||
Role.getSIGDeleteList()));
|
||||
addFormField(new CDRoleListFormField("join_lvl","Security level required to join SIG",null,true,
|
||||
Role.getSIGJoinList()));
|
||||
// TODO: add logo selection/uploading method here
|
||||
addCommandButton(new CDImageButton("update","bn_update.gif","Update",80,24));
|
||||
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
|
||||
|
||||
} // end EditSIGProfileDialog
|
||||
|
||||
protected EditSIGProfileDialog(EditSIGProfileDialog other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private void doDisable(SIGContext sig)
|
||||
{
|
||||
if (sig.isAdminSIG())
|
||||
{ // make sure certain fields are disabled for admin SIGs
|
||||
setFieldEnabled("comtype",false);
|
||||
setFieldEnabled("joinkey",false);
|
||||
setFieldEnabled("membersonly",false);
|
||||
setFieldEnabled("hidemode",false);
|
||||
setFieldEnabled("read_lvl",false);
|
||||
setFieldEnabled("write_lvl",false);
|
||||
setFieldEnabled("create_lvl",false);
|
||||
setFieldEnabled("delete_lvl",false);
|
||||
setFieldEnabled("join_lvl",false);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end doDisable
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class ContentDialog
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void validateWholeForm() throws ValidationException
|
||||
{
|
||||
if (engine.aliasExists(getFieldValue("alias"),sigid))
|
||||
throw new ValidationException("That alias is already used by another SIG on the system.");
|
||||
|
||||
if (getFieldValue("comtype").equals("1"))
|
||||
{ // make sure if they flagged it as Private that they specified a join key
|
||||
if (StringUtil.isStringEmpty(getFieldValue("joinkey")))
|
||||
throw new ValidationException("Private SIGs must specify a join key value.");
|
||||
|
||||
} // end if
|
||||
|
||||
} // end validateWholeForm
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setupDialogBasic(VeniceEngine engine, SIGContext sig)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.sigid = sig.getSIGID();
|
||||
|
||||
} // end setupDialogBasic
|
||||
|
||||
public void setupDialog(VeniceEngine engine, SIGContext sig) throws DataException, AccessError
|
||||
{
|
||||
setupDialogBasic(engine,sig);
|
||||
ContactInfo ci = sig.getContactInfo();
|
||||
|
||||
setHiddenField("sig",String.valueOf(sig.getSIGID()));
|
||||
setFieldValue("name",sig.getName());
|
||||
setFieldValue("alias",sig.getAlias());
|
||||
setFieldValue("synopsis",sig.getSynopsis());
|
||||
setFieldValue("rules",sig.getRules());
|
||||
setFieldValue("language",sig.getLanguageCode());
|
||||
setFieldValue("url",ci.getURL());
|
||||
setFieldValue("company",ci.getCompany());
|
||||
setFieldValue("addr1",ci.getAddressLine1());
|
||||
setFieldValue("addr2",ci.getAddressLine2());
|
||||
setFieldValue("loc",ci.getLocality());
|
||||
setFieldValue("reg",ci.getRegion());
|
||||
setFieldValue("pcode",ci.getPostalCode());
|
||||
setFieldValue("country",ci.getCountry());
|
||||
if (sig.isPublicSIG())
|
||||
{ // public SIG - no join key
|
||||
setFieldValue("comtype","0");
|
||||
setFieldValue("joinkey","");
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // private SIG - display the join key
|
||||
setFieldValue("comtype","1");
|
||||
setFieldValue("joinkey",sig.getJoinKey());
|
||||
|
||||
} // end else
|
||||
|
||||
if (sig.getMembersOnly())
|
||||
setFieldValue("membersonly","Y");
|
||||
setFieldValue("hidemode",String.valueOf(sig.getHideMode()));
|
||||
setFieldValue("read_lvl",String.valueOf(sig.getReadLevel()));
|
||||
setFieldValue("write_lvl",String.valueOf(sig.getWriteLevel()));
|
||||
setFieldValue("create_lvl",String.valueOf(sig.getCreateLevel()));
|
||||
setFieldValue("delete_lvl",String.valueOf(sig.getDeleteLevel()));
|
||||
setFieldValue("join_lvl",String.valueOf(sig.getJoinLevel()));
|
||||
|
||||
doDisable(sig);
|
||||
|
||||
} // end setupDialog
|
||||
|
||||
public void doDialog(SIGContext sig) throws ValidationException, DataException, AccessError
|
||||
{
|
||||
final String yes = "Y"; // the "yes" string
|
||||
validate(); // validate the dialog entries
|
||||
|
||||
int hidemode, read_lvl, write_lvl, create_lvl, delete_lvl, join_lvl;
|
||||
try
|
||||
{ // convert the values of some dropdowns to real numbers
|
||||
hidemode = Integer.parseInt(getFieldValue("hidemode"));
|
||||
read_lvl = Integer.parseInt(getFieldValue("read_lvl"));
|
||||
write_lvl = Integer.parseInt(getFieldValue("write_lvl"));
|
||||
create_lvl = Integer.parseInt(getFieldValue("create_lvl"));
|
||||
delete_lvl = Integer.parseInt(getFieldValue("delete_lvl"));
|
||||
join_lvl = Integer.parseInt(getFieldValue("join_lvl"));
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // how rude!
|
||||
throw new InternalStateError("somehow we got a non-numeric result from a numeric dropdown list!");
|
||||
|
||||
} // end catch
|
||||
|
||||
// save off the ContactInfo-related fields first
|
||||
ContactInfo ci = sig.getContactInfo();
|
||||
ci.setURL(getFieldValue("url"));
|
||||
ci.setCompany(getFieldValue("company"));
|
||||
ci.setAddressLine1(getFieldValue("addr1"));
|
||||
ci.setAddressLine2(getFieldValue("addr2"));
|
||||
ci.setLocality(getFieldValue("loc"));
|
||||
ci.setRegion(getFieldValue("reg"));
|
||||
ci.setPostalCode(getFieldValue("pcode"));
|
||||
ci.setCountry(getFieldValue("country"));
|
||||
sig.putContactInfo(ci);
|
||||
|
||||
// now save the big text fields
|
||||
sig.setName(getFieldValue("name"));
|
||||
sig.setAlias(getFieldValue("alias"));
|
||||
sig.setSynopsis(getFieldValue("synopsis"));
|
||||
sig.setRules(getFieldValue("rules"));
|
||||
sig.setLanguage(getFieldValue("language"));
|
||||
|
||||
if (!(sig.isAdminSIG()))
|
||||
{ // save off the security information
|
||||
String jkey;
|
||||
if (getFieldValue("comtype").equals("1"))
|
||||
jkey = getFieldValue("joinkey");
|
||||
else
|
||||
jkey = null;
|
||||
sig.setJoinKey(jkey);
|
||||
sig.setMembersOnly(yes.equals(getFieldValue("membersonly")));
|
||||
sig.setHideMode(hidemode);
|
||||
sig.setSecurityLevels(read_lvl,write_lvl,create_lvl,delete_lvl,join_lvl);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end doDialog
|
||||
|
||||
public void resetOnError(SIGContext sig, String message)
|
||||
{
|
||||
setErrorMessage(message);
|
||||
doDisable(sig);
|
||||
|
||||
} // end resetOnError
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new EditSIGProfileDialog(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class EditSIGProfileDialog
|
||||
|
||||
57
src/com/silverwrist/venice/servlets/format/ErrorBox.java
Normal file
57
src/com/silverwrist/venice/servlets/format/ErrorBox.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
|
||||
public class ErrorBox implements ContentRender
|
||||
{
|
||||
private String title;
|
||||
private String message;
|
||||
private String back;
|
||||
|
||||
public ErrorBox(String title, String message, String back)
|
||||
{
|
||||
this.title = title;
|
||||
this.message = message;
|
||||
this.back = back;
|
||||
|
||||
if (this.title==null)
|
||||
this.title = "Error!";
|
||||
|
||||
} // end constructor
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<P><TABLE ALIGN=CENTER WIDTH=\"70%\" BORDER=1 CELLPADDING=2 CELLSPACING=1>");
|
||||
out.write("<TR VALIGN=MIDDLE><TD ALIGN=CENTER BGCOLOR=\"#660000\">\n");
|
||||
out.write(rdat.getStdFontTag("white",3) + StringUtil.encodeHTML(title) + "</FONT>\n");
|
||||
out.write("</TD></TR><TR VALIGN=MIDDLE><TD ALIGN=CENTER>\n");
|
||||
out.write(rdat.getStdFontTag(null,3) + "<P>" + StringUtil.encodeHTML(message) + "<P>\n");
|
||||
if (back==null)
|
||||
out.write("Use your browser's <B>Back</B> button to go back.\n");
|
||||
else
|
||||
out.write("<A HREF=\"" + rdat.getEncodedServletPath(back) + "\">Go back.</A>\n");
|
||||
out.write("<P></FONT></TD></TR></TABLE><P>\n");
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
} // end class ErrorBox
|
||||
376
src/com/silverwrist/venice/servlets/format/FindData.java
Normal file
376
src/com/silverwrist/venice/servlets/format/FindData.java
Normal file
@@ -0,0 +1,376 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import javax.servlet.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class FindData implements JSPRender, SearchMode
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Attribute name for request attribute
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.content.FindData";
|
||||
|
||||
// The various display categories
|
||||
public static final int FD_SIGS = 0;
|
||||
public static final int FD_USERS = 1;
|
||||
public static final int FD_CATEGORIES = 2;
|
||||
|
||||
// The titles and URLs of the header data
|
||||
private static Vector header_titles = null;
|
||||
private static Vector header_urls = null;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private VeniceEngine engine;
|
||||
private UserContext user;
|
||||
private int disp;
|
||||
private int field = -1;
|
||||
private int mode = -1;
|
||||
private String term = null;
|
||||
private int offset = 0;
|
||||
private CategoryDescriptor cat = null;
|
||||
private List subcats = null;
|
||||
private List results = null;
|
||||
private int find_count = -1;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public FindData(VeniceEngine engine, UserContext user, int disp)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.user = user;
|
||||
this.disp = disp;
|
||||
|
||||
if (header_titles==null)
|
||||
{ // construct the title and URL vectors
|
||||
header_titles = new Vector();
|
||||
header_titles.add("SIGs");
|
||||
header_titles.add("Users");
|
||||
header_titles.add("Categories");
|
||||
header_titles.trimToSize();
|
||||
|
||||
header_urls = new Vector();
|
||||
header_urls.add("find?disp=" + String.valueOf(FD_SIGS));
|
||||
header_urls.add("find?disp=" + String.valueOf(FD_USERS));
|
||||
header_urls.add("find?disp=" + String.valueOf(FD_CATEGORIES));
|
||||
header_urls.trimToSize();
|
||||
|
||||
} // end if
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static int getParamInt(ServletRequest request, String name, int default_val)
|
||||
{
|
||||
String str = request.getParameter(name);
|
||||
if (str==null)
|
||||
return -1;
|
||||
|
||||
try
|
||||
{ // parse the integer value
|
||||
return Integer.parseInt(str);
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // in case of conversion error, return default
|
||||
return default_val;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getParamInt
|
||||
|
||||
private static boolean isImageButtonClicked(ServletRequest request, String name)
|
||||
{
|
||||
String val = request.getParameter(name + ".x");
|
||||
return (val!=null);
|
||||
|
||||
} // end isImageButtonClicked
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static int getNumChoices()
|
||||
{
|
||||
return FD_CATEGORIES + 1;
|
||||
|
||||
} // end getNumChoices
|
||||
|
||||
public static FindData retrieve(ServletRequest request)
|
||||
{
|
||||
return (FindData)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface JSPRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void store(ServletRequest request)
|
||||
{
|
||||
request.setAttribute(ATTR_NAME,this);
|
||||
|
||||
} // end store
|
||||
|
||||
public String getTargetJSPName()
|
||||
{
|
||||
return "find.jsp";
|
||||
|
||||
} // end getTargetJSPName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void writeHeader(RenderData rdat, Writer out) throws IOException
|
||||
{
|
||||
rdat.writeContentSelectorHeader(out,"Find:",header_titles,header_urls,disp);
|
||||
|
||||
} // end writeHeader
|
||||
|
||||
public int getDisplayOption()
|
||||
{
|
||||
return disp;
|
||||
|
||||
} // end getDisplayOption
|
||||
|
||||
public int getSearchField()
|
||||
{
|
||||
return field;
|
||||
|
||||
} // end getSearchField
|
||||
|
||||
public boolean searchFieldIs(int value)
|
||||
{
|
||||
return (value==field);
|
||||
|
||||
} // end searchFieldIs
|
||||
|
||||
public int getSearchMode()
|
||||
{
|
||||
return mode;
|
||||
|
||||
} // end getSearchMode
|
||||
|
||||
public boolean searchModeIs(int value)
|
||||
{
|
||||
return (value==mode);
|
||||
|
||||
} // end searchModeIs
|
||||
|
||||
public String getSearchTerm()
|
||||
{
|
||||
return term;
|
||||
|
||||
} // end getSearchTerm
|
||||
|
||||
public CategoryDescriptor getCategory()
|
||||
{
|
||||
return cat;
|
||||
|
||||
} // end getCategory
|
||||
|
||||
public List getSubCategoryList()
|
||||
{
|
||||
return subcats;
|
||||
|
||||
} // end getSubCategoryList
|
||||
|
||||
public List getResultsList()
|
||||
{
|
||||
return results;
|
||||
|
||||
} // end getResultsList
|
||||
|
||||
public int getNumResultsDisplayed()
|
||||
{
|
||||
return engine.getStdNumSearchResults();
|
||||
|
||||
} // end getNumResultsDisplayed
|
||||
|
||||
public int getFindCount()
|
||||
{
|
||||
return find_count;
|
||||
|
||||
} // end getFindCount
|
||||
|
||||
public int getOffset()
|
||||
{
|
||||
return offset;
|
||||
|
||||
} // end getOffset
|
||||
|
||||
public void loadGet(int catid) throws DataException
|
||||
{
|
||||
if (disp==FD_SIGS)
|
||||
{ // fill in the list of subcategories and of SIGs in this category
|
||||
cat = user.getCategoryDescriptor(catid);
|
||||
subcats = cat.getSubCategories();
|
||||
if (cat.getCategoryID()>=0)
|
||||
{ // fill in the SIGs that are in this category
|
||||
results = user.getSIGsInCategory(cat,offset,getNumResultsDisplayed());
|
||||
find_count = user.getNumSIGsInCategory(cat);
|
||||
|
||||
} // end if
|
||||
field = FIELD_SIG_NAME;
|
||||
|
||||
} // end if
|
||||
else if (disp==FD_USERS)
|
||||
field = FIELD_USER_NAME;
|
||||
|
||||
mode = SEARCH_PREFIX;
|
||||
term = "";
|
||||
|
||||
} // end loadGet
|
||||
|
||||
public void loadPost(ServletRequest request) throws ValidationException, DataException
|
||||
{
|
||||
int catid = -1;
|
||||
|
||||
// Retrieve all the posted parameters from the form and validate them. First validate the
|
||||
// category ID (if specified) and the field identifier.
|
||||
switch (disp)
|
||||
{
|
||||
case FD_SIGS:
|
||||
catid = getParamInt(request,"cat",-1);
|
||||
if (!engine.isValidCategoryID(catid))
|
||||
throw new ValidationException("The category ID parameter is not valid.");
|
||||
field = getParamInt(request,"field",FIELD_SIG_NAME);
|
||||
if ((field!=FIELD_SIG_NAME) && (field!=FIELD_SIG_SYNOPSIS))
|
||||
throw new ValidationException("The field search parameter is not valid.");
|
||||
break;
|
||||
|
||||
case FD_USERS:
|
||||
field = getParamInt(request,"field",FIELD_USER_NAME);
|
||||
if ( (field!=FIELD_USER_NAME) && (field!=FIELD_USER_DESCRIPTION) && (field!=FIELD_USER_GIVEN_NAME)
|
||||
&& (field!=FIELD_USER_FAMILY_NAME))
|
||||
throw new ValidationException("The field search parameter is not valid.");
|
||||
break;
|
||||
|
||||
case FD_CATEGORIES:
|
||||
// no parameters to set here - there's no "field" for category search
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InternalStateError("loadPost failure - invalid display parameter");
|
||||
|
||||
} // end switch
|
||||
|
||||
// Validate the search mode parameter.
|
||||
mode = getParamInt(request,"mode",SEARCH_PREFIX);
|
||||
if ((mode!=SEARCH_PREFIX) && (mode!=SEARCH_SUBSTRING) && (mode!=SEARCH_REGEXP))
|
||||
throw new ValidationException("The search mode parameter is not valid.");
|
||||
|
||||
// Retrieve the search term parameter.
|
||||
term = request.getParameter("term");
|
||||
if (term==null)
|
||||
term = "";
|
||||
|
||||
// Retrieve the offset and find count parameters.
|
||||
offset = getParamInt(request,"ofs",0);
|
||||
find_count = getParamInt(request,"fcount",-1);
|
||||
|
||||
// Adjust the search return offset based on the command button click.
|
||||
int count = getNumResultsDisplayed();
|
||||
if (isImageButtonClicked(request,"search"))
|
||||
offset = 0;
|
||||
else if (isImageButtonClicked(request,"previous"))
|
||||
{ // adjust the offset in the reverse direction
|
||||
offset -= count;
|
||||
if (offset<0)
|
||||
offset = 0;
|
||||
|
||||
} // end else if
|
||||
else if (isImageButtonClicked(request,"next"))
|
||||
offset += count; // go forwards instead
|
||||
else
|
||||
throw new ValidationException("Unable to determine what action triggered the form.");
|
||||
|
||||
// Run the actual search.
|
||||
switch (disp)
|
||||
{
|
||||
case FD_SIGS:
|
||||
if (catid>=0)
|
||||
{ // retrieve the category descriptor and the subcategory list
|
||||
cat = user.getCategoryDescriptor(catid);
|
||||
subcats = cat.getSubCategories();
|
||||
if (cat.getCategoryID()>=0)
|
||||
{ // fill in the SIGs that are in this category
|
||||
results = user.getSIGsInCategory(cat,offset,count);
|
||||
if (find_count<0)
|
||||
find_count = user.getNumSIGsInCategory(cat);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // retrieve the SIG search data
|
||||
results = user.searchForSIGs(field,mode,term,offset,count);
|
||||
if (find_count<0)
|
||||
find_count = user.getSearchSIGCount(field,mode,term);
|
||||
|
||||
} // end else
|
||||
break;
|
||||
|
||||
case FD_USERS:
|
||||
results = engine.searchForUsers(field,mode,term,offset,count);
|
||||
if (find_count<0)
|
||||
find_count = engine.getSearchUserCount(field,mode,term);
|
||||
break;
|
||||
|
||||
case FD_CATEGORIES:
|
||||
results = user.searchForCategories(mode,term,offset,count);
|
||||
if (find_count<0)
|
||||
find_count = user.getSearchCategoryCount(mode,term);
|
||||
break;
|
||||
|
||||
} // end switch
|
||||
|
||||
} // end loadPost
|
||||
|
||||
public static String getCatJumpLink(RenderData rdat, int catid)
|
||||
{
|
||||
return rdat.getEncodedServletPath("find?disp=" + String.valueOf(FD_SIGS) + "&cat="
|
||||
+ String.valueOf(catid));
|
||||
|
||||
} // end getCatJumpLink
|
||||
|
||||
} // end class FindData
|
||||
28
src/com/silverwrist/venice/servlets/format/JSPRender.java
Normal file
28
src/com/silverwrist/venice/servlets/format/JSPRender.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
public interface JSPRender
|
||||
{
|
||||
public abstract void store(ServletRequest request);
|
||||
|
||||
public abstract String getTargetJSPName();
|
||||
|
||||
} // end interface JSPRender
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class JoinKeyDialog extends ContentDialog
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public JoinKeyDialog()
|
||||
{
|
||||
super("Join Key Required",null,"joinkeyform","sigops");
|
||||
setHiddenField("cmd","J");
|
||||
setHiddenField("sig","");
|
||||
setInstructions("You must specify a join key before you can join this SIG. You might have received "
|
||||
+ "the join key from the SIG's host, or via an invitation e-mail message. Please "
|
||||
+ "enter it in the box below.");
|
||||
addFormField(new CDTextFormField("key","Join key",null,false,32,64));
|
||||
addCommandButton(new CDImageButton("join","bn_join_now.gif","Join Now",80,24));
|
||||
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected JoinKeyDialog(JoinKeyDialog other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class ContentDialog
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void validateWholeForm() throws ValidationException
|
||||
{
|
||||
if (StringUtil.isStringEmpty(getFieldValue("key")))
|
||||
throw new ValidationException("No join key specified.");
|
||||
|
||||
} // end validateWholeForm
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setupDialog(SIGContext sig)
|
||||
{
|
||||
setHiddenField("sig",String.valueOf(sig.getSIGID()));
|
||||
|
||||
} // end setupDialog
|
||||
|
||||
public void doDialog(SIGContext sig) throws ValidationException, DataException, AccessError
|
||||
{
|
||||
validate();
|
||||
sig.join(getFieldValue("key"));
|
||||
|
||||
} // end doDialog
|
||||
|
||||
public void resetOnError(String message)
|
||||
{
|
||||
setErrorMessage(message);
|
||||
setFieldValue("key",null);
|
||||
|
||||
} // end resetOnError
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new JoinKeyDialog(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class JoinKeyDialog
|
||||
|
||||
83
src/com/silverwrist/venice/servlets/format/LoginDialog.java
Normal file
83
src/com/silverwrist/venice/servlets/format/LoginDialog.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.servlets.Variables;
|
||||
|
||||
public class LoginDialog extends ContentDialog
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public LoginDialog()
|
||||
{
|
||||
super("Log In",null,"loginform","account");
|
||||
setHiddenField("cmd","L");
|
||||
setHiddenField("tgt","");
|
||||
addFormField(new CDVeniceIDFormField("user","User name",null,false,32,64));
|
||||
addFormField(new CDPasswordFormFieldCommand("pass","Password",null,false,32,128,
|
||||
new CDImageButton("remind","bn_reminder.gif","Reminder",
|
||||
80,24)));
|
||||
//addFormField(new CDCheckBoxFormField("saveme","Save my user name and password for automatic logins",
|
||||
// null,"Y"));
|
||||
addCommandButton(new CDImageButton("login","bn_log_in.gif","Log In",80,24));
|
||||
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected LoginDialog(LoginDialog other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setTarget(String target)
|
||||
{
|
||||
setHiddenField("tgt",target);
|
||||
|
||||
} // end setTarget
|
||||
|
||||
public void setupNew(String target)
|
||||
{
|
||||
setHiddenField("tgt",target);
|
||||
|
||||
} // end setupNew
|
||||
|
||||
public void resetOnError(String message)
|
||||
{
|
||||
setErrorMessage(message);
|
||||
setFieldValue("pass",null);
|
||||
|
||||
} // end resetOnError
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new LoginDialog(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class LoginDialog
|
||||
103
src/com/silverwrist/venice/servlets/format/MenuPanelCache.java
Normal file
103
src/com/silverwrist/venice/servlets/format/MenuPanelCache.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import javax.servlet.ServletContext;
|
||||
import org.apache.log4j.*;
|
||||
|
||||
public class MenuPanelCache
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data values
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.servlets.MenuPanelCache";
|
||||
|
||||
private static Category logger = Category.getInstance(MenuPanelCache.class.getName());
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Hashtable cache;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected MenuPanelCache()
|
||||
{
|
||||
cache = new Hashtable();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public boolean isCached(String name)
|
||||
{
|
||||
return (cache.get(name)!=null);
|
||||
|
||||
} // end isCached
|
||||
|
||||
public void saveTemplate(ContentMenuPanel template)
|
||||
{
|
||||
String fullname = template.getClass().getName();
|
||||
int clip_pos = fullname.lastIndexOf('.');
|
||||
if (clip_pos>=0)
|
||||
fullname = fullname.substring(clip_pos+1);
|
||||
cache.put(fullname,template);
|
||||
|
||||
} // end saveTemplate
|
||||
|
||||
public ContentMenuPanel getNewMenuPanel(String name)
|
||||
{
|
||||
ContentMenuPanel template = (ContentMenuPanel)(cache.get(name));
|
||||
if (template!=null)
|
||||
return (ContentMenuPanel)(template.clone());
|
||||
else
|
||||
return null;
|
||||
|
||||
} // end getNewMenuPanel
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static operations for use by servlets
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static MenuPanelCache getMenuPanelCache(ServletContext ctxt)
|
||||
{
|
||||
// Look in the servlet attributes first.
|
||||
Object foo = ctxt.getAttribute(ATTR_NAME);
|
||||
if (foo!=null)
|
||||
return (MenuPanelCache)foo;
|
||||
|
||||
// create a new one and return it
|
||||
MenuPanelCache cache = new MenuPanelCache();
|
||||
ctxt.setAttribute(ATTR_NAME,cache);
|
||||
return cache;
|
||||
|
||||
} // end getMenuPanelCache
|
||||
|
||||
} // end class MenuPanelCache
|
||||
105
src/com/silverwrist/venice/servlets/format/MenuSIG.java
Normal file
105
src/com/silverwrist/venice/servlets/format/MenuSIG.java
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class MenuSIG implements ContentRender
|
||||
{
|
||||
private String image_url;
|
||||
private boolean image_url_needs_fixup = false;
|
||||
private String title;
|
||||
private List items_list;
|
||||
private int sigid;
|
||||
private boolean show_unjoin;
|
||||
|
||||
public MenuSIG(SIGContext ctxt)
|
||||
{
|
||||
try
|
||||
{ // retrieve the contact info for this puppy
|
||||
ContactInfo ci = ctxt.getContactInfo();
|
||||
image_url = ci.getPhotoURL();
|
||||
if (StringUtil.isStringEmpty(image_url))
|
||||
{ // just hit the default
|
||||
image_url = "default_sig_logo.gif";
|
||||
image_url_needs_fixup = true;
|
||||
|
||||
} // end if
|
||||
|
||||
} // end try
|
||||
catch (DataException e)
|
||||
{ // if we couldn't get the contact info, screw it
|
||||
image_url = null;
|
||||
|
||||
} // end catch
|
||||
|
||||
title = ctxt.getName();
|
||||
items_list = ctxt.getSIGFeaturesList();
|
||||
sigid = ctxt.getSIGID();
|
||||
show_unjoin = ctxt.canUnjoin();
|
||||
|
||||
} // end constructor
|
||||
|
||||
public int getID()
|
||||
{
|
||||
return sigid;
|
||||
|
||||
} // end getID
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
if (image_url!=null)
|
||||
{ // display the image by URL
|
||||
if (image_url_needs_fixup)
|
||||
{ // fix up the URL...
|
||||
image_url = rdat.getFullImagePath(image_url);
|
||||
image_url_needs_fixup = false;
|
||||
|
||||
} // end if
|
||||
|
||||
out.write("<DIV ALIGN=\"LEFT\"><IMG SRC=\"" + image_url + "\" WIDTH=110 HEIGHT=65 BORDER=0></DIV>\n");
|
||||
|
||||
} // end if
|
||||
|
||||
// display the title
|
||||
out.write("<B>" + StringUtil.encodeHTML(title) + "</B>");
|
||||
|
||||
// display the menu items
|
||||
Iterator it = items_list.iterator();
|
||||
while (it.hasNext())
|
||||
{ // display each menu item in turn
|
||||
SIGFeature ftr = (SIGFeature)(it.next());
|
||||
out.write("<BR>\n<A HREF=\"" + rdat.getEncodedServletPath(ftr.getApplet() + "?sig="
|
||||
+ String.valueOf(sigid)));
|
||||
out.write("\">" + StringUtil.encodeHTML(ftr.getName()) + "</A>\n");
|
||||
|
||||
} // end while
|
||||
|
||||
if (show_unjoin)
|
||||
out.write("<P>\n<A HREF=\"" + rdat.getEncodedServletPath("sigops?cmd=U&sig=" + String.valueOf(sigid))
|
||||
+ "\">Unjoin</A>\n");
|
||||
|
||||
out.write("\n"); // all done...
|
||||
|
||||
} // end renderHere
|
||||
|
||||
} // end class MenuTop
|
||||
37
src/com/silverwrist/venice/servlets/format/MenuTop.java
Normal file
37
src/com/silverwrist/venice/servlets/format/MenuTop.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
|
||||
public class MenuTop implements ContentRender
|
||||
{
|
||||
public MenuTop()
|
||||
{ // constructor does nothing
|
||||
} // end constructor
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<B>Front Page</B><BR>\n");
|
||||
out.write("<A HREF=\"\">Calendar</A><BR>\n"); // TODO: fill this link in
|
||||
out.write("<A HREF=\"\">Chat</A>\n"); // TODO: fill this link in
|
||||
|
||||
} // end renderHere
|
||||
|
||||
} // end class MenuTop
|
||||
155
src/com/silverwrist/venice/servlets/format/NewAccountDialog.java
Normal file
155
src/com/silverwrist/venice/servlets/format/NewAccountDialog.java
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.ServletRequest;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class NewAccountDialog extends ContentDialog
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private VeniceEngine engine = null;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public NewAccountDialog(List country_list)
|
||||
{
|
||||
super("Create Account",null,"createform","account");
|
||||
setInstructions("To create a new account, please enter your information below.");
|
||||
setHiddenField("cmd","C");
|
||||
setHiddenField("tgt","");
|
||||
addFormField(new CDFormCategoryHeader("Name"));
|
||||
addFormField(new CDTextFormField("prefix","Prefix","(Mr., Ms., etc.)",false,8,8));
|
||||
addFormField(new CDTextFormField("first","First name",null,true,32,64));
|
||||
addFormField(new CDTextFormField("mid","Middle initial",null,false,1,1));
|
||||
addFormField(new CDTextFormField("last","Last name",null,true,32,64));
|
||||
addFormField(new CDTextFormField("suffix","Suffix","(Jr., III, etc.)",false,16,16));
|
||||
addFormField(new CDFormCategoryHeader("Location"));
|
||||
addFormField(new CDTextFormField("loc","City",null,true,32,64));
|
||||
addFormField(new CDTextFormField("reg","State/Province",null,true,32,64));
|
||||
addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
|
||||
addFormField(new CDFormCategoryHeader("E-mail"));
|
||||
addFormField(new CDEmailAddressFormField("email","E-mail address",null,true,32,255));
|
||||
addFormField(new CDFormCategoryHeader("Account Information"));
|
||||
addFormField(new CDVeniceIDFormField("user","User name",null,true,32,64));
|
||||
addFormField(new CDPasswordFormField("pass1","Password",null,true,32,128));
|
||||
addFormField(new CDPasswordFormField("pass2","Password","(retype)",true,32,128));
|
||||
addFormField(new CDTextFormField("remind","Password reminder phrase",null,false,32,255));
|
||||
addCommandButton(new CDImageButton("create","bn_create.gif","Create",80,24));
|
||||
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected NewAccountDialog(NewAccountDialog other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class ContentDialog
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void validateWholeForm() throws ValidationException
|
||||
{
|
||||
if (!(getFieldValue("pass1").equals(getFieldValue("pass2"))))
|
||||
throw new ValidationException("The typed passwords do not match.");
|
||||
|
||||
if (engine.isEmailAddressBanned(getFieldValue("email")))
|
||||
throw new ValidationException("This email address may not register a new account.");
|
||||
|
||||
} // end validateWholeForm
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setEngine(VeniceEngine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
|
||||
} // end setEngine
|
||||
|
||||
public void setTarget(String target)
|
||||
{
|
||||
setHiddenField("tgt",target);
|
||||
|
||||
} // end setTarget
|
||||
|
||||
public UserContext doDialog(ServletRequest request)
|
||||
throws ValidationException, DataException, AccessError, EmailException
|
||||
{
|
||||
validate(); // validate the dialog
|
||||
|
||||
// Create the new user account and set up its initial context.
|
||||
UserContext uc = engine.createNewAccount(request.getRemoteAddr(),getFieldValue("user"),
|
||||
getFieldValue("pass1"),getFieldValue("remind"));
|
||||
|
||||
// Set up the account's contact info.
|
||||
ContactInfo ci = uc.getContactInfo();
|
||||
ci.setNamePrefix(getFieldValue("prefix"));
|
||||
ci.setGivenName(getFieldValue("first"));
|
||||
String blort = getFieldValue("mid");
|
||||
if ((blort==null) || (blort.length()<1))
|
||||
ci.setMiddleInitial(' ');
|
||||
else
|
||||
ci.setMiddleInitial(blort.charAt(0));
|
||||
ci.setFamilyName(getFieldValue("last"));
|
||||
ci.setNameSuffix(getFieldValue("suffix"));
|
||||
ci.setLocality(getFieldValue("loc"));
|
||||
ci.setRegion(getFieldValue("reg"));
|
||||
ci.setPostalCode(getFieldValue("pcode"));
|
||||
ci.setCountry(getFieldValue("country"));
|
||||
ci.setEmail(getFieldValue("email"));
|
||||
|
||||
// save the contact info for the user (this also sends email confirmation messages as needed)
|
||||
uc.putContactInfo(ci);
|
||||
|
||||
return uc;
|
||||
|
||||
} // end doDialog
|
||||
|
||||
public void resetOnError(String message)
|
||||
{
|
||||
setErrorMessage(message);
|
||||
setFieldValue("pass1",null);
|
||||
setFieldValue("pass2",null);
|
||||
|
||||
} // end resetOnError
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new NewAccountDialog(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class NewAccountDialog
|
||||
|
||||
|
||||
104
src/com/silverwrist/venice/servlets/format/NewSIGWelcome.java
Normal file
104
src/com/silverwrist/venice/servlets/format/NewSIGWelcome.java
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import com.silverwrist.venice.core.SIGContext;
|
||||
|
||||
public class NewSIGWelcome implements JSPRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Attribute name for request attribute
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.content.NewSIGWelcome";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String name;
|
||||
private String entry_url;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public NewSIGWelcome(SIGContext sig)
|
||||
{
|
||||
name = sig.getName();
|
||||
entry_url = "sig/" + sig.getAlias();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static NewSIGWelcome retrieve(ServletRequest request)
|
||||
{
|
||||
return (NewSIGWelcome)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface JSPRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void store(ServletRequest request)
|
||||
{
|
||||
request.setAttribute(ATTR_NAME,this);
|
||||
|
||||
} // end store
|
||||
|
||||
public String getTargetJSPName()
|
||||
{
|
||||
return "newsigwelcome.jsp";
|
||||
|
||||
} // end getTargetJSPName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getSIGName()
|
||||
{
|
||||
return name;
|
||||
|
||||
} // end getSIGName
|
||||
|
||||
public String getEntryURL(RenderData rdat)
|
||||
{
|
||||
return rdat.getEncodedServletPath(entry_url);
|
||||
|
||||
} // end getEntryURL
|
||||
|
||||
public String getDisplayURL(RenderData rdat)
|
||||
{
|
||||
return rdat.getFullServletPath(entry_url);
|
||||
|
||||
} // end getEntryURL
|
||||
|
||||
} // end class NewSIGWelcome
|
||||
357
src/com/silverwrist/venice/servlets/format/RenderConfig.java
Normal file
357
src/com/silverwrist/venice/servlets/format/RenderConfig.java
Normal file
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import javax.xml.parsers.*;
|
||||
import org.apache.log4j.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import com.silverwrist.util.DOMElementHelper;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.ConfigException;
|
||||
|
||||
public class RenderConfig
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data values
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.servlets.RenderConfig";
|
||||
protected static final String CONFIG_FILE_PARAM = "render.config";
|
||||
|
||||
private static Category logger = Category.getInstance(RenderConfig.class.getName());
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private Document config;
|
||||
private String site_title;
|
||||
private boolean want_comments;
|
||||
private boolean allow_gzip;
|
||||
private String font_face;
|
||||
private String base_url;
|
||||
private String image_url;
|
||||
private String site_logo;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected RenderConfig(String config_file) throws ConfigException
|
||||
{
|
||||
config = loadConfiguration(config_file);
|
||||
|
||||
// Make sure the configuration is valid...
|
||||
Element root = config.getDocumentElement();
|
||||
if (!(root.getTagName().equals("render-config")))
|
||||
{ // not the correct root tag name
|
||||
logger.fatal("config document is not a <render-config/> document (root tag: <"
|
||||
+ root.getTagName() + "/>)");
|
||||
throw new ConfigException("document is not a <render-config/> document",root);
|
||||
|
||||
} // end if
|
||||
|
||||
// Get the site name.
|
||||
DOMElementHelper root_h = new DOMElementHelper(root);
|
||||
site_title = root_h.getSubElementText("site-name");
|
||||
if (site_title==null)
|
||||
{ // no <site-name/> section - bail out now!
|
||||
logger.fatal("config document has no <site-title/> element");
|
||||
throw new ConfigException("no <site-title/> section found in config file",root);
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Site title: " + site_title);
|
||||
|
||||
Element render_sect = root_h.getSubElement("rendering");
|
||||
if (render_sect==null)
|
||||
{ // no <rendering/> section - bail out now!
|
||||
logger.fatal("config document has no <rendering/> section");
|
||||
throw new ConfigException("no <rendering/> section found in config file",root);
|
||||
|
||||
} // end if
|
||||
|
||||
DOMElementHelper render_sect_h = new DOMElementHelper(render_sect);
|
||||
want_comments = render_sect_h.hasChildElement("html-comments");
|
||||
allow_gzip = render_sect_h.hasChildElement("gzip-output");
|
||||
if (logger.isDebugEnabled())
|
||||
{ // log the read values
|
||||
logger.debug("Use HTML comments: " + String.valueOf(want_comments));
|
||||
logger.debug("Use GZIP encoding: " + String.valueOf(allow_gzip));
|
||||
|
||||
} // end if
|
||||
|
||||
font_face = render_sect_h.getSubElementText("font");
|
||||
if (font_face==null)
|
||||
{ // no <font/> tag - bail out now!
|
||||
logger.fatal("<rendering/> section has no <font/> element");
|
||||
throw new ConfigException("no <font/> found in <rendering/> section",render_sect);
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Font face: " + font_face);
|
||||
|
||||
Element paths_sect = root_h.getSubElement("paths");
|
||||
if (paths_sect==null)
|
||||
{ // no <paths/> section - bail out now!
|
||||
logger.fatal("config document has no <paths/> section");
|
||||
throw new ConfigException("no <paths/> section found in config file",root);
|
||||
|
||||
} // end if
|
||||
|
||||
DOMElementHelper paths_sect_h = new DOMElementHelper(paths_sect);
|
||||
base_url = paths_sect_h.getSubElementText("base");
|
||||
if (base_url==null)
|
||||
{ // no <base/> tag - bail out now!
|
||||
logger.fatal("<paths/> section has no <base/> element");
|
||||
throw new ConfigException("no <base/> found in <paths/> section",paths_sect);
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Base path: " + base_url);
|
||||
|
||||
image_url = paths_sect_h.getSubElementText("image");
|
||||
if (image_url==null)
|
||||
{ // no <image/> tag - bail out now!
|
||||
logger.fatal("<paths/> section has no <image/> element");
|
||||
throw new ConfigException("no <image/> found in <paths/> section",paths_sect);
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Image path: " + image_url);
|
||||
|
||||
site_logo = paths_sect_h.getSubElementText("site-logo");
|
||||
if (site_logo==null)
|
||||
{ // no <image/> tag - bail out now!
|
||||
logger.fatal("<paths/> section has no <site-logo/> element");
|
||||
throw new ConfigException("no <site-logo/> found in <paths/> section",paths_sect);
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Site logo: " + image_url);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Document loadConfiguration(String configname) throws ConfigException
|
||||
{
|
||||
try
|
||||
{ // create a simple DOM parser by using the Java XML parsing API
|
||||
DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
|
||||
fac.setNamespaceAware(false);
|
||||
fac.setValidating(false);
|
||||
DocumentBuilder parser = fac.newDocumentBuilder();
|
||||
|
||||
// access the config file and parse it into our config data tree
|
||||
File configfile = new File(configname);
|
||||
Document rc = parser.parse(configfile);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("configuration loaded successfully");
|
||||
return rc;
|
||||
|
||||
} // end try
|
||||
catch (FactoryConfigurationError e1)
|
||||
{ // if the document builder factory could not be created
|
||||
logger.fatal("Parser factory configuration error: " + e1.getMessage(),e1);
|
||||
throw new ConfigException("XML parser factory could not be created - " + e1.getMessage());
|
||||
|
||||
} // end catch
|
||||
catch (ParserConfigurationException e2)
|
||||
{ // if the XML parser itself could not be created
|
||||
logger.fatal("Parser configuration error: " + e2.getMessage(),e2);
|
||||
throw new ConfigException("XML parser could not be created - " + e2.getMessage(),e2);
|
||||
|
||||
} // end catch
|
||||
catch (SAXException e3)
|
||||
{ // if the XML parser choked on our document
|
||||
if (e3 instanceof SAXParseException)
|
||||
{ // we have a detailed message - make a proper exception
|
||||
SAXParseException e3a = (SAXParseException)e3;
|
||||
logger.fatal("Config file error [" + configname + ":" + e3a.getLineNumber() + ","
|
||||
+ e3a.getColumnNumber() + "]: " + e3a.getMessage(),e3a);
|
||||
throw new ConfigException("Configuration file error: " + e3a.getMessage() + " at line "
|
||||
+ e3a.getLineNumber() + ", column " + e3a.getColumnNumber(),e3a);
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // generic exception - just send up a simple error message
|
||||
logger.fatal("Config file error [" + configname + "]: " + e3.getMessage(),e3);
|
||||
throw new ConfigException("Configuration file error - " + e3.getMessage(),e3);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end catch
|
||||
catch (IOException e4)
|
||||
{ // error reading the config file itself off the disk
|
||||
logger.fatal("IO error reading config: " + e4.getMessage(),e4);
|
||||
throw new ConfigException("unable to read config file \"" + configname + "\" - " + e4.getMessage(),e4);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end loadConfiguration
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations usable only by RenderData
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
boolean useHTMLComments()
|
||||
{
|
||||
return want_comments;
|
||||
|
||||
} // end useHTMLComments
|
||||
|
||||
boolean isGZIPAllowed()
|
||||
{
|
||||
return allow_gzip;
|
||||
|
||||
} // end isGZIPAllowed
|
||||
|
||||
String getFullServletPath(String name)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(base_url).append(name);
|
||||
return buf.toString();
|
||||
|
||||
} // end getFullServletPath
|
||||
|
||||
String getFullImagePath(String name)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(image_url).append(name);
|
||||
return buf.toString();
|
||||
|
||||
} // end getFullImagePath
|
||||
|
||||
String getTitleTag(String specific)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("<TITLE>").append(specific).append(" - ").append(site_title).append("</TITLE>");
|
||||
return buf.toString();
|
||||
|
||||
} // end getTitleTag
|
||||
|
||||
String getSiteImageTag(int hspace, int vspace)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("<IMG SRC=\"").append(site_logo).append("\" ALT=\"").append(site_title);
|
||||
buf.append("\" WIDTH=140 HEIGHT=80 BORDER=0");
|
||||
if (hspace>0)
|
||||
buf.append(" HSPACE=").append(hspace);
|
||||
if (vspace>0)
|
||||
buf.append(" VSPACE=").append(vspace);
|
||||
buf.append('>');
|
||||
return buf.toString();
|
||||
|
||||
} // end getSiteImageTag
|
||||
|
||||
String getStdFontTag(String color, int size)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer("<FONT FACE=\"");
|
||||
buf.append(font_face).append("\" SIZE=").append(size);
|
||||
if (color!=null)
|
||||
buf.append(" COLOR=\"").append(color).append("\"");
|
||||
buf.append('>');
|
||||
return buf.toString();
|
||||
|
||||
} // end getStdFontTag
|
||||
|
||||
public String getRequiredBullet()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer("<FONT FACE=\"");
|
||||
buf.append(font_face).append("\" COLOR=\"red\">*</FONT>");
|
||||
return buf.toString();
|
||||
|
||||
} // end getRequiredBullet
|
||||
|
||||
void writeFooter(Writer out) throws IOException
|
||||
{
|
||||
out.write("<HR WIDTH=\"80%\"><DIV ALIGN=\"CENTER\">\n<IMG SRC=\"");
|
||||
out.write(getFullImagePath("powered-by-venice.gif"));
|
||||
out.write("\" ALT=\"Powered by Venice\" WIDTH=140 HEIGHT=80 HSPACE=0 VSPACE=0>\n</DIV>\n");
|
||||
|
||||
} // end writeFooter
|
||||
|
||||
void writeContentHeader(Writer out, String primary, String secondary) throws IOException
|
||||
{
|
||||
out.write(getStdFontTag("#3333AA",5) + "<B>" + StringUtil.encodeHTML(primary) + "</B></FONT>");
|
||||
if (secondary!=null)
|
||||
out.write(" " + getStdFontTag("#3333AA",3) + "<B>" + StringUtil.encodeHTML(secondary)
|
||||
+ "</B></FONT>");
|
||||
out.write("<HR ALIGN=LEFT SIZE=2 WIDTH=\"90%\" NOSHADE>\n");
|
||||
|
||||
} // end writeContentHeader
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static operations for use by VeniceServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static RenderConfig getRenderConfig(ServletContext ctxt) throws ServletException
|
||||
{
|
||||
// Look in the servlet attributes first.
|
||||
Object obj = ctxt.getAttribute(ATTR_NAME);
|
||||
if (obj!=null)
|
||||
return (RenderConfig)obj;
|
||||
|
||||
// Get the parameter for the renderer's config file.
|
||||
String cfgfile = ctxt.getInitParameter(CONFIG_FILE_PARAM);
|
||||
logger.info("Initializing Venice rendering using config file: " + cfgfile);
|
||||
|
||||
try
|
||||
{ // create the RenderConfig object and save it to attributes.
|
||||
RenderConfig rconf = new RenderConfig(cfgfile);
|
||||
ctxt.setAttribute(ATTR_NAME,rconf);
|
||||
return rconf;
|
||||
|
||||
} // end try
|
||||
catch (ConfigException e)
|
||||
{ // configuration failed! post an error message
|
||||
logger.fatal("Rendering configuration failed: " + e.getMessage(),e);
|
||||
throw new ServletException("Venice rendering configuration failed: " + e.getMessage(),e);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getRenderConfig
|
||||
|
||||
public static RenderData createRenderData(ServletContext ctxt, HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException
|
||||
{
|
||||
return new RenderData(getRenderConfig(ctxt),request,response);
|
||||
|
||||
} // end createRenderData
|
||||
|
||||
} // end class RenderConfig
|
||||
296
src/com/silverwrist/venice/servlets/format/RenderData.java
Normal file
296
src/com/silverwrist/venice/servlets/format/RenderData.java
Normal file
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.text.DateFormat;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
|
||||
public class RenderData
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data values
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final String ATTR_NAME = "com.silverwrist.venice.RenderData";
|
||||
|
||||
private static Category logger = Category.getInstance(RenderData.class.getName());
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private RenderConfig rconf;
|
||||
private HttpServletRequest request;
|
||||
private HttpServletResponse response;
|
||||
private boolean can_gzip = false;
|
||||
private Locale my_locale;
|
||||
private TimeZone my_timezone;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
RenderData(RenderConfig rconf, HttpServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
this.rconf = rconf;
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
|
||||
// determine whether this browser can accept GZIP-encoded content
|
||||
String encodings = request.getHeader("Accept-Encoding");
|
||||
if ((encodings!=null) && (encodings.indexOf("gzip")>=0))
|
||||
can_gzip = true;
|
||||
|
||||
// TODO: replace with reading user's preferences
|
||||
my_locale = Locale.getDefault();
|
||||
my_timezone = TimeZone.getDefault();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static RenderData retrieve(ServletRequest request)
|
||||
{
|
||||
return (RenderData)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void store(ServletRequest request)
|
||||
{
|
||||
request.setAttribute(ATTR_NAME,this);
|
||||
|
||||
} // end store
|
||||
|
||||
public boolean useHTMLComments()
|
||||
{
|
||||
return rconf.useHTMLComments();
|
||||
|
||||
} // end useHTMLComments
|
||||
|
||||
public boolean canGZIPEncode()
|
||||
{
|
||||
return rconf.isGZIPAllowed() && can_gzip;
|
||||
|
||||
} // end canGZIPEncode
|
||||
|
||||
public String getSiteImageTag(int hspace, int vspace)
|
||||
{
|
||||
return rconf.getSiteImageTag(hspace,vspace);
|
||||
|
||||
} // end getSiteImageTag
|
||||
|
||||
public String getFullServletPath(String name)
|
||||
{
|
||||
return rconf.getFullServletPath(name);
|
||||
|
||||
} // end getFullServletPath
|
||||
|
||||
public String getEncodedServletPath(String name)
|
||||
{
|
||||
return response.encodeURL(rconf.getFullServletPath(name));
|
||||
|
||||
} // end getEncodedServletPath
|
||||
|
||||
public String getFullImagePath(String name)
|
||||
{
|
||||
return rconf.getFullImagePath(name);
|
||||
|
||||
} // end getFullImagePath
|
||||
|
||||
public String getFormatJSPPath(String name)
|
||||
{
|
||||
return "/format/" + name;
|
||||
|
||||
} // end getFullFormatJSPPath
|
||||
|
||||
public String getStdFontTag(String color, int size)
|
||||
{
|
||||
return rconf.getStdFontTag(color,size);
|
||||
|
||||
} // end getStdFontTag
|
||||
|
||||
public String getTitleTag(String specific)
|
||||
{
|
||||
return rconf.getTitleTag(specific);
|
||||
|
||||
} // end getTitleTag
|
||||
|
||||
public String getRequiredBullet()
|
||||
{
|
||||
return rconf.getRequiredBullet();
|
||||
|
||||
} // end getRequiredBullet
|
||||
|
||||
public void writeFooter(Writer out) throws IOException
|
||||
{
|
||||
rconf.writeFooter(out);
|
||||
|
||||
} // end writeFooter
|
||||
|
||||
public void writeContentHeader(Writer out, String primary, String secondary) throws IOException
|
||||
{
|
||||
rconf.writeContentHeader(out,primary,secondary);
|
||||
|
||||
} // end writeContentHeader
|
||||
|
||||
public void writeContentSelectorHeader(Writer out, String caption, List choices,
|
||||
List urls, int selected) throws IOException
|
||||
{
|
||||
int nchoice = choices.size();
|
||||
if (urls.size()<nchoice)
|
||||
nchoice = urls.size();
|
||||
|
||||
out.write(rconf.getStdFontTag("#3333AA",5) + "<B>" + StringUtil.encodeHTML(caption)
|
||||
+ "</B></FONT> " + rconf.getStdFontTag("#3333AA",3));
|
||||
for (int i=0; i<nchoice; i++)
|
||||
{ // loop through all the choices
|
||||
if (i==0)
|
||||
out.write("[");
|
||||
else
|
||||
out.write("|");
|
||||
out.write(" ");
|
||||
if (i==selected)
|
||||
out.write("<B>");
|
||||
else
|
||||
out.write("<A HREF=\"" + getEncodedServletPath((String)(urls.get(i))) + "\">");
|
||||
out.write(StringUtil.encodeHTML((String)(choices.get(i))));
|
||||
if (i==selected)
|
||||
out.write("</B>");
|
||||
else
|
||||
out.write("</A>");
|
||||
out.write(" ");
|
||||
|
||||
} // end for
|
||||
|
||||
out.write("]</FONT><HR ALIGN=LEFT SIZE=2 WIDTH=\"90%\" NOSHADE>\n");
|
||||
|
||||
} // end writeContentSelectorHeader
|
||||
|
||||
public String formatDateForDisplay(Date date)
|
||||
{
|
||||
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM,my_locale);
|
||||
fmt.setTimeZone(my_timezone);
|
||||
return fmt.format(date);
|
||||
|
||||
} // end formatDateForDisplay
|
||||
|
||||
public Calendar createCalendar()
|
||||
{
|
||||
return new GregorianCalendar(my_timezone,my_locale);
|
||||
|
||||
} // end createCalendar
|
||||
|
||||
public Calendar createCalendar(Date date)
|
||||
{
|
||||
Calendar rc = new GregorianCalendar(my_timezone,my_locale);
|
||||
rc.setTime(date);
|
||||
return rc;
|
||||
|
||||
} // end createCalendar
|
||||
|
||||
public void flushOutput() throws IOException
|
||||
{
|
||||
response.flushBuffer();
|
||||
|
||||
} // end flushOutput
|
||||
|
||||
public String encodeURL(String url)
|
||||
{
|
||||
return response.encodeURL(url);
|
||||
|
||||
} // end encodeURL
|
||||
|
||||
public void storeBaseJSPData(BaseJSPData data)
|
||||
{
|
||||
data.store(request);
|
||||
|
||||
} // end storeBaseJSPData
|
||||
|
||||
public void storeJSPRender(JSPRender jr)
|
||||
{
|
||||
jr.store(request);
|
||||
|
||||
} // end storeJSPRender
|
||||
|
||||
public void forwardDispatch(RequestDispatcher dispatcher) throws IOException, ServletException
|
||||
{
|
||||
dispatcher.forward(request,response);
|
||||
|
||||
} // end forwardDispatch
|
||||
|
||||
public void includeDispatch(RequestDispatcher dispatcher) throws IOException, ServletException
|
||||
{
|
||||
dispatcher.include(request,response);
|
||||
|
||||
} // end forwardDispatch
|
||||
|
||||
public void redirectTo(String servlet) throws IOException
|
||||
{
|
||||
String url = response.encodeRedirectURL(rconf.getFullServletPath(servlet));
|
||||
response.sendRedirect(url);
|
||||
|
||||
} // end redirectTo
|
||||
|
||||
public String getActivityString(Date date)
|
||||
{
|
||||
if (date==null)
|
||||
return "Never"; // safeguard
|
||||
|
||||
Calendar c_last = createCalendar(date);
|
||||
Calendar c_now = createCalendar(new Date());
|
||||
int delta_days = 0;
|
||||
while ( (c_last.get(Calendar.YEAR)!=c_now.get(Calendar.YEAR))
|
||||
|| (c_last.get(Calendar.DAY_OF_YEAR)!=c_now.get(Calendar.DAY_OF_YEAR)))
|
||||
{ // advance until we're pointing at the same year and the same day of the year
|
||||
delta_days++;
|
||||
c_last.add(Calendar.DAY_OF_YEAR,1);
|
||||
|
||||
} // end while
|
||||
|
||||
switch (delta_days)
|
||||
{ // now return a string based on the difference in days
|
||||
case 0:
|
||||
return "Today";
|
||||
|
||||
case 1:
|
||||
return "Yesterday";
|
||||
|
||||
default:
|
||||
return String.valueOf(delta_days) + " days ago";
|
||||
|
||||
} // end switch
|
||||
|
||||
} // end getActivityString
|
||||
|
||||
} // end class RenderData
|
||||
68
src/com/silverwrist/venice/servlets/format/SIGAdminTop.java
Normal file
68
src/com/silverwrist/venice/servlets/format/SIGAdminTop.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.venice.core.SIGContext;
|
||||
|
||||
public class SIGAdminTop extends ContentMenuPanel
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public SIGAdminTop()
|
||||
{
|
||||
super("SIG Administration:",null);
|
||||
addChoice("SIG Profile","sigadmin?sig=$s&cmd=P");
|
||||
addChoice("Set SIG Category","sigadmin?sig=$s&cmd=T");
|
||||
addChoice("Set SIG Features","sigadmin?sig=$s&cmd=F");
|
||||
addChoice("Membership Control","sigadmin?sig=$s&cmd=M");
|
||||
// TODO: More options
|
||||
addChoice("Delete SIG","sigadmin?sig=$s&cmd=DEL");
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected SIGAdminTop(SIGAdminTop other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setSIG(SIGContext sig)
|
||||
{
|
||||
setSubtitle(sig.getName());
|
||||
setParameter("s",String.valueOf(sig.getSIGID()));
|
||||
|
||||
} // end setSIG
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new SIGAdminTop(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class SIGAdminTop
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import javax.servlet.ServletRequest;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class SIGCategoryBrowseData implements JSPRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Attribute name for request attribute
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.content.UserProfileData";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String name;
|
||||
private String base_applet;
|
||||
private CategoryDescriptor prev_cat;
|
||||
private CategoryDescriptor curr_cat;
|
||||
private List subcats;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public SIGCategoryBrowseData(UserContext user, SIGContext sig, int current_id) throws DataException
|
||||
{
|
||||
name = sig.getName();
|
||||
base_applet = "sigadmin?sig=" + String.valueOf(sig.getSIGID());
|
||||
prev_cat = sig.getCategory();
|
||||
if (prev_cat.getCategoryID()==current_id)
|
||||
curr_cat = prev_cat;
|
||||
else
|
||||
curr_cat = user.getCategoryDescriptor(current_id);
|
||||
subcats = curr_cat.getSubCategories();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static SIGCategoryBrowseData retrieve(ServletRequest request)
|
||||
{
|
||||
return (SIGCategoryBrowseData)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface JSPRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void store(ServletRequest request)
|
||||
{
|
||||
request.setAttribute(ATTR_NAME,this);
|
||||
|
||||
} // end store
|
||||
|
||||
public String getTargetJSPName()
|
||||
{
|
||||
return "sigcatbrowser.jsp";
|
||||
|
||||
} // end getTargetJSPName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getSIGName()
|
||||
{
|
||||
return name;
|
||||
|
||||
} // end if
|
||||
|
||||
public String getCancelURL(RenderData rdat)
|
||||
{
|
||||
return rdat.getEncodedServletPath(base_applet);
|
||||
|
||||
} // end getCancelURL
|
||||
|
||||
public String getPreviousCategory()
|
||||
{
|
||||
return prev_cat.toString();
|
||||
|
||||
} // end getPreviousCategory
|
||||
|
||||
public CategoryDescriptor getCurrentCategory()
|
||||
{
|
||||
return curr_cat;
|
||||
|
||||
} // end getCurrentCategory
|
||||
|
||||
public String getGoLink(RenderData rdat, int catid)
|
||||
{
|
||||
return rdat.getEncodedServletPath(base_applet + "&cmd=T&go=" + String.valueOf(catid));
|
||||
|
||||
} // end getGoLink
|
||||
|
||||
public String getSetLink(RenderData rdat, int catid)
|
||||
{
|
||||
return rdat.getEncodedServletPath(base_applet + "&cmd=T&set=" + String.valueOf(catid));
|
||||
|
||||
} // end getGoLink
|
||||
|
||||
public Iterator getSubcategoryIterator()
|
||||
{
|
||||
return subcats.iterator();
|
||||
|
||||
} // end getSubcategoryIterator
|
||||
|
||||
public boolean hasSubcategories()
|
||||
{
|
||||
return (subcats.size()>0);
|
||||
|
||||
} // end hasSubcategories
|
||||
|
||||
} // end class SIGCategoryBrowseData
|
||||
158
src/com/silverwrist/venice/servlets/format/SIGProfileData.java
Normal file
158
src/com/silverwrist/venice/servlets/format/SIGProfileData.java
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class SIGProfileData implements JSPRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Attribute name for request attribute
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.content.SIGProfileData";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private VeniceEngine engine; // the Venice engine
|
||||
private UserContext user; // the current user managing this
|
||||
private SIGContext sig; // the SIG being displayed
|
||||
private ContactInfo ci; // SIG's contact info
|
||||
private UserProfile host_prof; // SIG host's user profile
|
||||
private CategoryDescriptor cat; // SIG's full category descriptor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public SIGProfileData(VeniceEngine engine, UserContext user, SIGContext ctxt) throws DataException
|
||||
{
|
||||
this.engine = engine;
|
||||
this.user = user;
|
||||
this.sig = ctxt;
|
||||
this.ci = ctxt.getContactInfo();
|
||||
this.host_prof = ctxt.getHostProfile();
|
||||
this.cat = ctxt.getCategory();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static SIGProfileData retrieve(ServletRequest request)
|
||||
{
|
||||
return (SIGProfileData)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface JSPRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void store(ServletRequest request)
|
||||
{
|
||||
request.setAttribute(ATTR_NAME,this);
|
||||
|
||||
} // end store
|
||||
|
||||
public String getTargetJSPName()
|
||||
{
|
||||
return "sigprofile.jsp";
|
||||
|
||||
} // end getTargetJSPName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public SIGContext getSIGContext()
|
||||
{
|
||||
return sig;
|
||||
|
||||
} // end getSIGContext
|
||||
|
||||
public String getSIGLogoURL(RenderData rdat)
|
||||
{
|
||||
String tmp = ci.getPhotoURL();
|
||||
if (StringUtil.isStringEmpty(tmp))
|
||||
tmp = rdat.getFullImagePath("default_sig_logo.gif");
|
||||
return tmp;
|
||||
|
||||
} // end getSIGLogoURL
|
||||
|
||||
public boolean isUserLoggedIn()
|
||||
{
|
||||
return user.isLoggedIn();
|
||||
|
||||
} // end isUserLoggedIn
|
||||
|
||||
public String getHostUserName()
|
||||
{
|
||||
return host_prof.getUserName();
|
||||
|
||||
} // end getHostUserName
|
||||
|
||||
public ContactInfo getSIGContactInfo()
|
||||
{
|
||||
return ci;
|
||||
|
||||
} // end getSIGContactInfo
|
||||
|
||||
public String getAddressLastLine()
|
||||
{
|
||||
String tmp_c = ci.getLocality();
|
||||
String tmp_s = ci.getRegion();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
if (!(StringUtil.isStringEmpty(tmp_c)) && !(StringUtil.isStringEmpty(tmp_s)))
|
||||
buf.append(tmp_c).append(", ").append(tmp_s);
|
||||
else if (!(StringUtil.isStringEmpty(tmp_c)))
|
||||
buf.append(tmp_c);
|
||||
else if (!(StringUtil.isStringEmpty(tmp_s)))
|
||||
buf.append(tmp_s);
|
||||
tmp_s = ci.getPostalCode();
|
||||
if (!(StringUtil.isStringEmpty(tmp_s)))
|
||||
buf.append(' ').append(tmp_s);
|
||||
return buf.toString();
|
||||
|
||||
} // end getAddressLastLine
|
||||
|
||||
public String getFullCountry()
|
||||
{
|
||||
return engine.getNameOfCountry(ci.getCountry());
|
||||
|
||||
} // end getFullCountry
|
||||
|
||||
public CategoryDescriptor getCategory()
|
||||
{
|
||||
return cat;
|
||||
|
||||
} // end getCategory
|
||||
|
||||
} // end class SIGProfileData
|
||||
98
src/com/silverwrist/venice/servlets/format/SIGWelcome.java
Normal file
98
src/com/silverwrist/venice/servlets/format/SIGWelcome.java
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import com.silverwrist.venice.core.SIGContext;
|
||||
|
||||
public class SIGWelcome implements JSPRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Attribute name for request attribute
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.content.SIGWelcome";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String name;
|
||||
private String entry_url;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public SIGWelcome(SIGContext sig)
|
||||
{
|
||||
name = sig.getName();
|
||||
entry_url = "sig/" + sig.getAlias();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static SIGWelcome retrieve(ServletRequest request)
|
||||
{
|
||||
return (SIGWelcome)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface JSPRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void store(ServletRequest request)
|
||||
{
|
||||
request.setAttribute(ATTR_NAME,this);
|
||||
|
||||
} // end store
|
||||
|
||||
public String getTargetJSPName()
|
||||
{
|
||||
return "sigwelcome.jsp";
|
||||
|
||||
} // end getTargetJSPName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getSIGName()
|
||||
{
|
||||
return name;
|
||||
|
||||
} // end getSIGName
|
||||
|
||||
public String getEntryURL(RenderData rdat)
|
||||
{
|
||||
return rdat.getEncodedServletPath(entry_url);
|
||||
|
||||
} // end getEntryURL
|
||||
|
||||
} // end class SIGWelcome
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.venice.core.UserContext;
|
||||
import com.silverwrist.venice.core.DataException;
|
||||
|
||||
public class TCPanelConferences extends TCStandardPanel
|
||||
{
|
||||
public TCPanelConferences()
|
||||
{
|
||||
super("Your Favorite Conferences:",null);
|
||||
addButton("bn_manage.gif","Manage",null,true,80,24);
|
||||
|
||||
} // end constructor
|
||||
|
||||
public TCPanelConferences(TCPanelConferences other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
public void renderContent(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
/* BEGIN TEMP */
|
||||
out.write("<FONT FACE=\"Arial, Helvetica\" SIZE=2><UL>\n");
|
||||
out.write("<LI>BOFH (Benevolent Dictators)</LI>\n");
|
||||
out.write("<LI>Playground (Electric Minds)</LI>\n");
|
||||
out.write("<LI>Commons (Electric Minds)</LI>\n");
|
||||
out.write("<LI>Top Ten Lists (Pamela's Lounge)</LI>\n");
|
||||
out.write("</UL></FONT>\n");
|
||||
/* END TEMP */
|
||||
|
||||
} // end renderHere
|
||||
|
||||
public void configure(UserContext uc, String parameter) throws DataException
|
||||
{ // TEMP - do nothing
|
||||
super.configure(uc,parameter);
|
||||
if (!(uc.isLoggedIn()))
|
||||
setTitle("Featured Conferences:");
|
||||
|
||||
} // end configure
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new TCPanelConferences(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class TCPanelSIGs
|
||||
92
src/com/silverwrist/venice/servlets/format/TCPanelSIGs.java
Normal file
92
src/com/silverwrist/venice/servlets/format/TCPanelSIGs.java
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import com.silverwrist.venice.core.SIGContext;
|
||||
import com.silverwrist.venice.core.UserContext;
|
||||
import com.silverwrist.venice.core.DataException;
|
||||
|
||||
public class TCPanelSIGs extends TCStandardPanel
|
||||
{
|
||||
private List my_sigs = null;
|
||||
|
||||
public TCPanelSIGs()
|
||||
{
|
||||
super("Your SIGs:",null);
|
||||
addButton("bn_manage.gif","Manage",null,true,80,24);
|
||||
addButton("bn_create_new.gif","Create New","sigops?cmd=C",true,80,24);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected TCPanelSIGs(TCPanelSIGs other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
public void renderContent(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write(rdat.getStdFontTag(null,2) + "\n");
|
||||
if (my_sigs.size()>0)
|
||||
{ // display the list of available SIGs
|
||||
out.write("<UL>\n");
|
||||
|
||||
Iterator it = my_sigs.iterator();
|
||||
while (it.hasNext())
|
||||
{ // display the names of the SIGs one by one
|
||||
SIGContext sig = (SIGContext)(it.next());
|
||||
// TODO: make this fancier than just an unordered list
|
||||
out.write("<LI><B><A HREF=\"" + rdat.getEncodedServletPath("sig/" + sig.getAlias())
|
||||
+ "\">" + sig.getName() + "</A></B>");
|
||||
if (sig.isAdmin())
|
||||
out.write(" <IMG SRC=\"" + rdat.getFullImagePath("tag_host.gif")
|
||||
+ "\" ALT=\"Host!\" BORDER=0 WIDTH=40 HEIGHT=20>");
|
||||
out.write("</LI>\n");
|
||||
|
||||
} // end while
|
||||
|
||||
out.write("</UL>\n");
|
||||
|
||||
} // end if
|
||||
else
|
||||
out.write("<EM>You are not a member of any SIGs.</EM>\n");
|
||||
|
||||
out.write("</FONT>\n");
|
||||
|
||||
} // end renderContent
|
||||
|
||||
public void configure(UserContext uc, String parameter) throws DataException
|
||||
{
|
||||
super.configure(uc,parameter);
|
||||
if (!(uc.isLoggedIn()))
|
||||
setTitle("Featured SIGs:");
|
||||
my_sigs = uc.getMemberSIGs();
|
||||
|
||||
} // end configure
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new TCPanelSIGs(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class TCPanelSIGs
|
||||
184
src/com/silverwrist/venice/servlets/format/TCStandardPanel.java
Normal file
184
src/com/silverwrist/venice/servlets/format/TCStandardPanel.java
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
import com.silverwrist.venice.core.UserContext;
|
||||
import com.silverwrist.venice.core.DataException;
|
||||
|
||||
public abstract class TCStandardPanel extends TopContentPanel
|
||||
{
|
||||
class TCButton implements ContentRender
|
||||
{
|
||||
private String image;
|
||||
private String alt_text;
|
||||
private String url;
|
||||
private boolean login_only;
|
||||
private int width;
|
||||
private int height;
|
||||
|
||||
public TCButton(String image, String alt_text, String url, boolean login_only, int width, int height)
|
||||
{
|
||||
this.image = image;
|
||||
this.alt_text = alt_text;
|
||||
this.url = url;
|
||||
this.login_only = login_only;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
} // end constructor
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
if (url!=null)
|
||||
out.write("<A HREF=\"" + rdat.getEncodedServletPath(url) + "\">");
|
||||
out.write("<IMG SRC=\"" + rdat.getFullImagePath(image) + "\" ALT=\"" + alt_text);
|
||||
out.write("\" BORDER=0 WIDTH=" + String.valueOf(width) + " HEIGHT=" + String.valueOf(height) + ">");
|
||||
if (url!=null)
|
||||
out.write("</A>");
|
||||
|
||||
} // end renderHere
|
||||
|
||||
public boolean isLoginOnly()
|
||||
{
|
||||
return login_only;
|
||||
|
||||
} // end isLoginOnly
|
||||
|
||||
} // end class TCButton
|
||||
|
||||
// Attributes
|
||||
private String title;
|
||||
private String subtitle;
|
||||
private Vector buttons;
|
||||
|
||||
private String real_title;
|
||||
private String real_subtitle;
|
||||
private boolean logged_in;
|
||||
|
||||
protected TCStandardPanel(String title, String subtitle)
|
||||
{
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.buttons = new Vector();
|
||||
this.real_title = title;
|
||||
this.real_subtitle = subtitle;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected TCStandardPanel(TCStandardPanel other)
|
||||
{
|
||||
super(other);
|
||||
this.title = other.title;
|
||||
this.subtitle = other.subtitle;
|
||||
this.buttons = other.buttons;
|
||||
this.real_title = other.title;
|
||||
this.real_subtitle = other.subtitle;
|
||||
|
||||
} // end constructor
|
||||
|
||||
private boolean displayButtons()
|
||||
{
|
||||
if (buttons.size()==0)
|
||||
return false;
|
||||
else if (logged_in)
|
||||
return true;
|
||||
|
||||
boolean login_only = true;
|
||||
Enumeration enum = buttons.elements();
|
||||
while (login_only && enum.hasMoreElements())
|
||||
{ // attempt to determine if there are any non-"login only" buttons
|
||||
TCButton bn = (TCButton)(enum.nextElement());
|
||||
login_only = bn.isLoginOnly();
|
||||
|
||||
} // end while
|
||||
|
||||
return !login_only;
|
||||
|
||||
} // end displayButtons
|
||||
|
||||
protected void addButton(String image, String alt_text, String url, boolean login_only, int width,
|
||||
int height)
|
||||
{
|
||||
buttons.addElement(new TCButton(image,alt_text,url,login_only,width,height));
|
||||
|
||||
} // end addButton
|
||||
|
||||
protected abstract void renderContent(Writer out, RenderData rdat) throws IOException;
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
rdat.writeContentHeader(out,real_title,real_subtitle);
|
||||
|
||||
if (displayButtons())
|
||||
{ // want to print the buttons
|
||||
out.write("<DIV ALIGN=\"LEFT\">\n");
|
||||
Enumeration enum = buttons.elements();
|
||||
|
||||
boolean first_post = true;
|
||||
while (enum.hasMoreElements())
|
||||
{ // figure out whether to display this button
|
||||
TCButton bn = (TCButton)(enum.nextElement());
|
||||
boolean display_me = logged_in;
|
||||
if (logged_in)
|
||||
display_me = true;
|
||||
else
|
||||
display_me = !(bn.isLoginOnly());
|
||||
|
||||
if (display_me)
|
||||
{ // display this button
|
||||
if (first_post)
|
||||
first_post = false;
|
||||
else
|
||||
out.write(" ");
|
||||
bn.renderHere(out,rdat);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end while
|
||||
|
||||
out.write("\n</DIV>\n");
|
||||
|
||||
} // end if
|
||||
|
||||
renderContent(out,rdat);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
public void configure(UserContext uc, String parameter) throws DataException
|
||||
{
|
||||
logged_in = uc.isLoggedIn();
|
||||
|
||||
} // end configure
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.real_title = title;
|
||||
|
||||
} // end setTitle
|
||||
|
||||
public void setSubtitle(String title)
|
||||
{
|
||||
this.real_subtitle = subtitle;
|
||||
|
||||
} // end setTitle
|
||||
|
||||
} // end class TCPanelSIGs
|
||||
113
src/com/silverwrist/venice/servlets/format/TopContent.java
Normal file
113
src/com/silverwrist/venice/servlets/format/TopContent.java
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class TopContent implements ContentRender
|
||||
{
|
||||
// Static constants
|
||||
public static final int MAX_COLS = 2;
|
||||
|
||||
// Attributes
|
||||
private int actual_cols = MAX_COLS;
|
||||
private int[] col_sizes;
|
||||
private Vector panels = new Vector();
|
||||
private boolean display_configure;
|
||||
|
||||
public TopContent(UserContext uc) throws DataException
|
||||
{
|
||||
int i; // loop counter
|
||||
|
||||
// get the current view configuration
|
||||
FrontPageViewConfig vconfig = uc.getFrontPageViewConfig(MAX_COLS);
|
||||
if (vconfig.getNumColumns()<MAX_COLS)
|
||||
actual_cols = vconfig.getNumColumns();
|
||||
|
||||
// compute the column sizes in percentages
|
||||
col_sizes = new int[actual_cols];
|
||||
int base_amt = 100 / actual_cols;
|
||||
int rem_amt = 100 % actual_cols;
|
||||
for (i=0; i<actual_cols; i++)
|
||||
{ // initialize the column sizes
|
||||
col_sizes[i] = base_amt;
|
||||
if (i<rem_amt)
|
||||
col_sizes[i]++;
|
||||
|
||||
} // end for
|
||||
|
||||
// load the top content
|
||||
TopContentPanel parray[];
|
||||
for (i=0; i<vconfig.getNumRows(); i++)
|
||||
{ // create array and load it with panels
|
||||
parray = new TopContentPanel[actual_cols];
|
||||
for (int j=0; j<actual_cols; j++)
|
||||
{ // create and configure the parts in this row
|
||||
parray[j] = TopContentPanel.create(vconfig.getPartID(i,j));
|
||||
parray[j].configure(uc,vconfig.getParameter(i,j));
|
||||
|
||||
} // end for
|
||||
|
||||
panels.addElement(parray);
|
||||
|
||||
} // end for
|
||||
|
||||
display_configure = uc.isLoggedIn();
|
||||
|
||||
} // end constructor
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<TABLE BORDER=0 ALIGN=CENTER WIDTH=\"100%\" CELLPADDING=4 CELLSPACING=0>\n");
|
||||
|
||||
Enumeration enum = panels.elements();
|
||||
while (enum.hasMoreElements())
|
||||
{ // output each row in turn
|
||||
TopContentPanel[] rowarray = (TopContentPanel[])(enum.nextElement());
|
||||
out.write("<TR VALIGN=TOP>\n");
|
||||
|
||||
for (int i=0; i<actual_cols; i++)
|
||||
{ // write the table data header and then render the content
|
||||
out.write("<TD ALIGN=LEFT WIDTH=\"" + String.valueOf(col_sizes[i]) + "%\">\n");
|
||||
rowarray[i].renderHere(out,rdat);
|
||||
out.write("</TD>\n");
|
||||
|
||||
} // end for
|
||||
|
||||
out.write("</TR>\n");
|
||||
|
||||
} // end while
|
||||
|
||||
out.write("</TABLE>\n");
|
||||
|
||||
if (display_configure)
|
||||
{ // display the Configure button
|
||||
out.write("<HR WIDTH=\"80%\"><DIV ALIGN=\"LEFT\">\n<A HREF=\"\"><IMG SRC=\"");
|
||||
out.write(rdat.getFullImagePath("bn_configure.gif"));
|
||||
out.write("\" ALT=\"Configure\" WIDTH=80 HEIGHT=24 BORDER=0></A>\n</DIV>\n");
|
||||
|
||||
} // end if
|
||||
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} /* end renderHere */
|
||||
|
||||
} // end class TopContent
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.venice.core.UserContext;
|
||||
import com.silverwrist.venice.core.DataException;
|
||||
|
||||
public abstract class TopContentPanel implements ContentRender, Cloneable
|
||||
{
|
||||
protected TopContentPanel()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
protected TopContentPanel(TopContentPanel other)
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
public abstract void renderHere(Writer out, RenderData rdat) throws IOException;
|
||||
|
||||
public abstract void configure(UserContext uc, String parameter) throws DataException;
|
||||
|
||||
public static TopContentPanel create(String partid)
|
||||
{
|
||||
if (partid.equals("SIGS"))
|
||||
return new TCPanelSIGs();
|
||||
if (partid.equals("CONF"))
|
||||
return new TCPanelConferences();
|
||||
return null;
|
||||
|
||||
} // end create
|
||||
|
||||
} // end class TopContentPanel
|
||||
|
||||
138
src/com/silverwrist/venice/servlets/format/UserProfileData.java
Normal file
138
src/com/silverwrist/venice/servlets/format/UserProfileData.java
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.UserProfile;
|
||||
|
||||
public class UserProfileData implements JSPRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Attribute name for request attribute
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.content.UserProfileData";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private UserProfile prof;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public UserProfileData(UserProfile prof)
|
||||
{
|
||||
this.prof = prof;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static UserProfileData retrieve(ServletRequest request)
|
||||
{
|
||||
return (UserProfileData)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface JSPRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void store(ServletRequest request)
|
||||
{
|
||||
request.setAttribute(ATTR_NAME,this);
|
||||
|
||||
} // end store
|
||||
|
||||
public String getTargetJSPName()
|
||||
{
|
||||
return "userprofile.jsp";
|
||||
|
||||
} // end getTargetJSPName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public UserProfile getUserProfile()
|
||||
{
|
||||
return prof;
|
||||
|
||||
} // end getUserProfile
|
||||
|
||||
public String getAddressLastLine()
|
||||
{
|
||||
String tmp_c = prof.getLocality();
|
||||
String tmp_s = prof.getRegion();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
if (!(StringUtil.isStringEmpty(tmp_c)) && !(StringUtil.isStringEmpty(tmp_s)))
|
||||
buf.append(tmp_c).append(", ").append(tmp_s);
|
||||
else if (!(StringUtil.isStringEmpty(tmp_c)))
|
||||
buf.append(tmp_c);
|
||||
else if (!(StringUtil.isStringEmpty(tmp_s)))
|
||||
buf.append(tmp_s);
|
||||
tmp_s = prof.getPostalCode();
|
||||
if (!(StringUtil.isStringEmpty(tmp_s)))
|
||||
buf.append(' ').append(tmp_s);
|
||||
return buf.toString();
|
||||
|
||||
} // end getAddressLastLine
|
||||
|
||||
public String getFullName()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer(prof.getGivenName());
|
||||
String tmp = prof.getNamePrefix();
|
||||
if (!(StringUtil.isStringEmpty(tmp)))
|
||||
{ // insert prefix at beginning
|
||||
buf.insert(0,' ');
|
||||
buf.insert(0,tmp);
|
||||
|
||||
} // end if
|
||||
if (prof.getMiddleInitial()!=' ')
|
||||
buf.append(' ').append(prof.getMiddleInitial()).append('.');
|
||||
buf.append(' ').append(prof.getFamilyName());
|
||||
tmp = prof.getNameSuffix();
|
||||
if (!(StringUtil.isStringEmpty(tmp)))
|
||||
buf.append(' ').append(tmp);
|
||||
return buf.toString();
|
||||
|
||||
} // end getFullName
|
||||
|
||||
public String getPhotoURL(RenderData rdat)
|
||||
{
|
||||
String tmp = prof.getPhotoURL();
|
||||
if (StringUtil.isStringEmpty(tmp))
|
||||
tmp = rdat.getFullImagePath("photo_not_avail.gif");
|
||||
return tmp;
|
||||
|
||||
} // end getPhotoURL
|
||||
|
||||
} // end class UserProfileData
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.IDUtils;
|
||||
|
||||
public class VerifyEmailDialog extends ContentDialog
|
||||
{
|
||||
int confirm_num = 0;
|
||||
|
||||
public VerifyEmailDialog()
|
||||
{
|
||||
super("Verify E-mail Address",null,"verifyform","account");
|
||||
setInstructions("Check your e-mail, then enter the confirmation number that was e-mailed to you "
|
||||
+ "in the field below. Once you do so, your account will be fully validated. "
|
||||
+ "If you have not received your confirmation, click on the 'Send Again' button "
|
||||
+ "below.");
|
||||
setHiddenField("cmd","V");
|
||||
setHiddenField("tgt","");
|
||||
addFormField(new CDTextFormField("num","Confirmation number",null,false,7,7));
|
||||
addCommandButton(new CDImageButton("ok","bn_ok.gif","OK",80,24));
|
||||
addCommandButton(new CDImageButton("again","bn_send_again.gif","Send Again",80,24));
|
||||
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected VerifyEmailDialog(VerifyEmailDialog other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void validateWholeForm() throws ValidationException
|
||||
{
|
||||
try
|
||||
{ // convert to a number and check its range
|
||||
int num = Integer.parseInt(getFieldValue("num"));
|
||||
|
||||
if (!IDUtils.isValidConfirmationNumber(num))
|
||||
throw new ValidationException("The value you have entered is not a valid confirmation number.");
|
||||
|
||||
confirm_num = num; // save off for later
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException e)
|
||||
{ // conversion error!
|
||||
throw new ValidationException("The value you have entered is not a valid number.");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end validateWholeForm
|
||||
|
||||
public void setTarget(String target)
|
||||
{
|
||||
setHiddenField("tgt",target);
|
||||
|
||||
} // end setTarget
|
||||
|
||||
public int getConfirmationNumber()
|
||||
{
|
||||
return confirm_num;
|
||||
|
||||
} // end getConfirmationNumber
|
||||
|
||||
public void resetOnError(String message)
|
||||
{
|
||||
setErrorMessage(message);
|
||||
setFieldValue("num",null);
|
||||
|
||||
} // end resetOnError
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new VerifyEmailDialog(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class VerifyEmailDialog
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user