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 2006-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  
 
 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.kns.util.KNSConstants;
 35  
 
 36  
 
 37  
 /**
 38  
  * Base EmailContentService implementation with a default email from address that can be
 39  
  * configured via Spring property injection
 40  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 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  
         // first check the configured value
 52  0
         String fromAddress = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(KEWConstants.KEW_NAMESPACE, KNSConstants.DetailTypes.MAILER_DETAIL_TYPE, KEWConstants.EMAIL_REMINDER_FROM_ADDRESS);
 53  
         // if there's no value configured, use the default
 54  0
         if (org.apache.commons.lang.StringUtils.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 (org.apache.commons.lang.StringUtils.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
             DocumentRouteHeaderValue routeHeader = KEWServiceLocator.getRouteHeaderService().getRouteHeader(actionItem.getDocumentId());
 78  0
         CustomEmailAttribute customEmailAttribute = routeHeader.getCustomEmailAttribute();
 79  0
         if (customEmailAttribute != null) {
 80  0
             RouteHeaderDTO routeHeaderVO = DTOConverter.convertRouteHeader(routeHeader, user.getPrincipalId());
 81  0
             ActionRequestValue actionRequest = KEWServiceLocator.getActionRequestService().findByActionRequestId(actionItem.getActionRequestId());
 82  0
             ActionRequestDTO actionRequestVO = DTOConverter.convertActionRequest(actionRequest);
 83  0
             customEmailAttribute.setRouteHeaderVO(routeHeaderVO);
 84  0
             customEmailAttribute.setActionRequestVO(actionRequestVO);
 85  
         }
 86  0
         return customEmailAttribute;
 87  
     }
 88  
 
 89  
     protected String getActionListUrl() {
 90  0
         return ConfigContext.getCurrentContextConfig().getProperty(KNSConstants.WORKFLOW_URL_KEY) + "/" + "ActionList.do";
 91  
     }
 92  
 
 93  
     protected String getPreferencesUrl() {
 94  0
         return ConfigContext.getCurrentContextConfig().getProperty(KNSConstants.WORKFLOW_URL_KEY) + "/" + "Preferences.do";
 95  
     }
 96  
 }