Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added email templates and sending for deposit receipt and deposit not…

…ices

added email sending unit test
modified form model to include contact information

added deposit error email sending and test
still needs error text output, pending that result api
  • Loading branch information...
commit 474125309f2185a9d02be8c8c0835393656c825f 1 parent 9bb0741
@gregjan gregjan authored
Showing with 1,085 additions and 24 deletions.
  1. +2 −0  crosswalk-gmf.edit/plugin.properties
  2. +49 −1 crosswalk-gmf.edit/src/crosswalk/provider/FormItemProvider.java
  3. +1 −0  crosswalk-gmf/META-INF/MANIFEST.MF
  4. +4 −0 crosswalk-gmf/model/crosswalk.ecore
  5. +2 −0  crosswalk-gmf/model/crosswalk.genmodel
  6. +57 −1 crosswalk-gmf/src/crosswalk/CrosswalkPackage.java
  7. +108 −0 crosswalk-gmf/src/crosswalk/Form.java
  8. +22 −0 crosswalk-gmf/src/crosswalk/impl/CrosswalkPackageImpl.java
  9. +176 −0 crosswalk-gmf/src/crosswalk/impl/FormImpl.java
  10. +1 −1  crosswalk-gmf/src/crosswalk/impl/MappedElementImpl.java
  11. +13 −1 forms/pom.xml
  12. +132 −13 forms/src/main/java/cdr/forms/EmailNotificationHandler.java
  13. +3 −3 forms/src/main/java/cdr/forms/FormController.java
  14. +19 −1 forms/src/main/java/cdr/forms/NotificationHandler.java
  15. +3 −3 forms/src/main/webapp/WEB-INF/service-context.xml
  16. +120 −0 forms/src/test/java/EmailNotificationTest.java
  17. +46 −0 forms/src/test/resources/DepositErrorHtml.ftl
  18. +33 −0 forms/src/test/resources/DepositErrorText.ftl
  19. +46 −0 forms/src/test/resources/DepositNoticeHtml.ftl
  20. +39 −0 forms/src/test/resources/DepositNoticeText.ftl
  21. +48 −0 forms/src/test/resources/DepositReceiptHtml.ftl
  22. +39 −0 forms/src/test/resources/DepositReceiptText.ftl
  23. +71 −0 forms/src/test/resources/email-test-service-context.xml
  24. +28 −0 forms/src/test/resources/log4j.properties
  25. +23 −0 forms/src/test/resources/server.properties
View
2  crosswalk-gmf.edit/plugin.properties
@@ -196,3 +196,5 @@ _UI_TextInputType_SingleLine_literal = Single Line
_UI_TextInputType_MultipleLines_literal = Multiple Lines
_UI_MappedAttribute_omittedWhenBlank_feature = Omitted When Blank
_UI_Form_canAddSupplementalFiles_feature = Can Add Supplemental Files
+_UI_Form_contactName_feature = Contact Name
+_UI_Form_contactEmail_feature = Contact Email
View
50 crosswalk-gmf.edit/src/crosswalk/provider/FormItemProvider.java
@@ -75,6 +75,8 @@ public FormItemProvider(AdapterFactory adapterFactory) {
addReviewBeforePublicationPropertyDescriptor(object);
addPromptForMultipleSubmissionsPropertyDescriptor(object);
addCanAddSupplementalFilesPropertyDescriptor(object);
+ addContactNamePropertyDescriptor(object);
+ addContactEmailPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
@@ -256,6 +258,50 @@ protected void addCanAddSupplementalFilesPropertyDescriptor(Object object) {
}
/**
+ * This adds a property descriptor for the Contact Name feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addContactNamePropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add
+ (createItemPropertyDescriptor
+ (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_Form_contactName_feature"),
+ getString("_UI_PropertyDescriptor_description", "_UI_Form_contactName_feature", "_UI_Form_type"),
+ CrosswalkPackage.Literals.FORM__CONTACT_NAME,
+ true,
+ false,
+ false,
+ ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
+ null,
+ null));
+ }
+
+ /**
+ * This adds a property descriptor for the Contact Email feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addContactEmailPropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add
+ (createItemPropertyDescriptor
+ (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_Form_contactEmail_feature"),
+ getString("_UI_PropertyDescriptor_description", "_UI_Form_contactEmail_feature", "_UI_Form_type"),
+ CrosswalkPackage.Literals.FORM__CONTACT_EMAIL,
+ true,
+ false,
+ false,
+ ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
+ null,
+ null));
+ }
+
+ /**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
@@ -304,7 +350,7 @@ public Object getImage(Object object) {
*/
@Override
public String getText(Object object) {
- String label = ((Form)object).getCurrentUser();
+ String label = ((Form)object).getContactName();
return label == null || label.length() == 0 ?
getString("_UI_Form_type") :
getString("_UI_Form_type") + " " + label;
@@ -331,6 +377,8 @@ public void notifyChanged(Notification notification) {
case CrosswalkPackage.FORM__REVIEW_BEFORE_PUBLICATION:
case CrosswalkPackage.FORM__PROMPT_FOR_MULTIPLE_SUBMISSIONS:
case CrosswalkPackage.FORM__CAN_ADD_SUPPLEMENTAL_FILES:
+ case CrosswalkPackage.FORM__CONTACT_NAME:
+ case CrosswalkPackage.FORM__CONTACT_EMAIL:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
case CrosswalkPackage.FORM__ELEMENTS:
View
1  crosswalk-gmf/META-INF/MANIFEST.MF
@@ -17,3 +17,4 @@ Require-Bundle: org.eclipse.core.runtime,
org.slf4j.log4j12;bundle-version="1.6.6"
Bundle-ClassPath: .,
lib/opencsv-2.2.jar
+Import-Package: org.slf4j
View
4 crosswalk-gmf/model/crosswalk.ecore
@@ -218,6 +218,10 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="canAddSupplementalFiles"
lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"
defaultValueLiteral="false"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="contactName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
+ unsettable="true"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="contactEmail" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
+ unsettable="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="FormElement" abstract="true" interface="true"/>
<eClassifiers xsi:type="ecore:EDataType" name="URI" instanceClassName="java.net.URI"/>
View
2  crosswalk-gmf/model/crosswalk.genmodel
@@ -176,6 +176,8 @@
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute crosswalk.ecore#//Form/reviewBeforePublication"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute crosswalk.ecore#//Form/promptForMultipleSubmissions"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute crosswalk.ecore#//Form/canAddSupplementalFiles"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute crosswalk.ecore#//Form/contactName"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute crosswalk.ecore#//Form/contactEmail"/>
</genClasses>
<genClasses image="false" ecoreClass="crosswalk.ecore#//FormElement"/>
<genClasses ecoreClass="crosswalk.ecore#//Paragraph">
View
58 crosswalk-gmf/src/crosswalk/CrosswalkPackage.java
@@ -1580,13 +1580,31 @@
int FORM__CAN_ADD_SUPPLEMENTAL_FILES = EDITABLE_FEATURE_COUNT + 10;
/**
+ * The feature id for the '<em><b>Contact Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int FORM__CONTACT_NAME = EDITABLE_FEATURE_COUNT + 11;
+
+ /**
+ * The feature id for the '<em><b>Contact Email</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int FORM__CONTACT_EMAIL = EDITABLE_FEATURE_COUNT + 12;
+
+ /**
* The number of structural features of the '<em>Form</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- int FORM_FEATURE_COUNT = EDITABLE_FEATURE_COUNT + 11;
+ int FORM_FEATURE_COUNT = EDITABLE_FEATURE_COUNT + 13;
/**
* The meta object id for the '{@link crosswalk.FormElement <em>Form Element</em>}' class.
@@ -2802,6 +2820,28 @@
EAttribute getForm_CanAddSupplementalFiles();
/**
+ * Returns the meta object for the attribute '{@link crosswalk.Form#getContactName <em>Contact Name</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Contact Name</em>'.
+ * @see crosswalk.Form#getContactName()
+ * @see #getForm()
+ * @generated
+ */
+ EAttribute getForm_ContactName();
+
+ /**
+ * Returns the meta object for the attribute '{@link crosswalk.Form#getContactEmail <em>Contact Email</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Contact Email</em>'.
+ * @see crosswalk.Form#getContactEmail()
+ * @see #getForm()
+ * @generated
+ */
+ EAttribute getForm_ContactEmail();
+
+ /**
* Returns the meta object for class '{@link crosswalk.FormElement <em>Form Element</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -3785,6 +3825,22 @@
EAttribute FORM__CAN_ADD_SUPPLEMENTAL_FILES = eINSTANCE.getForm_CanAddSupplementalFiles();
/**
+ * The meta object literal for the '<em><b>Contact Name</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute FORM__CONTACT_NAME = eINSTANCE.getForm_ContactName();
+
+ /**
+ * The meta object literal for the '<em><b>Contact Email</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute FORM__CONTACT_EMAIL = eINSTANCE.getForm_ContactEmail();
+
+ /**
* The meta object literal for the '{@link crosswalk.FormElement <em>Form Element</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
View
108 crosswalk-gmf/src/crosswalk/Form.java
@@ -26,6 +26,8 @@
* <li>{@link crosswalk.Form#isReviewBeforePublication <em>Review Before Publication</em>}</li>
* <li>{@link crosswalk.Form#isPromptForMultipleSubmissions <em>Prompt For Multiple Submissions</em>}</li>
* <li>{@link crosswalk.Form#isCanAddSupplementalFiles <em>Can Add Supplemental Files</em>}</li>
+ * <li>{@link crosswalk.Form#getContactName <em>Contact Name</em>}</li>
+ * <li>{@link crosswalk.Form#getContactEmail <em>Contact Email</em>}</li>
* </ul>
* </p>
*
@@ -241,4 +243,110 @@
*/
void setCanAddSupplementalFiles(boolean value);
+ /**
+ * Returns the value of the '<em><b>Contact Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Contact Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Contact Name</em>' attribute.
+ * @see #isSetContactName()
+ * @see #unsetContactName()
+ * @see #setContactName(String)
+ * @see crosswalk.CrosswalkPackage#getForm_ContactName()
+ * @model unsettable="true"
+ * @generated
+ */
+ String getContactName();
+
+ /**
+ * Sets the value of the '{@link crosswalk.Form#getContactName <em>Contact Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Contact Name</em>' attribute.
+ * @see #isSetContactName()
+ * @see #unsetContactName()
+ * @see #getContactName()
+ * @generated
+ */
+ void setContactName(String value);
+
+ /**
+ * Unsets the value of the '{@link crosswalk.Form#getContactName <em>Contact Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetContactName()
+ * @see #getContactName()
+ * @see #setContactName(String)
+ * @generated
+ */
+ void unsetContactName();
+
+ /**
+ * Returns whether the value of the '{@link crosswalk.Form#getContactName <em>Contact Name</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Contact Name</em>' attribute is set.
+ * @see #unsetContactName()
+ * @see #getContactName()
+ * @see #setContactName(String)
+ * @generated
+ */
+ boolean isSetContactName();
+
+ /**
+ * Returns the value of the '<em><b>Contact Email</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Contact Email</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Contact Email</em>' attribute.
+ * @see #isSetContactEmail()
+ * @see #unsetContactEmail()
+ * @see #setContactEmail(String)
+ * @see crosswalk.CrosswalkPackage#getForm_ContactEmail()
+ * @model unsettable="true"
+ * @generated
+ */
+ String getContactEmail();
+
+ /**
+ * Sets the value of the '{@link crosswalk.Form#getContactEmail <em>Contact Email</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Contact Email</em>' attribute.
+ * @see #isSetContactEmail()
+ * @see #unsetContactEmail()
+ * @see #getContactEmail()
+ * @generated
+ */
+ void setContactEmail(String value);
+
+ /**
+ * Unsets the value of the '{@link crosswalk.Form#getContactEmail <em>Contact Email</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetContactEmail()
+ * @see #getContactEmail()
+ * @see #setContactEmail(String)
+ * @generated
+ */
+ void unsetContactEmail();
+
+ /**
+ * Returns whether the value of the '{@link crosswalk.Form#getContactEmail <em>Contact Email</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Contact Email</em>' attribute is set.
+ * @see #unsetContactEmail()
+ * @see #getContactEmail()
+ * @see #setContactEmail(String)
+ * @generated
+ */
+ boolean isSetContactEmail();
+
} // Form
View
22 crosswalk-gmf/src/crosswalk/impl/CrosswalkPackageImpl.java
@@ -1285,6 +1285,24 @@ public EAttribute getForm_CanAddSupplementalFiles() {
* <!-- end-user-doc -->
* @generated
*/
+ public EAttribute getForm_ContactName() {
+ return (EAttribute)formEClass.getEStructuralFeatures().get(9);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getForm_ContactEmail() {
+ return (EAttribute)formEClass.getEStructuralFeatures().get(10);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public EClass getFormElement() {
return formElementEClass;
}
@@ -1564,6 +1582,8 @@ public void createPackageContents() {
createEAttribute(formEClass, FORM__REVIEW_BEFORE_PUBLICATION);
createEAttribute(formEClass, FORM__PROMPT_FOR_MULTIPLE_SUBMISSIONS);
createEAttribute(formEClass, FORM__CAN_ADD_SUPPLEMENTAL_FILES);
+ createEAttribute(formEClass, FORM__CONTACT_NAME);
+ createEAttribute(formEClass, FORM__CONTACT_EMAIL);
formElementEClass = createEClass(FORM_ELEMENT);
@@ -1836,6 +1856,8 @@ public void initializePackageContents() {
initEAttribute(getForm_ReviewBeforePublication(), ecorePackage.getEBoolean(), "reviewBeforePublication", "true", 1, 1, Form.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getForm_PromptForMultipleSubmissions(), ecorePackage.getEBoolean(), "promptForMultipleSubmissions", "false", 1, 1, Form.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getForm_CanAddSupplementalFiles(), ecorePackage.getEBoolean(), "canAddSupplementalFiles", "false", 1, 1, Form.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getForm_ContactName(), ecorePackage.getEString(), "contactName", null, 0, 1, Form.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getForm_ContactEmail(), ecorePackage.getEString(), "contactEmail", null, 0, 1, Form.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(formElementEClass, FormElement.class, "FormElement", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
View
176 crosswalk-gmf/src/crosswalk/impl/FormImpl.java
@@ -42,6 +42,8 @@
* <li>{@link crosswalk.impl.FormImpl#isReviewBeforePublication <em>Review Before Publication</em>}</li>
* <li>{@link crosswalk.impl.FormImpl#isPromptForMultipleSubmissions <em>Prompt For Multiple Submissions</em>}</li>
* <li>{@link crosswalk.impl.FormImpl#isCanAddSupplementalFiles <em>Can Add Supplemental Files</em>}</li>
+ * <li>{@link crosswalk.impl.FormImpl#getContactName <em>Contact Name</em>}</li>
+ * <li>{@link crosswalk.impl.FormImpl#getContactEmail <em>Contact Email</em>}</li>
* </ul>
* </p>
*
@@ -229,6 +231,64 @@
protected boolean canAddSupplementalFiles = CAN_ADD_SUPPLEMENTAL_FILES_EDEFAULT;
/**
+ * The default value of the '{@link #getContactName() <em>Contact Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getContactName()
+ * @generated
+ * @ordered
+ */
+ protected static final String CONTACT_NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getContactName() <em>Contact Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getContactName()
+ * @generated
+ * @ordered
+ */
+ protected String contactName = CONTACT_NAME_EDEFAULT;
+
+ /**
+ * This is true if the Contact Name attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean contactNameESet;
+
+ /**
+ * The default value of the '{@link #getContactEmail() <em>Contact Email</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getContactEmail()
+ * @generated
+ * @ordered
+ */
+ protected static final String CONTACT_EMAIL_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getContactEmail() <em>Contact Email</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getContactEmail()
+ * @generated
+ * @ordered
+ */
+ protected String contactEmail = CONTACT_EMAIL_EDEFAULT;
+
+ /**
+ * This is true if the Contact Email attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean contactEmailESet;
+
+ /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -473,6 +533,98 @@ public void setCanAddSupplementalFiles(boolean newCanAddSupplementalFiles) {
* <!-- end-user-doc -->
* @generated
*/
+ public String getContactName() {
+ return contactName;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setContactName(String newContactName) {
+ String oldContactName = contactName;
+ contactName = newContactName;
+ boolean oldContactNameESet = contactNameESet;
+ contactNameESet = true;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, CrosswalkPackage.FORM__CONTACT_NAME, oldContactName, contactName, !oldContactNameESet));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void unsetContactName() {
+ String oldContactName = contactName;
+ boolean oldContactNameESet = contactNameESet;
+ contactName = CONTACT_NAME_EDEFAULT;
+ contactNameESet = false;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.UNSET, CrosswalkPackage.FORM__CONTACT_NAME, oldContactName, CONTACT_NAME_EDEFAULT, oldContactNameESet));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetContactName() {
+ return contactNameESet;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getContactEmail() {
+ return contactEmail;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setContactEmail(String newContactEmail) {
+ String oldContactEmail = contactEmail;
+ contactEmail = newContactEmail;
+ boolean oldContactEmailESet = contactEmailESet;
+ contactEmailESet = true;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, CrosswalkPackage.FORM__CONTACT_EMAIL, oldContactEmail, contactEmail, !oldContactEmailESet));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void unsetContactEmail() {
+ String oldContactEmail = contactEmail;
+ boolean oldContactEmailESet = contactEmailESet;
+ contactEmail = CONTACT_EMAIL_EDEFAULT;
+ contactEmailESet = false;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.UNSET, CrosswalkPackage.FORM__CONTACT_EMAIL, oldContactEmail, CONTACT_EMAIL_EDEFAULT, oldContactEmailESet));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetContactEmail() {
+ return contactEmailESet;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
@@ -513,6 +665,10 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) {
return isPromptForMultipleSubmissions();
case CrosswalkPackage.FORM__CAN_ADD_SUPPLEMENTAL_FILES:
return isCanAddSupplementalFiles();
+ case CrosswalkPackage.FORM__CONTACT_NAME:
+ return getContactName();
+ case CrosswalkPackage.FORM__CONTACT_EMAIL:
+ return getContactEmail();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -562,6 +718,12 @@ public void eSet(int featureID, Object newValue) {
case CrosswalkPackage.FORM__CAN_ADD_SUPPLEMENTAL_FILES:
setCanAddSupplementalFiles((Boolean)newValue);
return;
+ case CrosswalkPackage.FORM__CONTACT_NAME:
+ setContactName((String)newValue);
+ return;
+ case CrosswalkPackage.FORM__CONTACT_EMAIL:
+ setContactEmail((String)newValue);
+ return;
}
super.eSet(featureID, newValue);
}
@@ -607,6 +769,12 @@ public void eUnset(int featureID) {
case CrosswalkPackage.FORM__CAN_ADD_SUPPLEMENTAL_FILES:
setCanAddSupplementalFiles(CAN_ADD_SUPPLEMENTAL_FILES_EDEFAULT);
return;
+ case CrosswalkPackage.FORM__CONTACT_NAME:
+ unsetContactName();
+ return;
+ case CrosswalkPackage.FORM__CONTACT_EMAIL:
+ unsetContactEmail();
+ return;
}
super.eUnset(featureID);
}
@@ -641,6 +809,10 @@ public boolean eIsSet(int featureID) {
return promptForMultipleSubmissions != PROMPT_FOR_MULTIPLE_SUBMISSIONS_EDEFAULT;
case CrosswalkPackage.FORM__CAN_ADD_SUPPLEMENTAL_FILES:
return canAddSupplementalFiles != CAN_ADD_SUPPLEMENTAL_FILES_EDEFAULT;
+ case CrosswalkPackage.FORM__CONTACT_NAME:
+ return isSetContactName();
+ case CrosswalkPackage.FORM__CONTACT_EMAIL:
+ return isSetContactEmail();
}
return super.eIsSet(featureID);
}
@@ -707,6 +879,10 @@ public String toString() {
result.append(promptForMultipleSubmissions);
result.append(", canAddSupplementalFiles: ");
result.append(canAddSupplementalFiles);
+ result.append(", contactName: ");
+ if (contactNameESet) result.append(contactName); else result.append("<unset>");
+ result.append(", contactEmail: ");
+ if (contactEmailESet) result.append(contactEmail); else result.append("<unset>");
result.append(')');
return result.toString();
}
View
2  crosswalk-gmf/src/crosswalk/impl/MappedElementImpl.java
@@ -32,7 +32,7 @@
import org.eclipse.emf.ecore.util.FeatureMapUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.slf4j.LoggerFactory;
import crosswalk.CrosswalkPackage;
import crosswalk.MappedAttribute;
View
14 forms/pom.xml
@@ -30,7 +30,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -173,5 +173,17 @@
<artifactId>access-control</artifactId>
<version>4.1.1-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
View
145 forms/src/main/java/cdr/forms/EmailNotificationHandler.java
@@ -2,6 +2,7 @@
import java.io.IOException;
import java.io.StringWriter;
+import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
@@ -21,8 +22,12 @@
public class EmailNotificationHandler implements NotificationHandler {
private static final Logger LOG = LoggerFactory
.getLogger(EmailNotificationHandler.class);
- private Template depositHtmlTemplate = null;
- private Template depositTextTemplate = null;
+ private Template depositReceiptHtmlTemplate = null;
+ private Template depositReceiptTextTemplate = null;
+ private Template depositNoticeHtmlTemplate = null;
+ private Template depositNoticeTextTemplate = null;
+ private Template depositErrorHtmlTemplate = null;
+ private Template depositErrorTextTemplate = null;
private JavaMailSender mailSender = null;
@@ -53,13 +58,51 @@ public void setFromAddress(String fromAddress) {
private Configuration freemarkerConfiguration = null;
private String fromAddress = null;
+
+ private String administratorAddress = null;
+
+ private String siteUrl = null;
+
+ private String siteName = null;
+
+ public String getSiteName() {
+ return siteName;
+ }
+
+ public void setSiteName(String siteName) {
+ this.siteName = siteName;
+ }
+
+ public String getSiteUrl() {
+ return siteUrl;
+ }
+
+ public void setSiteUrl(String siteUrl) {
+ this.siteUrl = siteUrl;
+ }
+
+ public String getAdministratorAddress() {
+ return administratorAddress;
+ }
+
+ public void setAdministratorAddress(String administratorAddress) {
+ this.administratorAddress = administratorAddress;
+ }
public void init() {
try {
- depositHtmlTemplate = getFreemarkerConfiguration().getTemplate(
- "depositHtml.ftl", Locale.getDefault(), "utf-8");
- depositTextTemplate = getFreemarkerConfiguration().getTemplate(
- "depositText.ftl", Locale.getDefault(), "utf-8");
+ depositReceiptHtmlTemplate = getFreemarkerConfiguration().getTemplate(
+ "DepositReceiptHtml.ftl", Locale.getDefault(), "utf-8");
+ depositReceiptTextTemplate = getFreemarkerConfiguration().getTemplate(
+ "DepositReceiptText.ftl", Locale.getDefault(), "utf-8");
+ depositNoticeHtmlTemplate = getFreemarkerConfiguration().getTemplate(
+ "DepositNoticeHtml.ftl", Locale.getDefault(), "utf-8");
+ depositNoticeTextTemplate = getFreemarkerConfiguration().getTemplate(
+ "DepositNoticeText.ftl", Locale.getDefault(), "utf-8");
+ depositErrorHtmlTemplate = getFreemarkerConfiguration().getTemplate(
+ "DepositErrorHtml.ftl", Locale.getDefault(), "utf-8");
+ depositErrorTextTemplate = getFreemarkerConfiguration().getTemplate(
+ "DepositErrorText.ftl", Locale.getDefault(), "utf-8");
} catch (IOException e) {
throw new Error("Cannot load email templates", e);
}
@@ -67,17 +110,66 @@ public void init() {
@Override
public void notifyDeposit(Form form, DepositResult result,
- String depositorEmail) {
+ String depositorEmail, String formId) {
// put data into the model
HashMap<String, Object> model = new HashMap<String, Object>();
model.put("form", form);
+ model.put("formId", formId);
model.put("result", result);
+ model.put("siteUrl", this.getSiteUrl());
+ model.put("siteName", this.getSiteName());
+ model.put("receivedDate", new Date(System.currentTimeMillis()));
+ sendReceipt(model, depositorEmail, form);
+ sendNotice(model, form);
+ }
+
+ @Override
+ public void notifyError(Form form, DepositResult result,
+ String depositorEmail, String formId) {
+ if(administratorAddress == null || administratorAddress.trim().length() == 0) return;
+ // put data into the model
+ HashMap<String, Object> model = new HashMap<String, Object>();
+ model.put("form", form);
+ model.put("formId", formId);
+ model.put("result", result);
+ model.put("depositorEmail", depositorEmail);
+ model.put("siteUrl", this.getSiteUrl());
+ model.put("siteName", this.getSiteName());
+ model.put("receivedDate", new Date(System.currentTimeMillis()));
+ StringWriter htmlsw = new StringWriter();
+ StringWriter textsw = new StringWriter();
+ try {
+ depositErrorHtmlTemplate.process(model, htmlsw);
+ depositErrorTextTemplate.process(model, textsw);
+ } catch (TemplateException e) {
+ LOG.error("cannot process email template", e);
+ return;
+ } catch (IOException e) {
+ LOG.error("cannot process email template", e);
+ return;
+ }
+ try {
+ MimeMessage mimeMessage = mailSender.createMimeMessage();
+ MimeMessageHelper message = new MimeMessageHelper(mimeMessage,
+ MimeMessageHelper.MULTIPART_MODE_MIXED);
+ message.addTo(this.administratorAddress);
+ message.setSubject("Deposit Error for " + form.getTitle());
+ message.setFrom(this.getFromAddress());
+ message.setText(textsw.toString() , htmlsw.toString());
+ this.mailSender.send(mimeMessage);
+ } catch (MessagingException e) {
+ LOG.error("problem sending deposit message", e);
+ }
+ }
+
+ private void sendReceipt(HashMap<String, Object> model, String email, Form form) {
+ if(email == null || email.trim().length() == 0) return;
StringWriter htmlsw = new StringWriter();
StringWriter textsw = new StringWriter();
try {
- depositHtmlTemplate.process(model, htmlsw);
- depositTextTemplate.process(model, textsw);
+ depositReceiptHtmlTemplate.process(model, htmlsw);
+ depositReceiptTextTemplate.process(model, textsw);
} catch (TemplateException e) {
LOG.error("cannot process email template", e);
return;
@@ -90,14 +182,41 @@ public void notifyDeposit(Form form, DepositResult result,
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper message = new MimeMessageHelper(mimeMessage,
MimeMessageHelper.MULTIPART_MODE_MIXED);
+ message.addTo(email);
+ message.setSubject("Deposit Receipt for " + form.getTitle());
+ message.setFrom(this.getFromAddress());
+ message.setText(textsw.toString() , htmlsw.toString());
+ this.mailSender.send(mimeMessage);
+ } catch (MessagingException e) {
+ LOG.error("problem sending deposit message", e);
+ }
+ }
+
+ private void sendNotice(HashMap<String, Object> model, Form form) {
+ if(form.getEmailDepositNoticeTo() == null || form.getEmailDepositNoticeTo().isEmpty()) return;
+ StringWriter htmlsw = new StringWriter();
+ StringWriter textsw = new StringWriter();
+ try {
+ depositNoticeHtmlTemplate.process(model, htmlsw);
+ depositNoticeTextTemplate.process(model, textsw);
+ } catch (TemplateException e) {
+ LOG.error("cannot process email template", e);
+ return;
+ } catch (IOException e) {
+ LOG.error("cannot process email template", e);
+ return;
+ }
- for (String addy : form.getEmailDepositNoticeTo()) {
+ try {
+ MimeMessage mimeMessage = mailSender.createMimeMessage();
+ MimeMessageHelper message = new MimeMessageHelper(mimeMessage,
+ MimeMessageHelper.MULTIPART_MODE_MIXED);
+ for(String addy : form.getEmailDepositNoticeTo()) {
message.addTo(addy);
}
- message.setSubject("Deposit to " + form.getTitle());
-
+ message.setSubject("Deposit to " + form.getTitle() + " by "+form.getCurrentUser());
message.setFrom(this.getFromAddress());
- message.setText(textsw.toString(), htmlsw.toString());
+ message.setText(textsw.toString() , htmlsw.toString());
this.mailSender.send(mimeMessage);
} catch (MessagingException e) {
LOG.error("problem sending deposit message", e);
View
6 forms/src/main/java/cdr/forms/FormController.java
@@ -168,7 +168,7 @@ public String showForm(@PathVariable String formId, ModelMap modelmap, HttpServl
@RequestMapping(value = "/{formId}.form", method = RequestMethod.POST)
public String processForm(@PathVariable String formId, @Valid @ModelAttribute("form") Form form, BindingResult errors,
- Principal user, @RequestParam("file") MultipartFile file, @RequestParam(value="supplementalFile", required=false) MultipartFile[] supplementalFiles, SessionStatus sessionStatus, HttpServletRequest request) throws PermissionDeniedException {
+ Principal user, @RequestParam(required=false,value="receiptEmailAddress") String receiptEmailAddress, @RequestParam("file") MultipartFile file, @RequestParam(value="supplementalFile", required=false) MultipartFile[] supplementalFiles, SessionStatus sessionStatus, HttpServletRequest request) throws PermissionDeniedException {
SubmittedFile submittedFile;
List<SubmittedFile> supplementalSubmittedFiles;
@@ -232,8 +232,8 @@ public String processForm(@PathVariable String formId, @Valid @ModelAttribute("f
// Otherwise, if the deposit was successful, send a notification
- if (getNotificationHandler() != null)
- getNotificationHandler().notifyDeposit(form, result, user != null ? user.getName() : null);
+ if (getNotificationHandler() != null && receiptEmailAddress != null)
+ getNotificationHandler().notifyDeposit(form, result, receiptEmailAddress, formId);
// Clean up: delete temporary files, clear the session
View
20 forms/src/main/java/cdr/forms/NotificationHandler.java
@@ -4,6 +4,24 @@
public interface NotificationHandler {
- public void notifyDeposit(Form form, DepositResult result, String email);
+ /**
+ * Send notifications for a successful deposit, including receipt if depositorEmail is specified and
+ * notices to those specified in the form itself.
+ * @param form the deposit form
+ * @param result the result object
+ * @param depositorEmail depositor email address or null
+ * @param formId the form id (file name without extension)
+ */
+ public void notifyDeposit(Form form, DepositResult result, String depositorEmail, String formId);
+
+ /**
+ * Send unrecoverable error notification to the administrator.
+ * @param form the deposit form
+ * @param result the result object
+ * @param depositorEmail depositor email address or null
+ * @param formId the form id (file name without extension)
+ */
+ void notifyError(Form form, DepositResult result, String depositorEmail,
+ String formId);
}
View
6 forms/src/main/webapp/WEB-INF/service-context.xml
@@ -65,13 +65,13 @@
</property>
</bean>
- <bean id="emailNotificationHandler" class="cdr.forms.EmailNotificationHandler">
+ <bean id="emailNotificationHandler" class="cdr.forms.EmailNotificationHandler" init-method="init">
<property name="mailSender" ref="javaMailSender"/>
- <property name="urlTemplate"
- value="http://${repository.host}/record?id={0}"/>
<property name="freemarkerConfiguration" ref="freemarkerConfiguration"/>
<property name="administratorAddress" value="${forms.administrator.email}"/>
<property name="fromAddress" value="${forms.from.email}"/>
+ <property name="siteUrl" value="${forms.site.url}"/>
+ <property name="siteName" value="${forms.site.name}"/>
</bean>
<bean id="freemarkerConfiguration" class="freemarker.template.Configuration">
View
120 forms/src/test/java/EmailNotificationTest.java
@@ -0,0 +1,120 @@
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.reset;
+
+import java.util.Date;
+
+import javax.annotation.Resource;
+import javax.mail.internet.MimeMessage;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.springframework.mail.SimpleMailMessage;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import cdr.forms.CachedXMIFormFactory;
+import cdr.forms.DepositResult;
+import cdr.forms.DepositResult.Status;
+import cdr.forms.EmailNotificationHandler;
+import crosswalk.DateInputField;
+import crosswalk.Form;
+import crosswalk.FormElement;
+import crosswalk.InputField;
+import crosswalk.MetadataBlock;
+import crosswalk.TextInputField;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "/email-test-service-context.xml" })
+public class EmailNotificationTest {
+
+ @Resource
+ JavaMailSender javaMailSender = null;
+
+ @Resource
+ EmailNotificationHandler emailNotificationHandler = null;
+
+ @Resource
+ CachedXMIFormFactory formFactory = null;
+
+ public void setMailMock() {
+ // setup mail sender mock invocations
+ reset(this.javaMailSender);
+ when(this.javaMailSender.createMimeMessage()).thenCallRealMethod();
+
+ Answer dumpMessage = new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ Object arg = invocation.getArguments()[0];
+ if (arg instanceof MimeMessage) {
+ MimeMessage m = (MimeMessage) arg;
+ System.out.println("EMAIL DUMP:");
+ m.writeTo(System.out);
+ } else if (arg instanceof SimpleMailMessage) {
+ SimpleMailMessage m = (SimpleMailMessage) arg;
+ System.out.println("EMAIL DUMP:");
+ System.out.println(m.toString());
+ } else {
+ throw new Error("Could not print email: " + arg);
+ }
+ return null;
+ }
+ };
+ doAnswer(dumpMessage).when(this.javaMailSender).send(any(MimeMessage.class));
+ doAnswer(dumpMessage).when(this.javaMailSender).send(any(SimpleMailMessage.class));
+ }
+
+ @Test
+ public void testDepositNotification() {
+ setMailMock();
+ Form form = this.formFactory.getForm("test");
+ fillForm(form);
+ DepositResult result = new DepositResult();
+ result.setAccessURL("http://example.org/the/deposit/url");
+ result.setStatus(Status.PENDING);
+ emailNotificationHandler.notifyDeposit(form, result, "test@example.org", "test");
+ verify(this.javaMailSender, times(2)).send(any(MimeMessage.class));
+ }
+
+ @Test
+ public void testDepositError() {
+ setMailMock();
+ Form form = this.formFactory.getForm("test");
+ fillForm(form);
+ DepositResult result = new DepositResult();
+ result.setAccessURL("http://example.org/the/deposit/url");
+ result.setStatus(Status.FAILED);
+ emailNotificationHandler.notifyError(form, result, "test@example.org", "test");
+ verify(this.javaMailSender, times(1)).send(any(MimeMessage.class));
+ }
+
+ private void fillForm(Form form) {
+ form.setCurrentUser("testuser");
+ for(FormElement el : form.getElements()) {
+ if(el instanceof MetadataBlock) {
+ MetadataBlock mb = (MetadataBlock)el;
+ for(InputField inf : mb.getPorts()) {
+ if(inf instanceof DateInputField) {
+ DateInputField dif = (DateInputField)inf;
+ dif.setEnteredValue(new Date());
+ } else if(inf instanceof TextInputField) {
+ TextInputField tif = (TextInputField)inf;
+ String val = "Test"+ tif.getLabel();
+ if(tif.getMaxCharacters() != null && val.length() > tif.getMaxCharacters()) {
+ val.subSequence(0, tif.getMaxCharacters());
+ }
+ tif.setEnteredValue(val);
+ }
+ }
+ }
+ }
+ }
+
+}
View
46 forms/src/test/resources/DepositErrorHtml.ftl
@@ -0,0 +1,46 @@
+<#--
+
+ Copyright 2008 The University of North Carolina at Chapel Hill
+
+ Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<html>
+<head>
+ <title>
+ <p>An unrecoverable error occurred on ${form.title} at ${receivedDate?datetime}.</p>
+ </title>
+</head>
+<body>
+ <img style="float: right;" alt="UNC Libraries logo" src="${siteUrl}/static/images/email_logo.png"/>
+ <h3>${siteName}</h3>
+ <p>An unrecoverable error occurred on ${form.title} at ${receivedDate?datetime}.
+ Please do not reply to this message.
+ <p>The following information was entered on <a href="${siteUrl}/forms/${formId}.form">${form.title}</a>:
+ <ul>
+ <li>Depositor Username: ${form.currentUser}</li>
+ <li>Depositor Email: ${depositorEmail!"not available"}</li>
+ <#list form.elements as element>
+ <#if element.ports??>
+ <#list element.ports as input>
+ <#attempt>
+ <li>${input.label}: ${input.enteredValue}</li>
+ <#recover>
+ <li>${input.label}: ${input.enteredValue?datetime}</li>
+ </#attempt>
+ </#list>
+ </#if>
+ </#list>
+ </ul></p>
+</body>
+</html>
View
33 forms/src/test/resources/DepositErrorText.ftl
@@ -0,0 +1,33 @@
+<#--
+
+ Copyright 2008 The University of North Carolina at Chapel Hill
+
+ Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+An unrecoverable error occurred on ${form.title} at ${receivedDate?datetime}.
+Please do not reply to this message.
+The following information was entered on ${siteUrl}/forms/${formId}.form
+ * Depositor Username: ${form.currentUser}
+ * Depositor Email: ${depositorEmail!"not available"}
+ <#list form.elements as element>
+ <#if element.ports??>
+ <#list element.ports as input>
+ <#attempt>
+ * ${input.label}: ${input.enteredValue}
+ <#recover>
+ * ${input.label}: ${input.enteredValue?datetime}
+ </#attempt>
+ </#list>
+ </#if>
+ </#list>
View
46 forms/src/test/resources/DepositNoticeHtml.ftl
@@ -0,0 +1,46 @@
+<#--
+
+ Copyright 2008 The University of North Carolina at Chapel Hill
+
+ Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<html>
+<head>
+ <title>
+ <p>A submission was received by ${form.title} at ${receivedDate?datetime}.</p>
+ </title>
+</head>
+<body>
+ <img style="float: right;" alt="UNC Libraries logo" src="${siteUrl}/static/images/email_logo.png"/>
+ <h3>${siteName}</h3>
+ <p>A submission was received by ${form.title} at ${receivedDate?datetime}.
+ Please do not reply to this message.
+ <p>The following information was entered on <a href="${siteUrl}/forms/${formId}.form">${form.title}</a>:
+ <ul>
+ <li>User: ${form.currentUser}</li>
+ <#list form.elements as element>
+ <#if element.ports??>
+ <#list element.ports as input>
+ <#attempt>
+ <li>${input.label}: ${input.enteredValue}</li>
+ <#recover>
+ <li>${input.label}: ${input.enteredValue?datetime}</li>
+ </#attempt>
+ </#list>
+ </#if>
+ </#list>
+ </ul></p>
+ <p>Thank you for contributing to the <a href="${siteUrl}">${siteName}</a>, a service of the <a href="http://www.lib.unc.edu/">University of North Carolina at Chapel Hill Libraries</a>.</p>
+</body>
+</html>
View
39 forms/src/test/resources/DepositNoticeText.ftl
@@ -0,0 +1,39 @@
+<#--
+
+ Copyright 2008 The University of North Carolina at Chapel Hill
+
+ Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+A submission was received by ${form.title} at ${receivedDate?datetime}.
+
+Please do not reply to this message.
+
+The following information was entered on ${form.title} at ${siteUrl}/forms/${formId}.form:
+ * User: ${form.currentUser}
+ <#list form.elements as element>
+ <#if element.ports??>
+ <#list element.ports as input>
+ <#attempt>
+ * ${input.label}: ${input.enteredValue}
+ <#recover>
+ * ${input.label}: ${input.enteredValue?datetime}
+ </#attempt>
+ </#list>
+ </#if>
+ </#list>
+
+Thank you for contributing to the ${siteName}, a service of the University of North Carolina at Chapel Hill Libraries.
+
+ Carolina Digital Repository: ${siteUrl}
+ UNC Chapel Hill Libraries: http://www.lib.unc.edu/
View
48 forms/src/test/resources/DepositReceiptHtml.ftl
@@ -0,0 +1,48 @@
+<#--
+
+ Copyright 2008 The University of North Carolina at Chapel Hill
+
+ Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<html>
+<head>
+ <title>
+ <p>Your submission was received by the ${siteName} at ${receivedDate?datetime}.</p>
+ </title>
+</head>
+<body>
+ <img style="float: right;" alt="UNC Libraries logo" src="${siteUrl}/static/images/email_logo.png"/>
+ <h3>${siteName}</h3>
+ <p>Your submission was received by the ${siteName} at ${receivedDate?datetime}.
+ Please do not reply to this message.
+ <#if form.contactEmail??>If you have any questions or concerns about your submission,
+ please contact ${form.contactName!}: ${form.contactEmail}</#if></p>
+ <p>You entered the following information on <a href="${siteUrl}/forms/${formId}.form">${form.title}</a>:
+ <ul>
+ <li>User: ${form.currentUser}</li>
+ <#list form.elements as element>
+ <#if element.ports??>
+ <#list element.ports as input>
+ <#attempt>
+ <li>${input.label}: ${input.enteredValue}</li>
+ <#recover>
+ <li>${input.label}: ${input.enteredValue?datetime}</li>
+ </#attempt>
+ </#list>
+ </#if>
+ </#list>
+ </ul></p>
+ <p>Thank you for contributing to the <a href="${siteUrl}">${siteName}</a>, a service of the <a href="http://www.lib.unc.edu/">University of North Carolina at Chapel Hill Libraries</a>.</p>
+</body>
+</html>
View
39 forms/src/test/resources/DepositReceiptText.ftl
@@ -0,0 +1,39 @@
+<#--
+
+ Copyright 2008 The University of North Carolina at Chapel Hill
+
+ Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+Your submission was received by the ${siteName} at ${receivedDate?datetime}.
+
+Please do not reply to this message.<#if form.contactEmail??> If you have any questions or concerns about your submission, please contact ${form.contactName!}: ${form.contactEmail}</#if>
+
+You entered the following information on ${form.title} at ${siteUrl}/forms/${formId}.form:
+ * User: ${form.currentUser}
+ <#list form.elements as element>
+ <#if element.ports??>
+ <#list element.ports as input>
+ <#attempt>
+ * ${input.label}: ${input.enteredValue}
+ <#recover>
+ * ${input.label}: ${input.enteredValue?datetime}
+ </#attempt>
+ </#list>
+ </#if>
+ </#list>
+
+Thank you for contributing to the ${siteName}, a service of the University of North Carolina at Chapel Hill Libraries.
+
+ Carolina Digital Repository: ${siteUrl}
+ UNC Chapel Hill Libraries: http://www.lib.unc.edu/
View
71 forms/src/test/resources/email-test-service-context.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2008 The University of North Carolina at Chapel Hill Licensed
+ under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the License
+ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the specific language
+ governing permissions and limitations under the License. -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jms="http://www.springframework.org/schema/jms"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+
+ <bean name="propertiesURI" class="java.lang.System"
+ factory-method="getProperty">
+ <constructor-arg index="0" value="server.properties.uri" />
+ <!-- property name for properties URI location -->
+ <constructor-arg index="1" value="classpath:server.properties" />
+ <!-- default location for testing -->
+ </bean>
+ <bean id="serverProperties"
+ class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="locations">
+ <list>
+ <ref bean="propertiesURI" />
+ </list>
+ </property>
+ <property name="ignoreResourceNotFound" value="false" />
+ </bean>
+
+ <bean id="formFactory" class="cdr.forms.CachedXMIFormFactory">
+ <property name="formPath" value="${forms.dir}" />
+ </bean>
+
+ <bean id="emailNotificationHandler" class="cdr.forms.EmailNotificationHandler" init-method="init">
+ <property name="mailSender" ref="javaMailSender"/>
+ <property name="freemarkerConfiguration" ref="freemarkerConfiguration"/>
+ <property name="administratorAddress" value="${forms.administrator.email}"/>
+ <property name="fromAddress" value="${forms.from.email}"/>
+ <property name="siteUrl" value="${forms.site.url}"/>
+ <property name="siteName" value="${forms.site.name}"/>
+ </bean>
+
+ <bean id="freemarkerConfiguration" class="freemarker.template.Configuration">
+ <property name="templateLoader">
+ <bean class="freemarker.cache.FileTemplateLoader">
+ <constructor-arg index="0" type="java.io.File">
+ <bean class="java.io.File">
+ <constructor-arg value="${forms.email.template.dir}" />
+ </bean>
+ </constructor-arg>
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="javaMailSender" class="org.mockito.Mockito" factory-method="spy">
+ <constructor-arg ref="realJavaMailSender"/>
+ </bean>
+
+ <bean id="realJavaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
+ <property name="host" value="${smtp.host}"/>
+ <property name="port" value="${smtp.port}"/>
+ <property name="defaultEncoding" value="UTF-8"/>
+ </bean>
+
+</beans>
View
28 forms/src/test/resources/log4j.properties
@@ -0,0 +1,28 @@
+#
+# Copyright 2008 The University of North Carolina at Chapel Hill
+#
+# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Root logger set to DEBUG, but SERVER.Threshold blocks below WARN
+log4j.rootLogger=DEBUG, SERVER
+
+# The SERVER and CDRSERVICES appenders are inherited from the root logger
+log4j.logger.org.apache.commons.httpclient=WARN
+log4j.logger.httpclient=WARN
+
+# Server level log to standard output ("catalina.out").
+log4j.appender.SERVER=org.apache.log4j.ConsoleAppender
+log4j.appender.SERVER.Threshold=DEBUG
+log4j.appender.SERVER.layout=org.apache.log4j.PatternLayout
+log4j.appender.SERVER.layout.ConversionPattern=%d %-5p [%t] %c - %m%n
View
23 forms/src/test/resources/server.properties
@@ -0,0 +1,23 @@
+# SERVER PROPERTIES CONFIGURATION
+
+# SMTP Mail Server (localhost, 25)
+smtp.host=localhost
+smtp.port=25
+
+# Deposit Forms
+forms.dir=src/test/resources
+forms.default.container.pid=uuid:your-pid-here
+forms.sword.username=depositforms
+forms.sword.password=depositformspassword
+forms.email.template.dir=src/test/resources
+forms.administrator.email=support@example.org
+forms.from.email=no-reply@example.org
+forms.site.name=My Institutional Repository
+forms.site.url=https://repository.example.org
+
+#sword properties
+sword.context=sword
+sword.version=1.3
+sword.depositorNamespace=unc:app:lib:cdr:depositor:
+sword.username=foo
+sword.password=bar
Please sign in to comment.
Something went wrong with that request. Please try again.