001    /**
002     * Copyright 2005-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.kns.util;
017    
018    import org.kuali.rice.core.framework.util.ApplicationThreadLocal;
019    import org.kuali.rice.kns.web.struts.form.KualiForm;
020    import org.kuali.rice.krad.util.GlobalVariables;
021    
022    import java.util.HashMap;
023    import java.util.Map;
024    
025    /**
026     * @author Kuali Rice Team (rice.collab@kuali.org)
027     */
028    @Deprecated
029    public final class KNSGlobalVariables {
030    
031        private KNSGlobalVariables() {
032            throw new UnsupportedOperationException("do not call");
033        }
034    
035        private static ThreadLocal<KualiForm> kualiForms = new ApplicationThreadLocal<KualiForm>();
036    
037        private static ThreadLocal<MessageList> messageLists = new ApplicationThreadLocal<MessageList>() {
038            @Override
039            protected MessageList initialValue() {
040                return new MessageList();
041            }
042        };
043    
044        private static ThreadLocal<HashMap<String, AuditCluster>> auditErrorMaps = new ApplicationThreadLocal<HashMap<String, AuditCluster>>() {
045            @Override
046            protected HashMap<String, AuditCluster> initialValue() {
047                    return new HashMap<String, AuditCluster>();
048            }
049        };
050    
051        /**
052         * @return ArrayList containing messages.
053         */
054        @Deprecated
055        public static MessageList getMessageList() {
056            return messageLists.get();
057        }
058    
059        /**
060         * Sets a new message list
061         *
062         * @param messageList
063         */
064        @Deprecated
065        public static void setMessageList(MessageList messageList) {
066            messageLists.set(messageList);
067        }
068    
069        /**
070         * @return KualiForm that has been assigned to this thread of execution.
071         */
072        @Deprecated
073        public static KualiForm getKualiForm() {
074            return kualiForms.get();
075        }
076    
077        /**
078         * @return ArrayList containing audit error messages.
079         */
080        @Deprecated
081        public static Map<String, AuditCluster> getAuditErrorMap() {
082            return auditErrorMaps.get();
083        }
084    
085        /**
086         * Sets a new (clean) AuditErrorList
087         *
088         * @param errorMap
089         */
090        @Deprecated
091        public static void setAuditErrorMap(HashMap<String, AuditCluster> errorMap) {
092            auditErrorMaps.set(errorMap);
093        }
094    
095        /**
096         * sets the kualiForm object into the global variable for this thread
097         *
098         * @param kualiForm
099         */
100        @Deprecated
101        public static void setKualiForm(KualiForm kualiForm) {
102            kualiForms.set(kualiForm);
103        }
104    
105        @Deprecated
106        public static void clear() {
107            GlobalVariables.clear();
108            messageLists.set(new MessageList());
109            auditErrorMaps.set(new HashMap<String, AuditCluster>());
110            kualiForms.set(null);
111        }
112    }