1 23 24 25 package org.infoglue.cms.applications.cmstool.actions; 26 27 import org.apache.log4j.Logger; 28 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 29 import org.infoglue.cms.applications.common.actions.SimpleXmlServiceAction; 30 import org.infoglue.cms.entities.content.impl.simple.ContentImpl; 31 import org.infoglue.cms.entities.content.impl.simple.SmallContentImpl; 32 import org.infoglue.cms.entities.management.impl.simple.ContentTypeDefinitionImpl; 33 import org.infoglue.cms.entities.management.impl.simple.InterceptionPointImpl; 34 import org.infoglue.cms.entities.management.impl.simple.InterceptorImpl; 35 import org.infoglue.cms.entities.management.impl.simple.RepositoryImpl; 36 import org.infoglue.deliver.util.CacheController; 37 38 39 46 47 public class UpdateCacheAction extends InfoGlueAbstractAction 48 { 49 private final static Logger logger = Logger.getLogger(UpdateCacheAction.class.getName()); 50 51 private static final long serialVersionUID = -1669612689042389758L; 52 53 private String className = null; 54 private String objectId = null; 55 private String objectName = null; 56 private String typeId = null; 57 58 private String repositoryName = null; 59 private Integer languageId = null; 60 private Integer siteNodeId = null; 61 62 private static boolean cachingInProgress = false; 63 64 67 68 public UpdateCacheAction() 69 { 70 71 } 72 73 76 77 public String doTest() throws Exception 78 { 79 this.getResponse().getWriter().println("test ok - cache action available"); 80 return NONE; 81 } 82 83 87 88 public String doExecute() throws Exception 89 { 90 try 91 { 92 CacheController.clearCaches(className, objectId, null); 93 94 logger.info("Updating className with id:" + className + ":" + objectId); 95 96 if(className != null) 97 { 98 Class types = Class.forName(className); 99 Object [] ids = {new Integer (objectId)}; 100 101 CacheController.clearCache(types, ids); 102 103 111 112 if(Class.forName(className).getName().equals(ContentImpl.class.getName())) 114 { 115 CacheController.clearCache(SmallContentImpl.class, new Object []{new Integer (objectId)}); 116 } 117 118 if(Class.forName(className).getClass().getName().equals(RepositoryImpl.class.getName())) 119 { 120 CacheController.clearCache("repositoryCache"); 121 } 122 else if(Class.forName(className).getClass().getName().equals(InterceptionPointImpl.class.getName())) 123 { 124 CacheController.clearCache("interceptionPointCache"); 125 CacheController.clearCache("interceptorsCache"); 126 } 127 else if(Class.forName(className).getClass().getName().equals(InterceptorImpl.class.getName())) 128 { 129 CacheController.clearCache("interceptionPointCache"); 130 CacheController.clearCache("interceptorsCache"); 131 } 132 else if(Class.forName(className).getClass().getName().equals(ContentTypeDefinitionImpl.class.getName())) 133 { 134 CacheController.clearCache("contentTypeDefinitionCache"); 135 } 136 else if(Class.forName(className).getClass().getName().equals(ContentImpl.class.getName())) 137 { 138 CacheController.clearCache("childContentCache"); 139 } 140 146 } 147 } 148 catch(Exception e) 149 { 150 logger.error(e.getMessage(), e); 151 } 152 153 return "success"; 154 } 155 156 157 160 161 public String doInput() throws Exception 162 { 163 return "input"; 164 } 165 166 167 170 171 public void setClassName(String className) 172 { 173 this.className = className; 174 } 175 176 public void setObjectId(String objectId) 177 { 178 this.objectId = objectId; 179 } 180 181 public void setObjectName(String objectName) 182 { 183 this.objectName = objectName; 184 } 185 186 public void setTypeId(String typeId) 187 { 188 this.typeId = typeId; 189 } 190 191 } 192 | Popular Tags |