1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.rice.kew.util;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.core.api.config.property.ConfigStrLookup;
20  import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator;
21  import org.kuali.rice.coreservice.api.parameter.ParameterKey;
22  import org.kuali.rice.coreservice.framework.CoreFrameworkServiceLocator;
23  import org.kuali.rice.kew.api.KewApiConstants;
24  import org.kuali.rice.krad.util.KRADConstants;
25  
26  
27  
28  
29  
30  
31  
32  public class ParameterStrLookup extends ConfigStrLookup {
33  	
34  	private final String applicationId;
35  
36      
37  
38  
39  	public ParameterStrLookup() {
40          this(null);
41  	}
42  
43      
44  
45  
46  
47  
48  	public ParameterStrLookup(String applicationId) {
49  		this.applicationId = applicationId;
50  	}
51  
52      
53  
54  
55      @Override
56      public String lookup(String propertyName) {
57          if (StringUtils.isBlank(propertyName)) {
58              return null;
59          }
60  
61          String paramValue;
62  
63          
64          if (StringUtils.isBlank(applicationId)) {
65              paramValue = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(
66                      KewApiConstants.KEW_NAMESPACE, KRADConstants.DetailTypes.ALL_DETAIL_TYPE, propertyName);
67          } else {
68              ParameterKey parameterKey = ParameterKey.create(applicationId, KewApiConstants.KEW_NAMESPACE,
69                      KRADConstants.DetailTypes.ALL_DETAIL_TYPE, propertyName);
70              paramValue = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameterValueAsString(parameterKey);
71          }
72  
73          
74          if (paramValue == null) {
75              paramValue = super.lookup(propertyName);
76          }
77  
78          return paramValue;
79      }
80  
81  }