Coverage Report - org.kuali.rice.kew.mail.service.impl.BaseEmailContentServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
BaseEmailContentServiceImpl
0%
0/27
0%
0/10
1.625
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 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  
  * 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 = Utilities.getKNSParameterValue(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 (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  
 }