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