001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.lar;
016    
017    import com.liferay.portal.kernel.util.AutoResetThreadLocal;
018    
019    /**
020     * @author Michael C. Han
021     */
022    public class ImportExportThreadLocal {
023    
024            public static boolean isExportInProcess() {
025                    if (isLayoutExportInProcess() || isPortletExportInProcess()) {
026                            return true;
027                    }
028    
029                    return false;
030            }
031    
032            public static boolean isImportInProcess() {
033                    if (isPortletImportInProcess() || isLayoutImportInProcess()) {
034                            return true;
035                    }
036    
037                    return false;
038            }
039    
040            public static boolean isLayoutExportInProcess() {
041                    return _layoutExportInProcess.get();
042            }
043    
044            public static boolean isLayoutImportInProcess() {
045                    return _layoutImportInProcess.get();
046            }
047    
048            public static boolean isPortletExportInProcess() {
049                    return _portletExportInProcess.get();
050            }
051    
052            public static boolean isPortletImportInProcess() {
053                    return _portletImportInProcess.get();
054            }
055    
056            public static void setLayoutExportInProcess(boolean inProcess) {
057                    _layoutExportInProcess.set(inProcess);
058            }
059    
060            public static void setLayoutImportInProcess(boolean inProcess) {
061                    _layoutImportInProcess.set(inProcess);
062            }
063    
064            public static void setPortletExportInProcess(boolean inProcess) {
065                    _portletExportInProcess.set(inProcess);
066            }
067    
068            public static void setPortletImportInProcess(boolean inProcess) {
069                    _portletImportInProcess.set(inProcess);
070            }
071    
072            private static ThreadLocal<Boolean> _layoutExportInProcess =
073                    new AutoResetThreadLocal<Boolean>(
074                            ImportExportThreadLocal.class + "._layoutExportInProcess", false);
075            private static ThreadLocal<Boolean> _layoutImportInProcess =
076                    new AutoResetThreadLocal<Boolean>(
077                            ImportExportThreadLocal.class + "._layoutImportInProcess", false);
078            private static ThreadLocal<Boolean> _portletExportInProcess =
079                    new AutoResetThreadLocal<Boolean>(
080                            ImportExportThreadLocal.class + "._portletExportInProcess", false);
081            private static ThreadLocal<Boolean> _portletImportInProcess =
082                    new AutoResetThreadLocal<Boolean>(
083                            ImportExportThreadLocal.class + "._portletImportInProcess", false);
084    
085    }