Coverage Report - org.kuali.rice.kew.mail.service.impl.BaseEmailContentServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
BaseEmailContentServiceImpl
0%
0/26
0%
0/8
1.5
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 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  
  * Base EmailContentService implementation with a default email from address that can be
 36  
  * configured via Spring property injection
 37  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 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  
         // first check the configured value
 49  0
         String fromAddress = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(KewApiConstants.KEW_NAMESPACE, KRADConstants.DetailTypes.MAILER_DETAIL_TYPE, KewApiConstants.EMAIL_REMINDER_FROM_ADDRESS);
 50  
         // if there's no value configured, use the default
 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  
 }