View Javadoc
1   /**
2    * Copyright 2005-2015 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.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   * This is a description of what this class does - jjhanso don't forget to fill this in. 
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   *
31   * @deprecated KNS Struts deprecated, use KRAD and the Spring MVC framework.
32   */
33  @Deprecated
34  public class KualiPropertyMessageResources extends PropertyMessageResources {
35      private static final long serialVersionUID = -7712311580595112293L;
36      private HashMap kualiMessages;
37  
38      public KualiPropertyMessageResources(MessageResourcesFactory factory, String config) {
39          super(factory, config);
40      }
41  
42      public KualiPropertyMessageResources(MessageResourcesFactory factory, String config, boolean returnNull) {
43          super(factory, config, returnNull);
44      }
45  
46      protected void loadLocale(String localeKey) {
47          String initialConfig = config;
48          String[] propertyFiles = config.split(",");
49          for (String propertyFile : propertyFiles) {
50              config = propertyFile;
51              locales.remove(localeKey);
52              super.loadLocale(localeKey);
53          }
54          config = initialConfig;
55      }
56      
57      public Map getKualiProperties(String localeKey) {
58          if (this.kualiMessages != null && !this.kualiMessages.isEmpty()) {
59              return this.kualiMessages;
60          } 
61          localeKey = (localeKey == null) ? "" : localeKey;
62          String localePrefix = localeKey + ".";
63          
64          this.loadLocale((localeKey == null) ? "" : localeKey);
65          this.kualiMessages = new HashMap(this.messages.size());
66          Set<String> keys = this.messages.keySet();
67          for (String key : keys) {
68              this.kualiMessages.put(StringUtils.substringAfter(key, localePrefix), this.messages.get(key));
69          }
70          return this.kualiMessages;
71      }
72  
73  }