| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 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 | |
import java.util.Map; |
| 24 | |
|
| 25 | |
import javax.xml.parsers.DocumentBuilder; |
| 26 | |
import javax.xml.parsers.DocumentBuilderFactory; |
| 27 | |
import javax.xml.parsers.ParserConfigurationException; |
| 28 | |
import javax.xml.transform.Templates; |
| 29 | |
import javax.xml.transform.TransformerConfigurationException; |
| 30 | |
import javax.xml.transform.TransformerException; |
| 31 | |
import javax.xml.transform.TransformerFactory; |
| 32 | |
import javax.xml.transform.dom.DOMSource; |
| 33 | |
import javax.xml.transform.stream.StreamResult; |
| 34 | |
import javax.xml.transform.stream.StreamSource; |
| 35 | |
|
| 36 | |
import org.apache.commons.lang.StringUtils; |
| 37 | |
import org.apache.log4j.Logger; |
| 38 | |
import org.kuali.rice.core.api.style.StyleService; |
| 39 | |
import org.kuali.rice.core.mail.EmailContent; |
| 40 | |
import org.kuali.rice.core.util.RiceConstants; |
| 41 | |
import org.kuali.rice.core.util.xml.XmlHelper; |
| 42 | |
import org.kuali.rice.core.util.xml.XmlJotter; |
| 43 | |
import org.kuali.rice.kew.actionitem.ActionItem; |
| 44 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
| 45 | |
import org.kuali.rice.kew.exception.WorkflowRuntimeException; |
| 46 | |
import org.kuali.rice.kew.feedback.web.FeedbackForm; |
| 47 | |
import org.kuali.rice.kew.mail.CustomEmailAttribute; |
| 48 | |
import org.kuali.rice.kew.mail.EmailStyleHelper; |
| 49 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
| 50 | |
import org.kuali.rice.kew.routeheader.service.RouteHeaderService; |
| 51 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 52 | |
import org.kuali.rice.kew.user.UserUtils; |
| 53 | |
import org.kuali.rice.kew.util.KEWConstants; |
| 54 | |
import org.kuali.rice.kim.api.entity.principal.Principal; |
| 55 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
| 56 | |
import org.kuali.rice.kim.bo.Person; |
| 57 | |
|
| 58 | |
import org.kuali.rice.kns.util.GlobalVariables; |
| 59 | |
import org.springframework.core.io.DefaultResourceLoader; |
| 60 | |
import org.w3c.dom.Document; |
| 61 | |
import org.w3c.dom.Element; |
| 62 | |
import org.w3c.dom.Node; |
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | 0 | public class StyleableEmailContentServiceImpl extends BaseEmailContentServiceImpl { |
| 74 | 0 | private static final Logger LOG = Logger.getLogger(StyleableEmailContentServiceImpl.class); |
| 75 | |
|
| 76 | 0 | protected final String DEFAULT_EMAIL_STYLESHEET_RESOURCE_LOC = "defaultEmailStyle.xsl"; |
| 77 | |
|
| 78 | |
protected StyleService styleService; |
| 79 | 0 | protected EmailStyleHelper styleHelper = new EmailStyleHelper(); |
| 80 | 0 | protected String globalEmailStyleSheet = KEWConstants.EMAIL_STYLESHEET_NAME; |
| 81 | |
|
| 82 | |
protected RouteHeaderService routeHeaderService; |
| 83 | |
|
| 84 | |
public void setStyleService(StyleService styleService) { |
| 85 | 0 | this.styleService = styleService; |
| 86 | 0 | } |
| 87 | |
|
| 88 | |
public void setGlobalEmailStyleSheet(String globalEmailStyleSheet) { |
| 89 | 0 | this.globalEmailStyleSheet = globalEmailStyleSheet; |
| 90 | 0 | } |
| 91 | |
|
| 92 | |
protected static DocumentBuilder getDocumentBuilder(boolean coalesce) { |
| 93 | |
try { |
| 94 | 0 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
| 95 | 0 | dbf.setCoalescing(coalesce); |
| 96 | 0 | return dbf.newDocumentBuilder(); |
| 97 | 0 | } catch (ParserConfigurationException e) { |
| 98 | 0 | String message = "Error constructing document builder"; |
| 99 | 0 | LOG.error(message, e); |
| 100 | 0 | throw new WorkflowRuntimeException(message, e); |
| 101 | |
} |
| 102 | |
} |
| 103 | |
|
| 104 | |
protected static void addObjectXML(Document doc, Object o, Node node, String name) throws Exception { |
| 105 | 0 | Element element = XmlHelper.propertiesToXml(doc, o, name); |
| 106 | |
|
| 107 | 0 | if (LOG.isDebugEnabled()) { |
| 108 | 0 | LOG.debug(XmlJotter.jotNode(element)); |
| 109 | |
} |
| 110 | |
|
| 111 | 0 | if (node == null) { |
| 112 | 0 | node = doc; |
| 113 | |
} |
| 114 | |
|
| 115 | 0 | node.appendChild(element); |
| 116 | 0 | } |
| 117 | |
|
| 118 | |
protected static void addTextElement(Document doc, Element baseElement, String elementName, Object elementData) { |
| 119 | 0 | Element element = doc.createElement(elementName); |
| 120 | 0 | String dataValue = ""; |
| 121 | 0 | if (elementData != null) { |
| 122 | 0 | dataValue = elementData.toString(); |
| 123 | |
} |
| 124 | 0 | element.appendChild(doc.createTextNode(dataValue)); |
| 125 | 0 | baseElement.appendChild(element); |
| 126 | 0 | } |
| 127 | |
|
| 128 | |
protected static void addCDataElement(Document doc, Element baseElement, String elementName, Object elementData) { |
| 129 | 0 | Element element = doc.createElement(elementName); |
| 130 | 0 | String dataValue = ""; |
| 131 | 0 | if (elementData != null) { |
| 132 | 0 | dataValue = elementData.toString(); |
| 133 | |
} |
| 134 | 0 | element.appendChild(doc.createCDATASection(dataValue)); |
| 135 | 0 | baseElement.appendChild(element); |
| 136 | 0 | } |
| 137 | |
|
| 138 | |
protected static void addTimestampElement(Document doc, Element baseElement, String elementName, Timestamp elementData) { |
| 139 | 0 | addTextElement(doc, baseElement, elementName, RiceConstants.getDefaultDateFormat().format(elementData)); |
| 140 | 0 | } |
| 141 | |
|
| 142 | |
protected static void addDelegatorElement(Document doc, Element baseElement, ActionItem actionItem) { |
| 143 | 0 | Element delegatorElement = doc.createElement("delegator"); |
| 144 | 0 | if ( (actionItem.getDelegatorWorkflowId() != null) && (actionItem.getDelegatorWorkflowId() != null) ) { |
| 145 | |
|
| 146 | 0 | baseElement.appendChild(delegatorElement); |
| 147 | 0 | return; |
| 148 | |
} |
| 149 | 0 | String delegatorType = ""; |
| 150 | 0 | String delegatorId = ""; |
| 151 | 0 | String delegatorDisplayValue = ""; |
| 152 | 0 | if (actionItem.getDelegatorWorkflowId() != null) { |
| 153 | 0 | delegatorType = "user"; |
| 154 | 0 | delegatorId = actionItem.getDelegatorWorkflowId(); |
| 155 | 0 | Principal delegator = KimApiServiceLocator.getIdentityManagementService().getPrincipal(delegatorId); |
| 156 | |
|
| 157 | 0 | if (delegator == null) { |
| 158 | 0 | LOG.error("Cannot find user for id " + delegatorId); |
| 159 | 0 | delegatorDisplayValue = "USER NOT FOUND"; |
| 160 | |
} else { |
| 161 | 0 | delegatorDisplayValue = UserUtils.getTransposedName(GlobalVariables.getUserSession(), delegator); |
| 162 | |
} |
| 163 | 0 | } else if (actionItem.getDelegatorWorkflowId() != null) { |
| 164 | 0 | delegatorType = "workgroup"; |
| 165 | 0 | delegatorId = actionItem.getDelegatorGroupId().toString(); |
| 166 | 0 | delegatorDisplayValue = KimApiServiceLocator.getIdentityManagementService().getGroup(actionItem.getDelegatorGroupId()).getName(); |
| 167 | |
} |
| 168 | 0 | delegatorElement.setAttribute("type", delegatorType); |
| 169 | |
|
| 170 | 0 | Element idElement = doc.createElement("id"); |
| 171 | 0 | idElement.appendChild(doc.createTextNode(delegatorId)); |
| 172 | 0 | delegatorElement.appendChild(idElement); |
| 173 | |
|
| 174 | 0 | Element displayValElement = doc.createElement("displayValue"); |
| 175 | 0 | displayValElement.appendChild(doc.createTextNode(delegatorDisplayValue)); |
| 176 | 0 | delegatorElement.appendChild(displayValElement); |
| 177 | 0 | baseElement.appendChild(delegatorElement); |
| 178 | 0 | } |
| 179 | |
|
| 180 | |
protected static void addWorkgroupRequestElement(Document doc, Element baseElement, ActionItem actionItem) { |
| 181 | 0 | Element workgroupElement = doc.createElement("workgroupRequest"); |
| 182 | 0 | if (actionItem.isWorkgroupItem()) { |
| 183 | |
|
| 184 | 0 | Element idElement = doc.createElement("id"); |
| 185 | 0 | idElement.appendChild(doc.createTextNode(actionItem.getGroupId())); |
| 186 | 0 | workgroupElement.appendChild(idElement); |
| 187 | |
|
| 188 | 0 | Element displayValElement = doc.createElement("displayValue"); |
| 189 | 0 | displayValElement.appendChild(doc.createTextNode(actionItem.getGroupId())); |
| 190 | 0 | workgroupElement.appendChild(displayValElement); |
| 191 | |
} |
| 192 | 0 | baseElement.appendChild(workgroupElement); |
| 193 | 0 | } |
| 194 | |
|
| 195 | |
|
| 196 | |
|
| 197 | |
|
| 198 | |
|
| 199 | |
|
| 200 | |
|
| 201 | |
|
| 202 | |
|
| 203 | |
|
| 204 | |
|
| 205 | |
protected void addSummarizedActionItem(Document doc, ActionItem actionItem, Person user, Node node, DocumentRouteHeaderValue routeHeader) throws Exception { |
| 206 | 0 | if (node == null) { |
| 207 | 0 | node = doc; |
| 208 | |
} |
| 209 | |
|
| 210 | 0 | Element root = doc.createElement("summarizedActionItem"); |
| 211 | |
|
| 212 | |
|
| 213 | 0 | addTextElement(doc, root, "documentId", actionItem.getDocumentId()); |
| 214 | 0 | addTextElement(doc, root, "docName", actionItem.getDocName()); |
| 215 | 0 | addCDataElement(doc, root, "docLabel", actionItem.getDocLabel()); |
| 216 | 0 | addCDataElement(doc, root, "docTitle", actionItem.getDocTitle()); |
| 217 | |
|
| 218 | 0 | addTextElement(doc, root, "docRouteStatus", routeHeader.getDocRouteStatus()); |
| 219 | 0 | addCDataElement(doc, root, "routeStatusLabel", routeHeader.getRouteStatusLabel()); |
| 220 | 0 | addTextElement(doc, root, "actionRequestCd", actionItem.getActionRequestCd()); |
| 221 | 0 | addTextElement(doc, root, "actionRequestLabel", actionItem.getActionRequestLabel()); |
| 222 | 0 | addDelegatorElement(doc, root, actionItem); |
| 223 | 0 | addTimestampElement(doc, root, "createDate", routeHeader.getCreateDate()); |
| 224 | 0 | addWorkgroupRequestElement(doc, root, actionItem); |
| 225 | 0 | addTimestampElement(doc, root, "dateAssigned", actionItem.getDateAssigned()); |
| 226 | |
|
| 227 | 0 | node.appendChild(root); |
| 228 | 0 | } |
| 229 | |
|
| 230 | |
public DocumentRouteHeaderValue getRouteHeader(ActionItem actionItem) { |
| 231 | 0 | if (routeHeaderService == null) { |
| 232 | 0 | routeHeaderService = KEWServiceLocator.getRouteHeaderService(); |
| 233 | |
} |
| 234 | 0 | return routeHeaderService.getRouteHeader(actionItem.getDocumentId()); |
| 235 | |
} |
| 236 | |
|
| 237 | |
protected Map<String,DocumentRouteHeaderValue> getRouteHeaders(Collection<ActionItem> actionItems) { |
| 238 | 0 | if (routeHeaderService == null) { |
| 239 | 0 | routeHeaderService = KEWServiceLocator.getRouteHeaderService(); |
| 240 | |
} |
| 241 | 0 | return routeHeaderService.getRouteHeadersForActionItems(actionItems); |
| 242 | |
} |
| 243 | |
|
| 244 | |
protected static String transform(Templates style, Document doc) { |
| 245 | 0 | StringWriter writer = new StringWriter(); |
| 246 | 0 | StreamResult result = new StreamResult(writer); |
| 247 | |
|
| 248 | |
try { |
| 249 | 0 | style.newTransformer().transform(new DOMSource(doc), result); |
| 250 | 0 | return writer.toString(); |
| 251 | 0 | } catch (TransformerException te) { |
| 252 | 0 | String message = "Error transforming DOM"; |
| 253 | 0 | LOG.error(message, te); |
| 254 | 0 | throw new WorkflowRuntimeException(message, te); |
| 255 | |
} |
| 256 | |
} |
| 257 | |
|
| 258 | |
|
| 259 | |
|
| 260 | |
|
| 261 | |
|
| 262 | |
|
| 263 | |
|
| 264 | |
|
| 265 | |
protected Templates getStyle(String styleName) { |
| 266 | 0 | Templates style = null; |
| 267 | |
try { |
| 268 | 0 | style = styleService.getStyleAsTranslet(styleName); |
| 269 | 0 | } catch (TransformerConfigurationException tce) { |
| 270 | 0 | String message = "Error obtaining style '" + styleName + "', using default"; |
| 271 | 0 | LOG.error(message, tce); |
| 272 | |
|
| 273 | 0 | } |
| 274 | |
|
| 275 | 0 | if (style == null) { |
| 276 | 0 | LOG.warn("Could not find specified style, " + styleName + ", using default"); |
| 277 | |
try { |
| 278 | |
|
| 279 | 0 | style = TransformerFactory.newInstance().newTemplates(new StreamSource(new DefaultResourceLoader().getResource("classpath:org/kuali/rice/kew/mail/" + DEFAULT_EMAIL_STYLESHEET_RESOURCE_LOC).getInputStream())); |
| 280 | 0 | } catch (Exception tce) { |
| 281 | 0 | String message = "Error obtaining default style from resource: " + DEFAULT_EMAIL_STYLESHEET_RESOURCE_LOC; |
| 282 | 0 | LOG.error(message, tce); |
| 283 | 0 | throw new WorkflowRuntimeException("Error obtaining style '" + styleName + "'", tce); |
| 284 | 0 | } |
| 285 | |
} |
| 286 | 0 | return style; |
| 287 | |
} |
| 288 | |
|
| 289 | |
protected EmailContent generateEmailContent(String styleName, Document doc) { |
| 290 | 0 | Templates style = getStyle(styleName); |
| 291 | 0 | return styleHelper.generateEmailContent(style, doc); |
| 292 | |
} |
| 293 | |
|
| 294 | |
protected EmailContent generateReminderForActionItems(Person user, Collection<ActionItem> actionItems, String name, String style) { |
| 295 | 0 | DocumentBuilder db = getDocumentBuilder(false); |
| 296 | 0 | Document doc = db.newDocument(); |
| 297 | 0 | Element element = doc.createElement(name); |
| 298 | 0 | Map<String,DocumentRouteHeaderValue> routeHeaders = getRouteHeaders(actionItems); |
| 299 | |
|
| 300 | 0 | setStandardAttributes(element); |
| 301 | 0 | doc.appendChild(element); |
| 302 | |
|
| 303 | |
try { |
| 304 | 0 | addObjectXML(doc, user, element, "user"); |
| 305 | 0 | for (ActionItem actionItem: actionItems) { |
| 306 | |
try { |
| 307 | 0 | addSummarizedActionItem(doc, actionItem, user, element, routeHeaders.get(actionItem.getDocumentId())); |
| 308 | 0 | } catch (Exception e) { |
| 309 | 0 | String message = "Error generating XML for action item: " + actionItem; |
| 310 | 0 | LOG.error(message, e); |
| 311 | 0 | throw new WorkflowRuntimeException(e); |
| 312 | 0 | } |
| 313 | |
} |
| 314 | |
|
| 315 | 0 | } catch (Exception e) { |
| 316 | 0 | String message = "Error generating XML for action items: " + actionItems; |
| 317 | 0 | LOG.error(message, e); |
| 318 | 0 | throw new WorkflowRuntimeException(e); |
| 319 | 0 | } |
| 320 | |
|
| 321 | 0 | return generateEmailContent(style, doc); |
| 322 | |
} |
| 323 | |
|
| 324 | |
protected void setStandardAttributes(Element e) { |
| 325 | 0 | e.setAttribute("env", getDeploymentEnvironment()); |
| 326 | 0 | e.setAttribute("applicationEmailAddress", getApplicationEmailAddress()); |
| 327 | 0 | e.setAttribute("actionListUrl", getActionListUrl()); |
| 328 | 0 | e.setAttribute("preferencesUrl", getPreferencesUrl()); |
| 329 | 0 | } |
| 330 | |
|
| 331 | |
|
| 332 | |
|
| 333 | |
|
| 334 | |
|
| 335 | |
|
| 336 | |
|
| 337 | |
|
| 338 | |
|
| 339 | |
|
| 340 | |
|
| 341 | |
|
| 342 | |
|
| 343 | |
|
| 344 | |
|
| 345 | |
|
| 346 | |
|
| 347 | |
|
| 348 | |
|
| 349 | |
|
| 350 | |
@Override |
| 351 | |
public EmailContent generateImmediateReminder(Person user, ActionItem actionItem, DocumentType documentType) { |
| 352 | |
|
| 353 | 0 | LOG.info("Starting generation of immediate email reminder..."); |
| 354 | 0 | LOG.info("Action Id: " + actionItem.getActionItemId() + |
| 355 | |
"; ActionRequestId: " + actionItem.getActionRequestId() + |
| 356 | |
"; Action Item Principal Name: " + actionItem.getPerson().getPrincipalName()); |
| 357 | 0 | LOG.info("User Principal Name: " + user.getPrincipalName()); |
| 358 | |
|
| 359 | 0 | String styleSheet = documentType.getCustomEmailStylesheet(); |
| 360 | 0 | LOG.debug(documentType.getName() + " style: " + styleSheet); |
| 361 | 0 | if (styleSheet == null) { |
| 362 | 0 | styleSheet = globalEmailStyleSheet; |
| 363 | |
} |
| 364 | |
|
| 365 | 0 | LOG.info("generateImmediateReminder using style sheet: "+ styleSheet + " for Document Type " + documentType.getName()); |
| 366 | |
|
| 367 | 0 | DocumentBuilder db = getDocumentBuilder(false); |
| 368 | 0 | Document doc = db.newDocument(); |
| 369 | 0 | Element element = doc.createElement("immediateReminder"); |
| 370 | 0 | setStandardAttributes(element); |
| 371 | 0 | doc.appendChild(element); |
| 372 | |
|
| 373 | |
try { |
| 374 | 0 | addObjectXML(doc, user, element, "user"); |
| 375 | |
|
| 376 | 0 | Node node = element; |
| 377 | 0 | if (node == null) { |
| 378 | 0 | node = doc; |
| 379 | |
} |
| 380 | |
|
| 381 | 0 | Element root = doc.createElement("actionItem"); |
| 382 | |
|
| 383 | |
try { |
| 384 | 0 | CustomEmailAttribute customEmailAttribute = getCustomEmailAttribute(user, actionItem); |
| 385 | 0 | if (customEmailAttribute != null) { |
| 386 | 0 | String customBody = customEmailAttribute.getCustomEmailBody(); |
| 387 | 0 | if (!org.apache.commons.lang.StringUtils.isEmpty(customBody)) { |
| 388 | 0 | Element bodyElement = doc.createElement("customBody"); |
| 389 | 0 | bodyElement.appendChild(doc.createTextNode(customBody)); |
| 390 | 0 | root.appendChild(bodyElement); |
| 391 | |
} |
| 392 | 0 | String customEmailSubject = customEmailAttribute.getCustomEmailSubject(); |
| 393 | 0 | if (!org.apache.commons.lang.StringUtils.isEmpty(customEmailSubject)) { |
| 394 | 0 | Element subjectElement = doc.createElement("customSubject"); |
| 395 | 0 | subjectElement.appendChild(doc.createTextNode(customEmailSubject)); |
| 396 | 0 | root.appendChild(subjectElement); |
| 397 | |
} |
| 398 | |
} |
| 399 | 0 | } catch (Exception e) { |
| 400 | 0 | LOG.error("Error when checking for custom email body and subject.", e); |
| 401 | 0 | } |
| 402 | 0 | Person person = actionItem.getPerson(); |
| 403 | 0 | DocumentRouteHeaderValue header = getRouteHeader(actionItem); |
| 404 | |
|
| 405 | 0 | addObjectXML(doc, actionItem, root, "actionItem"); |
| 406 | 0 | addObjectXML(doc, person, root, "actionItemPerson"); |
| 407 | 0 | addTextElement(doc, root, "actionItemPrincipalId", person.getPrincipalId()); |
| 408 | 0 | addTextElement(doc, root, "actionItemPrincipalName", person.getPrincipalName()); |
| 409 | 0 | addDocumentHeaderXML(doc, header, root, "doc"); |
| 410 | 0 | addObjectXML(doc, header.getInitiatorPrincipal(), root, "docInitiator"); |
| 411 | 0 | addTextElement(doc, root, "docInitiatorDisplayName", header.getInitiatorDisplayName()); |
| 412 | 0 | addObjectXML(doc, header.getDocumentType(), root, "documentType"); |
| 413 | |
|
| 414 | 0 | node.appendChild(root); |
| 415 | 0 | } catch (Exception e) { |
| 416 | 0 | String message = "Error generating immediate reminder XML for action item: " + actionItem; |
| 417 | 0 | LOG.error(message, e); |
| 418 | 0 | throw new WorkflowRuntimeException(e); |
| 419 | 0 | } |
| 420 | 0 | LOG.info("Leaving generation of immeidate email reminder..."); |
| 421 | |
|
| 422 | |
|
| 423 | |
|
| 424 | 0 | return generateEmailContent(styleSheet, doc); |
| 425 | |
} |
| 426 | |
|
| 427 | |
|
| 428 | |
|
| 429 | |
|
| 430 | |
|
| 431 | |
|
| 432 | |
|
| 433 | |
|
| 434 | |
protected void addDocumentHeaderXML(Document document, DocumentRouteHeaderValue documentHeader, Node node, String elementName) throws Exception { |
| 435 | 0 | Element element = XmlHelper.propertiesToXml(document, documentHeader, elementName); |
| 436 | |
|
| 437 | 0 | Element docContentElement = (Element)element.getElementsByTagName("docContent").item(0); |
| 438 | 0 | String documentContent = docContentElement.getTextContent(); |
| 439 | |
|
| 440 | 0 | if (!StringUtils.isBlank(documentContent) && documentContent.startsWith("<")) { |
| 441 | 0 | Document documentContentXML = XmlHelper.readXml(documentContent); |
| 442 | 0 | Element documentContentElement = documentContentXML.getDocumentElement(); |
| 443 | 0 | documentContentElement = (Element)document.importNode(documentContentElement, true); |
| 444 | |
|
| 445 | |
|
| 446 | 0 | docContentElement.removeChild(docContentElement.getFirstChild()); |
| 447 | |
|
| 448 | |
|
| 449 | 0 | docContentElement.appendChild(documentContentElement); |
| 450 | 0 | } else { |
| 451 | |
|
| 452 | |
|
| 453 | |
|
| 454 | |
|
| 455 | |
|
| 456 | 0 | docContentElement.removeChild(docContentElement.getFirstChild()); |
| 457 | |
} |
| 458 | |
|
| 459 | 0 | if (LOG.isDebugEnabled()) { |
| 460 | 0 | LOG.debug(XmlJotter.jotNode(element)); |
| 461 | |
} |
| 462 | |
|
| 463 | 0 | node.appendChild(element); |
| 464 | 0 | } |
| 465 | |
|
| 466 | |
@Override |
| 467 | |
public EmailContent generateWeeklyReminder(Person user, Collection<ActionItem> actionItems) { |
| 468 | 0 | return generateReminderForActionItems(user, actionItems, "weeklyReminder", globalEmailStyleSheet); |
| 469 | |
} |
| 470 | |
|
| 471 | |
@Override |
| 472 | |
public EmailContent generateDailyReminder(Person user, Collection<ActionItem> actionItems) { |
| 473 | 0 | return generateReminderForActionItems(user, actionItems, "dailyReminder", globalEmailStyleSheet); |
| 474 | |
} |
| 475 | |
|
| 476 | |
@Override |
| 477 | |
public EmailContent generateFeedback(FeedbackForm form) { |
| 478 | 0 | DocumentBuilder db = getDocumentBuilder(true); |
| 479 | 0 | Document doc = db.newDocument(); |
| 480 | 0 | String styleSheet = globalEmailStyleSheet; |
| 481 | |
|
| 482 | |
|
| 483 | |
|
| 484 | |
|
| 485 | |
|
| 486 | |
|
| 487 | |
|
| 488 | |
|
| 489 | |
|
| 490 | |
|
| 491 | |
|
| 492 | |
|
| 493 | |
|
| 494 | |
|
| 495 | 0 | LOG.info("form: " + form.getDocumentId()); |
| 496 | |
try { |
| 497 | 0 | addObjectXML(doc, form, null, "feedback"); |
| 498 | 0 | } catch (Exception e) { |
| 499 | 0 | String message = "Error generating XML for feedback form: " + form; |
| 500 | 0 | LOG.error(message, e); |
| 501 | 0 | throw new WorkflowRuntimeException(message, e); |
| 502 | 0 | } |
| 503 | 0 | setStandardAttributes(doc.getDocumentElement()); |
| 504 | |
|
| 505 | 0 | return generateEmailContent(styleSheet, doc); |
| 506 | |
} |
| 507 | |
} |