1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.mail.service.impl; |
18 | |
|
19 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
20 | |
import org.kuali.rice.core.framework.services.CoreFrameworkServiceLocator; |
21 | |
import org.kuali.rice.kew.actionitem.ActionItem; |
22 | |
import org.kuali.rice.kew.actionrequest.ActionRequestValue; |
23 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
24 | |
import org.kuali.rice.kew.dto.ActionRequestDTO; |
25 | |
import org.kuali.rice.kew.dto.DTOConverter; |
26 | |
import org.kuali.rice.kew.dto.RouteHeaderDTO; |
27 | |
import org.kuali.rice.kew.exception.WorkflowException; |
28 | |
import org.kuali.rice.kew.mail.CustomEmailAttribute; |
29 | |
import org.kuali.rice.kew.mail.service.EmailContentService; |
30 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
31 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
32 | |
import org.kuali.rice.kew.util.KEWConstants; |
33 | |
import org.kuali.rice.kim.bo.Person; |
34 | |
import org.kuali.rice.krad.util.KRADConstants; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | public abstract class BaseEmailContentServiceImpl implements EmailContentService { |
42 | 0 | protected String defaultEmailFromAddress = "admin@localhost"; |
43 | |
protected String deploymentEnvironment; |
44 | |
|
45 | |
public void setDefaultEmailFromAddress(String defaultEmailFromAddress) { |
46 | 0 | this.defaultEmailFromAddress = defaultEmailFromAddress; |
47 | 0 | } |
48 | |
|
49 | |
public String getApplicationEmailAddress() { |
50 | |
|
51 | 0 | String fromAddress = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(KEWConstants.KEW_NAMESPACE, KRADConstants.DetailTypes.MAILER_DETAIL_TYPE, KEWConstants.EMAIL_REMINDER_FROM_ADDRESS); |
52 | |
|
53 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(fromAddress)) { |
54 | 0 | fromAddress = defaultEmailFromAddress; |
55 | |
} |
56 | 0 | return fromAddress; |
57 | |
} |
58 | |
|
59 | |
public String getDocumentTypeEmailAddress(DocumentType documentType) { |
60 | 0 | String fromAddress = (documentType == null ? null : documentType.getNotificationFromAddress()); |
61 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(fromAddress)) { |
62 | 0 | fromAddress = getApplicationEmailAddress(); |
63 | |
} |
64 | 0 | return fromAddress; |
65 | |
} |
66 | |
|
67 | |
public String getDeploymentEnvironment() { |
68 | 0 | return deploymentEnvironment; |
69 | |
} |
70 | |
|
71 | |
public void setDeploymentEnvironment(String deploymentEnvironment) { |
72 | 0 | this.deploymentEnvironment = deploymentEnvironment; |
73 | 0 | } |
74 | |
|
75 | |
protected static CustomEmailAttribute getCustomEmailAttribute(Person user, ActionItem actionItem) throws WorkflowException { |
76 | 0 | DocumentRouteHeaderValue routeHeader = KEWServiceLocator.getRouteHeaderService().getRouteHeader(actionItem.getDocumentId()); |
77 | 0 | CustomEmailAttribute customEmailAttribute = routeHeader.getCustomEmailAttribute(); |
78 | 0 | if (customEmailAttribute != null) { |
79 | 0 | RouteHeaderDTO routeHeaderVO = DTOConverter.convertRouteHeader(routeHeader, user.getPrincipalId()); |
80 | 0 | ActionRequestValue actionRequest = KEWServiceLocator.getActionRequestService().findByActionRequestId(actionItem.getActionRequestId()); |
81 | 0 | ActionRequestDTO actionRequestVO = DTOConverter.convertActionRequest(actionRequest); |
82 | 0 | customEmailAttribute.setRouteHeaderVO(routeHeaderVO); |
83 | 0 | customEmailAttribute.setActionRequestVO(actionRequestVO); |
84 | |
} |
85 | 0 | return customEmailAttribute; |
86 | |
} |
87 | |
|
88 | |
protected String getActionListUrl() { |
89 | 0 | return ConfigContext.getCurrentContextConfig().getProperty(KRADConstants.WORKFLOW_URL_KEY) + "/" + "ActionList.do"; |
90 | |
} |
91 | |
|
92 | |
protected String getPreferencesUrl() { |
93 | 0 | return ConfigContext.getCurrentContextConfig().getProperty(KRADConstants.WORKFLOW_URL_KEY) + "/" + "Preferences.do"; |
94 | |
} |
95 | |
} |