001/**
002 * Copyright 2005-2016 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 */
016package org.kuali.rice.kns.util;
017
018import org.kuali.rice.core.framework.util.ApplicationThreadLocal;
019import org.kuali.rice.kns.web.struts.form.KualiForm;
020import org.kuali.rice.krad.util.GlobalVariables;
021
022/**
023 * @author Kuali Rice Team (rice.collab@kuali.org)
024 *
025 * @deprecated Only used in KNS classes, use KRAD.
026 */
027@Deprecated
028public final class KNSGlobalVariables {
029
030    private KNSGlobalVariables() {
031        throw new UnsupportedOperationException("do not call");
032    }
033
034    private static ThreadLocal<KualiForm> kualiForms = new ApplicationThreadLocal<KualiForm>();
035
036    private static ThreadLocal<MessageList> messageLists = new ApplicationThreadLocal<MessageList>() {
037        @Override
038        protected MessageList initialValue() {
039            return new MessageList();
040        }
041    };
042
043    /**
044     * @return ArrayList containing messages.
045     */
046    @Deprecated
047    public static MessageList getMessageList() {
048        return messageLists.get();
049    }
050
051    /**
052     * Sets a new message list
053     *
054     * @param messageList
055     */
056    @Deprecated
057    public static void setMessageList(MessageList messageList) {
058        messageLists.set(messageList);
059    }
060
061    /**
062     * @return KualiForm that has been assigned to this thread of execution.
063     */
064    @Deprecated
065    public static KualiForm getKualiForm() {
066        return kualiForms.get();
067    }
068
069    /**
070     * sets the kualiForm object into the global variable for this thread
071     *
072     * @param kualiForm
073     */
074    @Deprecated
075    public static void setKualiForm(KualiForm kualiForm) {
076        kualiForms.set(kualiForm);
077    }
078
079    @Deprecated
080    public static void clear() {
081        GlobalVariables.clear();
082        messageLists.set(new MessageList());
083        kualiForms.set(null);
084    }
085}