Merge of the NewUI changes into the trunk

This commit is contained in:
Eric J. Bowersox
2002-01-07 02:05:37 +00:00
parent b86ef1c3b0
commit c3e2870572
516 changed files with 32853 additions and 26097 deletions

View File

@@ -1,535 +0,0 @@
/*
* 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.net.URLEncoder;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class Account extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static final String DISPLAY_LOGIN_ATTR = "com.silverwrist.venice.servlets.internal.DisplayLogin";
private static final int COOKIE_LIFETIME = 60*60*24*365; // one year
private static Category logger = Category.getInstance(Account.class);
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private void setDisplayLogins(ServletRequest request)
{
request.setAttribute(DISPLAY_LOGIN_ATTR,new Integer(0));
} // end setDisplayLogins
private NewAccountDialog makeNewAccountDialog() throws ServletException
{
final String desired_name = "NewAccountDialog";
DialogCache cache = DialogCache.getDialogCache(getServletContext());
if (!(cache.isCached(desired_name)))
{ // create a template and save it off
NewAccountDialog template = new NewAccountDialog();
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();
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
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected String getMyLocation(HttpServletRequest request, VeniceEngine engine, UserContext user,
RenderData rdat)
{
String rc = super.getMyLocation(request,engine,user,rdat);
if (rc!=null)
return rc;
if (request.getAttribute(DISPLAY_LOGIN_ATTR)!=null)
return "account?cmd=" + getStandardCommandParam(request);
else
return null;
} // end getMyLocation
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
String tgt = request.getParameter("tgt"); // target location
if (tgt==null)
tgt = "top"; // go back to the Top screen if nothing else
String cmd = getStandardCommandParam(request);
if (cmd.equals("L"))
{ // "L" = Log In/Out
if (user.isLoggedIn())
{ // this is a Logout command
clearUserContext(request);
// delete the "login" cookie
Cookie del_login_info = rdat.createCookie(Variables.LOGIN_COOKIE,"",0);
Variables.saveCookie(request,del_login_info);
throw new RedirectResult("top"); // take 'em back to the "top" page
} // end if
// this is a Login command - display the Login page
LoginDialog dlg = makeLoginDialog();
dlg.setupNew(tgt);
setMyLocation(request,tgt); // fake out the location so we can display the "Log In/Create Account" links
return dlg;
} // end if ("L" command)
if (cmd.equals("C"))
{ // "C" = create new account
if (user.isLoggedIn()) // you can't create a new account while logged in on an existing one!
return new ErrorBox("Error","You cannot create a new account while logged in on an existing "
+ "one. You must log out first.",tgt);
final String yes = "yes";
if (yes.equals(request.getParameter("agree")))
{ // display the "Create Account" dialog
NewAccountDialog dlg = makeNewAccountDialog();
dlg.setEngine(engine);
dlg.setTarget(tgt);
dlg.setFieldValue("country","US");
return dlg;
} // end if
else
{ // display the account terms dialog
String[] choices = new String[2];
choices[0] = "account?cmd=C&agree=yes&tgt=" + URLEncoder.encode(tgt);
choices[1] = "top";
return new TextMessageDialog(TextMessageDialog.TYPE_ACCEPT_DECLINE,
rdat.getStockMessage("user-agreement-title"),
rdat.getStockMessage("user-agreement-subtitle"),
rdat.getStockMessage("user-agreement"),choices);
} // end else
} // end if ("C" command)
if (cmd.equals("P"))
{ // "P" = user profile
if (!(user.isLoggedIn())) // you have to be logged in for this one!
return new ErrorBox("Error","You must log in before you can modify the profile "
+ "on your account.",tgt);
// set up the Edit Profile dialog
EditProfileDialog dlg = makeEditProfileDialog();
try
{ /// set up the profile information for the dialog
dlg.setupDialog(user,tgt);
} // end try
catch (DataException e)
{ // unable to load the contact info for the profile
return new ErrorBox("Database Error","Database error retrieving profile: " + e.getMessage(),tgt);
} // end catch
return dlg; // display dialog
} // end if ("P" command)
if (cmd.equals("V"))
{ // "V" = verify email address
setDisplayLogins(request);
if (!(user.isLoggedIn())) // you have to be logged in for this one!
return new ErrorBox("Error","You must log in before you can verify your account's "
+ "email address.",tgt);
// display the "verify email" dialog
VerifyEmailDialog dlg = makeVerifyEmailDialog();
dlg.setTarget(tgt);
return dlg;
} // end if ("V" command)
// command not found!
logger.error("invalid command to Account.doGet: " + cmd);
return new ErrorBox("Internal Error","Invalid command to Account.doGet",tgt);
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
changeMenuTop(request); // this is "top" menus
String tgt = request.getParameter("tgt"); // target location
if (tgt==null)
tgt = "top"; // go back to the Top screen if nothing else
String cmd = getStandardCommandParam(request);
if (cmd.equals("L"))
{ // "L" = login the user
LoginDialog dlg = makeLoginDialog();
if (dlg.isButtonClicked(request,"cancel"))
throw new RedirectResult(tgt); // we decided not to log in - go back where we came from
if (dlg.isButtonClicked(request,"remind"))
{ // this will email a password reminder to the owner's account
dlg.loadValues(request); // load the dialog values
try
{ // send the password reminder
engine.sendPasswordReminder(dlg.getFieldValue("user"));
// recycle and redisplay the dialog box
dlg.resetOnError("Password reminder has been sent to your e-mail address.");
} // end try
catch (DataException de)
{ // there was a database error finding your email address
return new ErrorBox("Database Error","Database error finding user: " + de.getMessage(),tgt);
} // end catch
catch (AccessError ae)
{ // this indicates a problem with the user account or password
return new ErrorBox("User E-mail Address Not Found",ae.getMessage(),tgt);
} // end catch
catch (EmailException ee)
{ // error sending the confirmation email
return new ErrorBox("E-mail Error","E-mail error sending reminder: " + ee.getMessage(),tgt);
} // end catch
setMyLocation(request,tgt); // fake out the location
return dlg; // redisplay the dialog
} // end if ("remind" button clicked)
if (dlg.isButtonClicked(request,"login"))
{ // we actually want to try and log in! imagine that!
dlg.loadValues(request); // load the values
try
{ // use the user context to authenticate
user.authenticate(dlg.getFieldValue("user"),dlg.getFieldValue("pass"));
// If they want a cookie, give it to them!
final String yes = "Y";
if (yes.equals(dlg.getFieldValue("saveme")))
{ // create the authentication cookie and save it
Cookie auth_cookie = rdat.createCookie(Variables.LOGIN_COOKIE,user.getAuthenticationToken(),
COOKIE_LIFETIME);
Variables.saveCookie(request,auth_cookie);
} // end if
// assuming it worked OK, redirect them back where they came from
// (or to the verification page if they need to go there)
clearMenu(request);
if (user.isEmailVerified())
throw new RedirectResult(tgt);
else // they haven't verified yet - remind them to do so
throw new RedirectResult("account?cmd=V&tgt=" + URLEncoder.encode(tgt));
} // end try
catch (DataException de)
{ // this indicates a database error - display an ErrorBox
return new ErrorBox("Database Error","Database error logging in: " + de.getMessage(),tgt);
} // end catch
catch (AccessError ae)
{ // this indicates a problem with the user account or password
dlg.resetOnError(ae.getMessage());
} // end catch
setMyLocation(request,tgt); // fake out the location
return dlg; // go back and redisplay the dialog
} // end if ("login" button clicked)
// the button must be wrong!
logger.error("no known button click on Account.doPost, cmd=L");
return new ErrorBox("Internal Error","Unknown command button pressed",tgt);
} // end if ("L" command)
if (cmd.equals("C"))
{ // "C" = Create New Account
NewAccountDialog dlg = makeNewAccountDialog();
dlg.setEngine(engine);
if (dlg.isButtonClicked(request,"cancel"))
throw new RedirectResult(tgt); // we decided not to create account - go back where we came from
if (dlg.isButtonClicked(request,"create"))
{ // OK, actually want to create the account!
dlg.loadValues(request); // load field values
try
{ // attempt to create the account
UserContext uc = dlg.doDialog(request);
putUserContext(request,uc); // effectively logging in the new user
// now jump to the Verify page
throw new RedirectResult("account?cmd=V&tgt=" + URLEncoder.encode(tgt));
} // end try
catch (ValidationException ve)
{ // unable to validate some of the data in the form
dlg.resetOnError(ve.getMessage() + " Please try again.");
} // end catch
catch (DataException de)
{ // data error in setting up account
return new ErrorBox("Database Error","Database error creating account: " + de.getMessage(),tgt);
} // end catch
catch (AccessError ae)
{ // access error in setting up the account
dlg.resetOnError(ae.getMessage());
} // end catch
catch (EmailException ee)
{ // error sending the confirmation email
return new ErrorBox("E-mail Error","E-mail error creating account: " + ee.getMessage(),tgt);
} // end catch
return dlg; // redisplay me
} // end if ("create" button pressed)
// the button must be wrong!
logger.error("no known button click on Account.doPost, cmd=C");
return new ErrorBox("Internal Error","Unknown command button pressed",tgt);
} // end if ("C" command)
if (cmd.equals("V"))
{ // "V" = Verify E-mail Address
setDisplayLogins(request);
VerifyEmailDialog dlg = makeVerifyEmailDialog();
if (dlg.isButtonClicked(request,"cancel"))
throw new RedirectResult(tgt); // we decided not to bother - go back where we came from
if (dlg.isButtonClicked(request,"again"))
{ // send the confirmation message again
try
{ // resend the email confirmation
user.resendEmailConfirmation();
// now force the form to be redisplayed
dlg.clearAllFields();
dlg.setTarget(tgt);
} // end try
catch (DataException de)
{ // database error resending confirmation
return new ErrorBox("Database Error","Database error sending confirmation: " + de.getMessage(),tgt);
} // end catch
catch (EmailException ee)
{ // error sending the confirmation email
return new ErrorBox("E-mail Error","E-mail error sending confirmation: " + ee.getMessage(),tgt);
} // end catch
return dlg; // redisplay the dialog
} // end if ("again" button clicked)
if (dlg.isButtonClicked(request,"ok"))
{ // try to verify the confirmation number
dlg.loadValues(request); // load field values
try
{ // validate that we have a good number
dlg.validate();
user.confirmEmail(dlg.getConfirmationNumber());
// go back to our desired location
throw new RedirectResult(tgt);
} // end try
catch (ValidationException ve)
{ // there was a validation error...
dlg.resetOnError(ve.getMessage() + " Please try again.");
} // end catch
catch (DataException de)
{ // data error in confirming account
return new ErrorBox("Database Error","Database error verifying email: " + de.getMessage(),tgt);
} // end catch
catch (AccessError ae)
{ // invalid confirmation number, perhaps?
dlg.resetOnError(ae.getMessage());
} // end catch
return dlg; // redisplay the dialog
} // end if ("ok" button clicked)
// the button must be wrong!
logger.error("no known button click on Account.doPost, cmd=V");
return new ErrorBox("Internal Error","Unknown command button pressed",tgt);
} // end if ("V" command)
if (cmd.equals("P"))
{ // "P" = Edit User Profile
setDisplayLogins(request);
EditProfileDialog dlg = makeEditProfileDialog();
if (dlg.isButtonClicked(request,"cancel"))
throw new RedirectResult(tgt); // we decided not to bother - go back where we came from
if (dlg.isButtonClicked(request,"update"))
{ // we're ready to update the user profile
dlg.loadValues(request); // load field values
boolean photo_flag = true;
try
{ // validate the dialog and reset profile info
photo_flag = user.canSetUserPhoto();
if (dlg.doDialog(user)) // need to reconfirm email address
throw new RedirectResult("account?cmd=V&tgt=" + URLEncoder.encode(tgt));
else
throw new RedirectResult(tgt); // just go straight on back
} // end try
catch (ValidationException ve)
{ // there was a validation error...
dlg.resetOnError(photo_flag,ve.getMessage() + " Please try again.");
} // end catch
catch (DataException de)
{ // data error in changing profile
return new ErrorBox("Database Error","Database error updating profile: " + de.getMessage(),tgt);
} // end catch
catch (EmailException ee)
{ // error sending the confirmation email
return new ErrorBox("E-mail Error","E-mail error sending confirmation: " + ee.getMessage(),tgt);
} // end catch
return dlg; // redisplay dialog
} // end if ("update" button clicked)
// the button must be wrong!
logger.error("no known button click on Account.doPost, cmd=P");
return new ErrorBox("Internal Error","Unknown command button pressed",tgt);
} // end if
// unknown command
logger.error("invalid command to Account.doPost: " + cmd);
return new ErrorBox("Internal Error","Invalid command to Account.doPost",tgt);
} // end doVenicePost
} // end class Account

View File

@@ -1,203 +0,0 @@
/*
* 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.util.ServletMultipartHandler;
import com.silverwrist.util.ServletMultipartException;
import com.silverwrist.util.image.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class AdminUserPhoto extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(AdminUserPhoto.class);
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "AdminUserPhoto servlet - changes the user photo for a user\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
try
{ // get the user to be modified
AdminOperations adm = user.getAdminInterface();
String s_uid = request.getParameter("uid");
if (s_uid==null)
throw new ErrorBox(null,"User ID parameter not found.","sysadmin?cmd=UF");
AdminUserContext admuser = adm.getUserContext(Integer.parseInt(s_uid));
if (request.getParameter("null")!=null)
{ // null the photo out and return
ContactInfo ci = admuser.getContactInfo();
ci.setPhotoURL(null);
admuser.putContactInfo(ci);
throw new RedirectResult("sysadmin?cmd=UM&uid=" + admuser.getUID());
} // end if
return new AdminUserPhotoData(engine,admuser,rdat);
} // end try
catch (AccessError ae)
{ // an access error generally means we're not an administrator
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
} // end catch
catch (DataException de)
{ // error pulling the audit records
return new ErrorBox("Database Error","Unable to retrieve user information: " + de.getMessage(),
"sysadmin?cmd=UF");
} // end catch
catch (NumberFormatException nfe)
{ // this is if we get a bogus UID
return new ErrorBox(null,"Invalid user ID parameter.","sysadmin?cmd=UF");
} // end catch
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, ServletMultipartHandler mphandler,
VeniceEngine engine, UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
AdminUserContext admuser;
try
{ // get the user to be modified
AdminOperations adm = user.getAdminInterface();
String s_uid = mphandler.getValue("uid");
if (s_uid==null)
throw new ErrorBox(null,"User ID parameter not found.","sysadmin?cmd=UF");
admuser = adm.getUserContext(Integer.parseInt(s_uid));
} // end try
catch (AccessError ae)
{ // an access error generally means we're not an administrator
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
} // end catch
catch (DataException de)
{ // error pulling the audit records
return new ErrorBox("Database Error","Unable to retrieve user information: " + de.getMessage(),
"sysadmin?cmd=UF");
} // end catch
catch (NumberFormatException nfe)
{ // this is if we get a bogus UID
return new ErrorBox(null,"Invalid user ID parameter.","sysadmin?cmd=UF");
} // end catch
if (isImageButtonClicked(mphandler,"cancel"))
throw new RedirectResult("sysadmin?cmd=UM&uid=" + admuser.getUID());
if (isImageButtonClicked(mphandler,"upload"))
{ // uploading the image here!
// also check on file parameter status
if (!(mphandler.isFileParam("thepic")))
{ // bogus file parameter
logger.error("Internal Error: 'thepic' should be a file param");
return new ErrorBox(null,"Internal Error: 'thepic' should be a file param",
"sysadmin?cmd=UM&uid=" + admuser.getUID());
} // end if
if (!(mphandler.getContentType("thepic").startsWith("image/")))
{ // must be an image type we uploaded!
logger.error("Error: 'thepic' not an image type");
return new ErrorBox(null,"You did not upload an image file. Try again.",
"sysadmin?cmd=UM&uid=" + admuser.getUID());
} // end if
try
{ // get the real picture (normalized to 100x100 size)
ImageLengthPair real_pic = ImageNormalizer.normalizeImage(mphandler.getFileContentStream("thepic"),
engine.getUserPhotoSize(),"jpeg");
// set the user photo data!
ContactInfo ci = admuser.getContactInfo();
ci.setPhotoData(request.getContextPath() + "/imagedata/","image/jpeg",real_pic.getLength(),
real_pic.getData());
admuser.putContactInfo(ci);
// Jump back to the profile form.
throw new RedirectResult("sysadmin?cmd=UM&uid=" + admuser.getUID());
} // end try
catch (ServletMultipartException smpe)
{ // the servlet multipart parser screwed up
logger.error("Servlet multipart error:",smpe);
return new ErrorBox(null,"Internal Error: " + smpe.getMessage(),
"sysadmin?cmd=UM&uid=" + admuser.getUID());
} // end catch
catch (ImageNormalizerException ine)
{ // the image was not valid
logger.error("Image normalizer error:",ine);
return new ErrorBox(null,ine.getMessage(),"admuserphoto?uid=" + admuser.getUID());
} // end catch
catch (DataException de)
{ // error in the database!
logger.error("DataException:",de);
return new ErrorBox("Database Error","Database error storing user photo: " + de.getMessage(),
"sysadmin?cmd=UM&uid=" + admuser.getUID());
} // end catch
} // end if
else
{ // the button must be wrong!
logger.error("no known button click on AdminUserPhoto.doPost");
return new ErrorBox("Internal Error","Unknown command button pressed",
"sysadmin?cmd=UM&uid=" + admuser.getUID());
} // end else
} // end doVenicePost
} // end class AdminUserPhoto

View File

@@ -1,175 +0,0 @@
/*
* 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.ServletMultipartHandler;
import com.silverwrist.util.ServletMultipartException;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class Attachment extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(Attachment.class);
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "Attachment servlet - Handles uploading and downloading attachments\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// get the community
CommunityContext comm = getCommunityParameter(request,user,true,"top");
changeMenuCommunity(request,comm);
// get the conference
ConferenceContext conf = getConferenceParameter(request,comm,true,"top");
// get the message we want to use
TopicMessageContext msg = getMessageParameter(request,conf,true,"top");
String type, filename;
int length;
InputStream data;
try
{ // retrieve the information about the attachment
type = msg.getAttachmentType();
filename = msg.getAttachmentFilename();
length = msg.getAttachmentLength();
if (logger.isInfoEnabled())
logger.info("Uploaded file: " + filename + "(type " + type + ", " + length + " bytes)");
data = msg.getAttachmentData();
} // end try
catch (AccessError ae)
{ // unable to access the data stream
return new ErrorBox("Access Error",ae.getMessage(),"top");
} // end catch
catch (DataException de)
{ // error getting at the data stream from the attachment
return new ErrorBox("Database Error","Database error retrieving attachment: " + de.getMessage(),"top");
} // end catch
// now we want to send that data back to the user!
throw new SendFileResult(type,filename,length,data);
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, ServletMultipartHandler mphandler,
VeniceEngine engine, UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
logger.debug("Attachment.doVenicePost: entry");
// Get target URL for the operation
if (mphandler.isFileParam("target"))
{ // bogus target URL
logger.error("Internal Error: 'target' should be a normal param");
return new ErrorBox(null,"Internal Error: 'target' should be a normal param","top");
} // end if
String target = mphandler.getValue("target");
if (logger.isDebugEnabled())
logger.debug("Target URL: " + target);
setMyLocation(request,target);
// also check on file parameter status
if (!(mphandler.isFileParam("thefile")))
{ // bogus file parameter
logger.error("Internal Error: 'thefile' should be a file param");
return new ErrorBox(null,"Internal Error: 'thefile' should be a file param",target);
} // end if
// get the community
CommunityContext comm = getCommunityParameter(mphandler,user,true,"top");
if (logger.isDebugEnabled())
logger.debug("community param: #" + comm.getCommunityID());
changeMenuCommunity(request,comm);
// get the conference
ConferenceContext conf = getConferenceParameter(mphandler,comm,true,"top");
if (logger.isDebugEnabled())
logger.debug("Conference param: #" + conf.getConfID());
// get the message we want to use
TopicMessageContext msg = getMessageParameter(mphandler,conf,true,"top");
if (logger.isDebugEnabled())
logger.debug("Message param: #" + msg.getPostID());
try
{ // attach the data to the message!
msg.attachData(mphandler.getContentType("thefile"),mphandler.getValue("thefile"),
mphandler.getContentSize("thefile"),mphandler.getFileContentStream("thefile"));
} // end try
catch (ServletMultipartException smpe)
{ // error processing the file parameter data
logger.error("Servlet multipart error:",smpe);
return new ErrorBox(null,"Internal Error: " + smpe.getMessage(),target);
} // end catch
catch (AccessError ae)
{ // access error posting the attachment data
logger.error("Access error:",ae);
return new ErrorBox("Access Error",ae.getMessage(),target);
} // end catch
catch (DataException de)
{ // error storing the attachment in the database
logger.error("DataException:",de);
return new ErrorBox("Database Error","Database error storing attachment: " + de.getMessage(),target);
} // end catch
logger.debug("Attachment.doVenicePost: done!");
throw new RedirectResult(target); // get back, get back, get back to where you once belonged
} // end doVenicePost
} // end class Attachment

View File

@@ -1,649 +0,0 @@
/*
* 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.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class CommunityAdmin extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static final String DELETE_CONFIRM_ATTR = "servlets.CommunityAdmin.delete.confirm";
private static final String DELETE_CONFIRM_PARAM = "confirm";
private static Category logger = Category.getInstance(CommunityAdmin.class);
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private CommunityAdminTop makeCommunityAdminTop() throws ServletException
{
final String desired_name = "CommunityAdminTop";
MenuPanelCache cache = MenuPanelCache.getMenuPanelCache(getServletContext());
if (!(cache.isCached(desired_name)))
{ // create a template and save it off
CommunityAdminTop template = new CommunityAdminTop();
cache.saveTemplate(template);
} // end if
// return a new copy
return (CommunityAdminTop)(cache.getNewMenuPanel(desired_name));
} // end makeCommunityAdminTop
private EditCommunityProfileDialog makeEditCommunityProfileDialog(SecurityInfo sinf) throws ServletException
{
final String desired_name = "EditCommunityProfileDialog";
DialogCache cache = DialogCache.getDialogCache(getServletContext());
if (!(cache.isCached(desired_name)))
{ // create a template and save it off
EditCommunityProfileDialog template = new EditCommunityProfileDialog(sinf);
cache.saveTemplate(template);
} // end if
// return a new copy
return (EditCommunityProfileDialog)(cache.getNewDialog(desired_name));
} // end makeEditCommunityProfileDialog
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "CommunityAdmin servlet - Administrative functions for communities\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
/* Command values for CommunityAdmin:
* A = Display Audit Records
* DEL = Delete Community
* F = Set Features/Services (not implemented yet)
* I = E-Mail to All Members
* M = Membership Control
* P = Edit Profile
* T = Set Category
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// get the community context
CommunityContext comm = getCommunityParameter(request,user,true,"top");
changeMenuCommunity(request,comm);
setMyLocation(request,"sigadmin?" + request.getQueryString());
String on_error = "sigadmin?sig=" + comm.getCommunityID();
if (logger.isDebugEnabled())
logger.debug("CommunityAdmin/doGet operating on community \"" + comm.getName() + "\" ("
+ comm.getCommunityID() + ")");
// now decide what to do based on the "cmd" parameter
String cmd = getStandardCommandParam(request);
if (logger.isDebugEnabled())
logger.debug("CommunityAdmin/doGet command value = " + cmd);
if (cmd.equals("P"))
{ // "P" = "Edit Profile"
if (!(comm.canModifyProfile()))
{ // no access - sorry, dude
logger.error("tried to call up community profile screen without access...naughty naughty!");
return new ErrorBox("Unauthorized","You do not have access to modify this community's profile.",
on_error);
} // end if
// construct the edit profile dialog and load it up for use
EditCommunityProfileDialog dlg = makeEditCommunityProfileDialog(comm.getSecurityInfo());
try
{ // load the values for this dialog
dlg.setupDialog(engine,comm);
} // end try
catch (DataException de)
{ // we could not load the values because of a data exception
logger.error("DB error loading community profile: " + de.getMessage(),de);
return new ErrorBox("Database Error","Database error retrieving profile: " + de.getMessage(),on_error);
} // end catch
catch (AccessError ae)
{ // we don't have enough privilege
logger.error("Access error loading community profile: " + ae.getMessage(),ae);
return new ErrorBox("Unauthorized","You do not have access to modify this community's profile.",
on_error);
} // end catch
return dlg; // display me!
} // end if ("P" command)
if (cmd.equals("T"))
{ // "T" = "Set Category"
if (!(comm.canModifyProfile()))
{ // no access - sorry man
logger.error("tried to call up community category set screen without access...naughty naughty!");
return new ErrorBox("Unauthorized","You do not have access to modify this community's profile.",
on_error);
} // end else
// did they actually send a "set" parameter?
String p = request.getParameter("set");
if (!(StringUtil.isStringEmpty(p)))
{ // OK, we're setting the category ID...
try
{ // get the new category ID and set it
int catid = Integer.parseInt(p);
if (!(engine.isValidCategoryID(catid)))
throw new NumberFormatException(); // dump the category if it's not valid
// change the category ID
comm.setCategoryID(catid);
} // end try
catch (NumberFormatException nfe)
{ // we got an invalid category value...
return new ErrorBox("Invalid Input","Invalid category ID passed to category browser.",on_error);
} // end catch
catch (DataException de)
{ // unable to update the community properly
logger.error("DB error updating community: " + de.getMessage(),de);
return new ErrorBox("Database Error","Database error updating community: " + de.getMessage(),
on_error);
} // end catch
catch (AccessError ae)
{ // database access error - display an error box
logger.error("Access error updating community: " + ae.getMessage(),ae);
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
// now that it's set, go back to the admin menu
throw new RedirectResult(on_error);
} // end if (setting category ID)
else
{ // we're browsing - try and figure out what to display
try
{ // get the "go" parameter to see what the current category ID is
p = request.getParameter("go");
int curr_catid;
if (StringUtil.isStringEmpty(p))
curr_catid = comm.getCategoryID();
else
curr_catid = Integer.parseInt(p);
if (!(engine.isValidCategoryID(curr_catid)))
throw new NumberFormatException(); // dump the category if it's not valid
// create the browser panel and let it rip
return new CommunityCategoryBrowseData(user,comm,curr_catid);
} // end try
catch (NumberFormatException nfe)
{ // we got an invalid category value...
return new ErrorBox("Invalid Input","Invalid category ID passed to category browser.",on_error);
} // end catch
catch (DataException de)
{ // unable to get the categories properly
logger.error("DB error browsing categories: " + de.getMessage(),de);
return new ErrorBox("Database Error","Database error browsing categories: " + de.getMessage(),
on_error);
} // end catch
} // end else
} // end if ("T" command)
if (cmd.equals("M"))
{ // "M" = Set Membership
if (!(comm.canModifyProfile()))
{ // no access - sorry man
logger.error("tried to call up membership set screen without access...naughty naughty!");
return new ErrorBox("Unauthorized","You do not have access to modify this community's membership.",
on_error);
} // end else
try
{ // display the conference member list!
CommunityMembership m = new CommunityMembership(engine,comm);
m.doCommunityMemberList();
setMyLocation(request,"sigadmin?sig=" + comm.getCommunityID() + "&cmd=M");
return m;
} // end try
catch (DataException de)
{ // something wrong in the database
return new ErrorBox("Database Error","Database error listing community members: " + de.getMessage(),
on_error);
} // end catch
} // end if ("M" command)
if (cmd.equals("A"))
{ // "A" = "Display Audit Records"
try
{
int offset = 0;
try
{ // convert the offset parameter
String s_ofs = request.getParameter("ofs");
if (!StringUtil.isStringEmpty(s_ofs))
offset = Integer.parseInt(s_ofs);
} // end try
catch (NumberFormatException nfe)
{ // if it's untranslatable, set it at 0
offset = 0;
} // end catch
// generate the lists
List audit_list = comm.getAuditRecords(offset,engine.getNumAuditRecordsPerPage());
int audit_count = comm.getAuditRecordCount();
// return the audit viewer
return new AuditDataViewer(engine,audit_list,offset,audit_count,"Audit Records for Community \""
+ comm.getName() + "\"","sigadmin?sig=" + comm.getCommunityID()
+ "&cmd=A&ofs=%");
} // end try
catch (AccessError ae)
{ // you don't have access
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // something wrong in the database
return new ErrorBox("Database Error","Database error getting audit records: " + de.getMessage(),
on_error);
} // end catch
} // end if ("A" command)
if (cmd.equals("I"))
{ // "I" = "Send E-Mail To All Members"
if (!(comm.canMassMail()))
{ // we can't send mass mail to the community, so what are we doing here?
logger.error("you can't mass-mail the community - not gonna do it, wouldn't be prudent");
return new ErrorBox("Access Error","You do not have permission to sent mass mail to this community.",
on_error);
} // end if
return new CommunityEMail(comm); // return the view object
} // end if ("I" command)
if (cmd.equals("DEL"))
{ // "DEL" = "Delete Community" (requires a confirmation)
if (!(comm.canDelete()))
{ // we can't delete the community, so what are we doing here?
logger.error("you can't delete the community - not gonna do it, wouldn't be prudent");
return new ErrorBox("Access Error","You do not have permission to delete this community.",on_error);
} // end if
if (ConfirmBox.isConfirmed(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM))
{ // we are confirmed - delete the community!
try
{ // delete the community!
comm.delete();
} // end try
catch (DataException de)
{ // something wrong in the database
logger.error("Database error deleting community: " + de.getMessage(),de);
return new ErrorBox("Database Error","Database error deleting community: " + de.getMessage(),
on_error);
} // end catch
catch (AccessError ae)
{ // access error changing the community values
logger.error("Access error deleting community: " + ae.getMessage(),ae);
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
// the community is now GONE - there's noplace else to go but back to the Top page
throw new RedirectResult("top");
} // end if
else
{ // throw up a confirm box to let the user think it over
String message = "You are about to permanently delete the \"" + comm.getName() + "\" community, "
+ "including all conferences and other resources it contains! Are you sure you want "
+ "to do this?";
return new ConfirmBox(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM,"Delete Conference",message,
on_error + "&cmd=DEL",on_error);
} // end else
} // end if ("DEL" command)
// all unknown requests get turned into menu display requests
if (!(comm.canAdministerCommunity()))
{ // no access - sorry buddy
logger.error("tried to call up community admin menu without access...naughty naughty!");
return new ErrorBox("Access Error","You do not have access to administer this community.",on_error);
} // end if
// create a community administration menu
CommunityAdminTop menu = makeCommunityAdminTop();
menu.setCommunity(comm);
return menu;
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// get the community context
CommunityContext comm = getCommunityParameter(request,user,true,"top");
changeMenuCommunity(request,comm);
String on_error = "sigadmin?sig=" + comm.getCommunityID();
setMyLocation(request,on_error);
if (logger.isDebugEnabled())
logger.debug("CommunityAdmin/doPost operating on community \"" + comm.getName() + "\" ("
+ comm.getCommunityID() + ")");
// now decide what to do based on the "cmd" parameter
String cmd = getStandardCommandParam(request);
if (logger.isDebugEnabled())
logger.debug("CommunityAdmin/doPost command value = " + cmd);
if (cmd.equals("P"))
{ // "P" = "Edit Profile"
if (!(comm.canModifyProfile()))
{ // no access - sorry, dude
logger.error("tried to call up community profile screen without access...naughty naughty!");
return new ErrorBox("Unauthorized","You do not have access to modify this community's profile.",
on_error);
} // end if
// construct the edit profile dialog and load it up for use
EditCommunityProfileDialog dlg = makeEditCommunityProfileDialog(comm.getSecurityInfo());
dlg.setupDialogBasic(engine,comm);
if (dlg.isButtonClicked(request,"cancel"))
throw new RedirectResult(on_error); // go back - they canceled out
if (dlg.isButtonClicked(request,"update"))
{ // begin updating the community's contents
dlg.loadValues(request); // do value loading now
try
{ // attempt to change the community profile now...
dlg.doDialog(comm);
// now jump back to the main menu
clearMenu(request);
throw new RedirectResult(on_error);
} // end try
catch (ValidationException ve)
{ // simple validation exception
if (logger.isDebugEnabled())
logger.debug("validation failure: " + ve.getMessage());
dlg.resetOnError(comm,ve.getMessage() + " Please try again.");
} // end catch
catch (DataException de)
{ // database error updating the community values
logger.error("DB error updating community: " + de.getMessage(),de);
return new ErrorBox("Database Error","Database error updating community: " + de.getMessage(),
on_error);
} // end catch
catch (AccessError ae)
{ // access error changing the community values
logger.error("Access error updating community: " + ae.getMessage(),ae);
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
return dlg;
} // end if ("update" pressed)
// what the hell was that button?
logger.error("no known button click on CommunityAdmin.doPost, cmd=P");
return new ErrorBox("Internal Error","Unknown command button pressed",on_error);
} // end if ("P" command)
if (cmd.equals("M"))
{ // "M" = Modify Community Membership
on_error += "&cmd=M";
setMyLocation(request,on_error);
if (!(comm.canModifyProfile()))
{ // no access - sorry, dude
logger.error("tried to call up community membership screen without access...naughty naughty!");
return new ErrorBox("Unauthorized","You do not have access to modify this community's membership.",
on_error);
} // end if
if (isImageButtonClicked(request,"update"))
{ // the "update" command that changes all the security levels
HashMap org_vals = new HashMap();
HashMap new_vals = new HashMap();
try
{ // retrieve all parameters and filter them for the levels
Enumeration p_names = request.getParameterNames();
while (p_names.hasMoreElements())
{ // examine each parameter name in turn
String p_name = (String)(p_names.nextElement());
if (p_name.startsWith("zxcur_"))
{ // this is a current value (from a hidden field)
int uid = Integer.parseInt(p_name.substring(6));
int level = Integer.parseInt(request.getParameter(p_name));
org_vals.put(new Integer(uid),new Integer(level));
} // end if
else if (p_name.startsWith("zxnew_"))
{ // this is a new value (from a dropdown list box)
int uid = Integer.parseInt(p_name.substring(6));
int level = Integer.parseInt(request.getParameter(p_name));
new_vals.put(new Integer(uid),new Integer(level));
} // end else if
} // end while
if (org_vals.size()!=new_vals.size())
{ // we read the wrong number of parameters - this is bad
logger.error("level parameters mismatch (" + org_vals.size() + " old, " + new_vals.size()
+ " new)");
return new ErrorBox(null,"Invalid parameters.",on_error);
} // end if
} // end try
catch (NumberFormatException nfe)
{ // error converting the parameters
logger.error("got number format exception parsing a level parameter");
return new ErrorBox(null,"Invalid parameter conversion.",on_error);
} // end catch
try
{ // loop through the hashmaps and set the value
Iterator it = org_vals.keySet().iterator();
while (it.hasNext())
{ // extract the UID, old level, and new level
Integer uid = (Integer)(it.next());
Integer org_level = (Integer)(org_vals.get(uid));
Integer new_level = (Integer)(new_vals.get(uid));
if (new_level==null)
{ // whoops
logger.error("new community level not found for uid " + uid.intValue());
return new ErrorBox(null,"Invalid new level parameter.",on_error);
} // end if
int new_level_x = new_level.intValue();
if (new_level_x==0)
new_level_x = -1;
// call down to set the membership level
if (org_level.intValue()!=new_level_x)
{ // we need to reset the community membership
if (logger.isDebugEnabled())
logger.debug("resetting community member level for uid " + uid.intValue() + "(old = "
+ org_level.intValue() + ", new = " + new_level_x + ")");
comm.setMembership(uid.intValue(),new_level_x);
} // end if
} // end while
} // end try
catch (AccessError ae)
{ // some sort of access error - display an error dialog
logger.error("AccessError on comm.setMembership: " + ae.getMessage(),ae);
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // database error creating the conference
logger.error("DataException on comm.setMembership: " + de.getMessage(),de);
return new ErrorBox("Database Error","Database error setting memberships: " + de.getMessage(),
on_error);
} // end catch
// trap back to the community membership display
throw new RedirectResult(on_error);
} // end if ("update" clicked)
if ( isImageButtonClicked(request,"search") || isImageButtonClicked(request,"previous")
|| isImageButtonClicked(request,"next"))
{ // create the new dialog box
CommunityMembership m = new CommunityMembership(engine,comm);
try
{ // perform the search!
m.doSearch(request);
} // end try
catch (ValidationException ve)
{ // validation error - throw it back to the user
return new ErrorBox(null,ve.getMessage() + " Please try again.",on_error);
} // end catch
catch (AccessError ae)
{ // some sort of access error - display an error dialog
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // database error creating the conference
return new ErrorBox("Database Error","Database error searching for users: " + de.getMessage(),
on_error);
} // end catch
return m;
} // end if (search function clicked)
// we don't know what button was pressed
logger.error("no known button click on CommunityAdmin.doPost, cmd=M");
return new ErrorBox("Internal Error","Unknown command button pressed",on_error);
} // end if ("M" command)
if (cmd.equals("I"))
{ // "I" - "Send E-Mail To Community"
if (!(comm.canMassMail()))
{ // we can't send mass mail to the community, so what are we doing here?
logger.error("you can't mass-mail the community - not gonna do it, wouldn't be prudent");
return new ErrorBox("Access Error","You do not have permission to sent mass mail to this community.",
on_error);
} // end if
try
{ // attempt to do the mass mailing!
comm.massMail(request.getParameter("subj"),request.getParameter("pb"));
} // end try
catch (AccessError ae)
{ // some sort of access error - display an error dialog
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // database error creating the conference
return new ErrorBox("Database Error","Database error getting mailing list: " + de.getMessage(),
on_error);
} // end catch
throw new RedirectResult(on_error); // bounce back to the menu
} // end if ("I" command)
// on unknown command, redirect to the GET function
return doVeniceGet(request,engine,user,rdat);
} // end doVenicePost
} // end class CommunityAdmin

View File

@@ -1,169 +0,0 @@
/*
* 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.util.ServletMultipartHandler;
import com.silverwrist.util.ServletMultipartException;
import com.silverwrist.util.image.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class CommunityLogo extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(CommunityLogo.class);
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "CommunityLogo servlet - changes the community logo for a community\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// Get the community.
CommunityContext comm = getCommunityParameter(request,user,true,null);
changeMenuCommunity(request,comm);
if (!(comm.canModifyProfile()))
return new ErrorBox("Community Error","You are not permitted to modify this community's profile.",null);
try
{ // create the display
return new CommunityLogoData(engine,comm,rdat);
} // end try
catch (DataException de)
{ // error getting at the data stream from the attachment
return new ErrorBox("Database Error","Database error generating display: " + de.getMessage(),
"sigadmin?cmd=P&sig=" + comm.getCommunityID());
} // end catch
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, ServletMultipartHandler mphandler,
VeniceEngine engine, UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// Get the community.
CommunityContext comm = getCommunityParameter(mphandler,user,true,null);
changeMenuCommunity(request,comm);
String target = "sigadmin?cmd=P&sig=" + comm.getCommunityID();
if (!(comm.canModifyProfile()))
return new ErrorBox("Community Error","You are not permitted to modify this community's profile.",
target);
if (isImageButtonClicked(mphandler,"cancel"))
throw new RedirectResult(target);
if (isImageButtonClicked(mphandler,"upload"))
{ // uploading the image here!
// also check on file parameter status
if (!(mphandler.isFileParam("thepic")))
{ // bogus file parameter
logger.error("Internal Error: 'thepic' should be a file param");
return new ErrorBox(null,"Internal Error: 'thepic' should be a file param",target);
} // end if
if (!(mphandler.getContentType("thepic").startsWith("image/")))
{ // must be an image type we uploaded!
logger.error("Error: 'thepic' not an image type");
return new ErrorBox(null,"You did not upload an image file. Try again.",
"commlogo?sig=" + comm.getCommunityID());
} // end if
try
{ // get the real picture (normalized to 110x65 size)
ImageLengthPair real_pic = ImageNormalizer.normalizeImage(mphandler.getFileContentStream("thepic"),
engine.getCommunityLogoSize(),"jpeg");
// set the community logo data!
ContactInfo ci = comm.getContactInfo();
ci.setPhotoData(request.getContextPath() + "/imagedata/","image/jpeg",real_pic.getLength(),
real_pic.getData());
comm.putContactInfo(ci);
// Jump back to the profile form.
clearMenu(request); // allow the menu to be redisplayed
throw new RedirectResult(target);
} // end try
catch (ServletMultipartException smpe)
{ // the servlet multipart parser screwed up
logger.error("Servlet multipart error:",smpe);
return new ErrorBox(null,"Internal Error: " + smpe.getMessage(),target);
} // end catch
catch (ImageNormalizerException ine)
{ // the image was not valid
logger.error("Image normalizer error:",ine);
return new ErrorBox(null,ine.getMessage(),"commlogo?sig=" + comm.getCommunityID());
} // end catch
catch (DataException de)
{ // error in the database!
logger.error("DataException:",de);
return new ErrorBox("Database Error","Database error storing community logo: " + de.getMessage(),
target);
} // end catch
catch (AccessError ae)
{ // email exception (WTF?)
logger.error("Access error:",ae);
return new ErrorBox(null,"Access error: " + ae.getMessage(),target);
} // end catch
} // end if
else
{ // the button must be wrong!
logger.error("no known button click on CommunityLogo.doPost");
return new ErrorBox("Internal Error","Unknown command button pressed",target);
} // end else
} // end doVenicePost
} // end class CommunityLogo

View File

@@ -1,476 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class CommunityOperations extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static final String UNJOIN_CONFIRM_ATTR = "servlets.CommunityOperations.unjoin.confirm";
private static final String UNJOIN_CONFIRM_PARAM = "confirm";
private static Category logger = Category.getInstance(CommunityOperations.class);
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
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 CreateCommunityDialog makeCreateCommunityDialog() throws ServletException
{
final String desired_name = "CreateCommunityDialog";
DialogCache cache = DialogCache.getDialogCache(getServletContext());
if (!(cache.isCached(desired_name)))
{ // create a template and save it off
CreateCommunityDialog template = new CreateCommunityDialog();
cache.saveTemplate(template);
} // end if
// return a new copy
return (CreateCommunityDialog)(cache.getNewDialog(desired_name));
} // end makeCreateCommunityDialog
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "CommunityOperations servlet - General community operations (join, unjoin, etc.)\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// get the command we want to use
String cmd = getStandardCommandParam(request);
setMyLocation(request,"sigops?" + request.getQueryString());
if (cmd.equals("J"))
{ // "J" = "Join" (requires community parameter)
CommunityContext comm = getCommunityParameter(request,user,true,"top");
if (!(comm.canJoin())) // not permitted to join!
return new ErrorBox("Community Error","You are not permitted to join this community.","top");
if (comm.isPublicCommunity())
{ // attempt to join right now! (no join key required)
try
{ // call down to join the community
comm.join(null);
// success! display the "welcome" page
clearMenu(request); // force the clear to regen the menus
changeMenuCommunity(request,comm);
return new CommunityWelcome(comm);
} // end try
catch (AccessError ae)
{ // access error
return new ErrorBox("Access Error","Unable to join community: " + ae.getMessage(),"top");
} // end catch
catch (DataException de)
{ // data exception doing something
return new ErrorBox("Database Error","Database error joining community: " + de.getMessage(),"top");
} // end catch
} // end if (public community)
else
{ // we need to prompt them for the join key....
JoinKeyDialog dlg = makeJoinKeyDialog();
dlg.setupDialog(comm);
changeMenuCommunity(request,comm);
return dlg;
} // end else (private community)
} // end if ("J" command)
if (cmd.equals("U"))
{ // "U" = "Unjoin (requires community parameter)
CommunityContext comm = getCommunityParameter(request,user,true,"top");
if (!(comm.canUnjoin()))
return new ErrorBox("Community Error","You cannot unjoin this community.","top");
// OK, let's test for a confirmation...
if (ConfirmBox.isConfirmed(request,UNJOIN_CONFIRM_ATTR,UNJOIN_CONFIRM_PARAM))
{ // OK, if you say so, let's unjoin!
try
{ // do the unjoin now...
comm.unjoin();
} // end try
catch (AccessError ae)
{ // access error
return new ErrorBox("Access Error","Unable to unjoin community: " + ae.getMessage(),"top");
} // end catch
catch (DataException de)
{ // data exception doing something
return new ErrorBox("Database Error","Database error unjoining community: " + de.getMessage(),"top");
} // end catch
// after which, redirect back to the top
clearMenu(request);
throw new RedirectResult("top");
} // end if
else
{ // not a proper confirmation - display the confirm box
String message = "Are you sure you want to unjoin the '" + comm.getName() + "' community?";
return new ConfirmBox(request,UNJOIN_CONFIRM_ATTR,UNJOIN_CONFIRM_PARAM,"Unjoining community",
message,"sigops?cmd=U&sig=" + comm.getCommunityID(),"sig/" + comm.getAlias());
} // end else
} // end if ("U" command)
if (cmd.equals("C"))
{ // "C" - Create community (no parameters)
if (!(user.canCreateCommunity()))
return new ErrorBox("Community Error","You are not permitted to create communities.","top");
// present the "Create New Community" dialog
CreateCommunityDialog dlg = makeCreateCommunityDialog();
dlg.setupDialog(engine);
dlg.setFieldValue("language","en-US");
dlg.setFieldValue("country","US");
changeMenuTop(request);
return dlg;
} // end if ("C" command)
if (cmd.equals("I"))
{ // "I" - Send Invitation (requires community parameter)
CommunityContext comm = getCommunityParameter(request,user,true,"top");
if (!(comm.canSendInvitation()))
return new ErrorBox("Community Error","You are not permitted to send an invitation.",
"sig/" + comm.getAlias());
// get conference and topic parameters
ConferenceContext conf = getConferenceParameter(request,comm,false,"sig/" + comm.getAlias());
TopicContext topic = null;
if (conf!=null)
topic = getTopicParameter(request,conf,false,
"confops?cmd=Q&sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID());
// present the "Invitation" dialog
return new Invitation(comm,conf,topic);
} // end if ("I" command)
if (cmd.equals("M"))
{ // "M" = List Members
CommunityContext comm = getCommunityParameter(request,user,true,"top");
if (logger.isDebugEnabled())
logger.debug("Member list for community: " + comm.getName());
try
{ // return the view dialog
ViewCommunityMembers view = new ViewCommunityMembers(engine,comm);
view.doInitialList();
changeMenuCommunity(request,comm);
return view;
} // end try
catch (DataException de)
{ // unable to get community members list
return new ErrorBox("Database Error","Database error getting community members list: "
+ de.getMessage(),"top");
} // end catch
} // end if ("M" command)
// this is an error!
logger.error("invalid command to CommunityOperations.doGet: " + cmd);
return new ErrorBox("Internal Error","Invalid command to CommunityOperations.doGet","top");
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// get the command we want to use
String cmd = getStandardCommandParam(request);
setMyLocation(request,"sigops?cmd=" + cmd);
if (cmd.equals("J"))
{ // "J" = Join Community (requires community parameter)
CommunityContext comm = getCommunityParameter(request,user,true,"top");
setMyLocation(request,"sigops?cmd=J&sig=" + comm.getCommunityID());
JoinKeyDialog dlg = makeJoinKeyDialog();
if (dlg.isButtonClicked(request,"cancel")) // cancel - go back to community opening page
throw new RedirectResult("sig/" + comm.getAlias());
if (!(comm.canJoin())) // not permitted to join!
return new ErrorBox("Community Error","You are not permitted to join this community.","top");
if (dlg.isButtonClicked(request,"join"))
{ // OK, go join the community
dlg.loadValues(request); // load the dialog
try
{ // attempt to join the community!
dlg.doDialog(comm);
// success! display the "welcome" page
clearMenu(request); // force the clear to regen the menus
changeMenuCommunity(request,comm);
return new CommunityWelcome(comm);
} // end try
catch (ValidationException ve)
{ // here, a validation exception causes us to recycle and retry
dlg.resetOnError(ve.getMessage() + " Please try again.");
changeMenuCommunity(request,comm);
} // end catch
catch (AccessError ae)
{ // this is probably a bogus key - let them retry
dlg.resetOnError(ae.getMessage() + " Please try again.");
changeMenuCommunity(request,comm);
} // end catch
catch (DataException de)
{ // database error joining something
return new ErrorBox("Database Error","Database error joining community: " + de.getMessage(),"top");
} // end catch
return dlg; // recycle and try aagin
} // end if ("join" clicked)
// error - don't know what button was clicked
logger.error("no known button click on CommunityOperations.doPost, cmd=J");
return new ErrorBox("Internal Error","Unknown command button pressed","top");
} // end if ("J" command)
if (cmd.equals("C"))
{ // "C" = Create New Community
if (!(user.canCreateCommunity()))
{ // EJB 11/25/2001 - give a different error message if they're not logged in
if (user.isLoggedIn())
return new ErrorBox("Community Error","You are not permitted to create communities.","top");
else
return new LogInOrCreate("sigops?cmd=C");
} // end if
// load the "Create Communities" dialog
CreateCommunityDialog dlg = makeCreateCommunityDialog();
dlg.setupDialog(engine);
if (dlg.isButtonClicked(request,"cancel")) // cancel - go back to top
throw new RedirectResult("top");
if (dlg.isButtonClicked(request,"create"))
{ // OK, they actually want to create the new community...
dlg.loadValues(request); // load the form data
try
{ // attempt to create the community!
CommunityContext comm = dlg.doDialog(user);
// created successfully - display a "new community welcome" page
changeMenuCommunity(request,comm); // display menus for the first time!
return new NewCommunityWelcome(comm);
} // end try
catch (ValidationException ve)
{ // here, a validation exception causes us to recycle and retry
dlg.resetOnError(ve.getMessage() + " Please try again.");
changeMenuTop(request);
} // end catch
catch (AccessError ae)
{ // this is probably a bogus key - let them retry
dlg.resetOnError(ae.getMessage() + " Please try again.");
changeMenuTop(request);
} // end catch
catch (DataException de)
{ // database error doing something
return new ErrorBox("Database Error","Database error creating community: " + de.getMessage(),"top");
} // end catch
return dlg; // put the dialog back up
} // end if ("create" pressed)
// error - don't know what button was clicked
logger.error("no known button click on CommunityOperations.doPost, cmd=C");
return new ErrorBox("Internal Error","Unknown command button pressed","top");
} // end if ("C" command)
if (cmd.equals("I"))
{ // "I" = Send invitation (requires community parameter)
CommunityContext comm = getCommunityParameter(request,user,true,"top");
setMyLocation(request,"sigops?cmd=I&sig=" + comm.getCommunityID());
String on_error = "sig/" + comm.getAlias();
// get conference and topic parameters
ConferenceContext conf = getConferenceParameter(request,comm,false,on_error);
if (conf!=null)
on_error = "confops?cmd=Q&sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID();
TopicContext topic = null;
if (conf!=null)
{ // try and get a topic parameter
topic = getTopicParameter(request,conf,false,on_error);
if (topic!=null)
on_error = "topicops?sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID() + "&top="
+ topic.getTopicNumber();
} // end if
if (isImageButtonClicked(request,"cancel")) // cancel - go back to community opening page
throw new RedirectResult(on_error);
if (isImageButtonClicked(request,"send"))
{ // the "send" button was pressed
try
{ // send out the invitation
if (topic!=null)
topic.sendInvitation(request.getParameter("addr"),request.getParameter("pb"));
else if (conf!=null)
conf.sendInvitation(request.getParameter("addr"),request.getParameter("pb"));
else
comm.sendInvitation(request.getParameter("addr"),request.getParameter("pb"));
} // end try
catch (AccessError ae)
{ // access error - display error box
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // database error doing something
return new ErrorBox("Database Error","Database error sending invitation: " + de.getMessage(),
on_error);
} // end catch
catch (EmailException ee)
{ // error sending the email message
return new ErrorBox("E-Mail Error","Error sending e-mail: " + ee.getMessage(),on_error);
} // end catch
// all sent - go back to community profile display
throw new RedirectResult(on_error);
} // end if ("send" pressed)
// error - don't know what button was clicked
logger.error("no known button click on CommunityOperations.doPost, cmd=I");
return new ErrorBox("Internal Error","Unknown command button pressed",on_error);
} // end if ("I" command)
if (cmd.equals("M"))
{ // "M" = Display Members List
CommunityContext comm = getCommunityParameter(request,user,true,"top");
setMyLocation(request,"sigops?cmd=M&sig=" + comm.getCommunityID());
String on_error = "sig/" + comm.getAlias();
if (logger.isDebugEnabled())
logger.debug("Member list for community: " + comm.getName());
try
{ // generate the members list
ViewCommunityMembers view = new ViewCommunityMembers(engine,comm);
view.doSearch(request);
changeMenuCommunity(request,comm);
return view;
} // end try
catch (ValidationException ve)
{ // validation error - throw it back to the user
return new ErrorBox(null,ve.getMessage() + " Please try again.",
"sigops?cmd=M&sig=" + comm.getCommunityID());
} // end catch
catch (DataException de)
{ // unable to get community members list
return new ErrorBox("Database Error","Database error getting community members list: "
+ de.getMessage(),on_error);
} // end catch
} // end if ("M" command)
// this is an error!
logger.error("invalid command to CommunityOperations.doPost: " + cmd);
return new ErrorBox("Internal Error","Invalid command to CommunityOperations.doPost","top");
} // end doVenicePost
} // end class CommunityOperations

View File

@@ -1,487 +0,0 @@
/*
* 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.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class ConfDisplay extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Internal class used to get post number defaults
*--------------------------------------------------------------------------------
*/
static class PostInterval
{
private int first;
private int last;
public PostInterval(int f, int l)
{
if (f<=l)
{ // the sort is good
first = f;
last = l;
} // end if
else
{ // reverse the order
first = l;
last = f;
} // end else
} // end constructor
public int getFirst()
{
return first;
} // end getFirst
public int getLast()
{
return last;
} // end getLast
} // end class PostInterval
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(ConfDisplay.class);
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private static void getViewSortDefaults(ServletRequest request, int confid, TopicSortHolder tsc,
String on_error) throws ErrorBox
{
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 ErrorBox(null,"Invalid view parameter.",on_error);
} // end switch
} // end try
catch (NumberFormatException nfe)
{ // failure in parseInt
logger.error("Cannot convert view parameter '" + str + "'!");
throw new ErrorBox(null,"Invalid view parameter.",on_error);
} // 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 ErrorBox(null,"Invalid sort parameter.",on_error);
} // end switch
} // end try
catch (NumberFormatException nfe)
{ // failure in parseInt
logger.error("Cannot convert sort parameter '" + str + "'!");
throw new ErrorBox(null,"Invalid sort parameter.",on_error);
} // end catch
} // end if
} // end getViewSortDefaults
private static PostInterval getInterval(VeniceEngine engine, ServletRequest request, TopicContext topic,
String on_error) throws ErrorBox
{
int first, last;
String foo = request.getParameter("pxg");
if (!(StringUtil.isStringEmpty(foo)))
{ // we have a Go box parameter - try and decode it
try
{ // look for a range specifier
int p = foo.indexOf('-');
if (p<0)
{ // single post number - try and use it
first = Integer.parseInt(foo);
last = first;
} // end if
else if (p==0)
{ // "-number" - works like "0-number"
last = Integer.parseInt(foo.substring(1));
first = 0;
} // end if
else if (p==(foo.length()-1))
{ // "number-" - works like "number-end"
first = Integer.parseInt(foo.substring(0,p));
last = topic.getTotalMessages() - 1;
} // end else if
else
{ // two numbers to decode
first = Integer.parseInt(foo.substring(0,p));
last = Integer.parseInt(foo.substring(p+1));
} // end else
return new PostInterval(first,last);
} // end try
catch (NumberFormatException nfe)
{ // if numeric conversion fails, just fall out and try to redisplay the other way
} // end catch
} // end if
foo = request.getParameter("p1");
if (StringUtil.isStringEmpty(foo))
{ // no range specified - cook up a default one
last = topic.getTotalMessages();
int ur = topic.getUnreadMessages();
if ((ur==0) || (ur>=engine.getNumPostsPerPage()))
first = last - engine.getNumPostsPerPage();
else
first = last - (ur + engine.getNumOldPostsBeforeNew());
last--;
} // end if
else
{ // we have at least one parameter...
try
{ // convert it to an integer and range-limit it
first = Integer.parseInt(foo);
if (first<0)
first = 0;
else if (first>=topic.getTotalMessages())
first = topic.getTotalMessages() - 1;
} // end try
catch (NumberFormatException nfe)
{ // we could not translate the parameter to a number
throw new ErrorBox(null,"Message parameter is invalid.",on_error);
} // end catch
foo = request.getParameter("p2");
if (StringUtil.isStringEmpty(foo))
last = first; // just specify ONE post...
else
{ // OK, we have an actual "last message" parameter...
try
{ // convert it to an integer and range-limit it
last = Integer.parseInt(foo);
if ((last<0) || (last>=topic.getTotalMessages()))
last = topic.getTotalMessages() - 1;
} // end try
catch (NumberFormatException nfe)
{ // we could not translate the parameter to a number
throw new ErrorBox(null,"Message parameter is invalid.",on_error);
} // end catch
} // end else
} // end else
return new PostInterval(first,last);
} // end getInterval
private static boolean restorePosts(ServletRequest request, ConferenceContext conf, TopicContext curr_topic)
{
String xtopic = request.getParameter("rtop");
if (StringUtil.isStringEmpty(xtopic))
return true;
String xcount = request.getParameter("rct");
if (StringUtil.isStringEmpty(xcount))
return true;
TopicContext topic;
try
{ // get the topic corresponding to the first parameter
topic = conf.getTopic(Short.parseShort(xtopic));
} // end try
catch (NumberFormatException nfe)
{ // the topic number was invalid - forget it
logger.warn("restorePosts: error translating topic number");
return true;
} // end catch
catch (DataException de)
{ // could not get the topic...
logger.warn("restorePosts: DataException getting topic - " + de.getMessage(),de);
return true;
} // end catch
catch (AccessError ae)
{ // no access to the topic
logger.warn("restorePosts: AccessError getting topic - " + ae.getMessage(),ae);
return true;
} // end catch
int nunread;
try
{ // translate the number of unread posts to set
nunread = Integer.parseInt(xcount);
if ((nunread<=0) || (nunread>topic.getTotalMessages()))
{ // must be in the range [1, #messages]...
logger.warn("restorePosts: unread post count out of range");
return true;
} // end if
} // end try
catch (NumberFormatException nfe)
{ // the number of unread posts was invalid - forget it
logger.warn("restorePosts: error translating unread post count");
return true;
} // end catch
try
{ // now try to set the unread messages
topic.setUnreadMessages(nunread);
} // end try
catch (DataException de)
{ // could not get the topic...
logger.warn("restorePosts: DataException setting unread messages - " + de.getMessage(),de);
} // end catch
return (topic.getTopicID()!=curr_topic.getTopicID());
} // end restorePosts
/*--------------------------------------------------------------------------------
* 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
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// get the community
CommunityContext comm = getCommunityParameter(request,user,true,"top");
changeMenuCommunity(request,comm);
// get the conference
ConferenceContext conf = getConferenceParameter(request,comm,true,"top");
// get the topic, if we have it
TopicContext topic = getTopicParameter(request,user,conf,false,"top",
"confdisp?" + request.getQueryString());
if (topic!=null)
{ // we're handling messages within a single topic
if (logger.isDebugEnabled())
logger.debug("MODE: display messages in topic");
String on_error = "confdisp?sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID();
setMyLocation(request,on_error + "&top=" + topic.getTopicNumber());
// if this request is restoring the number of unread posts in another topic, try to do so
boolean do_readnew = restorePosts(request,conf,topic);
// determine what the post interval is we want to display
PostInterval piv = getInterval(engine,request,topic,on_error);
boolean read_new = do_readnew && !(StringUtil.isStringEmpty(request.getParameter("rnm")));
boolean show_adv = !(StringUtil.isStringEmpty(request.getParameter("shac")));
boolean no_bozos = !(StringUtil.isStringEmpty(request.getParameter("nbz")));
// Create the post display.
try
{ // create the display
return new TopicPosts(request,engine,user,comm,conf,topic,piv.getFirst(),piv.getLast(),read_new,
show_adv,no_bozos);
} // end try
catch (DataException de)
{ // there was a database error retrieving messages
return new ErrorBox("Database Error","Database error listing messages: " + de.getMessage(),on_error);
} // end catch
catch (AccessError ae)
{ // we were unable to retrieve the message list
if (user.isLoggedIn())
return new ErrorBox("Access Error",ae.getMessage(),on_error);
else
return new LogInOrCreate(getMyLocation(request));
} // end catch
} // end if (messages in a topic)
else
{ // we're displaying the conference's topic list
if (logger.isDebugEnabled())
logger.debug("MODE: display topics in conference");
String on_error = "confops?sig=" + comm.getCommunityID();
String my_location = "confdisp?sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID();
boolean read_new = !(StringUtil.isStringEmpty(request.getParameter("rnm")));
if (read_new)
my_location += "&rnm=1";
setMyLocation(request,my_location);
// get any changes to view or sort options
TopicSortHolder opts = TopicSortHolder.retrieve(request.getSession(true));
getViewSortDefaults(request,conf.getConfID(),opts,on_error);
if (read_new)
{ // we need to generate a TopicPosts view
try
{ // generate a topic list first
List topic_list = conf.getTopicList(opts.getViewOption(conf.getConfID()),
opts.getSortOption(conf.getConfID()));
// now generate the topic visit order
TopicVisitOrder ord = TopicVisitOrder.initialize(request.getSession(true),conf.getConfID(),
topic_list);
// use the new visit order to get the topic we need to visit
short topic_nbr = ord.getNext();
Iterator it = topic_list.iterator();
while (it.hasNext())
{ // locate the first topic to be read
topic = (TopicContext)(it.next());
if (topic.getTopicNumber()==topic_nbr)
break;
} // end while
if (topic==null) // no suitable topic found - just create the topic listing
return new TopicListing(request,comm,conf,opts.getViewOption(conf.getConfID()),
opts.getSortOption(conf.getConfID()));
// determine what the post interval is we want to display
PostInterval piv = getInterval(engine,request,topic,on_error);
// create the topic posts view
return new TopicPosts(request,engine,user,comm,conf,topic,piv.getFirst(),piv.getLast(),true,
false,false);
} // end try
catch (DataException de)
{ // there was a database error retrieving messages
return new ErrorBox("Database Error","Database error listing messages: " + de.getMessage(),on_error);
} // end catch
catch (AccessError ae)
{ // we were unable to retrieve the message list
if (user.isLoggedIn())
return new ErrorBox("Access Error",ae.getMessage(),on_error);
else
return new LogInOrCreate(getMyLocation(request));
} // end catch
} // end if (creating a "read new" topic list view)
else
{ // topic listing only...
TopicListing tl = null;
try
{ // create the topic list
tl = new TopicListing(request,comm,conf,opts.getViewOption(conf.getConfID()),
opts.getSortOption(conf.getConfID()));
} // end try
catch (DataException de)
{ // there was a database error retrieving topics
return new ErrorBox("Database Error","Database error listing topics: " + de.getMessage(),on_error);
} // end catch
catch (AccessError ae)
{ // we were unable to retrieve the topic list
if (user.isLoggedIn())
return new ErrorBox("Access Error",ae.getMessage(),on_error);
else
return new LogInOrCreate(getMyLocation(request));
} // end catch
return tl;
} // end else (not reading new messages, but just displaying topics)
} // end else (topics in a conference)
} // end doVeniceGet
} // end class ConfDisplay

File diff suppressed because it is too large Load Diff

View File

@@ -1,179 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
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(VeniceEngine engine, ServletRequest request)
{
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 (engine.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
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
changeMenuTop(request); // we go to the "top" menus for this
// figure out which page to display
int disp = getDisplayParam(request,FindData.getNumChoices());
FindData finddata = new FindData(engine,user,disp);
// figure out the category ID parameter
int cat = -1;
if (disp==FindData.FD_COMMUNITIES)
cat = getCategoryParam(engine,request);
try
{ // attempt to configure the display
finddata.loadGet(cat);
} // end try
catch (DataException de)
{ // database error, man
return new ErrorBox("Database Error","Database error accessing category data: " + de.getMessage(),"top");
} // end catch
setMyLocation(request,"find?" + request.getQueryString());
return finddata;
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
changeMenuTop(request); // we go to the "top" menus for this
// figure out which page to display
int disp = getDisplayParam(request,FindData.getNumChoices());
FindData finddata = new FindData(engine,user,disp);
try
{ // attempt to configure the display
finddata.loadPost(request);
} // end try
catch (ValidationException ve)
{ // error in find parameters
return new ErrorBox("Find Error",ve.getMessage(),"top");
} // end catch
catch (DataException de)
{ // database error, man
return new ErrorBox("Database Error","Database error on find: " + de.getMessage(),"top");
} // end catch
setMyLocation(request,"find?disp=" + finddata.getDisplayOption());
return finddata;
} // end doVenicePost
} // end class Find

View File

@@ -1,113 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class FindPost extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "FindPost servlet - Searches for posts in communities, conferences, and/or topics\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
CommunityContext comm = getCommunityParameter(request,user,true,"top");
changeMenuCommunity(request,comm);
String locator = "sig=" + comm.getCommunityID();
ConferenceContext conf = getConferenceParameter(request,comm,false,"confops?" + locator);
TopicContext topic = null;
if (conf!=null)
{ // find the topic parameter
locator += ("&conf=" + conf.getConfID());
topic = getTopicParameter(request,conf,false,"confdisp?" + locator);
if (topic!=null)
locator += ("&top=" + topic.getTopicNumber());
} // end if
setMyLocation(request,"findpost?" + locator);
return new FindPostData(comm,conf,topic);
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
CommunityContext comm = getCommunityParameter(request,user,true,"top");
changeMenuCommunity(request,comm);
String locator = "sig=" + comm.getCommunityID();
ConferenceContext conf = getConferenceParameter(request,comm,false,"confops?" + locator);
TopicContext topic = null;
if (conf!=null)
{ // find the topic parameter
locator += ("&conf=" + conf.getConfID());
topic = getTopicParameter(request,conf,false,"confdisp?" + locator);
if (topic!=null)
locator += ("&top=" + topic.getTopicNumber());
} // end if
setMyLocation(request,"findpost?" + locator);
FindPostData data = new FindPostData(comm,conf,topic);
try
{ // attempt to configure the display
data.doSearch(request,engine);
} // end try
catch (AccessError ae)
{ // error in find parameters
return new ErrorBox("Find Error",ae.getMessage(),"top");
} // end catch
catch (DataException de)
{ // database error, man
return new ErrorBox("Database Error","Database error on find: " + de.getMessage(),"top");
} // end catch
return data;
} // end doVenicePost
} // end class FindPost

View File

@@ -1,71 +0,0 @@
/*
* 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.net.URLEncoder;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.servlets.format.*;
public class Gateway extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(Gateway.class);
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "Gateway servlet - \"Gates\" a URL request based on whether or not the user is logged in\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
String target = request.getQueryString();
if (target==null)
throw new ErrorResult(HttpServletResponse.SC_BAD_REQUEST,"no parameter specified");
if (logger.isDebugEnabled())
logger.debug("they want to redirect to: " + target);
if (user.isLoggedIn())
throw new RedirectResult(target);
else
throw new RedirectResult("account?cmd=L&tgt=" + URLEncoder.encode(target));
} // end doVeniceGet
} // end class Gateway

View File

@@ -1,99 +0,0 @@
/*
* 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.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class ImageRetrieve extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(ImageRetrieve.class);
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "ImageRetrieve servlet - Displays images from the database image store\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
int imgid; // image ID to retrieve.
try
{ // parse the image ID
imgid = Integer.parseInt(request.getPathInfo().substring(1));
} // end try
catch (NumberFormatException nfe)
{ // invalid image URL
return new ErrorBox(null,"Invalid image URL.",null);
} // end catch
// the parameters of the response
String type, filename;
int length;
InputStream data;
try
{ // load the image from the database
BinaryData image = engine.loadImage(imgid);
type = image.getMIMEType();
filename = image.getFilename();
length = image.getLength();
data = image.getData();
} // end try
catch (DataException de)
{ // unable to get the user name
return new ErrorBox("Database Error","Database error retrieving image: " + de.getMessage(),null);
} // end catch
// now we want to send that data back to the user!
throw new SendFileResult(type,filename,length,data);
} // end doVeniceGet
} // end class ImageRetrieve

View File

@@ -1,197 +0,0 @@
/*
* 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.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class PostMessage extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(PostMessage.class.getName());
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private static int getPostNumber(ServletRequest request, String on_error) throws ErrorBox
{
String str = request.getParameter("sd");
if (StringUtil.isStringEmpty(str))
throw new ErrorBox(null,"Invalid parameter.",on_error);
try
{ // get the number of posts we think he topic has
return Integer.parseInt(str);
} // end try
catch (NumberFormatException nfe)
{ // not a good integer...
throw new ErrorBox(null,"Invalid parameter.",on_error);
} // end catch
} // end getPostNumber
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "PostMessage servlet - Handles posting messages to a conference\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// get the community
CommunityContext comm = getCommunityParameter(request,user,true,"top");
changeMenuCommunity(request,comm);
// get the conference
ConferenceContext conf = getConferenceParameter(request,comm,true,"top");
// get the topic
TopicContext topic = getTopicParameter(request,conf,true,"top");
String on_error = "confdisp?sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID() + "&top="
+ topic.getTopicNumber();
if (isImageButtonClicked(request,"cancel"))
throw new RedirectResult(on_error); // canceled posting - take us back
// make sure we've got some post data
String raw_postdata = request.getParameter("pb");
/* EJB 4/4/2001 - take this code out, FUTURE: maybe make it a global setting?
if (StringUtil.isStringEmpty(raw_postdata))
return null; // don't allow zero-size posts
-- end removed code */
if (raw_postdata==null)
raw_postdata = "";
final String yes = "Y";
if (isImageButtonClicked(request,"preview")) // generate a preview
return new PostPreview(engine,comm,conf,topic,request.getParameter("pseud"),raw_postdata,
request.getParameter("next"),getPostNumber(request,on_error),
yes.equals(request.getParameter("attach")),
yes.equals(request.getParameter("slip")));
if ( isImageButtonClicked(request,"post") || isImageButtonClicked(request,"postnext")
|| isImageButtonClicked(request,"posttopics"))
{ // post the message, and then either go back to the same topic or on to the next one
boolean go_next = isImageButtonClicked(request,"postnext");
boolean go_topics = isImageButtonClicked(request,"posttopics");
int pn = getPostNumber(request,on_error);
try
{ // first check for slippage
if (pn!=topic.getTotalMessages()) // slippage detected! display the slippage screen
return new PostSlippage(engine,comm,conf,topic,pn,request.getParameter("next"),
request.getParameter("pseud"),raw_postdata,
yes.equals(request.getParameter("attach")));
// post the darn thing!
TopicMessageContext msg = topic.postNewMessage(0,request.getParameter("pseud"),raw_postdata);
if (!(yes.equals(request.getParameter("slip"))))
topic.fixSeen(); // no slippage = make sure we mark all as read
// where do we want to go now?
String target;
if (go_topics)
target = "confdisp?sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID();
else
{ // figure out what topic to go to next
short next;
try
{ // attempt to get the value of the "next topic" parameter
if (go_next)
{ // get the "next topic" parameter
String foo = request.getParameter("next");
if (StringUtil.isStringEmpty(foo))
next = topic.getTopicNumber();
else
next = Short.parseShort(foo);
} // end if
else
next = topic.getTopicNumber();
} // end try
catch (NumberFormatException nfe)
{ // just default me
next = topic.getTopicNumber();
} // end catch
target = "confdisp?sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID() + "&top="
+ next + "&rnm=1";
} // end else
if (yes.equals(request.getParameter("attach")))
return new AttachmentForm(comm,conf,msg,target); // go to upload an attachment
// no attachment - redirect where we need to go
throw new RedirectResult(target);
} // end try
catch (DataException de)
{ // there was a database error posting the message
return new ErrorBox("Database Error","Database error posting message: " + de.getMessage(),"top");
} // end catch
catch (AccessError ae)
{ // we were unable to post the message
return new ErrorBox("Access Error",ae.getMessage(),"top");
} // end catch
} // end if
// unknown button clicked
logger.error("no known button click on PostMessage.doPost");
return new ErrorBox("Internal Error","Unknown command button pressed","top");
} // end doVenicePost
} // end class PostMessage

View File

@@ -1,224 +0,0 @@
/*
* 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.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class PostOperations extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static final String NUKE_CONFIRM_ATTR = "servlets.PostOperations.nuke.confirm";
private static final String NUKE_CONFIRM_PARAM = "confirm";
private static Category logger = Category.getInstance(TopicOperations.class.getName());
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "PostOperations servlet - General post operations (hide, scribble, etc.)\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// get the community
CommunityContext comm = getCommunityParameter(request,user,true,"top");
changeMenuCommunity(request,comm);
String locator = "sig=" + comm.getCommunityID();
String location = "sigprofile?" + locator;
// get the conference
ConferenceContext conf = getConferenceParameter(request,comm,true,location);
locator += "&conf=" + conf.getConfID();
location = "confdisp?" + locator;
// get the topic
TopicContext topic = getTopicParameter(request,conf,true,location);
locator += "&top=" + topic.getTopicNumber();
location = "confdisp?" + locator;
// get the message
TopicMessageContext msg = getMessageParameter(request,topic,true,location);
location = "confdisp?" + locator + "&p1=" + msg.getPostNumber() + "&shac=1";
setMyLocation(request,location);
// figure out what command we want to perform
String cmd = getStandardCommandParam(request);
if (cmd.equals("HY") || cmd.equals("HN"))
{ // we want to hide or show the message
try
{ // attempt to hide or show the message
msg.setHidden(cmd.equals("HY"));
// go back and display stuff
throw new RedirectResult(location);
} // end if
catch (DataException de)
{ // there was a database error
return new ErrorBox("Database Error","Database error setting hidden status: " + de.getMessage(),
location);
} // end catch
catch (AccessError ae)
{ // naughty naughty = you can't do this!
return new ErrorBox("Access Error",ae.getMessage(),location);
} // end catch
} // end if ("hide" or "show")
if (cmd.equals("SCR"))
{ // we want to scribble the message
try
{ // attempt to scribble the message
msg.scribble();
// go back and display stuff
throw new RedirectResult(location);
} // end try
catch (DataException de)
{ // there was a database error
return new ErrorBox("Database Error","Database error scribbling message: " + de.getMessage(),
location);
} // end catch
catch (AccessError ae)
{ // naughty naughty = you can't do this!
return new ErrorBox("Access Error",ae.getMessage(),location);
} // end catch
} // end if ("scribble")
if (cmd.equals("BY") || cmd.equals("BN"))
{ // we want to add or remove the bozo filter from the user here
try
{ // attempt to set the bozo filter status
topic.setBozo(msg.getCreatorUID(),cmd.equals("BY"));
// go back and display stuff
throw new RedirectResult(location);
} // end try
catch (DataException de)
{ // there was a database error
return new ErrorBox("Database Error","Database error setting filter status: " + de.getMessage(),
location);
} // end catch
} // end if
if (cmd.equals("NUKE"))
{ // nuking requires confirmation
try
{ // we need confirmation on this operation
if (ConfirmBox.isConfirmed(request,NUKE_CONFIRM_ATTR,NUKE_CONFIRM_PARAM))
{ // OK, go ahead, nuke the message!
msg.nuke();
// after which, redirect to topic view
throw new RedirectResult("confdisp?" + locator);
} // end if (confirmed)
else
{ // not a proper confirmation - better display one
List aliases = conf.getAliases();
String message = "You are about to nuke message <" + (String)(aliases.get(0)) + "."
+ topic.getTopicNumber() + "." + msg.getPostNumber() + ">, originally composed by <"
+ msg.getCreatorName() + ">! Are you sure you want to do this?";
String confirm_url = "postops?" + locator + "&msg=" + msg.getPostNumber() + "&cmd=NUKE";
return new ConfirmBox(request,NUKE_CONFIRM_ATTR,NUKE_CONFIRM_PARAM,"Nuke Message",
message,confirm_url,location);
} // end else (not yet confirmed)
} // end try
catch (DataException de)
{ // there was a database error
return new ErrorBox("Database Error","Database error nuking message: " + de.getMessage(),
location);
} // end catch
catch (AccessError ae)
{ // naughty naughty = you can't do this!
return new ErrorBox("Access Error",ae.getMessage(),location);
} // end catch
} // end if ("nuke")
if (cmd.equals("PU"))
{ // we want to publish the message to the front page
try
{ // attempt to publish the message
msg.publish();
// go back and display stuff
throw new RedirectResult(location);
} // end try
catch (DataException de)
{ // there was a database error
return new ErrorBox("Database Error","Database error publishing message: " + de.getMessage(),
location);
} // end catch
catch (AccessError ae)
{ // naughty naughty = you can't do this!
return new ErrorBox("Access Error",ae.getMessage(),location);
} // end catch
} // end if
// unrecognized command!
logger.error("invalid command to PostOperations.doGet: " + cmd);
return new ErrorBox("Internal Error","Invalid command to PostOperations.doGet",location);
} // end doVeniceGet
} // end class PostOperations

View File

@@ -1,425 +0,0 @@
/*
* 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.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class Settings extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static final String UNJOIN_CONFIRM_ATTR = "servlets.Settings.unjoin.confirm";
private static final String UNJOIN_CONFIRM_PARAM = "confirm";
private static Category logger = Category.getInstance(Settings.class.getName());
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private static int findHotlistIndex(List hotlist, ServletRequest request) throws ErrorBox
{
String foo = request.getParameter("sig");
if (foo==null)
throw new ErrorBox(null,"Parameter not specified!","settings?cmd=H");
int cid;
try
{ // this is the community id of the hotlist entry
cid = Integer.parseInt(foo);
} // end try
catch (NumberFormatException nfe)
{ // conversion error...
throw new ErrorBox(null,"Parameter invalid!","settings?cmd=H");
} // end catch
foo = request.getParameter("conf");
if (foo==null)
throw new ErrorBox(null,"Parameter not specified!","settings?cmd=H");
int confid;
try
{ // this is the conference id of the hotlist entry
confid = Integer.parseInt(foo);
} // end try
catch (NumberFormatException nfe)
{ // conversion error...
throw new ErrorBox(null,"Parameter invalid!","settings?cmd=H");
} // end catch
for (int i=0; i<hotlist.size(); i++)
{ // look at the hotlist entries to find the right index
ConferenceHotlistEntry hle = (ConferenceHotlistEntry)(hotlist.get(i));
if ( (hle.getConference().getConfID()==confid)
&& (hle.getConference().getEnclosingCommunity().getCommunityID()==cid))
return i;
} // end for
throw new ErrorBox(null,"Hotlist entry not found!","settings?cmd=H");
} // end findHotlistIndex
private static int getBoxIDParameter(ServletRequest request) throws ErrorBox
{
String foo = request.getParameter("box");
if (foo==null)
throw new ErrorBox(null,"Parameter not specified!","settings?cmd=B");
try
{ // parse the integer and get the box ID
return Integer.parseInt(foo);
} // end try
catch (NumberFormatException e)
{ // error in parsing...
throw new ErrorBox(null,"Parameter invalid!","settings?cmd=B");
} // end catch
} // end getBoxIDParameter
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "Settings servlet - Handles per-user customization and settings information\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
String cmd = getStandardCommandParam(request);
if (cmd.equals("H"))
{ // "H" - Manage Conference Hotlist
try
{ // return the hotlist viewer
setMyLocation(request,"settings?cmd=H");
return new Hotlist(user);
} // end try
catch (DataException de)
{ // oops...can't get it!
return new ErrorBox("Database Error","Error getting hotlist: " + de.getMessage(),"top");
} // end catch
} // end if ("H" command)
if (cmd.equals("HU") || cmd.equals("HD") || cmd.equals("HX"))
{ // one of the commands for modifying the user hotlist
try
{ // start by getting the hotlist and localizing the entry we want to modify
List hotlist = user.getConferenceHotlist();
int ndx = findHotlistIndex(hotlist,request);
ConferenceHotlistEntry hle = (ConferenceHotlistEntry)(hotlist.get(ndx));
ConferenceContext conf = hle.getConference();
if (cmd.equals("HX"))
conf.removeFromHotlist(); // pretty straightforward
else
{ // moving up or down - find the entry to switch places with
int other_ndx;
if (cmd.equals("HU"))
{ // moving up!
if (ndx==0)
return null; // can't move up from here
other_ndx = ndx - 1;
} // end if
else
{ // moving down
other_ndx = ndx + 1;
if (other_ndx==hotlist.size())
return null; // can't move down from here
} // end else
// find the sequence numbers and the other conference object
int my_seq = hle.getSequence();
hle = (ConferenceHotlistEntry)(hotlist.get(other_ndx));
ConferenceContext other_conf = hle.getConference();
int other_seq = hle.getSequence();
// now reset the sequences
conf.setHotlistSequence(other_seq);
boolean restore = true;
try
{ // reset the other conference sequence, too
other_conf.setHotlistSequence(my_seq);
restore = false;
} // end try
finally
{ // restore the original conference sequence on error
if (restore)
conf.setHotlistSequence(my_seq);
} // end finally
} // end else (moving up or down)
} // end try
catch (DataException de)
{ // there's a data exception somewhere
return new ErrorBox("Database Error","Error adjusting hotlist: " + de.getMessage(),"settings?cmd=H");
} // end catch
try
{ // return the hotlist viewer
setMyLocation(request,"settings?cmd=H");
return new Hotlist(user);
} // end try
catch (DataException de)
{ // oops...can't get it!
return new ErrorBox("Database Error","Error getting hotlist: " + de.getMessage(),"top");
} // end catch
} // end if (one of the "H" subcommands)
if (cmd.equals("S"))
{ // "S" - display the user's community list
try
{ // return the community list viewer
setMyLocation(request,"settings?cmd=S");
return new UserCommunityList(user);
} // end try
catch (DataException de)
{ // oops...can't get it!
return new ErrorBox("Database Error","Error getting communities list: " + de.getMessage(),"top");
} // end catch
} // end if ("S" command)
if (cmd.equals("SX"))
{ // "SX" - unjoin the specified community
CommunityContext comm = getCommunityParameter(request,user,true,"settings?cmd=S");
if (!(comm.canUnjoin()))
return new ErrorBox("Community Error","You cannot unjoin this community.","settings?cmd=S");
// OK, let's test for a confirmation...
if (ConfirmBox.isConfirmed(request,UNJOIN_CONFIRM_ATTR,UNJOIN_CONFIRM_PARAM))
{ // OK, if you say so, let's unjoin!
try
{ // do the unjoin now...
comm.unjoin();
} // end try
catch (AccessError ae)
{ // access error
return new ErrorBox("Access Error","Unable to unjoin community: " + ae.getMessage(),
"settings?cmd=S");
} // end catch
catch (DataException de)
{ // data exception doing something
return new ErrorBox("Database Error","Database error unjoining community: " + de.getMessage(),
"settings?cmd=S");
} // end catch
// after which, redirect back to the top
throw new RedirectResult("settings?cmd=S");
} // end if
else
{ // not a proper confirmation - display the confirm box
String message = "Are you sure you want to unjoin the '" + comm.getName() + "' community?";
return new ConfirmBox(request,UNJOIN_CONFIRM_ATTR,UNJOIN_CONFIRM_PARAM,"Unjoining Community",
message,"settings?cmd=SX&sig=" + comm.getCommunityID(),"settings?cmd=S");
} // end else
} // end if ("SX" command)
if (cmd.equals("B"))
{ // "B" - Configure Sideboxes
try
{ // return the sidebox viewer
setMyLocation(request,"settings?cmd=B");
return new SideBoxList(engine,user);
} // end try
catch (DataException de)
{ // Database error getting sidebox list
return new ErrorBox("Database Error","Error getting sidebox list: " + de.getMessage(),"top");
} // end catch
} // end if ("B" command)
if (cmd.equals("BU") || cmd.equals("BD") || cmd.equals("BX"))
{ // move sidebox up or down in list, or delete it
int boxid = getBoxIDParameter(request);
try
{ // get the box ID, find it in the list
List sidebox_list = user.getSideBoxList();
UserSideBoxDescriptor prev = null;
UserSideBoxDescriptor curr = null;
Iterator it = sidebox_list.iterator();
boolean found = false;
while (!found && it.hasNext())
{ // track the previous descriptor so we can do the swap
prev = curr;
curr = (UserSideBoxDescriptor)(it.next());
if (curr.getID()==boxid)
{ // found it - trip the loop exit
found = true;
if (cmd.equals("BD"))
{ // make "prev" actually be the NEXT descriptor
if (it.hasNext())
prev = (UserSideBoxDescriptor)(it.next());
else
prev = null;
} // end if
} // end if (found)
} // end while
if (found)
{ // the current one needs to be operated on
if (cmd.equals("BX"))
curr.remove(); // remove the "current" sidebox
else if (prev!=null)
{ // exchange the sequence numbers of "curr" and "prev"
int seq_curr = curr.getSequence();
int seq_prev = prev.getSequence();
curr.setSequence(seq_prev); // do the first "set"
boolean restore = true;
try
{ // do the second "set"
prev.setSequence(seq_curr);
restore = false;
} // end try
finally
{ // restore first if second failed
if (restore)
curr.setSequence(seq_curr);
} // end finally
} // end else if
// else just fall out and do nothing
} // end if
// else just fall out and don't do anything
} // end try
catch (DataException de)
{ // there was a data problem
return new ErrorBox("Database Error","Error adjusting sidebox list: " + de.getMessage(),
"settings?cmd=B");
} // end catch
try
{ // return the sidebox viewer
setMyLocation(request,"settings?cmd=B");
return new SideBoxList(engine,user);
} // end try
catch (DataException de)
{ // Database error getting sidebox list
return new ErrorBox("Database Error","Error getting sidebox list: " + de.getMessage(),"top");
} // end catch
} // end if ("BD"/"BU"/"BX" commands)
// command not found!
logger.error("invalid command to Settings.doGet: " + cmd);
return new ErrorBox("Internal Error","Invalid command to Settings.doGet","top");
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
String cmd = getStandardCommandParam(request);
if (cmd.equals("BA"))
{ // "BA" - add new sidebox
int boxid = getBoxIDParameter(request);
try
{ // add the sidebox
user.addSideBox(boxid);
} // end try
catch (DataException de)
{ // error adding to sideboxes
return new ErrorBox("Database Error","Error adding to sidebox list: " + de.getMessage(),
"settings?cmd=B");
} // end catch
try
{ // return the sidebox viewer
setMyLocation(request,"settings?cmd=B");
return new SideBoxList(engine,user);
} // end try
catch (DataException de)
{ // Database error getting sidebox list
return new ErrorBox("Database Error","Error getting sidebox list: " + de.getMessage(),"top");
} // end catch
} // end if ("BA" command)
// command not found!
logger.error("invalid command to Settings.doGet: " + cmd);
return new ErrorBox("Internal Error","Invalid command to Settings.doGet","top");
} // end doVenicePost
} // end class Settings

View File

@@ -1,62 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.servlets.format.RenderConfig;
import com.silverwrist.venice.servlets.format.RenderData;
public class StyleSheet extends HttpServlet
{
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "StyleSheet applet - Generates a Cascading Stylesheet for Venice's use\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
ServletContext ctxt = getServletContext();
RenderData rdat = RenderConfig.createRenderData(ctxt,request,response);
String stylesheet = Variables.getStyleSheetData(ctxt,rdat);
if (stylesheet!=null)
{ // send back the stylesheet
response.setContentType("text/css");
response.setContentLength(stylesheet.length());
PrintWriter out = response.getWriter();
out.write(stylesheet);
out.flush();
response.flushBuffer();
} // end if
else // no stylesheet data
response.sendError(HttpServletResponse.SC_NOT_FOUND,"stylesheets not enabled");
} // end doGet
} // end class StyleSheet

View File

@@ -1,474 +0,0 @@
/*
* 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.ServletMultipartHandler;
import com.silverwrist.util.ServletMultipartException;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class SystemAdmin extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(SystemAdmin.class);
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private SystemAdminTop makeSystemAdminTop() throws ServletException
{
final String desired_name = "SystemAdminTop";
MenuPanelCache cache = MenuPanelCache.getMenuPanelCache(getServletContext());
if (!(cache.isCached(desired_name)))
{ // create a template and save it off
SystemAdminTop template = new SystemAdminTop();
cache.saveTemplate(template);
} // end if
// return a new copy
return (SystemAdminTop)(cache.getNewMenuPanel(desired_name));
} // end makeSystemAdminTop
private AdminModifyUserDialog makeAdminModifyUserDialog() throws ServletException
{
final String desired_name = "AdminModifyUserDialog";
DialogCache cache = DialogCache.getDialogCache(getServletContext());
if (!(cache.isCached(desired_name)))
{ // create a template and save it off
AdminModifyUserDialog template = new AdminModifyUserDialog();
cache.saveTemplate(template);
} // end if
// return a new copy
return (AdminModifyUserDialog)(cache.getNewDialog(desired_name));
} // end makeAdminModifyUserDialog
private EditGlobalPropertiesDialog makeGlobalPropertiesDialog(SecurityInfo sinf) throws ServletException
{
final String desired_name = "EditGlobalPropertiesDialog";
DialogCache cache = DialogCache.getDialogCache(getServletContext());
if (!(cache.isCached(desired_name)))
{ // create a template and save it off
EditGlobalPropertiesDialog template = new EditGlobalPropertiesDialog(sinf);
cache.saveTemplate(template);
} // end if
// return a new copy
return (EditGlobalPropertiesDialog)(cache.getNewDialog(desired_name));
} // end makeGlobalPropertiesDialog
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "SystemAdmin servlet - Administrative functions for the entire system\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// decide what to do based on the "cmd" parameter
String cmd = getStandardCommandParam(request);
if (logger.isDebugEnabled())
logger.debug("SystemAdmin/doGet command value = " + cmd);
if (cmd.equals("A"))
{ // "A" = View System Audit Records
try
{ // get the list of audit records
AdminOperations adm = user.getAdminInterface();
int offset = 0;
try
{ // convert the offset parameter
String s_ofs = request.getParameter("ofs");
if (!StringUtil.isStringEmpty(s_ofs))
offset = Integer.parseInt(s_ofs);
} // end try
catch (NumberFormatException nfe)
{ // if it's untranslatable, set it at 0
offset = 0;
} // end catch
// generate the lists
List audit_list = adm.getAuditRecords(offset,engine.getNumAuditRecordsPerPage());
int audit_count = adm.getAuditRecordCount();
// return the audit viewer
setMyLocation(request,"sysadmin?cmd=A&ofs=" + offset);
return new AuditDataViewer(engine,audit_list,offset,audit_count,"System Audit Records",
"sysadmin?cmd=A&ofs=%");
} // end try
catch (AccessError ae)
{ // an access error generally means we're not an administrator
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
} // end catch
catch (DataException de)
{ // error pulling the audit records
return new ErrorBox("Database Error","Unable to retrieve audit records: " + de.getMessage(),
"sysadmin");
} // end catch
} // end if ("A" command)
if (cmd.equals("UF"))
{ // "UF" = "User Find" - the initial screen of User Account Management
if (!(user.hasAdminAccess()))
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
// prepare and load the display
AdminFindUser afu = new AdminFindUser(engine);
afu.loadGet();
setMyLocation(request,"sysadmin?cmd=UF");
return afu;
} // end if ("UF" command)
if (cmd.equals("UM"))
{ // "UM" = "User Modify" - the second screen of user account management
try
{ // get the user to be modified
AdminOperations adm = user.getAdminInterface();
String s_uid = request.getParameter("uid");
if (s_uid==null)
throw new ErrorBox(null,"User ID parameter not found.","sysadmin?cmd=UF");
AdminUserContext admuser = adm.getUserContext(Integer.parseInt(s_uid));
AdminModifyUserDialog dlg = makeAdminModifyUserDialog();
dlg.setupDialog(adm,admuser);
setMyLocation(request,"sysadmin?cmd=UM");
return dlg;
} // end try
catch (AccessError ae)
{ // an access error generally means we're not an administrator
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
} // end catch
catch (DataException de)
{ // error pulling the audit records
return new ErrorBox("Database Error","Unable to retrieve user information: " + de.getMessage(),
"sysadmin?cmd=UF");
} // end catch
catch (NumberFormatException nfe)
{ // this is if we get a bogus UID
return new ErrorBox(null,"Invalid user ID parameter.","sysadmin?cmd=UF");
} // end catch
} // end if ("UM" command)
if (cmd.equals("G"))
{ // "G" = Edit Global Properties
try
{ // get the global properties
AdminOperations adm = user.getAdminInterface();
EditGlobalPropertiesDialog dlg = makeGlobalPropertiesDialog(adm.getSecurityInfo());
dlg.setupDialog(adm);
setMyLocation(request,"sysadmin?cmd=G");
return dlg;
} // end try
catch (AccessError ae)
{ // an access error generally means we're not an administrator
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
} // end catch
} // end if ("G" command)
if (cmd.equals("IMP"))
{ // "IMP" = "Import Users"
try
{ // get the import dialog
AdminImportUser rc = new AdminImportUser(user.getAdminInterface(),false);
setMyLocation(request,"sysadmin?cmd=IMP");
return rc;
} // end try
catch (AccessError ae)
{ // an access error generally means we're not an administrator
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
} // end catch
} // end if ("IMP" command)
// TODO: other command handling
if (!(user.hasAdminAccess()))
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
setMyLocation(request,"sysadmin");
return makeSystemAdminTop();
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// decide what to do based on the "cmd" parameter
String cmd = getStandardCommandParam(request);
if (logger.isDebugEnabled())
logger.debug("SystemAdmin/doPost command value = " + cmd);
if (cmd.equals("UF"))
{ // "UF" = "User Find" - the initial screen of User Account Management
if (!(user.hasAdminAccess()))
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
try
{ // prepare and load the display
AdminFindUser afu = new AdminFindUser(engine);
afu.loadPost(request);
setMyLocation(request,"sysadmin?cmd=UF");
return afu;
} // end try
catch (DataException de)
{ // catch a database error and return it
return new ErrorBox("Database Error","Database error on find: " + de.getMessage(),"sysadmin?cmd=UF");
} // end catch
catch (ValidationException ve)
{ // there was a validation error
return new ErrorBox("Find Error",ve.getMessage(),"sysadmin?cmd=UF");
} // end catch
} // end if ("UF" command)
if (cmd.equals("UM"))
{ // "UM" = "User Modify" - the second screen of user account management
try
{ // get the dialog box
AdminModifyUserDialog dlg = makeAdminModifyUserDialog();
if (dlg.isButtonClicked(request,"cancel"))
throw new RedirectResult("sysadmin?cmd=UF"); // we decided not to bother - go back
if (dlg.isButtonClicked(request,"update"))
{ // get the user to be modified
AdminOperations adm = user.getAdminInterface();
String s_uid = request.getParameter("uid");
if (s_uid==null)
throw new ErrorBox(null,"User ID parameter not found.","sysadmin?cmd=UF");
AdminUserContext admuser = adm.getUserContext(Integer.parseInt(s_uid));
dlg.loadValues(request); // load field values
try
{ // execute the dialog!
dlg.doDialog(admuser);
throw new RedirectResult("sysadmin?cmd=UF");
} // end try
catch (ValidationException ve)
{ // this is a simple error
dlg.resetOnError(adm,admuser,ve.getMessage() + " Please try again.");
setMyLocation(request,"sysadmin?cmd=UM");
return dlg;
} // end catch
} // end if
else
{ // the button must be wrong!
logger.error("no known button click on SystemAdmin.doPost, cmd=UF");
return new ErrorBox("Internal Error","Unknown command button pressed","sysadmin?cmd=UF");
} // end else
} // end try
catch (AccessError ae)
{ // an access error generally means we're not an administrator
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
} // end catch
catch (DataException de)
{ // error pulling the audit records
return new ErrorBox("Database Error","Unable to retrieve user information: " + de.getMessage(),
"sysadmin?cmd=UF");
} // end catch
catch (NumberFormatException nfe)
{ // this is if we get a bogus UID
return new ErrorBox(null,"Invalid user ID parameter.","sysadmin?cmd=UF");
} // end catch
} // end if ("UM" command)
if (cmd.equals("G"))
{ // "G" - Edit Global Properties
try
{ // get the dialog box
EditGlobalPropertiesDialog dlg = makeGlobalPropertiesDialog(engine.getSecurityInfo());
if (dlg.isButtonClicked(request,"cancel"))
throw new RedirectResult("sysadmin"); // we decided not to bother - go back
if (dlg.isButtonClicked(request,"update"))
{ // update the system properties
AdminOperations adm = user.getAdminInterface();
dlg.loadValues(request);
try
{ // execute the dialog!
dlg.doDialog(adm);
throw new RedirectResult("sysadmin");
} // end try
catch (ValidationException ve)
{ // validation error - retry the dialog
dlg.setErrorMessage(ve.getMessage() + " Please try again.");
setMyLocation(request,"sysadmin?cmd=G");
return dlg;
} // end catch
} // end if
else
{ // the button must be wrong!
logger.error("no known button click on SystemAdmin.doPost, cmd=G");
return new ErrorBox("Internal Error","Unknown command button pressed","sysadmin?cmd=UF");
} // end else
} // end try
catch (AccessError ae)
{ // an access error generally means we're not an administrator
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
} // end catch
catch (DataException de)
{ // error pulling the audit records
return new ErrorBox("Database Error","Unable to update global properties: " + de.getMessage(),
"sysadmin");
} // end catch
} // end if ("G" command)
// TODO: other command handling
if (!(user.hasAdminAccess()))
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
setMyLocation(request,"sysadmin");
return makeSystemAdminTop();
} // end doVenicePost
protected VeniceContent doVenicePost(HttpServletRequest request, ServletMultipartHandler mphandler,
VeniceEngine engine, UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// decide what to do based on the "cmd" parameter
String cmd = getStandardCommandParam(mphandler);
if (logger.isDebugEnabled())
logger.debug("SystemAdmin/doPost command value = " + cmd);
if (cmd.equals("IMP"))
{ // "IMP" = "Import User Accounts"
try
{ // get the administrative interface and then check the buttons
AdminOperations adm = user.getAdminInterface();
if (isImageButtonClicked(mphandler,"cancel"))
throw new RedirectResult("sysadmin"); // we decided not to bother - go back
if (!isImageButtonClicked(mphandler,"upload"))
{ // the button must be wrong!
logger.error("no known button click on SystemAdmin.doPost, cmd=IMP");
return new ErrorBox("Internal Error","Unknown command button pressed","sysadmin");
} // end if
if (!(mphandler.isFileParam("idata")))
return new ErrorBox("Internal Error","Invalid input file parameter.","sysadmin");
// create the view object and use it to execute the operation
AdminImportUser rc = new AdminImportUser(user.getAdminInterface(),true);
rc.execute(mphandler.getFileContentStream("idata"));
setMyLocation(request,"sysadmin?cmd=IMP");
return rc;
} // end try
catch (AccessError ae)
{ // an access error generally means we're not an administrator
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
} // end catch
catch (ServletMultipartException smpe)
{ // error loading the data stream
return new ErrorBox("Internal Error","Error loading post data: " + smpe.getMessage(),"sysadmin");
} // end catch
} // end if
// TODO: other command handling
if (!(user.hasAdminAccess()))
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
setMyLocation(request,"sysadmin");
return makeSystemAdminTop();
} // end doVenicePost
} // end class SystemAdmin

View File

@@ -1,102 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import org.apache.log4j.xml.DOMConfigurator;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class Top extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public void init(ServletConfig config) throws ServletException
{
super.init(config); // required before we do anything else
ServletContext ctxt = config.getServletContext();
String root_file_path = ctxt.getRealPath("/");
if (!(root_file_path.endsWith("/")))
root_file_path += "/";
// Initialize LOG4J logging.
String lconf = ctxt.getInitParameter("logging.config");
if (!(lconf.startsWith("/")))
lconf = root_file_path + lconf;
DOMConfigurator.configure(lconf);
// Initialize the Venice engine.
VeniceEngine engine = Variables.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 Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
changeMenuTop(request);
setMyLocation(request,"top");
try
{ // attempt to get the user content
return new TopDisplay(getServletContext(),engine,user);
} // end try
catch (DataException de)
{ // there was a database error, whoops!
return new ErrorBox("Database Error","Error loading front page: " + de.getMessage(),null);
} // end catch
catch (AccessError ae)
{ // there was an access error, whoops!
return new ErrorBox("Access Error",ae.getMessage(),null);
} // end catch
} // end doVeniceGet
} // end class Top

View File

@@ -1,252 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class TopicOperations extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static final String DELETE_CONFIRM_ATTR = "servlets.TopicOperations.delete.confirm";
private static final String DELETE_CONFIRM_PARAM = "confirm";
private static Category logger = Category.getInstance(TopicOperations.class.getName());
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "TopicOperations servlet - General topic operations (freeze, archive, etc.)\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// get the community
CommunityContext comm = getCommunityParameter(request,user,true,"top");
changeMenuCommunity(request,comm);
String locator = "sig=" + comm.getCommunityID();
String location = "sigprofile?" + locator;
// get the conference
ConferenceContext conf = getConferenceParameter(request,comm,true,location);
locator += "&conf=" + conf.getConfID();
location = "confdisp?" + locator;
// get the topic
TopicContext topic = getTopicParameter(request,conf,true,location);
locator += "&top=" + topic.getTopicNumber();
location = "confdisp?" + locator;
// figure out what command we want to perform...
String cmd = getStandardCommandParam(request);
if (cmd.equals("HY") || cmd.equals("HN"))
{ // we want to set the hide status of the topic
try
{ // call down to set the topic!
topic.setHidden(cmd.equals("HY"));
} // end try
catch (DataException de)
{ // there was a database error
return new ErrorBox("Database Error","Database error setting hide status: " + de.getMessage(),
location);
} // end catch
// go back to the topic view
throw new RedirectResult(location);
} // end if ("hide" or "show")
if (cmd.equals("FY") || cmd.equals("FN"))
{ // we want to set the frozen status of the topic
try
{ // call down to set the topic!
topic.setFrozen(cmd.equals("FY"));
} // end try
catch (DataException de)
{ // there was a database error
return new ErrorBox("Database Error","Database error setting freeze status: " + de.getMessage(),
location);
} // end catch
catch (AccessError ae)
{ // naughty naughty = you can't do this!
return new ErrorBox("Access Error",ae.getMessage(),location);
} // end catch
// go back to the topic view
throw new RedirectResult(location);
} // end if ("freeze" or "unfreeze")
if (cmd.equals("AY") || cmd.equals("AN"))
{ // we want to change the archived status of the topic
try
{ // call down to set the topic!
topic.setArchived(cmd.equals("AY"));
} // end try
catch (DataException de)
{ // there was a database error
return new ErrorBox("Database Error","Database error setting archive status: " + de.getMessage(),
location);
} // end catch
catch (AccessError ae)
{ // naughty naughty = you can't do this!
return new ErrorBox("Access Error",ae.getMessage(),location);
} // end catch
// go back to the topic view
throw new RedirectResult(location);
} // end if ("archive" or "unarchive")
if (cmd.equals("DEL"))
{ // Delete Topic requires a confirmation!
if (ConfirmBox.isConfirmed(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM))
{ // OK, go ahead, delete the topic!
location = "confdisp?sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID();
try
{ // delete the bloody topic!
topic.delete();
} // end try
catch (DataException de)
{ // there was a database error
return new ErrorBox("Database Error","Database error deleting topic: " + de.getMessage(),location);
} // end catch
catch (AccessError ae)
{ // naughty naughty = you can't do this!
return new ErrorBox("Access Error",ae.getMessage(),location);
} // end catch
// go back to the conference view
throw new RedirectResult(location);
} // end if (confirmed)
else
{ // not a proper confirmation - better display one
String message = "You are about to delete topic " + String.valueOf(topic.getTopicNumber())
+ " from the \"" + conf.getName() + "\" conference! Are you sure you want to do this?";
return new ConfirmBox(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM,"Delete Topic",message,
"topicops?" + locator + "&cmd=DEL",location);
} // end else
} // end if (delete)
if (cmd.equals("RB"))
{ // "RB" = "Remove Bozo" (UID specified as parameter "u")
int uid = -1;
try
{ // get the user ID to un-bozo
String foo = request.getParameter("u");
if (foo!=null)
uid = Integer.parseInt(foo);
} // end try
catch (NumberFormatException nfe)
{ // just don't do anything on error
uid = -1;
} // end catch
try
{ // remove "bozo" status from this user
if (uid>0)
topic.setBozo(uid,false);
setMyLocation(request,"topicops?" + locator);
return new ManageTopic(user,comm,conf,topic);
} // end try
catch (DataException de)
{ // whoops! this is a problem!
return new ErrorBox("Database Error","Database error removing filtered user: " + de.getMessage(),
"topicops?" + locator);
} // end catch
} // end if (remove bozo)
if (cmd.equals("SY") || cmd.equals("SN"))
{ // "SY", "SN" - Set subscription status
try
{ // call down to set the topic!
topic.setSubscribed(cmd.equals("SY"));
setMyLocation(request,"topicops?" + locator);
return new ManageTopic(user,comm,conf,topic);
} // end try
catch (DataException de)
{ // there was a database error
return new ErrorBox("Database Error","Database error setting subscription status: " + de.getMessage(),
location);
} // end catch
} // end if (subscription control)
// unrecognized command - load the "Manage Topic menu"
try
{ // return that "Manage Topic" page
setMyLocation(request,"topicops?" + locator);
return new ManageTopic(user,comm,conf,topic);
} // end try
catch (DataException de)
{ // whoops! this is a problem!
return new ErrorBox("Database Error","Database error loading manage page: " + de.getMessage(),location);
} // end catch
} // end doVeniceGet
} // end class TopicOperations

View File

@@ -1,142 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class UserDisplay extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(UserDisplay.class);
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "UserDisplay servlet - Displays Venice user profiles\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
String uname = request.getPathInfo().substring(1); // the username we're looking at
try
{ // load the profile corresponding to that username and display it
UserProfile prof = user.getProfile(uname);
changeMenuTop(request);
setMyLocation(request,"user" + request.getPathInfo());
return new UserProfileData(engine,prof);
} // end try
catch (DataException de)
{ // unable to get the user name
return new ErrorBox("Database Error","Database error finding user: " + de.getMessage(),"top");
} // end catch
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
String uname = request.getPathInfo().substring(1); // the username we're looking at
UserProfile prof;
String on_error;
if (logger.isDebugEnabled())
logger.debug("Posting to profile: " + uname);
try
{ // load the profile corresponding to that username and display it
prof = user.getProfile(uname);
on_error = "user/" + prof.getUserName();
} // end try
catch (DataException de)
{ // unable to get the user name
logger.error("error retrieving user profile: " + de.getMessage(),de);
return new ErrorBox("Database Error","Database error finding user: " + de.getMessage(),"top");
} // end catch
String cmd = getStandardCommandParam(request);
if (cmd.equals("E"))
{ // send a quick email message - let's do it!
if (logger.isDebugEnabled())
logger.debug("sending quick email message");
try
{ // send a quick email message...
prof.sendQuickEmail(request.getParameter("subj"),request.getParameter("pb"));
} // end try
catch (AccessError ae)
{ // throw an access error box
logger.error("access error sending email: " + ae.getMessage(),ae);
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // database error
logger.error("database error sending email: " + de.getMessage(),de);
return new ErrorBox("Database Error","Database error sending message: " + de.getMessage(),on_error);
} // end catch
catch (EmailException ee)
{ // error sending the actual email
logger.error("email exception: " + ee.getMessage(),ee);
return new ErrorBox("E-Mail Error","Error sending e-mail: " + ee.getMessage(),on_error);
} // end catch
} // end if
if (logger.isDebugEnabled())
logger.debug("redisplaying profile window");
changeMenuTop(request);
setMyLocation(request,"user" + request.getPathInfo());
return new UserProfileData(engine,prof);
} // end doVenicePost
} // end class UserDisplay

View File

@@ -1,174 +0,0 @@
/*
* 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.net.URLEncoder;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.util.ServletMultipartHandler;
import com.silverwrist.util.ServletMultipartException;
import com.silverwrist.util.image.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public class UserPhoto extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(UserPhoto.class);
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public String getServletInfo()
{
String rc = "UserPhoto servlet - changes the user photo for a user\n"
+ "Part of the Venice Web Communities System\n";
return rc;
} // end getServletInfo
/*--------------------------------------------------------------------------------
* Overrides from class VeniceServlet
*--------------------------------------------------------------------------------
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
String tgt = request.getParameter("tgt"); // target location
if (tgt==null)
tgt = "top"; // go back to the Top screen if nothing else
try
{ // create the display
return new UserPhotoData(engine,user,rdat,tgt);
} // end try
catch (DataException de)
{ // error getting at the data stream from the attachment
return new ErrorBox("Database Error","Database error generating display: " + de.getMessage(),null);
} // end catch
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, ServletMultipartHandler mphandler,
VeniceEngine engine, UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
// Get target URL for the operation
if (mphandler.isFileParam("tgt"))
{ // bogus target URL
logger.error("Internal Error: 'tgt' should be a normal param");
return new ErrorBox(null,"Internal Error: 'tgt' should be a normal param","top");
} // end if
String tgt = mphandler.getValue("tgt");
if (tgt==null)
tgt = "top"; // go back to the Top screen if nothing else
if (isImageButtonClicked(mphandler,"cancel"))
throw new RedirectResult("account?cmd=P&tgt=" + URLEncoder.encode(tgt));
if (isImageButtonClicked(mphandler,"upload"))
{ // uploading the image here!
// also check on file parameter status
if (!(mphandler.isFileParam("thepic")))
{ // bogus file parameter
logger.error("Internal Error: 'thepic' should be a file param");
return new ErrorBox(null,"Internal Error: 'thepic' should be a file param",
"account?cmd=P&tgt=" + URLEncoder.encode(tgt));
} // end if
if (!(mphandler.getContentType("thepic").startsWith("image/")))
{ // must be an image type we uploaded!
logger.error("Error: 'thepic' not an image type");
return new ErrorBox(null,"You did not upload an image file. Try again.",
"userphoto?tgt=" + URLEncoder.encode(tgt));
} // end if
try
{ // get the real picture (normalized to 100x100 size)
ImageLengthPair real_pic = ImageNormalizer.normalizeImage(mphandler.getFileContentStream("thepic"),
engine.getUserPhotoSize(),"jpeg");
// set the user photo data!
ContactInfo ci = user.getContactInfo();
ci.setPhotoData(request.getContextPath() + "/imagedata/","image/jpeg",real_pic.getLength(),
real_pic.getData());
user.putContactInfo(ci);
// Jump back to the profile form.
throw new RedirectResult("account?cmd=P&tgt=" + URLEncoder.encode(tgt));
} // end try
catch (ServletMultipartException smpe)
{ // the servlet multipart parser screwed up
logger.error("Servlet multipart error:",smpe);
return new ErrorBox(null,"Internal Error: " + smpe.getMessage(),
"account?cmd=P&tgt=" + URLEncoder.encode(tgt));
} // end catch
catch (ImageNormalizerException ine)
{ // the image was not valid
logger.error("Image normalizer error:",ine);
return new ErrorBox(null,ine.getMessage(),"userphoto?tgt=" + URLEncoder.encode(tgt));
} // end catch
catch (DataException de)
{ // error in the database!
logger.error("DataException:",de);
return new ErrorBox("Database Error","Database error storing user photo: " + de.getMessage(),
"account?cmd=P&tgt=" + URLEncoder.encode(tgt));
} // end catch
catch (EmailException ee)
{ // email exception (WTF?)
logger.error("Email exception (shouldn't happen):",ee);
return new ErrorBox(null,"Internal Error: " + ee.getMessage(),
"account?cmd=P&tgt=" + URLEncoder.encode(tgt));
} // end catch
} // end if
else
{ // the button must be wrong!
logger.error("no known button click on UserPhoto.doPost");
return new ErrorBox("Internal Error","Unknown command button pressed",
"account?cmd=P&tgt=" + URLEncoder.encode(tgt));
} // end else
} // end doVenicePost
} // end class UserPhoto

View File

@@ -1,312 +0,0 @@
/*
* 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.lang.ref.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
import com.silverwrist.venice.servlets.format.menus.*;
public class Variables
{
/*--------------------------------------------------------------------------------
* Static data values
*--------------------------------------------------------------------------------
*/
// ServletContext ("application") attributes
protected static final String ENGINE_ATTRIBUTE = "com.silverwrist.venice.core.Engine";
protected static final String STYLESHEET_ATTRIBUTE = "com.silverwrist.venice.rendering.StyleSheet";
// HttpSession ("session") attributes
protected static final String USERCTXT_ATTRIBUTE = "user.context";
protected static final String MENU_ATTRIBUTE = "current.menu";
// ServletRequest ("request" attributes)
protected static final String COOKIEJAR_ATTRIBUTE = "com.silverwrist.venice.servlets.CookieJar";
// Servlet initialization parameters
protected static final String ENGINE_INIT_PARAM = "venice.config";
// Cookie name
public static final String LOGIN_COOKIE = "VeniceAuth";
private static Category logger = Category.getInstance(Variables.class);
private static Integer engine_gate = new Integer(0);
/*--------------------------------------------------------------------------------
* External static operations
*--------------------------------------------------------------------------------
*/
public static VeniceEngine getVeniceEngine(ServletContext ctxt) throws ServletException
{
synchronized (engine_gate)
{ // we must synchronize efforts to access the engine
Object foo = ctxt.getAttribute(ENGINE_ATTRIBUTE);
if (foo!=null)
return (VeniceEngine)foo;
String root_file_path = ctxt.getRealPath("/");
if (!(root_file_path.endsWith("/")))
root_file_path += "/";
String cfgfile = ctxt.getInitParameter(ENGINE_INIT_PARAM); // get the config file name
if (!(cfgfile.startsWith("/")))
cfgfile = root_file_path + cfgfile;
logger.info("Initializing Venice engine using config file: " + cfgfile);
try
{ // extract the configuration file name and create the engine
VeniceEngine engine = Startup.createEngine(cfgfile,root_file_path);
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 synchronized block
} // end getVeniceEngine
public static UserContext getUserContext(ServletContext ctxt, HttpServletRequest 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());
// Did the user send a Venice authentication cookie? If so, try to use it.
Cookie[] cookies = request.getCookies();
Cookie venice_cookie = null;
for (int i=0; (venice_cookie==null) && (i<cookies.length); i++)
{ // look for a Venice authentication cookie
if (LOGIN_COOKIE.equals(cookies[i].getName()))
venice_cookie = cookies[i];
} // end for
if (venice_cookie!=null)
{ // we've found the cookie - now attempt to authenticate with it
if (!(user.authenticateWithToken(venice_cookie.getValue())))
{ // the authentication failed - this cookie MUST be bogus, delete it!
Cookie zapper = new Cookie(LOGIN_COOKIE,"");
zapper.setMaxAge(0);
zapper.setPath(request.getContextPath());
saveCookie(request,zapper);
} // end if
// else we're authenticated - let the cookie stay!
} // end if
// else don't bother trying to authenticate
// save the user context off as usual and return it
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 ComponentRender getMenu(HttpSession session)
{
return (ComponentRender)(session.getAttribute(MENU_ATTRIBUTE));
} // end getMenu
public static void setMenuTop(ServletContext ctxt, HttpSession session)
{
Object obj = session.getAttribute(MENU_ATTRIBUTE);
boolean do_change;
if ((obj==null) || !(obj instanceof LeftMenu))
do_change = true;
else
{ // look to see if this is the "top" menu
LeftMenu mnu = (LeftMenu)obj;
do_change = !(mnu.getIdentifier().equals("top"));
} // end else
if (do_change)
{ // get the new menu from the RenderConfig object and save it
try
{ // but note that getting the rendering configuration can throw a ServletException
RenderConfig cfg = RenderConfig.getRenderConfig(ctxt);
LeftMenu new_mnu = cfg.getLeftMenu("top");
session.setAttribute(MENU_ATTRIBUTE,new_mnu);
} // end try
catch (ServletException e)
{ // if we fail, just clear it out
logger.warn("caught ServletException in setMenuTop",e);
session.removeAttribute(MENU_ATTRIBUTE);
} // end catch
} // end if
} // end setMenuTop
public static void setMenuCommunity(ServletContext ctxt, HttpSession session, CommunityContext comm)
{
Object obj = session.getAttribute(MENU_ATTRIBUTE);
boolean do_change;
if ((obj==null) || !(obj instanceof CommunityLeftMenu))
do_change = true;
else
{ // look at the actual community IDs underlying the MenuCommunity
CommunityLeftMenu tmp = (CommunityLeftMenu)obj;
do_change = (tmp.getID()!=comm.getCommunityID());
} // end else
if (do_change)
{ // switch to the appropriate CommunityLeftMenu
try
{ // but note that getting the rendering configuration can throw a ServletException
RenderConfig cfg = RenderConfig.getRenderConfig(ctxt);
CommunityLeftMenu menu = cfg.createCommunityMenu(comm);
session.setAttribute(MENU_ATTRIBUTE,menu);
} // end try
catch (ServletException e)
{ // if we fail, just clear it out
logger.warn("caught ServletException in setMenuCommunity",e);
session.removeAttribute(MENU_ATTRIBUTE);
} // end catch
} // end if
} // end setMenuCommunity
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
public static void saveCookie(ServletRequest request, Cookie cookie)
{
ArrayList cookiejar = null;
Object o = request.getAttribute(COOKIEJAR_ATTRIBUTE);
if ((o==null) || !(o instanceof ArrayList))
{ // create a new cookie jar and save it
cookiejar = new ArrayList();
request.setAttribute(COOKIEJAR_ATTRIBUTE,cookiejar);
} // end if
else // found our cookie jar
cookiejar = (ArrayList)o;
// save the cookie in the cookie jar (to be flushed later)
cookiejar.add(cookie);
} // end saveCookie
public static void flushCookies(ServletRequest request, HttpServletResponse response)
{
Object o = request.getAttribute(COOKIEJAR_ATTRIBUTE);
request.removeAttribute(COOKIEJAR_ATTRIBUTE);
if (o instanceof ArrayList)
{ // found the cookie jar - now take the cookies out and add them to the response
ArrayList cookiejar = (ArrayList)o;
Iterator it = cookiejar.iterator();
while (it.hasNext())
{ // add each cookie in turn
Cookie cookie = (Cookie)(it.next());
response.addCookie(cookie);
} // end while
} // end if
} // end flushCookies
public static String getStyleSheetData(ServletContext ctxt, RenderData rdat) throws IOException
{
if (!(rdat.useStyleSheet()))
return null;
String data = null;
SoftReference r = (SoftReference)(ctxt.getAttribute(STYLESHEET_ATTRIBUTE));
if (r!=null)
data = (String)(r.get());
if ((data==null) || rdat.hasStyleSheetChanged())
{ // construct or reconstruct the stylesheet data, save a soft reference to it
data = rdat.loadStyleSheetData();
r = new SoftReference(data);
ctxt.setAttribute(STYLESHEET_ATTRIBUTE,r);
} // end if
return data;
} // end getStyleSheetData
} // end class Variables

View File

@@ -1,758 +0,0 @@
/*
* 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.util.ServletMultipartHandler;
import com.silverwrist.util.ServletMultipartException;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.format.*;
public abstract class VeniceServlet extends HttpServlet
{
/*--------------------------------------------------------------------------------
* Static data values
*--------------------------------------------------------------------------------
*/
private static final String LOCATION_ATTR = "com.silverwrist.venice.servlets.internal.Location";
private static Category logger = Category.getInstance(VeniceServlet.class.getName());
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private static final void notSupported(HttpServletRequest request, String message) throws ErrorResult
{
String protocol = request.getProtocol();
if (protocol.endsWith("1.1"))
throw new ErrorResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED,message);
else
throw new ErrorResult(HttpServletResponse.SC_BAD_REQUEST,message);
} // end notSupported
private static final CommunityContext getCommunityParameter(String str, UserContext user, boolean required,
String on_error) throws ErrorBox
{
if (StringUtil.isStringEmpty(str))
{ // there's no community parameter
if (required)
{ // no communty parameter - bail out now!
logger.error("community parameter not specified!");
throw new ErrorBox(null,"No community specified.",on_error);
} // end if
else
{ // a null CommunityContext is permitted
logger.debug("no community specified");
return null;
} // end else
} // end if
CommunityContext rc = null;
try
{ // turn the string into a community ID, and thence to a CommunityContext
int tmp_id = Integer.parseInt(str);
rc = user.getCommunityContext(tmp_id);
if (rc==null)
{ // trap any null results (may not be possible with communities, but you never know)
logger.error("Community #" + tmp_id + " was not found!");
throw new ErrorBox(null,"The specified community (#" + tmp_id + ") was not found in the database.",
on_error);
} // end if
if (logger.isDebugEnabled())
logger.debug("found community #" + rc.getCommunityID());
} // end try
catch (NumberFormatException nfe)
{ // error in Integer.parseInt
logger.error("Cannot convert community parameter '" + str + "'!");
throw new ErrorBox(null,"Invalid community parameter.",on_error);
} // end catch
catch (DataException de)
{ // error looking up the community
throw new ErrorBox("Database Error","Database error finding community: " + de.getMessage(),on_error);
} // end catch
return rc;
} // end getCommunityParameter
private static TopicContext getTopicParameter(String str, UserContext user, ConferenceContext conf,
boolean required, String on_error, String target)
throws ErrorBox, LogInOrCreate
{
if (StringUtil.isStringEmpty(str))
{ // there's no topic parameter
if (required)
{ // no topic parameter - bail out now!
logger.error("Topic parameter not specified!");
throw new ErrorBox(null,"No topic specified.",on_error);
} // end if
else
{ // a null TopicContext is permitted
logger.debug("no topic specified");
return null;
} // end else
} // end if
TopicContext rc = null;
try
{ // turn the string into a topic number, and thence to a TopicContext
short tmp_id = Short.parseShort(str);
rc = conf.getTopic(tmp_id);
if (rc==null)
{ // the topic was not found!
logger.error("ConfID #" + conf.getConfID() + " did not have topic #" + tmp_id);
throw new ErrorBox(null,"Topic #" + tmp_id + " was not found in the '" + conf.getName()
+ "' conference.",on_error);
} // end if
if (logger.isDebugEnabled())
logger.debug("found topic #" + rc.getTopicID());
} // end try
catch (NumberFormatException nfe)
{ // error in Integer.parseInt
logger.error("Cannot convert topic parameter '" + str + "'!");
throw new ErrorBox(null,"Invalid topic parameter.",on_error);
} // end catch
catch (AccessError ae)
{ // these all get handled in pretty much the same way
logger.error("getTopicParameter(): Access error retrieving topic parameter");
if ((user!=null) && (target!=null) && !(user.isLoggedIn()))
throw new LogInOrCreate(target);
throw new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // error looking up the topic
throw new ErrorBox("Database Error","Database error finding topic: " + de.getMessage(),"top");
} // end catch
return rc;
} // end getTopicParameter
private static TopicMessageContext getMessageParameter(String str, ConferenceContext conf, boolean required,
String on_error) throws ErrorBox
{
if (StringUtil.isStringEmpty(str))
{ // there's no message parameter
if (required)
{ // no message parameter - bail out now!
logger.error("Message parameter not specified!");
throw new ErrorBox(null,"No message specified.",on_error);
} // end if
else
{ // a null TopicMessageContext is permitted
logger.debug("no message specified");
return null;
} // end else
} // end if
TopicMessageContext rc = null;
try
{ // turn the string into a postid, and thence to a TopicMessageContext
long tmp_id = Long.parseLong(str);
rc = conf.getMessageByPostID(tmp_id);
if (rc==null)
{ // the message was not found
logger.error("ConfID #" + conf.getConfID() + " does not contain postid " + tmp_id);
throw new ErrorBox(null,"The post with ID number " + tmp_id + " was not found in the '"
+ conf.getName() + "' conference.",on_error);
} // end if
if (logger.isDebugEnabled())
logger.debug("found post #" + rc.getPostID());
} // end try
catch (NumberFormatException nfe)
{ // error in Integer.parseInt
logger.error("Cannot convert message parameter '" + str + "'!");
throw new ErrorBox(null,"Invalid message parameter.",on_error);
} // end catch
catch (AccessError ae)
{ // these all get handled in pretty much the same way
throw new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // error looking up the conference
throw new ErrorBox("Database Error","Database error finding message: " + de.getMessage(),on_error);
} // end catch
return rc;
} // end getMessageParameter
private static TopicMessageContext getMessageParameter(String str, TopicContext topic, boolean required,
String on_error) throws ErrorBox
{
if (StringUtil.isStringEmpty(str))
{ // there's no message parameter
if (required)
{ // no message parameter - bail out now!
logger.error("Message parameter not specified!");
throw new ErrorBox(null,"No message specified.",on_error);
} // end if
else
{ // a null TopicMessageContext is permitted
logger.debug("no message specified");
return null;
} // end else
} // end if
TopicMessageContext rc = null;
try
{ // turn the string into a post number, and thence to a TopicMessageContext
int tmp_id = Integer.parseInt(str);
rc = topic.getMessage(tmp_id);
if (rc==null)
{ // could not find the message
logger.error("TopicID " + topic.getTopicID() + " does not contain message #" + tmp_id);
throw new ErrorBox(null,"There is no message #" + tmp_id + " in the '" + topic.getName() + "' topic.",
on_error);
} // end if
if (logger.isDebugEnabled())
logger.debug("found post #" + rc.getPostID());
} // end try
catch (NumberFormatException nfe)
{ // error in Integer.parseInt
logger.error("Cannot convert message parameter '" + str + "'!");
throw new ErrorBox(null,"Invalid message parameter.",on_error);
} // end catch
catch (AccessError ae)
{ // these all get handled in pretty much the same way
throw new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // error looking up the conference
throw new ErrorBox("Database Error","Database error finding message: " + de.getMessage(),on_error);
} // end catch
return rc;
} // end getMessageParameter
/*--------------------------------------------------------------------------------
* Internal operations intended for use by derived classes
*--------------------------------------------------------------------------------
*/
protected static final boolean isImageButtonClicked(ServletRequest request, String name)
{
String val = request.getParameter(name + ".x");
return (val!=null);
} // end isImageButtonClicked
protected static final boolean isImageButtonClicked(ServletMultipartHandler mphandler, String name)
{
String val = mphandler.getValue(name + ".x");
return (val!=null);
} // end isImageButtonClicked
protected final void putUserContext(HttpServletRequest request, UserContext ctxt)
{
Variables.putUserContext(request.getSession(true),ctxt);
} // end putUserContext
protected final void clearUserContext(HttpServletRequest request)
{
Variables.clearUserContext(request.getSession(true));
} // end clearUserContext
protected final void changeMenuTop(HttpServletRequest request)
{
Variables.setMenuTop(getServletContext(),request.getSession(true));
} // end changeMenuTop
protected final void changeMenuCommunity(HttpServletRequest request, CommunityContext comm)
{
Variables.setMenuCommunity(getServletContext(),request.getSession(true),comm);
} // end changeMenuCommunity
protected final void clearMenu(HttpServletRequest request)
{
Variables.clearMenu(request.getSession(true));
} // end clearMenu
protected final String getStandardCommandParam(ServletRequest request)
{
String foo = request.getParameter("cmd");
if (foo==null)
return "???";
else
return foo;
} // end getStandardCommandParam
protected final String getStandardCommandParam(ServletMultipartHandler mphandler) throws ErrorBox
{
if (mphandler.isFileParam("cmd"))
throw new ErrorBox(null,"Internal Error: command should be a normal param",null);
String foo = mphandler.getValue("cmd");
if (foo==null)
return "???";
else
return foo;
} // end getStandardCommandParam
protected final void setMyLocation(ServletRequest request, String loc)
{
request.setAttribute(LOCATION_ATTR,loc);
} // end setMyLocation
protected final static CommunityContext getCommunityParameter(ServletRequest request, UserContext user,
boolean required, String on_error)
throws ErrorBox
{
return getCommunityParameter(request.getParameter("sig"),user,required,on_error);
} // end getCommunityParameter
protected final static CommunityContext getCommunityParameter(ServletMultipartHandler mphandler,
UserContext user, boolean required,
String on_error) throws ErrorBox
{
if (mphandler.isFileParam("sig"))
throw new ErrorBox(null,"Internal Error: community should be a normal param",on_error);
return getCommunityParameter(mphandler.getValue("sig"),user,required,on_error);
} // end getCommunityParameter
protected static ConferenceContext getConferenceParameter(String str, CommunityContext comm,
boolean required, String on_error) throws ErrorBox
{
if (StringUtil.isStringEmpty(str))
{ // there's no conference parameter
if (required)
{ // no conference parameter - bail out now!
logger.error("Conference parameter not specified!");
throw new ErrorBox(null,"No conference specified.",on_error);
} // end if
else
{ // a null ConferenceContext is permitted
logger.debug("no conference specified");
return null;
} // end else
} // end if
ConferenceContext rc = null;
try
{ // turn the string into a ConfID, and thence to a ConferenceContext
int tmp_id = Integer.parseInt(str);
rc = comm.getConferenceContext(tmp_id);
if (rc==null)
{ // couldn't find the conference
logger.error("community #" + comm.getCommunityID() + " does not contain conference #" + tmp_id);
throw new ErrorBox(null,"The conference #" + tmp_id + " could not be found in the '" + comm.getName()
+ "' community.",on_error);
} // end if
if (logger.isDebugEnabled())
logger.debug("found conf #" + rc.getConfID());
} // end try
catch (NumberFormatException nfe)
{ // error in Integer.parseInt
logger.error("Cannot convert conference parameter '" + str + "'!");
throw new ErrorBox(null,"Invalid conference parameter.",on_error);
} // end catch
catch (AccessError ae)
{ // these all get handled in pretty much the same way
throw new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // error looking up the conference
throw new ErrorBox("Database Error","Database error finding conference: " + de.getMessage(),on_error);
} // end catch
return rc;
} // end getConferenceParameter
protected final static ConferenceContext getConferenceParameter(ServletRequest request,
CommunityContext comm, boolean required,
String on_error) throws ErrorBox
{
return getConferenceParameter(request.getParameter("conf"),comm,required,on_error);
} // end getConferenceParameter
protected final static ConferenceContext getConferenceParameter(ServletMultipartHandler mphandler,
CommunityContext comm, boolean required,
String on_error) throws ErrorBox
{
if (mphandler.isFileParam("conf"))
throw new ErrorBox(null,"Internal Error: conference should be a normal param",on_error);
return getConferenceParameter(mphandler.getValue("conf"),comm,required,on_error);
} // end getConferenceParameter
protected final static TopicContext getTopicParameter(ServletRequest request, ConferenceContext conf,
boolean required, String on_error)
throws ErrorBox, LogInOrCreate
{
return getTopicParameter(request.getParameter("top"),null,conf,required,on_error,null);
} // end getTopicParameter
protected final static TopicContext getTopicParameter(ServletRequest request, UserContext user,
ConferenceContext conf, boolean required,
String on_error, String target)
throws ErrorBox, LogInOrCreate
{
return getTopicParameter(request.getParameter("top"),user,conf,required,on_error,target);
} // end getTopicParameter
protected final static TopicContext getTopicParameter(ServletMultipartHandler mphandler,
ConferenceContext conf, boolean required,
String on_error) throws ErrorBox, LogInOrCreate
{
if (mphandler.isFileParam("top"))
throw new ErrorBox(null,"Internal Error: topic should be a normal param",on_error);
return getTopicParameter(mphandler.getValue("top"),null,conf,required,on_error,null);
} // end getTopicParameter
protected final static TopicMessageContext getMessageParameter(ServletRequest request,
ConferenceContext conf, boolean required,
String on_error) throws ErrorBox
{
return getMessageParameter(request.getParameter("msg"),conf,required,on_error);
} // end getMessageParameter
protected final static TopicMessageContext getMessageParameter(ServletMultipartHandler mphandler,
ConferenceContext conf, boolean required,
String on_error) throws ErrorBox
{
if (mphandler.isFileParam("msg"))
throw new ErrorBox(null,"Internal Error: message should be a normal param",on_error);
return getMessageParameter(mphandler.getValue("msg"),conf,required,on_error);
} // end getMessageParameter
protected final static TopicMessageContext getMessageParameter(ServletRequest request, TopicContext topic,
boolean required, String on_error)
throws ErrorBox
{
return getMessageParameter(request.getParameter("msg"),topic,required,on_error);
} // end getMessageParameter
protected final static TopicMessageContext getMessageParameter(ServletMultipartHandler mphandler,
TopicContext topic, boolean required,
String on_error) throws ErrorBox
{
if (mphandler.isFileParam("msg"))
throw new ErrorBox(null,"Internal Error: message should be a normal param",on_error);
return getMessageParameter(mphandler.getValue("msg"),topic,required,on_error);
} // end getMessageParameter
/*--------------------------------------------------------------------------------
* Overrideable operations
*--------------------------------------------------------------------------------
*/
protected String getMyLocation(HttpServletRequest request)
{
return (String)(request.getAttribute(LOCATION_ATTR));
} // end getMyLocation
protected String getMyLocation(HttpServletRequest request, VeniceEngine engine, UserContext user,
RenderData rdat)
{
return getMyLocation(request);
} // end getMyLocation
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
notSupported(request,"GET method not supported");
return null;
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
notSupported(request,"POST method not supported for normal form posts");
return null;
} // end doVenicePost
protected VeniceContent doVenicePost(HttpServletRequest request, ServletMultipartHandler mphandler,
VeniceEngine engine, UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
notSupported(request,"POST method not supported for multipart/form-data posts");
return null;
} // end doVenicePost
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
*/
public final void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
ServletContext ctxt = getServletContext();
VeniceEngine engine = Variables.getVeniceEngine(ctxt);
VeniceContent content = null;
// Make all log messages for the request carry the remote address.
NDC.push(request.getRemoteAddr());
try
{ // get the user context
UserContext user = Variables.getUserContext(ctxt,request,request.getSession(true));
boolean record_uname = user.isLoggedIn();
if (record_uname)
NDC.push(user.getUserName());
try
{ // and now we proceed!
RenderData rdat = RenderConfig.createRenderData(ctxt,user,request,response);
try
{ // run the actual "get" in the servlet
content = doVeniceGet(request,engine,user,rdat);
} // end try
catch (VeniceServletResult res)
{ // special VeniceServletResult catch here - figure out what result it is
if (res instanceof VeniceContent)
content = (VeniceContent)res; // this is content
else if (res instanceof ContentResult)
{ // this contains content
ContentResult cres = (ContentResult)res;
content = cres.getContent();
} // end else if
else if (res instanceof ExecuteResult)
{ // direct-execution result
ExecuteResult xres = (ExecuteResult)res;
Variables.flushCookies(request,response);
xres.execute(rdat);
return;
} // end else if
else // unrecognized VeniceServletResult
content = null;
} // end catch
catch (RuntimeException re)
{ // record that we caught a runtime exception in here!
logger.error("VeniceServlet.doGet caught " + re.getClass().getName() + " in doVeniceGet",re);
throw re;
} // end catch
Variables.flushCookies(request,response);
if (content!=null)
{ // display the content!
BaseJSPData base = new BaseJSPData(engine,user,getMyLocation(request,engine,user,rdat),content);
base.transfer(ctxt,rdat);
} // end if
else // there is no content - display the null response
rdat.nullResponse();
} // end try
finally
{ // pop the username from the NDC if we used it
if (record_uname)
NDC.pop();
} // end finally
} // end try
finally
{ // pop the nested diagnostic context
NDC.pop();
} // end finally
} // end doGet
public final void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
ServletContext ctxt = getServletContext();
VeniceEngine engine = Variables.getVeniceEngine(ctxt);
ServletMultipartHandler mphandler = null;
VeniceContent content = null;
// Make all log messages for the request carry the remote address.
NDC.push(request.getRemoteAddr());
try
{ // get the user context
UserContext user = Variables.getUserContext(ctxt,request,request.getSession(true));
boolean record_uname = user.isLoggedIn();
if (record_uname)
NDC.push(user.getUserName());
try
{ // and now we proceed!
RenderData rdat = RenderConfig.createRenderData(ctxt,user,request,response);
if (ServletMultipartHandler.canHandle(request))
{ // if this is a multipart/form-data request, invoke our special handler code
try
{ // create the multipart handler
mphandler = new ServletMultipartHandler(request);
} // end try
catch (ServletMultipartException e)
{ // this is an error message we need to generate and just bail out on
logger.error("ServletMultipartException caught in doVenicePost!",e);
BaseJSPData base = new BaseJSPData(engine,user,getMyLocation(request,engine,user,rdat),
new ErrorBox(null,"Internal Error: " + e.getMessage(),null));
base.transfer(ctxt,rdat);
return;
} // end if
} // end if
try
{ // call the appropriate doVenicePost method
if (mphandler!=null)
content = doVenicePost(request,mphandler,engine,user,rdat);
else
content = doVenicePost(request,engine,user,rdat);
} // end try
catch (VeniceServletResult res)
{ // special VeniceServletResult catch here - figure out what result it is
if (res instanceof VeniceContent)
content = (VeniceContent)res; // this is content
else if (res instanceof ContentResult)
{ // this contains content
ContentResult cres = (ContentResult)res;
content = cres.getContent();
} // end else if
else if (res instanceof ExecuteResult)
{ // direct-execution result
ExecuteResult xres = (ExecuteResult)res;
Variables.flushCookies(request,response);
xres.execute(rdat);
return;
} // end else if
else // unrecognized VeniceServletResult
content = null;
} // end catch
catch (RuntimeException re)
{ // record that we caught a runtime exception in here!
logger.error("VeniceServlet.doPost caught " + re.getClass().getName() + " in doVenicePost",re);
throw re;
} // end catch
Variables.flushCookies(request,response);
if (content!=null)
{ // display the content!
BaseJSPData base = new BaseJSPData(engine,user,getMyLocation(request,engine,user,rdat),content);
base.transfer(ctxt,rdat);
} // end if
else // there is no content - display the null response
rdat.nullResponse();
} // end try
finally
{ // pop the username from the NDC if we used it
if (record_uname)
NDC.pop();
} // end finally
} // end try
finally
{ // pop the nested diagnostic context
NDC.pop();
} // end finally
} // end doPost
} // end class VeniceServlet

View File

@@ -1,246 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class AdminFindUser implements JSPRender, SearchMode
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.AdminFindUser";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private VeniceEngine engine;
private int field = -1;
private int mode = -1;
private String term = null;
private int offset = 0;
private List results = null;
private int find_count = -1;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public AdminFindUser(VeniceEngine engine)
{
this.engine = engine;
} // 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 AdminFindUser retrieve(ServletRequest request)
{
return (AdminFindUser)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "User Account Management";
} // end getPageTitle
public String getPageQID()
{
return "sysadmin?cmd=UF";
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "admin_find.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
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 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()
{
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.
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.");
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.");
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.
results = engine.searchForUsers(field,mode,term,offset,count);
if (find_count<0)
find_count = engine.getSearchUserCount(field,mode,term);
} // end loadPost
} // end class AdminFindUser

View File

@@ -1,378 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.Writer;
import java.io.IOException;
import java.util.*;
import com.silverwrist.util.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.security.Role;
public class AdminModifyUserDialog extends ContentDialog
{
/*--------------------------------------------------------------------------------
* The photo URL control class.
*--------------------------------------------------------------------------------
*/
static class CDUserPhotoControl extends CDBaseFormField
{
private String linkURL;
public CDUserPhotoControl(String name, String caption, String linkURL)
{
super(name,caption,"(click to change)",false);
this.linkURL = linkURL;
} // end constructor
protected CDUserPhotoControl(CDUserPhotoControl other)
{
super(other);
this.linkURL = other.linkURL;
} // end constructor
protected void renderActualField(Writer out, RenderData rdat) throws IOException
{
if (isEnabled())
out.write("<A HREF=\"" + rdat.getEncodedServletPath(linkURL) + "\">");
String photo = getValue();
if (StringUtil.isStringEmpty(photo))
photo = rdat.getPhotoNotAvailURL();
out.write("<IMG SRC=\"" + photo + "\" ALT=\"\" BORDER=0 WIDTH=100 HEIGHT=100></A>");
if (isEnabled())
out.write("</A>");
} // end renderActualField
protected void validateContents(String value) throws ValidationException
{ // this is a do-nothing value
} // end validateContents
public CDFormField duplicate()
{
return new CDUserPhotoControl(this);
} // end clone
public void setLinkURL(String s)
{
linkURL = s;
} // end setLinkURL
} // end class CDUserPhotoControl
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static final String YES = "Y";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CDUserPhotoControl photo_control;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public AdminModifyUserDialog()
{
super("Modify User Account",null,"moduserform","sysadmin");
setHiddenField("cmd","UM");
setHiddenField("uid","");
addFormField(new CDFormCategoryHeader("Security Information","To change the user's 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 CDRoleListFormField("base_lvl","Base security level",null,true,
Collections.EMPTY_LIST));
addFormField(new CDCheckBoxFormField("verify_email","E-mail address verified",null,YES));
addFormField(new CDCheckBoxFormField("lockout","Account locked out",null,YES));
addFormField(new CDCheckBoxFormField("nophoto","Disallow photo uploads for this user",null,YES));
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,YES));
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));
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,YES));
addFormField(new CDTextFormField("fax","Fax",null,false,32,32));
addFormField(new CDCheckBoxFormField("pvt_fax","Hide fax number in profile",null,YES));
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,YES));
addFormField(new CDTextFormField("url","Home page","(URL)",false,32,255));
addFormField(new CDFormCategoryHeader("Personal"));
addFormField(new CDTextFormField("descr","Personal description",null,false,32,255));
photo_control = new CDUserPhotoControl("photo","User Photo","userphoto");
addFormField(photo_control);
addFormField(new CDFormCategoryHeader("User Preferences"));
addFormField(new CDCheckBoxFormField("pic_in_post","Display user photos next to conference posts",
"(where applicable)",YES));
addFormField(new CDCheckBoxFormField("no_mass_mail",
"Don't send user mass E-mail from community/conference hosts",
null,YES));
addFormField(new CDLocaleListFormField("locale","Default locale","(for formatting dates/times)",true));
addFormField(new CDTimeZoneListFormField("tz","Default time zone",null,true));
addCommandButton(new CDImageButton("update","bn_update.gif","Update",80,24));
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
} // end constructor
protected AdminModifyUserDialog(AdminModifyUserDialog other)
{
super(other);
photo_control = (CDUserPhotoControl)modifyField("photo");
} // end AdminModifyUserDialog
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private void coreSetup(AdminOperations ops, AdminUserContext admuser)
{
setSubtitle("User: " + admuser.getUserName());
setHiddenField("uid",String.valueOf(admuser.getUID()));
CDPickListFormField level_field = (CDPickListFormField)modifyField("base_lvl");
List role_list = ops.getAllowedRoleList();
level_field.setChoicesList(role_list);
// See if this level was found on the list.
Role my_role = admuser.getBaseRole();
boolean found = false;
Iterator it = role_list.iterator();
while (it.hasNext())
{ // seek each role in turn
Role r = (Role)(it.next());
if (r.equals(my_role))
{ // found it!
found = true;
break;
} // end if
} // end while
if (!found)
{ // not in the list - set the defined "role list" to be a singleton of our current level
role_list = Collections.singletonList(my_role);
level_field.setChoicesList(role_list);
} // end if
} // end coreSetup
/*--------------------------------------------------------------------------------
* Overrides from class Object
*--------------------------------------------------------------------------------
*/
public Object clone()
{
return new AdminModifyUserDialog(this);
} // end clone
/*--------------------------------------------------------------------------------
* Overrides from class ContentDialog
*--------------------------------------------------------------------------------
*/
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
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void setupDialog(AdminOperations ops, AdminUserContext admuser) throws DataException
{
coreSetup(ops,admuser);
setFieldValue("base_lvl",String.valueOf(admuser.getBaseLevel()));
if (admuser.isEmailVerified())
setFieldValue("verify_email",YES);
if (admuser.isLockedOut())
setFieldValue("lockout",YES);
ContactInfo ci = admuser.getContactInfo(); // get the main contact info
AdminUserProperties props = admuser.getProperties();
if (props.getDisallowPhoto())
setFieldValue("nophoto",YES);
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",YES);
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",YES);
setFieldValue("fax",ci.getFax());
if (ci.getPrivateFax())
setFieldValue("pvt_fax",YES);
setFieldValue("email",ci.getEmail());
if (ci.getPrivateEmail())
setFieldValue("pvt_email",YES);
setFieldValue("url",ci.getURL());
setFieldValue("descr",admuser.getDescription());
setFieldValue("photo",ci.getPhotoURL());
photo_control.setLinkURL("adminuserphoto?uid=" + admuser.getUID());
if (props.getDisplayPostPictures())
setFieldValue("pic_in_post",YES);
if (props.getMassMailOptOut())
setFieldValue("no_mass_mail",YES);
setFieldValue("locale",admuser.getLocale().toString());
setFieldValue("tz",admuser.getTimeZone().getID());
} // end setupDialog
public void doDialog(AdminUserContext admuser) throws ValidationException, DataException
{
validate(); // validate the dialog
try
{ // reset the base level
admuser.setBaseLevel(Integer.parseInt(getFieldValue("base_lvl")));
} // end try
catch (NumberFormatException nfe)
{ // this shouldn't happen
throw new InternalStateError("new_level should be an integer - form screwup");
} // end catch
// Change the password if applicable.
String foo = getFieldValue("pass1");
if (!StringUtil.isStringEmpty(foo))
admuser.setPassword(foo,getFieldValue("remind"));
admuser.setEmailVerified(YES.equals(getFieldValue("verify_email")));
admuser.setLockedOut(YES.equals(getFieldValue("lockout")));
ContactInfo ci = admuser.getContactInfo(); // get the main contact info
AdminUserProperties props = admuser.getProperties();
// Reset all the contact info fields.
props.setDisallowPhoto(YES.equals(getFieldValue("nophoto")));
ci.setNamePrefix(getFieldValue("prefix"));
ci.setGivenName(getFieldValue("first"));
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"));
props.setDisplayPostPictures(YES.equals(getFieldValue("pic_in_post")));
props.setMassMailOptOut(YES.equals(getFieldValue("no_mass_mail")));
// Store the completed contact info.
admuser.putContactInfo(ci);
admuser.setProperties(props);
// Save off the user's description and preferences.
admuser.setDescription(getFieldValue("descr"));
admuser.setLocale(International.get().createLocale(getFieldValue("locale")));
admuser.setTimeZone(TimeZone.getTimeZone(getFieldValue("tz")));
} // end doDialog
public void resetOnError(AdminOperations ops, AdminUserContext admuser, String message)
{
coreSetup(ops,admuser);
setErrorMessage(message);
setFieldValue("pass1",null);
setFieldValue("pass2",null);
} // end resetOnError
} // end class AdminModifyUserDialog

View File

@@ -1,135 +0,0 @@
/*
* 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.awt.Dimension;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class AdminUserPhotoData implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.AdminUserPhotoData";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private Dimension photo_dims;
private String photo_url;
private int uid;
private String user_name;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public AdminUserPhotoData(VeniceEngine engine, AdminUserContext admuser, RenderData rdat)
throws DataException
{
photo_dims = engine.getUserPhotoSize();
photo_url = admuser.getContactInfo().getPhotoURL();
if (StringUtil.isStringEmpty(photo_url))
photo_url = rdat.getPhotoNotAvailURL();
this.uid = admuser.getUID();
this.user_name = admuser.getUserName();
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static AdminUserPhotoData retrieve(ServletRequest request)
{
return (AdminUserPhotoData)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Set User Photo";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "admin_user_photo.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getUID()
{
return uid;
} // end getUID
public String getUserName()
{
return user_name;
} // end getUserName
public String getPhotoTag(RenderData rdat)
{
StringBuffer buf = new StringBuffer("<IMG SRC=\"");
buf.append(photo_url).append("\" ALT=\"\" ALIGN=LEFT WIDTH=").append(photo_dims.width).append(" HEIGHT=");
buf.append(photo_dims.height).append(" HSPACE=6 VSPACE=0 BORDER=0>");
return buf.toString();
} // end getPhotoTag
} // end class AdminUserPhotoData

View File

@@ -1,135 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.htmlcheck.*;
import com.silverwrist.venice.core.*;
public class AttachmentForm implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.AttachmentForm";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private int cid;
private int confid;
private long postid;
private String target;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public AttachmentForm(CommunityContext comm, ConferenceContext conf, TopicMessageContext msg, String target)
{
this.cid = comm.getCommunityID();
this.confid = conf.getConfID();
this.postid = msg.getPostID();
this.target = target;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static AttachmentForm retrieve(ServletRequest request)
{
return (AttachmentForm)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Upload Attachment";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "attach_form.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getCommunityID()
{
return cid;
} // end getCommunityID
public int getConfID()
{
return confid;
} // end getConfID
public long getPostID()
{
return postid;
} // end getPostID
public String getTarget()
{
return target;
} // end getTarget
} // end class AttachmentForm

View File

@@ -1,227 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.Writer;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.servlets.Variables;
import com.silverwrist.venice.servlets.format.menus.LeftMenu;
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 VeniceEngine engine; // the Venice engine
private UserContext user; // user context
private String location; // location string to use for this page
private VeniceContent content; // the actual content
private boolean login_links = true; // show login links up top?
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public BaseJSPData(VeniceEngine engine, UserContext user, String location, VeniceContent content)
{
this.engine = engine;
this.user = user;
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(RenderData rdat)
{
if (content==null)
return "";
else
return content.getPageTitle(rdat);
} // end getTitle
public String getPageQID()
{
if (content==null)
return null;
else
return content.getPageQID();
} // end getPageQID
public boolean locationSpecified()
{
return (location!=null);
} // end if
public String getLocation()
{
return location;
} // end getLocation
public boolean displayLoginLinks()
{
return login_links && (location!=null);
} // 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 renderBannerAd(Writer out, RenderData rdat) throws IOException
{
Advertisement advert;
if (user.isLoggedIn())
advert = user.selectAd();
else
advert = engine.selectAd();
if (advert==null)
{ // no advert found - bail out now!
out.write("&nbsp;");
return;
} // end if
String full_image_path;
if (advert.getImagePathStyle()==Advertisement.CONTEXT_RELATIVE)
{ // return the full image path
full_image_path = rdat.getContextRelativePath(advert.getImagePath());
} // end if
else
{ // can't render the ad - just punt
out.write("&nbsp;");
return;
} // end else
// Write the banner ad.
String url = advert.getLinkURL();
String capt = advert.getCaption();
if (url!=null)
out.write("<A HREF=\"" + url + "\">");
out.write("<IMG SRC=\"" + full_image_path + "\" ALT=\"");
if (capt!=null)
out.write(capt);
out.write("\" ALIGN=RIGHT WIDTH=468 HEIGHT=60 HSPACE=2 VSPACE=2 BORDER=0>");
if (url!=null)
out.write("</A>");
} // end renderBannerAd
public void renderMenu(HttpSession session, Writer out, RenderData rdat) throws IOException
{
ComponentRender menu = Variables.getMenu(session);
if (menu==null)
menu = (ComponentRender)(rdat.getLeftMenu("top"));
menu.renderHere(out,rdat);
} // end renderMenu
public void renderFixedMenu(Writer out, RenderData rdat) throws IOException
{
ComponentRender menu = (ComponentRender)(rdat.getLeftMenu("fixed"));
menu.renderHere(out,rdat);
} // end renderFixedMenu
public void renderContent(ServletContext ctxt, Writer out, RenderData rdat)
throws IOException, ServletException
{
if (content==null)
{ // there is no content!
new ErrorBox(null,"Internal Error: There is no content available",null).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
else 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 else if
else // this is the fallback if we don't recognize the content
new ErrorBox(null,"Internal Error: Content of invalid type",null).renderHere(out,rdat);
} // end renderContent
} // end class BaseJSPData

View File

@@ -1,181 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.Writer;
import java.io.IOException;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.except.ValidationException;
public abstract class CDBaseFormFieldReverse implements CDFormField, ColorSelectors
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String name;
private String caption;
private String caption2;
private boolean required;
private String value = null;
private boolean enabled;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
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
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
protected final String getCaption()
{
return caption;
} // end getCaption
/*--------------------------------------------------------------------------------
* Abstract functions which MUST be overriden
*--------------------------------------------------------------------------------
*/
protected abstract void renderActualField(Writer out, RenderData rdat)
throws IOException;
/*--------------------------------------------------------------------------------
* Overridable operations
*--------------------------------------------------------------------------------
*/
protected void validateContents(String value) throws ValidationException
{ // this is a do-nothing value
} // end validateContents
/*--------------------------------------------------------------------------------
* Implementations from interface ComponentRender
*--------------------------------------------------------------------------------
*/
public void renderHere(Writer out, RenderData rdat) throws IOException
{
out.write("<TR VALIGN=MIDDLE>\n<TD ALIGN=RIGHT CLASS=\"content\">");
renderActualField(out,rdat);
out.write("</TD>\n<TD ALIGN=LEFT CLASS=\"content\"><FONT COLOR=\""
+ rdat.getStdColor(enabled ? CONTENT_FOREGROUND : CONTENT_DISABLED) + "\">"
+ StringUtil.encodeHTML(caption));
if (caption2!=null)
out.write(" " + StringUtil.encodeHTML(caption2));
out.write("</FONT>");
if (required)
out.write(rdat.getRequiredBullet());
out.write("</TD>\n</TR>\n");
} // end renderHere
/*--------------------------------------------------------------------------------
* Implementations from interface CDFormField
*--------------------------------------------------------------------------------
*/
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 Object getObjValue()
{
return value;
} // end getObjValue
public void setObjValue(Object obj)
{
this.value = obj.toString();
} // end setObjValue
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

View File

@@ -1,28 +0,0 @@
/*
* 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 ComponentRender
{
public abstract String getName();
public abstract boolean isClicked(ServletRequest request);
} // end interface CDCommandButton

View File

@@ -1,64 +0,0 @@
/*
* 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

View File

@@ -1,143 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.*;
import com.silverwrist.venice.except.ValidationException;
public class CDIntegerFormField extends CDTextFormField
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static final double LN10 = Math.log(10.0);
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private int min_value;
private int max_value;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public CDIntegerFormField(String name, String caption, String caption2, int min, int max)
{
super(name,caption,caption2,true,numDigits(min,max),numDigits(min,max));
this.min_value = min;
this.max_value = max;
} // end constructor
protected CDIntegerFormField(CDIntegerFormField other)
{
super(other);
this.min_value = other.min_value;
this.max_value = other.max_value;
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private static int numDigits(int v)
{
if (v==0)
return 1;
else if (v>0)
return 1 + (int)(Math.floor(Math.log((double)v) / LN10));
else
return 2 + (int)(Math.floor(Math.log((double)(-v)) / LN10));
} // end numDigits
private static int numDigits(int min, int max)
{
return Math.max(Math.max(numDigits(min),numDigits(max)),2);
} // end numDigits
/*--------------------------------------------------------------------------------
* Overrides from class CDTextFormField
*--------------------------------------------------------------------------------
*/
protected void renderActualField(Writer out, RenderData rdat) throws IOException
{
super.renderActualField(out,rdat);
out.write("&nbsp;(" + min_value + " - " + max_value + ")");
} // end renderActualField
protected void validateContents(String value) throws ValidationException
{
super.validateContents(value);
try
{ // convert to an integer and check against range
int x = Integer.parseInt(value);
if ((min_value>Integer.MIN_VALUE) && (x<min_value))
throw new ValidationException("The value of the '" + getCaption()
+ "' field must be greater than or equal to " + min_value + ".");
if ((max_value<Integer.MAX_VALUE) && (x>max_value))
throw new ValidationException("The value of the '" + getCaption()
+ "' field must be less than or equal to " + max_value + ".");
} // end try
catch (NumberFormatException nfe)
{ // integer conversion failed
throw new ValidationException("Invalid non-numeric character in the '" + getCaption() + "' field.");
} // end catch
} // end validateContents
/*--------------------------------------------------------------------------------
* Implementations from interface CDFormField
*--------------------------------------------------------------------------------
*/
public Object getObjValue()
{
try
{ // build an Integer and return it
return new Integer(getValue());
} // end try
catch (NumberFormatException nfe)
{ // shouldn't happen
return null;
} // end catch
} // end getObjValue
public CDFormField duplicate()
{
return new CDIntegerFormField(this);
} // end clone
} // end class CDIntegerFormField

View File

@@ -1,70 +0,0 @@
/*
* 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.except.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("<SPAN CLASS=\"cinput\"><INPUT TYPE=PASSWORD CLASS=\"cinput\" 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("\"></SPAN>");
} // 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

View File

@@ -1,70 +0,0 @@
/*
* 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("&nbsp;&nbsp;");
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

View File

@@ -1,62 +0,0 @@
/*
* 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

View File

@@ -1,97 +0,0 @@
/*
* 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.except.ValidationException;
public class CDTextFormField extends CDBaseFormField
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private int size;
private int maxlength;
private int real_maxlength;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public CDTextFormField(String name, String caption, String caption2, boolean required,
int size, int maxlength)
{
super(name,caption,caption2,required);
this.size = Math.max(size,2);
this.maxlength = Math.max(maxlength,2);
this.real_maxlength = maxlength;
} // end constructor
protected CDTextFormField(CDTextFormField other)
{
super(other);
this.size = other.size;
this.maxlength = other.maxlength;
this.real_maxlength = other.real_maxlength;
} // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class CDBaseFormField
*--------------------------------------------------------------------------------
*/
protected void renderActualField(Writer out, RenderData rdat) throws IOException
{
out.write("<SPAN CLASS=\"cinput\"><INPUT TYPE=TEXT CLASS=\"cinput\" 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("\"></SPAN>");
} // end renderActualField
protected void validateContents(String value) throws ValidationException
{
if (value.length()>real_maxlength)
throw new ValidationException("The value of the '" + getCaption() + "' field must be no longer than "
+ real_maxlength + " characters.");
} // end validateContents
/*--------------------------------------------------------------------------------
* Implementations from interface CDFormField
*--------------------------------------------------------------------------------
*/
public CDFormField duplicate()
{
return new CDTextFormField(this);
} // end clone
} // end class CDTextFormField

View File

@@ -1,70 +0,0 @@
/*
* 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 java.io.Writer;
import java.io.IOException;
import com.silverwrist.venice.core.CommunityContext;
public class CommunityAdminTop extends ContentMenuPanel
{
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public CommunityAdminTop()
{
super("Community Administration:",null);
addChoice("Community Profile","sigadmin?sig=$s&cmd=P");
addChoice("Set Community Category","sigadmin?sig=$s&cmd=T");
addChoice("Set Community Features","sigadmin?sig=$s&cmd=F");
addChoice("Membership Control","sigadmin?sig=$s&cmd=M");
addChoice("E-Mail To All Members","sigadmin?sig=$s&cmd=I");
addChoice("Display Audit Records","sigadmin?sig=$s&cmd=A");
// TODO: More options
addChoice("Delete Community","sigadmin?sig=$s&cmd=DEL");
} // end constructor
protected CommunityAdminTop(CommunityAdminTop other)
{
super(other);
} // end constructor
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void setCommunity(CommunityContext comm)
{
setSubtitle(comm.getName());
setParameter("s",String.valueOf(comm.getCommunityID()));
} // end setCommunity
public Object clone()
{
return new CommunityAdminTop(this);
} // end clone
} // end class CommunityAdminTop

View File

@@ -1,163 +0,0 @@
/*
* 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.*;
import com.silverwrist.venice.except.*;
public class CommunityCategoryBrowseData implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.CommunityCategoryBrowseData";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String name;
private String base_applet;
private CategoryDescriptor prev_cat;
private CategoryDescriptor curr_cat;
private List subcats;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public CommunityCategoryBrowseData(UserContext user, CommunityContext comm, int current_id)
throws DataException
{
name = comm.getName();
base_applet = "sigadmin?sig=" + String.valueOf(comm.getCommunityID());
prev_cat = comm.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 CommunityCategoryBrowseData retrieve(ServletRequest request)
{
return (CommunityCategoryBrowseData)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Set Community Category";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "commcatbrowser.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public String getCommunityName()
{
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 CommunityCategoryBrowseData

View File

@@ -1,115 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class CommunityEMail implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.CommunityEMail";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm; // the community we're in
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public CommunityEMail(CommunityContext comm)
{
this.comm = comm;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static CommunityEMail retrieve(ServletRequest request)
{
return (CommunityEMail)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Community E-Mail: " + comm.getName();
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "comm_email.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public final String getCommunityName()
{
return comm.getName();
} // end getCommunityName
} // end class CommunityEMail

View File

@@ -1,127 +0,0 @@
/*
* 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.awt.Dimension;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class CommunityLogoData implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.CommunityLogoData";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private int cid;
private Dimension logo_dims;
private String logo_url;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public CommunityLogoData(VeniceEngine engine, CommunityContext comm, RenderData rdat)
throws DataException
{
cid = comm.getCommunityID();
logo_dims = engine.getCommunityLogoSize();
logo_url = comm.getContactInfo().getPhotoURL();
if (StringUtil.isStringEmpty(logo_url))
logo_url = rdat.getFullImagePath("sig_other.jpg");
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static CommunityLogoData retrieve(ServletRequest request)
{
return (CommunityLogoData)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Set Community Logo";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "comm_logo.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getCommunityID()
{
return cid;
} // end getCommunityID
public String getLogoTag(RenderData rdat)
{
StringBuffer buf = new StringBuffer("<IMG SRC=\"");
buf.append(logo_url).append("\" ALT=\"\" ALIGN=LEFT WIDTH=").append(logo_dims.width).append(" HEIGHT=");
buf.append(logo_dims.height).append(" HSPACE=6 VSPACE=0 BORDER=0>");
return buf.toString();
} // end getLogoTag
} // end class CommunityLogoData

View File

@@ -1,340 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.security.Role;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class CommunityMembership implements JSPRender, SearchMode
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.CommunityMembership";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private VeniceEngine engine; // reference to the engine
private CommunityContext comm; // the community we're in
private List display_list = null; // list of members to display
private boolean comm_members = false; // is this a list of community members?
private int field = -1; // search field
private int mode = -1; // search mode
private String term = null; // search term
private int offset = 0; // search result offset
private int find_count = -1; // search results count
private List role_choices; // the list of security roles
private Role role_comm_host; // the "Community Host" security role
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public CommunityMembership(VeniceEngine engine, CommunityContext comm)
{
this.engine = engine;
this.comm = comm;
SecurityInfo sinf = comm.getSecurityInfo();
this.role_choices = sinf.getRoleList("Community.UserLevels");
this.role_comm_host = sinf.getRole("Community.Host");
} // 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 CommunityMembership retrieve(ServletRequest request)
{
return (CommunityMembership)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Membership in Community " + comm.getName();
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "comm_member.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void doCommunityMemberList() throws DataException
{
this.display_list = comm.getMemberList();
this.comm_members = true;
this.term = "";
} // end doCommunityMemberList
public void doSearch(ServletRequest request) throws ValidationException, DataException, AccessError
{
// Validate the search field parameter.
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.");
// 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.");
// Perform the search!
List intermediate = engine.searchForUsers(field,mode,term,offset,count);
if (find_count<0)
find_count = engine.getSearchUserCount(field,mode,term);
// Create the real display list by getting the community security levels.
Iterator it = intermediate.iterator();
Vector rc = new Vector(count+1);
while (it.hasNext())
{ // loop around and find the member level of every one
UserFound uf = (UserFound)(it.next());
int new_level = comm.getMemberLevel(uf.getUID());
if (new_level==-1)
new_level = 0;
rc.add(uf.createNewLevel(new_level));
} // end while
display_list = rc; // save display list for display
} // end doSearch
public int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public String getCommunityName()
{
return comm.getName();
} // end getCommunityName
public String getLocator()
{
return "sig=" + comm.getCommunityID();
} // end getLocator
public boolean displayList()
{
if ((display_list==null) || (display_list.size()==0))
return false;
if (comm_members && (display_list.size()>engine.getMaxNumCommunityMembersDisplay()))
return false;
return true;
} // end displayList
public boolean isCommunityMemberList()
{
return comm_members;
} // end isCommunityMemberList
public int getSearchField()
{
return field;
} // end getSearchField
public int getSearchMode()
{
return mode;
} // end getSearchMode
public boolean searchFieldIs(int value)
{
return (field==value);
} // end searchFieldIs
public boolean searchModeIs(int value)
{
return (mode==value);
} // end searchModeIs
public String getSearchTerm()
{
return term;
} // end getSearchTerm
public int getFindCount()
{
return find_count;
} // end getFindCount
public int getOffset()
{
return offset;
} // end getOffset
public int getSize()
{
return display_list.size();
} // end getSize
public int getNumResultsDisplayed()
{
return engine.getStdNumSearchResults();
} // end getNumResultsDisplayed
public UserFound getItem(int ndx)
{
return (UserFound)(display_list.get(ndx));
} // end getItem
public void outputDropDown(Writer out, int uid, int cur_level) throws IOException
{
out.write("<INPUT TYPE=HIDDEN NAME=\"zxcur_" + uid + "\" VALUE=\"" + cur_level + "\">\n");
out.write("<SELECT NAME=\"zxnew_" + uid + "\" SIZE=1>\n");
if (cur_level==role_comm_host.getLevel()) // cheat and put in just the host level
out.write("<OPTION VALUE=\"" + role_comm_host.getLevel() + "\" SELECTED>"
+ StringUtil.encodeHTML(role_comm_host.getName()) + "</OPTION>\n");
else
{ // display all the level choices properly
Iterator it = role_choices.iterator();
while (it.hasNext())
{ // output the <OPTION> lines for the dropdown
Role r = (Role)(it.next());
out.write("<OPTION VALUE=\"" + r.getLevel() + "\"");
if (r.getLevel()==cur_level)
out.write(" SELECTED");
out.write(">" + StringUtil.encodeHTML(r.getName()) + "</OPTION>\n");
} // end while
} // end else
out.write("</SELECT>\n");
} // end outputDropDown
} // end class CommunityMembership

View File

@@ -1,178 +0,0 @@
/*
* 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 javax.servlet.ServletRequest;
import com.silverwrist.util.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class CommunityProfileData implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.CommunityProfileData";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private VeniceEngine engine; // the Venice engine
private UserContext user; // the current user managing this
private CommunityContext comm; // the community being displayed
private ContactInfo ci; // community's contact info
private UserProfile host_prof; // community host's user profile
private CategoryDescriptor cat; // community's full category descriptor
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public CommunityProfileData(VeniceEngine engine, UserContext user, CommunityContext ctxt)
throws DataException
{
this.engine = engine;
this.user = user;
this.comm = ctxt;
this.ci = ctxt.getContactInfo();
this.host_prof = ctxt.getHostProfile();
this.cat = ctxt.getCategory();
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static CommunityProfileData retrieve(ServletRequest request)
{
return (CommunityProfileData)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Community Profile: " + comm.getName();
} // end getPageTitle
public String getPageQID()
{
return "go/" + comm.getAlias() + "!";
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "commprofile.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public CommunityContext getCommunityContext()
{
return comm;
} // end getCommunityContext
public String getCommunityLogoURL(RenderData rdat)
{
String tmp = ci.getPhotoURL();
if (StringUtil.isStringEmpty(tmp))
tmp = rdat.getFullImagePath("sig_other.jpg");
return tmp;
} // end getCommunityLogoURL
public boolean isUserLoggedIn()
{
return user.isLoggedIn();
} // end isUserLoggedIn
public String getHostUserName()
{
return host_prof.getUserName();
} // end getHostUserName
public ContactInfo getCommunityContactInfo()
{
return ci;
} // end getCommunityContactInfo
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()
{
Country c = International.get().getCountryForCode(ci.getCountry());
return ((c==null) ? null : c.getName());
} // end getFullCountry
public CategoryDescriptor getCategory()
{
return cat;
} // end getCategory
} // end class CommunityProfileData

View File

@@ -1,115 +0,0 @@
/*
* 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 javax.servlet.ServletRequest;
import com.silverwrist.venice.core.CommunityContext;
public class CommunityWelcome implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.CommunityWelcome";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String name;
private String entry_url;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public CommunityWelcome(CommunityContext comm)
{
name = comm.getName();
entry_url = "sig/" + comm.getAlias();
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static CommunityWelcome retrieve(ServletRequest request)
{
return (CommunityWelcome)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Welcome to " + name;
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "commwelcome.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public String getCommunityName()
{
return name;
} // end getCommunityName
public String getEntryURL(RenderData rdat)
{
return rdat.getEncodedServletPath(entry_url);
} // end getEntryURL
} // end class CommunityWelcome

View File

@@ -1,191 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class ConferenceActivity implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ConferenceActivity";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm; // the community we're in
private ConferenceContext conf; // the conference being listed
private TopicContext topic; // the topic being listed
private boolean posters; // is this a list of posters?
private List records; // the actual data records
private String locator = null; // our locator
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ConferenceActivity(CommunityContext comm, ConferenceContext conf, TopicContext topic, boolean posters)
throws DataException, AccessError
{
this.comm = comm;
this.conf = conf;
this.topic = topic;
this.posters = posters;
if (topic!=null)
{ // do the report on the topic
if (posters)
this.records = topic.getActivePosters();
else
this.records = topic.getActiveReaders();
} // end if
else
{ // do the report on the conference
if (posters)
this.records = conf.getActivePosters();
else
this.records = conf.getActiveReaders();
} // end else
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static ConferenceActivity retrieve(ServletRequest request)
{
return (ConferenceActivity)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
if (topic!=null)
{ // it's a topic report
if (posters)
return "Users Posting in Topic " + topic.getName();
else
return "Users Reading Topic " + topic.getName();
} // end if
else
{ // it's a conference report
if (posters)
return "Users Posting in Conference " + conf.getName();
else
return "Users Reading Conference " + conf.getName();
} // end else
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "conf_activity.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public String getConfName()
{
return conf.getName();
} // end getConfName
public String getTopicName()
{
if (topic==null)
return null;
else
return topic.getName();
} // end getTopicName
public String getLocator()
{
if (locator==null)
locator = "sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID();
return locator;
} // end getLocator
public boolean isTopicReport()
{
return (topic!=null);
} // end isTopicReport
public boolean isPosterReport()
{
return posters;
} // end isPosterReport
public boolean anyElements()
{
return (records.size()>0);
} // end anyElements
public Iterator getRecordsIterator()
{
return records.iterator();
} // end getRecordsIterator
} // end class ConferenceActivity

View File

@@ -1,150 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class ConferenceCustomBlocks implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ConferenceCustomBlocks";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm; // the community we're in
private ConferenceContext conf; // the conference being diddled with
private String top_custom; // the top custom block
private String bottom_custom; // the bottom custom block
private String locator = null; // locator string
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ConferenceCustomBlocks(CommunityContext comm, ConferenceContext conf) throws DataException
{
this.comm = comm;
this.conf = conf;
this.top_custom = conf.getCustomBlock(ConferenceContext.CUST_BLOCK_TOP);
this.bottom_custom = conf.getCustomBlock(ConferenceContext.CUST_BLOCK_BOTTOM);
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static ConferenceCustomBlocks retrieve(ServletRequest request)
{
return (ConferenceCustomBlocks)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Customize Conference: " + conf.getName();
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "conf_custom.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public final int getConferenceID()
{
return conf.getConfID();
} // end getConferenceID
public final String getConferenceName()
{
return conf.getName();
} // end getConferenceName
public final String getLocator()
{
if (locator==null)
locator = "sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID();
return locator;
} // end getLocator
public final String getTopCustomBlock()
{
return (top_custom==null) ? "" : StringUtil.encodeHTML(top_custom);
} // end getTopCustomBlock
public final String getBottomCustomBlock()
{
return (bottom_custom==null) ? "" : StringUtil.encodeHTML(bottom_custom);
} // end getBottomCustomBlock
} // end class ConferenceCustomBlocks

View File

@@ -1,152 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.IOException;
import java.io.Writer;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class ConferenceEMail implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ConferenceEMail";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm; // the community we're in
private ConferenceContext conf; // the conference being listed
private List topics; // list of topics in that conference
private String locator = null; // locator string
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ConferenceEMail(CommunityContext comm, ConferenceContext conf) throws DataException, AccessError
{
this.comm = comm;
this.conf = conf;
this.topics = conf.getTopicList(ConferenceContext.DISPLAY_ALL,ConferenceContext.SORT_NAME);
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static ConferenceEMail retrieve(ServletRequest request)
{
return (ConferenceEMail)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Conference E-Mail: " + conf.getName();
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "conf_email.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public final int getConferenceID()
{
return conf.getConfID();
} // end getConferenceID
public final String getConferenceName()
{
return conf.getName();
} // end getConferenceName
public final String getLocator()
{
if (locator==null)
locator = "sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID();
return locator;
} // end getLocator
public final void writeTopicChoices(Writer out) throws IOException
{
out.write("<OPTION VALUE=\"0\" SELECTED>(Entire conference)</OPTION>\n");
Iterator it = topics.iterator();
while (it.hasNext())
{ // write out the entire topic list as a drop-down list
TopicContext topic = (TopicContext)(it.next());
out.write("<OPTION VALUE=\"" + topic.getTopicNumber() + "\">" + StringUtil.encodeHTML(topic.getName())
+ "</OPTION>\n");
} // end while
} // end writeTopicChoices
} // end class ConferenceEMail

View File

@@ -1,181 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.ServletRequest;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
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 CommunityContext comm;
private List conferences;
private List[] hosts;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ConferenceListing(CommunityContext comm) throws DataException, AccessError
{
this.comm = comm;
this.conferences = comm.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 VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Conference Listing: " + comm.getName();
} // end getPageTitle
public String getPageQID()
{
return "go/" + comm.getAlias() + "!";
} // end getPageQID
/*--------------------------------------------------------------------------------
* 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 getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public String getCommunityName()
{
return comm.getName();
} // end getCommunityName
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 boolean anyUnread(int ndx)
{
return ((ConferenceContext)(conferences.get(ndx))).anyUnread();
} // end anyUnread
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 comm.canCreateConference();
} // end canCreateConference
public boolean canManageConferences()
{
return comm.canManageConferences();
} // end canManageConferences
} // end class ConferenceListing

View File

@@ -1,344 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.security.Role;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class ConferenceMembership implements JSPRender, SearchMode
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ConferenceMembership";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private VeniceEngine engine; // reference to the engine
private CommunityContext comm; // the community we're in
private ConferenceContext conf; // the conference being listed
private List display_list = null; // list of members to display
private boolean conf_members = false; // is this a list of conference members?
private int field = -1; // search field
private int mode = -1; // search mode
private String term = null; // search term
private int offset = 0; // search result offset
private int find_count = -1; // search results count
private List role_choices; // the list of security roles
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public ConferenceMembership(VeniceEngine engine, CommunityContext comm, ConferenceContext conf)
{
this.engine = engine;
this.comm = comm;
this.conf = conf;
this.role_choices = conf.getSecurityInfo().getRoleList("Conference.UserLevels");
} // 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 ConferenceMembership retrieve(ServletRequest request)
{
return (ConferenceMembership)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Membership in Conference " + conf.getName();
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "conf_member.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void doConferenceMemberList() throws DataException, AccessError
{
this.display_list = conf.getMemberList();
this.conf_members = true;
this.term = "";
} // end doConferenceMemberList
public void doSearch(ServletRequest request) throws ValidationException, DataException, AccessError
{
// Validate the search field parameter.
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.");
// 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.");
// Perform the search!
List intermediate = comm.searchForMembers(field,mode,term,offset,count);
if (find_count<0)
find_count = comm.getSearchMemberCount(field,mode,term);
// Create the real display list by getting the conference security levels.
Iterator it = intermediate.iterator();
Vector rc = new Vector(count+1);
while (it.hasNext())
{ // loop around and find the member level of every one
UserFound uf = (UserFound)(it.next());
int new_level = conf.getMemberLevel(uf.getUID());
if (new_level==-1)
new_level = 0;
rc.add(uf.createNewLevel(new_level));
} // end while
display_list = rc; // save display list for display
} // end doSearch
public int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public int getConfID()
{
return conf.getConfID();
} // end getConfID
public String getCommunityName()
{
return comm.getName();
} // end getCommunityName
public String getConfName()
{
return conf.getName();
} // end getConfName
public String getLocator()
{
return "sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID();
} // end getLocator
public boolean displayList()
{
if ((display_list==null) || (display_list.size()==0))
return false;
if (conf_members && (display_list.size()>engine.getMaxNumConferenceMembersDisplay()))
return false;
return true;
} // end displayList
public boolean conferenceMemberList()
{
return conf_members;
} // end conferenceMemberList
public int getSearchField()
{
return field;
} // end getSearchField
public int getSearchMode()
{
return mode;
} // end getSearchMode
public boolean searchFieldIs(int value)
{
return (field==value);
} // end searchFieldIs
public boolean searchModeIs(int value)
{
return (mode==value);
} // end searchModeIs
public String getSearchTerm()
{
return term;
} // end getSearchTerm
public int getFindCount()
{
return find_count;
} // end getFindCount
public int getOffset()
{
return offset;
} // end getOffset
public int getSize()
{
return display_list.size();
} // end getSize
public int getNumResultsDisplayed()
{
return engine.getStdNumSearchResults();
} // end getNumResultsDisplayed
public UserFound getItem(int ndx)
{
return (UserFound)(display_list.get(ndx));
} // end getItem
public void outputDropDown(Writer out, int uid, int cur_level) throws IOException
{
out.write("<INPUT TYPE=HIDDEN NAME=\"zxcur_" + uid + "\" VALUE=\"" + cur_level + "\">\n");
out.write("<SELECT NAME=\"zxnew_" + uid + "\" SIZE=1>\n");
Iterator it = role_choices.iterator();
while (it.hasNext())
{ // output the <OPTION> lines for the dropdown
Role r = (Role)(it.next());
out.write("<OPTION VALUE=\"" + r.getLevel() + "\"");
if (r.getLevel()==cur_level)
out.write(" SELECTED");
out.write(">" + StringUtil.encodeHTML(r.getName()) + "</OPTION>\n");
} // end while
out.write("</SELECT>\n");
} // end outputDropDown
} // end class ConferenceMembership

View File

@@ -1,177 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class ConferenceSequence implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ConferenceSequence";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm;
private List conf_list;
private Hashtable hidden_stat = new Hashtable();
private Hashtable next_id = new Hashtable();
private Hashtable prev_id = new Hashtable();
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ConferenceSequence(CommunityContext comm) throws DataException, AccessError
{
this.comm = comm;
this.conf_list = comm.getConferences();
Integer last_id = null;
for (int i=0; i<conf_list.size(); i++)
{ // build up the "next_id" and "prev_id" mappings
ConferenceContext conf = (ConferenceContext)(conf_list.get(i));
Integer this_id = new Integer(conf.getConfID());
// save conference "hidden" status
hidden_stat.put(this_id,new Boolean(conf.getHideList()));
if (last_id!=null)
{ // establish the "next" and "prev" IDs for the conferences
next_id.put(last_id,this_id);
prev_id.put(this_id,last_id);
} // end if
last_id = this_id;
} // end for
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static ConferenceSequence retrieve(ServletRequest request)
{
return (ConferenceSequence)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Manage Conference List";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "conf_sequence.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public int getNumConferences()
{
return conf_list.size();
} // end getNumConferences
public ConferenceContext getConference(int ndx)
{
return (ConferenceContext)(conf_list.get(ndx));
} // end getConference
public boolean isConferenceHidden(ConferenceContext conf)
{
Boolean value = (Boolean)(hidden_stat.get(new Integer(conf.getConfID())));
if (value==null)
return false;
else
return value.booleanValue();
} // end isConferenceHidden
public int getNextConfID(ConferenceContext conf)
{
Integer value = (Integer)(next_id.get(new Integer(conf.getConfID())));
if (value==null)
return 0;
else
return value.intValue();
} // end getNextConfID
public int getPrevConfID(ConferenceContext conf)
{
Integer value = (Integer)(prev_id.get(new Integer(conf.getConfID())));
if (value==null)
return 0;
else
return value.intValue();
} // end getPrevConfID
} // end class ConferenceSequence

View File

@@ -1,465 +0,0 @@
/*
* 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.except.ValidationException;
public class ContentDialog implements Cloneable, ContentRender, ColorSelectors
{
/*--------------------------------------------------------------------------------
* 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 VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return title;
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* 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 CLASS=\"content\">\n" + rdat.getStdFontTag(CONTENT_ERROR,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=\"" + rdat.getEncodedServletPath(action)
+ "\"><DIV CLASS=\"content\">" + rdat.getStdFontTag(CONTENT_FOREGROUND,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 CLASS=\"content\">");
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("&nbsp;&nbsp;");
button.renderHere(out,rdat);
} // end while
out.write("</DIV>\n");
} // end if
out.write("</FONT></DIV></FORM>\n");
} // end renderHere
/*--------------------------------------------------------------------------------
* Operations usable only from derived classes
*--------------------------------------------------------------------------------
*/
protected CDFormField modifyField(String name)
{
return (CDFormField)(form_fields.get(name));
} // end modifyField
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void setTitle(String title)
{
this.title = title;
} // end setTitle
public void setSubtitle(String subtitle)
{
this.subtitle = subtitle;
} // end setSubtitle
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 Object getFieldObjValue(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.getObjValue();
else
return null;
} // end getFieldObjValue
public void setFieldObjValue(String fieldname, Object value)
{
CDFormField fld = (CDFormField)(form_fields.get(fieldname));
if (fld!=null)
fld.setObjValue(value);
else if (value!=null)
setHiddenField(fieldname,value.toString());
} // end setFieldObjValue
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

View File

@@ -1,182 +0,0 @@
/*
* 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 java.io.Writer;
import java.io.IOException;
import com.silverwrist.util.StringUtil;
public class ContentMenuPanel implements Cloneable, ContentRender, ColorSelectors
{
/*--------------------------------------------------------------------------------
* 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 VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return title;
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* 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(CONTENT_FOREGROUND,2));
ContentMenuPanelItem item = (ContentMenuPanelItem)(it.next());
item.renderHere(out,rdat,params);
out.write("</FONT></TD>\n</TR>\n");
} // end while
out.write("</TABLE>\n");
} // 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

View File

@@ -1,165 +0,0 @@
/*
* 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.core.*;
import com.silverwrist.venice.except.*;
public class CreateCommunityDialog extends ContentDialog
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private VeniceEngine engine;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public CreateCommunityDialog()
{
super("Create New Community",null,"createcommform","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(CommunityContext.HIDE_NONE) + "|Show in both directory and search");
vec_hidemode.add(String.valueOf(CommunityContext.HIDE_DIRECTORY)
+ "|Hide in directory, but not in search");
vec_hidemode.add(String.valueOf(CommunityContext.HIDE_BOTH) + "|Hide in both directory and search");
vec_hidemode.trimToSize();
addFormField(new CDFormCategoryHeader("Basic Information"));
addFormField(new CDTextFormField("name","Community Name",null,true,32,128));
addFormField(new CDVeniceIDFormField("alias","Community 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));
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));
addFormField(new CDFormCategoryHeader("Security"));
addFormField(new CDSimplePickListFormField("comtype","Community type:",null,true,vec_pubpriv,'|'));
addFormField(new CDTextFormField("joinkey","Join key","(for private communities)",false,32,64));
addFormField(new CDSimplePickListFormField("hidemode","Community 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 CreateCommunityDialog(CreateCommunityDialog other)
{
super(other);
} // end CreateCommunityDialog
/*--------------------------------------------------------------------------------
* 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 community 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 communities must specify a join key value.");
} // end if
} // end validateWholeForm
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void setupDialog(VeniceEngine engine)
{
this.engine = engine;
} // end setupDialog
public CommunityContext 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 community context.
CommunityContext rc = user.createCommunity(getFieldValue("name"),getFieldValue("alias"),
getFieldValue("language"),getFieldValue("synopsis"),
getFieldValue("rules"),jkey,hidemode);
// Get the new community'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 CreateCommunityDialog(this);
} // end clone
} // end class CreateCommunityDialog

View File

@@ -1,120 +0,0 @@
/*
* 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.core.*;
import com.silverwrist.venice.except.AccessError;
import com.silverwrist.venice.except.DataException;
import com.silverwrist.venice.except.ValidationException;
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 community'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, CommunityContext comm)
{
this.engine = engine;
setHiddenField("sig",String.valueOf(comm.getCommunityID()));
} // end setupDialog
public ConferenceContext doDialog(CommunityContext comm)
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 comm.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

View File

@@ -1,103 +0,0 @@
/*
* 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

View File

@@ -1,353 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.*;
import java.util.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.security.Role;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class EditCommunityProfileDialog extends ContentDialog
{
/*--------------------------------------------------------------------------------
* The logo URL control class.
*--------------------------------------------------------------------------------
*/
static class CDCommunityLogoControl extends CDBaseFormField
{
private String linkURL;
public CDCommunityLogoControl(String name, String caption, String linkURL)
{
super(name,caption,"(click to change)",false);
this.linkURL = linkURL;
} // end constructor
protected CDCommunityLogoControl(CDCommunityLogoControl other)
{
super(other);
this.linkURL = other.linkURL;
} // end constructor
protected void renderActualField(Writer out, RenderData rdat) throws IOException
{
if (isEnabled())
out.write("<A HREF=\"" + rdat.getEncodedServletPath(linkURL) + "\">");
String photo = getValue();
if (StringUtil.isStringEmpty(photo))
photo = rdat.getFullImagePath("sig_other.jpg");
out.write("<IMG SRC=\"" + photo + "\" ALT=\"\" BORDER=0 WIDTH=110 HEIGHT=65></A>");
if (isEnabled())
out.write("</A>");
} // end renderActualField
protected void validateContents(String value) throws ValidationException
{ // this is a do-nothing value
} // end validateContents
public CDFormField duplicate()
{
return new CDCommunityLogoControl(this);
} // end clone
public void setLinkURL(String s)
{
linkURL = s;
} // end setLinkURL
} // end class CDCommunityLogoControl
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static final String YES = "Y";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CDCommunityLogoControl logo_control;
private VeniceEngine engine;
private int cid;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public EditCommunityProfileDialog(SecurityInfo sinf)
{
super("Edit Community Profile:",null,"commprofform","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(CommunityContext.HIDE_NONE) + "|Show in both directory and search");
vec_hidemode.add(String.valueOf(CommunityContext.HIDE_DIRECTORY)
+ "|Hide in directory, but not in search");
vec_hidemode.add(String.valueOf(CommunityContext.HIDE_BOTH) + "|Hide in both directory and search");
vec_hidemode.trimToSize();
addFormField(new CDFormCategoryHeader("Basic Information"));
addFormField(new CDTextFormField("name","Community Name",null,true,32,128));
addFormField(new CDVeniceIDFormField("alias","Community 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));
addFormField(new CDTextFormField("url","Home page",null,false,32,255));
logo_control = new CDCommunityLogoControl("logo","Community logo","commlogo");
addFormField(logo_control);
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));
addFormField(new CDFormCategoryHeader("Security"));
addFormField(new CDSimplePickListFormField("comtype","Communty type",null,true,vec_pubpriv,'|'));
addFormField(new CDTextFormField("joinkey","Join key","(for private communities)",false,32,64));
addFormField(new CDCheckBoxFormField("membersonly","Allow only members to access this community",
null,YES));
addFormField(new CDSimplePickListFormField("hidemode","Community visibility",null,true,vec_hidemode,'|'));
addFormField(new CDRoleListFormField("read_lvl","Security level required to read contents",null,true,
sinf.getRoleList("Community.Read")));
addFormField(new CDRoleListFormField("write_lvl","Security level required to update profile",null,true,
sinf.getRoleList("Community.Write")));
addFormField(new CDRoleListFormField("create_lvl","Security level required to create new subobjects",
null,true,sinf.getRoleList("Community.Create")));
addFormField(new CDRoleListFormField("delete_lvl","Security level required to delete community",null,true,
sinf.getRoleList("Community.Delete")));
addFormField(new CDRoleListFormField("join_lvl","Security level required to join community",null,true,
sinf.getRoleList("Community.Join")));
addFormField(new CDFormCategoryHeader("Conferencing Options"));
addFormField(new CDCheckBoxFormField("pic_in_post","Display user pictures next to posts in conferences",
"(by default; user can override)",YES));
addCommandButton(new CDImageButton("update","bn_update.gif","Update",80,24));
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
} // end EditCommunityProfileDialog
protected EditCommunityProfileDialog(EditCommunityProfileDialog other)
{
super(other);
logo_control = (CDCommunityLogoControl)modifyField("logo");
} // end constructor
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private void doDisable(CommunityContext comm)
{
if (comm.isAdminCommunity())
{ // make sure certain fields are disabled for admin community
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"),cid))
throw new ValidationException("That alias is already used by another community 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 communities must specify a join key value.");
} // end if
} // end validateWholeForm
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void setupDialogBasic(VeniceEngine engine, CommunityContext comm)
{
this.engine = engine;
this.cid = comm.getCommunityID();
} // end setupDialogBasic
public void setupDialog(VeniceEngine engine, CommunityContext comm) throws DataException, AccessError
{
setupDialogBasic(engine,comm);
ContactInfo ci = comm.getContactInfo();
CommunityProperties props = comm.getProperties();
setHiddenField("sig",String.valueOf(comm.getCommunityID()));
setFieldValue("name",comm.getName());
setFieldValue("alias",comm.getAlias());
setFieldValue("synopsis",comm.getSynopsis());
setFieldValue("rules",comm.getRules());
setFieldValue("language",comm.getLanguageCode());
setFieldValue("url",ci.getURL());
setFieldValue("logo",ci.getPhotoURL());
logo_control.setLinkURL("commlogo?sig=" + comm.getCommunityID());
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 (comm.isPublicCommunity())
{ // public community - no join key
setFieldValue("comtype","0");
setFieldValue("joinkey","");
} // end if
else
{ // private community - display the join key
setFieldValue("comtype","1");
setFieldValue("joinkey",comm.getJoinKey());
} // end else
if (comm.getMembersOnly())
setFieldValue("membersonly",YES);
setFieldValue("hidemode",String.valueOf(comm.getHideMode()));
setFieldValue("read_lvl",String.valueOf(comm.getReadLevel()));
setFieldValue("write_lvl",String.valueOf(comm.getWriteLevel()));
setFieldValue("create_lvl",String.valueOf(comm.getCreateLevel()));
setFieldValue("delete_lvl",String.valueOf(comm.getDeleteLevel()));
setFieldValue("join_lvl",String.valueOf(comm.getJoinLevel()));
if (props.getDisplayPostPictures())
setFieldValue("pic_in_post",YES);
doDisable(comm);
} // end setupDialog
public void doDialog(CommunityContext comm) throws ValidationException, DataException, AccessError
{
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 = comm.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"));
comm.putContactInfo(ci);
// now save off the property-related fields
CommunityProperties props = comm.getProperties();
props.setDisplayPostPictures(YES.equals(getFieldValue("pic_in_post")));
comm.setProperties(props);
// now save the big text fields
comm.setName(getFieldValue("name"));
comm.setAlias(getFieldValue("alias"));
comm.setSynopsis(getFieldValue("synopsis"));
comm.setRules(getFieldValue("rules"));
comm.setLanguage(getFieldValue("language"));
if (!(comm.isAdminCommunity()))
{ // save off the security information
String jkey;
if (getFieldValue("comtype").equals("1"))
jkey = getFieldValue("joinkey");
else
jkey = null;
comm.setJoinKey(jkey);
comm.setMembersOnly(YES.equals(getFieldValue("membersonly")));
comm.setHideMode(hidemode);
comm.setSecurityLevels(read_lvl,write_lvl,create_lvl,delete_lvl,join_lvl);
} // end if
} // end doDialog
public void resetOnError(CommunityContext comm, String message)
{
setErrorMessage(message);
doDisable(comm);
} // end resetOnError
public Object clone()
{
return new EditCommunityProfileDialog(this);
} // end clone
} // end class EditCommunityProfileDialog

View File

@@ -1,188 +0,0 @@
/*
* 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.security.Role;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class EditConferenceDialog extends ContentDialog
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static final String YES = "Y";
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public EditConferenceDialog(SecurityInfo sinf)
{
super("Edit Conference:",null,"editconfform","confops");
setHiddenField("cmd","E");
setHiddenField("sig","");
setHiddenField("conf","");
addFormField(new CDFormCategoryHeader("Basic Information"));
addFormField(new CDTextFormField("name","Conference Name",null,true,32,128));
addFormField(new CDTextFormField("descr","Description",null,false,32,255));
addFormField(new CDCheckBoxFormField("hide","Hide conference in the community's conference list",
null,YES));
addFormField(new CDFormCategoryHeader("Security Information"));
addFormField(new CDRoleListFormField("read_lvl","Security level required to read conference",null,true,
sinf.getRoleList("Conference.Read")));
addFormField(new CDRoleListFormField("post_lvl","Security level required to post to conference",null,true,
sinf.getRoleList("Conference.Post")));
addFormField(new CDRoleListFormField("create_lvl",
"Security level required to create new topics in conference",null,
true,sinf.getRoleList("Conference.Create")));
addFormField(new CDRoleListFormField("hide_lvl",
"Security level required to archive or freeze topics",
"(or to hide posts of which you are not the owner)",true,
sinf.getRoleList("Conference.Hide")));
addFormField(new CDRoleListFormField("nuke_lvl",
"Security level required to delete topics or nuke posts",
"(or to scribble posts of which you are not the owner)",true,
sinf.getRoleList("Conference.Nuke")));
addFormField(new CDRoleListFormField("change_lvl",
"Security level required to change conference attributes",null,true,
sinf.getRoleList("Conference.Change")));
addFormField(new CDRoleListFormField("delete_lvl",
"Security level required to delete conference",null,true,
sinf.getRoleList("Conference.Delete")));
addFormField(new CDFormCategoryHeader("Conference Properties"));
addFormField(new CDCheckBoxFormField("pic_in_post","Display users' pictures next to their posts",
"(user can override)",YES));
addCommandButton(new CDImageButton("update","bn_update.gif","Update",80,24));
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
} // end constructor
protected EditConferenceDialog(EditConferenceDialog other)
{
super(other);
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private final void doDisable(CommunityContext comm, ConferenceContext conf)
{
setFieldEnabled("hide",conf.canSetHideList());
} // end doDisable
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void setupDialog(CommunityContext comm, ConferenceContext conf) throws DataException, AccessError
{
doDisable(comm,conf);
setHiddenField("sig",String.valueOf(comm.getCommunityID()));
setHiddenField("conf",String.valueOf(conf.getConfID()));
setTitle("Edit Conference: " + conf.getName());
setFieldValue("name",conf.getName());
setFieldValue("descr",conf.getDescription());
if (conf.canSetHideList())
{ // this is only valid at community level
if (conf.getHideList())
setFieldValue("hide",YES);
else
setFieldValue("hide","");
} // end if
setFieldValue("read_lvl",String.valueOf(conf.getReadLevel()));
setFieldValue("post_lvl",String.valueOf(conf.getPostLevel()));
setFieldValue("create_lvl",String.valueOf(conf.getCreateLevel()));
setFieldValue("hide_lvl",String.valueOf(conf.getHideLevel()));
setFieldValue("nuke_lvl",String.valueOf(conf.getNukeLevel()));
setFieldValue("change_lvl",String.valueOf(conf.getChangeLevel()));
setFieldValue("delete_lvl",String.valueOf(conf.getDeleteLevel()));
ConferenceProperties props = conf.getProperties();
if (props.getDisplayPostPictures())
setFieldValue("pic_in_post",YES);
else
setFieldValue("pic_in_post","");
} // end setupDialog
public void doDialog(ConferenceContext conf) throws ValidationException, DataException, AccessError
{
validate(); // validate the dialog entries
ConferenceProperties props = conf.getProperties();
int read_lvl, post_lvl, create_lvl, hide_lvl, nuke_lvl, change_lvl, delete_lvl;
try
{ // get all the security levels out of their form fields
read_lvl = Integer.parseInt(getFieldValue("read_lvl"));
post_lvl = Integer.parseInt(getFieldValue("post_lvl"));
create_lvl = Integer.parseInt(getFieldValue("create_lvl"));
hide_lvl = Integer.parseInt(getFieldValue("hide_lvl"));
nuke_lvl = Integer.parseInt(getFieldValue("nuke_lvl"));
change_lvl = Integer.parseInt(getFieldValue("change_lvl"));
delete_lvl = Integer.parseInt(getFieldValue("delete_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
// sweep through the conference and set the appropriate changes
conf.setName(getFieldValue("name"));
conf.setDescription(getFieldValue("descr"));
if (conf.canSetHideList())
conf.setHideList(YES.equals(getFieldValue("hide")));
conf.setSecurityLevels(read_lvl,post_lvl,create_lvl,hide_lvl,nuke_lvl,change_lvl,delete_lvl);
// reset the properties
props.setDisplayPostPictures(YES.equals(getFieldValue("pic_in_post")));
conf.setProperties(props);
} // end doDialog
public void resetOnError(CommunityContext comm, ConferenceContext conf, String message)
{
doDisable(comm,conf);
setHiddenField("sig",String.valueOf(comm.getCommunityID()));
setHiddenField("conf",String.valueOf(conf.getConfID()));
setTitle("Edit Conference: " + conf.getName());
setErrorMessage(message);
} // end resetOnError
public Object clone()
{
return new EditConferenceDialog(this);
} // end clone
} // end class EditConferenceDialog

View File

@@ -1,128 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.*;
import java.util.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.security.Role;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class EditGlobalPropertiesDialog extends ContentDialog
{
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public EditGlobalPropertiesDialog(SecurityInfo sinf)
{
super("Edit Global Properties",null,"globpropform","sysadmin");
setHiddenField("cmd","G");
addFormField(new CDFormCategoryHeader("System Properties"));
addFormField(new CDIntegerFormField("search_items","Number of search items to display per page",
null,5,100));
addFormField(new CDIntegerFormField("fp_posts","Number of published posts to display on front page",
null,1,50));
addFormField(new CDIntegerFormField("audit_recs","Number of audit records to display per page",
null,10,500));
addFormField(new CDRoleListFormField("create_lvl","Security level required to create a new community",
null,true,sinf.getRoleList("Global.CreateCommunity")));
addFormField(new CDFormCategoryHeader("Community Properties"));
addFormField(new CDIntegerFormField("comm_mbrs","Number of community members to display per page",
null,10,100));
addFormField(new CDFormCategoryHeader("Conferencing Properties"));
addFormField(new CDIntegerFormField("posts_page","Maximum number of posts to display per page",
null,5,100));
addFormField(new CDIntegerFormField("old_posts","Number of \"old\" posts to display at top of page",
null,1,5));
addFormField(new CDIntegerFormField("conf_mbrs","Number of conference members to display per page",
null,10,100));
addFormField(new CDCheckBoxFormField("pic_in_post","Display user pictures next to posts in conferences",
"(by default; user can override)"));
addCommandButton(new CDImageButton("update","bn_update.gif","Update",80,24));
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
} // end constructor
protected EditGlobalPropertiesDialog(EditGlobalPropertiesDialog other)
{
super(other);
} // end constructor
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void setupDialog(AdminOperations adm)
{
GlobalProperties props = adm.getProperties();
setFieldObjValue("search_items",new Integer(props.getSearchItemsPerPage()));
setFieldObjValue("fp_posts",new Integer(props.getPostsOnFrontPage()));
setFieldObjValue("audit_recs",new Integer(props.getAuditRecordsPerPage()));
setFieldObjValue("create_lvl",new Integer(props.getCommunityCreateLevel()));
setFieldObjValue("comm_mbrs",new Integer(props.getCommunityMembersPerPage()));
setFieldObjValue("posts_page",new Integer(props.getPostsPerPage()));
setFieldObjValue("old_posts",new Integer(props.getOldPostsAtTop()));
setFieldObjValue("conf_mbrs",new Integer(props.getConferenceMembersPerPage()));
setFieldObjValue("pic_in_post",new Boolean(props.getDisplayPostPictures()));
} // end setupDialog
public void doDialog(AdminOperations adm) throws ValidationException, DataException
{
validate(); // validate the dialog
// Reset the global properties.
GlobalProperties props = adm.getProperties();
Integer iv = (Integer)(getFieldObjValue("search_items"));
props.setSearchItemsPerPage(iv.intValue());
iv = (Integer)(getFieldObjValue("fp_posts"));
props.setPostsOnFrontPage(iv.intValue());
iv = (Integer)(getFieldObjValue("audit_recs"));
props.setAuditRecordsPerPage(iv.intValue());
iv = (Integer)(getFieldObjValue("create_lvl"));
props.setCommunityCreateLevel(iv.intValue());
iv = (Integer)(getFieldObjValue("comm_mbrs"));
props.setCommunityMembersPerPage(iv.intValue());
iv = (Integer)(getFieldObjValue("posts_page"));
props.setPostsPerPage(iv.intValue());
iv = (Integer)(getFieldObjValue("old_posts"));
props.setOldPostsAtTop(iv.intValue());
iv = (Integer)(getFieldObjValue("conf_mbrs"));
props.setConferenceMembersPerPage(iv.intValue());
Boolean bv = (Boolean)(getFieldObjValue("pic_in_post"));
props.setDisplayPostPictures(bv.booleanValue());
adm.setProperties(props);
} // end doDialog
public Object clone()
{
return new EditGlobalPropertiesDialog(this);
} // end clone
} // end class EditGlobalPropertiesDialog

View File

@@ -1,319 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.*;
import java.net.URLEncoder;
import java.util.*;
import com.silverwrist.util.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class EditProfileDialog extends ContentDialog
{
/*--------------------------------------------------------------------------------
* The photo URL control class.
*--------------------------------------------------------------------------------
*/
static class CDUserPhotoControl extends CDBaseFormField
{
private String linkURL;
public CDUserPhotoControl(String name, String caption, String linkURL)
{
super(name,caption,"(click to change)",false);
this.linkURL = linkURL;
} // end constructor
protected CDUserPhotoControl(CDUserPhotoControl other)
{
super(other);
this.linkURL = other.linkURL;
} // end constructor
protected void renderActualField(Writer out, RenderData rdat) throws IOException
{
if (isEnabled())
out.write("<A HREF=\"" + rdat.getEncodedServletPath(linkURL) + "\">");
String photo = getValue();
if (StringUtil.isStringEmpty(photo))
photo = rdat.getPhotoNotAvailURL();
out.write("<IMG SRC=\"" + photo + "\" ALT=\"\" BORDER=0 WIDTH=100 HEIGHT=100></A>");
if (isEnabled())
out.write("</A>");
} // end renderActualField
protected void validateContents(String value) throws ValidationException
{ // this is a do-nothing value
} // end validateContents
public CDFormField duplicate()
{
return new CDUserPhotoControl(this);
} // end clone
public void setLinkURL(String s)
{
linkURL = s;
} // end setLinkURL
} // end class CDUserPhotoControl
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static final String YES = "Y";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CDUserPhotoControl photo_control;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public EditProfileDialog()
{
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,YES));
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));
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,YES));
addFormField(new CDTextFormField("fax","Fax",null,false,32,32));
addFormField(new CDCheckBoxFormField("pvt_fax","Hide fax number in profile",null,YES));
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,YES));
addFormField(new CDTextFormField("url","Home page","(URL)",false,32,255));
addFormField(new CDFormCategoryHeader("Personal"));
addFormField(new CDTextFormField("descr","Personal description",null,false,32,255));
photo_control = new CDUserPhotoControl("photo","User Photo","userphoto");
addFormField(photo_control);
addFormField(new CDFormCategoryHeader("User Preferences"));
addFormField(new CDCheckBoxFormField("pic_in_post","Display user photos next to conference posts",
"(where applicable)",YES));
addFormField(new CDCheckBoxFormField("no_mass_mail",
"Don't send me mass E-mail from community/conference hosts",
null,YES));
addFormField(new CDLocaleListFormField("locale","Default locale","(for formatting dates/times)",true));
addFormField(new CDTimeZoneListFormField("tz","Default time zone",null,true));
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);
photo_control = (CDUserPhotoControl)modifyField("photo");
} // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class Object
*--------------------------------------------------------------------------------
*/
public Object clone()
{
return new EditProfileDialog(this);
} // end clone
/*--------------------------------------------------------------------------------
* Overrides from class ContentDialog
*--------------------------------------------------------------------------------
*/
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
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
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
UserProperties props = uc.getProperties(); // get the properties
setFieldEnabled("photo",ci.canSetPhoto());
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",YES);
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",YES);
setFieldValue("fax",ci.getFax());
if (ci.getPrivateFax())
setFieldValue("pvt_fax",YES);
setFieldValue("email",ci.getEmail());
if (ci.getPrivateEmail())
setFieldValue("pvt_email",YES);
setFieldValue("url",ci.getURL());
setFieldValue("descr",uc.getDescription());
setFieldValue("photo",ci.getPhotoURL());
photo_control.setLinkURL("userphoto?tgt=" + URLEncoder.encode(target));
if (props.getDisplayPostPictures())
setFieldValue("pic_in_post",YES);
if (props.getMassMailOptOut())
setFieldValue("no_mass_mail",YES);
setFieldValue("locale",uc.getLocale().toString());
setFieldValue("tz",uc.getTimeZone().getID());
} // end setupDialog
public boolean doDialog(UserContext uc) throws ValidationException, DataException, EmailException
{
validate(); // validate the dialog
ContactInfo ci = uc.getContactInfo(); // get the main contact info
UserProperties props = uc.getProperties();
// 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 properties.
props.setDisplayPostPictures(YES.equals(getFieldValue("pic_in_post")));
props.setMassMailOptOut(YES.equals(getFieldValue("no_mass_mail")));
uc.setProperties(props);
// Save off the user's description and preferences.
uc.setDescription(getFieldValue("descr"));
uc.setLocale(International.get().createLocale(getFieldValue("locale")));
uc.setTimeZone(TimeZone.getTimeZone(getFieldValue("tz")));
// 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(boolean photo_flag, String message)
{
setErrorMessage(message);
setFieldValue("pass1",null);
setFieldValue("pass2",null);
setFieldEnabled("photo",photo_flag);
} // end resetOnError
} // end class EditProfileDialog

View File

@@ -1,91 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.Writer;
import java.io.IOException;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.servlets.VeniceServletResult;
public class ErrorBox extends VeniceServletResult implements ContentRender, ColorSelectors
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String title;
private String message;
private String back;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ErrorBox(String title, String message, String back)
{
super();
this.title = title;
this.message = message;
this.back = back;
if (this.title==null)
this.title = "Error!";
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return title;
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface 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=\"" + rdat.getStdColor(ERROR_TITLE_BACKGROUND)
+ "\">\n");
out.write(rdat.getStdFontTag(ERROR_TITLE_FOREGROUND,3) + StringUtil.encodeHTML(title) + "</FONT>\n");
out.write("</TD></TR><TR VALIGN=MIDDLE><TD ALIGN=CENTER>\n");
out.write(rdat.getStdFontTag(CONTENT_FOREGROUND,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");
} // end renderHere
} // end class ErrorBox

View File

@@ -1,443 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.Writer;
import java.io.IOException;
import java.util.*;
import javax.servlet.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
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_COMMUNITIES = 0;
public static final int FD_USERS = 1;
public static final int FD_CATEGORIES = 2;
public static final int FD_POSTS = 3;
// 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("Communities");
header_titles.add("Users");
header_titles.add("Categories");
header_titles.add("Posts");
header_titles.trimToSize();
header_urls = new Vector();
header_urls.add("find?disp=" + String.valueOf(FD_COMMUNITIES));
header_urls.add("find?disp=" + String.valueOf(FD_USERS));
header_urls.add("find?disp=" + String.valueOf(FD_CATEGORIES));
header_urls.add("find?disp=" + String.valueOf(FD_POSTS));
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_POSTS + 1;
} // end getNumChoices
public static FindData retrieve(ServletRequest request)
{
return (FindData)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Find";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* 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_COMMUNITIES)
{ // fill in the list of subcategories and of communities in this category
cat = user.getCategoryDescriptor(catid);
subcats = cat.getSubCategories();
if (cat.getCategoryID()>=0)
{ // fill in the communities that are in this category
results = user.getCommunitiesInCategory(cat,offset,getNumResultsDisplayed());
find_count = user.getNumCommunitiesInCategory(cat);
} // end if
field = FIELD_COMMUNITY_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_COMMUNITIES:
catid = getParamInt(request,"cat",-1);
if (!engine.isValidCategoryID(catid))
throw new ValidationException("The category ID parameter is not valid.");
field = getParamInt(request,"field",FIELD_COMMUNITY_NAME);
if ((field!=FIELD_COMMUNITY_NAME) && (field!=FIELD_COMMUNITY_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:
case FD_POSTS:
// no parameters to set here - there's no "field" for category/post search
break;
default:
throw new InternalStateError("loadPost failure - invalid display parameter");
} // end switch
if (disp!=FD_POSTS)
{ // 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.");
} // end if
// 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_COMMUNITIES:
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 communities that are in this category
results = user.getCommunitiesInCategory(cat,offset,count);
if (find_count<0)
find_count = user.getNumCommunitiesInCategory(cat);
} // end if
} // end if
else
{ // retrieve the community search data
results = user.searchForCommunities(field,mode,term,offset,count);
if (find_count<0)
find_count = user.getSearchCommunityCount(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;
case FD_POSTS:
results = user.searchPosts(term,offset,count);
if (find_count<0)
find_count = user.getSearchPostCount(term);
break;
} // end switch
} // end loadPost
public static String getCatJumpLink(RenderData rdat, int catid)
{
return rdat.getEncodedServletPath("find?disp=" + String.valueOf(FD_COMMUNITIES) + "&cat="
+ String.valueOf(catid));
} // end getCatJumpLink
public static String getCommunityHostName(CommunityContext comm)
{
try
{ // get the host name for the specified community
UserProfile prof = comm.getHostProfile();
return prof.getUserName();
} // end try
catch (DataException e)
{ // just return NULL if an exception strikes
return null;
} // end catch
} // end getCommunityHostName
public static int getCommunityMemberCount(CommunityContext comm)
{
try
{ // get the member count for the specified community
return comm.getMemberCount();
} // end try
catch (DataException e)
{ // just return -1 if an exception strikes
return -1;
} // end catch
} // end getCommunityMemberCount
public static String getActivityString(CommunityContext comm, RenderData rdat)
{
return rdat.getActivityString(comm.getLastAccessDate());
} // end getActivityString
} // end class FindData

View File

@@ -1,275 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.Writer;
import java.io.IOException;
import java.util.*;
import javax.servlet.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class FindPostData implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.FindPostData";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm;
private ConferenceContext conf;
private TopicContext topic;
private String term = "";
private int offset = 0;
private int find_count = 0;
private List results = null;
private int max_results = 0;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public FindPostData(CommunityContext comm, ConferenceContext conf, TopicContext topic)
{
this.comm = comm;
this.conf = conf;
this.topic = topic;
} // end constructor
/*--------------------------------------------------------------------------------
* Internal static 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, fall through
} // end catch
return default_val;
} // 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 FindPostData retrieve(ServletRequest request)
{
return (FindPostData)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Find Posts";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "findpost.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final void doSearch(ServletRequest request, VeniceEngine engine) throws AccessError, DataException
{
max_results = engine.getStdNumSearchResults();
// 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.
if (isImageButtonClicked(request,"search"))
offset = 0;
else if (isImageButtonClicked(request,"previous"))
{ // adjust the offset in the reverse direction
offset -= max_results;
if (offset<0)
offset = 0;
} // end else if
else if (isImageButtonClicked(request,"next"))
offset += max_results; // go forwards instead
else
throw new InternalStateError("Unable to determine what action triggered the form.");
if (topic!=null)
{ // search the topic
results = topic.searchPosts(term,offset,max_results);
if (find_count<0)
find_count = topic.getSearchPostCount(term);
} // end if
else if (conf!=null)
{ // search the conference
results = conf.searchPosts(term,offset,max_results);
if (find_count<0)
find_count = conf.getSearchPostCount(term);
} // end else if
else
{ // search the community
results = comm.searchPosts(term,offset,max_results);
if (find_count<0)
find_count = comm.getSearchPostCount(term);
} // end else
} // end doSearch
public final String getExtraParameters()
{
StringBuffer buf = new StringBuffer("<INPUT TYPE=\"HIDDEN\" NAME=\"sig\" VALUE=\"");
buf.append(comm.getCommunityID()).append("\">");
if (conf!=null)
{ // append the conference number parameter
buf.append("\n<INPUT TYPE=\"HIDDEN\" NAME=\"conf\" VALUE=\"").append(conf.getConfID()).append("\">");
if (topic!=null)
{ // append the topic number parameter
buf.append("\n<INPUT TYPE=\"HIDDEN\" NAME=\"top\" VALUE=\"").append(topic.getTopicNumber());
buf.append("\">");
} // end if
} // end if
return buf.toString();
} // end getExtraParameters
public final String getReturnLink(RenderData rdat)
{
if (topic!=null)
return "<A HREF=\"" + rdat.getEncodedServletPath("confdisp?sig=" + comm.getCommunityID()
+ "&conf=" + conf.getConfID() + "&top="
+ topic.getTopicNumber()) + "\">Return to Topic</A>";
else if (conf!=null)
return "<A HREF=\"" + rdat.getEncodedServletPath("confdisp?sig=" + comm.getCommunityID()
+ "&conf=" + conf.getConfID())
+ "\">Return to Topic List</A>";
else
return "<A HREF=\"" + rdat.getEncodedServletPath("confops?sig=" + comm.getCommunityID())
+ "\">Return to Topic List</A>";
} // end getReturnLink
public final String getSubtitle()
{
if (topic!=null)
return "Topic: " + topic.getName();
else if (conf!=null)
return "Conference: " + conf.getName();
else
return "Community: " + comm.getName();
} // end getSubtitle
public final String getTerm()
{
return term;
} // end getTerm
public final int getOffset()
{
return offset;
} // end getOffset
public final int getFindCount()
{
return find_count;
} // end getFindCount
public final List getResults()
{
return results;
} // end getResults
public final int getMaxResults()
{
return max_results;
} // end getMaxResults
} // end class FindPostData

View File

@@ -1,149 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.IOException;
import java.io.Writer;
import javax.servlet.ServletRequest;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
public class Invitation implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.Invitation";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm; // the community context
private ConferenceContext conf; // the conference context
private TopicContext topic; // the topic context
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public Invitation(CommunityContext comm, ConferenceContext conf, TopicContext topic)
{
this.comm = comm;
this.conf = conf;
this.topic = topic;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static Invitation retrieve(ServletRequest request)
{
return (Invitation)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Send Invitation";
} // end getPageTitle
public String getPageQID()
{
String rc = "sigops?cmd=I&sig=" + comm.getCommunityID();
if (conf!=null)
{ // add conference and topic parameters, as needed
rc += ("&conf=" + conf.getConfID());
if (topic!=null)
rc += ("&top=" + topic.getTopicNumber());
} // end if
return rc;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "invitation.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final void writeHeader(Writer out, RenderData rdat) throws IOException
{
if (topic!=null)
rdat.writeContentHeader(out,"Send Topic Invitation:",
topic.getName() + " (in " + conf.getName() + ", in " + comm.getName() + ")");
else if (conf!=null)
rdat.writeContentHeader(out,"Send Conference Invitation:",
conf.getName() + " (in " + comm.getName() + ")");
else
rdat.writeContentHeader(out,"Send Community Invitation:",comm.getName());
} // end writeHeader
public final int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public final String getParameters()
{
String rc = "<INPUT TYPE=\"HIDDEN\" NAME=\"sig\" VALUE=\"" + comm.getCommunityID() + "\">";
if (conf==null)
return rc;
rc += ("\n<INPUT TYPE=\"HIDDEN\" NAME=\"conf\" VALUE=\"" + conf.getConfID() + "\">");
if (topic==null)
return rc;
rc += ("\n<INPUT TYPE=\"HIDDEN\" NAME=\"top\" VALUE=\"" + topic.getTopicNumber() + "\">");
return rc;
} // end getAdditionalParameters
} // end class Invitation

View File

@@ -1,95 +0,0 @@
/*
* 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.core.*;
import com.silverwrist.venice.except.*;
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 community. You might have received "
+ "the join key from the community'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(CommunityContext comm)
{
setHiddenField("sig",String.valueOf(comm.getCommunityID()));
} // end setupDialog
public void doDialog(CommunityContext comm) throws ValidationException, DataException, AccessError
{
validate();
comm.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

View File

@@ -1,84 +0,0 @@
/*
* 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.except.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","");
setInstructions("Forgot your password? Enter your user name and click the Reminder button to receive "
+ "a password reminder via E-mail.");
addFormField(new CDVeniceIDFormField("user","User name",null,false,32,64));
addFormField(new CDPasswordFormField("pass","Password",null,false,32,128));
addFormField(new CDCheckBoxFormField("saveme","Remember me for next time so I can log in automatically",
null,"Y"));
addCommandButton(new CDImageButton("login","bn_log_in.gif","Log In",80,24));
addCommandButton(new CDImageButton("remind","bn_reminder.gif","Password Reminder",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

View File

@@ -1,150 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
public class ManageConference implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ManageConference";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm; // the community we're in
private ConferenceContext conf; // the conference being listed
private String locator = null; // the locator we use
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ManageConference(CommunityContext comm, ConferenceContext conf)
{
this.comm = comm;
this.conf = conf;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static ManageConference retrieve(ServletRequest request)
{
return (ManageConference)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Manage Conference: " + conf.getName();
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "manage_conf.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public final int getConfID()
{
return conf.getConfID();
} // end getConfID
public final String getConfName()
{
return conf.getName();
} // end getConfName
public final String getLocator()
{
if (locator==null)
locator = "sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID();
return locator;
} // end getLocator
public final String getDefaultPseud()
{
return conf.getDefaultPseud();
} // end getDefaultPseud
public final boolean displayInviteSection()
{
return conf.canSendInvitation();
} // end displayInviteSection
public final boolean displayAdminSection()
{
return conf.canChangeConference() || conf.canDeleteConference();
} // end displayAdminSection
} // end class ManageConference

View File

@@ -1,162 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class ManageConferenceAliases implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ManageConferenceAliases";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm; // the community we're in
private ConferenceContext conf; // the conference being listed
private List aliases; // list of aliases generated
private String error_message; // error message to display
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public ManageConferenceAliases(CommunityContext comm, ConferenceContext conf) throws DataException
{
this.comm = comm;
this.conf = conf;
this.aliases = conf.getAliases();
this.error_message = null;
} // end constructor
public ManageConferenceAliases(CommunityContext comm, ConferenceContext conf, String message)
throws DataException
{
this.comm = comm;
this.conf = conf;
this.aliases = conf.getAliases();
this.error_message = message;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static ManageConferenceAliases retrieve(ServletRequest request)
{
return (ManageConferenceAliases)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Manage Conference Aliases: " + conf.getName();
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "manage_aliases.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public int getConfID()
{
return conf.getConfID();
} // end getConfID
public String getConfName()
{
return conf.getName();
} // end getConfName
public String getLocator()
{
return "sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID();
} // end getLocator
public boolean canRemoveAliases()
{
return (aliases.size()>1);
} // end canRemoveAliases
public Iterator getAliasIterator()
{
return aliases.iterator();
} // end getAliasIterator
public String getErrorMessage()
{
return error_message;
} // end getErrorMessage
} // end class ManageConferenceAliases

View File

@@ -1,188 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class ManageTopic implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ManageTopic";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm; // the community we're in
private ConferenceContext conf; // the conference being listed
private TopicContext topic; // the topic being managed
private String locator = null; // the locator we use
private List bozos_list; // the list of "bozo" users
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ManageTopic(UserContext user, CommunityContext comm, ConferenceContext conf, TopicContext topic)
throws DataException
{
this.comm = comm;
this.conf = conf;
this.topic = topic;
// Load up the list of bozos, sorting them in user name order.
List bozo_uids = topic.getBozos();
if (bozo_uids.size()>0)
{ // use a TreeMap to do the sorting
TreeMap load_map = new TreeMap();
Iterator it = bozo_uids.iterator();
while (it.hasNext())
{ // fill in the list of user profiles
Integer uid = (Integer)(it.next());
UserProfile prof = user.getProfile(uid.intValue());
load_map.put(prof.getUserName(),prof);
} // end while
bozos_list = new ArrayList(load_map.values());
} // end if
else // no bozos - just set empty list
bozos_list = Collections.EMPTY_LIST;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static ManageTopic retrieve(ServletRequest request)
{
return (ManageTopic)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Manage Topic: " + topic.getName();
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "manage_topic.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public final int getConfID()
{
return conf.getConfID();
} // end getConfID
public final int getTopicNumber()
{
return topic.getTopicNumber();
} // end getTopicID
public final String getTopicName()
{
return topic.getName();
} // end getConfName
public final String getLocator()
{
if (locator==null)
locator = "sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID() + "&top="
+ topic.getTopicNumber();
return locator;
} // end getLocator
public final int getNumBozos()
{
return bozos_list.size();
} // end getNumBozos()
public final Iterator getBozosIterator()
{
return bozos_list.iterator();
} // end getBozosIterator
public final boolean isSubscribed()
{
return topic.isSubscribed();
} // end isSubscribed
public final boolean displayInviteSection()
{
return topic.canSendInvitation();
} // end displayInviteSection
} // end class ManageTopic

View File

@@ -1,103 +0,0 @@
/*
* 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

View File

@@ -1,155 +0,0 @@
/*
* 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.core.*;
import com.silverwrist.venice.except.*;
public class NewAccountDialog extends ContentDialog
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private VeniceEngine engine = null;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public NewAccountDialog()
{
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));
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

View File

@@ -1,129 +0,0 @@
/*
* 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.CommunityContext;
public class NewCommunityWelcome implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.NewCommunityWelcome";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String name;
private String entry_url;
private String invite_url;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public NewCommunityWelcome(CommunityContext comm)
{
name = comm.getName();
entry_url = "sig/" + comm.getAlias();
invite_url = "sigops?cmd=I&sig=" + comm.getCommunityID();
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static NewCommunityWelcome retrieve(ServletRequest request)
{
return (NewCommunityWelcome)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "New Community Created";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "newcommwelcome.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public String getCommunityName()
{
return name;
} // end getCommunityName
public String getEntryURL(RenderData rdat)
{
return rdat.getEncodedServletPath(entry_url);
} // end getEntryURL
public String getDisplayURL(RenderData rdat)
{
return rdat.getCompleteServletPath(entry_url);
} // end getEntryURL
public String getInviteURL(RenderData rdat)
{
return rdat.getEncodedServletPath(invite_url);
} // end getInviteURL
} // end class NewCommunityWelcome

View File

@@ -1,242 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import com.silverwrist.venice.htmlcheck.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class NewTopicForm implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.NewTopicForm";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm; // the community we're in
private ConferenceContext conf; // the conference being created in
private String topic_name; // the initial topic name
private String pseud; // the pseud to display
private boolean attach; // is there an attachment?
private String post_box; // stuff from the post box
private String preview = null; // the preview & spellchuck data
private int num_errors = 0; // the number of spelling errors we get
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public NewTopicForm(CommunityContext comm, ConferenceContext conf)
{
this.comm = comm;
this.conf = conf;
} // end constrcutor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static NewTopicForm retrieve(ServletRequest request)
{
return (NewTopicForm)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Create New Topic";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "newtopic.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void setupNewRequest()
{
topic_name = "";
pseud = conf.getDefaultPseud();
attach = false;
post_box = "";
} // end setupNewRequest
public void generatePreview(VeniceEngine engine, ConferenceContext conf, ServletRequest request)
throws ValidationException
{
HTMLChecker check;
try
{ // run the data through the HTML Checker
check = engine.getEscapingChecker();
// sanitize the "title" parameter
String foo = request.getParameter("title");
if (foo==null)
throw new ValidationException("Title parameter was not specified.");
check.append(foo);
check.finish();
topic_name = check.getValue();
check.reset();
// sanitize the "pseud" parameter
foo = request.getParameter("pseud");
if (foo==null)
throw new ValidationException("Pseud parameter was not specified.");
check.append(foo);
check.finish();
pseud = check.getValue();
check.reset();
// sanitize the body text itself
foo = request.getParameter("pb");
if (foo==null)
throw new ValidationException("Body text was not specified.");
check.append(foo);
check.finish();
post_box = check.getValue();
// generate the body text preview
check = conf.getNewTopicPreviewChecker();
check.append(foo);
check.finish();
preview = check.getValue();
num_errors = check.getCounter("spelling");
} // end try
catch (HTMLCheckerException e)
{ // make sure we catch the HTML Checker exceptions
throw new InternalStateError("spurious HTMLCheckerException in generatePreview",e);
} // end catch
// set the "attach" flag to save the checkbox state
final String yes = "Y";
attach = yes.equals(request.getParameter("attach"));
} // end generatePreview
public int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public int getConfID()
{
return conf.getConfID();
} // end getConfID
public String getConfName()
{
return conf.getName();
} // end getConfName
public String getTopicName()
{
return topic_name;
} // end getTopicName
public String getPseud()
{
return pseud;
} // end getPseud
public boolean getAttachCheck()
{
return attach;
} // end getAttachCheck
public String getPostBoxData()
{
return post_box;
} // end getPostBoxData
public boolean isPreview()
{
return (preview!=null);
} // end isPreview
public String getPreviewData()
{
return preview;
} // end getPreviewData
public int getNumSpellingErrors()
{
return num_errors;
} // end getNumSpellingErrors
public boolean isNullRequest()
{
return ((topic_name.length()==0) || (post_box.length()==0));
} // end isNullRequest
} // end class NewTopicForm

View File

@@ -1,216 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.htmlcheck.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class PostPreview implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.PostPreview";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm;
private ConferenceContext conf;
private TopicContext topic;
private String next;
private String pseud;
private String data;
private String preview;
private int num_errors;
private int msgs;
private boolean attach;
private boolean slippage;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public PostPreview(VeniceEngine engine, CommunityContext comm, ConferenceContext conf, TopicContext topic,
String pseud, String data, String next, int msgs, boolean attach, boolean slippage)
{
this.comm = comm;
this.conf = conf;
this.topic = topic;
this.next = next;
this.msgs = msgs;
this.attach = attach;
this.slippage = slippage;
try
{ // sanitize the pseud data
HTMLChecker check = engine.getEscapingChecker();
check.append(pseud);
check.finish();
this.pseud = check.getValue();
// sanitize the post box data
check.reset();
check.append(data);
check.finish();
this.data = check.getValue();
// now generate the preview
check = topic.getPreviewChecker();
check.append(data);
check.finish();
this.preview = check.getValue();
this.num_errors = check.getCounter("spelling");
} // end try
catch (HTMLCheckerException e)
{ // this is a bad issue...
throw new InternalStateError("spurious HTMLCheckerException thrown");
} // end catch
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static PostPreview retrieve(ServletRequest request)
{
return (PostPreview)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Previewing Message";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "preview.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getNumSpellingErrors()
{
return num_errors;
} // end getNumSpellingErrors
public String getPreviewData()
{
return preview;
} // end getPreviewData
public int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public int getConfID()
{
return conf.getConfID();
} // end getConfID
public int getTopicNumber()
{
return topic.getTopicNumber();
} // end getTopicNumber
public int getTotalMessages()
{
return msgs;
} // end getTotalMessages
public String getNextVal()
{
return next;
} // end getNextVal
public String getPseud()
{
return pseud;
} // end getPseud
public boolean attachChecked()
{
return attach;
} // end attachChecked
public String getBodyText()
{
return data;
} // end getBodyText
public boolean slippageDetected()
{
return slippage;
} // end slippageDetected
} // end class PostPreview

View File

@@ -1,243 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.htmlcheck.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class PostSlippage implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.PostSlippage";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm;
private ConferenceContext conf;
private TopicContext topic;
private List messages;
private String next;
private String pseud;
private String text;
private boolean attach;
private String topic_stem;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public PostSlippage(VeniceEngine engine, CommunityContext comm, ConferenceContext conf, TopicContext topic,
int lastval, String next, String pseud, String text, boolean attach)
throws DataException, AccessError
{
this.comm = comm;
this.conf = conf;
this.topic = topic;
this.messages = topic.getMessages(lastval,topic.getTotalMessages()-1);
this.next = next;
this.attach = attach;
List aliases = conf.getAliases();
topic_stem = (String)(aliases.get(0)) + "." + String.valueOf(topic.getTopicNumber()) + ".";
try
{ // run the text and pseud through an HTML checker to escape them
HTMLChecker ch = engine.getEscapingChecker();
ch.append(pseud);
ch.finish();
this.pseud = ch.getValue();
ch.reset();
ch.append(text);
ch.finish();
this.text = text;
} // end try
catch (HTMLCheckerException e)
{ // this shouldn't happen
throw new InternalStateError("spurious HTMLCheckerException thrown");
} // end catch
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static PostSlippage retrieve(ServletRequest request)
{
return (PostSlippage)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Slippage or Double-Click Detected";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "slippage.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public static String getPosterName(TopicMessageContext msg)
{
try
{ // have to guard agains a DataException here
return msg.getCreatorName();
} // end try
catch (DataException de)
{ // just return "unknown" on failure
return "(unknown)";
} // end catch
} // end getPosterName
public static String getMessageBodyText(TopicMessageContext msg)
{
try
{ // have to guard against a DataException here
return msg.getBodyText();
} // end try
catch (DataException de)
{ // just return an error message
return "<EM>(Unable to retrieve message data: " + StringUtil.encodeHTML(de.getMessage()) + ")</EM>";
} // end catch
} // end getMessageBodyText
public int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public int getConfID()
{
return conf.getConfID();
} // end getConfID
public int getTopicNumber()
{
return topic.getTopicNumber();
} // end getTopicNumber
public String getTopicName()
{
return topic.getName();
} // end getTopicName
public String getIdentifyingData()
{
return "Slippage posting to topic " + String.valueOf(topic.getTopicID());
} // end getIdentifyingData
public int getTotalMessages()
{
return topic.getTotalMessages();
} // end getTotalMessages
public Iterator getMessageIterator()
{
return messages.iterator();
} // end getMessageIterator
public String getNextVal()
{
return next;
} // end getNextVal
public String getPseud()
{
return pseud;
} // end getPseud
public boolean attachChecked()
{
return attach;
} // end attachChecked
public String getBodyText()
{
return text;
} // end getBodyText
public String getMessageReference(TopicMessageContext msg)
{
return topic_stem + String.valueOf(msg.getPostNumber());
} // end getMessageReference
} // end class PostSlippage

View File

@@ -1,675 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import org.w3c.dom.*;
import com.silverwrist.util.*;
import com.silverwrist.venice.core.CommunityContext;
import com.silverwrist.venice.core.UserContext;
import com.silverwrist.venice.core.VeniceEngine;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.servlets.Variables;
import com.silverwrist.venice.servlets.format.menus.*;
import com.silverwrist.venice.servlets.format.sideboxes.SideBoxFactory;
import com.silverwrist.venice.util.XMLLoader;
public class RenderConfig implements ColorSelectors
{
/*--------------------------------------------------------------------------------
* 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);
private static Map colornames_map;
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String site_title;
private boolean want_comments;
private boolean allow_gzip;
private boolean no_smart_tags;
private String font_face;
private File stylesheet;
private long stylesheet_time = 0;
private String image_url;
private String static_url;
private String site_logo;
private int site_logo_width = 140;
private int site_logo_height = 80;
private String site_logo_linkURL = null;
private StockMessages stock_messages;
private Map menus;
private String[] colors_array;
private int footer_logo_scale;
private Map sidebox_factories;
private String photo_not_avail;
private boolean photo_not_avail_fixup;
private CommunityLeftMenuFactory comm_menu_fact;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
protected RenderConfig(String config_file, String root_file_path) throws ConfigException
{
XMLLoader loader = XMLLoader.get();
Document doc = loader.loadConfigDocument(config_file);
// Make sure the document is valid.
Element root = loader.configGetRootElement(doc,"render-config");
DOMElementHelper root_h = new DOMElementHelper(root);
// Get the site title.
site_title = loader.configGetSubElementText(root_h,"site-name");
if (logger.isDebugEnabled())
logger.debug("Site title: " + site_title);
// Get the <rendering/> section.
Element sect = loader.configGetSubSection(root_h,"rendering");
// Load the quick Boolean values indicated by the presence or absence of a tag.
DOMElementHelper sect_h = new DOMElementHelper(sect);
want_comments = sect_h.hasChildElement("html-comments");
allow_gzip = sect_h.hasChildElement("gzip-output");
no_smart_tags = !(sect_h.hasChildElement("ms-copyright-violations"));
if (logger.isDebugEnabled())
{ // log the read values
logger.debug("Use HTML comments: " + want_comments);
logger.debug("Use GZIP encoding: " + allow_gzip);
logger.debug("Disable IE Smart Tags: " + no_smart_tags);
} // end if
// Load the default font face.
font_face = loader.configGetSubElementText(sect_h,"font");
if (logger.isDebugEnabled())
logger.debug("Font face: " + font_face);
// Load the default stylesheet file reference.
String tmp = sect_h.getSubElementText("stylesheet");
if (tmp!=null)
{ // we're using Cascading Stylesheets - load it and test for existence
if (!(tmp.startsWith("/"))) // prepend app root
tmp = root_file_path + tmp;
if (logger.isDebugEnabled())
logger.debug("Stylesheet location: " + tmp);
// Test to make sure the stylesheet is actually present.
stylesheet = new File(tmp);
if (!(stylesheet.exists() && stylesheet.canRead()))
{ // it's not there - bail out!
logger.fatal("unable to read stylesheet file: " + tmp);
throw new ConfigException("stylesheet " + tmp + " cannot be read",sect);
} // end if
} // end if
else // no stylesheet
stylesheet = null;
// Get the <colors/> section and load the colors out of it..
Element sect1 = loader.configGetSubSection(sect_h,"colors");
colors_array = new String[colornames_map.size()];
int i;
NodeList nl = sect1.getChildNodes();
for (i=0; i<nl.getLength(); i++)
{ // look at all subelements and map their names to color selectors
Node n = nl.item(i);
if (n.getNodeType()==Node.ELEMENT_NODE)
{ // map the name of the node to a color selector
Integer cs = (Integer)(colornames_map.get(n.getNodeName()));
if (cs!=null)
{ // get the color value and load it into the array
DOMElementHelper h = new DOMElementHelper((Element)n);
colors_array[cs.intValue()] = h.getElementText();
} // end if
} // end if
} // end for
// Load in the footer logo scale.
Integer itmp = sect_h.getSubElementInt("footer-logo-scale");
footer_logo_scale = ((itmp==null) ? 100 : itmp.intValue());
// Get the <paths/> section.
sect = loader.configGetSubSection(root_h,"paths");
sect_h = new DOMElementHelper(sect);
// Load the image path.
image_url = loader.configGetSubElementText(sect_h,"image");
if (logger.isDebugEnabled())
logger.debug("Image path: " + image_url);
// Load the static path.
static_url = loader.configGetSubElementText(sect_h,"static");
if (logger.isDebugEnabled())
logger.debug("Static files path: " + static_url);
// Get the site logo element.
sect1 = loader.configGetSubSection(sect_h,"site-logo");
DOMElementHelper sect1_h = new DOMElementHelper(sect1);
site_logo = loader.configGetText(sect1_h);
// Get the width and height of the logo.
itmp = sect1_h.getAttributeInt("width");
if (itmp!=null)
site_logo_width = itmp.intValue();
itmp = sect1_h.getAttributeInt("height");
if (itmp!=null)
site_logo_height = itmp.intValue();
// Get the link URL of the logo.
tmp = sect1.getAttribute("href");
if (!(StringUtil.isStringEmpty(tmp)))
site_logo_linkURL = tmp;
if (logger.isDebugEnabled())
logger.debug("Site logo: " + site_logo);
// Get the name of the sidebox configuration file.
String sidebox_config = loader.configGetSubElementText(sect_h,"sidebox-config");
if (!(sidebox_config.startsWith("/")))
sidebox_config = root_file_path + sidebox_config;
// Get the name of the "photo not available" image.
sect1 = sect_h.getSubElement("photo-not-avail");
if (sect1!=null)
{ // load the element text and fixup information
sect1_h = new DOMElementHelper(sect1);
photo_not_avail = sect1_h.getElementText();
photo_not_avail_fixup = sect1_h.hasAttribute("fixup");
} // end if
else
{ // just load the defaults
photo_not_avail = "photo_not_avail.gif";
photo_not_avail_fixup = true;
} // end else
// Get the name of the services configuration file.
String services_config = loader.configGetSubElementText(sect_h,"services-config");
if (!(services_config.startsWith("/")))
services_config = root_file_path + services_config;
// Load the <messages/> section.
sect = loader.configGetSubSection(root_h,"messages");
// Initialize the stock messages list.
stock_messages = new StockMessages(sect);
// Load the <menu-definitions/> section.
sect = loader.configGetSubSection(root_h,"menu-definitions");
// Initialize the menus list.
HashMap tmp_menus = new HashMap();
nl = sect.getChildNodes();
for (i=0; i<nl.getLength(); i++)
{ // look for <menudef> subnodes and use them to initialize menus
Node n = nl.item(i);
if (n.getNodeType()==Node.ELEMENT_NODE)
{ // verify that it's a menu definition, then get its ID and build a menu
loader.configVerifyNodeName(n,"menudef",sect);
String menuid = loader.configGetAttribute((Element)n,"id");
// create the menu and add it to the mapping
LeftMenu menu = new LeftMenu((Element)n,menuid);
tmp_menus.put(menuid,menu);
if (logger.isDebugEnabled())
logger.debug("menu \"" + menuid + "\" defined");
} // end if
// else just ignore it
} // end for
// save off the menus as an unmodifiable map
if (tmp_menus.isEmpty())
menus = Collections.EMPTY_MAP;
else
menus = Collections.unmodifiableMap(tmp_menus);
if (logger.isDebugEnabled())
logger.debug(menus.size() + " menu definitions loaded from config");
// done with the render-config.xml file
// Load up the sidebox-config.xml file.
doc = loader.loadConfigDocument(sidebox_config);
root = loader.configGetRootElement(doc,"sidebox-config");
// Examine the child nodes for sidebox configuration data.
nl = root.getChildNodes();
HashMap tmp_factories = new HashMap();
for (i=0; i<nl.getLength(); i++)
{ // extract each sidebox section from the list and build a new master sidebox object
Node n = nl.item(i);
if ((n.getNodeType()==Node.ELEMENT_NODE) && (n.getNodeName().equals("sidebox")))
{ // get the ID for this sidebox
try
{ // get the ID and convert it to integer
tmp = loader.configGetAttribute((Element)n,"id");
itmp = new Integer(tmp);
} // end try
catch (NumberFormatException nfe)
{ // sidebox ID was not an integer!
logger.fatal("<sidebox/> ID not numeric!");
throw new ConfigException("non-numeric ID specified in <sidebox/>",(Element)n);
} // end catch
SideBoxFactory factory = createSideBoxFactory((Element)n);
tmp_factories.put(itmp,factory);
} // end if
// else ignore this node
} // end for
if (tmp_factories.isEmpty())
sidebox_factories = Collections.EMPTY_MAP;
else
sidebox_factories = Collections.unmodifiableMap(tmp_factories);
// done with the sidebox-config.xml file
// Load up the services-config.xml file.
doc = loader.loadConfigDocument(services_config);
root = loader.configGetRootElement(doc,"services-config");
root_h = new DOMElementHelper(root);
// Get the community section and pass it to the CommunityLeftMenuFactory.
comm_menu_fact = new CommunityLeftMenuFactory(root_h.getSubElement("community"));
} // end constructor
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private static SideBoxFactory createSideBoxFactory(Element cfg) throws ConfigException
{
XMLLoader loader = XMLLoader.get();
String cname = loader.configGetSubElementText(cfg,"factory-class");
try
{ // load the factory class and create an instance of the factory
SideBoxFactory factory = (SideBoxFactory)(Class.forName(cname).newInstance());
factory.setConfiguration(cfg);
return factory;
} // end try
catch (ClassNotFoundException cnfe)
{ // sidebox could not be configured
logger.fatal("<sidebox/> config <factory-class/> not valid!",cnfe);
throw new ConfigException("<factory-class/> in <sidebox/> is not a valid class!",cfg);
} // end catch
catch (IllegalAccessException iae)
{ // could not access class and/or constructor
logger.fatal("<sidebox/> <factory-class/> is not accessible!",iae);
throw new ConfigException("<factory-class/> in <sidebox/> is not accessible!",cfg);
} // end catch
catch (InstantiationException ie)
{ // unable to create the class
logger.fatal("<sidebox/> <factory-class/> could not be instantiated!",ie);
throw new ConfigException("<factory-class/> in <sidebox/> could not be created!",cfg);
} // end catch
catch (ClassCastException cce)
{ // the class is not a SideBoxFactory implementor - cannot create
logger.fatal("<sidebox/> <factory-class/> is not a SideBoxFactory!",cce);
throw new ConfigException("<factory-class/> in <sidebox/> is not the correct type!",cfg);
} // end catch
} // end createSideBoxFactory
/*--------------------------------------------------------------------------------
* External operations usable only by RenderData
*--------------------------------------------------------------------------------
*/
boolean useHTMLComments()
{
return want_comments;
} // end useHTMLComments
boolean isGZIPAllowed()
{
return allow_gzip;
} // end isGZIPAllowed
boolean noSmartTags()
{
return no_smart_tags;
} // end noSmartTags
String getFullImagePath(String name)
{
StringBuffer buf = new StringBuffer();
buf.append(image_url).append(name);
return buf.toString();
} // end getFullImagePath
String getStaticFilePath(String name)
{
StringBuffer buf = new StringBuffer();
buf.append(static_url).append(name);
return buf.toString();
} // end getStaticFilePath
String getTitleTag(String specific)
{
StringBuffer buf = new StringBuffer();
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();
if (site_logo_linkURL!=null)
buf.append("<A HREF=\"").append(site_logo_linkURL).append("\">");
buf.append("<IMG SRC=\"").append(site_logo).append("\" ALT=\"").append(site_title);
buf.append("\" WIDTH=").append(site_logo_width).append(" HEIGHT=").append(site_logo_height);
buf.append(" BORDER=0");
if (hspace>0)
buf.append(" HSPACE=").append(hspace);
if (vspace>0)
buf.append(" VSPACE=").append(vspace);
buf.append('>');
if (site_logo_linkURL!=null)
buf.append("</A>");
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
String getStdFontTag(int selector, int size)
{
if ((selector<0) || (selector>=colors_array.length))
throw new IndexOutOfBoundsException("getStdColor(): invalid color selector value");
return getStdFontTag(colors_array[selector],size);
} // end getStdFontTag
String getStdBaseFontTag(int size)
{
StringBuffer buf = new StringBuffer("<BASEFONT FACE=\"");
buf.append(font_face).append("\" SIZE=").append(size).append('>');
return buf.toString();
} // end getStdBaseFontTag
public String getRequiredBullet()
{
StringBuffer buf = new StringBuffer("<FONT FACE=\"");
buf.append(font_face).append("\" COLOR=\"red\">*</FONT>");
return buf.toString();
} // end getRequiredBullet
void writeContentHeader(Writer out, String primary, String secondary) throws IOException
{
out.write("<SPAN CLASS=\"chead1\">" + getStdFontTag(colors_array[CONTENT_HEADER],5) + "<B>"
+ StringUtil.encodeHTML(primary) + "</B></FONT></SPAN>");
if (secondary!=null)
out.write("&nbsp;&nbsp;<SPAN CLASS=\"chead2\">" + getStdFontTag(colors_array[CONTENT_HEADER],3) + "<B>"
+ StringUtil.encodeHTML(secondary) + "</B></FONT></SPAN>");
out.write("<HR ALIGN=LEFT SIZE=2 WIDTH=\"90%\" NOSHADE>\n");
} // end writeContentHeader
String getStockMessage(String identifier)
{
return (String)(stock_messages.get(identifier));
} // end getStockMessage
void writeStockMessage(Writer out, String identifier) throws IOException
{
String text = (String)(stock_messages.get(identifier));
out.write(StringUtil.encodeHTML(text));
} // end writeStockMessage
String getStdColor(int selector)
{
if ((selector<0) || (selector>=colors_array.length))
throw new IndexOutOfBoundsException("getStdColor(): invalid color selector value");
return colors_array[selector];
} // end getStdColor
int scaleFooterLogo(int param)
{
return (param * footer_logo_scale) / 100;
} // end scaleFooterLogo
public LeftMenu getLeftMenu(String identifier)
{
return (LeftMenu)(menus.get(identifier));
} // end getLeftMenu
synchronized String loadStyleSheetData() throws IOException
{
if (stylesheet==null)
return null;
// Load the stylesheet data.
StringBuffer raw_data = IOUtil.loadText(stylesheet);
stylesheet_time = stylesheet.lastModified();
// Set up the replacements map to replace the various parameters.
HashMap vars = new HashMap();
vars.put("font",font_face);
vars.put("color.frame",colors_array[FRAME_BACKGROUND]);
vars.put("color.top.background",colors_array[TITLE_BACKGROUND]);
vars.put("color.top.foreground",colors_array[TITLE_FOREGROUND]);
vars.put("color.top.link",colors_array[TITLE_LINK]);
vars.put("color.left.background",colors_array[LEFT_BACKGROUND]);
vars.put("color.left.foreground",colors_array[LEFT_FOREGROUND]);
vars.put("color.left.link",colors_array[LEFT_LINK]);
vars.put("color.content.background",colors_array[CONTENT_BACKGROUND]);
vars.put("color.content.foreground",colors_array[CONTENT_FOREGROUND]);
vars.put("color.content.header",colors_array[CONTENT_HEADER]);
vars.put("color.disabled",colors_array[CONTENT_DISABLED]);
vars.put("color.error",colors_array[CONTENT_ERROR]);
vars.put("color.sidebox.top.background",colors_array[SIDEBOX_TITLE_BACKGROUND]);
vars.put("color.sidebox.top.foreground",colors_array[SIDEBOX_TITLE_FOREGROUND]);
vars.put("color.sidebox.background",colors_array[SIDEBOX_CONTENT_BACKGROUND]);
vars.put("color.sidebox.foreground",colors_array[SIDEBOX_CONTENT_FOREGROUND]);
vars.put("color.sidebox.link",colors_array[SIDEBOX_CONTENT_LINK]);
vars.put("color.dlg.confirm.title.background",colors_array[CONFIRM_TITLE_BACKGROUND]);
vars.put("color.dlg.confirm.title.foreground",colors_array[CONFIRM_TITLE_FOREGROUND]);
vars.put("color.dlg.error.title.background",colors_array[ERROR_TITLE_BACKGROUND]);
vars.put("color.dlg.error.title.foreground",colors_array[ERROR_TITLE_FOREGROUND]);
return StringUtil.replaceAllVariables(raw_data.toString(),vars);
} // end loadStyleSheet
boolean hasStyleSheetChanged()
{
if (stylesheet==null)
return false;
return (stylesheet_time!=stylesheet.lastModified());
} // end hasStyleSheetChanged
boolean useStyleSheet()
{
return (stylesheet!=null);
} // end useStyleSheet
VeniceContent createSideBox(int id, VeniceEngine engine, UserContext uc) throws AccessError, DataException
{
SideBoxFactory fact = (SideBoxFactory)(sidebox_factories.get(new Integer(id)));
if (fact==null)
throw new DataException("invalid sidebox ID!");
return fact.create(engine,uc);
} // end createSideBox
String getPhotoNotAvail()
{
return photo_not_avail;
} // end getPhotoNotAvail
boolean getPhotoNotAvailFixup()
{
return photo_not_avail_fixup;
} // end getPhotoNotAvailFixup
public CommunityLeftMenu createCommunityMenu(CommunityContext comm)
{
return comm_menu_fact.createMenu(comm);
} // end createCommunityMenu
String getDefaultServletAddress(RenderData rdat, CommunityContext comm)
{
return comm_menu_fact.getDefaultServletAddress(rdat,comm);
} // end getDefaultServletAddress
/*--------------------------------------------------------------------------------
* 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 root file path.
String root_file_path = ctxt.getRealPath("/");
if (!(root_file_path.endsWith("/")))
root_file_path += "/";
// Get the parameter for the renderer's config file.
String cfgfile = ctxt.getInitParameter(CONFIG_FILE_PARAM);
if (!(cfgfile.startsWith("/")))
cfgfile = root_file_path + cfgfile;
logger.info("Initializing Venice rendering using config file: " + cfgfile);
try
{ // create the RenderConfig object and save it to attributes.
RenderConfig rconf = new RenderConfig(cfgfile,root_file_path);
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
{
UserContext uc = Variables.getUserContext(ctxt,request,request.getSession(true));
return new RenderData(getRenderConfig(ctxt),uc,ctxt,request,response);
} // end createRenderData
public static RenderData createRenderData(ServletContext ctxt, UserContext uc, HttpServletRequest request,
HttpServletResponse response) throws ServletException
{
return new RenderData(getRenderConfig(ctxt),uc,ctxt,request,response);
} // end createRenderData
/*--------------------------------------------------------------------------------
* Static initializer
*--------------------------------------------------------------------------------
*/
static
{ // Initialize the mapping of color names from render-config.xml to color selector IDs.
HashMap m = new HashMap();
m.put("frame-bg",new Integer(FRAME_BACKGROUND));
m.put("title-bg",new Integer(TITLE_BACKGROUND));
m.put("title-fg",new Integer(TITLE_FOREGROUND));
m.put("title-link",new Integer(TITLE_LINK));
m.put("left-bg",new Integer(LEFT_BACKGROUND));
m.put("left-fg",new Integer(LEFT_FOREGROUND));
m.put("left-link",new Integer(LEFT_LINK));
m.put("content-bg",new Integer(CONTENT_BACKGROUND));
m.put("content-fg",new Integer(CONTENT_FOREGROUND));
m.put("content-hdr",new Integer(CONTENT_HEADER));
m.put("content-disabled",new Integer(CONTENT_DISABLED));
m.put("content-error",new Integer(CONTENT_ERROR));
m.put("sidebox-title-bg",new Integer(SIDEBOX_TITLE_BACKGROUND));
m.put("sidebox-title-fg",new Integer(SIDEBOX_TITLE_FOREGROUND));
m.put("sidebox-content-bg",new Integer(SIDEBOX_CONTENT_BACKGROUND));
m.put("sidebox-content-fg",new Integer(SIDEBOX_CONTENT_FOREGROUND));
m.put("sidebox-content-link",new Integer(SIDEBOX_CONTENT_LINK));
m.put("confirm-title-bg",new Integer(CONFIRM_TITLE_BACKGROUND));
m.put("confirm-title-fg",new Integer(CONFIRM_TITLE_FOREGROUND));
m.put("error-title-bg",new Integer(ERROR_TITLE_BACKGROUND));
m.put("error-title-fg",new Integer(ERROR_TITLE_FOREGROUND));
colornames_map = Collections.unmodifiableMap(m);
} // end static initializer
} // end class RenderConfig

View File

@@ -1,597 +0,0 @@
/*
* 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 java.io.*;
import java.text.DateFormat;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.util.IOUtil;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.CommunityContext;
import com.silverwrist.venice.core.UserContext;
import com.silverwrist.venice.core.VeniceEngine;
import com.silverwrist.venice.db.PostLinkRewriter;
import com.silverwrist.venice.db.UserNameRewriter;
import com.silverwrist.venice.except.DataException;
import com.silverwrist.venice.servlets.format.menus.LeftMenu;
import com.silverwrist.venice.util.IDUtils;
public class RenderData implements ColorSelectors
{
/*--------------------------------------------------------------------------------
* 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 ServletContext ctxt;
private HttpServletRequest request;
private HttpServletResponse response;
private boolean can_gzip = false;
private Locale my_locale;
private TimeZone my_timezone;
private DateFormat activity_time = null;
private DateFormat display_date = null;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
RenderData(RenderConfig rconf, UserContext uc, ServletContext ctxt, HttpServletRequest request,
HttpServletResponse response)
{
this.rconf = rconf;
this.ctxt = ctxt;
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;
// read the user's preferred locale
try
{ // get the user default locale
my_locale = uc.getLocale();
} // end try
catch (DataException de)
{ // locale problems...
my_locale = Locale.getDefault();
} // end catch
// read the user's preferred time zone
try
{ // get the user default timezone
my_timezone = uc.getTimeZone();
} // end try
catch (DataException de)
{ // time zone problems...
my_timezone = TimeZone.getDefault();
} // end catch
} // 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 boolean noSmartTags()
{
return rconf.noSmartTags();
} // end noSmartTags
public String getSiteImageTag(int hspace, int vspace)
{
return rconf.getSiteImageTag(hspace,vspace);
} // end getSiteImageTag
public String getFullServletPath(String name)
{
StringBuffer buf = new StringBuffer(request.getContextPath());
buf.append('/').append(name);
return buf.toString();
} // end getFullServletPath
public String getCompleteServletPath(String name)
{
StringBuffer buf = new StringBuffer("http://");
buf.append(request.getServerName());
if (request.getServerPort()!=80)
buf.append(':').append(request.getServerPort());
buf.append(request.getContextPath()).append('/').append(name);
return buf.toString();
} // end getCompleteServletPath
public String getEncodedServletPath(String name)
{
return response.encodeURL(this.getFullServletPath(name));
} // end getEncodedServletPath
public String getFullImagePath(String name)
{
return rconf.getFullImagePath(name);
} // end getFullImagePath
public String getStaticFilePath(String name)
{
return rconf.getStaticFilePath(name);
} // end getStaticFilePath
public String getFormatJSPPath(String name)
{
return "/format/" + name;
} // end getFormatJSPPath
public String getStaticIncludePath(String name)
{
return "/static/" + name;
} // end getStaticIncludePath
public String getContextRelativePath(String name)
{
StringBuffer buf = new StringBuffer(request.getContextPath());
if (name.charAt(0)!='/')
buf.append('/');
return buf.append(name).toString();
} // end getContextRelativePath
public String getStdFontTag(String color, int size)
{
return rconf.getStdFontTag(color,size);
} // end getStdFontTag
public String getStdFontTag(int selector, int size)
{
return rconf.getStdFontTag(selector,size);
} // end getStdFontTag
public String getStdBaseFontTag(int size)
{
return rconf.getStdBaseFontTag(size);
} // end getStdBaseFontTag
public String getTitleTag(String specific)
{
return rconf.getTitleTag(specific);
} // end getTitleTag
public String getRequiredBullet()
{
return rconf.getRequiredBullet();
} // end getRequiredBullet
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("<SPAN CLASS=\"chead1\">" + rconf.getStdFontTag(CONTENT_HEADER,5) + "<B>"
+ StringUtil.encodeHTML(caption) + "</B></FONT></SPAN>&nbsp;&nbsp;<SPAN CLASS=\"chead2\">"
+ rconf.getStdFontTag(CONTENT_HEADER,3));
for (int i=0; i<nchoice; i++)
{ // loop through all the choices
if (i==0)
out.write("[");
else
out.write("|");
out.write("&nbsp;");
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("&nbsp;");
} // end for
out.write("]</FONT></SPAN><HR ALIGN=LEFT SIZE=2 WIDTH=\"90%\" NOSHADE>\n");
} // end writeContentSelectorHeader
public String getStockMessage(String identifier)
{
return rconf.getStockMessage(identifier);
} // end getStockMessage
public void writeStockMessage(Writer out, String identifier) throws IOException
{
rconf.writeStockMessage(out,identifier);
} // end writeStockMessage
public String getStdColor(int selector)
{
return rconf.getStdColor(selector);
} // end getStdColor
public int scaleFooterLogo(int param)
{
return rconf.scaleFooterLogo(param);
} // end scaleFooterLogo
public LeftMenu getLeftMenu(String identifier)
{
return rconf.getLeftMenu(identifier);
} // end getLeftMenu
public String loadStyleSheetData() throws IOException
{
return rconf.loadStyleSheetData();
} // end loadStyleSheetData
public boolean hasStyleSheetChanged()
{
return rconf.hasStyleSheetChanged();
} // end hasStyleSheetChanged
public boolean useStyleSheet()
{
return rconf.useStyleSheet();
} // end useStyleSheet
public String getPhotoNotAvailURL()
{
if (rconf.getPhotoNotAvailFixup())
return rconf.getFullImagePath(rconf.getPhotoNotAvail());
else
return rconf.getPhotoNotAvail();
} // end getPhotoNotAvailURL
public String getDefaultServletAddress(CommunityContext comm)
{
return rconf.getDefaultServletAddress(this,comm);
} // end getDefaultServletAddress
public String formatDateForDisplay(Date date)
{
if (display_date==null)
{ // create the display date formatter
display_date = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM,my_locale);
display_date.setTimeZone(my_timezone);
} // end if
return display_date.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 setRequestAttribute(String name, Object value)
{
request.setAttribute(name,value);
} // end setRequestAttribute
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(this.getFullServletPath(servlet));
response.sendRedirect(url);
} // end redirectTo
public void redirectAbsolute(String url) throws IOException
{
response.sendRedirect(url);
} // end redirectAbsolute
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:
if (activity_time==null)
{ // get the "activity" time formatter
activity_time = DateFormat.getTimeInstance(DateFormat.MEDIUM,my_locale);
activity_time.setTimeZone(my_timezone);
} // end if
return "Today, " + activity_time.format(date);
case 1:
if (activity_time==null)
{ // get the "activity" time formatter
activity_time = DateFormat.getTimeInstance(DateFormat.MEDIUM,my_locale);
activity_time.setTimeZone(my_timezone);
} // end if
return "Yesterday, " + activity_time.format(date);
default:
return String.valueOf(delta_days) + " days ago";
} // end switch
} // end getActivityString
public void nullResponse()
{
response.setStatus(response.SC_NO_CONTENT);
} // end nullResponse
public void errorResponse(int code) throws IOException
{
response.sendError(code);
} // end errorResponse
public void errorResponse(int code, String msg) throws IOException
{
response.sendError(code,msg);
} // end errorResponse
public void sendBinaryData(String type, String filename, int length, InputStream data) throws IOException
{
response.setContentType(type);
response.setContentLength(length);
if (filename!=null) // make sure we pass the filename along, too
response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\";");
// Copy the contents of the "data" stream to the output.
IOUtil.copy(data,response.getOutputStream());
} // end sendBinaryData
public String rewritePostData(String data)
{
if ((data.indexOf(PostLinkRewriter.URI_PREFIX)<0) && (data.indexOf(UserNameRewriter.URI_PREFIX)<0))
return data;
StringBuffer buf = new StringBuffer();
String interm;
if (data.indexOf(PostLinkRewriter.URI_PREFIX)>=0)
{ // begin replacing everything with post links
String t = data;
int p = t.indexOf(PostLinkRewriter.URI_PREFIX);
while (p>=0)
{ // break off the start of the string
if (p>0)
buf.append(t.substring(0,p));
t = t.substring(p + PostLinkRewriter.URI_PREFIX.length());
// find the end of the post link...
p = 0;
while (IDUtils.isValidPostLinkChar(t.charAt(p)))
p++;
if (p>0)
{ // append the post link to the "go" servlet path, and encode the lot
buf.append(getEncodedServletPath("go/" + t.substring(0,p)));
t = t.substring(p);
} // end if
else // false alarm
buf.append(PostLinkRewriter.URI_PREFIX);
// and now look again...
p = t.indexOf(PostLinkRewriter.URI_PREFIX);
} // end while
buf.append(t);
interm = buf.toString();
buf.setLength(0);
} // end if
else // no post link strings, this is the intermediate form
interm = data;
if (interm.indexOf(UserNameRewriter.URI_PREFIX)>=0)
{ // begin replacing everything with user links
String t = interm;
int p = t.indexOf(UserNameRewriter.URI_PREFIX);
while (p>=0)
{ // break off the start of the string
if (p>0)
buf.append(t.substring(0,p));
t = t.substring(p + UserNameRewriter.URI_PREFIX.length());
// find the end of the user link...
p = 0;
while (IDUtils.isValidVeniceIDChar(t.charAt(p)))
p++;
if (p>0)
{ // append the post link to the "user" servlet path, and encode the lot
buf.append(getEncodedServletPath("user/" + t.substring(0,p)));
t = t.substring(p);
} // end if
else // false alarm
buf.append(UserNameRewriter.URI_PREFIX);
// and now look again...
p = t.indexOf(UserNameRewriter.URI_PREFIX);
} // end while
buf.append(t);
return buf.toString();
} // end if
else // no more to find - just return this
return interm;
} // end rewritePostData
public String mapToPath(String path)
{
return ctxt.getRealPath(path);
} // end mapToPath
public Cookie createCookie(String name, String value, int age)
{
Cookie rc = new Cookie(name,value);
rc.setMaxAge(age);
rc.setPath(request.getContextPath());
return rc;
} // end createCookie
} // end class RenderData

View File

@@ -1,135 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class ReportConferenceMenu implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ReportConferenceMenu";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm; // the community we're in
private ConferenceContext conf; // the conference being listed
private List topics; // the topics in this conference
private String locator = null; // the locator
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ReportConferenceMenu(CommunityContext comm, ConferenceContext conf) throws DataException, AccessError
{
this.comm = comm;
this.conf = conf;
this.topics = conf.getTopicList(ConferenceContext.GET_ALL,ConferenceContext.SORT_NUMBER);
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static ReportConferenceMenu retrieve(ServletRequest request)
{
return (ReportConferenceMenu)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Conference Reports: " + conf.getName();
} // end getPageTitle
public String getPageQID()
{
return "confops?cmd=QR&" + getLocator();
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "report_conf.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getConfID()
{
return conf.getConfID();
} // end getConfID
public String getConfName()
{
return conf.getName();
} // end getConfName
public String getLocator()
{
if (locator==null)
locator = "sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID();
return locator;
} // end getLocator
public Iterator getTopics()
{
return topics.iterator();
} // end getTopics
} // end class ReportConferenceMenu

View File

@@ -1,157 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class SideBoxList implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.SideBoxList";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private UserContext uc; // user context
private List in_list; // sideboxes that are "in"
private List out_list; // sideboxes that are "out"
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public SideBoxList(VeniceEngine engine, UserContext uc) throws DataException
{
this.uc = uc;
this.in_list = uc.getSideBoxList();
HashSet ids = new HashSet(in_list.size());
Iterator it = in_list.iterator();
while (it.hasNext())
{ // add the IDs of all the sideboxes to the set
SideBoxDescriptor d = (SideBoxDescriptor)(it.next());
ids.add(new Integer(d.getID()));
} // end while
List all_list = engine.getMasterSideBoxList();
if (all_list.size()>in_list.size())
{ // allocate an ArrayList to hold the sideboxes
out_list = new ArrayList(all_list.size()-in_list.size());
it = all_list.iterator();
while (it.hasNext())
{ // get all sideboxes not in the "in" list and put them in the "out" list
SideBoxDescriptor d = (SideBoxDescriptor)(it.next());
if (!(ids.contains(new Integer(d.getID()))))
out_list.add(d);
} // end while
} // end if
else // all sideboxes are "in"...
out_list = Collections.EMPTY_LIST;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static SideBoxList retrieve(ServletRequest request)
{
return (SideBoxList)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Your Front Page Configuration";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "sideboxlist.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getInListSize()
{
return in_list.size();
} // end getInListSize
public SideBoxDescriptor getInListItem(int index)
{
return (SideBoxDescriptor)(in_list.get(index));
} // end getInListItem
public int getOutListSize()
{
return out_list.size();
} // end getOutListSize
public SideBoxDescriptor getOutListItem(int index)
{
return (SideBoxDescriptor)(out_list.get(index));
} // end getInListItem
} // end class SideBoxList

View File

@@ -1,180 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.*;
import com.silverwrist.util.IOUtil;
import com.silverwrist.util.cache.CacheMap;
public class StaticRender implements ContentRender
{
/*--------------------------------------------------------------------------------
* Static data values
*--------------------------------------------------------------------------------
*/
private static CacheMap cache = new CacheMap(15,25);
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String name;
private boolean processed = false;
private String title = null;
private String content = null;
/*--------------------------------------------------------------------------------
* Static data values
*--------------------------------------------------------------------------------
*/
protected StaticRender(String name)
{
this.name = name;
} // end constructor
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private static String searchBetweenTags(StringBuffer data, String search, String tagname)
{
tagname = tagname.toUpperCase();
String start = "<" + tagname;
String end = "</" + tagname + ">";
int startpos = search.indexOf(start);
if (startpos<0)
return null;
startpos += start.length();
int bkt_pos = search.indexOf('>',startpos);
if (bkt_pos<0)
return null;
int end_pos = search.indexOf(end,++bkt_pos);
if (end_pos<0)
return data.substring(bkt_pos);
else
return data.substring(bkt_pos,end_pos);
} // end searchBetweenTags
private synchronized void process(RenderData rdat)
{
if (processed)
return; // check and set flag
// Map the content path to a real filename.
String real_path = rdat.mapToPath(rdat.getStaticIncludePath(name));
if (real_path==null)
{ // not found!
title = name;
content = "File not mappable: " + name;
return;
} // end if
// Read in the whole thing.
StringBuffer raw_file;
try
{ // read in from the file
raw_file = IOUtil.loadText(new File(real_path));
} // end try
catch (IOException ioe)
{ // I/O exception - just discard
title = name;
content = "I/O error reading " + name + ": " + ioe.getMessage();
return;
} // end catch
// make the upper-case search page and use that to locate the page title and body
String search_page = raw_file.toString().toUpperCase();
title = searchBetweenTags(raw_file,search_page,"TITLE");
content = searchBetweenTags(raw_file,search_page,"BODY");
if (content==null)
{ // no content?
content = "No content seen on " + name;
processed = false;
} // end if
processed = true; // set the flag to indicate we've got everything
} // end process
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
process(rdat);
if (title==null)
return name;
else
return title;
} // end getPageTitle
public String getPageQID()
{
return "static/" + name;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface ContentRender
*--------------------------------------------------------------------------------
*/
public void renderHere(Writer out, RenderData rdat) throws IOException
{
process(rdat);
if (content!=null)
out.write(content);
} // end renderHere
/*--------------------------------------------------------------------------------
* External static operations
*--------------------------------------------------------------------------------
*/
public static StaticRender getStaticRender(String name)
{
StaticRender rc = (StaticRender)(cache.get(name));
if (rc==null)
{ // create a new object and cache it
rc = new StaticRender(name);
cache.put(name,rc);
} // end if
return rc;
} // end getStaticRender
} // end class StaticRender

View File

@@ -1,178 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.htmlcheck.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class TextMessageDialog implements ContentRender, ColorSelectors
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Dialog types
public static final int TYPE_ACCEPT_DECLINE = 0;
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private int type;
private String title;
private String subtitle;
private String text;
private String[] choices;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public TextMessageDialog(int type, String title, String text, String[] choices)
{
this.type = type;
this.title = title;
this.subtitle = null;
this.text = text;
this.choices = choices;
int nbutton = getNumButtons(type);
if (choices.length<nbutton)
throw new InternalStateError("insufficient elements in choices array");
} // end constructor
public TextMessageDialog(int type, String title, String subtitle, String text, String[] choices)
{
this.type = type;
this.title = title;
this.subtitle = subtitle;
this.text = text;
this.choices = choices;
int nbutton = getNumButtons(type);
if (choices.length<nbutton)
throw new InternalStateError("insufficient elements in choices array");
} // end constructor
/*--------------------------------------------------------------------------------
* Internal overrideable operations
*--------------------------------------------------------------------------------
*/
protected int getNumButtons(int xtype)
{
if (xtype==TYPE_ACCEPT_DECLINE)
return 2;
throw new InternalStateError("invalid TextMessageDialog type :" + type);
} // end getNumButtons
protected String getImageNameForButton(int xtype, int ndx)
{
if (xtype==TYPE_ACCEPT_DECLINE)
{ // accept or decline
if (ndx==0)
return "bn_i_accept.gif";
else if (ndx==1)
return "bn_i_decline.gif";
throw new InternalStateError("invalid button index: " + ndx);
} // end if
throw new InternalStateError("invalid TextMessageDialog type :" + type);
} // end getImageNameForButton
protected String getAltTextForButton(int xtype, int ndx)
{
if (xtype==TYPE_ACCEPT_DECLINE)
{ // accept or decline
if (ndx==0)
return "I Accept";
else if (ndx==1)
return "I Decline";
throw new InternalStateError("invalid button index: " + ndx);
} // end if
throw new InternalStateError("invalid TextMessageDialog type :" + type);
} // end getImageNameForButton
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return title;
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface ContentRender
*--------------------------------------------------------------------------------
*/
public void renderHere(Writer out, RenderData rdat) throws IOException
{
rdat.writeContentHeader(out,title,subtitle);
out.write(rdat.getStdFontTag(CONTENT_FOREGROUND,2));
out.write("\n");
out.write(text);
out.write("</FONT><P>\n<DIV ALIGN=\"center\">\n");
int nbutton = getNumButtons(type);
for (int i=0; i<nbutton; i++)
{ // write out the individual buttons
if (i>0)
out.write("&nbsp;\n");
out.write("<A HREF=\"");
out.write(rdat.getEncodedServletPath(choices[i]));
out.write("\"><IMG SRC=\"");
out.write(rdat.getFullImagePath(getImageNameForButton(type,i)));
out.write("\" ALT=\"");
out.write(getAltTextForButton(type,i));
out.write("\" WIDTH=80 HEIGHT=24 BORDER=0></A>\n");
} // end for
out.write("</DIV>\n");
} // end renderHere
} // end class TextMessageDialog

View File

@@ -1,283 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.Writer;
import java.io.IOException;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class TopDisplay implements ContentRender, ColorSelectors
{
/*--------------------------------------------------------------------------------
* Static data values
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(TopDisplay.class);
private static final String ATTR_NAME = "com.silverwrist.venice.TopDisplay";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private ServletContext ctxt;
private VeniceEngine engine;
private UserContext uc;
private List top_posts;
private List descrs;
private VeniceContent[] sideboxes;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public TopDisplay(ServletContext ctxt, VeniceEngine engine, UserContext uc)
throws ServletException, DataException, AccessError
{
// Stash some basic information.
this.ctxt = ctxt;
this.engine = engine;
this.uc = uc;
this.top_posts = engine.getPublishedMessages(false);
this.descrs = uc.getSideBoxList();
// Create the sideboxes.
sideboxes = new VeniceContent[descrs.size()];
RenderConfig rconf = RenderConfig.getRenderConfig(ctxt);
for (int i=0; i<descrs.size(); i++)
{ // create each sidebox in turn...
SideBoxDescriptor d = (SideBoxDescriptor)(descrs.get(i));
sideboxes[i] = rconf.createSideBox(d.getID(),engine,uc);
} // end for
} // end constructor
/*--------------------------------------------------------------------------------
* External static operations
*--------------------------------------------------------------------------------
*/
public static TopDisplay retrieve(ServletRequest request)
{
return (TopDisplay)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "My Front Page";
} // end getPageTitle
public String getPageQID()
{
return "top";
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface ContentRender
*--------------------------------------------------------------------------------
*/
public void renderHere(Writer out, RenderData rdat) throws IOException
{
// Write out the start of the content structure.
out.write("<TABLE BORDER=0 ALIGN=CENTER WIDTH=\"100%\" CELLPADDING=4 CELLSPACING=0><TR VALIGN=TOP>\n");
out.write("<TD ALIGN=LEFT>\n");
// The top content is a JSP page, so include it here.
rdat.setRequestAttribute(ATTR_NAME,this);
RequestDispatcher dispatcher = ctxt.getRequestDispatcher(rdat.getFormatJSPPath("top_content.jsp"));
out.flush();
rdat.flushOutput(); // make sure the stuff to be output first is output
try
{ // include me!
rdat.includeDispatch(dispatcher);
} // end try
catch (ServletException se)
{ // since we can't throw ServletException, we throw IOException
logger.error("top_content.jsp failure",se);
throw new IOException("Failure including top_content.jsp");
} // end catch
rdat.flushOutput(); // now make sure the included page is properly flushed
out.write("</TD>\n<TD ALIGN=CENTER WIDTH=210>\n"); // break to the sidebox column
for (int i=0; i<sideboxes.length; i++)
{ // draw in the outer framework of the sidebox
out.write("<TABLE ALIGN=CENTER WIDTH=200 BORDER=0 CELLPADDING=2 CELLSPACING=0>"
+ "<TR VALIGN=MIDDLE BGCOLOR=\"" + rdat.getStdColor(SIDEBOX_TITLE_BACKGROUND)
+ "\"><TD ALIGN=LEFT CLASS=\"sideboxtop\">\n"
+ rdat.getStdFontTag(SIDEBOX_TITLE_FOREGROUND,3) + "<B>" + sideboxes[i].getPageTitle(rdat)
+ "</B></FONT>\n</TD></TR><TR VALIGN=TOP BGCOLOR=\""
+ rdat.getStdColor(SIDEBOX_CONTENT_BACKGROUND) + "\"><TD ALIGN=LEFT CLASS=\"sidebox\">\n");
// Fill in the sidebox by calling down to the base.
if (sideboxes[i] instanceof ContentRender)
{ // we have a direct-rendering component here - do it
ContentRender cr = (ContentRender)(sideboxes[i]);
cr.renderHere(out,rdat);
} // end if
else if (sideboxes[i] instanceof JSPRender)
{ // we have a JSP rendering component here - bounce to the appropriate JSP file
JSPRender jr = (JSPRender)(sideboxes[i]);
rdat.storeJSPRender(jr);
dispatcher = ctxt.getRequestDispatcher(rdat.getFormatJSPPath(jr.getTargetJSPName()));
out.flush();
rdat.flushOutput(); // make sure the stuff to be output first is output
try
{ // include me!
rdat.includeDispatch(dispatcher);
} // end try
catch (ServletException se)
{ // since we can't throw ServletException, we write an error message
logger.error("sidebox #" + i + " failure",se);
out.write(rdat.getStdFontTag(SIDEBOX_CONTENT_FOREGROUND,2) + "<EM>failure rendering class "
+ sideboxes[i].getClass().getName() + ": " + StringUtil.encodeHTML(se.getMessage())
+ "</EM></FONT>\n");
out.flush();
} // end catch
rdat.flushOutput(); // now make sure the included page is properly flushed
} // end else if
else
{ // this is bogus - just display a little error here
logger.error("sidebox #" + i + " class " + sideboxes[i].getClass().getName() + " cannot be rendered");
out.write(rdat.getStdFontTag(SIDEBOX_CONTENT_FOREGROUND,2) + "<EM>cannot display sidebox of class: "
+ sideboxes[i].getClass().getName() + "</EM></FONT>\n");
} // end else
// close up the framework of this sidebox
out.write("</TD></TR></TABLE><P>\n");
} // end for
if (uc.isLoggedIn())
{ // write the Configure button below the sideboxes
out.write("<A HREF=\"" + rdat.getEncodedServletPath("settings?cmd=B") + "\"><IMG SRC=\""
+ rdat.getFullImagePath("bn_configure.gif")
+ "\" ALT=\"Configure\" WIDTH=80 HEIGHT=24 BORDER=0></A>\n");
} // end if
// Finish up.
out.write("</TD>\n</TR></TABLE>");
} // end renderHere
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public static String getPosterName(TopicMessageContext msg)
{
try
{ // have to guard agains a DataException here
return msg.getCreatorName();
} // end try
catch (DataException de)
{ // just return "unknown" on failure
return "(unknown)";
} // end catch
} // end getPosterName
public static String getTopicPostLink(RenderData rdat, TopicMessageContext msg)
{
try
{ // retrieve the topic post link and name, and combine them
TopicContext topic = msg.getEnclosingTopic();
String plink = topic.getPostLink();
return "<A HREF=\"" + rdat.getEncodedServletPath("go/" + plink) + "\">" + topic.getName() + "</A>";
} // end try
catch (DataException de)
{ // just return null on failure
return null;
} // end catch
catch (Exception e)
{ // temporary guard point here
logger.error("Caught in getTopicPostLink:",e);
return null;
} // end catch
} // end getTopicPostLink
public static String getMessageBodyText(TopicMessageContext msg)
{
try
{ // have to guard against a DataException here
return msg.getBodyText();
} // end try
catch (DataException de)
{ // just return an error message
return "<EM>(Unable to retrieve message data: " + StringUtil.encodeHTML(de.getMessage()) + ")</EM>";
} // end catch
} // end getMessageBodyText
public int getNumTopPosts()
{
return top_posts.size();
} // end getNumTopPosts
public TopicMessageContext getTopPost(int index)
{
return (TopicMessageContext)(top_posts.get(index));
} // end getTopPost
public boolean displayWelcome()
{
return !(uc.isLoggedIn());
} // end displayWelcome
} // end class TopDisplay

View File

@@ -1,221 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.IOException;
import java.io.Writer;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class TopicListing implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.TopicListing";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm; // the community we're in
private ConferenceContext conf; // the conference being listed
private int view_opt; // the view option used
private int sort_opt; // the sort option used
private List topic_list; // the topic list
private TopicVisitOrder visit_order; // indicates order in which topics are visited
private String qid; // "quick ID" for this page
private String top_custom; // top custom HTML block
private String bottom_custom; // bottom custom HTML block
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public TopicListing(HttpServletRequest request, CommunityContext comm, ConferenceContext conf, int view_opt,
int sort_opt) throws DataException, AccessError
{
this.comm = comm;
this.conf = conf;
this.view_opt = view_opt;
this.sort_opt = sort_opt;
this.topic_list = conf.getTopicList(view_opt,sort_opt);
this.visit_order = TopicVisitOrder.initialize(request.getSession(true),conf.getConfID(),this.topic_list);
List aliases = conf.getAliases();
this.qid = "go/" + comm.getAlias() + "!" + (String)(aliases.get(0));
this.top_custom = conf.getCustomBlock(ConferenceContext.CUST_BLOCK_TOP);
this.bottom_custom = conf.getCustomBlock(ConferenceContext.CUST_BLOCK_BOTTOM);
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static TopicListing retrieve(ServletRequest request)
{
return (TopicListing)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Topics in " + conf.getName();
} // end getPageTitle
public String getPageQID()
{
return qid;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "topics.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public final int getConfID()
{
return conf.getConfID();
} // end getConfID
public final String getLocator()
{
StringBuffer buf = new StringBuffer("sig=");
buf.append(comm.getCommunityID()).append("&conf=").append(conf.getConfID());
return buf.toString();
} // end getLocator
public final String getConfName()
{
return conf.getName();
} // end getConfName
public final boolean canDoReadNew()
{
return visit_order.isNext();
} // end canDoReadNew
public final String getNextLocator()
{
StringBuffer buf = new StringBuffer("sig=");
buf.append(comm.getCommunityID()).append("&conf=").append(conf.getConfID()).append("&top=");
buf.append(visit_order.getNext());
return buf.toString();
} // end getNextLocator
public final boolean canCreateTopic()
{
return conf.canCreateTopic();
} // end canCreateTopic
public final boolean canAddToHotlist()
{
return conf.canAddToHotlist();
} // end canAddToHotlist
public final boolean anyTopics()
{
return (topic_list.size()>0);
} // end anyTopics
public final int getViewOption()
{
return view_opt;
} // end getViewOption
public final boolean isView(int value)
{
return (view_opt==value);
} // end isSort
public final boolean isSort(int value)
{
return (sort_opt==value);
} // end isSort
public final Iterator getTopicIterator()
{
return topic_list.iterator();
} // end getTopicIterator
public final void writeTopCustom(Writer out) throws IOException
{
if (top_custom!=null)
out.write(top_custom);
} // end writeTopCustom
public final void writeBottomCustom(Writer out) throws IOException
{
if (bottom_custom!=null)
out.write(bottom_custom);
} // end writeBottomCustom
} // end class TopicListing

View File

@@ -1,544 +0,0 @@
/*
* 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.awt.Dimension;
import java.io.Writer;
import java.io.IOException;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class TopicPosts implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(TopicPosts.class);
private static int SCALING_NUM = 1;
private static int SCALING_DENOM = 2;
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.TopicPosts";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private VeniceEngine engine;
private CommunityContext comm;
private ConferenceContext conf;
private TopicContext topic;
private int first;
private int last;
private boolean show_advanced;
private boolean no_bozos;
private int unread;
private List messages;
private TopicVisitOrder visit_order;
private String topic_stem;
private String topic_qid;
private String top_custom;
private String bottom_custom;
private String cache_locator = null;
private HashSet bozo_uids = new HashSet();
private Dimension photo_size = null;
private HashMap uid_photos = null;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public TopicPosts(HttpServletRequest request, VeniceEngine engine, UserContext user, CommunityContext comm,
ConferenceContext conf, TopicContext topic, int first, int last, boolean read_new,
boolean show_advanced, boolean no_bozos) throws DataException, AccessError
{
if (logger.isDebugEnabled())
logger.debug("TopicPosts: comm=" + comm.getCommunityID() + ", conf=" + conf.getConfID() + ", topic="
+ topic.getTopicNumber() + ", range=[" + first + ", " + last + "], rnm=" + read_new
+ ", shac=" + show_advanced + ", nbz=" + no_bozos);
this.engine = engine;
this.comm = comm;
this.conf = conf;
this.topic = topic;
this.first = first;
this.last = last;
this.show_advanced = show_advanced;
this.no_bozos = no_bozos;
this.unread = topic.getUnreadMessages();
if (read_new)
topic.setUnreadMessages(0);
if (logger.isDebugEnabled())
logger.debug(this.unread + " unread messages");
this.messages = topic.getMessages(first,last);
this.visit_order = TopicVisitOrder.retrieve(request.getSession(true),conf.getConfID());
if (visit_order!=null)
visit_order.visit(topic.getTopicNumber());
List aliases = conf.getAliases();
topic_stem = (String)(aliases.get(0)) + "." + topic.getTopicNumber() + ".";
topic_qid = "go/" + comm.getAlias() + "!" + (String)(aliases.get(0)) + "." + topic.getTopicNumber();
top_custom = conf.getCustomBlock(ConferenceContext.CUST_BLOCK_TOP);
bottom_custom = conf.getCustomBlock(ConferenceContext.CUST_BLOCK_BOTTOM);
// build up the list of users IN THIS VIEW that are bozo-filtered
HashSet saw_users = new HashSet();
if (conf.displayPostPictures() && user.displayPostPictures())
{ // build up the mapping of UIDs to photo URLs
Dimension psz = engine.getUserPhotoSize();
photo_size = new Dimension((psz.width * SCALING_NUM) / SCALING_DENOM,
(psz.height * SCALING_NUM) / SCALING_DENOM);
uid_photos = new HashMap();
} // end if
Iterator it = messages.iterator();
while (it.hasNext())
{ // get the user IDs of all messages on this page
TopicMessageContext msg = (TopicMessageContext)(it.next());
Integer the_uid = new Integer(msg.getCreatorUID());
boolean get_photo;
if (!(saw_users.contains(the_uid)))
{ // only check user IDs once per display operation
saw_users.add(the_uid);
get_photo = true;
if (topic.isBozo(the_uid.intValue()))
{ // shall we get the user photo?
bozo_uids.add(the_uid);
get_photo = no_bozos;
} // end if
if (conf.displayPostPictures() && user.displayPostPictures() && get_photo)
{ // look up the user photo URL
UserProfile prof = user.getProfile(the_uid.intValue());
String url = prof.getPhotoURL();
if (url!=null)
uid_photos.put(the_uid,url);
} // end else if
} // end if
} // end while
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static TopicPosts retrieve(ServletRequest request)
{
return (TopicPosts)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return topic.getName() + ": " + topic.getTotalMessages() + " Total; " + unread + " New; Last: "
+ rdat.formatDateForDisplay(topic.getLastUpdateDate());
} // end getPageTitle
public String getPageQID()
{
return topic_qid;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "posts.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public static final String getPosterName(TopicMessageContext msg)
{
try
{ // have to guard agains a DataException here
return msg.getCreatorName();
} // end try
catch (DataException de)
{ // just return "unknown" on failure
return "(unknown)";
} // end catch
} // end getPosterName
public static final String getMessageBodyText(TopicMessageContext msg)
{
try
{ // have to guard against a DataException here
return msg.getBodyText();
} // end try
catch (DataException de)
{ // just return an error message
return "<EM>(Unable to retrieve message data: " + StringUtil.encodeHTML(de.getMessage()) + ")</EM>";
} // end catch
} // end getMessageBodyText
public final int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public final int getConfID()
{
return conf.getConfID();
} // end getConfID
public final int getTopicNumber()
{
return topic.getTopicNumber();
} // end getTopicNumber
public final int getNextTopicNumber()
{
if (visit_order!=null)
return visit_order.getNext();
else
return -1;
} // end getNextTopicNumber
public final String getConfLocator()
{
StringBuffer buf = new StringBuffer("sig=");
buf.append(comm.getCommunityID()).append("&conf=").append(conf.getConfID());
return buf.toString();
} // end getConfLocator
public final String getLocator()
{
if (cache_locator==null)
{ // build up the standard locator
StringBuffer buf = new StringBuffer("sig=");
buf.append(comm.getCommunityID()).append("&conf=").append(conf.getConfID()).append("&top=");
buf.append(topic.getTopicNumber());
cache_locator = buf.toString();
} // end if
return cache_locator;
} // end getLocator
public final String getNextLocator()
{
StringBuffer buf = new StringBuffer("sig=");
buf.append(comm.getCommunityID()).append("&conf=").append(conf.getConfID());
if (visit_order!=null)
buf.append("&top=").append(visit_order.getNext());
return buf.toString();
} // end getNextLocator
public final String getRestoreLocator()
{
StringBuffer buf = new StringBuffer("rtop=");
buf.append(topic.getTopicNumber()).append("&rct=").append(unread);
return buf.toString();
} // end getRestoreLocator
public final String getIdentifyingData()
{
StringBuffer buf = new StringBuffer("Posts ");
buf.append(first).append(" through ").append(last).append(" in topic #").append(topic.getTopicID());
return buf.toString();
} // end getIdentifyingData
public final String getTopicName()
{
return topic.getName();
} // end getTopicName
public final int getTotalMessages()
{
return topic.getTotalMessages();
} // end getTotalMessages
public final int getNewMessages()
{
return unread;
} // end getNewMessages
public final Date getLastUpdate()
{
return topic.getLastUpdateDate();
} // end getLastUpdate
public final boolean isTopicHidden()
{
return topic.isHidden();
} // end isTopicHidden
public final boolean canDoNextTopic()
{
if (visit_order!=null)
return visit_order.isNext();
else
return false;
} // end canDoNextTopic
public final boolean canFreezeTopic()
{
return topic.canFreeze();
} // end canFreezeTopic
public final boolean isTopicFrozen()
{
return topic.isFrozen();
} // end isTopicFrozen
public final boolean canArchiveTopic()
{
return topic.canArchive();
} // end canArchiveTopic
public final boolean isTopicArchived()
{
return topic.isArchived();
} // end isTopicArchived
public final boolean canDeleteTopic()
{
return topic.canDelete();
} // end canDeleteTopic
public final boolean canScrollUp()
{
return (first>0);
} // end canScrollUp
public final String getScrollUpLocator()
{
int new_first = first - engine.getNumPostsPerPage();
int new_last = first - 1;
if (new_first<0)
{ // normalize so we start at 0
new_last += (-new_first);
new_first = 0;
} // end if
StringBuffer buf = new StringBuffer("p1=");
buf.append(new_first).append("&p2=").append(new_last);
return buf.toString();
} // end getScrollUpLocator
public final boolean canScrollDown()
{
return ((topic.getTotalMessages() - (1 + last))>0);
} // end canScrollDown
public final String getScrollDownLocator()
{
int new_last = last + engine.getNumPostsPerPage();
int my_last = topic.getTotalMessages() - 1;
if (new_last>my_last)
new_last = my_last; // normalize so we end at the last post
StringBuffer buf = new StringBuffer("p1=");
buf.append(last+1).append("&p2=").append(new_last);
return buf.toString();
} // end getScrollDownLocator
public final boolean canScrollToEnd()
{
return ((topic.getTotalMessages() - (1 + last))>0);
} // end canScrollToEnd
public final String getScrollToEndLocator()
{
int my_last = topic.getTotalMessages();
StringBuffer buf = new StringBuffer("p1=");
buf.append(my_last-engine.getNumPostsPerPage()).append("&p2=").append(my_last-1);
return buf.toString();
} // end getScrollToEndLocator
public final Iterator getMessageIterator()
{
return messages.iterator();
} // end getMessageIterator()
public final boolean emitBreakLinePoint(int msg)
{
return (msg==(topic.getTotalMessages()-unread));
} // end emitBreakLinePoint
public final boolean showAdvanced()
{
return show_advanced && (last==first);
} // end showAdvanced
public final boolean displayPostBox()
{
boolean flag1 = conf.canPostToConference();
boolean flag2 = (topic.isFrozen() ? topic.canFreeze() : true);
boolean flag3 = (topic.isArchived() ? topic.canArchive() : true);
return flag1 && flag2 && flag3;
} // end displayPostBox
public final String getDefaultPseud()
{
return conf.getDefaultPseud();
} // end getDefaultPseud
public final String getMessageReference(TopicMessageContext msg)
{
return topic_stem + msg.getPostNumber();
} // end getMessageReference
public final int getNumPostsPerPage()
{
return engine.getNumPostsPerPage();
} // end getNumPostsPerPage
public final boolean displayAttachmentInNewWindow(TopicMessageContext msg)
{
if (!(msg.hasAttachment()))
return false;
String type = msg.getAttachmentType();
return (type.startsWith("text/") || type.startsWith("image/"));
} // end displayAttachmentInNewWindow
public final boolean bozoFilterUser(int uid)
{
if (no_bozos)
return false;
else
return bozo_uids.contains(new Integer(uid));
} // end bozoFilterUser
public final boolean showBozoFilteredIndicator(int uid)
{
if (no_bozos)
return bozo_uids.contains(new Integer(uid));
else
return false;
} // end showBozoFilteredIndicator
public final boolean showFilterButton(int uid)
{
return !(bozo_uids.contains(new Integer(uid))) && topic.canSetBozo(uid);
} // end showFilterButton
public final String getUserPhotoTag(int uid, RenderData rdat)
{
if (photo_size==null)
return ""; // user photos not enabled
StringBuffer buf = new StringBuffer("<IMG SRC=\"");
String url = (String)(uid_photos.get(new Integer(uid)));
if (url==null)
url = rdat.getPhotoNotAvailURL();
buf.append(url).append("\" ALT=\"\" WIDTH=").append(photo_size.width).append(" HEIGHT=");
buf.append(photo_size.height).append(" ALIGN=LEFT BORDER=0 HSPACE=2 VSPACE=2>");
return buf.toString();
} // end getUserPhotoTag
public final boolean displayPostPictures()
{
return (photo_size!=null);
} // end displayPostPictures
public final void writeTopCustom(Writer out) throws IOException
{
if (top_custom!=null)
out.write(top_custom);
} // end writeTopCustom
public final void writeBottomCustom(Writer out) throws IOException
{
if (bottom_custom!=null)
out.write(bottom_custom);
} // end writeBottomCustom
} // end class TopicPosts

View File

@@ -1,118 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class UserCommunityList implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.UserCommunityList";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private UserContext uc;
private List comm_list;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public UserCommunityList(UserContext uc) throws DataException
{
this.uc = uc;
this.comm_list = uc.getMemberCommunities();
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static UserCommunityList retrieve(ServletRequest request)
{
return (UserCommunityList)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Your Communities";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "communitylist.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getNumCommunities()
{
return comm_list.size();
} // end getNumCommunities
public CommunityContext getCommunity(int ndx)
{
return (CommunityContext)(comm_list.get(ndx));
} // end getCommunity
} // end class UserCommunityList

View File

@@ -1,127 +0,0 @@
/*
* 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.awt.Dimension;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class UserPhotoData implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.UserPhotoData";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private Dimension photo_dims;
private String photo_url;
private String target;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public UserPhotoData(VeniceEngine engine, UserContext user, RenderData rdat, String target)
throws DataException
{
photo_dims = engine.getUserPhotoSize();
photo_url = user.getContactInfo().getPhotoURL();
if (StringUtil.isStringEmpty(photo_url))
photo_url = rdat.getPhotoNotAvailURL();
this.target = target;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static UserPhotoData retrieve(ServletRequest request)
{
return (UserPhotoData)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Set User Photo";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "user_photo.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public String getTarget()
{
return target;
} // end getTarget
public String getPhotoTag(RenderData rdat)
{
StringBuffer buf = new StringBuffer("<IMG SRC=\"");
buf.append(photo_url).append("\" ALT=\"\" ALIGN=LEFT WIDTH=").append(photo_dims.width).append(" HEIGHT=");
buf.append(photo_dims.height).append(" HSPACE=6 VSPACE=0 BORDER=0>");
return buf.toString();
} // end getPhotoTag
} // end class UserPhotoData

View File

@@ -1,163 +0,0 @@
/*
* 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.awt.Dimension;
import javax.servlet.ServletRequest;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.VeniceEngine;
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 VeniceEngine engine;
private UserProfile prof;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public UserProfileData(VeniceEngine engine, UserProfile prof)
{
this.engine = engine;
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 VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "User Profile - " + prof.getUserName();
} // end getPageTitle
public String getPageQID()
{
return "user/" + prof.getUserName();
} // end getPageQID
/*--------------------------------------------------------------------------------
* 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 getPhotoTag(RenderData rdat)
{
Dimension dim = engine.getUserPhotoSize();
StringBuffer buf = new StringBuffer("<IMG SRC=\"");
String tmp = prof.getPhotoURL();
if (StringUtil.isStringEmpty(tmp))
tmp = rdat.getPhotoNotAvailURL();
buf.append(tmp).append("\" ALT=\"\" ALIGN=LEFT WIDTH=").append(dim.width).append(" HEIGHT=");
buf.append(dim.height).append(" BORDER=0>");
return buf.toString();
} // end getPhotoTag
} // end class UserProfileData

View File

@@ -1,118 +0,0 @@
/*
* 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 com.silverwrist.venice.except.*;
import com.silverwrist.venice.util.IDUtils;
public class VerifyEmailDialog extends ContentDialog
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
int confirm_num = 0;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
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
/*--------------------------------------------------------------------------------
* Overrides from class ContentDialog
*--------------------------------------------------------------------------------
*/
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
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
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

View File

@@ -1,341 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.security.Role;
public class ViewCommunityMembers implements JSPRender, SearchMode
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ViewCommunityMembers";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private VeniceEngine engine; // engine context
private CommunityContext comm; // community context
private List display_list = null; // list of members to display
private boolean simple_list = false; // simple list?
private int field = -1; // search field
private int mode = -1; // search mode
private String term = null; // search term
private int offset = 0; // search result offset
private int find_count = -1; // search results count
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ViewCommunityMembers(VeniceEngine engine, CommunityContext comm)
{
this.engine = engine;
this.comm = comm;
} // 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 ViewCommunityMembers retrieve(ServletRequest request)
{
return (ViewCommunityMembers)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Members of Community " + comm.getName();
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "view_member.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void doInitialList() throws DataException
{
display_list = comm.getMemberList();
simple_list = true;
term = "";
offset = 0;
find_count = display_list.size();
} // end doInitialList
public void doSearch(ServletRequest request) throws ValidationException, DataException
{
// Get the "simple list" parameter.
int slp = getParamInt(request,"sl",1);
simple_list = (slp==1);
if (simple_list)
{ // 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"))
throw new ValidationException("Invalid button click."); // this can't happen
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.");
// Get the member list and offset it if necessary.
List tmp = comm.getMemberList();
if (find_count<0)
find_count = tmp.size();
if (offset>0)
display_list = tmp.subList(offset,tmp.size());
else
display_list = tmp;
term = ""; // null out the search term
} // end if
else
{ // Validate the search field parameter.
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.");
// 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.");
// Perform the search!
display_list = comm.searchForMembers(field,mode,term,offset,count);
if (find_count<0)
find_count = comm.getSearchMemberCount(field,mode,term);
} // end else
} // end doSearch
public int getNumResultsDisplayed()
{
return engine.getStdNumSearchResults();
} // end getNumResultsDisplayed
public String getCommunityName()
{
return comm.getName();
} // end getCommunityName
public int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public boolean getSimpleList()
{
return simple_list;
} // end getSimpleList
public int getSimpleListParam()
{
return (simple_list ? 1 : 0);
} // end getSimpleListParam
public int getSearchField()
{
return field;
} // end getSearchField
public int getSearchMode()
{
return mode;
} // end getSearchMode
public boolean searchFieldIs(int value)
{
return (field==value);
} // end searchFieldIs
public boolean searchModeIs(int value)
{
return (mode==value);
} // end searchModeIs
public String getSearchTerm()
{
return term;
} // end getSearchTerm
public int getFindCount()
{
return find_count;
} // end getFindCount
public int getOffset()
{
return offset;
} // end getOffset
public int getSize()
{
return display_list.size();
} // end getSize
public boolean displayList()
{
if ((display_list==null) || (display_list.size()==0))
return false;
return true;
} // end displayList
public UserFound getItem(int ndx)
{
return (UserFound)(display_list.get(ndx));
} // end getItem
public boolean isCommunityAdmin(UserFound uf)
{
SecurityInfo sinf = comm.getSecurityInfo();
Role r = sinf.getRole("Community.Host");
return r.isSatisfiedBy(uf.getLevel());
} // end isCommunityAdmin
} // end class ViewCommunityMembers

View File

@@ -1,183 +0,0 @@
/*
* 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.menus;
import java.io.Writer;
import java.io.IOException;
import java.util.*;
import org.apache.log4j.*;
import org.w3c.dom.*;
import com.silverwrist.util.*;
import com.silverwrist.venice.except.ConfigException;
import com.silverwrist.venice.servlets.format.ComponentRender;
import com.silverwrist.venice.servlets.format.RenderData;
public class LeftMenu implements ComponentRender
{
/*--------------------------------------------------------------------------------
* Internal class representing a header component
*--------------------------------------------------------------------------------
*/
static class Header implements ComponentRender
{
private TextItem item;
Header(Element elt)
{
DOMElementHelper h = new DOMElementHelper(elt);
item = new TextItem(h.getElementText());
} // end constructor
public void renderHere(Writer out, RenderData rdat) throws IOException
{
out.write("<B>");
item.renderHere(out,rdat);
out.write("</B><BR>\n");
} // end renderHere
} // end class Header
/*--------------------------------------------------------------------------------
* Internal class representing a separator component
*--------------------------------------------------------------------------------
*/
static class Separator implements ComponentRender
{
private ComponentRender cr;
Separator()
{
this.cr = null;
} // end constructor
Separator(ComponentRender cr)
{
this.cr = cr;
} // end constructor
public void renderHere(Writer out, RenderData rdat) throws IOException
{
if (cr!=null)
cr.renderHere(out,rdat);
out.write("<BR>\n");
} // end renderHere
} // end class Separator
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(LeftMenu.class);
private static final Separator separator_singleton = new Separator(null);
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String identifier;
private ArrayList menu_items = new ArrayList();
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public LeftMenu(Element elt, String identifier) throws ConfigException
{
if (!(elt.getNodeName().equals("menudef")))
{ // just some shorts-checking here to make sure the element is OK
logger.fatal("huh?!? this should have been a <menudef/> if it got here!");
throw new ConfigException("not a <menudef/> element");
} // end if
NodeList items = elt.getChildNodes();
for (int i=0; i<items.getLength(); i++)
{ // examine each of the child elements closely
Node n = items.item(i);
if (n.getNodeType()==Node.ELEMENT_NODE)
{ // we've found a child element - what type is it?
if (n.getNodeName().equals("header"))
menu_items.add(new Header((Element)n)); // add a new header
else if (n.getNodeName().equals("separator"))
menu_items.add(separator_singleton); // all separators are exactly the same
else if (n.getNodeName().equals("text"))
{ // add a text item
DOMElementHelper h = new DOMElementHelper((Element)n);
menu_items.add(new Separator(new TextItem(h.getElementText())));
} // end else if
else if (n.getNodeName().equals("link"))
menu_items.add(new LinkItem((Element)n));
else if (n.getNodeName().equals("image"))
menu_items.add(new Separator(new ImageItem((Element)n)));
else
{ // menu definition has an unknown item
logger.fatal("unknown element <" + n.getNodeName() + "/> inside <menudef/>");
throw new ConfigException("unknown element <" + n.getNodeName() + "/> inside <menudef/>",n);
} // end else
} // end if (an element node)
} // end for (each child node)
this.identifier = identifier;
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface ComponentRender
*--------------------------------------------------------------------------------
*/
public void renderHere(Writer out, RenderData rdat) throws IOException
{
Iterator it = menu_items.iterator();
while (it.hasNext())
{ // render each menu item in turn
ComponentRender cr = (ComponentRender)(it.next());
cr.renderHere(out,rdat);
} // end while
} // end renderHere
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public String getIdentifier()
{
return identifier;
} // end getIdentifier
} // end class LeftMenu

View File

@@ -0,0 +1,24 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.ui;
public interface AutoCleanup
{
public abstract void cleanup();
} // end interface AutoCleanup

View File

@@ -15,7 +15,7 @@
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
package com.silverwrist.venice.ui;
public interface ColorSelectors
{

View File

@@ -0,0 +1,34 @@
/*
* 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.ui;
public interface Content
{
public static final int MENU_SELECTOR_NOCHANGE = -1;
public static final int MENU_SELECTOR_TOP = 0;
public static final int MENU_SELECTOR_COMMUNITY = 1;
public abstract boolean needFrame();
public abstract int getMenuSelector();
public abstract String getPageTitle(RequestOutput ro);
public abstract String getPageQID();
} // end interface Content

View File

@@ -15,13 +15,12 @@
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
package com.silverwrist.venice.ui;
import java.io.Writer;
import java.io.IOException;
public interface ComponentRender
public interface ContentDirect extends Content
{
public abstract void renderHere(Writer out, RenderData rdat) throws IOException;
public abstract void render(RequestOutput out) throws IOException;
} // end interface ComponentRender
} // end interface ContentDirect

View File

@@ -15,12 +15,12 @@
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
package com.silverwrist.venice.ui;
public interface VeniceContent
import java.io.IOException;
public interface ContentExecute
{
public abstract String getPageTitle(RenderData rdat);
public abstract void execute(RequestExec req) throws IOException;
public abstract String getPageQID();
} // end interface VeniceContent
} // end interface ContentExecute

View File

@@ -15,14 +15,14 @@
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
package com.silverwrist.venice.ui;
import javax.servlet.ServletRequest;
public interface JSPRender extends VeniceContent
public interface ContentJSP extends Content
{
public abstract void store(ServletRequest request);
public abstract String getJSPName();
public abstract String getTargetJSPName();
public abstract void initialize(RequestInput req);
} // end interface JSPRender
public abstract void terminate(RequestInput req);
} // end interface ContentJSP

View 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 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.ui;
public interface LinkTypes
{
public static final int ABSOLUTE = 0;
public static final int SERVLET = 1;
public static final int FRAME = 2;
} // end interface LinkTypes

View File

@@ -15,13 +15,12 @@
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
package com.silverwrist.venice.ui;
import java.io.Writer;
import java.io.IOException;
public interface ContentRender extends VeniceContent
public interface RenderDirect
{
public abstract void renderHere(Writer out, RenderData rdat) throws IOException;
public abstract void render(RequestOutput out) throws IOException;
} // end interface ContentRender
} // end interface RenderDirect

View File

@@ -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 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.ui;
import java.io.InputStream;
import java.io.IOException;
import java.sql.Blob;
import java.sql.SQLException;
public interface RequestExec extends LinkTypes
{
public abstract void error(int code) throws IOException;
public abstract void error(int code, String message) throws IOException;
public abstract void redirect(String where, int type) throws IOException;
public abstract void noContent();
public abstract void sendBinary(String type, String filename, int length, InputStream data)
throws IOException;
public abstract void sendBinary(String type, int length, InputStream data) throws IOException;
public abstract void sendBinary(String type, String filename, Blob data) throws IOException, SQLException;
public abstract void sendBinary(String type, Blob data) throws IOException, SQLException;
public abstract void sendBinary(String type, String filename, byte[] data) throws IOException;
public abstract void sendBinary(String type, byte[] data) throws IOException;
public abstract void sendText(String type, String data) throws IOException;
public abstract void sendText(String type, char[] data) throws IOException;
} // end interface RequestExec

View File

@@ -0,0 +1,180 @@
/*
* 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.ui;
import java.awt.Dimension;
import java.io.InputStream;
import java.io.IOException;
import java.util.Date;
import java.util.Enumeration;
import java.util.Map;
import com.silverwrist.util.ServletMultipartException;
import com.silverwrist.venice.core.CommunityContext;
import com.silverwrist.venice.core.UserContext;
import com.silverwrist.venice.core.VeniceEngine;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.ui.dlg.Dialog;
import com.silverwrist.venice.ui.helpers.ErrorBox;
import com.silverwrist.venice.ui.menus.MenuComponent;
import com.silverwrist.venice.ui.script.ScriptManager;
public interface RequestInput extends LinkTypes
{
public static final String LOGIN_COOKIE = "VeniceAuth";
public static final int LOGIN_COOKIE_AGE = 60*60*24*365; // one year
public static final String LEFT_MENU_SESSION_ATTR = "LeftMenu";
public abstract String mapPath(String s);
public abstract String getContextPath();
public abstract String getServletPath();
public abstract String getPathInfo();
public abstract String getQueryString();
public abstract String getVerb();
public abstract String getSourceAddress();
public abstract boolean hasParameter(String name);
public abstract String getParameter(String name);
public abstract int getParameterInt(String name, int default_value);
public abstract short getParameterShort(String name, short default_value);
public abstract long getParameterLong(String name, long default_value);
public abstract Enumeration getParameterNames();
public abstract String[] getParameterValues(String name);
public abstract boolean isFileParam(String name);
public abstract String getParameterType(String name);
public abstract int getParameterSize(String name);
public abstract InputStream getParameterDataStream(String name) throws ServletMultipartException;
public abstract boolean isImageButtonClicked(String name);
public abstract Object getAppAttribute(String name);
public abstract void setAppAttribute(String name, Object o);
public abstract Object getSessionAttribute(String name);
public abstract void setSessionAttribute(String name, Object o);
public abstract Object getRequestAttribute(String name);
public abstract void setRequestAttribute(String name, Object o);
public abstract void savePersistentCookie(String name, String value, int max_age);
public abstract void saveTemporaryCookie(String name, String value);
public abstract void deleteCookie(String name);
public abstract VeniceEngine getEngine();
public abstract UserContext getUser();
public abstract void replaceUser(UserContext new_user);
public abstract ScriptManager getScriptManager();
public abstract String getStyleSheetData() throws IOException;
public abstract String getColor(int selector);
public abstract String getColor(String name);
public abstract boolean useHTMLComments();
public abstract String formatURL(String url, int type);
public abstract String formatDate(Date date);
public abstract String getFontTag(int colorsel, int size);
public abstract String getFontTag(String color, int size);
public abstract String getFontTag(int colorsel, String size);
public abstract String getFontTag(String color, String size);
public abstract int convertLinkType(String str);
public abstract String getLocation();
public abstract void setLocation(String str);
public abstract boolean getDisplayLogin();
public abstract void setDisplayLogin(boolean val);
public abstract String getStockMessage(String key);
public abstract String getStockMessage(String key, Map vars);
public abstract String getStaticPath(String s);
public abstract String getExternalStaticPath(String s);
public abstract String getImagePath(String s);
public abstract MenuComponent getMenu(String name);
public abstract MenuComponent getMenu(String name, Map vars);
public abstract String getScriptName(String raw_name);
public abstract String getScriptName(boolean strip_ext);
public abstract String getScriptLoggerName(String raw_name);
public abstract String getScriptLoggerName();
public abstract Dialog getDialog(String name);
public abstract Content[] getSideBoxes() throws AccessError, DataException;
public abstract String getUserPhotoTag(String url);
public abstract String getUserPhotoTag(String url, Dimension size);
public abstract CommunityContext getCommunity();
public abstract CommunityContext getCommunity(boolean required, String on_error) throws ErrorBox;
public abstract String getActivityString(Date date);
public abstract String getDefaultServletAddress(CommunityContext comm);
public abstract String getCommunityLogoTag(String url);
public abstract String expandServletPath(String spath);
public abstract void registerCleanup(AutoCleanup ac);
} // end interface RequestInput

View File

@@ -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 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.ui;
import java.awt.Dimension;
import java.io.IOException;
import java.io.Writer;
import java.util.Date;
import java.util.Map;
import javax.servlet.ServletException;
public interface RequestOutput extends LinkTypes
{
public abstract Writer getWriter() throws IOException;
public abstract void write(String s) throws IOException;
public abstract void writeStackTrace(Throwable t) throws IOException;
public abstract void flush() throws IOException;
public abstract void output(Content c) throws IOException, ServletException;
public abstract void output(Writer out, Content c) throws IOException, ServletException;
public abstract void writeFrameHead(Writer out, Content c) throws IOException;
public abstract void writeFrameHead(Content c) throws IOException;
public abstract void writeSiteImageTag(Writer out) throws IOException;
public abstract void writeSiteImageTag() throws IOException;
public abstract void writeVeniceLogo(Writer out) throws IOException;
public abstract void writeVeniceLogo() throws IOException;
public abstract void writeContentHeader(Writer out, String primary, String secondary) throws IOException;
public abstract void writeContentHeader(String primary, String secondary) throws IOException;
public abstract String formatURL(String url, int type);
public abstract String formatDate(Date date);
public abstract String getColor(int selector);
public abstract String getColor(String name);
public abstract String getFontTag(int colorsel, int size);
public abstract String getFontTag(String color, int size);
public abstract String getFontTag(int colorsel, String size);
public abstract String getFontTag(String color, String size);
public abstract String getStockMessage(String key);
public abstract String getStockMessage(String key, Map vars);
public abstract String getStaticPath(String s);
public abstract String getExternalStaticPath(String s);
public abstract String getImagePath(String s);
public abstract String getButtonVisual(String id);
public abstract String getButtonInput(String id);
public abstract String getUserPhotoTag(String url);
public abstract String getUserPhotoTag(String url, Dimension size);
public abstract String getActivityString(Date date);
public abstract String getCommunityLogoTag(String url);
} // end interface RequestOutput

View 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 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.ui.helpers;
import java.io.InputStream;
import java.io.IOException;
import com.silverwrist.venice.core.TopicMessageContext;
import com.silverwrist.venice.except.AccessError;
import com.silverwrist.venice.except.DataException;
import com.silverwrist.venice.ui.ContentExecute;
import com.silverwrist.venice.ui.LinkTypes;
import com.silverwrist.venice.ui.RequestExec;
import com.silverwrist.venice.ui.helpers.ThrowableContent;
public class AttachmentContent extends ThrowableContent implements ContentExecute
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String type;
private String filename;
private int length;
private InputStream stm;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public AttachmentContent(TopicMessageContext msg) throws AccessError, DataException
{
super();
this.type = msg.getAttachmentType();
this.filename = msg.getAttachmentFilename();
this.length = msg.getAttachmentLength();
this.stm = msg.getAttachmentData();
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface ContentExecute
*--------------------------------------------------------------------------------
*/
public void execute(RequestExec req) throws IOException
{
req.sendBinary(type,filename,length,stm);
} // end execute
} // end class BinaryDataContent

Some files were not shown because too many files have changed in this diff Show More