001
014
015 package com.liferay.portal.webserver;
016
017 import com.liferay.portal.kernel.cache.MultiVMPool;
018 import com.liferay.portal.kernel.cache.PortalCache;
019 import com.liferay.portal.servlet.filters.cache.CacheUtil;
020 import com.liferay.portlet.journalcontent.util.JournalContentUtil;
021
022
025 public class WebServerServletTokenImpl implements WebServerServletToken {
026
027 public void afterPropertiesSet() {
028 _portalCache = _multiVMPool.getCache(_CACHE_NAME);
029 }
030
031 public String getToken(long imageId) {
032 Long key = imageId;
033
034 String token = (String)_portalCache.get(key);
035
036 if (token == null) {
037 token = _createToken(imageId);
038
039 _portalCache.put(key, token);
040 }
041
042 return token;
043 }
044
045 public void resetToken(long imageId) {
046 _portalCache.remove(imageId);
047
048
049
050 JournalContentUtil.clearCache();
051
052
053
054 CacheUtil.clearCache();
055 }
056
057 public void setMultiVMPool(MultiVMPool multiVMPool) {
058 _multiVMPool = multiVMPool;
059 }
060
061 private String _createToken(long imageId) {
062 return String.valueOf(System.currentTimeMillis());
063 }
064
065 private static final String _CACHE_NAME =
066 WebServerServletToken.class.getName();
067
068 private MultiVMPool _multiVMPool;
069 private PortalCache _portalCache;
070
071 }