Coverage Report - org.kuali.rice.kew.mail.service.impl.StyleableEmailContentServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
StyleableEmailContentServiceImpl
0%
0/222
0%
0/40
2.857
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 package org.kuali.rice.kew.mail.service.impl;
 19  
 
 20  
 import java.io.StringWriter;
 21  
 import java.sql.Timestamp;
 22  
 import java.util.Collection;
 23  
 
 24  
 import javax.xml.parsers.DocumentBuilder;
 25  
 import javax.xml.parsers.DocumentBuilderFactory;
 26  
 import javax.xml.parsers.ParserConfigurationException;
 27  
 import javax.xml.transform.Templates;
 28  
 import javax.xml.transform.TransformerConfigurationException;
 29  
 import javax.xml.transform.TransformerException;
 30  
 import javax.xml.transform.TransformerFactory;
 31  
 import javax.xml.transform.dom.DOMSource;
 32  
 import javax.xml.transform.stream.StreamResult;
 33  
 import javax.xml.transform.stream.StreamSource;
 34  
 
 35  
 import org.apache.commons.lang.StringUtils;
 36  
 import org.apache.log4j.Logger;
 37  
 import org.kuali.rice.core.util.RiceConstants;
 38  
 import org.kuali.rice.kew.actionitem.ActionItem;
 39  
 import org.kuali.rice.kew.doctype.bo.DocumentType;
 40  
 import org.kuali.rice.kew.edl.service.StyleService;
 41  
 import org.kuali.rice.kew.exception.WorkflowRuntimeException;
 42  
 import org.kuali.rice.kew.feedback.web.FeedbackForm;
 43  
 import org.kuali.rice.kew.mail.CustomEmailAttribute;
 44  
 import org.kuali.rice.kew.mail.EmailContent;
 45  
 import org.kuali.rice.kew.mail.EmailStyleHelper;
 46  
 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
 47  
 import org.kuali.rice.kew.user.UserUtils;
 48  
 import org.kuali.rice.kew.util.KEWConstants;
 49  
 import org.kuali.rice.kew.util.Utilities;
 50  
 import org.kuali.rice.kew.util.XmlHelper;
 51  
 import org.kuali.rice.kew.web.session.UserSession;
 52  
 import org.kuali.rice.kim.bo.Person;
 53  
 import org.kuali.rice.kim.bo.entity.KimPrincipal;
 54  
 import org.kuali.rice.kim.service.KIMServiceLocator;
 55  
 import org.springframework.core.io.DefaultResourceLoader;
 56  
 import org.w3c.dom.Document;
 57  
 import org.w3c.dom.Element;
 58  
 import org.w3c.dom.Node;
 59  
 
 60  
 
 61  
 
 62  
 /**
 63  
  * EmailContentService that serves EmailContent customizable via XSLT style sheets
 64  
  * The global email style name is: kew.email.style
 65  
  * If this style is not found, the resource 'defaultEmailStyle.xsl' will be retrieved
 66  
  * relative to this class.
 67  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 68  
  */
 69  0
 public class StyleableEmailContentServiceImpl extends BaseEmailContentServiceImpl {
 70  0
     private static final Logger LOG = Logger.getLogger(StyleableEmailContentServiceImpl.class);
 71  
 
 72  0
     protected final String DEFAULT_EMAIL_STYLESHEET_RESOURCE_LOC = "defaultEmailStyle.xsl";
 73  
 
 74  
     protected StyleService styleService;
 75  0
     protected EmailStyleHelper styleHelper = new EmailStyleHelper();
 76  0
     protected String globalEmailStyleSheet = KEWConstants.EMAIL_STYLESHEET_NAME;
 77  
 
 78  
 
 79  
     public void setStyleService(StyleService styleService) {
 80  0
         this.styleService = styleService;
 81  0
     }
 82  
 
 83  
     public void setGlobalEmailStyleSheet(String globalEmailStyleSheet) {
 84  0
         this.globalEmailStyleSheet = globalEmailStyleSheet;
 85  0
     }
 86  
 
 87  
     protected static DocumentBuilder getDocumentBuilder(boolean coalesce) {
 88  
         try {
 89  0
             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
 90  0
             dbf.setCoalescing(coalesce);
 91  0
             return dbf.newDocumentBuilder();
 92  0
         } catch (ParserConfigurationException e) {
 93  0
             String message = "Error constructing document builder";
 94  0
             LOG.error(message, e);
 95  0
             throw new WorkflowRuntimeException(message, e);
 96  
         }
 97  
     }
 98  
 
 99  
     protected static void addObjectXML(Document doc, Object o, Node node, String name) throws Exception {
 100  0
         Element element = XmlHelper.propertiesToXml(doc, o, name);
 101  
 
 102  0
         if (LOG.isDebugEnabled()) {
 103  0
             LOG.debug(XmlHelper.jotNode(element));
 104  
         }
 105  
 
 106  0
         if (node == null) {
 107  0
             node = doc;
 108  
         }
 109  
 
 110  0
         node.appendChild(element);
 111  0
     }
 112  
 
 113  
     protected static void addTextElement(Document doc, Element baseElement, String elementName, Object elementData) {
 114  0
         Element element = doc.createElement(elementName);
 115  0
         element.appendChild(doc.createTextNode(elementData.toString()));
 116  0
         baseElement.appendChild(element);
 117  0
     }
 118  
 
 119  
     protected static void addCDataElement(Document doc, Element baseElement, String elementName, Object elementData) {
 120  0
         Element element = doc.createElement(elementName);
 121  0
         String dataValue = "";
 122  0
         if (elementData != null) {
 123  0
             dataValue = elementData.toString();
 124  
         }
 125  0
         element.appendChild(doc.createCDATASection(dataValue));
 126  0
         baseElement.appendChild(element);
 127  0
     }
 128  
 
 129  
     protected static void addTimestampElement(Document doc, Element baseElement, String elementName, Timestamp elementData) {
 130  0
         addTextElement(doc, baseElement, elementName, RiceConstants.getDefaultDateFormat().format(elementData));
 131  0
     }
 132  
 
 133  
     protected static void addDelegatorElement(Document doc, Element baseElement, ActionItem actionItem) {
 134  0
         Element delegatorElement = doc.createElement("delegator");
 135  0
         if ( (actionItem.getDelegatorWorkflowId() != null) && (actionItem.getDelegatorWorkflowId() != null) ) {
 136  
             // add empty delegator element
 137  0
             baseElement.appendChild(delegatorElement);
 138  0
             return;
 139  
         }
 140  0
         String delegatorType = "";
 141  0
         String delegatorId = "";
 142  0
         String delegatorDisplayValue = "";
 143  0
         if (actionItem.getDelegatorWorkflowId() != null) {
 144  0
             delegatorType = "user";
 145  0
             delegatorId = actionItem.getDelegatorWorkflowId();
 146  0
             KimPrincipal delegator = KIMServiceLocator.getIdentityService().getPrincipal(delegatorId);
 147  0
             if (delegator == null) {
 148  0
                     LOG.error("Cannot find user for id " + delegatorId);
 149  0
                     delegatorDisplayValue = "USER NOT FOUND";
 150  
             } else {
 151  0
                     delegatorDisplayValue = UserUtils.getTransposedName(UserSession.getAuthenticatedUser(), delegator);
 152  
             }
 153  0
         } else if (actionItem.getDelegatorWorkflowId() != null) {
 154  0
             delegatorType = "workgroup";
 155  0
             delegatorId = actionItem.getDelegatorGroupId().toString();
 156  0
             delegatorDisplayValue = KIMServiceLocator.getIdentityManagementService().getGroup(actionItem.getDelegatorGroupId()).getGroupName();
 157  
         }
 158  0
         delegatorElement.setAttribute("type", delegatorType);
 159  
         // add the id element
 160  0
         Element idElement = doc.createElement("id");
 161  0
         idElement.appendChild(doc.createTextNode(delegatorId));
 162  0
         delegatorElement.appendChild(idElement);
 163  
         // add the display value element
 164  0
         Element displayValElement = doc.createElement("displayValue");
 165  0
         displayValElement.appendChild(doc.createTextNode(delegatorDisplayValue));
 166  0
         delegatorElement.appendChild(displayValElement);
 167  0
         baseElement.appendChild(delegatorElement);
 168  0
     }
 169  
 
 170  
     protected static void addWorkgroupRequestElement(Document doc, Element baseElement, ActionItem actionItem) {
 171  0
         Element workgroupElement = doc.createElement("workgroupRequest");
 172  0
         if (actionItem.isWorkgroupItem()) {
 173  
             // add the id element
 174  0
             Element idElement = doc.createElement("id");
 175  0
             idElement.appendChild(doc.createTextNode(actionItem.getGroupId()));
 176  0
             workgroupElement.appendChild(idElement);
 177  
             // add the display value element
 178  0
             Element displayValElement = doc.createElement("displayValue");
 179  0
             displayValElement.appendChild(doc.createTextNode(actionItem.getGroupId()));
 180  0
             workgroupElement.appendChild(displayValElement);
 181  
         }
 182  0
         baseElement.appendChild(workgroupElement);
 183  0
     }
 184  
 
 185  
     /**
 186  
      * This method is used to add the given {@link ActionItem} to the given {@link org.w3c.dom.Document} in a summarized
 187  
      * form for use in weekly or daily type reminder e-mails.
 188  
      *
 189  
      * @param doc - Document to have the ActionItem added to
 190  
      * @param actionItem - the action item being added
 191  
      * @param user - the current user
 192  
      * @param node - the node object to add the actionItem XML to (defaults to the doc variable if null is passed in)
 193  
      * @throws Exception
 194  
      */
 195  
     protected void addSummarizedActionItem(Document doc, ActionItem actionItem, Person user, Node node) throws Exception {
 196  0
         if (node == null) {
 197  0
             node = doc;
 198  
         }
 199  
 
 200  0
         Element root = doc.createElement("summarizedActionItem");
 201  
 
 202  
         // add in all items from action list as preliminary default dataset
 203  0
         addTextElement(doc, root, "routeHeaderId", actionItem.getRouteHeaderId());
 204  0
         addTextElement(doc, root, "docName", actionItem.getDocName());
 205  0
         addCDataElement(doc, root, "docLabel", actionItem.getDocLabel());
 206  0
         addCDataElement(doc, root, "docTitle", actionItem.getDocTitle());
 207  0
         DocumentRouteHeaderValue routeHeader = getRouteHeader(actionItem);
 208  0
         addTextElement(doc, root, "docRouteStatus", routeHeader.getDocRouteStatus());
 209  0
         addCDataElement(doc, root, "routeStatusLabel", routeHeader.getRouteStatusLabel());
 210  0
         addTextElement(doc, root, "actionRequestCd", actionItem.getActionRequestCd());
 211  0
         addTextElement(doc, root, "actionRequestLabel", actionItem.getActionRequestLabel());
 212  0
         addDelegatorElement(doc, root, actionItem);
 213  0
         addTimestampElement(doc, root, "createDate", routeHeader.getCreateDate());
 214  0
         addWorkgroupRequestElement(doc, root, actionItem);
 215  0
         addTimestampElement(doc, root, "dateAssigned", actionItem.getDateAssigned());
 216  
 
 217  0
         node.appendChild(root);
 218  0
     }
 219  
 
 220  
     public DocumentRouteHeaderValue getRouteHeader(ActionItem actionItem) {
 221  0
         return actionItem.getRouteHeader();
 222  
     }
 223  
 
 224  
     protected static String transform(Templates style, Document doc) {
 225  0
         StringWriter writer = new StringWriter();
 226  0
         StreamResult result = new StreamResult(writer);
 227  
 
 228  
         try {
 229  0
             style.newTransformer().transform(new DOMSource(doc), result);
 230  0
             return writer.toString();
 231  0
         } catch (TransformerException te) {
 232  0
             String message = "Error transforming DOM";
 233  0
             LOG.error(message, te);
 234  0
             throw new WorkflowRuntimeException(message, te);
 235  
         }
 236  
     }
 237  
 
 238  
     /**
 239  
      * This method retrieves the style from the system using the given name. If none is found the default style xsl file
 240  
      * defined by {@link #DEFAULT_EMAIL_STYLESHEET_RESOURCE_LOC} is used.
 241  
      *
 242  
      * @param styleName
 243  
      * @return a valid {@link javax.xml.transform.Templates} using either the given styleName or the default xsl style file
 244  
      */
 245  
     protected Templates getStyle(String styleName) {
 246  0
         Templates style = null;
 247  
         try {
 248  0
             style = styleService.getStyleAsTranslet(styleName);
 249  0
         } catch (TransformerConfigurationException tce) {
 250  0
             String message = "Error obtaining style '" + styleName + "', using default";
 251  0
             LOG.error(message, tce);
 252  
             // throw new WorkflowRuntimeException("Error obtaining style '" + styleName + "'", tce);
 253  0
         }
 254  
 
 255  0
         if (style == null) {
 256  0
             LOG.warn("Could not find specified style, " + styleName + ", using default");
 257  
             try {
 258  
 
 259  0
                 style = TransformerFactory.newInstance().newTemplates(new StreamSource(new DefaultResourceLoader().getResource("classpath:org/kuali/rice/kew/mail/" + DEFAULT_EMAIL_STYLESHEET_RESOURCE_LOC).getInputStream()));
 260  0
             } catch (Exception tce) {
 261  0
                 String message = "Error obtaining default style from resource: " + DEFAULT_EMAIL_STYLESHEET_RESOURCE_LOC;
 262  0
                 LOG.error(message, tce);
 263  0
                 throw new WorkflowRuntimeException("Error obtaining style '" + styleName + "'", tce);
 264  0
             }
 265  
         }
 266  0
         return style;
 267  
     }
 268  
 
 269  
     protected EmailContent generateEmailContent(String styleName, Document doc) {
 270  0
         Templates style = getStyle(styleName);
 271  0
         return styleHelper.generateEmailContent(style, doc);
 272  
     }
 273  
 
 274  
     protected EmailContent generateReminderForActionItems(Person user, Collection<ActionItem> actionItems, String name, String style) {
 275  0
         DocumentBuilder db = getDocumentBuilder(false);
 276  0
         Document doc = db.newDocument();
 277  0
         Element element = doc.createElement(name);
 278  0
         setStandardAttributes(element);
 279  0
         doc.appendChild(element);
 280  
 
 281  
         try {
 282  0
             addObjectXML(doc, user, element, "user");
 283  0
             for (ActionItem actionItem: actionItems) {
 284  
                 try {
 285  0
                     addSummarizedActionItem(doc, actionItem, user, element);
 286  0
                 } catch (Exception e) {
 287  0
                     String message = "Error generating XML for action item: " + actionItem;
 288  0
                     LOG.error(message, e);
 289  0
                     throw new WorkflowRuntimeException(e);
 290  0
                 }
 291  
             }
 292  
 
 293  0
         } catch (Exception e) {
 294  0
             String message = "Error generating XML for action items: " + actionItems;
 295  0
             LOG.error(message, e);
 296  0
             throw new WorkflowRuntimeException(e);
 297  0
         }
 298  
 
 299  0
         return generateEmailContent(style, doc);
 300  
     }
 301  
 
 302  
     protected void setStandardAttributes(Element e) {
 303  0
         e.setAttribute("env", getDeploymentEnvironment());
 304  0
         e.setAttribute("applicationEmailAddress", getApplicationEmailAddress());
 305  0
         e.setAttribute("actionListUrl", getActionListUrl());
 306  0
         e.setAttribute("preferencesUrl", getPreferencesUrl());
 307  0
     }
 308  
 
 309  
     /**
 310  
      * This method generates an {@link EmailContent} object using the given parameters.  Part of this operation includes
 311  
      * serializing the given {@link ActionItem} to XML. The following objects and methods are included in the serialization:
 312  
      *
 313  
      * <ul>
 314  
      * <li>{@link Person}</li>
 315  
      * <li>{@link Person#getAuthenticationUserId()}</li>
 316  
      * <li>{@link DocumentRouteHeaderValue}</li>
 317  
      * <li>{@link DocumentRouteHeaderValue#getInitiatorUser()}</li>
 318  
      * <li>{@link DocumentRouteHeaderValue#getDocumentType()}</li>
 319  
      * <li>{@link Person}</li>
 320  
      * </ul>
 321  
      *
 322  
      * @param user - the current user
 323  
      * @param actionItem - the action item being added
 324  
      * @param documentType - the document type that the custom email style sheet will come from
 325  
      * @param node - the node object to add the actionItem XML to (defaults to the doc variable if null is passed in)
 326  
      * @throws Exception
 327  
      */
 328  
     public EmailContent generateImmediateReminder(Person user, ActionItem actionItem, DocumentType documentType) {
 329  
             
 330  0
             LOG.info("Starting generation of immediate email reminder...");
 331  0
             LOG.info("Action Id: " + actionItem.getActionItemId() + 
 332  
                              ";  ActionRequestId: " + actionItem.getActionRequestId() + 
 333  
                              ";  Action Item Principal Name: " + actionItem.getPerson().getPrincipalName());
 334  0
             LOG.info("User Principal Name: " + user.getPrincipalName());
 335  
         // change style name based on documentType when configurable email style on document is implemented...
 336  0
         String styleSheet = documentType.getCustomEmailStylesheet();
 337  0
         LOG.debug(documentType.getName() + " style: " + styleSheet);
 338  0
         if (styleSheet == null) {
 339  0
             styleSheet = globalEmailStyleSheet;
 340  
         }
 341  
 
 342  0
         LOG.info("generateImmediateReminder using style sheet: "+ styleSheet + " for Document Type " + documentType.getName());
 343  
 //        return generateReminderForActionItems(user, actionItems, "immediateReminder", styleSheet);
 344  0
         DocumentBuilder db = getDocumentBuilder(false);
 345  0
         Document doc = db.newDocument();
 346  0
         Element element = doc.createElement("immediateReminder");
 347  0
         setStandardAttributes(element);
 348  0
         doc.appendChild(element);
 349  
 
 350  
         try {
 351  0
             addObjectXML(doc, user, element, "user");
 352  
 //            addActionItem(doc, actionItem, user, node);
 353  0
             Node node = (Node) element;
 354  0
             if (node == null) {
 355  0
                 node = doc;
 356  
             }
 357  
 
 358  0
             Element root = doc.createElement("actionItem");
 359  
             // append the custom body and subject if they exist
 360  
             try {
 361  0
                 CustomEmailAttribute customEmailAttribute = getCustomEmailAttribute(user, actionItem);
 362  0
                 if (customEmailAttribute != null) {
 363  0
                     String customBody = customEmailAttribute.getCustomEmailBody();
 364  0
                     if (!Utilities.isEmpty(customBody)) {
 365  0
                         Element bodyElement = doc.createElement("customBody");
 366  0
                         bodyElement.appendChild(doc.createTextNode(customBody));
 367  0
                         root.appendChild(bodyElement);
 368  
                     }
 369  0
                     String customEmailSubject = customEmailAttribute.getCustomEmailSubject();
 370  0
                     if (!Utilities.isEmpty(customEmailSubject)) {
 371  0
                         Element subjectElement = doc.createElement("customSubject");
 372  0
                         subjectElement.appendChild(doc.createTextNode(customEmailSubject));
 373  0
                         root.appendChild(subjectElement);
 374  
                     }
 375  
                 }
 376  0
             } catch (Exception e) {
 377  0
                 LOG.error("Error when checking for custom email body and subject.", e);
 378  0
             }
 379  0
             Person person = actionItem.getPerson();
 380  0
             DocumentRouteHeaderValue header = actionItem.getRouteHeader();
 381  
             // keep adding stuff until we have all the xml we need to formulate the message :/
 382  0
             addObjectXML(doc, actionItem, root, "actionItem");
 383  0
             addObjectXML(doc, person, root, "actionItemPerson");
 384  0
             addTextElement(doc, root, "actionItemPrincipalId", person.getPrincipalId());
 385  0
             addTextElement(doc, root, "actionItemPrincipalName", person.getPrincipalName());
 386  0
             addDocumentHeaderXML(doc, header, root, "doc");
 387  0
             addObjectXML(doc, header.getInitiatorPrincipal(), root, "docInitiator");
 388  0
             addTextElement(doc, root, "docInitiatorDisplayName", header.getInitiatorDisplayName());
 389  0
             addObjectXML(doc, header.getDocumentType(), root, "documentType");
 390  
 
 391  0
             node.appendChild(root);
 392  0
         } catch (Exception e) {
 393  0
             String message = "Error generating immediate reminder XML for action item: " + actionItem;
 394  0
             LOG.error(message, e);
 395  0
             throw new WorkflowRuntimeException(e);
 396  0
         }
 397  0
         LOG.info("Leaving generation of immeidate email reminder...");
 398  
             /**
 399  
              * End IU customization
 400  
              */
 401  0
         return generateEmailContent(styleSheet, doc);
 402  
     }
 403  
     
 404  
     /**
 405  
      * This method handles converting the DocumentRouteHeaderValue into an XML representation.  The reason we can't just use
 406  
      * propertiesToXml like we have elsewhere is because the doc header has a String attached to it that has the XML document
 407  
      * content in it.  The default serialization of this will serialize this as a String so we will end up with escaped XML
 408  
      * in our output which we won't be able to process with the email stylesheet.  So we need to read the xml content from
 409  
      * the document and parse it into a DOM object so it can be appended to our output.
 410  
      */
 411  
     protected void addDocumentHeaderXML(Document document, DocumentRouteHeaderValue documentHeader, Node node, String elementName) throws Exception {
 412  0
             Element element = XmlHelper.propertiesToXml(document, documentHeader, elementName);
 413  
             // now we need to "fix" the xml document content because it's going to be in there as escaped XML
 414  0
             Element docContentElement = (Element)element.getElementsByTagName("docContent").item(0);
 415  0
             String documentContent = docContentElement.getTextContent();
 416  
             
 417  0
             if (!StringUtils.isBlank(documentContent) && documentContent.startsWith("<")) {
 418  0
                     Document documentContentXML = XmlHelper.readXml(documentContent);
 419  0
                     Element documentContentElement = documentContentXML.getDocumentElement();
 420  0
                     documentContentElement = (Element)document.importNode(documentContentElement, true);
 421  
             
 422  
                     // remove the old, bad text content
 423  0
                     docContentElement.removeChild(docContentElement.getFirstChild());
 424  
             
 425  
                     // replace with actual XML
 426  0
                     docContentElement.appendChild(documentContentElement);
 427  0
             } else {
 428  
                     // in this case it means that the XML is encrypted, unfortunately, we have no way to decrypt it since
 429  
                     // the key is stored in the client application.  We will just include the doc content since none of our
 430  
                     // current IU clients will be using this feature right away
 431  
 
 432  
                     // remove the old, bad text content
 433  0
                     docContentElement.removeChild(docContentElement.getFirstChild());
 434  
             }
 435  
             
 436  0
             if (LOG.isDebugEnabled()) {
 437  0
             LOG.debug(XmlHelper.jotNode(element));
 438  
         }
 439  
 
 440  0
         node.appendChild(element);
 441  0
     }
 442  
 
 443  
     public EmailContent generateWeeklyReminder(Person user, Collection<ActionItem> actionItems) {
 444  0
         return generateReminderForActionItems(user, actionItems, "weeklyReminder", globalEmailStyleSheet);
 445  
     }
 446  
 
 447  
     public EmailContent generateDailyReminder(Person user, Collection<ActionItem> actionItems) {
 448  0
         return generateReminderForActionItems(user, actionItems, "dailyReminder", globalEmailStyleSheet);
 449  
     }
 450  
 
 451  
     public EmailContent generateFeedback(FeedbackForm form) {
 452  0
         DocumentBuilder db = getDocumentBuilder(true);
 453  0
         Document doc = db.newDocument();
 454  0
         String styleSheet = globalEmailStyleSheet;
 455  
 
 456  
         // if the doc type is specified, see if that doc has a custom email stylesheet and use it
 457  
         // NOTE: do we need to do this for feedback? presumably feedback will be going back to admins
 458  
         /*String docTypeName = form.getDocumentType();
 459  
         if (!StringUtils.isBlank(docTypeName)) {
 460  
             DocumentType docType = KEWServiceLocator.getDocumentTypeService().findByName(docTypeName);
 461  
             if (docType == null) {
 462  
                 LOG.error("User specified document type '" + docTypeName + "' in feedback form, but the document type was not found in the system");
 463  
             } else {
 464  
                 if (docType.getCustomEmailStylesheet() != null) {
 465  
                     styleSheet = docType.getCustomEmailStylesheet();
 466  
                 }
 467  
             }
 468  
         }*/
 469  0
         LOG.info("form: " + form.getRouteHeaderId());
 470  
         try {
 471  0
             addObjectXML(doc, form, null, "feedback");
 472  0
         } catch (Exception e) {
 473  0
             String message = "Error generating XML for feedback form: " + form;
 474  0
             LOG.error(message, e);
 475  0
             throw new WorkflowRuntimeException(message, e);
 476  0
         }
 477  0
         setStandardAttributes(doc.getDocumentElement());
 478  
 
 479  0
         return generateEmailContent(styleSheet, doc);
 480  
     }
 481  
 }