KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > deliver > util > PublicationThread


1 /* ===============================================================================
2 *
3 * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4 *
5 * ===============================================================================
6 *
7 * Copyright (C)
8 *
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License version 2, as published by the
11 * Free Software Foundation. See the file LICENSE.html for more information.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19 * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20 *
21 * ===============================================================================
22 */

23 package org.infoglue.deliver.util;
24
25 import org.apache.log4j.Logger;
26 import org.infoglue.cms.util.CmsPropertyHandler;
27
28 /**
29  * @author mattias
30  *
31  * TODO To change the template for this generated type comment go to
32  * Window - Preferences - Java - Code Style - Code Templates
33  */

34 public class PublicationThread extends Thread JavaDoc
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 JavaDoc 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 JavaDoc[] {"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 JavaDoc 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