* @return <code>true</code> if the cache is still valid, otherwise <code>false</code>
*/
public boolean isCacheValid(Object validity, String uid) {
ChannelState channelState = (ChannelState)channelStateMap.get(uid);
ChannelStaticData staticData = channelState.getStaticData();
ChannelRuntimeData runtimeData = channelState.getRuntimeData();
ChannelData cd = channelState.getChannelData();
PortletWindow pw = cd.getPortletWindow();
PortletEntity pe = pw.getPortletEntity();
PortletDefinition pd = pe.getPortletDefinition();
//Expiration based caching support for the portlet.
String portletSetExprCacheTime = cd.getExpirationCache();
String exprCacheTimeStr = pd.getExpirationCache();
try {
if (portletSetExprCacheTime != null)
exprCacheTimeStr = portletSetExprCacheTime;
int exprCacheTime = Integer.parseInt(exprCacheTimeStr);
if (exprCacheTime == 0) {
return false;
}
else if (exprCacheTime > 0) {
long lastRenderTime = cd.getLastRenderTime();
if ((lastRenderTime + (exprCacheTime * 1000)) < System.currentTimeMillis())
return false;
}
}
catch (Exception e) {
if (log.isWarnEnabled()) {
String portletId = staticData.getParameter(portletDefinitionIdParamName);
log.warn("Error parsing portlet expiration time (" + exprCacheTimeStr + ") for portlet (" + portletId + ").", e);
}
}
// Determine if the channel focus has changed
boolean previouslyFocused = cd.isFocused();
cd.setFocused(runtimeData.isRenderingAsRoot());
boolean focusHasSwitched = cd.isFocused() != previouslyFocused;
// Dirty cache only when we receive an event, one or more request params, or a change in focus
boolean cacheValid = !(cd.hasReceivedEvent() || runtimeData.isTargeted() || focusHasSwitched);
cd.setReceivedEvent(false);
return cacheValid;
}