View Javadoc
1   /**
2    * Copyright 2005-2014 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.util;
17  
18  import org.kuali.rice.core.framework.util.ApplicationThreadLocal;
19  import org.kuali.rice.kns.web.struts.form.KualiForm;
20  import org.kuali.rice.krad.util.GlobalVariables;
21  
22  import java.util.HashMap;
23  import java.util.Map;
24  
25  /**
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   *
28   * @deprecated Only used in KNS classes, use KRAD.
29   */
30  @Deprecated
31  public final class KNSGlobalVariables {
32  
33      private KNSGlobalVariables() {
34          throw new UnsupportedOperationException("do not call");
35      }
36  
37      private static ThreadLocal<KualiForm> kualiForms = new ApplicationThreadLocal<KualiForm>();
38  
39      private static ThreadLocal<MessageList> messageLists = new ApplicationThreadLocal<MessageList>() {
40          @Override
41          protected MessageList initialValue() {
42              return new MessageList();
43          }
44      };
45  
46      private static ThreadLocal<HashMap<String, AuditCluster>> auditErrorMaps = new ApplicationThreadLocal<HashMap<String, AuditCluster>>() {
47      	@Override
48      	protected HashMap<String, AuditCluster> initialValue() {
49      		return new HashMap<String, AuditCluster>();
50      	}
51      };
52  
53      /**
54       * @return ArrayList containing messages.
55       */
56      @Deprecated
57      public static MessageList getMessageList() {
58          return messageLists.get();
59      }
60  
61      /**
62       * Sets a new message list
63       *
64       * @param messageList
65       */
66      @Deprecated
67      public static void setMessageList(MessageList messageList) {
68          messageLists.set(messageList);
69      }
70  
71      /**
72       * @return KualiForm that has been assigned to this thread of execution.
73       */
74      @Deprecated
75      public static KualiForm getKualiForm() {
76          return kualiForms.get();
77      }
78  
79      /**
80       * @return ArrayList containing audit error messages.
81       */
82      @Deprecated
83      public static Map<String, AuditCluster> getAuditErrorMap() {
84          return auditErrorMaps.get();
85      }
86  
87      /**
88       * Sets a new (clean) AuditErrorList
89       *
90       * @param errorMap
91       */
92      @Deprecated
93      public static void setAuditErrorMap(HashMap<String, AuditCluster> errorMap) {
94          auditErrorMaps.set(errorMap);
95      }
96  
97      /**
98       * sets the kualiForm object into the global variable for this thread
99       *
100      * @param kualiForm
101      */
102     @Deprecated
103     public static void setKualiForm(KualiForm kualiForm) {
104         kualiForms.set(kualiForm);
105     }
106 
107     @Deprecated
108     public static void clear() {
109         GlobalVariables.clear();
110         messageLists.set(new MessageList());
111         auditErrorMaps.set(new HashMap<String, AuditCluster>());
112         kualiForms.set(null);
113     }
114 }