1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.web.struts.action;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.apache.struts.util.MessageResourcesFactory;
20 import org.apache.struts.util.PropertyMessageResources;
21
22 import java.util.HashMap;
23 import java.util.Map;
24 import java.util.Set;
25
26
27
28
29
30
31
32 public class KualiPropertyMessageResources extends PropertyMessageResources {
33 private static final long serialVersionUID = -7712311580595112293L;
34 private HashMap kualiMessages;
35
36 public KualiPropertyMessageResources(MessageResourcesFactory factory, String config) {
37 super(factory, config);
38 }
39
40 public KualiPropertyMessageResources(MessageResourcesFactory factory, String config, boolean returnNull) {
41 super(factory, config, returnNull);
42 }
43
44 protected void loadLocale(String localeKey) {
45 String initialConfig = config;
46 String[] propertyFiles = config.split(",");
47 for (String propertyFile : propertyFiles) {
48 config = propertyFile;
49 locales.remove(localeKey);
50 super.loadLocale(localeKey);
51 }
52 config = initialConfig;
53 }
54
55 public Map getKualiProperties(String localeKey) {
56 if (this.kualiMessages != null && !this.kualiMessages.isEmpty()) {
57 return this.kualiMessages;
58 }
59 localeKey = (localeKey == null) ? "" : localeKey;
60 String localePrefix = localeKey + ".";
61
62 this.loadLocale((localeKey == null) ? "" : localeKey);
63 this.kualiMessages = new HashMap(this.messages.size());
64 Set<String> keys = this.messages.keySet();
65 for (String key : keys) {
66 this.kualiMessages.put(StringUtils.substringAfter(key, localePrefix), this.messages.get(key));
67 }
68 return this.kualiMessages;
69 }
70
71 }