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 isLayoutStagingInProcess() {
051                    return _layoutStagingInProcess.get();
052            }
053    
054            public static boolean isLayoutValidationInProcess() {
055                    return _layoutValidationInProcess.get();
056            }
057    
058            public static boolean isPortletExportInProcess() {
059                    return _portletExportInProcess.get();
060            }
061    
062            public static boolean isPortletImportInProcess() {
063                    return _portletImportInProcess.get();
064            }
065    
066            public static boolean isPortletStagingInProcess() {
067                    return _portletStagingInProcess.get();
068            }
069    
070            public static boolean isPortletValidationInProcess() {
071                    return _portletValidationInProcess.get();
072            }
073    
074            public static boolean isStagingInProcess() {
075                    if (isLayoutStagingInProcess() || isPortletStagingInProcess()) {
076                            return true;
077                    }
078    
079                    return false;
080            }
081    
082            public static void setLayoutExportInProcess(boolean layoutExportInProcess) {
083                    _layoutExportInProcess.set(layoutExportInProcess);
084            }
085    
086            public static void setLayoutImportInProcess(boolean layoutImportInProcess) {
087                    _layoutImportInProcess.set(layoutImportInProcess);
088            }
089    
090            public static void setLayoutStagingInProcess(
091                    boolean layoutStagingInProcess) {
092    
093                    _layoutStagingInProcess.set(layoutStagingInProcess);
094            }
095    
096            public static void setLayoutValidationInProcess(
097                    boolean layoutValidationInProcess) {
098    
099                    _layoutValidationInProcess.set(layoutValidationInProcess);
100            }
101    
102            public static void setPortletExportInProcess(
103                    boolean portletExportInProcess) {
104    
105                    _portletExportInProcess.set(portletExportInProcess);
106            }
107    
108            public static void setPortletImportInProcess(
109                    boolean portletImportInProcess) {
110    
111                    _portletImportInProcess.set(portletImportInProcess);
112            }
113    
114            public static void setPortletStagingInProcess(
115                    boolean portletStagingInProcess) {
116    
117                    _portletStagingInProcess.set(portletStagingInProcess);
118            }
119    
120            public static void setPortletValidationInProcess(
121                    boolean portletValidationInProcess) {
122    
123                    _portletValidationInProcess.set(portletValidationInProcess);
124            }
125    
126            private static ThreadLocal<Boolean> _layoutExportInProcess =
127                    new AutoResetThreadLocal<Boolean>(
128                            ExportImportThreadLocal.class + "._layoutExportInProcess", false);
129            private static ThreadLocal<Boolean> _layoutImportInProcess =
130                    new AutoResetThreadLocal<Boolean>(
131                            ExportImportThreadLocal.class + "._layoutImportInProcess", false);
132            private static final ThreadLocal<Boolean> _layoutStagingInProcess =
133                    new AutoResetThreadLocal<Boolean>(
134                            ExportImportThreadLocal.class + "._layoutStagingInProcess", false);
135            private static final ThreadLocal<Boolean> _layoutValidationInProcess =
136                    new AutoResetThreadLocal<Boolean>(
137                            ExportImportThreadLocal.class + "._layoutValidationInProcess",
138                            false);
139            private static ThreadLocal<Boolean> _portletExportInProcess =
140                    new AutoResetThreadLocal<Boolean>(
141                            ExportImportThreadLocal.class + "._portletExportInProcess", false);
142            private static ThreadLocal<Boolean> _portletImportInProcess =
143                    new AutoResetThreadLocal<Boolean>(
144                            ExportImportThreadLocal.class + "._portletImportInProcess", false);
145            private static final ThreadLocal<Boolean> _portletStagingInProcess =
146                    new AutoResetThreadLocal<Boolean>(
147                            ExportImportThreadLocal.class + "._portletStagingInProcess", false);
148            private static final ThreadLocal<Boolean> _portletValidationInProcess =
149                    new AutoResetThreadLocal<Boolean>(
150                            ExportImportThreadLocal.class + "._portletValidationInProcess",
151                            false);
152    
153    }