try
{
Iterator cacheEvictionBeansIterator = cacheEvictionBeans.iterator();
while(cacheEvictionBeansIterator.hasNext())
{
CacheEvictionBean cacheEvictionBean = (CacheEvictionBean)cacheEvictionBeansIterator.next();
String className = cacheEvictionBean.getClassName();
if(className == null)
logger.error("No className in CacheEvictionBean");
if(cacheEvictionBean.getObjectName() == null)
logger.error("No objectName in CacheEvictionBean");
if(className.equalsIgnoreCase("ServerNodeProperties"))
{
if(processedServerNodeProperties || cacheEvictionBean.getObjectName().equals("MySettings"))
{
cacheEvictionBeansIterator.remove();
//logger.info("Removed one ServerNodeProperties update as it will be processed anyway in this eviction cycle");
}
else
{
processedServerNodeProperties = true;
}
}
}
}
catch (Exception e)
{
logger.error("Error in selective live publication thread. Could not process eviction beans part 1: " + e.getMessage(), e);
}
logger.info("cacheEvictionBeans.size:" + cacheEvictionBeans.size() + ":" + RequestAnalyser.getRequestAnalyser().getBlockRequests());
if(cacheEvictionBeans.size() > 0)
{
try
{
Timer t = new Timer();
logger.info("setting block");
RequestAnalyser.getRequestAnalyser().setBlockRequests(true);
//logger.info("cacheEvictionBeans:" + cacheEvictionBeans.size());
boolean accessRightsFlushed = false;
List<String> processedEntities = new ArrayList<String>();
Iterator i = cacheEvictionBeans.iterator();
while(i.hasNext())
{
CacheEvictionBean cacheEvictionBean = (CacheEvictionBean)i.next();
boolean processedInterupted = false;
boolean skipOriginalEntity = false;
try
{
RequestAnalyser.getRequestAnalyser().addOngoingPublications(cacheEvictionBean);
String className = cacheEvictionBean.getClassName();
String objectId = cacheEvictionBean.getObjectId();
String objectName = cacheEvictionBean.getObjectName();
String typeId = cacheEvictionBean.getTypeId();
List<Map<String,String>> allIGCacheCalls = new ArrayList<Map<String,String>>();
logger.info("className:" + className + " objectId:" + objectId + " objectName: " + objectName + " typeId: " + typeId);
if(className.indexOf("AccessRight") > -1)
{
logger.info("Special handling of access rights..");
if(!accessRightsFlushed)
{
CacheController.clearCache(AccessRightImpl.class);
CacheController.clearCache(AccessRightRoleImpl.class);
CacheController.clearCache(AccessRightGroupImpl.class);
CacheController.clearCache(AccessRightUserImpl.class);
CacheController.clearCache("personalAuthorizationCache");
accessRightsFlushed = true;
}
skipOriginalEntity = true;
try
{
AccessRightVO acVO = AccessRightController.getController().getAccessRightVOWithId(new Integer(objectId));
InterceptionPointVO icpVO = InterceptionPointController.getController().getInterceptionPointVOWithId(acVO.getInterceptionPointId());
if(!processedEntities.contains("" + icpVO.getCategory() + "_" + acVO.getParameters()))
{
logger.info("icpVO:" + icpVO.getName());
if(icpVO.getName().indexOf("Content.") > -1)
{
logger.info("Was a content access... let's clear caches for that content.");
String idAsString = acVO.getParameters();
if(idAsString != null && !idAsString.equals(""))
addCacheUpdateDirective("org.infoglue.cms.entities.content.impl.simple.ContentImpl", idAsString, allIGCacheCalls);
}
else if(icpVO.getName().indexOf("ContentVersion.") > -1)
{
logger.info("Was a contentversion access... let's clear caches for that content.");
String idAsString = acVO.getParameters();
if(idAsString != null && !idAsString.equals(""))
addCacheUpdateDirective("org.infoglue.cms.entities.content.impl.simple.ContentVersionImpl", idAsString, allIGCacheCalls);
}
else if(icpVO.getName().indexOf("SiteNode.") > -1)
{
logger.info("Was a sitenode access... let's clear caches for that content.");
String idAsString = acVO.getParameters();
if(idAsString != null && !idAsString.equals(""))
addCacheUpdateDirective("org.infoglue.cms.entities.structure.impl.simple.SiteNodeImpl", idAsString, allIGCacheCalls);
}
else if(icpVO.getName().indexOf("SiteNodeVersion.") > -1)
{
logger.info("Was a sitenode version access... let's clear caches for that content.");
String idAsString = acVO.getParameters();
if(idAsString != null && !idAsString.equals(""))
addCacheUpdateDirective("org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl", idAsString, allIGCacheCalls);
}
else
{
logger.info("****************************");
logger.info("* WHAT TO DO WITH: " + icpVO.getName() + " *");
logger.info("****************************");
}
logger.info("Feeling done with " + "" + icpVO.getCategory() + "_" + acVO.getParameters());
processedEntities.add("" + icpVO.getCategory() + "_" + acVO.getParameters());
}
else
logger.info("Allready processed " + icpVO.getCategory() + "_" + acVO.getParameters());
}
catch(Exception e2)
{
logger.warn("Error handling access right update: " + e2.getMessage());
}
}
boolean isDependsClass = false;
if(className != null && className.equalsIgnoreCase(PublicationDetailImpl.class.getName()))
isDependsClass = true;
if(!typeId.equalsIgnoreCase("" + NotificationMessage.SYSTEM))
{
//CacheController.clearCaches(className, objectId, null);
CacheController.setForcedCacheEvictionMode(true);
}
if(!skipOriginalEntity)
addCacheUpdateDirective(className, objectId, allIGCacheCalls);
logger.info("Updating className with id:" + className + ":" + objectId);
if(className != null && !typeId.equalsIgnoreCase("" + NotificationMessage.SYSTEM) && !skipOriginalEntity)
{
Class type = Class.forName(className);
if(!isDependsClass &&
className.equalsIgnoreCase(SystemUserImpl.class.getName()) ||
className.equalsIgnoreCase(RoleImpl.class.getName()) ||
className.equalsIgnoreCase(GroupImpl.class.getName()) ||
className.equalsIgnoreCase(SmallSystemUserImpl.class.getName()) ||
className.equalsIgnoreCase(SmallRoleImpl.class.getName()) ||
className.equalsIgnoreCase(SmallGroupImpl.class.getName()) ||
className.equalsIgnoreCase(SystemUserRoleImpl.class.getName()) ||
className.equalsIgnoreCase(SystemUserGroupImpl.class.getName()))
{
Object[] ids = {objectId};
CacheController.clearCache(type, ids);
}
else if(!isDependsClass)
{
Object[] ids = {new Integer(objectId)};
CacheController.clearCache(type, ids);
}
//If it's an contentVersion we should delete all images it might have generated from attributes.
if(Class.forName(className).getName().equals(ContentImpl.class.getName()))
{
logger.info("We clear all small contents as well " + objectId);
Class typesExtra = SmallContentImpl.class;
Object[] idsExtra = {new Integer(objectId)};
CacheController.clearCache(typesExtra, idsExtra);
logger.info("We clear all small contents as well " + objectId);
Class typesExtraSmallish = SmallishContentImpl.class;
Object[] idsExtraSmallish = {new Integer(objectId)};
CacheController.clearCache(typesExtraSmallish, idsExtraSmallish);
logger.info("We clear all medium contents as well " + objectId);
Class typesExtraMedium = MediumContentImpl.class;
Object[] idsExtraMedium = {new Integer(objectId)};
CacheController.clearCache(typesExtraMedium, idsExtraMedium);
}
if(Class.forName(className).getName().equals(ContentVersionImpl.class.getName()))
{
logger.info("We clear all small contents as well " + objectId);
Class typesExtra = SmallContentVersionImpl.class;
Object[] idsExtra = {new Integer(objectId)};
CacheController.clearCache(typesExtra, idsExtra);
logger.info("We clear all small contents as well " + objectId);
Class typesExtraSmallest = SmallestContentVersionImpl.class;
Object[] idsExtraSmallest = {new Integer(objectId)};
CacheController.clearCache(typesExtraSmallest, idsExtraSmallest);
}
else if(Class.forName(className).getName().equals(AvailableServiceBindingImpl.class.getName()))
{
Class typesExtra = SmallAvailableServiceBindingImpl.class;
Object[] idsExtra = {new Integer(objectId)};
CacheController.clearCache(typesExtra, idsExtra);
}
else if(Class.forName(className).getName().equals(SiteNodeImpl.class.getName()))
{
Class typesExtra = SmallSiteNodeImpl.class;
Object[] idsExtra = {new Integer(objectId)};
CacheController.clearCache(typesExtra, idsExtra);
}
else if(Class.forName(className).getName().equals(SiteNodeVersionImpl.class.getName()))
{
Class typesExtra = SmallSiteNodeVersionImpl.class;
Object[] idsExtra = {new Integer(objectId)};
CacheController.clearCache(typesExtra, idsExtra);
}
else if(Class.forName(className).getName().equals(DigitalAssetImpl.class.getName()))
{
CacheController.clearCache("digitalAssetCache");
Class typesExtra = SmallDigitalAssetImpl.class;
Object[] idsExtra = {new Integer(objectId)};
CacheController.clearCache(typesExtra, idsExtra);
Class typesExtraMedium = MediumDigitalAssetImpl.class;
Object[] idsExtraMedium = {new Integer(objectId)};
CacheController.clearCache(typesExtraMedium, idsExtraMedium);
String disableAssetDeletionInLiveThread = CmsPropertyHandler.getDisableAssetDeletionInLiveThread();
if(disableAssetDeletionInLiveThread != null && !disableAssetDeletionInLiveThread.equals("true"))
{
logger.info("We should delete all images with digitalAssetId " + objectId);
DigitalAssetDeliveryController.getDigitalAssetDeliveryController().deleteDigitalAssets(new Integer(objectId));
}
}
else if(Class.forName(className).getName().equals(MediumDigitalAssetImpl.class.getName()))
{
CacheController.clearCache("digitalAssetCache");
Class typesExtra = SmallDigitalAssetImpl.class;
Object[] idsExtra = {new Integer(objectId)};
CacheController.clearCache(typesExtra, idsExtra);
Class typesExtraMedium = DigitalAssetImpl.class;
Object[] idsExtraMedium = {new Integer(objectId)};
CacheController.clearCache(typesExtraMedium, idsExtraMedium);
String disableAssetDeletionInLiveThread = CmsPropertyHandler.getDisableAssetDeletionInLiveThread();
if(disableAssetDeletionInLiveThread != null && !disableAssetDeletionInLiveThread.equals("true"))
{
logger.info("We should delete all images with digitalAssetId " + objectId);
DigitalAssetDeliveryController.getDigitalAssetDeliveryController().deleteDigitalAssets(new Integer(objectId));
}
}
else if(Class.forName(className).getName().equals(SystemUserImpl.class.getName()))
{
Class typesExtra = SmallSystemUserImpl.class;
Object[] idsExtra = {objectId};
CacheController.clearCache(typesExtra, idsExtra);
}
else if(Class.forName(className).getName().equals(RoleImpl.class.getName()))
{
Class typesExtra = SmallRoleImpl.class;
Object[] idsExtra = {objectId};
CacheController.clearCache(typesExtra, idsExtra);
}
else if(Class.forName(className).getName().equals(GroupImpl.class.getName()))
{
Class typesExtra = SmallGroupImpl.class;
Object[] idsExtra = {objectId};
CacheController.clearCache(typesExtra, idsExtra);
}
else if(Class.forName(className).getName().equals(PublicationImpl.class.getName()))
{
logger.info("**************************************");
logger.info("* HERE THE MAGIC SHOULD HAPPEN *");
logger.info("**************************************");
PublicationVO publicationVO = PublicationController.getController().getPublicationVO(new Integer(objectId));
if(publicationVO != null)
{
AssetCleanerThread assetCleaningThread = new AssetCleanerThread();
List publicationDetailVOList = PublicationController.getController().getPublicationDetailVOList(new Integer(objectId));
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(publicationDetailVO.getEntityClass().indexOf("pageCache") > -1)
{
logger.info("publicationDetailVO.getEntityClass():" + publicationDetailVO.getEntityClass());
if(publicationDetailVO.getEntityClass().indexOf("pageCache:") == 0)
{
String groupQualifyer = publicationDetailVO.getEntityClass().substring("pageCache:".length());
logger.info("This is a application pageCache-clear request... specific:" + groupQualifyer);
CacheController.clearCaches(publicationDetailVO.getEntityClass(), "" + publicationDetailVO.getEntityId(), null);
}
else
{
CacheController.clearCaches("pageCache", "selectiveCacheUpdateNonApplicable", null);
}
//CacheController.clearCacheForGroup("pageCacheExtra", "selectiveCacheUpdateNonApplicable");
//CacheController.clearCacheForGroup("pageCache", "selectiveCacheUpdateNonApplicable");
}
else if(Class.forName(publicationDetailVO.getEntityClass()).getName().equals(ContentVersion.class.getName()))
{
logger.info("We clear all caches having references to contentVersion: " + publicationDetailVO.getEntityId());
try
{
Integer contentId = ContentVersionController.getContentVersionController().getContentIdForContentVersion(publicationDetailVO.getEntityId());
ContentVO previousContentVO = ContentController.getContentController().getContentVOWithId(contentId);
Integer previousParentContentId = previousContentVO.getParentContentId();
logger.info("previousParentContentId:" + previousParentContentId);
addCacheUpdateDirective(publicationDetailVO.getEntityClass(), publicationDetailVO.getEntityId().toString(), allIGCacheCalls);
//CacheController.clearCaches(publicationDetailVO.getEntityClass(), publicationDetailVO.getEntityId().toString(), null);
CacheController.clearCache(SmallContentVersionImpl.class, new Integer[]{new Integer(publicationDetailVO.getEntityId())});
CacheController.clearCache(SmallestContentVersionImpl.class, new Integer[]{new Integer(publicationDetailVO.getEntityId())});
logger.info("We clear all small contents as well " + contentId);
CacheController.clearCache(ContentImpl.class, new Integer[]{contentId});
CacheController.clearCache(SmallContentImpl.class, new Integer[]{contentId});
CacheController.clearCache(SmallishContentImpl.class, new Integer[]{contentId});
CacheController.clearCache(MediumContentImpl.class, new Integer[]{contentId});
CacheController.clearCache(SmallSiteNodeVersionImpl.class, new Integer[]{new Integer(objectId)});
logger.info("Handling parents....");
ContentVO contentVOAfter = ContentController.getContentController().getContentVOWithId(contentId);
Integer currentParentContentId = contentVOAfter.getParentContentId();
logger.info("previousParentContentId:" + previousParentContentId);
logger.info("currentParentContentId:" + currentParentContentId);
logger.info("We should also clear the parents...");
if(currentParentContentId != null)
{
logger.info("contentVOAfter - clear the new:" + contentVOAfter.getName() + " / " + currentParentContentId);
//CacheController.clearCaches(Content.class.getName(), currentParentContentId.toString(), null);
addCacheUpdateDirective(Content.class.getName(), currentParentContentId.toString(), allIGCacheCalls);
logger.info("We clear all small siteNodes as well " + currentParentContentId);
CacheController.clearCache(ContentImpl.class, new Integer[]{currentParentContentId});
CacheController.clearCache(SmallContentImpl.class, new Integer[]{currentParentContentId});
CacheController.clearCache(SmallishContentImpl.class, new Integer[]{currentParentContentId});
CacheController.clearCache(MediumContentImpl.class, new Integer[]{currentParentContentId});
}
if(currentParentContentId != null && previousParentContentId != null && !previousParentContentId.equals(previousParentContentId))
{
logger.info("contentVOAfter - clear the new:" + contentVOAfter.getName() + " / " + currentParentContentId);
//CacheController.clearCaches(Content.class.getName(), previousParentContentId.toString(), null);
addCacheUpdateDirective(Content.class.getName(), previousParentContentId.toString(), allIGCacheCalls);
logger.info("We clear all small siteNodes as well " + previousParentContentId);
CacheController.clearCache(ContentImpl.class, new Integer[]{previousParentContentId});
CacheController.clearCache(SmallContentImpl.class, new Integer[]{previousParentContentId});
CacheController.clearCache(SmallishContentImpl.class, new Integer[]{previousParentContentId});
CacheController.clearCache(MediumContentImpl.class, new Integer[]{previousParentContentId});
}
if (publicationDetailVO.getTypeId().equals(PublicationDetailVO.UNPUBLISH_LATEST))
{
assetCleaningThread.addContentVersion(publicationDetailVO.getEntityId());
}
}
catch(Exception e)
{
logger.warn("An error occurred handling content version from publication " + publicationVO.getId() + ":" + e.getMessage());
}
}
else if(Class.forName(publicationDetailVO.getEntityClass()).getName().equals(SiteNodeVersion.class.getName()))
{
System.out.println("SiteNodeVersion update....:" + publicationDetailVO.getEntityId());
try
{
SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(publicationDetailVO.getEntityId());
//logger.info("siteNodeVersionVO:" + siteNodeVersionVO.getId());
Integer siteNodeId = siteNodeVersionVO.getSiteNodeId();
CacheController.clearCache("pageCacheLatestSiteNodeVersions", "" + siteNodeId);
String versionKey = "" + siteNodeId + "_" + CmsPropertyHandler.getOperatingMode() + "_siteNodeVersionVO";
CacheController.clearCache("latestSiteNodeVersionCache", versionKey);
logger.info("We also clear the meta info content..");
SiteNodeVO previousSiteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(siteNodeId);
Integer previousParentSiteNodeId = previousSiteNodeVO.getParentSiteNodeId();
//System.out.println("previousParentSiteNodeId:" + previousParentSiteNodeId);
Object previousParentSiteNodeIdCandidate = CacheController.getCachedObject("parentSiteNodeCache", "" + siteNodeId);
//System.out.println("previousParentSiteNodeIdCandidate:" + previousParentSiteNodeIdCandidate);
if(previousParentSiteNodeIdCandidate != null && !(previousParentSiteNodeIdCandidate instanceof NullObject))
previousParentSiteNodeId = ((SiteNodeVO)previousParentSiteNodeIdCandidate).getId();
//System.out.println("previousParentSiteNodeId:" + previousParentSiteNodeId);
//CacheController.clearCaches(publicationDetailVO.getEntityClass(), publicationDetailVO.getEntityId().toString(), null);
//if(siteNodeId != null)
// CacheController.clearCaches(SiteNode.class.getName(), siteNodeId.toString(), null);
logger.info("We clear all small siteNodes as well " + siteNodeId);
CacheController.clearCache(SiteNodeImpl.class, new Integer[]{siteNodeId});
CacheController.clearCache(SmallSiteNodeImpl.class, new Integer[]{siteNodeId});
CacheController.clearCache(SmallSiteNodeVersionImpl.class, new Integer[]{new Integer(publicationDetailVO.getEntityId())});
logger.info("We clear all contents as well " + previousSiteNodeVO.getMetaInfoContentId());
Class metaInfoContentExtra = ContentImpl.class;
Object[] idsMetaInfoContentExtra = {previousSiteNodeVO.getMetaInfoContentId()};
CacheController.clearCache(metaInfoContentExtra, idsMetaInfoContentExtra);
logger.info("We clear all small contents as well " + previousSiteNodeVO.getMetaInfoContentId());
Class metaInfoContentExtraSmall = SmallContentImpl.class;
CacheController.clearCache(metaInfoContentExtraSmall, idsMetaInfoContentExtra);
logger.info("We clear all smallish contents as well " + previousSiteNodeVO.getMetaInfoContentId());
Class metaInfoContentExtraSmallish = SmallishContentImpl.class;
CacheController.clearCache(metaInfoContentExtraSmallish, idsMetaInfoContentExtra);
logger.info("We clear all medium contents as well " + previousSiteNodeVO.getMetaInfoContentId());
Class metaInfoContentExtraMedium = MediumContentImpl.class;
CacheController.clearCache(metaInfoContentExtraMedium, idsMetaInfoContentExtra);
//CacheController.clearCaches(ContentImpl.class.getName(), previousSiteNodeVO.getMetaInfoContentId().toString(), null);
addCacheUpdateDirective(ContentImpl.class.getName(), previousSiteNodeVO.getMetaInfoContentId().toString(), allIGCacheCalls);
Database db = CastorDatabaseService.getDatabase();
db.begin();
LanguageVO masterLanguageVO = LanguageController.getController().getMasterLanguage(previousSiteNodeVO.getRepositoryId(), db);
ContentVersionVO metaInfoContentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(previousSiteNodeVO.getMetaInfoContentId(), masterLanguageVO.getId(), db);
addCacheUpdateDirective(ContentVersionImpl.class.getName(), metaInfoContentVersionVO.getId().toString(), allIGCacheCalls);
List contentVersionIds = new ArrayList();
if(previousSiteNodeVO.getMetaInfoContentId() != null)
{
List<SmallestContentVersionVO> contentVersionVOList = ContentVersionController.getContentVersionController().getSmallestContentVersionVOList(previousSiteNodeVO.getMetaInfoContentId(), db);
for(SmallestContentVersionVO cvVO : contentVersionVOList)
{
contentVersionIds.add(cvVO.getId());
logger.info("We clear the meta info contentVersion " + cvVO.getId());
}
}
/*
Content content = ContentController.getContentController().getReadOnlyContentWithId(previousSiteNodeVO.getMetaInfoContentId(), db);
List contentVersionIds = new ArrayList();
Iterator contentVersionIterator = content.getContentVersions().iterator();
logger.info("Versions:" + content.getContentVersions().size());
while(contentVersionIterator.hasNext())
{
ContentVersion contentVersion = (ContentVersion)contentVersionIterator.next();
contentVersionIds.add(contentVersion.getId());
logger.info("We clear the meta info contentVersion " + contentVersion.getId());
}
*/
db.rollback();
db.close();
Iterator contentVersionIdsIterator = contentVersionIds.iterator();
logger.info("Versions:" + contentVersionIds.size());
while(contentVersionIdsIterator.hasNext())
{
Integer contentVersionId = (Integer)contentVersionIdsIterator.next();
logger.info("We clear the meta info contentVersion " + contentVersionId);
Class metaInfoContentVersionExtra = ContentVersionImpl.class;
Object[] idsMetaInfoContentVersionExtra = {contentVersionId};
CacheController.clearCache(metaInfoContentVersionExtra, idsMetaInfoContentVersionExtra);
//CacheController.clearCaches(ContentVersionImpl.class.getName(), contentVersionId.toString(), null);
//addCacheUpdateDirective(ContentVersionImpl.class.getName(), contentVersionId.toString(), allIGCacheCalls);
}
logger.info("After:" + contentVersionIds.size());
SiteNodeVersionVO previousSiteNodeVersionVO = SiteNodeVersionController.getController().getPreviousActiveSiteNodeVersionVO(siteNodeVersionVO.getSiteNodeId(), siteNodeVersionVO.getId(), new Integer(CmsPropertyHandler.getOperatingMode()));
//logger.info("previousSiteNodeVersionVO:" + previousSiteNodeVersionVO.getId());
addCacheUpdateDirective(publicationDetailVO.getEntityClass(), publicationDetailVO.getEntityId().toString(), allIGCacheCalls);
if(siteNodeId != null)
{
//logger.info("What really happened.... let's find out");
boolean anyRealDifferences = isThereAnyRealDifferencesBetweenSiteNodeVersions(siteNodeVersionVO, previousSiteNodeVersionVO);
//logger.info("anyRealDifferences:" + anyRealDifferences);
if(anyRealDifferences)
addCacheUpdateDirective(SiteNode.class.getName(), siteNodeId.toString(), allIGCacheCalls);
else
{
//logger.info("We'll skip it and assume that this was just a meta info update...");
}
}
//Handling access rights...
if(siteNodeVersionVO.getIsProtected().intValue() != SiteNodeVersionVO.INHERITED || (previousSiteNodeVersionVO != null && previousSiteNodeVersionVO.getIsProtected().intValue() != SiteNodeVersionVO.INHERITED))
{
CacheController.clearCache(AccessRightImpl.class);
CacheController.clearCache(AccessRightRoleImpl.class);
CacheController.clearCache(AccessRightGroupImpl.class);
CacheController.clearCache(AccessRightUserImpl.class);
CacheController.clearCache("personalAuthorizationCache");
}
logger.info("Handling parents....");
SiteNodeVO siteNodeVOAfter = SiteNodeController.getController().getSiteNodeVOWithId(siteNodeId);
Integer currentParentSiteNodeId = siteNodeVOAfter.getParentSiteNodeId();
//System.out.println("previousParentSiteNodeId:" + previousParentSiteNodeId);
//System.out.println("currentParentSiteNodeId:" + currentParentSiteNodeId);
logger.info("We should also clear the parents...");
if(currentParentSiteNodeId != null)
{
if(previousSiteNodeVersionVO == null)
{
//logger.info("Looks to be first version - let's update parent as well");
logger.info("siteNodeVOAfter - clear the new:" + siteNodeVOAfter.getName() + " / " + currentParentSiteNodeId);
addCacheUpdateDirective(SiteNode.class.getName(), currentParentSiteNodeId.toString(), allIGCacheCalls);
}
logger.info("We clear all small siteNodes as well " + currentParentSiteNodeId);
CacheController.clearCache(SiteNodeImpl.class, new Integer[]{currentParentSiteNodeId});
CacheController.clearCache(SmallSiteNodeImpl.class, new Integer[]{currentParentSiteNodeId});
}
if(currentParentSiteNodeId != null && previousParentSiteNodeId != null && !previousParentSiteNodeId.equals(currentParentSiteNodeId))
{
System.out.println("siteNodeVOAfter was not the same - lets clear the old:" + siteNodeVOAfter.getName() + " / " + currentParentSiteNodeId);
//CacheController.clearCaches(SiteNode.class.getName(), previousParentSiteNodeId.toString(), null);
addCacheUpdateDirective(SiteNode.class.getName(), currentParentSiteNodeId.toString(), allIGCacheCalls);
addCacheUpdateDirective(SiteNode.class.getName(), previousParentSiteNodeId.toString(), allIGCacheCalls);
logger.info("We clear all small siteNodes as well " + previousParentSiteNodeId);
CacheController.clearCache(SiteNodeImpl.class, new Integer[]{previousParentSiteNodeId});
CacheController.clearCache(SmallSiteNodeImpl.class, new Integer[]{previousParentSiteNodeId});
}
if(publicationDetailVO.getTypeId().intValue() == PublicationDetailVO.MOVED.intValue())
CacheController.clearCache("childSiteNodesCache");
}
catch (Exception e)
{
logger.warn("An error occurred handling sitenode version from publication " + publicationVO.getId() + ":" + e.getMessage());
}
}
}
assetCleaningThread.startIfNotEmpty();
}
else
{
long diff = System.currentTimeMillis() - cacheEvictionBean.getReceivedTimestamp();
if(diff < 1000*60)
{
processedInterupted = true;
logger.warn("Could not find publication in database. It may be a replication delay issue - lets try again.");
synchronized(CacheController.notifications)
{
CacheController.notifications.add(cacheEvictionBean);
}
}
else
{
logger.warn("Could not find publication in database. It may be a replication delay issue but now it's been very long so we have to abort.");
}
}
}
long elapsedTime = t.getElapsedTime();
if(elapsedTime > 100)
logger.warn("Cleared all castor caches for " + className + ":" + objectId + " took");
for(Map<String,String> igCacheCall : allIGCacheCalls)
{
logger.info("Calling clear caches with:" + igCacheCall.get("className") + ":" + igCacheCall.get("objectId"));
CacheController.clearCaches(igCacheCall.get("className"), igCacheCall.get("objectId"), null);
elapsedTime = t.getElapsedTime();
if(elapsedTime > 100)
logger.warn("Clearing all caches for " + igCacheCall.get("className") + ":" + igCacheCall.get("objectId") + " took");
}
if(CmsPropertyHandler.getServerNodeProperty("recacheEntities", true, "false").equals("true"))
recacheEntities(cacheEvictionBean);
}
else if(!skipOriginalEntity)
{
/*
logger.info("Was notification message in selective live publication...");
logger.info("className:" + className);
logger.info("objectId:" + objectId);
logger.info("objectName:" + objectName);
logger.info("typeId:" + typeId);
*/
if(className.equals("ServerNodeProperties"))
{
logger.info("clearing InfoGlueAuthenticationFilter");
CacheController.clearServerNodeProperty(true);
logger.info("cleared InfoGlueAuthenticationFilter");
InfoGlueAuthenticationFilter.initializeProperties();
logger.info("initialized InfoGlueAuthenticationFilter");
logger.info("Shortening page stats");
RequestAnalyser.shortenPageStatistics();
logger.info("Updating all caches from SelectiveLivePublicationThread as this was a publishing-update\n\n\n");
//CacheController.clearCastorCaches();
String[] excludedCaches = CacheController.getPublicationPersistentCacheNames();
logger.info("clearing all except " + excludedCaches + " as we are in publish mode..\n\n\n");
CacheController.clearCaches(null, null, excludedCaches);
//logger.info("Recaching all caches as this was a publishing-update\n\n\n");
//CacheController.cacheCentralCastorCaches();
CacheController.clearCastorCaches();
logger.info("Cleared all castor caches...");
//logger.info("Finally clearing page cache and other caches as this was a publishing-update\n\n\n");
logger.info("Finally clearing page cache and some other caches as this was a publishing-update\n\n\n");
//CacheController.clearCache("ServerNodeProperties");
//CacheController.clearCache("serverNodePropertiesCache");
CacheController.clearCache("boundContentCache");
//CacheController.clearFileCaches("pageCache");
PageCacheHelper.getInstance().clearPageCache();
CacheController.clearCache("pageCache");
CacheController.clearCache("pageCacheExtra");
CacheController.clearCache("componentCache");
CacheController.clearCache("NavigationCache");
CacheController.clearCache("pagePathCache");
CacheController.clearCache("pageCacheParentSiteNodeCache");
CacheController.clearCache("pageCacheLatestSiteNodeVersions");
CacheController.clearCache("pageCacheSiteNodeTypeDefinition");
try
{
LuceneUsersController.getController().getUserCount(null);
}
catch (Exception e)
{
logger.error("Problem recaching users:" + e.getMessage());
}
}
else if(className.equalsIgnoreCase("PortletRegistry"))
{
logger.info("clearing portletRegistry");
CacheController.clearPortlets();
logger.info("cleared portletRegistry");
}
else if(className.indexOf("RepositoryImpl") > -1)
{
logger.info("clearing repo affecting stuff");
CacheController.clearServerNodeProperty(true);
Class repoClass = RepositoryImpl.class;
CacheController.clearCache(repoClass);
CacheController.clearCaches(repoClass.getName(), null, null);
CacheController.clearCache("repositoryCache");
CacheController.clearCache("masterRepository");
CacheController.clearCache("parentRepository");
CacheController.clearCache("componentPropertyCache");
//CacheController.clearFileCaches("pageCache");
PageCacheHelper.getInstance().clearPageCache();
CacheController.clearCache("pageCache");
CacheController.clearCache("pageCacheExtra");
CacheController.clearCache("componentCache");
CacheController.clearCache("NavigationCache");
CacheController.clearCache("pagePathCache");
URIMapperCache.getInstance().clear();
logger.info("cleared repo affecting stuff");
}
else
{
logger.info("This was an deviation: " + className);
Class type = Class.forName(className);
Object[] ids = {objectId};
CacheController.clearCache(type, ids);
CacheController.clearCache(type);
CacheController.clearCaches(className, objectId, null);
logger.info("Clearing content types and repos");
Class ctdClass = ContentTypeDefinitionImpl.class;
CacheController.clearCache("contentTypeDefinitionCache");
CacheController.clearCache(ctdClass);
CacheController.clearCaches(ctdClass.getName(), null, null);
Class repoClass = RepositoryImpl.class;
CacheController.clearCache("repositoryCache");
CacheController.clearCache("masterRepository");
CacheController.clearCache(repoClass);
CacheController.clearCaches(repoClass.getName(), null, null);
Class categoryClass = CategoryImpl.class;
CacheController.clearCache("categoryCache");
CacheController.clearCache(categoryClass);
CacheController.clearCaches(categoryClass.getName(), null, null);
}
for(Map<String,String> igCacheCall : allIGCacheCalls)
{
if(igCacheCall.get("className") == null || !igCacheCall.get("className").equals("ServerNodeProperties"))
{
logger.info("Calling clear caches with:" + igCacheCall.get("className") + ":" + igCacheCall.get("objectId"));
CacheController.clearCaches(igCacheCall.get("className"), igCacheCall.get("objectId"), null);
}
}
}
}
catch (Exception e)
{
logger.error("An error occurred handling cache eviction bean in SelectiveLivePublicationThread:" + e.getMessage());
logger.warn("An error occurred handling cache eviction bean in SelectiveLivePublicationThread:" + e.getMessage(), e);
}
finally
{
//TODO
CacheEvictionBeanListenerService.getService().notifyListeners(cacheEvictionBean);
RequestAnalyser.getRequestAnalyser().removeOngoingPublications(cacheEvictionBean);
if(!processedInterupted)
{
cacheEvictionBean.setProcessed();
if(cacheEvictionBean.getPublicationId() > -1 || cacheEvictionBean.getClassName().equals("ServerNodeProperties"))
RequestAnalyser.getRequestAnalyser().addPublication(cacheEvictionBean);
}
}
}
}