Clean up paths and names relating to contact form. Use freemarker template to generate email backup.
This commit is contained in:
parent
a16985ccaa
commit
8b0665a0d7
10 changed files with 61 additions and 64 deletions
|
@ -804,6 +804,7 @@
|
||||||
<url-pattern>/listObjectPropertyStatements</url-pattern>
|
<url-pattern>/listObjectPropertyStatements</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<!--
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>EntityListController</servlet-name>
|
<servlet-name>EntityListController</servlet-name>
|
||||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.EntityListController</servlet-class>
|
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.EntityListController</servlet-class>
|
||||||
|
@ -812,7 +813,8 @@
|
||||||
<servlet-name>EntityListController</servlet-name>
|
<servlet-name>EntityListController</servlet-name>
|
||||||
<url-pattern>/entitylist</url-pattern>
|
<url-pattern>/entitylist</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
-->
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>IndividualListController</servlet-name>
|
<servlet-name>IndividualListController</servlet-name>
|
||||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController</servlet-class>
|
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController</servlet-class>
|
||||||
|
@ -863,29 +865,14 @@
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>CommentFormController</servlet-name>
|
<servlet-name>ContactFormController</servlet-name>
|
||||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.CommentFormController</servlet-class>
|
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.ContactFormController</servlet-class>
|
||||||
</servlet>
|
</servlet>
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>CommentFormController</servlet-name>
|
<servlet-name>ContactFormController</servlet-name>
|
||||||
<url-pattern>/comments</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>CommentFormController</servlet-name>
|
|
||||||
<url-pattern>/contact</url-pattern>
|
<url-pattern>/contact</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
<!-- TEMPORARY - for comparison with new version -->
|
|
||||||
<servlet>
|
|
||||||
<servlet-name>CommentsController</servlet-name>
|
|
||||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.CommentsController</servlet-class>
|
|
||||||
</servlet>
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>CommentsController</servlet-name>
|
|
||||||
<url-pattern>/comments-old</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
<!-- end TEMPORARY -->
|
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>JSON Service</servlet-name>
|
<servlet-name>JSON Service</servlet-name>
|
||||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.JSONServlet</servlet-class>
|
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.JSONServlet</servlet-class>
|
||||||
|
|
|
@ -25,10 +25,10 @@ import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||||
* Controller for comments ("contact us") page
|
* Controller for comments ("contact us") page
|
||||||
* * @author bjl23
|
* * @author bjl23
|
||||||
*/
|
*/
|
||||||
public class CommentFormController extends FreeMarkerHttpServlet {
|
public class ContactFormController extends FreeMarkerHttpServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final Log log = LogFactory.getLog(CommentFormController.class.getName());
|
private static final Log log = LogFactory.getLog(ContactFormController.class.getName());
|
||||||
|
|
||||||
protected String getTitle() {
|
protected String getTitle() {
|
||||||
return appName + " Feedback Form";
|
return appName + " Feedback Form";
|
||||||
|
@ -43,13 +43,13 @@ public class CommentFormController extends FreeMarkerHttpServlet {
|
||||||
body.put("errorMessage",
|
body.put("errorMessage",
|
||||||
"This application has not yet been configured to send mail. " +
|
"This application has not yet been configured to send mail. " +
|
||||||
"An smtp host has not been specified in the configuration properties file.");
|
"An smtp host has not been specified in the configuration properties file.");
|
||||||
bodyTemplate = "commentForm/error.ftl";
|
bodyTemplate = "contactForm/error.ftl";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (StringUtils.isEmpty(portal.getContactMail())) {
|
else if (StringUtils.isEmpty(portal.getContactMail())) {
|
||||||
body.put("errorMessage",
|
body.put("errorMessage",
|
||||||
"The site administrator has not configured an email address to receive the form submission.");
|
"The site administrator has not configured an email address to receive the form submission.");
|
||||||
bodyTemplate = "commentForm/error.ftl";
|
bodyTemplate = "contactForm/error.ftl";
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -75,12 +75,12 @@ public class CommentFormController extends FreeMarkerHttpServlet {
|
||||||
|
|
||||||
// Not used in template. Is it used in processing the form?
|
// Not used in template. Is it used in processing the form?
|
||||||
if (vreq.getHeader("Referer") == null) {
|
if (vreq.getHeader("Referer") == null) {
|
||||||
vreq.getSession().setAttribute("commentsFormReferer","none");
|
vreq.getSession().setAttribute("contactFormReferer","none");
|
||||||
} else {
|
} else {
|
||||||
vreq.getSession().setAttribute("commentsFormReferer",vreq.getHeader("Referer"));
|
vreq.getSession().setAttribute("contactFormReferer",vreq.getHeader("Referer"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyTemplate = "commentForm/form.ftl";
|
bodyTemplate = "contactForm/form.ftl";
|
||||||
}
|
}
|
||||||
|
|
||||||
return mergeBodyToTemplate(bodyTemplate, body);
|
return mergeBodyToTemplate(bodyTemplate, body);
|
|
@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -77,7 +78,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
||||||
body.put("errorMessage",
|
body.put("errorMessage",
|
||||||
"This application has not yet been configured to send mail. " +
|
"This application has not yet been configured to send mail. " +
|
||||||
"An smtp host has not been specified in the configuration properties file.");
|
"An smtp host has not been specified in the configuration properties file.");
|
||||||
bodyTemplate = "commentForm/error.ftl";
|
bodyTemplate = "contactForm/error.ftl";
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -93,7 +94,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
||||||
// rjy7 We should reload the form, not go to the error page!
|
// rjy7 We should reload the form, not go to the error page!
|
||||||
body.put("errorMessage",
|
body.put("errorMessage",
|
||||||
"Invalid submission");
|
"Invalid submission");
|
||||||
bodyTemplate = "commentForm/error.ftl";
|
bodyTemplate = "contactForm/error.ftl";
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -103,9 +104,9 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
||||||
|
|
||||||
String spamReason = null;
|
String spamReason = null;
|
||||||
|
|
||||||
String originalReferer = (String) vreq.getSession().getAttribute("commentsFormReferer");
|
String originalReferer = (String) vreq.getSession().getAttribute("contactFormReferer");
|
||||||
if (originalReferer != null) {
|
if (originalReferer != null) {
|
||||||
vreq.getSession().removeAttribute("commentsFormReferer");
|
vreq.getSession().removeAttribute("contactFormReferer");
|
||||||
/* does not support legitimate clients that don't send the Referer header
|
/* does not support legitimate clients that don't send the Referer header
|
||||||
String referer = request.getHeader("Referer");
|
String referer = request.getHeader("Referer");
|
||||||
if (referer == null ||
|
if (referer == null ||
|
||||||
|
@ -132,7 +133,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
||||||
int recipientCount = 0;
|
int recipientCount = 0;
|
||||||
String deliveryfrom = null;
|
String deliveryfrom = null;
|
||||||
|
|
||||||
if ("comment".equals(formType)) {
|
if ("contact".equals(formType)) {
|
||||||
if (portal.getContactMail() == null || portal.getContactMail().trim().length()==0) {
|
if (portal.getContactMail() == null || portal.getContactMail().trim().length()==0) {
|
||||||
LOG.error("No contact mail address defined in current portal "+portal.getPortalId());
|
LOG.error("No contact mail address defined in current portal "+portal.getPortalId());
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
@ -142,18 +143,6 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
||||||
deliverToArray = portal.getContactMail().split(",");
|
deliverToArray = portal.getContactMail().split(",");
|
||||||
}
|
}
|
||||||
deliveryfrom = "Message from the "+portal.getAppName()+" Contact Form";
|
deliveryfrom = "Message from the "+portal.getAppName()+" Contact Form";
|
||||||
} else if ("correction".equals(formType)) {
|
|
||||||
if (portal.getCorrectionMail() == null || portal.getCorrectionMail().trim().length()==0) {
|
|
||||||
LOG.error("Expecting one or more correction email addresses to be specified in current portal "+portal.getPortalId()+"; will attempt to use contact mail address");
|
|
||||||
if (portal.getContactMail() == null || portal.getContactMail().trim().length()==0) {
|
|
||||||
LOG.error("No contact mail address or correction mail address defined in current portal "+portal.getPortalId());
|
|
||||||
} else {
|
|
||||||
deliverToArray = portal.getContactMail().split(",");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
deliverToArray = portal.getCorrectionMail().split(",");
|
|
||||||
}
|
|
||||||
deliveryfrom = "Message from the "+portal.getAppName()+" Correction Form (ARMANN-nospam)";
|
|
||||||
} else {
|
} else {
|
||||||
deliverToArray = portal.getContactMail().split(",");
|
deliverToArray = portal.getContactMail().split(",");
|
||||||
statusMsg = SPAM_MESSAGE ;
|
statusMsg = SPAM_MESSAGE ;
|
||||||
|
@ -212,10 +201,10 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
||||||
|
|
||||||
// Message was sent successfully
|
// Message was sent successfully
|
||||||
if (statusMsg == null && spamReason == null) {
|
if (statusMsg == null && spamReason == null) {
|
||||||
bodyTemplate = "commentForm/confirmation.ftl";
|
bodyTemplate = "contactForm/confirmation.ftl";
|
||||||
} else {
|
} else {
|
||||||
body.put("errorMessage", statusMsg);
|
body.put("errorMessage", statusMsg);
|
||||||
bodyTemplate = "commentForm/error.ftl";
|
bodyTemplate = "contactForm/error.ftl";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +227,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
||||||
String originalReferer, String ipAddr) {
|
String originalReferer, String ipAddr) {
|
||||||
|
|
||||||
Map<String, Object> email = new HashMap<String, Object>();
|
Map<String, Object> email = new HashMap<String, Object>();
|
||||||
String template = "commentForm/email.ftl";
|
String template = "contactForm/email.ftl";
|
||||||
|
|
||||||
email.put("subject", deliveryfrom);
|
email.put("subject", deliveryfrom);
|
||||||
email.put("name", webusername);
|
email.put("name", webusername);
|
||||||
|
@ -254,21 +243,23 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
||||||
|
|
||||||
private void writeBackupCopy(PrintWriter outFile, String msgText,
|
private void writeBackupCopy(PrintWriter outFile, String msgText,
|
||||||
String spamReason) {
|
String spamReason) {
|
||||||
|
|
||||||
|
Map<String, Object> backup = new HashMap<String, Object>();
|
||||||
|
String template = "contactForm/backup.ftl";
|
||||||
|
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
outFile.println("<hr/>");
|
backup.put("datetime", cal.getTime().toString());
|
||||||
outFile.println();
|
|
||||||
outFile.println("<p>"+cal.getTime()+"</p>");
|
|
||||||
outFile.println();
|
|
||||||
if (spamReason != null) {
|
if (spamReason != null) {
|
||||||
outFile.println("<p>REJECTED - SPAM</p>");
|
backup.put("spamReason", spamReason);
|
||||||
outFile.println("<p>"+spamReason+"</p>");
|
|
||||||
outFile.println();
|
|
||||||
}
|
}
|
||||||
outFile.print( msgText );
|
|
||||||
outFile.println();
|
backup.put("msgText", msgText);
|
||||||
outFile.println();
|
|
||||||
|
String backupText = mergeBodyToTemplate(template, backup);
|
||||||
|
outFile.print(backupText);
|
||||||
outFile.flush();
|
outFile.flush();
|
||||||
// outFile.close();
|
//outFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessage(Session s, String webuseremail, String webusername,
|
private void sendMessage(Session s, String webuseremail, String webusername,
|
||||||
|
|
|
@ -193,7 +193,7 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
||||||
|
|
||||||
urls.put("about", getUrl(Routes.ABOUT, portalParam));
|
urls.put("about", getUrl(Routes.ABOUT, portalParam));
|
||||||
if (ContactMailServlet.getSmtpHostFromProperties() != null) {
|
if (ContactMailServlet.getSmtpHostFromProperties() != null) {
|
||||||
urls.put("contact", getUrl(Routes.COMMENT_FORM, portalParam));
|
urls.put("contact", getUrl(Routes.CONTACT, portalParam));
|
||||||
}
|
}
|
||||||
urls.put("search", getUrl(Routes.SEARCH));
|
urls.put("search", getUrl(Routes.SEARCH));
|
||||||
urls.put("termsOfUse", getUrl(Routes.TERMS_OF_USE, portalParam));
|
urls.put("termsOfUse", getUrl(Routes.TERMS_OF_USE, portalParam));
|
||||||
|
|
|
@ -9,9 +9,9 @@ public class Routes {
|
||||||
|
|
||||||
public static final String ABOUT = "/about";
|
public static final String ABOUT = "/about";
|
||||||
public static final String BROWSE = "/browse";
|
public static final String BROWSE = "/browse";
|
||||||
public static final String COMMENT_FORM = "/comments";
|
public static final String CONTACT = "/contact";
|
||||||
public static final String INDIVIDUAL = "/individual";
|
public static final String INDIVIDUAL = "/individual";
|
||||||
public static final String INDIVIDUAL_LIST = "/individuallist"; // "/entitylist"; "/individuallist";
|
public static final String INDIVIDUAL_LIST = "/individuallist";
|
||||||
public static final String SEARCH = "/search";
|
public static final String SEARCH = "/search";
|
||||||
public static final String TERMS_OF_USE = "/termsOfUse";
|
public static final String TERMS_OF_USE = "/termsOfUse";
|
||||||
|
|
||||||
|
|
16
webapp/web/templates/freemarker/body/contactForm/backup.ftl
Normal file
16
webapp/web/templates/freemarker/body/contactForm/backup.ftl
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Backup of contact mail email -->
|
||||||
|
|
||||||
|
<p>${datetime}</p>
|
||||||
|
|
||||||
|
<#if spamReason??>
|
||||||
|
<div style="color:red;">
|
||||||
|
<p>REJECTED - SPAM</p>
|
||||||
|
<p>${spamReason}</p>
|
||||||
|
</div>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
${msgText}
|
||||||
|
|
||||||
|
<hr />
|
|
@ -1,6 +1,6 @@
|
||||||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
<#-- Confirmation page for comment form -->
|
<#-- Contact form submission confirmation page -->
|
||||||
|
|
||||||
<h2>Thank you for your feedback</h2>
|
<h2>Thank you for your feedback</h2>
|
||||||
<img src="${siteIconPath}/mail.gif" alt="mailbox"/><br/>
|
<img src="${siteIconPath}/mail.gif" alt="mailbox"/><br/>
|
|
@ -1,6 +1,6 @@
|
||||||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
<#-- Comment form email response -->
|
<#-- Contact form email response -->
|
||||||
|
|
||||||
<#-- Only inline styles seem to work in email. Can't get styles for margin to work, though. -->
|
<#-- Only inline styles seem to work in email. Can't get styles for margin to work, though. -->
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
<img src="${siteIconPath}/bomb.gif" alt="email error"/>
|
<#-- Contact form processing errors -->
|
||||||
|
|
||||||
|
<h2>${title}</h2>
|
||||||
|
|
||||||
|
<img src="${siteIconPath}/bomb.gif" alt="email error"/>
|
||||||
|
|
||||||
<p class="normal">An error occurred during the processing of your request.<br />
|
<p class="normal">An error occurred during the processing of your request.<br />
|
||||||
<#if errorMessage?has_content>
|
<#if errorMessage?has_content>
|
|
@ -33,7 +33,7 @@
|
||||||
<input type="hidden" name="RequiredFieldsNames" value="Name,Email address,Comments"/>
|
<input type="hidden" name="RequiredFieldsNames" value="Name,Email address,Comments"/>
|
||||||
<input type="hidden" name="EmailFields" value="webuseremail"/>
|
<input type="hidden" name="EmailFields" value="webuseremail"/>
|
||||||
<input type="hidden" name="EmailFieldsNames" value="emailaddress"/>
|
<input type="hidden" name="EmailFieldsNames" value="emailaddress"/>
|
||||||
<input type="hidden" name="DeliveryType" value="comment"/>
|
<input type="hidden" name="DeliveryType" value="contact"/>
|
||||||
|
|
||||||
<label for="webusername">Full name</label>
|
<label for="webusername">Full name</label>
|
||||||
<p><input style="width:33%;" type="text" name="webusername" maxlength="255"/></p>
|
<p><input style="width:33%;" type="text" name="webusername" maxlength="255"/></p>
|
Loading…
Add table
Reference in a new issue