String pageKey = CacheController.getPageCacheKey(session, request, siteNodeId, languageId, contentId, userAgent, queryString, extra);
try
{
SiteNodeVersionVO latestSiteNodeVersionVO = getLatestActiveSiteNodeVersionVOForPageCache(db, siteNodeId);
Integer currentSiteNodeId = siteNodeId;
while(latestSiteNodeVersionVO == null || latestSiteNodeVersionVO.getPageCacheKey() == null || latestSiteNodeVersionVO.getPageCacheKey().length() == 0 || latestSiteNodeVersionVO.getPageCacheKey().equalsIgnoreCase("default"))
{
if(currentSiteNodeId == null)
break;
SiteNodeVO parentSiteNodeVO = getParentSiteNode(db, currentSiteNodeId);
if(parentSiteNodeVO != null)
{
latestSiteNodeVersionVO = getLatestActiveSiteNodeVersionVOForPageCache(db, parentSiteNodeVO.getId());
if(latestSiteNodeVersionVO != null)
currentSiteNodeId = latestSiteNodeVersionVO.getSiteNodeId();
else
currentSiteNodeId = null;
}
else
break;
}
if(latestSiteNodeVersionVO != null && latestSiteNodeVersionVO.getPageCacheKey() != null && latestSiteNodeVersionVO.getPageCacheKey().length() > 0 && !latestSiteNodeVersionVO.getPageCacheKey().equalsIgnoreCase("default"))
{
String originalRequestURL = request.getParameter("originalRequestURL");
if(originalRequestURL == null || originalRequestURL.length() == 0)
originalRequestURL = request.getRequestURL().toString();
pageKey = originalRequestURL + "_" + latestSiteNodeVersionVO.getPageCacheKey();
pageKey = pageKey.replaceAll("\\$siteNodeId", "" + siteNodeId);
pageKey = pageKey.replaceAll("\\$languageId", "" + languageId);
pageKey = pageKey.replaceAll("\\$contentId", "" + contentId);
pageKey = pageKey.replaceAll("\\$useragent", "" + userAgent);
pageKey = pageKey.replaceAll("\\$queryString", "" + queryString);