001
014
015 package com.liferay.portal.kernel.util;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.model.GroupConstants;
020
021
024 public class GroupThreadLocal {
025
026 public static Long getGroupId() {
027 Long groupId = _groupId.get();
028
029 if (_log.isDebugEnabled()) {
030 _log.debug("getGroupId " + groupId);
031 }
032
033 return groupId;
034 }
035
036 public static boolean isDeleteInProcess() {
037 return _deleteInProcess.get();
038 }
039
040 public static void setDeleteInProcess(boolean deleteInProcess) {
041 _deleteInProcess.set(deleteInProcess);
042 }
043
044 public static void setGroupId(Long groupId) {
045 if (_log.isDebugEnabled()) {
046 _log.debug("setGroupId " + groupId);
047 }
048
049 if (groupId > 0) {
050 _groupId.set(groupId);
051 }
052 else {
053 _groupId.set(GroupConstants.DEFAULT_LIVE_GROUP_ID);
054 }
055 }
056
057 private static Log _log = LogFactoryUtil.getLog(GroupThreadLocal.class);
058
059 private static ThreadLocal<Boolean> _deleteInProcess =
060 new AutoResetThreadLocal<Boolean>(
061 GroupThreadLocal.class + "._deleteInProcess", false);
062 private static ThreadLocal<Long> _groupId =
063 new AutoResetThreadLocal<Long>(
064 GroupThreadLocal.class + "._groupId",
065 GroupConstants.DEFAULT_LIVE_GROUP_ID);
066
067 }