PageCacheHelper.getInstance().notify("content_" + contentId);
//clearFileCacheForGroup(cacheInstance, "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
if((changes == null || changes.size() == 0) && CmsPropertyHandler.getOperatingMode().equals("3"))
{
ContentVersionVO oldContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(new Integer(entityId));
ContentVersionVO newContentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentId, oldContentVersionVO.getLanguageId(), new Integer(CmsPropertyHandler.getOperatingMode()));
if(newContentVersionVO != null && oldContentVersionVO != null && newContentVersionVO.getId().equals(oldContentVersionVO.getId()))
{
oldContentVersionVO = null;
//System.out.println("SHIT - same version allready - must find other");
List<SmallestContentVersionVO> contentVersionVOList = ContentVersionController.getContentVersionController().getSmallestContentVersionVOList(new Integer(contentId));
for(SmallestContentVersionVO cvVO : contentVersionVOList)
{
if(!cvVO.getId().equals(newContentVersionVO.getId()) && cvVO.getStateId().equals(new Integer(CmsPropertyHandler.getOperatingMode())) && cvVO.getLanguageId().equals(newContentVersionVO.getLanguageId()) && cvVO.getIsActive() && (oldContentVersionVO == null || oldContentVersionVO.getId() < cvVO.getId()))
{
oldContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(cvVO.getId());
}
}
}
//System.out.println("Now we should have current and previous version:" + newContentVersionVO + " / " + oldContentVersionVO);
if(newContentVersionVO != null && oldContentVersionVO != null)
changes = ContentVersionController.getContentVersionController().getChangedAttributeNames(newContentVersionVO, oldContentVersionVO);
}
//System.out.println("changes:" + changes);
for(String changedAttributeName : changes)
{
if(changedAttributeName.indexOf("ComponentStructure") > -1)
{
//Map allreadyFlushedEntries....
Set<String> groupEntries = (Set<String>)cacheInstance.getCache().cacheMap.getGroup("content_" + contentId + "_ComponentStructureDependency");
//System.out.println("groupEntries:" + groupEntries);
if(groupEntries != null)
{
System.out.println("groupEntries:" + groupEntries.size());
outer:for(String key : groupEntries)
{
//System.out.println("key 1:" + key);
try
{
//String[] usedEntities = (String[])cacheInstance.getFromCache(key + "_entities");
byte[] usedEntitiesByteArray = (byte[])cacheInstance.getFromCache(key + "_entitiesAsByte");
String usedEntitiesString = compressionHelper.decompress(usedEntitiesByteArray);
//t.printElapsedTime("Decompress to " + usedEntitiesString.length() + " took");
String[] usedEntities = StringUtils.split(usedEntitiesString, "|");
//t.printElapsedTime("Split to usedEntities " + usedEntities.length + " took");
ContentVersionVO newContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(new Integer(entityId));
String newComponentStructure = ContentVersionController.getContentVersionController().getAttributeValue(newContentVersionVO, "ComponentStructure", false);
for(String usedEntity : usedEntities)
{
//System.out.println("usedEntity:" + usedEntity);
if(usedEntity.startsWith("content_" + contentId + "_ComponentStructure("))
{
//System.out.println("Match - now lets parse: " + usedEntity);
String arguments = usedEntity.substring(usedEntity.indexOf("(") + 1, usedEntity.indexOf(")"));
Integer oldComponentPropertyHash = new Integer(usedEntity.substring(usedEntity.indexOf("=") + 1));
String[] args = arguments.split(",");
Integer componentId = new Integer(args[0]);
String propertyName = args[1];
Integer siteNodeId = new Integer(args[2]);
Integer languageId = new Integer(args[3]);
//System.out.println("componentId:" + componentId);
//System.out.println("propertyName:" + propertyName);
//System.out.println("siteNodeId:" + siteNodeId);
//System.out.println("languageId:" + languageId);
int newComponentPropertyHash = getPropertyAsStringHashCode(newComponentStructure, componentId, propertyName, siteNodeId, languageId);
//System.out.println("oldComponentPropertyHash:" + oldComponentPropertyHash);
//System.out.println("newComponentPropertyHash:" + newComponentPropertyHash);
if(oldComponentPropertyHash.intValue() != newComponentPropertyHash)
{
//System.out.println("Yes - clearing - must have changed something important:" + usedEntity);
PageCacheHelper.getInstance().notify(usedEntity);
//clearFileCacheForGroup(cacheInstance, usedEntity);
}
else
{
//System.out.println("Flushing content_" + currentPageMetaInfoContentId + "_ComponentStructure just to catch page itself");
//cacheInstance.flushGroup("content_" + currentPageMetaInfoContentId + "_ComponentStructure");
//System.out.println("Flushing content_" + contentId + "_ComponentStructure just to catch page itself");
//cacheInstance.flushGroup("content_" + contentId + "_ComponentStructure");
}
}
else if(usedEntity.startsWith("content_" + contentId + "_ComponentStructure:"))
{
//System.out.println("Match - now lets parse component order etc: " + usedEntity);
String xPath = usedEntity.substring(usedEntity.indexOf(":") + 1, usedEntity.lastIndexOf("="));
Integer oldComponentPropertyHash = new Integer(usedEntity.substring(usedEntity.lastIndexOf("=") + 1));
//System.out.println("xPath:" + xPath);
int newComponentPropertyHash = getComponentsAsStringHashCode(newComponentStructure, xPath);
//System.out.println("oldComponentPropertyHash:" + oldComponentPropertyHash);
//System.out.println("newComponentPropertyHash:" + newComponentPropertyHash);
if(oldComponentPropertyHash.intValue() != newComponentPropertyHash)
{
//System.out.println("Yes - clearing - must have changed order or added/subtracted components:" + usedEntity);
PageCacheHelper.getInstance().notify(usedEntity);
//clearFileCacheForGroup(cacheInstance, usedEntity);
}
}
}
}
catch (Exception ex)
{
//logger.error("Got error trying to update cache:" + ex.getMessage());
logger.warn("Got error trying to update cache:" + ex.getMessage(), ex);
//clearFileCacheForGroup(cacheInstance, "content_" + contentId + "_" + changedAttributeName);
//cacheInstance.flushGroup("content_" + contentId + "_" + changedAttributeName);
//logger.warn("Cleared pageCache for " + "content_" + contentId + "_" + changedAttributeName);
break outer;
}
}
}
}
else
{
PageCacheHelper.getInstance().notify("content_" + contentId + "_" + changedAttributeName);
//clearFileCacheForGroup(cacheInstance, "content_" + contentId + "_" + changedAttributeName);
//System.out.println("Cleared for " + "content_" + contentId + "_" + changedAttributeName);
}
}
//t.printElapsedTime("Handled page cache extra");
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Handled page cache extra", t.getElapsedTime());
//clearFileCacheForGroup(cacheInstance, "content_" + contentId);
}
else if(cacheName.equals("pageCache"))
{
//t.printElapsedTime("Page cache start");
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Page cache start", t.getElapsedTime());
logger.info("Flushing pageCache for content type def");
String contentTypeDefKey = "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentTypeDefinitionId;
cacheInstance.flushGroup(contentTypeDefKey);
//cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
//cacheInstance.flushGroup("content_" + contentVO.getId());
//System.out.println("Flushing:" + getPooledString(1, contentVO.getId()));
cacheInstance.flushGroup(getPooledString(1, new Integer(contentId)));
PageCacheHelper.getInstance().notify("content_" + contentId);
ContentVersionVO oldContentVersionVO = null;
ContentVersionVO newContentVersionVO = null;
String debug = "";
if((changes == null || changes.size() == 0) && CmsPropertyHandler.getOperatingMode().equals("3"))
{
debug += "entityId:" + entityId + "\n";
debug += "contentId:" + contentId + "\n";
oldContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(new Integer(entityId));
debug += "oldContentVersionVO:" + oldContentVersionVO.getId() + ":" + oldContentVersionVO.getLanguageId() + "\n";
debug += "oldContentVersionVO:" + CmsPropertyHandler.getOperatingMode() + "\n";
newContentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentId, oldContentVersionVO.getLanguageId(), new Integer(CmsPropertyHandler.getOperatingMode()));
debug += "newContentVersionVO:" + newContentVersionVO + "\n";
if(newContentVersionVO != null && oldContentVersionVO != null && newContentVersionVO.getId().equals(oldContentVersionVO.getId()))
{
debug += "newContentVersionVO:" + newContentVersionVO.getId() + "\n";
oldContentVersionVO = null;
debug += "SHIT - same version allready - must find other";
List<SmallestContentVersionVO> contentVersionVOList = ContentVersionController.getContentVersionController().getSmallestContentVersionVOList(new Integer(contentId));
for(SmallestContentVersionVO cvVO : contentVersionVOList)
{
if(!cvVO.getId().equals(newContentVersionVO.getId()) && cvVO.getStateId().equals(new Integer(CmsPropertyHandler.getOperatingMode())) && cvVO.getLanguageId().equals(newContentVersionVO.getLanguageId()) && cvVO.getIsActive() && (oldContentVersionVO == null || oldContentVersionVO.getId() < cvVO.getId()))
{
oldContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(cvVO.getId());
}
}
debug += "oldContentVersionVO:" + (oldContentVersionVO == null ? "null" : oldContentVersionVO.getId()) + "\n";
}
//System.out.println("Now we should have current and previous version:" + newContentVersionVO + " / " + oldContentVersionVO);
if(newContentVersionVO != null && oldContentVersionVO != null)
changes = ContentVersionController.getContentVersionController().getChangedAttributeNames(newContentVersionVO, oldContentVersionVO);
}
//t.printElapsedTime("Changes analyzed");
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Changes analyzed", t.getElapsedTime());
if((changes == null || changes.size() == 0) && CmsPropertyHandler.getOperatingMode().equals("3"))
{
if(oldContentVersionVO == null || newContentVersionVO == null)
{
//Hur kan det bli detta????
logger.warn("Fishy 1: " + oldContentVersionVO + ":" + newContentVersionVO + " in " + CmsPropertyHandler.getContextRootPath());
logger.warn("DEBUG: " + debug);
}
else
{
logger.warn("Fishy 2: No changes found between content versions " + newContentVersionVO.getId() + " and " + oldContentVersionVO.getId() + " in " + CmsPropertyHandler.getContextRootPath());
logger.warn("DEBUG: " + debug);
logger.warn("Fishy: newContentVersionVO: " + newContentVersionVO.getVersionValue());
logger.warn("Fishy: newContentVersionVO: " + oldContentVersionVO.getVersionValue());
}
logger.warn("Just to make sure pages are updated we pretend all attributes changed until we find the bug");
changes = ContentVersionController.getContentVersionController().getAttributeNames(newContentVersionVO);
}
//System.out.println("changes:" + changes);
for(String changedAttributeName : changes)
{
logger.warn("changedAttributeName: " + changedAttributeName);
if(changedAttributeName.indexOf("ComponentStructure") > -1 && cacheName.equals("pageCache"))
{
//Map allreadyFlushedEntries....
//It's something wrong here..
GeneralCacheAdministrator pageCacheExtraInstance = (GeneralCacheAdministrator)caches.get("pageCacheExtra");
String cacheGroupKey = "content_" + contentId + "_ComponentStructureDependency";
//Set<String> groupEntries = (Set<String>)cacheInstance.getCache().cacheMap.getGroup("content_" + contentId + "_ComponentStructureDependency");
Set<String> groupEntries = (Set<String>)cacheInstance.getCache().cacheMap.getGroup(getPooledString(cacheGroupKey.hashCode()));
//System.out.println("groupEntries:" + groupEntries);
if(groupEntries != null)
{
outer:for(String key : groupEntries)
{
logger.info("key 2:" + key);
try
{
//String[] usedEntities = (String[])pageCacheExtraInstance.getFromCache(key + "_entities");
byte[] usedEntitiesByteArray = (byte[])pageCacheExtraInstance.getFromCache(key + "_entitiesAsByte");
String usedEntitiesString = compressionHelper.decompress(usedEntitiesByteArray);
//t.printElapsedTime("Decompress to " + usedEntitiesString.length() + " took");
String[] usedEntities = StringUtils.split(usedEntitiesString, ",");
//t.printElapsedTime("Split to usedEntities " + usedEntities.length + " took");
ContentVersionVO newestContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(new Integer(entityId));
String newComponentStructure = ContentVersionController.getContentVersionController().getAttributeValue(newestContentVersionVO, "ComponentStructure", false);
for(String usedEntity : usedEntities)
{
//System.out.println("usedEntity:" + usedEntity);
if(usedEntity.startsWith("content_" + contentId + "_ComponentStructure("))
{
//System.out.println("Match - now lets parse: " + usedEntity);
String arguments = usedEntity.substring(usedEntity.indexOf("(") + 1, usedEntity.indexOf(")"));
Integer oldComponentPropertyHash = new Integer(usedEntity.substring(usedEntity.indexOf("=") + 1));
String[] args = arguments.split(",");
Integer componentId = new Integer(args[0]);
String propertyName = args[1];
Integer siteNodeId = new Integer(args[2]);
Integer languageId = new Integer(args[3]);
//System.out.println("componentId:" + componentId);
//System.out.println("propertyName:" + propertyName);
//System.out.println("siteNodeId:" + siteNodeId);
//System.out.println("languageId:" + languageId);
int newComponentPropertyHash = getPropertyAsStringHashCode(newComponentStructure, componentId, propertyName, siteNodeId, languageId);
//System.out.println("oldComponentPropertyHash:" + oldComponentPropertyHash);
//System.out.println("newComponentPropertyHash:" + newComponentPropertyHash);
if(oldComponentPropertyHash.intValue() != newComponentPropertyHash)
{
//System.out.println("Yes - clearing - must have changed something important:" + usedEntity);
//cacheInstance.flushGroup(usedEntity);
cacheInstance.flushGroup(getPooledString(usedEntity.hashCode()));
//clearFileCacheForGroup(cacheInstance, usedEntity);
}
else
{
//System.out.println("Flushing content_" + currentPageMetaInfoContentId + "_ComponentStructure just to catch page itself");
//cacheInstance.flushGroup("content_" + currentPageMetaInfoContentId + "_ComponentStructure");
//System.out.println("Flushing content_" + contentId + "_ComponentStructure just to catch page itself");
String componentStructureKey = "content_" + contentId + "_ComponentStructure";
//cacheInstance.flushGroup(componentStructureKey);
cacheInstance.flushGroup(getPooledString(componentStructureKey.hashCode()));
cacheInstance.flushGroup(getPooledString(usedEntity.hashCode()));
}
}
else if(usedEntity.startsWith("content_" + contentId + "_ComponentStructure:"))
{
//System.out.println("Match - now lets parse component order etc: " + usedEntity);
String xPath = usedEntity.substring(usedEntity.indexOf(":") + 1, usedEntity.lastIndexOf("="));
Integer oldComponentPropertyHash = new Integer(usedEntity.substring(usedEntity.lastIndexOf("=") + 1));
//System.out.println("xPath:" + xPath);
int newComponentPropertyHash = getComponentsAsStringHashCode(newComponentStructure, xPath);
//System.out.println("oldComponentPropertyHash:" + oldComponentPropertyHash);
//System.out.println("newComponentPropertyHash:" + newComponentPropertyHash);
if(oldComponentPropertyHash.intValue() != newComponentPropertyHash)
{
//System.out.println("Yes - clearing - must have changed order or added/subtracted components:" + usedEntity);
cacheInstance.flushGroup(getPooledString(usedEntity.hashCode()));
//cacheInstance.flushGroup(usedEntity);
}
}
}
}
catch(Exception ex)
{
//logger.error("Got error trying to update cache:" + ex.getMessage());
logger.warn("Got error trying to update cache:" + ex.getMessage(), ex);
try
{
String attributeKey = "content_" + contentId + "_" + changedAttributeName;
//cacheInstance.flushGroup(attributeKey);
cacheInstance.flushGroup(getPooledString(attributeKey.hashCode()));
logger.warn("Cleared pageCache for " + getPooledString(attributeKey.hashCode()));
}
catch(Exception ex2)
{
logger.error("Got error trying to flushGroup 2:" + ex2.getMessage());
cacheInstance.flushAll();
}
break outer;
}
t.printElapsedTime("Handled group entries");
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Handled group entries", t.getElapsedTime());
}
}
}
else
{
String attributeKey = "content_" + contentId + "_" + changedAttributeName;
//cacheInstance.flushGroup("content_" + contentId + "_" + changedAttributeName);
cacheInstance.flushGroup(getPooledString(attributeKey.hashCode()));
logger.info("Cleared pageCache for " + "content_" + contentId + "_" + changedAttributeName);
}
}
//cacheInstance.flushGroup("content_" + contentId);
}
else
{
String contentTypeDefKey = "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentTypeDefinitionId;
//cacheInstance.flushGroup(contentTypeDefKey);
cacheInstance.flushGroup(contentTypeDefKey);
//System.out.println("Cleared for " + "content_" + contentId + " on cache " + cacheName);
String contentKey = "content_" + contentId;
cacheInstance.flushGroup(contentKey);
//cacheInstance.flushGroup(contentKey);
}
//t.printElapsedTime("Handled page cache");
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Handled page cache", t.getElapsedTime());
logger.info("After flushGroup2...");
}
//}
if (cacheName.equals("contentVersionCache"))
{
new AssetUpdatingThread(entityId).start();
}
}
catch(SystemException se)
{
se.printStackTrace();
logger.info("Missing content version: " + se.getMessage());
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
else if(selectiveCacheUpdate && (entity.indexOf("Content") > 0 && entity.indexOf("ContentTypeDefinition") == -1 && entity.indexOf("ContentCategory") == -1) && useSelectivePageCacheUpdate)
{
logger.info("Content entity was sent: " + entity + ":" + entityId);
//System.out.println("Content entity was called and needs to be fixed:" + entity);
//String[] changedAttributes = new String[]{"Title","NavigationTitle"};
/*
ContentVO contentVO = null;
if(isObjectCachedInCastor(SmallContentImpl.class, new Integer(entityId)))
contentVO = ContentController.getContentController().getContentVOWithId(new Integer(entityId));
*/
String repositoryId = sentRepositoryId;
String contentTypeDefinitionId = sentContentTypeDefinitionId;
String contentIsProtected = sentContentIsProtected;
if(repositoryId == null || contentTypeDefinitionId == null || contentIsProtected == null)
{
//System.out.println("repositoryId:" + repositoryId);
//System.out.println("contentTypeDefinitionId:" + contentTypeDefinitionId);
//System.out.println("contentIsProtected:" + contentIsProtected);
try
{
ContentVO contentVO = ContentController.getContentController().getContentVOWithId(new Integer(entityId));
//t.printElapsedTime("clearCaches cv u1 contentVO", 10);
repositoryId = ""+contentVO.getRepositoryId();
contentTypeDefinitionId = ""+contentVO.getContentTypeDefinitionId();
contentIsProtected = ""+contentVO.getIsProtected();
}
catch (Exception e2)
{
logger.info("Error loading content with id " + entityId + ":" + e2.getMessage());
}
}
if(cacheName.equals("componentPropertyCacheRepoGroups") || cacheName.equals("componentPropertyVersionIdCacheRepoGroups"))
{
cacheInstance.flushGroup("" + repositoryId);
logger.info("Clearing componentPropertyCacheRepoGroups for repo:" + repositoryId);
}
if(cacheName.equals("pageCacheExtra"))
{
//clearFileCacheForGroup(cacheInstance, "content_" + entityId);
PageCacheHelper.getInstance().notify("content_" + entityId);
try
{
//cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
if(contentTypeDefinitionId != null)
{
//clearFileCacheForGroup(cacheInstance, "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
PageCacheHelper.getInstance().notify("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentTypeDefinitionId);
}
}
catch (Exception e2)
{
logger.warn("Could not find content type to clear pages based on: " + e2.getMessage(), e2);
}
}
else if(cacheName.equals("pageCache"))
{
logger.info("Flushing page cache for {" + entityId + "} and {content_" + entityId + "}");
String entityKey = "" + entityId;
String contentEntityKey = "content_" + entityId;
//cacheInstance.flushGroup("" + entityId);
//cacheInstance.flushGroup(contentEntityKey);
cacheInstance.flushGroup(entityKey);
cacheInstance.flushGroup(contentEntityKey);
try
{
if(contentTypeDefinitionId != null)
{
String contentTypeCacheKey = "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentTypeDefinitionId;
//cacheInstance.flushGroup(contentTypeCacheKey);
cacheInstance.flushGroup(contentTypeCacheKey);
}
}
catch (Exception e2)
{
logger.warn("Could not find content type to clear pages based on: " + e2.getMessage(), e2);
}
}
else
{
cacheInstance.flushGroup("" + entityId);
cacheInstance.flushGroup("content_" + entityId);
logger.info("clearing " + e.getKey() + " with selectiveCacheUpdateNonApplicable");
cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable");
if(contentTypeDefinitionId != null)
{
cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentTypeDefinitionId);
}
}
if(contentTypeDefinitionId != null)
{
//System.out.println("****************************************************************");
if(contentIsProtected.equals(""+ContentVO.YES.intValue()))
{
List<InterceptionPointVO> interceptionPointVOList = InterceptionPointController.getController().getInterceptionPointVOList("Content");
for(InterceptionPointVO interceptionPointVO : interceptionPointVOList)
{
if(interceptionPointVO.getName().endsWith(".Read"))
{
String acKey = "" + interceptionPointVO.getId() + "_" + entityId;
//System.out.println("Clearing access rights for:" + acKey);
CacheController.clearUserAccessCache(acKey);
}
}
}
}
//System.out.println("************************END************************************");
logger.info("clearing " + e.getKey() + " with group " + "content_" + entityId);
}
else if(selectiveCacheUpdate && entity.indexOf("DigitalAsset") > -1)
{
logger.info("Asset entity was sent: " + entity + ":" + entityId);
Integer contentId = assetContentIdMapping.get(new Integer(entityId));
if(contentId == null)
{
logger.info("Checking fot cv for asset:" + entityId);
List<SmallestContentVersionVO> contentVersions = DigitalAssetController.getContentVersionVOListConnectedToAssetWithId(new Integer(entityId));
if(contentVersions != null)
{
for(SmallestContentVersionVO contentVersionVO : contentVersions)
{
contentId = contentVersionVO.getContentId();
assetContentIdMapping.put(new Integer(entityId), contentId);
break;
}
}
}
else
logger.info("Using read asset");
//Integer contentId = null;
ContentVO contentVO = null;
try
{
contentVO = ContentController.getContentController().getContentVOWithId(contentId);
if(cacheName.equals("componentPropertyCacheRepoGroups") || cacheName.equals("componentPropertyVersionIdCacheRepoGroups"))
{
cacheInstance.flushGroup("" + contentVO.getRepositoryId());
logger.info("Clearing componentPropertyCacheRepoGroups for repo:" + contentVO.getRepositoryId());
}
}
catch (Exception e2)
{
logger.info("Error loading content with id " + contentId + ":" + e2.getMessage());
}
//ContentVO contentVO = ContentController.getContentController().getContentVOWithId(new Integer(entityId));
if(cacheName.equals("pageCacheExtra"))
{
//clearFileCacheForGroup(cacheInstance, "content_" + entityId);
PageCacheHelper.getInstance().notify("content_" + contentId);
try
{
//cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
if(contentVO != null)
{
//clearFileCacheForGroup(cacheInstance, "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
PageCacheHelper.getInstance().notify("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
}
}
catch (Exception e2)
{
logger.warn("Could not find content type to clear pages based on: " + e2.getMessage(), e2);
}
}
else if(cacheName.equals("pageCache"))
{
logger.info("Flushing page cache for {" + contentId + "} and {content_" + contentId + "}");
String entityKey = "" + contentId;
String contentEntityKey = "content_" + contentId;
//cacheInstance.flushGroup("" + entityId);
//cacheInstance.flushGroup(contentEntityKey);
cacheInstance.flushGroup(entityKey);
cacheInstance.flushGroup(contentEntityKey);
try
{
if(contentVO != null)
{
String contentTypeCacheKey = "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId();
//cacheInstance.flushGroup(contentTypeCacheKey);
cacheInstance.flushGroup(contentTypeCacheKey);
}
}
catch (Exception e2)
{
logger.warn("Could not find content type to clear pages based on: " + e2.getMessage(), e2);
}
}
else
{
cacheInstance.flushGroup("" + contentId);
cacheInstance.flushGroup("content_" + contentId);
logger.info("clearing " + e.getKey() + " with selectiveCacheUpdateNonApplicable");
cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable");
}
logger.info("clearing " + e.getKey() + " with group " + "content_" + entityId);
}
else if(selectiveCacheUpdate && entity.indexOf("Publication") > 0 && useSelectivePageCacheUpdate && (operatingMode != null && operatingMode.equalsIgnoreCase("3")) && CmsPropertyHandler.getLivePublicationThreadClass().equalsIgnoreCase("org.infoglue.deliver.util.SelectiveLivePublicationThread"))
{
logger.info("Now we will ease out the publication...");
/*
List publicationDetailVOList = PublicationController.getController().getPublicationDetailVOList(new Integer(entityId));
Iterator publicationDetailVOListIterator = publicationDetailVOList.iterator();
while(publicationDetailVOListIterator.hasNext())
{
PublicationDetailVO publicationDetailVO = (PublicationDetailVO)publicationDetailVOListIterator.next();
logger.info("publicationDetailVO.getEntityClass():" + publicationDetailVO.getEntityClass());
logger.info("publicationDetailVO.getEntityId():" + publicationDetailVO.getEntityId());
if(Class.forName(publicationDetailVO.getEntityClass()).getName().equals(ContentVersion.class.getName()))
{
logger.error("We clear all caches having references to contentVersion: " + publicationDetailVO.getEntityId());
Integer contentId = ContentVersionController.getContentVersionController().getContentIdForContentVersion(publicationDetailVO.getEntityId());
cacheInstance.flushGroup("content_" + contentId);
cacheInstance.flushGroup(CacheController.getPooledString(2, publicationDetailVO.getEntityId().toString()));
cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable");
logger.info("clearing " + e.getKey() + " with group " + "content_" + contentId);
logger.info("clearing " + e.getKey() + " with group " + "content_" + contentId);
}
else if(Class.forName(publicationDetailVO.getEntityClass()).getName().equals(SiteNodeVersion.class.getName()))
{
Integer siteNodeId = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(publicationDetailVO.getEntityId()).getSiteNodeId();
CacheController.clearCaches(publicationDetailVO.getEntityClass(), publicationDetailVO.getEntityId().toString(), null);
}
}
*/
}
else if(entity.equals("org.infoglue.cms.entities.management.impl.simple.AccessRightImpl"))
{
//System.out.println("This was an access right update - do we handle it:" + cacheName);
if(!CmsPropertyHandler.getOperatingMode().equalsIgnoreCase("3"))
{
try
{
AccessRightVO acVO = AccessRightController.getController().getAccessRightVOWithId(new Integer(entityId));
InterceptionPointVO icpVO = InterceptionPointController.getController().getInterceptionPointVOWithId(acVO.getInterceptionPointId());
//System.out.println("icpVO:" + icpVO.getName());
if(icpVO.getName().indexOf("Content.") > -1)
{
//System.out.println("Was a content access... let's clear caches for that content.");
String idAsString = acVO.getParameters();
if(idAsString != null && !idAsString.equals(""))
clearCaches("org.infoglue.cms.entities.content.impl.simple.ContentImpl", idAsString, null, cachesToSkip, forceClear);
}
else if(icpVO.getName().indexOf("ContentVersion.") > -1)
{
//System.out.println("Was a contentversion access... let's clear caches for that content.");
String idAsString = acVO.getParameters();
if(idAsString != null && !idAsString.equals(""))
clearCaches("org.infoglue.cms.entities.content.impl.simple.ContentVersionImpl", idAsString, null, cachesToSkip, forceClear);
}
else if(icpVO.getName().indexOf("SiteNode.") > -1)
{
//System.out.println("Was a sitenode access... let's clear caches for that content.");
String idAsString = acVO.getParameters();
if(idAsString != null && !idAsString.equals(""))
clearCaches("org.infoglue.cms.entities.structure.impl.simple.SiteNodeImpl", idAsString, null, cachesToSkip, forceClear);
}
else if(icpVO.getName().indexOf("SiteNodeVersion.") > -1)
{
//System.out.println("Was a sitenode version access... let's clear caches for that content.");
String idAsString = acVO.getParameters();
if(idAsString != null && !idAsString.equals(""))
clearCaches("org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl", idAsString, null, cachesToSkip, forceClear);
}
else
{
//System.out.println("****************************");
//System.out.println("* WHAT TO DO WITH IN CACHECONTROLLER: " + icpVO.getName() + " *");
//System.out.println("****************************");
}
}
catch(Exception e2)
{
logger.error("Error handling access right update: " + e2.getMessage(), e2);
}
}
else
logger.info("Skipping it as this is live mode..");
}
else if(selectiveCacheUpdate && (entity.indexOf("ServiceBinding") > 0 || entity.indexOf("Qualifyer") > 0))
{
logger.info("Ignoring this kind of notification... never used anymore:" + cacheName);
}
else if(entity.indexOf("AccessRightImpl") > -1)
{
logger.info("Ignoring handling of entity:" + entity);
}
else if(cacheName.equalsIgnoreCase("matchingContentsCache") && entity.indexOf("MediumContentCategoryImpl") > 0)
{
try
{
String contentId = sentContentId;
//if(contentId == null || contentId.equals(""))
ContentCategoryVO contentCategoryVO = ContentCategoryController.getController().findById(new Integer(entityId));
ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(contentCategoryVO.getContentVersionId());
ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentVersionVO.getContentId());
String contentTypeDefinitionId = "" + contentVO.getContentTypeDefinitionId();
cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentTypeDefinitionId);
cacheInstance.putInCache("recacheMark_" + contentTypeDefinitionId, "" + System.currentTimeMillis());
cacheInstance.putInCache("recacheMark", "" + System.currentTimeMillis());
}