View Javadoc

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