001    /**
002     * Copyright (c) 2000-present 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.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    /**
030     * @author     Brian Wing Shun Chan
031     * @author     Michael Young
032     * @deprecated As of 7.0.0, with no direct replacement
033     */
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    }