| 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 org.kuali.rice.core.config.ConfigContext; |
| 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.service.KEWServiceLocator; |
| 31 | |
import org.kuali.rice.kew.util.KEWConstants; |
| 32 | |
import org.kuali.rice.kew.util.Utilities; |
| 33 | |
import org.kuali.rice.kim.bo.Person; |
| 34 | |
import org.kuali.rice.kns.util.KNSConstants; |
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | 0 | public abstract class BaseEmailContentServiceImpl implements EmailContentService { |
| 43 | 0 | protected String defaultEmailFromAddress = "admin@localhost"; |
| 44 | |
protected String deploymentEnvironment; |
| 45 | |
|
| 46 | |
public void setDefaultEmailFromAddress(String defaultEmailFromAddress) { |
| 47 | 0 | this.defaultEmailFromAddress = defaultEmailFromAddress; |
| 48 | 0 | } |
| 49 | |
|
| 50 | |
public String getApplicationEmailAddress() { |
| 51 | |
|
| 52 | 0 | String fromAddress = Utilities.getKNSParameterValue(KEWConstants.KEW_NAMESPACE, KNSConstants.DetailTypes.MAILER_DETAIL_TYPE, KEWConstants.EMAIL_REMINDER_FROM_ADDRESS); |
| 53 | |
|
| 54 | 0 | if (Utilities.isEmpty(fromAddress)) { |
| 55 | 0 | fromAddress = defaultEmailFromAddress; |
| 56 | |
} |
| 57 | 0 | return fromAddress; |
| 58 | |
} |
| 59 | |
|
| 60 | |
public String getDocumentTypeEmailAddress(DocumentType documentType) { |
| 61 | 0 | String fromAddress = (documentType == null ? null : documentType.getNotificationFromAddress()); |
| 62 | 0 | if (Utilities.isEmpty(fromAddress)) { |
| 63 | 0 | fromAddress = getApplicationEmailAddress(); |
| 64 | |
} |
| 65 | 0 | return fromAddress; |
| 66 | |
} |
| 67 | |
|
| 68 | |
public String getDeploymentEnvironment() { |
| 69 | 0 | return deploymentEnvironment; |
| 70 | |
} |
| 71 | |
|
| 72 | |
public void setDeploymentEnvironment(String deploymentEnvironment) { |
| 73 | 0 | this.deploymentEnvironment = deploymentEnvironment; |
| 74 | 0 | } |
| 75 | |
|
| 76 | |
protected static CustomEmailAttribute getCustomEmailAttribute(Person user, ActionItem actionItem) throws WorkflowException { |
| 77 | 0 | if (actionItem.getRouteHeader() == null) { |
| 78 | 0 | actionItem.setRouteHeader(KEWServiceLocator.getRouteHeaderService().getRouteHeader(actionItem.getRouteHeaderId())); |
| 79 | |
} |
| 80 | 0 | CustomEmailAttribute customEmailAttribute = actionItem.getRouteHeader().getCustomEmailAttribute(); |
| 81 | 0 | if (customEmailAttribute != null) { |
| 82 | 0 | RouteHeaderDTO routeHeaderVO = DTOConverter.convertRouteHeader(actionItem.getRouteHeader(), user.getPrincipalId()); |
| 83 | 0 | ActionRequestValue actionRequest = KEWServiceLocator.getActionRequestService().findByActionRequestId(actionItem.getActionRequestId()); |
| 84 | 0 | ActionRequestDTO actionRequestVO = DTOConverter.convertActionRequest(actionRequest); |
| 85 | 0 | customEmailAttribute.setRouteHeaderVO(routeHeaderVO); |
| 86 | 0 | customEmailAttribute.setActionRequestVO(actionRequestVO); |
| 87 | |
} |
| 88 | 0 | return customEmailAttribute; |
| 89 | |
} |
| 90 | |
|
| 91 | |
protected String getActionListUrl() { |
| 92 | 0 | return ConfigContext.getCurrentContextConfig().getProperty(KNSConstants.WORKFLOW_URL_KEY) + "/" + "ActionList.do"; |
| 93 | |
} |
| 94 | |
|
| 95 | |
protected String getPreferencesUrl() { |
| 96 | 0 | return ConfigContext.getCurrentContextConfig().getProperty(KNSConstants.WORKFLOW_URL_KEY) + "/" + "Preferences.do"; |
| 97 | |
} |
| 98 | |
} |