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