001
014
015 package com.liferay.portlet.calendar.service.impl;
016
017 import com.liferay.portal.kernel.cache.MultiVMPoolUtil;
018 import com.liferay.portal.kernel.cache.PortalCache;
019 import com.liferay.portal.kernel.util.StringPool;
020 import com.liferay.portal.kernel.util.StringUtil;
021 import com.liferay.portlet.calendar.model.CalEvent;
022
023 import java.io.Serializable;
024
025 import java.util.List;
026 import java.util.Map;
027 import java.util.concurrent.ConcurrentHashMap;
028
029
034 @Deprecated
035 public class CalEventLocalUtil {
036
037 protected static void clearEventsPool(long groupId) {
038 String key = _encodeKey(groupId);
039
040 _portalCache.remove(key);
041 }
042
043 protected static Map<String, List<CalEvent>> getEventsPool(long groupId) {
044 String key = _encodeKey(groupId);
045
046 Map<String, List<CalEvent>> eventsPool =
047 (ConcurrentHashMap<String, List<CalEvent>>)_portalCache.get(key);
048
049 if (eventsPool == null) {
050 eventsPool = new ConcurrentHashMap<>();
051
052 _portalCache.put(key, (Serializable)eventsPool);
053 }
054
055 return eventsPool;
056 }
057
058 private static String _encodeKey(long groupId) {
059 return _CACHE_NAME.concat(StringPool.POUND).concat(
060 StringUtil.toHexString(groupId));
061 }
062
063 private static final String _CACHE_NAME = CalEventLocalUtil.class.getName();
064
065 private static final PortalCache<String, Serializable> _portalCache =
066 MultiVMPoolUtil.getPortalCache(_CACHE_NAME);
067
068 }