View Javadoc

1   /*
2    * Copyright 2005-2008 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  package org.kuali.rice.kew.util;
18  
19  import org.apache.commons.lang.StringUtils;
20  import org.apache.commons.lang.text.StrLookup;
21  import org.kuali.rice.core.config.ConfigContext;
22  import org.kuali.rice.kns.service.KNSServiceLocator;
23  import org.kuali.rice.kns.util.KNSConstants;
24  
25  /**
26   * Looks up Strings from the Config and System Parameters.
27   *
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  public class ConfigStringLookup extends StrLookup {
31  	private String namespace;
32  	
33  	public ConfigStringLookup() {
34  		
35  	}
36  	
37  	public ConfigStringLookup(String namespace) {
38  		this.namespace = namespace;
39  	}
40  	
41  	@Override
42  	public String lookup(String propertyName) {
43  		if (StringUtils.isBlank(propertyName)) {
44  			return null;
45  		}
46  		
47  		String paramValue = null;
48  		
49  		// TODO temporarily disabling configuration parameter resolution against the racms because it's been causing some issues
50  		if ( namespace != null ) {
51  			paramValue = KNSServiceLocator.getRiceApplicationConfigurationMediationService().getConfigurationParameter(namespace, propertyName);
52  		}
53  		
54  		// check system parameters first
55  		if ( paramValue == null ) {
56  			paramValue = Utilities.getKNSParameterValue(KEWConstants.KEW_NAMESPACE, KNSConstants.DetailTypes.ALL_DETAIL_TYPE, propertyName);
57  		}
58  		if (paramValue == null) {
59  			paramValue = ConfigContext.getCurrentContextConfig().getProperty(propertyName);
60  		}
61  		return paramValue;
62  	}
63  
64  }