1 23 package org.infoglue.deliver.util; 24 25 import java.util.ArrayList ; 26 import java.util.Iterator ; 27 import java.util.List ; 28 29 import org.apache.log4j.Logger; 30 import org.exolab.castor.jdo.Database; 31 import org.infoglue.cms.controllers.kernel.impl.simple.CastorDatabaseService; 32 import org.infoglue.cms.entities.content.impl.simple.ContentImpl; 33 import org.infoglue.cms.entities.content.impl.simple.DigitalAssetImpl; 34 import org.infoglue.cms.entities.content.impl.simple.MediumContentImpl; 35 import org.infoglue.cms.entities.content.impl.simple.SmallContentImpl; 36 import org.infoglue.cms.entities.management.impl.simple.AvailableServiceBindingImpl; 37 import org.infoglue.cms.entities.management.impl.simple.GroupImpl; 38 import org.infoglue.cms.entities.management.impl.simple.RoleImpl; 39 import org.infoglue.cms.entities.management.impl.simple.SmallAvailableServiceBindingImpl; 40 import org.infoglue.cms.entities.management.impl.simple.SystemUserImpl; 41 import org.infoglue.cms.entities.publishing.impl.simple.PublicationDetailImpl; 42 import org.infoglue.cms.entities.structure.impl.simple.SiteNodeImpl; 43 import org.infoglue.cms.entities.structure.impl.simple.SmallSiteNodeImpl; 44 import org.infoglue.cms.util.CmsPropertyHandler; 45 import org.infoglue.cms.util.NotificationMessage; 46 import org.infoglue.deliver.applications.databeans.CacheEvictionBean; 47 import org.infoglue.deliver.controllers.kernel.impl.simple.DigitalAssetDeliveryController; 48 49 55 public class WorkingPublicationThread extends Thread 56 { 57 public final static Logger logger = Logger.getLogger(WorkingPublicationThread.class.getName()); 58 59 private List cacheEvictionBeans = new ArrayList (); 60 61 public WorkingPublicationThread() 62 { 63 } 64 65 public List getCacheEvictionBeans() 66 { 67 return cacheEvictionBeans; 68 } 69 70 public void run() 71 { 72 System.out.println("Hepp..."); 73 74 work(); 75 } 76 77 78 public void work() 79 { 80 83 logger.info("cacheEvictionBeans.size:" + cacheEvictionBeans.size() + ":" + RequestAnalyser.getRequestAnalyser().getBlockRequests()); 84 if(cacheEvictionBeans.size() > 0) 85 { 86 89 91 try 92 { 93 95 97 100 Iterator i = cacheEvictionBeans.iterator(); 101 while(i.hasNext()) 102 { 103 CacheEvictionBean cacheEvictionBean = (CacheEvictionBean)i.next(); 104 String className = cacheEvictionBean.getClassName(); 105 String objectId = cacheEvictionBean.getObjectId(); 106 String objectName = cacheEvictionBean.getObjectName(); 107 String typeId = cacheEvictionBean.getTypeId(); 108 109 logger.info("className:" + className); 110 logger.info("objectId:" + objectId); 111 logger.info("objectName:" + objectName); 112 logger.info("typeId:" + typeId); 113 114 boolean isDependsClass = false; 115 if(className != null && className.equalsIgnoreCase(PublicationDetailImpl.class.getName())) 116 isDependsClass = true; 117 118 CacheController.clearCaches(className, objectId, null); 119 120 logger.info("Updating className with id:" + className + ":" + objectId); 121 if(className != null && !typeId.equalsIgnoreCase("" + NotificationMessage.SYSTEM)) 122 { 123 Class type = Class.forName(className); 124 125 if(!isDependsClass && className.equalsIgnoreCase(SystemUserImpl.class.getName()) || className.equalsIgnoreCase(RoleImpl.class.getName()) || className.equalsIgnoreCase(GroupImpl.class.getName())) 126 { 127 Object [] ids = {objectId}; 128 CacheController.clearCache(type, ids); 129 } 130 else if(!isDependsClass) 131 { 132 Object [] ids = {new Integer (objectId)}; 133 CacheController.clearCache(type, ids); 134 } 135 136 if(Class.forName(className).getName().equals(ContentImpl.class.getName())) 138 { 139 logger.info("We clear all small contents as well " + objectId); 140 Class typesExtra = SmallContentImpl.class; 141 Object [] idsExtra = {new Integer (objectId)}; 142 CacheController.clearCache(typesExtra, idsExtra); 143 144 logger.info("We clear all medium contents as well " + objectId); 145 Class typesExtraMedium = MediumContentImpl.class; 146 Object [] idsExtraMedium = {new Integer (objectId)}; 147 CacheController.clearCache(typesExtraMedium, idsExtraMedium); 148 } 149 else if(Class.forName(className).getName().equals(AvailableServiceBindingImpl.class.getName())) 150 { 151 Class typesExtra = SmallAvailableServiceBindingImpl.class; 152 Object [] idsExtra = {new Integer (objectId)}; 153 CacheController.clearCache(typesExtra, idsExtra); 154 } 155 else if(Class.forName(className).getName().equals(SiteNodeImpl.class.getName())) 156 { 157 Class typesExtra = SmallSiteNodeImpl.class; 158 Object [] idsExtra = {new Integer (objectId)}; 159 CacheController.clearCache(typesExtra, idsExtra); 160 } 161 else if(Class.forName(className).getName().equals(DigitalAssetImpl.class.getName())) 162 { 163 logger.info("We should delete all images with digitalAssetId " + objectId); 164 DigitalAssetDeliveryController.getDigitalAssetDeliveryController().deleteDigitalAssets(new Integer (objectId)); 165 } 166 logger.info("4"); 167 } 168 } 169 } 170 catch (Exception e) 171 { 172 logger.error("An error occurred in the WorkingPublicationThread:" + e.getMessage(), e); 173 } 174 188 } 189 190 RequestAnalyser.getRequestAnalyser().setBlockRequests(false); 191 logger.info("released block"); 192 } 193 } 194 | Popular Tags |