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
026 public class WebServerServletTokenImpl implements WebServerServletToken {
027
028 public void afterPropertiesSet() {
029 _portalCache = _multiVMPool.getCache(_CACHE_NAME);
030 }
031
032 public String getToken(long imageId) {
033 Long key = imageId;
034
035 String token = (String)_portalCache.get(key);
036
037 if (token == null) {
038 token = _createToken(imageId);
039
040 _portalCache.put(key, token);
041 }
042
043 return token;
044 }
045
046 public void resetToken(long imageId) {
047 _portalCache.remove(imageId);
048
049
050
051 JournalContentUtil.clearCache();
052
053
054
055 CacheUtil.clearCache();
056 }
057
058 public void setMultiVMPool(MultiVMPool multiVMPool) {
059 _multiVMPool = multiVMPool;
060 }
061
062 private String _createToken(long imageId) {
063 return String.valueOf(System.currentTimeMillis());
064 }
065
066 private static final String _CACHE_NAME =
067 WebServerServletToken.class.getName();
068
069 private MultiVMPool _multiVMPool;
070 private PortalCache _portalCache;
071
072 }