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 ExportImportThreadLocal {
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 (isLayoutImportInProcess() || isLayoutValidationInProcess() ||
034                            isPortletImportInProcess() || isPortletValidationInProcess()) {
035    
036                            return true;
037                    }
038    
039                    return false;
040            }
041    
042            public static boolean isLayoutExportInProcess() {
043                    return _layoutExportInProcess.get();
044            }
045    
046            public static boolean isLayoutImportInProcess() {
047                    return _layoutImportInProcess.get();
048            }
049    
050            public static boolean isLayoutValidationInProcess() {
051                    return _layoutValidationInProcess.get();
052            }
053    
054            public static boolean isPortletExportInProcess() {
055                    return _portletExportInProcess.get();
056            }
057    
058            public static boolean isPortletImportInProcess() {
059                    return _portletImportInProcess.get();
060            }
061    
062            public static boolean isPortletValidationInProcess() {
063                    return _portletValidationInProcess.get();
064            }
065    
066            public static void setLayoutExportInProcess(boolean layoutExportInProcess) {
067                    _layoutExportInProcess.set(layoutExportInProcess);
068            }
069    
070            public static void setLayoutImportInProcess(boolean layoutImportInProcess) {
071                    _layoutImportInProcess.set(layoutImportInProcess);
072            }
073    
074            public static void setLayoutValidationInProcess(
075                    boolean layoutValidationInProcess) {
076    
077                    _layoutValidationInProcess.set(layoutValidationInProcess);
078            }
079    
080            public static void setPortletExportInProcess(
081                    boolean portletExportInProcess) {
082    
083                    _portletExportInProcess.set(portletExportInProcess);
084            }
085    
086            public static void setPortletImportInProcess(
087                    boolean portletImportInProcess) {
088    
089                    _portletImportInProcess.set(portletImportInProcess);
090            }
091    
092            public static void setPortletValidationInProcess(
093                    boolean portletValidationInProcess) {
094    
095                    _portletValidationInProcess.set(portletValidationInProcess);
096            }
097    
098            private static ThreadLocal<Boolean> _layoutExportInProcess =
099                    new AutoResetThreadLocal<Boolean>(
100                            ExportImportThreadLocal.class + "._layoutExportInProcess", false);
101            private static ThreadLocal<Boolean> _layoutImportInProcess =
102                    new AutoResetThreadLocal<Boolean>(
103                            ExportImportThreadLocal.class + "._layoutImportInProcess", false);
104            private static ThreadLocal<Boolean> _layoutValidationInProcess =
105                    new AutoResetThreadLocal<Boolean>(
106                            ExportImportThreadLocal.class + "._layoutValidationInProcess",
107                            false);
108            private static ThreadLocal<Boolean> _portletExportInProcess =
109                    new AutoResetThreadLocal<Boolean>(
110                            ExportImportThreadLocal.class + "._portletExportInProcess", false);
111            private static ThreadLocal<Boolean> _portletImportInProcess =
112                    new AutoResetThreadLocal<Boolean>(
113                            ExportImportThreadLocal.class + "._portletImportInProcess", false);
114            private static ThreadLocal<Boolean> _portletValidationInProcess =
115                    new AutoResetThreadLocal<Boolean>(
116                            ExportImportThreadLocal.class + "._portletValidationInProcess",
117                            false);
118    
119    }