implemented quick E-mail and SIG invitation emails

This commit is contained in:
Eric J. Bowersox
2001-02-25 07:42:11 +00:00
parent 680b84b9d8
commit 129b69973b
18 changed files with 662 additions and 38 deletions

View File

@@ -198,6 +198,19 @@ public class SIGOperations extends VeniceServlet
} // end if ("C" command)
if (cmd.equals("I"))
{ // "I" - Send Invitation (requires SIG parameter)
SIGContext sig = getSIGParameter(request,user,true,"top");
if (!(sig.canSendInvitation()))
return new ErrorBox("SIG Error","You are not permitted to send an invitation.",
"sig/" + sig.getAlias());
// present the "Invitation" dialog
return new Invitation(sig);
} // end if ("I" command)
// this is an error!
logger.error("invalid command to SIGOperations.doGet: " + cmd);
return new ErrorBox("Internal Error","Invalid command to SIGOperations.doGet","top");
@@ -318,6 +331,48 @@ public class SIGOperations extends VeniceServlet
} // end if ("C" command)
if (cmd.equals("I"))
{ // "I" = Send invitation (requires SIG parameter)
SIGContext sig = getSIGParameter(request,user,true,"top");
String on_error = "sig/" + sig.getAlias();
if (isImageButtonClicked(request,"cancel")) // cancel - go back to SIG opening page
throw new RedirectResult(on_error);
if (isImageButtonClicked(request,"send"))
{ // the "send" button was pressed
try
{ // send out the invitation
sig.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 creating SIG: " + 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 SIG 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 SIGOperations.doPost, cmd=I");
return new ErrorBox("Internal Error","Unknown command button pressed",on_error);
} // end if ("I" command)
// this is an error!
logger.error("invalid command to SIGOperations.doPost: " + cmd);
return new ErrorBox("Internal Error","Invalid command to SIGOperations.doPost","top");

View File

@@ -20,11 +20,19 @@ 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.servlets.format.*;
public class UserDisplay extends VeniceServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(UserDisplay.class.getName());
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
@@ -53,6 +61,7 @@ public class UserDisplay extends VeniceServlet
{ // 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(prof);
} // end try
@@ -64,4 +73,69 @@ public class UserDisplay extends VeniceServlet
} // 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(prof);
} // end doVenicePost
} // end class UserDisplay

View File

@@ -0,0 +1,108 @@
/*
* 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.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 SIGContext sig; // the SIG context
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public Invitation(SIGContext sig)
{
this.sig = sig;
} // 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
/*--------------------------------------------------------------------------------
* 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 int getSIGID()
{
return sig.getSIGID();
} // end getSIGID
public String getSIGName()
{
return sig.getName();
} // end getSIGName
} // end class Invitation

View File

@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Community System.
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are