{
SiteNodeVersionVO snvVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(new Integer(entityId));
siteNodeId = ""+snvVO.getSiteNodeId();
if(repositoryId == null)
{
SiteNodeVO snVO = SiteNodeController.getController().getSiteNodeVOWithId(snvVO.getSiteNodeId());
repositoryId = ""+snVO.getRepositoryId();
parentSiteNodeId = ""+snVO.getParentSiteNodeId();
}
}
catch (Exception e2)
{
logger.info("Error getting siteNodeVersion " + entityId);
}
}
if(siteNodeId != null)
{
logger.info("Before flushGroup2...");
if(cacheName.equals("pageCacheExtra"))
{
PageCacheHelper.getInstance().notify("siteNode_" + siteNodeId);
//clearFileCacheForGroup(cacheInstance, "siteNode_" + siteNodeId);
}
else
{
cacheInstance.flushGroup("siteNode_" + siteNodeId);
cacheInstance.flushGroup("" + siteNodeId);
}
if(siteNodeId != null && (cacheName.equals("childSiteNodesCache") || cacheName.equals("childPagesCache") || cacheName.equals("siteNodeCache") || cacheName.equals("componentPropertyCacheRepoGroups") || cacheName.equals("componentPropertyVersionIdCacheRepoGroups")))
{
if(cacheName.equals("componentPropertyCacheRepoGroups") || cacheName.equals("componentPropertyVersionIdCacheRepoGroups"))
{
cacheInstance.flushGroup("" + repositoryId);
logger.info("Clearing componentPropertyCacheRepoGroups for repo:" + repositoryId);
}
if(parentSiteNodeId != null)
{
cacheInstance.flushGroup("siteNode_" + parentSiteNodeId);
cacheInstance.flushGroup("" + parentSiteNodeId);
cacheInstance.flushEntry("" + parentSiteNodeId);
logger.info("Clearing for:" + parentSiteNodeId);
}
}
logger.info("After flushGroup2...");
}
}
catch(Exception se)
{
logger.warn("Missing siteNode version: " + se.getMessage(), se);
}
}
else
{
try
{
if((cacheName.equals("childSiteNodesCache") || cacheName.equals("childPagesCache") || cacheName.equals("siteNodeCache") || cacheName.equals("componentPropertyCacheRepoGroups") || cacheName.equals("componentPropertyVersionIdCacheRepoGroups")))
{
SiteNodeVersionVO snvVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(new Integer(entityId));
SiteNodeVO snVO = SiteNodeController.getController().getSiteNodeVOWithId(snvVO.getSiteNodeId());
Integer repositoryId = snVO.getRepositoryId();
Integer parentSiteNodeId = snVO.getParentSiteNodeId();
if(cacheName.equals("componentPropertyCacheRepoGroups") || cacheName.equals("componentPropertyVersionIdCacheRepoGroups"))
{
cacheInstance.flushGroup("" + repositoryId);
logger.info("Clearing componentPropertyCacheRepoGroups for repo:" + repositoryId);
}
if(parentSiteNodeId != null)
{
cacheInstance.flushGroup("siteNode_" + parentSiteNodeId);
cacheInstance.flushGroup("" + parentSiteNodeId);
cacheInstance.flushEntry("" + parentSiteNodeId);
logger.info("Clearing for:" + parentSiteNodeId);
}
}
}
catch (Exception e2)
{
logger.error("Problem clearing cache for site node version:" + e2.getMessage(), e2);
}
}
}
else if(selectiveCacheUpdate && (entity.indexOf("SiteNode") > 0 && entity.indexOf("SiteNodeTypeDefinition") == -1) && useSelectivePageCacheUpdate)
{
//System.out.println("Entity: " + entity);
logger.info("Flushing " + "" + entityId);
logger.info("Flushing " + "siteNode_" + entityId);
logger.info("Flushing " + "selectiveCacheUpdateNonApplicable");
if(cacheName.equals("pageCacheExtra"))
{
PageCacheHelper.getInstance().notify("siteNode_" + entityId);
PageCacheHelper.getInstance().notify("selectiveCacheUpdateNonApplicable");
//clearFileCacheForGroup(cacheInstance, "siteNode_" + entityId);
//clearFileCacheForGroup(cacheInstance, "selectiveCacheUpdateNonApplicable");
}
else
{
cacheInstance.flushEntry("" + entityId);
cacheInstance.flushGroup("" + entityId);
cacheInstance.flushGroup("siteNode_" + entityId);
cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable");
if(cacheName.equals("childSiteNodesCache") || cacheName.equals("childPagesCache") || cacheName.equals("siteNodeCache") || cacheName.equals("componentPropertyCacheRepoGroups") || cacheName.equals("componentPropertyVersionIdCacheRepoGroups"))
{
logger.info("Flushing parent also");
String repositoryId = sentRepositoryId;
String parentSiteNodeId = sentParentSiteNodeId;
try
{
if(repositoryId == null)
{
SiteNodeVO snVO = SiteNodeController.getController().getSiteNodeVOWithId(new Integer(entityId));
if(snVO != null)
{
repositoryId = "" + snVO.getRepositoryId();
parentSiteNodeId = "" + snVO.getParentSiteNodeId();
}
}
if(cacheName.equals("componentPropertyCacheRepoGroups") || cacheName.equals("componentPropertyVersionIdCacheRepoGroups"))
{
cacheInstance.flushGroup("" + repositoryId);
logger.info("Clearing componentPropertyCacheRepoGroups for repo:" + repositoryId);
}
if(parentSiteNodeId != null && !parentSiteNodeId.equals(""))
{
logger.info("Flushing " + "" + entityId);
logger.info("Flushing " + "siteNode_" + entityId);
cacheInstance.flushGroup("siteNode_" + parentSiteNodeId);
cacheInstance.flushGroup("" + parentSiteNodeId);
cacheInstance.flushEntry("" + parentSiteNodeId);
logger.info("Clearing for:" + parentSiteNodeId);
}
}
catch(SystemException se)
{
logger.warn("Missing siteNode: " + se.getMessage(), se);
}
}
}
logger.info("clearing " + e.getKey() + " with group " + "siteNode_" + entityId);
}
else if(selectiveCacheUpdate && entity.indexOf("ContentVersion") > 0 && useSelectivePageCacheUpdate)
{
//t.printElapsedTime("CV start....");
logger.info("ContentVersion entity was sent: " + entity + ":" + entityId + " and cacheName:" + cacheName);
logger.info("Getting eventListeners...");
//Object cacheEntryEventListener = eventListeners.get(e.getKey() + "_cacheEntryEventListener");
//Object cacheMapAccessEventListener = eventListeners.get(e.getKey() + "_cacheMapAccessEventListener");
//System.out.println("entity:" + entity);
//System.out.println("Before flushGroup:" +cacheName);
logger.info("Before flushGroup...");
if(cacheName.equals("pageCacheExtra"))
{
//clearFileCacheForGroup(cacheInstance, "contentVersion_" + entityId);
//clearFileCacheForGroup(cacheInstance, "selectiveCacheUpdateNonApplicable");
}
else if(cacheName.equals("pageCache"))
{
logger.info("Skipping clearing pageCache for version");
//cacheInstance.flushGroup("contentVersion_" + entityId);
//cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable");
}
else if(cacheName.equals("componentPropertyCacheRepoGroups") || cacheName.equals("componentPropertyVersionIdCacheRepoGroups"))
{
Timer t2 = new Timer();
try
{
String repositoryId = sentRepositoryId;
if(repositoryId == null)
{
String contentId = sentContentId;
if(contentId == null)
contentId = "" + ContentVersionController.getContentVersionController().getContentIdForContentVersion(new Integer(entityId));
ContentVO contentVO = ContentController.getContentController().getContentVOWithId(new Integer(contentId));
repositoryId = "" + contentVO.getRepositoryId();
}
cacheInstance.flushGroup("" + repositoryId);
//t2.printElapsedTime("3");
if(cacheName.equals("componentPropertyVersionIdCacheRepoGroups"))
cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable");
//t2.printElapsedTime("4");
logger.info("Clearing componentPropertyCacheRepoGroups for repo:" +repositoryId);
}
catch (Exception e2)
{
logger.info("Error loading content with id " + entityId + ":" + e2.getMessage());
}
//t.printElapsedTime("componentPropertyCacheRepoGroups");
}
else if(cacheName.equals("assetUrlCacheWithGroups"))
{
try
{
String contentId = sentContentId;
if(contentId == null || contentId.equals(""))
contentId = ""+ContentVersionController.getContentVersionController().getContentIdForContentVersion(new Integer(entityId));
cacheInstance.flushGroup("content_" + contentId);
logger.info("Clearing assetUrlCacheWithGroups for content:" + "content_" + contentId);
}
catch (Exception e2)
{
logger.warn("Flushing assetUrlCacheWithGroups as it was a missing entity - was probably a delete");
cacheInstance.flushAll();
}
//t.printElapsedTime("assetUrlCacheWithGroups");
}
else if(cacheName.equals("childPagesCache") || cacheName.equals("childSiteNodesCache"))
{
//System.out.println("childPagesCache:" + entity + "=" + entityId);
//t.printElapsedTime("childPagesCache start");
try
{
String contentId = sentContentId;
//System.out.println("sentContentId:" + sentContentId);
if(contentId == null || contentId.equals(""))
contentId = ""+ContentVersionController.getContentVersionController().getContentIdForContentVersion(new Integer(entityId));
//System.out.println("contentId:" + contentId);
//t.printElapsedTime("childPagesCache A");
ContentTypeDefinitionVO metaInfoContentTypeDefinitionVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName("Meta info");
//t.printElapsedTime("childPagesCache B");
ContentVO contentVO = ContentController.getContentController().getContentVOWithId(new Integer(contentId));
//t.printElapsedTime("childPagesCache C");
if(metaInfoContentTypeDefinitionVO.getId().equals(contentVO.getContentTypeDefinitionId()))
{
try
{
SiteNodeVO siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithMetaInfoContentId(new Integer(contentId));
//t.printElapsedTime("childPagesCache getSiteNodeVOWithMetaInfoContentId");
if(siteNodeVO != null)
{
cacheInstance.flushGroup("siteNode_" + siteNodeVO.getId());
cacheInstance.flushGroup("siteNode_" + siteNodeVO.getParentSiteNodeId());
}
}
catch (Exception e2)
{
logger.error("Did not find a sitenode with this meta info:" + contentId);