1 23 package org.infoglue.deliver.util; 24 25 import org.apache.log4j.Logger; 26 import org.infoglue.cms.util.CmsPropertyHandler; 27 28 34 public class PublicationThread extends Thread 35 { 36 37 public final static Logger logger = Logger.getLogger(PublicationThread.class.getName()); 38 39 public synchronized void run() 40 { 41 logger.info("setting block"); 42 RequestAnalyser.getRequestAnalyser().setBlockRequests(true); 43 44 try 45 { 46 int publicationDelay = 5000; 47 String publicationThreadDelay = CmsPropertyHandler.getPublicationThreadDelay(); 48 if(publicationThreadDelay != null && !publicationThreadDelay.equalsIgnoreCase("") && publicationThreadDelay.indexOf("publicationThreadDelay") == -1) 49 publicationDelay = Integer.parseInt(publicationThreadDelay); 50 51 logger.info("\n\n\nSleeping " + publicationDelay + "ms.\n\n\n"); 52 sleep(publicationDelay); 53 54 logger.info("\n\n\nUpdating all caches as this was a publishing-update\n\n\n"); 55 CacheController.clearCastorCaches(); 56 57 logger.info("\n\n\nclearing all except page cache as we are in publish mode..\n\n\n"); 58 CacheController.clearCaches(null, null, new String [] {"pageCache", "NavigationCache", "pagePathCache", "userCache", "pageCacheParentSiteNodeCache", "pageCacheLatestSiteNodeVersions", "pageCacheSiteNodeTypeDefinition"}); 59 60 logger.info("\n\n\nRecaching all caches as this was a publishing-update\n\n\n"); 61 CacheController.cacheCentralCastorCaches(); 62 63 logger.info("\n\n\nFinally clearing page cache and other caches as this was a publishing-update\n\n\n"); 64 CacheController.clearCache("pageCache"); 65 CacheController.clearCache("NavigationCache"); 66 CacheController.clearCache("pagePathCache"); 67 CacheController.clearCache("pageCacheParentSiteNodeCache"); 68 CacheController.clearCache("pageCacheLatestSiteNodeVersions"); 69 CacheController.clearCache("pageCacheSiteNodeTypeDefinition"); 70 71 CacheController.renameCache("newPagePathCache", "pagePathCache"); 72 } 73 catch (Exception e) 74 { 75 logger.error("An error occurred in the PublicationThread:" + e.getMessage(), e); 76 } 77 78 logger.info("released block \n\n DONE---"); 79 RequestAnalyser.getRequestAnalyser().setBlockRequests(false); 80 81 } 82 } 83 | Popular Tags |