Coverage Report - org.kuali.rice.kew.util.ConfigStringLookup
 
Classes in this File Line Coverage Branch Coverage Complexity
ConfigStringLookup
0%
0/15
0%
0/6
2.333
 
 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.util;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.apache.commons.lang.text.StrLookup;
 20  
 import org.kuali.rice.core.api.CoreApiServiceLocator;
 21  
 import org.kuali.rice.core.api.config.property.ConfigContext;
 22  
 import org.kuali.rice.core.api.parameter.ParameterKey;
 23  
 import org.kuali.rice.core.framework.services.CoreFrameworkServiceLocator;
 24  
 import org.kuali.rice.kew.api.KewApiConstants;
 25  
 import org.kuali.rice.kim.api.KimConstants;
 26  
 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
 27  
 import org.kuali.rice.krad.util.KRADConstants;
 28  
 
 29  
 /**
 30  
  * Looks up Strings from the Config and System Parameters.
 31  
  *
 32  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 33  
  */
 34  
 public class ConfigStringLookup extends StrLookup {
 35  
         
 36  
         private final String applicationId;
 37  
         
 38  
         public ConfigStringLookup() {
 39  0
         this(null);
 40  0
         }
 41  
         
 42  0
         public ConfigStringLookup(String applicationId) {
 43  0
                 this.applicationId = applicationId;
 44  0
         }
 45  
 
 46  
     @Override
 47  
     public String lookup(String propertyName) {
 48  0
         if (StringUtils.isBlank(propertyName)) {
 49  0
             return null;
 50  
         }
 51  
 
 52  0
         String paramValue = null;
 53  
         // check system parameters first
 54  0
         if (StringUtils.isBlank(applicationId)) {
 55  0
             paramValue = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(
 56  
                     KewApiConstants.KEW_NAMESPACE, KRADConstants.DetailTypes.ALL_DETAIL_TYPE, propertyName);
 57  
         } else {
 58  0
             ParameterKey parameterKey = ParameterKey.create(applicationId, KewApiConstants.KEW_NAMESPACE,
 59  
                     KRADConstants.DetailTypes.ALL_DETAIL_TYPE, propertyName);
 60  0
             paramValue = CoreApiServiceLocator.getParameterRepositoryService().getParameterValueAsString(parameterKey);
 61  
         }
 62  
 
 63  0
         if (paramValue == null) {
 64  0
             paramValue = ConfigContext.getCurrentContextConfig().getProperty(propertyName);
 65  
         }
 66  0
         return paramValue;
 67  
     }
 68  
 
 69  
 }