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.apache.commons.lang.text.StrLookup;
20 import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator;
21 import org.kuali.rice.core.api.config.property.ConfigContext;
22 import org.kuali.rice.coreservice.api.parameter.ParameterKey;
23 import org.kuali.rice.coreservice.framework.CoreFrameworkServiceLocator;
24 import org.kuali.rice.kew.api.KewApiConstants;
25 import org.kuali.rice.krad.util.KRADConstants;
26
27
28
29
30
31
32 public class ConfigStringLookup extends StrLookup {
33
34 private final String applicationId;
35
36 public ConfigStringLookup() {
37 this(null);
38 }
39
40 public ConfigStringLookup(String applicationId) {
41 this.applicationId = applicationId;
42 }
43
44 @Override
45 public String lookup(String propertyName) {
46 if (StringUtils.isBlank(propertyName)) {
47 return null;
48 }
49
50 String paramValue = null;
51
52 if (StringUtils.isBlank(applicationId)) {
53 paramValue = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(
54 KewApiConstants.KEW_NAMESPACE, KRADConstants.DetailTypes.ALL_DETAIL_TYPE, propertyName);
55 } else {
56 ParameterKey parameterKey = ParameterKey.create(applicationId, KewApiConstants.KEW_NAMESPACE,
57 KRADConstants.DetailTypes.ALL_DETAIL_TYPE, propertyName);
58 paramValue = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameterValueAsString(parameterKey);
59 }
60
61 if (paramValue == null) {
62 paramValue = ConfigContext.getCurrentContextConfig().getProperty(propertyName);
63 }
64 return paramValue;
65 }
66
67 }