* @param context The velocity context for this request.
*/
public void doReject(RunData rundata, Context context)
throws Exception
{
JetspeedUser user = null;
try
{
//
// get the user object from the selected entry in the browser
//
user = (JetspeedUser)JetspeedSecurity.getUser(
rundata.getParameters().getString(SecurityConstants.PARAM_ENTITY_ID));
user.setConfirmed(JetspeedResources.CONFIRM_VALUE_REJECTED);
//
// update the user in the database
//
JetspeedSecurity.saveUser(user);
//
// tell the user that they can now use jetspeed
//
DynamicURI url = new DynamicURI(rundata);
//build body via template
StringWriter email_body = new StringWriter();
SimpleEmail se = new SimpleEmail();
Context emailContext = TurbineVelocity.getContext();
emailContext.put( "data", rundata );
emailContext.put( "user", user );
emailContext.put( "config",new JetspeedResources());
emailContext.put( "urltojetspeed",url);
emailContext.put( "email",se);
//determine the language to be used for the notification email
String language = (String)user.getPerm("language",TurbineResources.getString("locale.default.language", "en"));
String country = (String)user.getPerm("country",TurbineResources.getString("locale.default.country", "US"));
Locale locale = new Locale(language,country);
String templateFile = JetspeedResources.getString("newuser.approval.reject.template");
String templatePath = TemplateLocator.locateEmailTemplate(rundata, templateFile, locale );
TurbineVelocity.handleRequest(emailContext, templatePath, email_body);
se.setMsg( email_body.toString() );
Properties props = System.getProperties();
String mailServerMachine = JetspeedResources.getString( "mail.server" );
props.put ( "mail.host", mailServerMachine );
props.put("mail.smtp.host", mailServerMachine);
se.send();
} catch (Exception e)
{
// log the error msg
logger.error("Exception", e);
//
// error on update - display error message
//
DynamicURI duri = new DynamicURI (rundata);
duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_USER_UPDATE);
duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_UPDATE_FAILED);
if (user != null)
duri.addPathInfo(SecurityConstants.PARAM_ENTITY_ID, user.getUserName());
duri.addQueryData(SecurityConstants.PARAM_MODE, SecurityConstants.PARAM_MODE_UPDATE);
rundata.setRedirectURI(duri.toString());
// save values that user just entered so they don't have to re-enter
if (user != null)
rundata.getUser().setTemp(TEMP_USER, user);